SNMP time reporting

Hi,

First post, please bare with me.

I am currently using SNMP on Nagios to monitor Exim and all is running great with the exception to it picking up the date / time of the last Exim queue run.

What I am hoping to achieve is for SNMP / Nagios to correctly pickup the difference between the current time and the last queue run.

I am using the below to capture the date / time value ;

 hostname-f:/etc/snmp# cat /var/log/exim4/mainlog|grep "End queue run"|tail -n1|awk '{ print $1, $2 }'
2008-05-22 10:42:58 

However, when I check the snmp, it only takes the first value from the time (: works as a break);

bash-2.05# ./check_snmp -H xxx.xxx.xx.xx -o .1.3.6.1.4.1.8072.1.3.2.4.1.2.15.115.110.109.112.95.101.120.105.109.95.115.116.97.116.115.10 -w 10 -c 20
SNMP OK - 10 

As you can see from my code above I am only trying to get it to display the last date / time as I have no idea where to start with subtracting the values.

Any further info required, give me a shout.

Many thanks in advance.

TheBlueProject

It's not perfect but I've found the below does the job.

Instead of doing a date and a time calculation (as I first simply thought of), it will work out the difference in seconds, then divides that by 60, thus displaying the difference in minutes.

$(( $(( $(( $(date --utc +%s)+3600)) - $(grep "End queue run" /var/log/exim4/mainlog |tail -n1|awk '{ print "date --utc --date \""$1" "$2"\" +%s" }'|sh) )) / 60 ))

:slight_smile: