Back to index

nagios-plugins  1.4.16
check_ups.c
Go to the documentation of this file.
00001 /*****************************************************************************
00002 * 
00003 * Nagios check_ups plugin
00004 * 
00005 * License: GPL
00006 * Copyright (c) 2000 Tom Shields
00007 *               2004 Alain Richard <alain.richard@equation.fr>
00008 *               2004 Arnaud Quette <arnaud.quette@mgeups.com>
00009 * Copyright (c) 2002-2007 Nagios Plugins Development Team
00010 * 
00011 * Description:
00012 * 
00013 * This file contains Network UPS Tools plugin for Nagios
00014 * 
00015 * This plugin tests the UPS service on the specified host. Network UPS Tools
00016 * from www.networkupstools.org must be running for this plugin to work.
00017 * 
00018 * 
00019 * This program is free software: you can redistribute it and/or modify
00020 * it under the terms of the GNU General Public License as published by
00021 * the Free Software Foundation, either version 3 of the License, or
00022 * (at your option) any later version.
00023 * 
00024 * This program is distributed in the hope that it will be useful,
00025 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00026 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00027 * GNU General Public License for more details.
00028 * 
00029 * You should have received a copy of the GNU General Public License
00030 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00031 * 
00032 * 
00033 *****************************************************************************/
00034 
00035 const char *progname = "check_ups";
00036 const char *copyright = "2000-2007";
00037 const char *email = "nagiosplug-devel@lists.sourceforge.net";
00038 
00039 #include "common.h"
00040 #include "netutils.h"
00041 #include "utils.h"
00042 
00043 enum {
00044        PORT = 3493
00045 };
00046 
00047 #define CHECK_NONE    0
00048 
00049 #define UPS_NONE     0   /* no supported options */
00050 #define UPS_UTILITY  1   /* supports utility line voltage */
00051 #define UPS_BATTPCT  2   /* supports percent battery remaining */
00052 #define UPS_STATUS   4   /* supports UPS status */
00053 #define UPS_TEMP     8   /* supports UPS temperature */
00054 #define UPS_LOADPCT  16   /* supports load percent */
00055 
00056 #define UPSSTATUS_NONE       0
00057 #define UPSSTATUS_OFF        1
00058 #define UPSSTATUS_OL         2
00059 #define UPSSTATUS_OB         4
00060 #define UPSSTATUS_LB         8
00061 #define UPSSTATUS_CAL       16
00062 #define UPSSTATUS_RB        32  /*Replace Battery */
00063 #define UPSSTATUS_BYPASS    64
00064 #define UPSSTATUS_OVER     128
00065 #define UPSSTATUS_TRIM     256
00066 #define UPSSTATUS_BOOST    512
00067 #define UPSSTATUS_CHRG    1024
00068 #define UPSSTATUS_DISCHRG 2048
00069 #define UPSSTATUS_UNKOWN  4096
00070 
00071 enum { NOSUCHVAR = ERROR-1 };
00072 
00073 int server_port = PORT;
00074 char *server_address;
00075 char *ups_name = NULL;
00076 double warning_value = 0.0;
00077 double critical_value = 0.0;
00078 int check_warn = FALSE;
00079 int check_crit = FALSE;
00080 int check_variable = UPS_NONE;
00081 int supported_options = UPS_NONE;
00082 int status = UPSSTATUS_NONE;
00083 
00084 double ups_utility_voltage = 0.0;
00085 double ups_battery_percent = 0.0;
00086 double ups_load_percent = 0.0;
00087 double ups_temperature = 0.0;
00088 char *ups_status;
00089 int temp_output_c = 0;
00090 
00091 int determine_status (void);
00092 int get_ups_variable (const char *, char *, size_t);
00093 
00094 int process_arguments (int, char **);
00095 int validate_arguments (void);
00096 void print_help (void);
00097 void print_usage (void);
00098 
00099 int
00100 main (int argc, char **argv)
00101 {
00102        int result = STATE_UNKNOWN;
00103        char *message;
00104        char *data;
00105        char *tunits;
00106        char temp_buffer[MAX_INPUT_BUFFER];
00107        double ups_utility_deviation = 0.0;
00108        int res;
00109 
00110        setlocale (LC_ALL, "");
00111        bindtextdomain (PACKAGE, LOCALEDIR);
00112        textdomain (PACKAGE);
00113 
00114        ups_status = strdup ("N/A");
00115        data = strdup ("");
00116        message = strdup ("");
00117 
00118        /* Parse extra opts if any */
00119        argv=np_extra_opts (&argc, argv, progname);
00120 
00121        if (process_arguments (argc, argv) == ERROR)
00122               usage4 (_("Could not parse arguments"));
00123 
00124        /* initialize alarm signal handling */
00125        signal (SIGALRM, socket_timeout_alarm_handler);
00126 
00127        /* set socket timeout */
00128        alarm (socket_timeout);
00129 
00130        /* get the ups status if possible */
00131        if (determine_status () != OK)
00132               return STATE_CRITICAL;
00133        if (supported_options & UPS_STATUS) {
00134 
00135               ups_status = strdup ("");
00136               result = STATE_OK;
00137 
00138               if (status & UPSSTATUS_OFF) {
00139                      asprintf (&ups_status, "Off");
00140                      result = STATE_CRITICAL;
00141               }
00142               else if ((status & (UPSSTATUS_OB | UPSSTATUS_LB)) ==
00143                                            (UPSSTATUS_OB | UPSSTATUS_LB)) {
00144                      asprintf (&ups_status, _("On Battery, Low Battery"));
00145                      result = STATE_CRITICAL;
00146               }
00147               else {
00148                      if (status & UPSSTATUS_OL) {
00149                             asprintf (&ups_status, "%s%s", ups_status, _("Online"));
00150                      }
00151                      if (status & UPSSTATUS_OB) {
00152                             asprintf (&ups_status, "%s%s", ups_status, _("On Battery"));
00153                             result = STATE_WARNING;
00154                      }
00155                      if (status & UPSSTATUS_LB) {
00156                             asprintf (&ups_status, "%s%s", ups_status, _(", Low Battery"));
00157                             result = STATE_WARNING;
00158                      }
00159                      if (status & UPSSTATUS_CAL) {
00160                             asprintf (&ups_status, "%s%s", ups_status, _(", Calibrating"));
00161                      }
00162                      if (status & UPSSTATUS_RB) {
00163                             asprintf (&ups_status, "%s%s", ups_status, _(", Replace Battery"));
00164                             result = STATE_WARNING;
00165                      }
00166                      if (status & UPSSTATUS_BYPASS) {
00167                             asprintf (&ups_status, "%s%s", ups_status, _(", On Bypass"));
00168                      }
00169                      if (status & UPSSTATUS_OVER) {
00170                             asprintf (&ups_status, "%s%s", ups_status, _(", Overload"));
00171                      }
00172                      if (status & UPSSTATUS_TRIM) {
00173                             asprintf (&ups_status, "%s%s", ups_status, _(", Trimming"));
00174                      }
00175                      if (status & UPSSTATUS_BOOST) {
00176                             asprintf (&ups_status, "%s%s", ups_status, _(", Boosting"));
00177                      }
00178                      if (status & UPSSTATUS_CHRG) {
00179                             asprintf (&ups_status, "%s%s", ups_status, _(", Charging"));
00180                      }
00181                      if (status & UPSSTATUS_DISCHRG) {
00182                             asprintf (&ups_status, "%s%s", ups_status, _(", Discharging"));
00183                      }
00184                      if (status & UPSSTATUS_UNKOWN) {
00185                             asprintf (&ups_status, "%s%s", ups_status, _(", Unknown"));
00186                      }
00187               }
00188               asprintf (&message, "%sStatus=%s ", message, ups_status);
00189        }
00190 
00191        /* get the ups utility voltage if possible */
00192        res=get_ups_variable ("input.voltage", temp_buffer, sizeof (temp_buffer));
00193        if (res == NOSUCHVAR) supported_options &= ~UPS_UTILITY;
00194        else if (res != OK)
00195               return STATE_CRITICAL;
00196        else {
00197               supported_options |= UPS_UTILITY;
00198 
00199               ups_utility_voltage = atof (temp_buffer);
00200               asprintf (&message, "%sUtility=%3.1fV ", message, ups_utility_voltage);
00201 
00202               if (ups_utility_voltage > 120.0)
00203                      ups_utility_deviation = 120.0 - ups_utility_voltage;
00204               else
00205                      ups_utility_deviation = ups_utility_voltage - 120.0;
00206 
00207               if (check_variable == UPS_UTILITY) {
00208                      if (check_crit==TRUE && ups_utility_deviation>=critical_value) {
00209                             result = STATE_CRITICAL;
00210                      }
00211                      else if (check_warn==TRUE && ups_utility_deviation>=warning_value) {
00212                             result = max_state (result, STATE_WARNING);
00213                      }
00214                      asprintf (&data, "%s",
00215                                perfdata ("voltage", (long)(1000*ups_utility_voltage), "mV",
00216                                          check_warn, (long)(1000*warning_value),
00217                                          check_crit, (long)(1000*critical_value),
00218                                          TRUE, 0, FALSE, 0));
00219               } else {
00220                      asprintf (&data, "%s",
00221                                perfdata ("voltage", (long)(1000*ups_utility_voltage), "mV",
00222                                          FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0));
00223               }
00224        }
00225 
00226        /* get the ups battery percent if possible */
00227        res=get_ups_variable ("battery.charge", temp_buffer, sizeof (temp_buffer));
00228        if (res == NOSUCHVAR) supported_options &= ~UPS_BATTPCT;
00229        else if ( res != OK)
00230               return STATE_CRITICAL;
00231        else {
00232               supported_options |= UPS_BATTPCT;
00233               ups_battery_percent = atof (temp_buffer);
00234               asprintf (&message, "%sBatt=%3.1f%% ", message, ups_battery_percent);
00235 
00236               if (check_variable == UPS_BATTPCT) {
00237                      if (check_crit==TRUE && ups_battery_percent <= critical_value) {
00238                             result = STATE_CRITICAL;
00239                      }
00240                      else if (check_warn==TRUE && ups_battery_percent<=warning_value) {
00241                             result = max_state (result, STATE_WARNING);
00242                      }
00243                      asprintf (&data, "%s %s", data,
00244                                perfdata ("battery", (long)ups_battery_percent, "%",
00245                                          check_warn, (long)(1000*warning_value),
00246                                          check_crit, (long)(1000*critical_value),
00247                                          TRUE, 0, TRUE, 100));
00248               } else {
00249                      asprintf (&data, "%s %s", data,
00250                                perfdata ("battery", (long)ups_battery_percent, "%",
00251                                          FALSE, 0, FALSE, 0, TRUE, 0, TRUE, 100));
00252               }
00253        }
00254 
00255        /* get the ups load percent if possible */
00256        res=get_ups_variable ("ups.load", temp_buffer, sizeof (temp_buffer));
00257        if ( res == NOSUCHVAR ) supported_options &= ~UPS_LOADPCT;
00258        else if ( res != OK)
00259               return STATE_CRITICAL;
00260        else {
00261               supported_options |= UPS_LOADPCT;
00262               ups_load_percent = atof (temp_buffer);
00263               asprintf (&message, "%sLoad=%3.1f%% ", message, ups_load_percent);
00264 
00265               if (check_variable == UPS_LOADPCT) {
00266                      if (check_crit==TRUE && ups_load_percent>=critical_value) {
00267                             result = STATE_CRITICAL;
00268                      }
00269                      else if (check_warn==TRUE && ups_load_percent>=warning_value) {
00270                             result = max_state (result, STATE_WARNING);
00271                      }
00272                      asprintf (&data, "%s %s", data,
00273                                perfdata ("load", (long)ups_load_percent, "%",
00274                                          check_warn, (long)(1000*warning_value),
00275                                          check_crit, (long)(1000*critical_value),
00276                                          TRUE, 0, TRUE, 100));
00277               } else {
00278                      asprintf (&data, "%s %s", data,
00279                                perfdata ("load", (long)ups_load_percent, "%",
00280                                          FALSE, 0, FALSE, 0, TRUE, 0, TRUE, 100));
00281               }
00282        }
00283 
00284        /* get the ups temperature if possible */
00285        res=get_ups_variable ("ups.temperature", temp_buffer, sizeof (temp_buffer));
00286        if ( res == NOSUCHVAR ) supported_options &= ~UPS_TEMP;
00287        else if ( res != OK)
00288               return STATE_CRITICAL;
00289        else {
00290               supported_options |= UPS_TEMP;
00291               if (temp_output_c) {
00292                 tunits="degC";
00293                 ups_temperature = atof (temp_buffer);
00294                 asprintf (&message, "%sTemp=%3.1fC", message, ups_temperature);
00295               }
00296               else {
00297                 tunits="degF";
00298                 ups_temperature = (atof (temp_buffer) * 1.8) + 32;
00299                 asprintf (&message, "%sTemp=%3.1fF", message, ups_temperature);
00300               }
00301 
00302               if (check_variable == UPS_TEMP) {
00303                      if (check_crit==TRUE && ups_temperature>=critical_value) {
00304                             result = STATE_CRITICAL;
00305                      }
00306                      else if (check_warn == TRUE && ups_temperature>=warning_value) {
00307                             result = max_state (result, STATE_WARNING);
00308                      }
00309                      asprintf (&data, "%s %s", data,
00310                                perfdata ("temp", (long)ups_temperature, tunits,
00311                                          check_warn, (long)(1000*warning_value),
00312                                          check_crit, (long)(1000*critical_value),
00313                                          TRUE, 0, FALSE, 0));
00314               } else {
00315                      asprintf (&data, "%s %s", data,
00316                                perfdata ("temp", (long)ups_temperature, tunits,
00317                                          FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0));
00318               }
00319        }
00320 
00321        /* if the UPS does not support any options we are looking for, report an error */
00322        if (supported_options == UPS_NONE) {
00323               result = STATE_CRITICAL;
00324               asprintf (&message, _("UPS does not support any available options\n"));
00325        }
00326 
00327        /* reset timeout */
00328        alarm (0);
00329 
00330        printf ("UPS %s - %s|%s\n", state_text(result), message, data);
00331        return result;
00332 }
00333 
00334 
00335 
00336 /* determines what options are supported by the UPS */
00337 int
00338 determine_status (void)
00339 {
00340        char recv_buffer[MAX_INPUT_BUFFER];
00341        char temp_buffer[MAX_INPUT_BUFFER];
00342        char *ptr;
00343        int res;
00344 
00345        res=get_ups_variable ("ups.status", recv_buffer, sizeof (recv_buffer));
00346        if (res == NOSUCHVAR) return OK;
00347        if (res != STATE_OK) {
00348               printf ("%s\n", _("Invalid response received from host"));
00349               return ERROR;
00350        }
00351 
00352        supported_options |= UPS_STATUS;
00353 
00354        strcpy (temp_buffer, recv_buffer);
00355        for (ptr = (char *) strtok (temp_buffer, " "); ptr != NULL;
00356                       ptr = (char *) strtok (NULL, " ")) {
00357               if (!strcmp (ptr, "OFF"))
00358                      status |= UPSSTATUS_OFF;
00359               else if (!strcmp (ptr, "OL"))
00360                      status |= UPSSTATUS_OL;
00361               else if (!strcmp (ptr, "OB"))
00362                      status |= UPSSTATUS_OB;
00363               else if (!strcmp (ptr, "LB"))
00364                      status |= UPSSTATUS_LB;
00365               else if (!strcmp (ptr, "CAL"))
00366                      status |= UPSSTATUS_CAL;
00367               else if (!strcmp (ptr, "RB"))
00368                      status |= UPSSTATUS_RB;
00369               else if (!strcmp (ptr, "BYPASS"))
00370                      status |= UPSSTATUS_BYPASS;
00371               else if (!strcmp (ptr, "OVER"))
00372                      status |= UPSSTATUS_OVER;
00373               else if (!strcmp (ptr, "TRIM"))
00374                      status |= UPSSTATUS_TRIM;
00375               else if (!strcmp (ptr, "BOOST"))
00376                      status |= UPSSTATUS_BOOST;
00377               else if (!strcmp (ptr, "CHRG"))
00378                      status |= UPSSTATUS_CHRG;
00379               else if (!strcmp (ptr, "DISCHRG"))
00380                      status |= UPSSTATUS_DISCHRG;
00381               else
00382                      status |= UPSSTATUS_UNKOWN;
00383        }
00384 
00385        return OK;
00386 }
00387 
00388 
00389 /* gets a variable value for a specific UPS  */
00390 int
00391 get_ups_variable (const char *varname, char *buf, size_t buflen)
00392 {
00393        /*  char command[MAX_INPUT_BUFFER]; */
00394        char temp_buffer[MAX_INPUT_BUFFER];
00395        char send_buffer[MAX_INPUT_BUFFER];
00396        char *ptr;
00397        char *logout = "OK Goodbye\n";
00398        int logout_len = strlen(logout);
00399        int len;
00400 
00401        *buf=0;
00402 
00403        /* create the command string to send to the UPS daemon */
00404        /* Add LOGOUT to avoid read failure logs */
00405        sprintf (send_buffer, "GET VAR %s %s\nLOGOUT\n", ups_name, varname);
00406 
00407        /* send the command to the daemon and get a response back */
00408        if (process_tcp_request
00409                      (server_address, server_port, send_buffer, temp_buffer,
00410                       sizeof (temp_buffer)) != STATE_OK) {
00411               printf ("%s\n", _("Invalid response received from host"));
00412               return ERROR;
00413        }
00414 
00415        ptr = temp_buffer;
00416        len = strlen(ptr);
00417        if (len > logout_len && strcmp (ptr + len - logout_len, logout) == 0) len -= logout_len;
00418        if (len > 0 && ptr[len-1] == '\n') ptr[len-1]=0;
00419        if (strcmp (ptr, "ERR UNKNOWN-UPS") == 0) {
00420               printf (_("CRITICAL - no such UPS '%s' on that host\n"), ups_name);
00421               return ERROR;
00422        }
00423 
00424        if (strcmp (ptr, "ERR VAR-NOT-SUPPORTED") == 0) {
00425               /*printf ("Error: Variable '%s' is not supported\n", varname);*/
00426               return NOSUCHVAR;
00427        }
00428 
00429        if (strcmp (ptr, "ERR DATA-STALE") == 0) {
00430               printf ("%s\n", _("CRITICAL - UPS data is stale"));
00431               return ERROR;
00432        }
00433 
00434        if (strncmp (ptr, "ERR", 3) == 0) {
00435               printf (_("Unknown error: %s\n"), ptr);
00436               return ERROR;
00437        }
00438 
00439        ptr = temp_buffer + strlen (varname) + strlen (ups_name) + 6;
00440        len = strlen(ptr);
00441        if (len < 2 || ptr[0] != '"' || ptr[len-1] != '"') {
00442               printf ("%s\n", _("Error: unable to parse variable"));
00443               return ERROR;
00444        }
00445        strncpy (buf, ptr+1, len - 2);
00446        buf[len - 2] = 0;
00447 
00448        return OK;
00449 }
00450 
00451 
00452 /* Command line: CHECK_UPS -H <host_address> -u ups [-p port] [-v variable]
00453                         [-wv warn_value] [-cv crit_value] [-to to_sec] */
00454 
00455 
00456 /* process command-line arguments */
00457 int
00458 process_arguments (int argc, char **argv)
00459 {
00460        int c;
00461 
00462        int option = 0;
00463        static struct option longopts[] = {
00464               {"hostname", required_argument, 0, 'H'},
00465               {"ups", required_argument, 0, 'u'},
00466               {"port", required_argument, 0, 'p'},
00467               {"critical", required_argument, 0, 'c'},
00468               {"warning", required_argument, 0, 'w'},
00469               {"timeout", required_argument, 0, 't'},
00470               {"temperature", no_argument, 0, 'T'},
00471               {"variable", required_argument, 0, 'v'},
00472               {"version", no_argument, 0, 'V'},
00473               {"help", no_argument, 0, 'h'},
00474               {0, 0, 0, 0}
00475        };
00476 
00477        if (argc < 2)
00478               return ERROR;
00479 
00480        for (c = 1; c < argc; c++) {
00481               if (strcmp ("-to", argv[c]) == 0)
00482                      strcpy (argv[c], "-t");
00483               else if (strcmp ("-wt", argv[c]) == 0)
00484                      strcpy (argv[c], "-w");
00485               else if (strcmp ("-ct", argv[c]) == 0)
00486                      strcpy (argv[c], "-c");
00487        }
00488 
00489        while (1) {
00490               c = getopt_long (argc, argv, "hVTH:u:p:v:c:w:t:", longopts,
00491                                                                 &option);
00492 
00493               if (c == -1 || c == EOF)
00494                      break;
00495 
00496               switch (c) {
00497               case '?':                                                             /* help */
00498                      usage5 ();
00499               case 'H':                                                             /* hostname */
00500                      if (is_host (optarg)) {
00501                             server_address = optarg;
00502                      }
00503                      else {
00504                             usage2 (_("Invalid hostname/address"), optarg);
00505                      }
00506                      break;
00507               case 'T': /* FIXME: to be improved (ie "-T C" for Celsius or "-T F" for Farenheit) */
00508                      temp_output_c = 1;
00509                      break;
00510               case 'u':                                                             /* ups name */
00511                      ups_name = optarg;
00512                      break;
00513               case 'p':                                                             /* port */
00514                      if (is_intpos (optarg)) {
00515                             server_port = atoi (optarg);
00516                      }
00517                      else {
00518                             usage2 (_("Port must be a positive integer"), optarg);
00519                      }
00520                      break;
00521               case 'c':                                                             /* critical time threshold */
00522                      if (is_intnonneg (optarg)) {
00523                             critical_value = atoi (optarg);
00524                             check_crit = TRUE;
00525                      }
00526                      else {
00527                             usage2 (_("Critical time must be a positive integer"), optarg);
00528                      }
00529                      break;
00530               case 'w':                                                             /* warning time threshold */
00531                      if (is_intnonneg (optarg)) {
00532                             warning_value = atoi (optarg);
00533                             check_warn = TRUE;
00534                      }
00535                      else {
00536                             usage2 (_("Warning time must be a positive integer"), optarg);
00537                      }
00538                      break;
00539               case 'v':                                                             /* variable */
00540                      if (!strcmp (optarg, "LINE"))
00541                             check_variable = UPS_UTILITY;
00542                      else if (!strcmp (optarg, "TEMP"))
00543                             check_variable = UPS_TEMP;
00544                      else if (!strcmp (optarg, "BATTPCT"))
00545                             check_variable = UPS_BATTPCT;
00546                      else if (!strcmp (optarg, "LOADPCT"))
00547                             check_variable = UPS_LOADPCT;
00548                      else
00549                             usage2 (_("Unrecognized UPS variable"), optarg);
00550                      break;
00551               case 't':                                                             /* timeout */
00552                      if (is_intnonneg (optarg)) {
00553                             socket_timeout = atoi (optarg);
00554                      }
00555                      else {
00556                             usage4 (_("Timeout interval must be a positive integer"));
00557                      }
00558                      break;
00559               case 'V':                                                             /* version */
00560                      print_revision (progname, NP_VERSION);
00561                      exit (STATE_OK);
00562               case 'h':                                                             /* help */
00563                      print_help ();
00564                      exit (STATE_OK);
00565               }
00566        }
00567 
00568 
00569        if (server_address == NULL && argc > optind) {
00570               if (is_host (argv[optind]))
00571                      server_address = argv[optind++];
00572               else
00573                      usage2 (_("Invalid hostname/address"), optarg);
00574        }
00575 
00576        if (server_address == NULL)
00577               server_address = strdup("127.0.0.1");
00578 
00579        return validate_arguments();
00580 }
00581 
00582 
00583 int
00584 validate_arguments (void)
00585 {
00586        if (! ups_name) {
00587               printf ("%s\n", _("Error : no UPS indicated"));
00588               return ERROR;
00589        }
00590        return OK;
00591 }
00592 
00593 
00594 void
00595 print_help (void)
00596 {
00597        char *myport;
00598        asprintf (&myport, "%d", PORT);
00599 
00600        print_revision (progname, NP_VERSION);
00601 
00602        printf ("Copyright (c) 2000 Tom Shields\n");
00603        printf ("Copyright (c) 2004 Alain Richard <alain.richard@equation.fr>\n");
00604        printf ("Copyright (c) 2004 Arnaud Quette <arnaud.quette@mgeups.com>\n");
00605        printf (COPYRIGHT, copyright, email);
00606 
00607        printf ("%s\n", _("This plugin tests the UPS service on the specified host. Network UPS Tools"));
00608   printf ("%s\n", _("from www.networkupstools.org must be running for this plugin to work."));
00609 
00610   printf ("\n\n");
00611 
00612        print_usage ();
00613 
00614        printf (UT_HELP_VRSN);
00615        printf (UT_EXTRA_OPTS);
00616 
00617        printf (UT_HOST_PORT, 'p', myport);
00618 
00619        printf (" %s\n", "-u, --ups=STRING");
00620   printf ("    %s\n", _("Name of UPS"));
00621   printf (" %s\n", "-T, --temperature");
00622   printf ("    %s\n", _("Output of temperatures in Celsius"));
00623   printf (" %s\n", "-v, --variable=STRING");
00624   printf ("    %s %s\n", _("Valid values for STRING are"), "LINE, TEMP, BATTPCT or LOADPCT");
00625 
00626        printf (UT_WARN_CRIT);
00627 
00628        printf (UT_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
00629 
00630 /* TODO: -v clashing with -v/-variable. Commenting out help text since verbose
00631          is unused up to now */
00632 /*     printf (UT_VERBOSE); */
00633 
00634   printf ("\n");
00635        printf ("%s\n", _("This plugin attempts to determine the status of a UPS (Uninterruptible Power"));
00636   printf ("%s\n", _("Supply) on a local or remote host. If the UPS is online or calibrating, the"));
00637   printf ("%s\n", _("plugin will return an OK state. If the battery is on it will return a WARNING"));
00638   printf ("%s\n", _("state. If the UPS is off or has a low battery the plugin will return a CRITICAL"));
00639   printf ("%s\n", _("state."));
00640 
00641   printf ("\n");
00642   printf ("%s\n", _("Notes:"));
00643   printf (" %s\n", _("You may also specify a variable to check (such as temperature, utility voltage,"));
00644   printf (" %s\n", _("battery load, etc.) as well as warning and critical thresholds for the value"));
00645   printf (" %s\n", _("of that variable.  If the remote host has multiple UPS that are being monitored"));
00646   printf (" %s\n", _("you will have to use the --ups option to specify which UPS to check."));
00647   printf ("\n");
00648   printf (" %s\n", _("This plugin requires that the UPSD daemon distributed with Russell Kroll's"));
00649   printf (" %s\n", _("Network UPS Tools be installed on the remote host. If you do not have the"));
00650   printf (" %s\n", _("package installed on your system, you can download it from"));
00651   printf (" %s\n", _("http://www.networkupstools.org"));
00652 
00653        printf (UT_SUPPORT);
00654 }
00655 
00656 
00657 void
00658 print_usage (void)
00659 {
00660   printf ("%s\n", _("Usage:"));
00661        printf ("%s -H host -u ups [-p port] [-v variable] [-w warn_value] [-c crit_value] [-to to_sec] [-T]\n", progname);
00662 }