<div dir="ltr">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()))<br><br>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!<br>
<br><div class="gmail_quote">On Tue, Aug 12, 2008 at 2:17 AM, Thomas Guyot-Sionnest <span dir="ltr"><<a href="mailto:dermoth@aei.ca">dermoth@aei.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">-----BEGIN PGP SIGNED MESSAGE-----<br>
Hash: SHA1<br>
<br>
</div><div><div></div><div class="Wj3C7c">On 11/08/08 11:23 PM, Thomas Guyot-Sionnest wrote:<br>
> On 11/08/08 04:57 PM, fevin Kagen wrote:<br>
>> So...    is a date sent in the SNMP trap or is the date set to the<br>
>> time that Nagios receives the alert?<br>
><br>
> It's in the command sent to the Nagios command pipe.<br>
><br>
> See:<br>
><br>
> <a href="http://nagios.sourceforge.net/docs/3_0/extcommands.html" target="_blank">http://nagios.sourceforge.net/docs/3_0/extcommands.html</a><br>
> <a href="http://www.nagios.org/developerinfo/externalcommands/commandlist.php" target="_blank">http://www.nagios.org/developerinfo/externalcommands/commandlist.php</a><br>
><br>
>> Is there a way to output to both the existing output (the nagios<br>
>> command file) and a debug output?  It doesn't happen all the time so<br>
>> trying to capture a bad entry would mean taking the whole system down<br>
>> for a week plus.<br>
><br>
> I never touched python before, but looks plain simple object-oriented<br>
> programming. I'd try making the post_results function looks like this:<br>
><br>
> def post_results(host, job, mondata_res, return_code):<br>
>       mytime = time.time()<br>
>       mytime = str(mytime)<br>
>       mytime = mytime[:-3]<br>
>       #print mondata_res<br>
>       output = open('/usr/local/nagios/var/rw/nagios.cmd', 'w')<br>
>       debug_out = open('/tmp/services-debug.out, 'a')<br>
>       results = "[" + mytime + "] " + "PROCESS_SERVICE_CHECK_RESULT;" \<br>
>         + host + ";" + job + ";" \<br>
>         + return_code + ";" + mondata_res + "\n"<br>
>       output.write(results)<br>
>       debug_out.write(results)<br>
><br>
> The change are oppening a 2nd file in append mode:<br>
>   debug_out = open('/tmp/services-debug.out, 'a')<br>
><br>
> And then writing the same thing as the nagios out to it:<br>
>   debug_out.write(results)<br>
><br>
> As soon as it fails check the end of that file, you should see the same<br>
> thing as what nagios received. If the [time] part is the problem thoug I<br>
> can't really help. This is the part that generated the time part:<br>
><br>
>   mytime = time.time()<br>
>   mytime = str(mytime)<br>
>   mytime = mytime[:-3]<br>
><br>
<br>
</div></div>Well, python is a language I wouldn't refuse to learn, and I just<br>
started looking at it. On the fun side there's an interactive mode that<br>
let you learn as you try live...<br>
<br>
After a few minutes of reading <a href="http://docs.python.org/tut/" target="_blank">http://docs.python.org/tut/</a> ...<br>
<br>
- From what I understand in the above commands, time.time() returns you a<br>
float object that returns unix time with two decimals, ex:<br>
1218520859.75.  In this plugin the author strips the last three<br>
characters from the string'ified value ([:-3] to get a normal timestamp.<br>
Whenever the time is rounded (ex: 1218520859.7, 1218520859.0) this<br>
strips too many characters and you get a date far in the past.<br>
<br>
The proper way to do it is simply by converting it to an integer, i.e.<br>
replace the three lines above with:<br>
<br>
mytime = str(int(time.time()))<br>
<br>
Since I believe the str() was only to use the hooks on it, this probably<br>
works as well:<br>
<br>
mytime = int(time.time())<br>
<br>
Hope this helps.<br>
<div class="Ih2E3d"><br>
- --<br>
Thomas<br>
-----BEGIN PGP SIGNATURE-----<br>
Version: GnuPG v1.4.6 (GNU/Linux)<br>
Comment: Using GnuPG with Mozilla - <a href="http://enigmail.mozdev.org" target="_blank">http://enigmail.mozdev.org</a><br>
<br>
</div>iD8DBQFIoSr86dZ+Kt5BchYRAmZ5AJ9zH2akrPQfhsLhve74jgxtdicLjwCfWsIo<br>
qt0WgLTig7uVQvf1JwYcCMA=<br>
=KMAD<br>
-----END PGP SIGNATURE-----<br>
</blockquote></div><br></div>