summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorSven Nierlein <sven@consol.de>2013-09-14 18:41:24 (GMT)
committerSven Nierlein <sven@consol.de>2013-09-14 18:44:54 (GMT)
commitc7d6730255aaf4d07db947e9f032bc0206bccbcb (patch)
tree81d40b28cad65ab2e27f3f789b7ccd8783c5556e /plugins
parent6361247b4c72b2527ffef5c5c4d9672264b61941 (diff)
downloadmonitoring-plugins-c7d6730255aaf4d07db947e9f032bc0206bccbcb.tar.gz
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
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_load.c11
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)
153 printf (_("Could not open stderr for %s\n"), PATH_TO_UPTIME); 153 printf (_("Could not open stderr for %s\n"), PATH_TO_UPTIME);
154 } 154 }
155 fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process); 155 fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process);
156 sscanf (input_buffer, "%*[^l]load average: %lf, %lf, %lf", &la1, &la5, &la15); 156 if(strstr(input_buffer, "load average:")) {
157 sscanf (input_buffer, "%*[^l]load average: %lf, %lf, %lf", &la1, &la5, &la15);
158 }
159 else if(strstr(input_buffer, "load averages:")) {
160 sscanf (input_buffer, "%*[^l]load averages: %lf, %lf, %lf", &la1, &la5, &la15);
161 }
162 else {
163 printf (_("could not parse load from uptime: %s\n"), result, PATH_TO_UPTIME);
164 return STATE_UNKNOWN;
165 }
157 166
158 result = spclose (child_process); 167 result = spclose (child_process);
159 if (result) { 168 if (result) {