check_ups.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  1. /******************************************************************************
  2. *
  3. * Nagios check_ups plugin
  4. *
  5. * License: GPL
  6. * Copyright (c) 2000 Tom Shields
  7. * 2004 Alain Richard <alain.richard@equation.fr>
  8. * 2004 Arnaud Quette <arnaud.quette@mgeups.com>
  9. * Copyright (c) 2002-2006 nagios-plugins team
  10. *
  11. * Last Modified: $Date$
  12. *
  13. * Description:
  14. *
  15. * This file contains Network UPS Tools plugin for Nagios
  16. *
  17. * License Information:
  18. *
  19. * This program is free software; you can redistribute it and/or modify
  20. * it under the terms of the GNU General Public License as published by
  21. * the Free Software Foundation; either version 2 of the License, or
  22. * (at your option) any later version.
  23. *
  24. * This program is distributed in the hope that it will be useful,
  25. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  26. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  27. * GNU General Public License for more details.
  28. *
  29. * You should have received a copy of the GNU General Public License
  30. * along with this program; if not, write to the Free Software
  31. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  32. *
  33. * $Id$
  34. *
  35. ******************************************************************************/
  36. const char *progname = "check_ups";
  37. const char *revision = "$Revision$";
  38. const char *copyright = "2000-2006";
  39. const char *email = "nagiosplug-devel@lists.sourceforge.net";
  40. #include "common.h"
  41. #include "netutils.h"
  42. #include "utils.h"
  43. enum {
  44. PORT = 3493
  45. };
  46. #define CHECK_NONE 0
  47. #define UPS_NONE 0 /* no supported options */
  48. #define UPS_UTILITY 1 /* supports utility line voltage */
  49. #define UPS_BATTPCT 2 /* supports percent battery remaining */
  50. #define UPS_STATUS 4 /* supports UPS status */
  51. #define UPS_TEMP 8 /* supports UPS temperature */
  52. #define UPS_LOADPCT 16 /* supports load percent */
  53. #define UPSSTATUS_NONE 0
  54. #define UPSSTATUS_OFF 1
  55. #define UPSSTATUS_OL 2
  56. #define UPSSTATUS_OB 4
  57. #define UPSSTATUS_LB 8
  58. #define UPSSTATUS_CAL 16
  59. #define UPSSTATUS_RB 32 /*Replace Battery */
  60. #define UPSSTATUS_BYPASS 64
  61. #define UPSSTATUS_OVER 128
  62. #define UPSSTATUS_TRIM 256
  63. #define UPSSTATUS_BOOST 512
  64. #define UPSSTATUS_CHRG 1024
  65. #define UPSSTATUS_DISCHRG 2048
  66. #define UPSSTATUS_UNKOWN 4096
  67. enum { NOSUCHVAR = ERROR-1 };
  68. int server_port = PORT;
  69. char *server_address;
  70. char *ups_name = NULL;
  71. double warning_value = 0.0;
  72. double critical_value = 0.0;
  73. int check_warn = FALSE;
  74. int check_crit = FALSE;
  75. int check_variable = UPS_NONE;
  76. int supported_options = UPS_NONE;
  77. int status = UPSSTATUS_NONE;
  78. double ups_utility_voltage = 0.0;
  79. double ups_battery_percent = 0.0;
  80. double ups_load_percent = 0.0;
  81. double ups_temperature = 0.0;
  82. char *ups_status;
  83. int temp_output_c = 0;
  84. int determine_status (void);
  85. int get_ups_variable (const char *, char *, size_t);
  86. int process_arguments (int, char **);
  87. int validate_arguments (void);
  88. void print_help (void);
  89. void print_usage (void);
  90. int
  91. main (int argc, char **argv)
  92. {
  93. int result = STATE_UNKNOWN;
  94. char *message;
  95. char *data;
  96. char *tunits;
  97. char temp_buffer[MAX_INPUT_BUFFER];
  98. double ups_utility_deviation = 0.0;
  99. int res;
  100. setlocale (LC_ALL, "");
  101. bindtextdomain (PACKAGE, LOCALEDIR);
  102. textdomain (PACKAGE);
  103. ups_status = strdup ("N/A");
  104. data = strdup ("");
  105. message = strdup ("");
  106. if (process_arguments (argc, argv) == ERROR)
  107. usage4 (_("Could not parse arguments"));
  108. /* initialize alarm signal handling */
  109. signal (SIGALRM, socket_timeout_alarm_handler);
  110. /* set socket timeout */
  111. alarm (socket_timeout);
  112. /* get the ups status if possible */
  113. if (determine_status () != OK)
  114. return STATE_CRITICAL;
  115. if (supported_options & UPS_STATUS) {
  116. ups_status = strdup ("");
  117. result = STATE_OK;
  118. if (status & UPSSTATUS_OFF) {
  119. asprintf (&ups_status, "Off");
  120. result = STATE_CRITICAL;
  121. }
  122. else if ((status & (UPSSTATUS_OB | UPSSTATUS_LB)) ==
  123. (UPSSTATUS_OB | UPSSTATUS_LB)) {
  124. asprintf (&ups_status, _("On Battery, Low Battery"));
  125. result = STATE_CRITICAL;
  126. }
  127. else {
  128. if (status & UPSSTATUS_OL) {
  129. asprintf (&ups_status, "%s%s", ups_status, _("Online"));
  130. }
  131. if (status & UPSSTATUS_OB) {
  132. asprintf (&ups_status, "%s%s", ups_status, _("On Battery"));
  133. result = STATE_WARNING;
  134. }
  135. if (status & UPSSTATUS_LB) {
  136. asprintf (&ups_status, "%s%s", ups_status, _(", Low Battery"));
  137. result = STATE_WARNING;
  138. }
  139. if (status & UPSSTATUS_CAL) {
  140. asprintf (&ups_status, "%s%s", ups_status, _(", Calibrating"));
  141. }
  142. if (status & UPSSTATUS_RB) {
  143. asprintf (&ups_status, "%s%s", ups_status, _(", Replace Battery"));
  144. result = STATE_WARNING;
  145. }
  146. if (status & UPSSTATUS_BYPASS) {
  147. asprintf (&ups_status, "%s%s", ups_status, _(", On Bypass"));
  148. }
  149. if (status & UPSSTATUS_OVER) {
  150. asprintf (&ups_status, "%s%s", ups_status, _(", Overload"));
  151. }
  152. if (status & UPSSTATUS_TRIM) {
  153. asprintf (&ups_status, "%s%s", ups_status, _(", Trimming"));
  154. }
  155. if (status & UPSSTATUS_BOOST) {
  156. asprintf (&ups_status, "%s%s", ups_status, _(", Boosting"));
  157. }
  158. if (status & UPSSTATUS_CHRG) {
  159. asprintf (&ups_status, "%s%s", ups_status, _(", Charging"));
  160. }
  161. if (status & UPSSTATUS_DISCHRG) {
  162. asprintf (&ups_status, "%s%s", ups_status, _(", Discharging"));
  163. }
  164. if (status & UPSSTATUS_UNKOWN) {
  165. asprintf (&ups_status, "%s%s", ups_status, _(", Unknown"));
  166. }
  167. }
  168. asprintf (&message, "%sStatus=%s ", message, ups_status);
  169. }
  170. /* get the ups utility voltage if possible */
  171. res=get_ups_variable ("input.voltage", temp_buffer, sizeof (temp_buffer));
  172. if (res == NOSUCHVAR) supported_options &= ~UPS_UTILITY;
  173. else if (res != OK)
  174. return STATE_CRITICAL;
  175. else {
  176. supported_options |= UPS_UTILITY;
  177. ups_utility_voltage = atof (temp_buffer);
  178. asprintf (&message, "%sUtility=%3.1fV ", message, ups_utility_voltage);
  179. if (ups_utility_voltage > 120.0)
  180. ups_utility_deviation = 120.0 - ups_utility_voltage;
  181. else
  182. ups_utility_deviation = ups_utility_voltage - 120.0;
  183. if (check_variable == UPS_UTILITY) {
  184. if (check_crit==TRUE && ups_utility_deviation>=critical_value) {
  185. result = STATE_CRITICAL;
  186. }
  187. else if (check_warn==TRUE && ups_utility_deviation>=warning_value) {
  188. result = max_state (result, STATE_WARNING);
  189. }
  190. asprintf (&data, "%s",
  191. perfdata ("voltage", (long)(1000*ups_utility_voltage), "mV",
  192. check_warn, (long)(1000*warning_value),
  193. check_crit, (long)(1000*critical_value),
  194. TRUE, 0, FALSE, 0));
  195. } else {
  196. asprintf (&data, "%s",
  197. perfdata ("voltage", (long)(1000*ups_utility_voltage), "mV",
  198. FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0));
  199. }
  200. }
  201. /* get the ups battery percent if possible */
  202. res=get_ups_variable ("battery.charge", temp_buffer, sizeof (temp_buffer));
  203. if (res == NOSUCHVAR) supported_options &= ~UPS_BATTPCT;
  204. else if ( res != OK)
  205. return STATE_CRITICAL;
  206. else {
  207. supported_options |= UPS_BATTPCT;
  208. ups_battery_percent = atof (temp_buffer);
  209. asprintf (&message, "%sBatt=%3.1f%% ", message, ups_battery_percent);
  210. if (check_variable == UPS_BATTPCT) {
  211. if (check_crit==TRUE && ups_battery_percent <= critical_value) {
  212. result = STATE_CRITICAL;
  213. }
  214. else if (check_warn==TRUE && ups_battery_percent<=warning_value) {
  215. result = max_state (result, STATE_WARNING);
  216. }
  217. asprintf (&data, "%s %s", data,
  218. perfdata ("battery", (long)ups_battery_percent, "%",
  219. check_warn, (long)(1000*warning_value),
  220. check_crit, (long)(1000*critical_value),
  221. TRUE, 0, TRUE, 100));
  222. } else {
  223. asprintf (&data, "%s %s", data,
  224. perfdata ("battery", (long)ups_battery_percent, "%",
  225. FALSE, 0, FALSE, 0, TRUE, 0, TRUE, 100));
  226. }
  227. }
  228. /* get the ups load percent if possible */
  229. res=get_ups_variable ("ups.load", temp_buffer, sizeof (temp_buffer));
  230. if ( res == NOSUCHVAR ) supported_options &= ~UPS_LOADPCT;
  231. else if ( res != OK)
  232. return STATE_CRITICAL;
  233. else {
  234. supported_options |= UPS_LOADPCT;
  235. ups_load_percent = atof (temp_buffer);
  236. asprintf (&message, "%sLoad=%3.1f%% ", message, ups_load_percent);
  237. if (check_variable == UPS_LOADPCT) {
  238. if (check_crit==TRUE && ups_load_percent>=critical_value) {
  239. result = STATE_CRITICAL;
  240. }
  241. else if (check_warn==TRUE && ups_load_percent>=warning_value) {
  242. result = max_state (result, STATE_WARNING);
  243. }
  244. asprintf (&data, "%s %s", data,
  245. perfdata ("load", (long)ups_load_percent, "%",
  246. check_warn, (long)(1000*warning_value),
  247. check_crit, (long)(1000*critical_value),
  248. TRUE, 0, TRUE, 100));
  249. } else {
  250. asprintf (&data, "%s %s", data,
  251. perfdata ("load", (long)ups_load_percent, "%",
  252. FALSE, 0, FALSE, 0, TRUE, 0, TRUE, 100));
  253. }
  254. }
  255. /* get the ups temperature if possible */
  256. res=get_ups_variable ("ups.temperature", temp_buffer, sizeof (temp_buffer));
  257. if ( res == NOSUCHVAR ) supported_options &= ~UPS_TEMP;
  258. else if ( res != OK)
  259. return STATE_CRITICAL;
  260. else {
  261. supported_options |= UPS_TEMP;
  262. if (temp_output_c) {
  263. tunits="degC";
  264. ups_temperature = atof (temp_buffer);
  265. asprintf (&message, "%sTemp=%3.1fC", message, ups_temperature);
  266. }
  267. else {
  268. tunits="degF";
  269. ups_temperature = (atof (temp_buffer) * 1.8) + 32;
  270. asprintf (&message, "%sTemp=%3.1fF", message, ups_temperature);
  271. }
  272. if (check_variable == UPS_TEMP) {
  273. if (check_crit==TRUE && ups_temperature>=critical_value) {
  274. result = STATE_CRITICAL;
  275. }
  276. else if (check_warn == TRUE && ups_temperature>=warning_value) {
  277. result = max_state (result, STATE_WARNING);
  278. }
  279. asprintf (&data, "%s %s", data,
  280. perfdata ("temp", (long)ups_temperature, tunits,
  281. check_warn, (long)(1000*warning_value),
  282. check_crit, (long)(1000*critical_value),
  283. TRUE, 0, FALSE, 0));
  284. } else {
  285. asprintf (&data, "%s %s", data,
  286. perfdata ("temp", (long)ups_temperature, tunits,
  287. FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0));
  288. }
  289. }
  290. /* if the UPS does not support any options we are looking for, report an error */
  291. if (supported_options == UPS_NONE) {
  292. result = STATE_CRITICAL;
  293. asprintf (&message, _("UPS does not support any available options\n"));
  294. }
  295. /* reset timeout */
  296. alarm (0);
  297. printf ("UPS %s - %s|%s\n", state_text(result), message, data);
  298. return result;
  299. }
  300. /* determines what options are supported by the UPS */
  301. int
  302. determine_status (void)
  303. {
  304. char recv_buffer[MAX_INPUT_BUFFER];
  305. char temp_buffer[MAX_INPUT_BUFFER];
  306. char *ptr;
  307. int res;
  308. res=get_ups_variable ("ups.status", recv_buffer, sizeof (recv_buffer));
  309. if (res == NOSUCHVAR) return OK;
  310. if (res != STATE_OK) {
  311. printf ("%s\n", _("Invalid response received from host"));
  312. return ERROR;
  313. }
  314. supported_options |= UPS_STATUS;
  315. strcpy (temp_buffer, recv_buffer);
  316. for (ptr = (char *) strtok (temp_buffer, " "); ptr != NULL;
  317. ptr = (char *) strtok (NULL, " ")) {
  318. if (!strcmp (ptr, "OFF"))
  319. status |= UPSSTATUS_OFF;
  320. else if (!strcmp (ptr, "OL"))
  321. status |= UPSSTATUS_OL;
  322. else if (!strcmp (ptr, "OB"))
  323. status |= UPSSTATUS_OB;
  324. else if (!strcmp (ptr, "LB"))
  325. status |= UPSSTATUS_LB;
  326. else if (!strcmp (ptr, "CAL"))
  327. status |= UPSSTATUS_CAL;
  328. else if (!strcmp (ptr, "RB"))
  329. status |= UPSSTATUS_RB;
  330. else if (!strcmp (ptr, "BYPASS"))
  331. status |= UPSSTATUS_BYPASS;
  332. else if (!strcmp (ptr, "OVER"))
  333. status |= UPSSTATUS_OVER;
  334. else if (!strcmp (ptr, "TRIM"))
  335. status |= UPSSTATUS_TRIM;
  336. else if (!strcmp (ptr, "BOOST"))
  337. status |= UPSSTATUS_BOOST;
  338. else if (!strcmp (ptr, "CHRG"))
  339. status |= UPSSTATUS_CHRG;
  340. else if (!strcmp (ptr, "DISCHRG"))
  341. status |= UPSSTATUS_DISCHRG;
  342. else
  343. status |= UPSSTATUS_UNKOWN;
  344. }
  345. return OK;
  346. }
  347. /* gets a variable value for a specific UPS */
  348. int
  349. get_ups_variable (const char *varname, char *buf, size_t buflen)
  350. {
  351. /* char command[MAX_INPUT_BUFFER]; */
  352. char temp_buffer[MAX_INPUT_BUFFER];
  353. char send_buffer[MAX_INPUT_BUFFER];
  354. char *ptr;
  355. int len;
  356. *buf=0;
  357. /* create the command string to send to the UPS daemon */
  358. sprintf (send_buffer, "GET VAR %s %s\n", ups_name, varname);
  359. /* send the command to the daemon and get a response back */
  360. if (process_tcp_request
  361. (server_address, server_port, send_buffer, temp_buffer,
  362. sizeof (temp_buffer)) != STATE_OK) {
  363. printf ("%s\n", _("Invalid response received from host"));
  364. return ERROR;
  365. }
  366. ptr = temp_buffer;
  367. len = strlen(ptr);
  368. if (len > 0 && ptr[len-1] == '\n') ptr[len-1]=0;
  369. if (strcmp (ptr, "ERR UNKNOWN-UPS") == 0) {
  370. printf (_("CRITICAL - no such ups '%s' on that host\n"), ups_name);
  371. return ERROR;
  372. }
  373. if (strcmp (ptr, "ERR VAR-NOT-SUPPORTED") == 0) {
  374. /*printf ("Error: Variable '%s' is not supported\n", varname);*/
  375. return NOSUCHVAR;
  376. }
  377. if (strcmp (ptr, "ERR DATA-STALE") == 0) {
  378. printf ("%s\n", _("CRITICAL - UPS data is stale"));
  379. return ERROR;
  380. }
  381. if (strncmp (ptr, "ERR", 3) == 0) {
  382. printf (_("Unknown error: %s\n"), ptr);
  383. return ERROR;
  384. }
  385. ptr = temp_buffer + strlen (varname) + strlen (ups_name) + 6;
  386. len = strlen(ptr);
  387. if (len < 2 || ptr[0] != '"' || ptr[len-1] != '"') {
  388. printf ("%s\n", _("Error: unable to parse variable"));
  389. return ERROR;
  390. }
  391. strncpy (buf, ptr+1, len - 2);
  392. buf[len - 2] = 0;
  393. return OK;
  394. }
  395. /* Command line: CHECK_UPS -H <host_address> -u ups [-p port] [-v variable]
  396. [-wv warn_value] [-cv crit_value] [-to to_sec] */
  397. /* process command-line arguments */
  398. int
  399. process_arguments (int argc, char **argv)
  400. {
  401. int c;
  402. int option = 0;
  403. static struct option longopts[] = {
  404. {"hostname", required_argument, 0, 'H'},
  405. {"ups", required_argument, 0, 'u'},
  406. {"port", required_argument, 0, 'p'},
  407. {"critical", required_argument, 0, 'c'},
  408. {"warning", required_argument, 0, 'w'},
  409. {"timeout", required_argument, 0, 't'},
  410. {"temperature", no_argument, 0, 'T'},
  411. {"variable", required_argument, 0, 'v'},
  412. {"version", no_argument, 0, 'V'},
  413. {"help", no_argument, 0, 'h'},
  414. {0, 0, 0, 0}
  415. };
  416. if (argc < 2)
  417. return ERROR;
  418. for (c = 1; c < argc; c++) {
  419. if (strcmp ("-to", argv[c]) == 0)
  420. strcpy (argv[c], "-t");
  421. else if (strcmp ("-wt", argv[c]) == 0)
  422. strcpy (argv[c], "-w");
  423. else if (strcmp ("-ct", argv[c]) == 0)
  424. strcpy (argv[c], "-c");
  425. }
  426. while (1) {
  427. c = getopt_long (argc, argv, "hVTH:u:p:v:c:w:t:", longopts,
  428. &option);
  429. if (c == -1 || c == EOF)
  430. break;
  431. switch (c) {
  432. case '?': /* help */
  433. usage2 (_("Unknown argument"), optarg);
  434. case 'H': /* hostname */
  435. if (is_host (optarg)) {
  436. server_address = optarg;
  437. }
  438. else {
  439. usage2 (_("Invalid hostname/address"), optarg);
  440. }
  441. break;
  442. case 'T': /* FIXME: to be improved (ie "-T C" for Celsius or "-T F" for Farenheit) */
  443. temp_output_c = 1;
  444. break;
  445. case 'u': /* ups name */
  446. ups_name = optarg;
  447. break;
  448. case 'p': /* port */
  449. if (is_intpos (optarg)) {
  450. server_port = atoi (optarg);
  451. }
  452. else {
  453. usage2 (_("Port must be a positive integer"), optarg);
  454. }
  455. break;
  456. case 'c': /* critical time threshold */
  457. if (is_intnonneg (optarg)) {
  458. critical_value = atoi (optarg);
  459. check_crit = TRUE;
  460. }
  461. else {
  462. usage2 (_("Critical time must be a positive integer"), optarg);
  463. }
  464. break;
  465. case 'w': /* warning time threshold */
  466. if (is_intnonneg (optarg)) {
  467. warning_value = atoi (optarg);
  468. check_warn = TRUE;
  469. }
  470. else {
  471. usage2 (_("Warning time must be a positive integer"), optarg);
  472. }
  473. break;
  474. case 'v': /* variable */
  475. if (!strcmp (optarg, "LINE"))
  476. check_variable = UPS_UTILITY;
  477. else if (!strcmp (optarg, "TEMP"))
  478. check_variable = UPS_TEMP;
  479. else if (!strcmp (optarg, "BATTPCT"))
  480. check_variable = UPS_BATTPCT;
  481. else if (!strcmp (optarg, "LOADPCT"))
  482. check_variable = UPS_LOADPCT;
  483. else
  484. usage2 (_("Unrecognized UPS variable"), optarg);
  485. break;
  486. case 't': /* timeout */
  487. if (is_intnonneg (optarg)) {
  488. socket_timeout = atoi (optarg);
  489. }
  490. else {
  491. usage4 (_("Timeout interval must be a positive integer"));
  492. }
  493. break;
  494. case 'V': /* version */
  495. print_revision (progname, revision);
  496. exit (STATE_OK);
  497. case 'h': /* help */
  498. print_help ();
  499. exit (STATE_OK);
  500. }
  501. }
  502. if (server_address == NULL && argc > optind) {
  503. if (is_host (argv[optind]))
  504. server_address = argv[optind++];
  505. else
  506. usage2 (_("Invalid hostname/address"), optarg);
  507. }
  508. if (server_address == NULL)
  509. server_address = strdup("127.0.0.1");
  510. return validate_arguments();
  511. }
  512. int
  513. validate_arguments (void)
  514. {
  515. if (! ups_name) {
  516. printf ("%s\n", _("Error : no ups indicated"));
  517. return ERROR;
  518. }
  519. return OK;
  520. }
  521. void
  522. print_help (void)
  523. {
  524. char *myport;
  525. asprintf (&myport, "%d", PORT);
  526. print_revision (progname, revision);
  527. printf ("Copyright (c) 2000 Tom Shields");
  528. printf ("Copyright (c) 2004 Alain Richard <alain.richard@equation.fr>\n");
  529. printf ("Copyright (c) 2004 Arnaud Quette <arnaud.quette@mgeups.com>\n");
  530. printf (COPYRIGHT, copyright, email);
  531. printf ("%s\n", _("This plugin tests the UPS service on the specified host.Network UPS Tools "));
  532. printf ("%s\n", _("from www.networkupstools.org must be running for thisplugin to work."));
  533. printf ("\n\n");
  534. print_usage ();
  535. printf (_(UT_HELP_VRSN));
  536. printf (_(UT_HOST_PORT), 'p', myport);
  537. printf (" %s\n", "-u, --ups=STRING");
  538. printf (" %s\n", _("Name of UPS"));
  539. printf (" %s\n", "-T, --temperature");
  540. printf (" %s\n", _("Output of temperatures in Celsius"));
  541. printf (_(UT_WARN_CRIT));
  542. printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
  543. printf (_(UT_VERBOSE));
  544. printf ("\n");
  545. printf ("%s\n", _("Notes:"));
  546. printf ("%s\n", _("This plugin attempts to determine the status of a UPS (Uninterruptible Power"));
  547. printf ("%s\n", _("Supply) on a local or remote host. If the UPS is online or calibrating, the"));
  548. printf ("%s\n", _("plugin will return an OK state. If the battery is on it will return a WARNING"));
  549. printf ("%s\n", _("state.If the UPS is off or has a low battery the plugin will return a CRITICAL"));
  550. printf ("%s\n\n", _("state."));
  551. printf ("%s\n", _("You may also specify a variable to check [such as temperature, utility voltage,"));
  552. printf ("%s\n", _("battery load, etc.] as well as warning and critical thresholds for the value of"));
  553. printf ("%s\n", _("that variable. If the remote host has multiple UPS that are being monitored you"));
  554. printf ("%s\n", _("will have to use the [ups] option to specify which UPS to check."));
  555. printf ("%s\n", _("This plugin requires that the UPSD daemon distributed with Russel Kroll's"));
  556. printf ("%s\n", _("Smart UPS Tools be installed on the remote host. If you do not have the"));
  557. printf ("%s\n", _("package installed on your system, you can download it from http://www.networkupstools.org"));
  558. printf (_(UT_SUPPORT));
  559. }
  560. void
  561. print_usage (void)
  562. {
  563. printf (_("Usage:"));
  564. printf ("%s -H host -u ups [-p port] [-v variable] [-w warn_value] [-c crit_value] [-to to_sec] [-T]\n", progname);
  565. }