From 4e318b9277ba5209fab447da5afa3c0a22a681d9 Mon Sep 17 00:00:00 2001 From: Karl DeBisschop Date: Sun, 14 Mar 2004 04:09:19 +0000 Subject: use fperfdata git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@849 f882894a-f735-0410-b71e-b25c423dba1c diff --git a/plugins/check_ldap.c b/plugins/check_ldap.c index b21351b..207b98e 100644 --- a/plugins/check_ldap.c +++ b/plugins/check_ldap.c @@ -51,8 +51,8 @@ int ld_port = DEFAULT_PORT; #ifdef HAVE_LDAP_SET_OPTION int ld_protocol = DEFAULT_PROTOCOL; #endif -int warn_time = UNDEFINED; -int crit_time = UNDEFINED; +double warn_time = UNDEFINED; +double crit_time = UNDEFINED; struct timeval tv; int @@ -135,9 +135,9 @@ main (int argc, char *argv[]) printf (_("LDAP %s - %.3f seconds response time|%s\n"), state_text (status), elapsed_time, - perfdata ("time", microsec, "us", - warn_time, warn_time, - crit_time, crit_time, + fperfdata ("time", elapsed_time, "s", + (int)warn_time, warn_time, + (int)crit_time, crit_time, TRUE, 0, FALSE, 0)); return status; @@ -218,10 +218,10 @@ process_arguments (int argc, char **argv) ld_passwd = optarg; break; case 'w': - warn_time = atoi (optarg); + warn_time = strtod (optarg, NULL); break; case 'c': - crit_time = atoi (optarg); + crit_time = strtod (optarg, NULL); break; #ifdef HAVE_LDAP_SET_OPTION case '2': diff --git a/plugins/check_load.c b/plugins/check_load.c index ba942c5..fc7e949 100644 --- a/plugins/check_load.c +++ b/plugins/check_load.c @@ -152,9 +152,9 @@ main (int argc, char **argv) "%s - %s|%s %s %s\n", state_text (result), status_line, - perfdata ("load1", la1, "", wload1, wload1, cload1, cload1, TRUE, 0, FALSE, 0), - perfdata ("load5", la5, "", wload5, wload5, cload5, cload5, TRUE, 0, FALSE, 0), - perfdata ("load15", la15, "", wload15, wload15, cload15, cload15, TRUE, 0, FALSE, 0)); + fperfdata ("load1", la1, "", (int)wload1, wload1, (int)cload1, cload1, TRUE, 0, FALSE, 0), + fperfdata ("load5", la5, "", (int)wload5, wload5, (int)cload5, cload5, TRUE, 0, FALSE, 0), + fperfdata ("load15", la15, "", (int)wload15, wload15, (int)cload15, cload15, TRUE, 0, FALSE, 0)); return STATE_OK; } diff --git a/plugins/check_mrtgtraf.c b/plugins/check_mrtgtraf.c index cdb50f3..d23b76d 100644 --- a/plugins/check_mrtgtraf.c +++ b/plugins/check_mrtgtraf.c @@ -179,14 +179,14 @@ main (int argc, char **argv) (use_average == TRUE) ? _("Avg") : _("Max"), adjusted_incoming_rate, incoming_speed_rating, (use_average == TRUE) ? _("Avg") : _("Max"), adjusted_outgoing_rate, outgoing_speed_rating, - perfdata("in", (long) adjusted_incoming_rate, incoming_speed_rating, - (int) incoming_warning_threshold, (long) incoming_warning_threshold, - (int) incoming_critical_threshold, (long) incoming_critical_threshold, - TRUE, 0, TRUE, (long) incoming_speed_rating), - perfdata("in", (long) adjusted_outgoing_rate, outgoing_speed_rating, - (int) outgoing_warning_threshold, (long) outgoing_warning_threshold, - (int) outgoing_critical_threshold, (long) outgoing_critical_threshold, - TRUE, 0, TRUE, (long) outgoing_speed_rating)); + fperfdata("in", adjusted_incoming_rate, incoming_speed_rating, + (int)incoming_warning_threshold, incoming_warning_threshold, + (int)incoming_critical_threshold, incoming_critical_threshold, + TRUE, 0, FALSE, 0), + fperfdata("in", adjusted_outgoing_rate, outgoing_speed_rating, + (int)outgoing_warning_threshold, outgoing_warning_threshold, + (int)outgoing_critical_threshold, outgoing_critical_threshold, + TRUE, 0, FALSE, 0)); printf (_("Traffic %s - %s\n"), state_text(result), error_message); diff --git a/plugins/check_pgsql.c b/plugins/check_pgsql.c index 00b051b..22a5b81 100644 --- a/plugins/check_pgsql.c +++ b/plugins/check_pgsql.c @@ -45,8 +45,8 @@ char *pgtty = NULL; char dbName[NAMEDATALEN] = DEFAULT_DB; char *pguser = NULL; char *pgpasswd = NULL; -int twarn = DEFAULT_WARN; -int tcrit = DEFAULT_CRIT; +double twarn = (double)DEFAULT_WARN; +double tcrit = (double)DEFAULT_CRIT; PGconn *conn; /*PGresult *res;*/ @@ -168,8 +168,8 @@ main (int argc, char **argv) PQfinish (conn); printf (_("PGSQL: %s - database %s (%d sec.)|%s\n"), state_text(status), dbName, elapsed_time, - perfdata("time", (long)elapsed_time, "s", - twarn, (long)twarn, tcrit, (long)tcrit, TRUE, 0, FALSE,0)); + fperfdata("time", elapsed_time, "s", + (int)twarn, twarn, (int)tcrit, tcrit, TRUE, 0, FALSE,0)); return status; } @@ -221,16 +221,16 @@ process_arguments (int argc, char **argv) timeout_interval = atoi (optarg); break; case 'c': /* critical time threshold */ - if (!is_integer (optarg)) + if (!is_nonnegative (optarg)) usage2 (_("Invalid critical threshold"), optarg); else - tcrit = atoi (optarg); + tcrit = strtod (optarg, NULL); break; case 'w': /* warning time threshold */ - if (!is_integer (optarg)) + if (!is_nonnegative (optarg)) usage2 (_("Invalid critical threshold"), optarg); else - twarn = atoi (optarg); + twarn = strtod (optarg, NULL); break; case 'H': /* host */ if (!is_host (optarg)) diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c index 8f9ec8b..314f59b 100644 --- a/plugins/check_smtp.c +++ b/plugins/check_smtp.c @@ -228,8 +228,8 @@ main (int argc, char **argv) state_text (result), elapsed_time, verbose?", ":"", verbose?buffer:"", perfdata ("time", microsec, "us", - check_warning_time, (long)(1000000*warning_time), - check_critical_time, (long)(1000000*critical_time), + (int)check_warning_time, warning_time, + (int)check_critical_time, critical_time, TRUE, 0, FALSE, 0)); return result; diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c index 55ce898..9bb161a 100644 --- a/plugins/check_tcp.c +++ b/plugins/check_tcp.c @@ -332,11 +332,11 @@ main (int argc, char **argv) if (status && strlen(status) > 0) printf (" [%s]", status); - printf (" |%s\n", perfdata ("time", microsec, "us", - TRUE, warning_time*1000, - TRUE, critical_time*1000, + printf (" |%s\n", fperfdata ("time", elapsed_time, "s", + TRUE, warning_time, + TRUE, critical_time, TRUE, 0, - TRUE, socket_timeout*1000)); + TRUE, socket_timeout)); return result; } @@ -481,7 +481,7 @@ process_arguments (int argc, char **argv) else maxbytes = atoi (optarg); case 'q': - server_quit = optarg; + asprintf(&server_quit, "%s\r\n", optarg); break; case 'r': if (!strncmp(optarg,"ok",2)) diff --git a/plugins/check_ups.c b/plugins/check_ups.c index 116e888..f88e9e9 100644 --- a/plugins/check_ups.c +++ b/plugins/check_ups.c @@ -167,13 +167,13 @@ main (int argc, char **argv) result = max_state (result, STATE_WARNING); } asprintf (&data, "%s", - perfdata ("voltage", (long)(1000*ups_utility_voltage), "mV", - check_warn, (long)(1000*warning_value), - check_crit, (long)(1000*critical_value), + fperfdata ("voltage", ups_utility_voltage, "V", + check_warn, warning_value, + check_crit, critical_value, TRUE, 0, FALSE, 0)); } else { asprintf (&data, "%s", - perfdata ("voltage", (long)(1000*ups_utility_voltage), "mV", + fperfdata ("voltage", ups_utility_voltage, "V", FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0)); } } -- cgit v0.10-9-g596f