check_ups.c 19 KB

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