- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: 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:17 AM
тАО12-08-2003 05:17 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 grately appreciated.
regards,
seun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-08-2003 05:29 AM
тАО12-08-2003 05:29 AM
Re: grep dates on snmp collected data
sed -n '/10\/11\/2002\/15\/11\/2003\/p' < input_file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-08-2003 05:29 AM
тАО12-08-2003 05:29 AM
Re: grep dates on snmp collected data
grep '^1[1-5]/.*/2003'
Or you can script it with a read statement and input the days you want to grep for... based upon your entry, assigned to a variable.
if i have time i can post a solution like that later.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-08-2003 07:34 AM
тАО12-08-2003 07:34 AM
Re: grep dates on snmp collected data
Thanks alo for your replies.
Todd - I would really appreciate it if you post a solution of the script that would do this(do it only if you have time). Thanks
Rac - Thanks I will be trying yours and Todds solution in a momment and il reply back.
Thanks guys
regards,
gab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-08-2003 09:17 AM
тАО12-08-2003 09:17 AM
Re: grep dates on snmp collected data
use Date::Calc;
$lower = Date_to_Days(2003,11,10);
$upper = Date_to_Days(2003,11,15);
open(INP,"
chomp;
($mydate)=split(" ",$_);
($day,$mth,$yr)=Decode_Date_EU($mydate);
$date = Date_to_Days($year,$month,$day);
$dow=day_of_week($yr,$mth,$day)
next if $dow >= 6; # skip SAT,SUN
next if $date < $lower || $date > $upper;
print $_,"\n";
}
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-08-2003 11:38 PM
тАО12-08-2003 11:38 PM
Re: grep dates on snmp collected data
her is my solution.
greetings,
Michael
#!/bin/ksh
while read LINE
do
DATE=`echo ${LINE} | cut -c 1-10`
DOW=`./timeconv "${LINE}" "%d/%m/%Y"|awk '{printf("%s"),$7}'`
if ([[ ${DOW} -gt 0 && ${DOW} -lt 6 ]])
then
echo ${LINE}
fi
done < logfile
timeconv.c
#include
#include
main(argc,arg)
int argc;
char **arg;
{
struct tm t;
if (argc!=3)
{
printf("Usage: arg[0] date datefmt(see man strptime)\n");
return(2);
};
strptime(arg[1],arg[2], &t);
printf("%2d %2d %2d %2d %2d %1d %3d %1d",t.tm_sec,t.tm_min,t.tm_hour,t.tm_mday
,t.tm_mon,t.tm_year,t.tm_wday,t.tm_yday,t.tm_isdst);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-19-2004 04:40 AM
тАО01-19-2004 04:40 AM
Re: grep dates on snmp collected data
i am a new HPOV admin. and just saw some answers to some questions i had which you had replied to and ws beneficial.
thinking i might be able to have a mentor in you. touch base with me, geniusaceb_j@msn.com
i am based here in texas USA.
BAYO