[nagiosplug] check_load: add alternative uptime syntax
"Nagios Plugin Development" <[email protected]> Sat, 14 Sep 2013 22:00:50 +0000
| Newsgroups | gmane.network.nagios.plugins.cvs |
|---|---|
| Message-ID | <[email protected]> |
Module: nagiosplug Branch: master Commit: c7d6730255aaf4d07db947e9f032bc0206bccbcb Author: Sven Nierlein <[email protected]> Date: Sat Sep 14 20:41:24 2013 +0200 URL: http://nagiosplug.git.sf.net/git/gitweb.cgi?p=nagiosplug/nagiosplug;a=commit;h=c7d6730 check_load: add alternative uptime syntax check_load parses load from the uptime command if no proc filesystem is available. Seems like there are at least 2 different uptime outputs. linux: 20:44:34 up 25 days, 2:07, 13 users, load average: 0.13, 0.17, 0.22 freebsd 8: 8:44PM up 4:29, 1 user, load averages: 0.00, 0.00, 0.00 --- plugins/check_load.c | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-) diff --git a/plugins/check_load.c b/plugins/check_load.c index 780ffff..296a823 100644 --- a/plugins/check_load.c +++ b/plugins/check_load.c @@ -153,7 +153,16 @@ main (int argc, char **argv) printf (_("Could not open stderr for %s\n"), PATH_TO_UPTIME); } fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process); - sscanf (input_buffer, "%*[^l]load average: %lf, %lf, %lf", &la1, &la5, &la15); + if(strstr(input_buffer, "load average:")) { + sscanf (input_buffer, "%*[^l]load average: %lf, %lf, %lf", &la1, &la5, &la15); + } + else if(strstr(input_buffer, "load averages:")) { + sscanf (input_buffer, "%*[^l]load averages: %lf, %lf, %lf", &la1, &la5, &la15); + } + else { + printf (_("could not parse load from uptime: %s\n"), result, PATH_TO_UPTIME); + return STATE_UNKNOWN; + } result = spclose (child_process); if (result) { ------------------------------------------------------------------------------ LIMITED TIME SALE - Full Year of Microsoft Training For Just $49.99! 1,500+ hours of tutorials including VisualStudio 2012, Windows 8, SharePoint 2013, SQL 2012, MVC 4, more. BEST VALUE: New Multi-Library Power Pack includes Mobile, Cloud, Java, and UX Design. Lowest price ever! Ends 9/22/13. http://pubads.g.doubleclick.net/gampad/clk?id=64545871&iu=/4140/ostg.clktrk