- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- grep dates on snmp collected data
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-08-2003 05:18 AM
тАО12-08-2003 05:18 AM
grep dates on snmp collected data
I use egrep to grep on data of the format below
10/11/2003 00:00 299 0.43 0.45 140.54 68.34 72.2 32
11/11/2003 00:05 301 0.25 0.34 93.56 39.77 53.78 28
12/11/2003 00:10 300 0.34 0.37 113.91 54.08 59.83 32
1) To see all data for just a certain day I usually do
grep '^10/.*/2003'
2)to see all data for some days I usually do
egrep -e '11/.*/2003' -e '12/.*/2003' snmp.log
Now if I want to see the all data for example from 10/11/2003 - 15/11/2003 how would this be done with awk, egrep or sed.
My main aim is to see/filter all data in a snmp log file just for mondays-fridays and omitting all the weekend dates.
Any help or advice will be greatly appreciated.
regards,
seun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-08-2003 06:32 AM
тАО12-08-2003 06:32 AM
Re: grep dates on snmp collected data
egrep '^1[0-5]/.*/2003' snmp.log
will get the 10th to the 15th.
If you reallz want to know Mo to Fr I suggest you write a little Perl program to get the weekday of a given date and the take it from there.
Greetings, Martin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-08-2003 09:22 AM
тАО12-08-2003 09:22 AM
Re: grep dates on snmp collected data
As all the entires should be in sequential date/time order, it should be easy to do a simple check against the first field and print it if it exceeds the given date pair provided.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-09-2003 12:16 AM
тАО12-09-2003 12:16 AM
Re: grep dates on snmp collected data
for example, taking your first date of 10/11/2003 you reverse the date and take a mod 7
20031110%7 which gives you 1, so that date is a Monday.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-09-2003 05:36 AM
тАО12-09-2003 05:36 AM
Re: grep dates on snmp collected data
as for a Perl solution, you could have a look at the Date::Manip module, which does provide the handy Date_IsWorkDay function for such purposes...
Greetings, Martin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-09-2003 06:25 PM
тАО12-09-2003 06:25 PM
Re: grep dates on snmp collected data
[diciu@bluefish diciu]$ cat tt
10/11/2003 00:00 299 0.43 0.45 140.54 68.34 72.2 32
11/11/2003 00:05 301 0.25 0.34 93.56 39.77 53.78 28
12/11/2003 00:10 300 0.34 0.37 113.91 54.08 59.83 32
[diciu@bluefish diciu]$ cat tt.sh
cat tt | while read sw
do
weekday=`echo $sw | cut -b0-10 | xargs date +%a -d `
ismatch=`echo $weekday | egrep -v "(^Sun$)|(^Sat$)"`
if [ "$ismatch" ]; then
echo $sw
fi
done
[diciu@bluefish diciu]$ sh tt.sh
11/11/2003 00:05 301 0.25 0.34 93.56 39.77 53.78 28
12/11/2003 00:10 300 0.34 0.37 113.91 54.08 59.83 32
tt is the data file.
tt.sh is the filter script (also attached in case the forum eats special characters).