diff options
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2003-08-04 07:42:24 +0000 |
---|---|---|
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2003-08-04 07:42:24 +0000 |
commit | 55def28f6619ab0f9807a0195aa01da5d6ff1dc0 (patch) | |
tree | f0762811e1ff964e874d88bd4448b64213bcbd45 /plugins/check_ups.c | |
parent | 04b3d4554b829531ee4859859e7dd25fe660bba8 (diff) | |
download | monitoring-plugins-55def28f6619ab0f9807a0195aa01da5d6ff1dc0.tar.gz |
markup for translation
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@643 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_ups.c')
-rw-r--r-- | plugins/check_ups.c | 209 |
1 files changed, 92 insertions, 117 deletions
diff --git a/plugins/check_ups.c b/plugins/check_ups.c index b077d31f..499b9222 100644 --- a/plugins/check_ups.c +++ b/plugins/check_ups.c | |||
@@ -1,70 +1,97 @@ | |||
1 | /****************************************************************************** | 1 | /****************************************************************************** |
2 | * | 2 | |
3 | * CHECK_UPS.C | 3 | This program is free software; you can redistribute it and/or modify |
4 | * | 4 | it under the terms of the GNU General Public License as published by |
5 | * Program: UPS monitor plugin for Nagios | 5 | the Free Software Foundation; either version 2 of the License, or (at |
6 | * License: GPL | 6 | your option) any later version. |
7 | * Copyright (c) 1999 Ethan Galstad (nagios@nagios.org) | 7 | |
8 | * | 8 | This program is distributed in the hope that it will be useful, but |
9 | * Last Modified: $Date$ | 9 | WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * | 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
11 | * Command line: CHECK_UPS <host_address> [-u ups] [-p port] [-v variable] \ | 11 | General Public License for more details. |
12 | * [-wv warn_value] [-cv crit_value] [-to to_sec] | 12 | |
13 | * | 13 | You should have received a copy of the GNU General Public License |
14 | * Description: | 14 | along with this program; if not, write to the Free Software |
15 | * | 15 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
16 | 16 | ||
17 | * This plugin attempts to determine the status of an UPS | ||
18 | * (Uninterruptible Power Supply) on a remote host (or the local host) | ||
19 | * that is being monitored with Russel Kroll's "Smarty UPS Tools" | ||
20 | * package. If the UPS is online or calibrating, the plugin will | ||
21 | * return an OK state. If the battery is on it will return a WARNING | ||
22 | * state. If the UPS is off or has a low battery the plugin will | ||
23 | * return a CRITICAL state. You may also specify a variable to check | ||
24 | * (such as temperature, utility voltage, battery load, etc.) as well | ||
25 | * as warning and critical thresholds for the value of that variable. | ||
26 | * If the remote host has multiple UPS that are being monitored you | ||
27 | * will have to use the [ups] option to specify which UPS to check. | ||
28 | * | ||
29 | * Notes: | ||
30 | * | ||
31 | * This plugin requires that the UPSD daemon distributed with Russel | ||
32 | * Kroll's "Smart UPS Tools" be installed on the remote host. If you | ||
33 | * don't have the package installed on your system, you can download | ||
34 | * it from http://www.exploits.org/nut | ||
35 | * | ||
36 | * License Information: | ||
37 | * | ||
38 | * This program is free software; you can redistribute it and/or modify | ||
39 | * it under the terms of the GNU General Public License as published by | ||
40 | * the Free Software Foundation; either version 2 of the License, or | ||
41 | * (at your option) any later version. | ||
42 | * | ||
43 | * This program is distributed in the hope that it will be useful, | ||
44 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
45 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
46 | * GNU General Public License for more details. | ||
47 | * | ||
48 | * You should have received a copy of the GNU General Public License | ||
49 | * along with this program; if not, write to the Free Software | ||
50 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
51 | * | ||
52 | ******************************************************************************/ | 17 | ******************************************************************************/ |
53 | 18 | ||
54 | #include "config.h" | 19 | const char *progname = "check_ups"; |
20 | const char *revision = "$Revision$"; | ||
21 | const char *copyright = "2000-2002"; | ||
22 | const char *email = "nagiosplug-devel@lists.sourceforge.net"; | ||
23 | |||
55 | #include "common.h" | 24 | #include "common.h" |
56 | #include "netutils.h" | 25 | #include "netutils.h" |
57 | #include "utils.h" | 26 | #include "utils.h" |
58 | 27 | ||
59 | const char *progname = "check_ups"; | 28 | enum { |
60 | #define REVISION "$Revision$" | 29 | PORT = 3493 |
61 | #define COPYRIGHT "1999-2002" | 30 | }; |
62 | #define AUTHOR "Ethan Galstad" | 31 | |
63 | #define EMAIL "nagios@nagios.org" | 32 | void |
33 | print_usage (void) | ||
34 | { | ||
35 | printf (_("\ | ||
36 | Usage: %s -H host [-e expect] [-p port] [-w warn] [-c crit]\n\ | ||
37 | [-t timeout] [-v]\n"), progname); | ||
38 | printf (_(UT_HLP_VRS), progname, progname); | ||
39 | } | ||
40 | |||
41 | void | ||
42 | print_help (void) | ||
43 | { | ||
44 | char *myport; | ||
45 | asprintf (&myport, "%d", PORT); | ||
46 | |||
47 | print_revision (progname, revision); | ||
48 | |||
49 | printf (_("Copyright (c) 2000 Tom Shields")); | ||
50 | printf (_(COPYRIGHT), copyright, email); | ||
51 | |||
52 | printf (_("This plugin tests the UPS service on the specified host.\n\ | ||
53 | Network UPS Tools from www.exploits.org must be running for this plugin to\n\ | ||
54 | work.\n\n")); | ||
55 | |||
56 | print_usage (); | ||
57 | |||
58 | printf (_(UT_HELP_VRSN)); | ||
59 | |||
60 | printf (_(UT_HOST_PORT), 'p', myport); | ||
61 | |||
62 | printf (_("\ | ||
63 | -u, --ups=STRING\n\ | ||
64 | Name of UPS\n")); | ||
65 | |||
66 | printf (_(UT_WARN_CRIT)); | ||
64 | 67 | ||
65 | #define CHECK_NONE 0 | 68 | printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT); |
66 | 69 | ||
67 | #define PORT 3493 | 70 | printf (_(UT_VERBOSE)); |
71 | |||
72 | printf (_("\ | ||
73 | This plugin attempts to determine the status of a UPS (Uninterruptible Power\n\ | ||
74 | Supply) on a local or remote host. If the UPS is online or calibrating, the\n\ | ||
75 | plugin will return an OK state. If the battery is on it will return a WARNING\n\ | ||
76 | state. If the UPS is off or has a low battery the plugin will return a CRITICAL\n\ | ||
77 | state.\n\n")); | ||
78 | |||
79 | printf (_("\ | ||
80 | You may also specify a variable to check [such as temperature, utility voltage,\n\ | ||
81 | battery load, etc.] as well as warning and critical thresholds for the value of\n\ | ||
82 | that variable. If the remote host has multiple UPS that are being monitored you\n\ | ||
83 | will have to use the [ups] option to specify which UPS to check.\n\n")); | ||
84 | |||
85 | printf (_("Notes:\n\n\ | ||
86 | This plugin requires that the UPSD daemon distributed with Russel Kroll's\n\ | ||
87 | Smart UPS Tools be installed on the remote host. If you do not have the\n\ | ||
88 | package installed on your system, you can download it from\n\ | ||
89 | http://www.exploits.org/nut\n\n")); | ||
90 | |||
91 | printf (_(UT_SUPPORT)); | ||
92 | } | ||
93 | |||
94 | #define CHECK_NONE 0 | ||
68 | 95 | ||
69 | #define UPS_NONE 0 /* no supported options */ | 96 | #define UPS_NONE 0 /* no supported options */ |
70 | #define UPS_UTILITY 1 /* supports utility line voltage */ | 97 | #define UPS_UTILITY 1 /* supports utility line voltage */ |
@@ -85,18 +112,18 @@ const char *progname = "check_ups"; | |||
85 | int server_port = PORT; | 112 | int server_port = PORT; |
86 | char *server_address = "127.0.0.1"; | 113 | char *server_address = "127.0.0.1"; |
87 | char *ups_name = NULL; | 114 | char *ups_name = NULL; |
88 | double warning_value = 0.0L; | 115 | double warning_value = 0.0; |
89 | double critical_value = 0.0L; | 116 | double critical_value = 0.0; |
90 | int check_warning_value = FALSE; | 117 | int check_warning_value = FALSE; |
91 | int check_critical_value = FALSE; | 118 | int check_critical_value = FALSE; |
92 | int check_variable = UPS_NONE; | 119 | int check_variable = UPS_NONE; |
93 | int supported_options = UPS_NONE; | 120 | int supported_options = UPS_NONE; |
94 | int status = UPSSTATUS_NONE; | 121 | int status = UPSSTATUS_NONE; |
95 | 122 | ||
96 | double ups_utility_voltage = 0.0L; | 123 | double ups_utility_voltage = 0.0; |
97 | double ups_battery_percent = 0.0L; | 124 | double ups_battery_percent = 0.0; |
98 | double ups_load_percent = 0.0L; | 125 | double ups_load_percent = 0.0; |
99 | double ups_temperature = 0.0L; | 126 | double ups_temperature = 0.0; |
100 | char *ups_status = "N/A"; | 127 | char *ups_status = "N/A"; |
101 | 128 | ||
102 | int determine_status (void); | 129 | int determine_status (void); |
@@ -105,8 +132,6 @@ int get_ups_variable (const char *, char *, int); | |||
105 | 132 | ||
106 | int process_arguments (int, char **); | 133 | int process_arguments (int, char **); |
107 | int validate_arguments (void); | 134 | int validate_arguments (void); |
108 | void print_help (void); | ||
109 | void print_usage (void); | ||
110 | 135 | ||
111 | int | 136 | int |
112 | main (int argc, char **argv) | 137 | main (int argc, char **argv) |
@@ -115,7 +140,7 @@ main (int argc, char **argv) | |||
115 | char *message; | 140 | char *message; |
116 | char temp_buffer[MAX_INPUT_BUFFER]; | 141 | char temp_buffer[MAX_INPUT_BUFFER]; |
117 | 142 | ||
118 | double ups_utility_deviation = 0.0L; | 143 | double ups_utility_deviation = 0.0; |
119 | 144 | ||
120 | if (process_arguments (argc, argv) != OK) | 145 | if (process_arguments (argc, argv) != OK) |
121 | usage ("Invalid command arguments supplied\n"); | 146 | usage ("Invalid command arguments supplied\n"); |
@@ -556,53 +581,3 @@ validate_arguments (void) | |||
556 | { | 581 | { |
557 | return OK; | 582 | return OK; |
558 | } | 583 | } |
559 | |||
560 | |||
561 | |||
562 | |||
563 | |||
564 | void | ||
565 | print_help (void) | ||
566 | { | ||
567 | print_revision (progname, "$Revision$"); | ||
568 | printf | ||
569 | ("Copyright (c) 2000 Tom Shields/Karl DeBisschop\n\n" | ||
570 | "This plugin tests the UPS service on the specified host.\n" | ||
571 | "Newtork UPS Tools for www.exploits.org must be running for this plugin to work.\n\n"); | ||
572 | print_usage (); | ||
573 | printf | ||
574 | ("\nOptions:\n" | ||
575 | " -H, --hostname=STRING or IPADDRESS\n" | ||
576 | " Check server on the indicated host\n" | ||
577 | " -p, --port=INTEGER\n" | ||
578 | " Make connection on the indicated port (default: %d)\n" | ||
579 | " -u, --ups=STRING\n" | ||
580 | " Name of UPS\n" | ||
581 | " -w, --warning=INTEGER\n" | ||
582 | " Seconds necessary to result in a warning status\n" | ||
583 | " -c, --critical=INTEGER\n" | ||
584 | " Seconds necessary to result in a critical status\n" | ||
585 | " -t, --timeout=INTEGER\n" | ||
586 | " Seconds before connection attempt times out (default: %d)\n" | ||
587 | " -v, --verbose\n" | ||
588 | " Print extra information (command-line use only)\n" | ||
589 | " -h, --help\n" | ||
590 | " Print detailed help screen\n" | ||
591 | " -V, --version\n" | ||
592 | " Print version information\n\n", PORT, DEFAULT_SOCKET_TIMEOUT); | ||
593 | support (); | ||
594 | } | ||
595 | |||
596 | |||
597 | |||
598 | |||
599 | |||
600 | void | ||
601 | print_usage (void) | ||
602 | { | ||
603 | printf | ||
604 | ("Usage: %s -H host [-e expect] [-p port] [-w warn] [-c crit]\n" | ||
605 | " [-t timeout] [-v]\n" | ||
606 | " %s --help\n" | ||
607 | " %s --version\n", progname, progname, progname); | ||
608 | } | ||