03-06-2013 02:38 AM
Need a script to check whether system logs are updating .
I have a perl one liner here , from this forum only to check in last 1 hour ;
perl -le 'exit 1 if -M "/var/opt/resmon/log/event.log" > 3600/86400'
But its not working ; my event.log file is not updated for last 3 months , still it doent throw any error.
Any reason why is it so ?
Solved! Go to Solution.
03-07-2013 10:30 AM
The fact that your event log is not changing is not necessarily a bad thing. It means that EMS is not detecting any events that it needs to notify you about.
If you want to send a test event to EMS to verify that an event will get logged in that file you can do:
# /etc/opt/resmon/lbin/send_test_event -v disk_em
Then check the /var/opt/resmon/log/event.log file to see if it has the test event. You can also just view this file via 'vi' or 'more' as it is a plain ASCII text file.
03-07-2013 09:26 PM
Hi Patrick ,
Its not about event log not getting updated.
What am saying is the perl liner given above should exit with value 1right , if the event.log is not updated in last 1 hr ?
Its not throwing me value of 1.
03-08-2013 12:53 AM
Your one-liner will never produce any output. Instead, it will set its return value to 1 if the condition is true.
In other words, it should work like this:
# perl -le 'exit 1 if -M "/var/opt/resmon/log/event.log" > 3600/86400' # echo $? 1
The return value is often easier to handle in scripts than explicitly catching and interpreting the output. For example, you might do something like this:
#!/bin/sh if perl -le 'exit 1 if -M "/var/opt/resmon/log/event.log" > 3600/86400' then echo "No new events within the last hour" else echo "A new event has been received within the last hour" fi