[Nagiosplug-devel] Fix for check_nagios plugin with Nagios 2.03b

Scott Greenman greenmanse at ldschurch.org
Mon Jul 11 11:58:25 CEST 2005


Hi list



I just started using nagios2.03b with the latest plugins, and found
 that the check_nagios plugin wasn't correctly computing the time
 since last update of the status log. I found several people who
 had reported this problem on the nagiosplug-help list, but no responses.
 I tweaked the plugin code and it seems to work correctly now. I
 don't know how to go about contributing this change to the community,
 so I'm just posting a diff here and if someone more in the know
 wants to pick it up, great....



The problem is a difference between the status log file formats
 between versions of Nagios. I have no idea in what version of Nagios
 this change occurred. Implimenting this change will fix  the plugin
 for Nagios 2.0b3, but will break it for earlier versions. Ultimately
 it seems that two different plugins are needed, or one plugin that
 has a flag to indicate which Nagios verison or can check the Nagios
 version itself.



Here's the diff:



*** plugins/check_nagios.c      Sat Dec 25 16:17:44 2004

--- ~plugins/check_nagios.c    Mon Jul 11 10:20:22 2005

***************

*** 84,96 ****

                return STATE_CRITICAL;

        }



        /* get the date/time of the last item updated in the log
 */

        while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, fp)) {

!               temp_ptr = strtok (input_buffer, "]");

!               temp_entry_time =

!                       (temp_ptr == NULL) ? 0L : strtoul (temp_ptr
 + 1, NULL, 10);

!               if (temp_entry_time > latest_entry_time)

!                       latest_entry_time = temp_entry_time;

        }

        fclose (fp);



--- 84,98 ----

                return STATE_CRITICAL;

        }



+       const char *tag = "created=";

+

        /* get the date/time of the last item updated in the log
 */

        while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, fp)) {

!               temp_ptr = strstr (input_buffer, tag);

!               if (temp_ptr != NULL) {

!                       latest_entry_time = strtoul (temp_ptr
 + strlen(tag), NULL, 10);

!                       break;

!               }

        }

        fclose (fp);







Cheers...



- Scott Greenman (sgreenman)



-----------------------

The mailing list archive is found here:

http://www.nagiosexchange.org/nagiosplug-devel.31.0.html

				




More information about the Devel mailing list