Code

use fperfdata
authorKarl DeBisschop <kdebisschop@users.sourceforge.net>
Sun, 14 Mar 2004 04:09:19 +0000 (04:09 +0000)
committerKarl DeBisschop <kdebisschop@users.sourceforge.net>
Sun, 14 Mar 2004 04:09:19 +0000 (04:09 +0000)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@849 f882894a-f735-0410-b71e-b25c423dba1c

plugins/check_ldap.c
plugins/check_load.c
plugins/check_mrtgtraf.c
plugins/check_pgsql.c
plugins/check_smtp.c
plugins/check_tcp.c
plugins/check_ups.c

index b21351b72ab2fbd5e26c9d9b2464a03ae58efe25..207b98ed0b55f2d82334a3b1c3f09a0008b7f4ed 100644 (file)
@@ -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':
index ba942c5c21c0acbdc0527f7a6f86f351520c2272..fc7e9496d8f3eabcf04bb1b2edb2c9e3484416e1 100644 (file)
@@ -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;
 }
 
index cdb50f31a5adb0037d9e36dfd29e33dbeee1263e..d23b76d08ddcad1919687cdfefac56c0bf1ec535 100644 (file)
@@ -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);
 
index 00b051be2d47e652e0aa585487508fab6cc4d49a..22a5b8119a98ba63855e140c9cf9163bcb02daa9 100644 (file)
@@ -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;
 }
 \f
@@ -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))
index 8f9ec8bbc63e7f7bc6751600234e48e52225b4a7..314f59b10154a39e83709a6bf7f6c184af8fcaf5 100644 (file)
@@ -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;
index 55ce89848215e082f7fc35e406008311f41ef0db..9bb161a9358832b4f8539ee521165c3f811971a8 100644 (file)
@@ -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))
index 116e888ce5c79d8610515dbda1f37d7537993f49..f88e9e9f5c002f1407314319ee1040c5c4a1fc2d 100644 (file)
@@ -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));
                }
        }