diff options
author | Andy Brist <abrist@nagios.com> | 2014-04-04 06:59:19 (GMT) |
---|---|---|
committer | Holger Weiss <holger@zedat.fu-berlin.de> | 2014-11-28 12:22:20 (GMT) |
commit | c59ee0036f3c6e699b5c3064026ffa34dc264da1 (patch) | |
tree | 8c7209982024cc83b7989c5d1abf6740cc8b2aea /plugins/check_nt.c | |
parent | 7906d27bfad7a2dfc1ee1964ba82e47b419df2d1 (diff) | |
download | monitoring-plugins-c59ee0036f3c6e699b5c3064026ffa34dc264da1.tar.gz |
Added perfdata to check_nt. New -l options - seconds|minutes|hours|days.
Diffstat (limited to 'plugins/check_nt.c')
-rw-r--r-- | plugins/check_nt.c | 51 |
1 files changed, 37 insertions, 14 deletions
diff --git a/plugins/check_nt.c b/plugins/check_nt.c index fefbfb7..f621b0a 100644 --- a/plugins/check_nt.c +++ b/plugins/check_nt.c | |||
@@ -197,19 +197,40 @@ int main(int argc, char **argv){ | |||
197 | 197 | ||
198 | case CHECK_UPTIME: | 198 | case CHECK_UPTIME: |
199 | 199 | ||
200 | xasprintf(&send_buffer, "%s&3", req_password); | 200 | if (value_list == NULL) { |
201 | fetch_data (server_address, server_port, send_buffer); | 201 | value_list = "minutes"; |
202 | uptime=strtoul(recv_buffer,NULL,10); | 202 | } |
203 | updays = uptime / 86400; | 203 | if (strncmp(value_list, "seconds", strlen("seconds") + 1 ) && |
204 | uphours = (uptime % 86400) / 3600; | 204 | strncmp(value_list, "minutes", strlen("minutes") + 1) && |
205 | upminutes = ((uptime % 86400) % 3600) / 60; | 205 | strncmp(value_list, "hours", strlen("hours") + 1) && |
206 | xasprintf(&output_message,_("System Uptime - %u day(s) %u hour(s) %u minute(s)|uptime=%lu"), updays, uphours, upminutes, uptime); | 206 | strncmp(value_list, "days", strlen("days") + 1)) { |
207 | if (check_critical_value==TRUE && uptime <= critical_value) | 207 | |
208 | return_code=STATE_CRITICAL; | 208 | output_message = strdup (_("wrong -l argument")); |
209 | else if (check_warning_value==TRUE && uptime <= warning_value) | 209 | } else { |
210 | return_code=STATE_WARNING; | 210 | xasprintf(&send_buffer, "%s&3", req_password); |
211 | else | 211 | fetch_data (server_address, server_port, send_buffer); |
212 | return_code=STATE_OK; | 212 | uptime=strtoul(recv_buffer,NULL,10); |
213 | updays = uptime / 86400; | ||
214 | uphours = (uptime % 86400) / 3600; | ||
215 | upminutes = ((uptime % 86400) % 3600) / 60; | ||
216 | |||
217 | if (!strncmp(value_list, "minutes", strlen("minutes"))) | ||
218 | uptime = uptime / 60; | ||
219 | else if (!strncmp(value_list, "hours", strlen("hours"))) | ||
220 | uptime = uptime / 3600; | ||
221 | else if (!strncmp(value_list, "days", strlen("days"))) | ||
222 | uptime = uptime / 86400; | ||
223 | /* else uptime in seconds, nothing to do */ | ||
224 | |||
225 | xasprintf(&output_message,_("System Uptime - %u day(s) %u hour(s) %u minute(s) |uptime=%lu"),updays, uphours, upminutes, uptime); | ||
226 | |||
227 | if (check_critical_value==TRUE && uptime <= critical_value) | ||
228 | return_code=STATE_CRITICAL; | ||
229 | else if (check_warning_value==TRUE && uptime <= warning_value) | ||
230 | return_code=STATE_WARNING; | ||
231 | else | ||
232 | return_code=STATE_OK; | ||
233 | } | ||
213 | break; | 234 | break; |
214 | 235 | ||
215 | case CHECK_USEDDISKSPACE: | 236 | case CHECK_USEDDISKSPACE: |
@@ -713,7 +734,9 @@ void print_help(void) | |||
713 | printf (" %s\n", "ie: -l 60,90,95,120,90,95"); | 734 | printf (" %s\n", "ie: -l 60,90,95,120,90,95"); |
714 | printf (" %s\n", "UPTIME ="); | 735 | printf (" %s\n", "UPTIME ="); |
715 | printf (" %s\n", _("Get the uptime of the machine.")); | 736 | printf (" %s\n", _("Get the uptime of the machine.")); |
716 | printf (" %s\n", _("No specific parameters. No warning or critical threshold")); | 737 | printf (" %s\n", _("-l <unit> ")); |
738 | printf (" %s\n", _("<unit> = seconds, minutes, hours, or days. (default: minutes)")); | ||
739 | printf (" %s\n", _("Thresholds will use the unit specified above.")); | ||
717 | printf (" %s\n", "USEDDISKSPACE ="); | 740 | printf (" %s\n", "USEDDISKSPACE ="); |
718 | printf (" %s\n", _("Size and percentage of disk use.")); | 741 | printf (" %s\n", _("Size and percentage of disk use.")); |
719 | printf (" %s\n", _("Request a -l parameter containing the drive letter only.")); | 742 | printf (" %s\n", _("Request a -l parameter containing the drive letter only.")); |