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. * Description:
  12. *
  13. * This file contains Network UPS Tools plugin for Nagios
  14. *
  15. * This plugin tests the UPS service on the specified host. Network UPS Tools
  16. * from www.networkupstools.org must be running for this plugin to work.
  17. *
  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 3 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, see <http://www.gnu.org/licenses/>.
  31. *
  32. *
  33. *****************************************************************************/
  34. const char *progname = "check_ups";
  35. const char *copyright = "2000-2007";
  36. const char *email = "nagiosplug-devel@lists.sourceforge.net";
  37. #include "common.h"
  38. #include "netutils.h"
  39. #include "utils.h"
  40. enum {
  41. PORT = 3493
  42. };
  43. #define CHECK_NONE 0
  44. #define UPS_NONE 0 /* no supported options */
  45. #define UPS_UTILITY 1 /* supports utility line voltage */
  46. #define UPS_BATTPCT 2 /* supports percent battery remaining */
  47. #define UPS_STATUS 4 /* supports UPS status */
  48. #define UPS_TEMP 8 /* supports UPS temperature */
  49. #define UPS_LOADPCT 16 /* supports load percent */
  50. #define UPSSTATUS_NONE 0
  51. #define UPSSTATUS_OFF 1
  52. #define UPSSTATUS_OL 2
  53. #define UPSSTATUS_OB 4
  54. #define UPSSTATUS_LB 8
  55. #define UPSSTATUS_CAL 16
  56. #define UPSSTATUS_RB 32 /*Replace Battery */
  57. #define UPSSTATUS_BYPASS 64
  58. #define UPSSTATUS_OVER 128
  59. #define UPSSTATUS_TRIM 256
  60. #define UPSSTATUS_BOOST 512
  61. #define UPSSTATUS_CHRG 1024
  62. #define UPSSTATUS_DISCHRG 2048
  63. #define UPSSTATUS_UNKOWN 4096
  64. enum { NOSUCHVAR = ERROR-1 };
  65. int server_port = PORT;
  66. char *server_address;
  67. char *ups_name = NULL;
  68. double warning_value = 0.0;
  69. double critical_value = 0.0;
  70. int check_warn = FALSE;
  71. int check_crit = FALSE;
  72. int check_variable = UPS_NONE;
  73. int supported_options = UPS_NONE;
  74. int status = UPSSTATUS_NONE;
  75. double ups_utility_voltage = 0.0;
  76. double ups_battery_percent = 0.0;
  77. double ups_load_percent = 0.0;
  78. double ups_temperature = 0.0;
  79. char *ups_status;
  80. int temp_output_c = 0;
  81. int determine_status (void);
  82. int get_ups_variable (const char *, char *, size_t);
  83. int process_arguments (int, char **);
  84. int validate_arguments (void);
  85. void print_help (void);
  86. void print_usage (void);
  87. int
  88. main (int argc, char **argv)
  89. {
  90. int result = STATE_UNKNOWN;
  91. char *message;
  92. char *data;
  93. char *tunits;
  94. char temp_buffer[MAX_INPUT_BUFFER];
  95. double ups_utility_deviation = 0.0;
  96. int res;
  97. setlocale (LC_ALL, "");
  98. bindtextdomain (PACKAGE, LOCALEDIR);
  99. textdomain (PACKAGE);
  100. ups_status = strdup ("N/A");
  101. data = strdup ("");
  102. message = strdup ("");
  103. /* Parse extra opts if any */
  104. argv=np_extra_opts (&argc, argv, progname);
  105. if (process_arguments (argc, argv) == ERROR)
  106. usage4 (_("Could not parse arguments"));
  107. /* initialize alarm signal handling */
  108. signal (SIGALRM, socket_timeout_alarm_handler);
  109. /* set socket timeout */
  110. alarm (socket_timeout);
  111. /* get the ups status if possible */
  112. if (determine_status () != OK)
  113. return STATE_CRITICAL;
  114. if (supported_options & UPS_STATUS) {
  115. ups_status = strdup ("");
  116. result = STATE_OK;
  117. if (status & UPSSTATUS_OFF) {
  118. asprintf (&ups_status, "Off");
  119. result = STATE_CRITICAL;
  120. }
  121. else if ((status & (UPSSTATUS_OB | UPSSTATUS_LB)) ==
  122. (UPSSTATUS_OB | UPSSTATUS_LB)) {
  123. asprintf (&ups_status, _("On Battery, Low Battery"));
  124. result = STATE_CRITICAL;
  125. }
  126. else {
  127. if (status & UPSSTATUS_OL) {
  128. asprintf (&ups_status, "%s%s", ups_status, _("Online"));
  129. }
  130. if (status & UPSSTATUS_OB) {
  131. asprintf (&ups_status, "%s%s", ups_status, _("On Battery"));
  132. result = STATE_WARNING;
  133. }
  134. if (status & UPSSTATUS_LB) {
  135. asprintf (&ups_status, "%s%s", ups_status, _(", Low Battery"));
  136. result = STATE_WARNING;
  137. }
  138. if (status & UPSSTATUS_CAL) {
  139. asprintf (&ups_status, "%s%s", ups_status, _(", Calibrating"));
  140. }
  141. if (status & UPSSTATUS_RB) {
  142. asprintf (&ups_status, "%s%s", ups_status, _(", Replace Battery"));
  143. result = STATE_WARNING;
  144. }
  145. if (status & UPSSTATUS_BYPASS) {
  146. asprintf (&ups_status, "%s%s", ups_status, _(", On Bypass"));
  147. }
  148. if (status & UPSSTATUS_OVER) {
  149. asprintf (&ups_status, "%s%s", ups_status, _(", Overload"));
  150. }
  151. if (status & UPSSTATUS_TRIM) {
  152. asprintf (&ups_status, "%s%s", ups_status, _(", Trimming"));
  153. }
  154. if (status & UPSSTATUS_BOOST) {
  155. asprintf (&ups_status, "%s%s", ups_status, _(", Boosting"));
  156. }
  157. if (status & UPSSTATUS_CHRG) {
  158. asprintf (&ups_status, "%s%s", ups_status, _(", Charging"));
  159. }
  160. if (status & UPSSTATUS_DISCHRG) {
  161. asprintf (&ups_status, "%s%s", ups_status, _(", Discharging"));
  162. }
  163. if (status & UPSSTATUS_UNKOWN) {
  164. asprintf (&ups_status, "%s%s", ups_status, _(", Unknown"));
  165. }
  166. }
  167. asprintf (&message, "%sStatus=%s ", message, ups_status);
  168. }
  169. /* get the ups utility voltage if possible */
  170. res=get_ups_variable ("input.voltage", temp_buffer, sizeof (temp_buffer));
  171. if (res == NOSUCHVAR) supported_options &= ~UPS_UTILITY;
  172. else if (res != OK)
  173. return STATE_CRITICAL;
  174. else {
  175. supported_options |= UPS_UTILITY;
  176. ups_utility_voltage = atof (temp_buffer);
  177. asprintf (&message, "%sUtility=%3.1fV ", message, ups_utility_voltage);
  178. if (ups_utility_voltage > 120.0)
  179. ups_utility_deviation = 120.0 - ups_utility_voltage;
  180. else
  181. ups_utility_deviation = ups_utility_voltage - 120.0;
  182. if (check_variable == UPS_UTILITY) {
  183. if (check_crit==TRUE && ups_utility_deviation>=critical_value) {
  184. result = STATE_CRITICAL;
  185. }
  186. else if (check_warn==TRUE && ups_utility_deviation>=warning_value) {
  187. result = max_state (result, STATE_WARNING);
  188. }
  189. asprintf (&data, "%s",
  190. perfdata ("voltage", (long)(1000*ups_utility_voltage), "mV",
  191. check_warn, (long)(1000*warning_value),
  192. check_crit, (long)(1000*critical_value),
  193. TRUE, 0, FALSE, 0));
  194. } else {
  195. asprintf (&data, "%s",
  196. perfdata ("voltage", (long)(1000*ups_utility_voltage), "mV",
  197. FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0));
  198. }
  199. }
  200. /* get the ups battery percent if possible */
  201. res=get_ups_variable ("battery.charge", temp_buffer, sizeof (temp_buffer));
  202. if (res == NOSUCHVAR) supported_options &= ~UPS_BATTPCT;
  203. else if ( res != OK)
  204. return STATE_CRITICAL;
  205. else {
  206. supported_options |= UPS_BATTPCT;
  207. ups_battery_percent = atof (temp_buffer);
  208. asprintf (&message, "%sBatt=%3.1f%% ", message, ups_battery_percent);
  209. if (check_variable == UPS_BATTPCT) {
  210. if (check_crit==TRUE && ups_battery_percent <= critical_value) {
  211. result = STATE_CRITICAL;
  212. }
  213. else if (check_warn==TRUE && ups_battery_percent<=warning_value) {
  214. result = max_state (result, STATE_WARNING);
  215. }
  216. asprintf (&data, "%s %s", data,
  217. perfdata ("battery", (long)ups_battery_percent, "%",
  218. check_warn, (long)(1000*warning_value),
  219. check_crit, (long)(1000*critical_value),
  220. TRUE, 0, TRUE, 100));
  221. } else {
  222. asprintf (&data, "%s %s", data,
  223. perfdata ("battery", (long)ups_battery_percent, "%",
  224. FALSE, 0, FALSE, 0, TRUE, 0, TRUE, 100));
  225. }
  226. }
  227. /* get the ups load percent if possible */
  228. res=get_ups_variable ("ups.load", temp_buffer, sizeof (temp_buffer));
  229. if ( res == NOSUCHVAR ) supported_options &= ~UPS_LOADPCT;
  230. else if ( res != OK)
  231. return STATE_CRITICAL;
  232. else {
  233. supported_options |= UPS_LOADPCT;
  234. ups_load_percent = atof (temp_buffer);
  235. asprintf (&message, "%sLoad=%3.1f%% ", message, ups_load_percent);
  236. if (check_variable == UPS_LOADPCT) {
  237. if (check_crit==TRUE && ups_load_percent>=critical_value) {
  238. result = STATE_CRITICAL;
  239. }
  240. else if (check_warn==TRUE && ups_load_percent>=warning_value) {
  241. result = max_state (result, STATE_WARNING);
  242. }
  243. asprintf (&data, "%s %s", data,
  244. perfdata ("load", (long)ups_load_percent, "%",
  245. check_warn, (long)(1000*warning_value),
  246. check_crit, (long)(1000*critical_value),
  247. TRUE, 0, TRUE, 100));
  248. } else {
  249. asprintf (&data, "%s %s", data,
  250. perfdata ("load", (long)ups_load_percent, "%",
  251. FALSE, 0, FALSE, 0, TRUE, 0, TRUE, 100));
  252. }
  253. }
  254. /* get the ups temperature if possible */
  255. res=get_ups_variable ("ups.temperature", temp_buffer, sizeof (temp_buffer));
  256. if ( res == NOSUCHVAR ) supported_options &= ~UPS_TEMP;
  257. else if ( res != OK)
  258. return STATE_CRITICAL;
  259. else {
  260. supported_options |= UPS_TEMP;
  261. if (temp_output_c) {
  262. tunits="degC";
  263. ups_temperature = atof (temp_buffer);
  264. asprintf (&message, "%sTemp=%3.1fC", message, ups_temperature);
  265. }
  266. else {
  267. tunits="degF";
  268. ups_temperature = (atof (temp_buffer) * 1.8) + 32;
  269. asprintf (&message, "%sTemp=%3.1fF", message, ups_temperature);
  270. }
  271. if (check_variable == UPS_TEMP) {
  272. if (check_crit==TRUE && ups_temperature>=critical_value) {
  273. result = STATE_CRITICAL;
  274. }
  275. else if (check_warn == TRUE && ups_temperature>=warning_value) {
  276. result = max_state (result, STATE_WARNING);
  277. }
  278. asprintf (&data, "%s %s", data,
  279. perfdata ("temp", (long)ups_temperature, tunits,
  280. check_warn, (long)(1000*warning_value),
  281. check_crit, (long)(1000*critical_value),
  282. TRUE, 0, FALSE, 0));
  283. } else {
  284. asprintf (&data, "%s %s", data,
  285. perfdata ("temp", (long)ups_temperature, tunits,
  286. FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0));
  287. }
  288. }
  289. /* if the UPS does not support any options we are looking for, report an error */
  290. if (supported_options == UPS_NONE) {
  291. result = STATE_CRITICAL;
  292. asprintf (&message, _("UPS does not support any available options\n"));
  293. }
  294. /* reset timeout */
  295. alarm (0);
  296. printf ("UPS %s - %s|%s\n", state_text(result), message, data);
  297. return result;
  298. }
  299. /* determines what options are supported by the UPS */
  300. int
  301. determine_status (void)
  302. {
  303. char recv_buffer[MAX_INPUT_BUFFER];
  304. char temp_buffer[MAX_INPUT_BUFFER];
  305. char *ptr;
  306. int res;
  307. res=get_ups_variable ("ups.status", recv_buffer, sizeof (recv_buffer));
  308. if (res == NOSUCHVAR) return OK;
  309. if (res != STATE_OK) {
  310. printf ("%s\n", _("Invalid response received from host"));
  311. return ERROR;
  312. }
  313. supported_options |= UPS_STATUS;
  314. strcpy (temp_buffer, recv_buffer);
  315. for (ptr = (char *) strtok (temp_buffer, " "); ptr != NULL;
  316. ptr = (char *) strtok (NULL, " ")) {
  317. if (!strcmp (ptr, "OFF"))
  318. status |= UPSSTATUS_OFF;
  319. else if (!strcmp (ptr, "OL"))
  320. status |= UPSSTATUS_OL;
  321. else if (!strcmp (ptr, "OB"))
  322. status |= UPSSTATUS_OB;
  323. else if (!strcmp (ptr, "LB"))
  324. status |= UPSSTATUS_LB;
  325. else if (!strcmp (ptr, "CAL"))
  326. status |= UPSSTATUS_CAL;
  327. else if (!strcmp (ptr, "RB"))
  328. status |= UPSSTATUS_RB;
  329. else if (!strcmp (ptr, "BYPASS"))
  330. status |= UPSSTATUS_BYPASS;
  331. else if (!strcmp (ptr, "OVER"))
  332. status |= UPSSTATUS_OVER;
  333. else if (!strcmp (ptr, "TRIM"))
  334. status |= UPSSTATUS_TRIM;
  335. else if (!strcmp (ptr, "BOOST"))
  336. status |= UPSSTATUS_BOOST;
  337. else if (!strcmp (ptr, "CHRG"))
  338. status |= UPSSTATUS_CHRG;
  339. else if (!strcmp (ptr, "DISCHRG"))
  340. status |= UPSSTATUS_DISCHRG;
  341. else
  342. status |= UPSSTATUS_UNKOWN;
  343. }
  344. return OK;
  345. }
  346. /* gets a variable value for a specific UPS */
  347. int
  348. get_ups_variable (const char *varname, char *buf, size_t buflen)
  349. {
  350. /* char command[MAX_INPUT_BUFFER]; */
  351. char temp_buffer[MAX_INPUT_BUFFER];
  352. char send_buffer[MAX_INPUT_BUFFER];
  353. char *ptr;
  354. char *logout = "OK Goodbye\n";
  355. int logout_len = strlen(logout);
  356. int len;
  357. *buf=0;
  358. /* create the command string to send to the UPS daemon */
  359. /* Add LOGOUT to avoid read failure logs */
  360. sprintf (send_buffer, "GET VAR %s %s\nLOGOUT\n", ups_name, varname);
  361. /* send the command to the daemon and get a response back */
  362. if (process_tcp_request
  363. (server_address, server_port, send_buffer, temp_buffer,
  364. sizeof (temp_buffer)) != STATE_OK) {
  365. printf ("%s\n", _("Invalid response received from host"));
  366. return ERROR;
  367. }
  368. ptr = temp_buffer;
  369. len = strlen(ptr);
  370. if (len > logout_len && strcmp (ptr + len - logout_len, logout) == 0) len -= logout_len;
  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, NP_VERSION);
  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, NP_VERSION);
  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 this plugin 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 Russell Kroll's"));
  566. printf (" %s\n", _("Network 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. }