Nagios freshness checks randomly think check results are from 1973.

fevin Kagen fevinkagen at gmail.com
Wed Aug 13 14:01:07 CEST 2008


Problem solved!  We were 100% last night and, after a little testing, I
found the smoking gun...

A time stamp of 1218611709 = 8/13/2008 07:15:09

loose the last number and, you guessed it, 11/11/1973 20:19:30!

Thanks for the extra effort Thomas!

On Tue, Aug 12, 2008 at 12:31 PM, fevin Kagen <fevinkagen at gmail.com> wrote:

> Thanks!  That seems like it just may be the ticket.  I have enabled the
> debug output and changed the time calculation to > mytime =
> str(int(time.time()))
>
> So far so good, but the real test will be over the next few nights.  I'll
> keep you guys posted.  Thanks again for all the help!
>
>
> On Tue, Aug 12, 2008 at 2:17 AM, Thomas Guyot-Sionnest <dermoth at aei.ca>wrote:
>
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> On 11/08/08 11:23 PM, Thomas Guyot-Sionnest wrote:
>> > On 11/08/08 04:57 PM, fevin Kagen wrote:
>> >> So...    is a date sent in the SNMP trap or is the date set to the
>> >> time that Nagios receives the alert?
>> >
>> > It's in the command sent to the Nagios command pipe.
>> >
>> > See:
>> >
>> > http://nagios.sourceforge.net/docs/3_0/extcommands.html
>> > http://www.nagios.org/developerinfo/externalcommands/commandlist.php
>> >
>> >> Is there a way to output to both the existing output (the nagios
>> >> command file) and a debug output?  It doesn't happen all the time so
>> >> trying to capture a bad entry would mean taking the whole system down
>> >> for a week plus.
>> >
>> > I never touched python before, but looks plain simple object-oriented
>> > programming. I'd try making the post_results function looks like this:
>> >
>> > def post_results(host, job, mondata_res, return_code):
>> >       mytime = time.time()
>> >       mytime = str(mytime)
>> >       mytime = mytime[:-3]
>> >       #print mondata_res
>> >       output = open('/usr/local/nagios/var/rw/nagios.cmd', 'w')
>> >       debug_out = open('/tmp/services-debug.out, 'a')
>> >       results = "[" + mytime + "] " + "PROCESS_SERVICE_CHECK_RESULT;" \
>> >         + host + ";" + job + ";" \
>> >         + return_code + ";" + mondata_res + "\n"
>> >       output.write(results)
>> >       debug_out.write(results)
>> >
>> > The change are oppening a 2nd file in append mode:
>> >   debug_out = open('/tmp/services-debug.out, 'a')
>> >
>> > And then writing the same thing as the nagios out to it:
>> >   debug_out.write(results)
>> >
>> > As soon as it fails check the end of that file, you should see the same
>> > thing as what nagios received. If the [time] part is the problem thoug I
>> > can't really help. This is the part that generated the time part:
>> >
>> >   mytime = time.time()
>> >   mytime = str(mytime)
>> >   mytime = mytime[:-3]
>> >
>>
>> Well, python is a language I wouldn't refuse to learn, and I just
>> started looking at it. On the fun side there's an interactive mode that
>> let you learn as you try live...
>>
>> After a few minutes of reading http://docs.python.org/tut/ ...
>>
>> - From what I understand in the above commands, time.time() returns you a
>> float object that returns unix time with two decimals, ex:
>> 1218520859.75.  In this plugin the author strips the last three
>> characters from the string'ified value ([:-3] to get a normal timestamp.
>> Whenever the time is rounded (ex: 1218520859.7, 1218520859.0) this
>> strips too many characters and you get a date far in the past.
>>
>> The proper way to do it is simply by converting it to an integer, i.e.
>> replace the three lines above with:
>>
>> mytime = str(int(time.time()))
>>
>> Since I believe the str() was only to use the hooks on it, this probably
>> works as well:
>>
>> mytime = int(time.time())
>>
>> Hope this helps.
>>
>> - --
>> Thomas
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v1.4.6 (GNU/Linux)
>> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>>
>> iD8DBQFIoSr86dZ+Kt5BchYRAmZ5AJ9zH2akrPQfhsLhve74jgxtdicLjwCfWsIo
>> qt0WgLTig7uVQvf1JwYcCMA=
>> =KMAD
>> -----END PGP SIGNATURE-----
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/users/attachments/20080813/9749fc29/attachment.html>
-------------- next part --------------
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
-------------- next part --------------
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null


More information about the Users mailing list