check_ups.c 19 KB

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