diff options
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2003-08-09 13:36:49 +0000 |
---|---|---|
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2003-08-09 13:36:49 +0000 |
commit | 90b45deb4138efb47efbdd98a4aede1aebb47146 (patch) | |
tree | d27a0180ce89542ee546a0b1e958b68a114ea7ce /plugins/check_ups.c | |
parent | 4784cac1f017a67978c2f3f2af75b161d1ef33c0 (diff) | |
download | monitoring-plugins-90b45deb4138efb47efbdd98a4aede1aebb47146.tar.gz |
more pedantic compiler warnings
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@674 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_ups.c')
-rw-r--r-- | plugins/check_ups.c | 148 |
1 files changed, 81 insertions, 67 deletions
diff --git a/plugins/check_ups.c b/plugins/check_ups.c index 499b9222..fcee7477 100644 --- a/plugins/check_ups.c +++ b/plugins/check_ups.c @@ -29,68 +29,6 @@ enum { PORT = 3493 }; -void -print_usage (void) -{ - printf (_("\ -Usage: %s -H host [-e expect] [-p port] [-w warn] [-c crit]\n\ - [-t timeout] [-v]\n"), progname); - printf (_(UT_HLP_VRS), progname, progname); -} - -void -print_help (void) -{ - char *myport; - asprintf (&myport, "%d", PORT); - - print_revision (progname, revision); - - printf (_("Copyright (c) 2000 Tom Shields")); - printf (_(COPYRIGHT), copyright, email); - - printf (_("This plugin tests the UPS service on the specified host.\n\ -Network UPS Tools from www.exploits.org must be running for this plugin to\n\ -work.\n\n")); - - print_usage (); - - printf (_(UT_HELP_VRSN)); - - printf (_(UT_HOST_PORT), 'p', myport); - - printf (_("\ - -u, --ups=STRING\n\ - Name of UPS\n")); - - printf (_(UT_WARN_CRIT)); - - printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT); - - printf (_(UT_VERBOSE)); - - printf (_("\ -This plugin attempts to determine the status of a UPS (Uninterruptible Power\n\ -Supply) on a local or remote host. If the UPS is online or calibrating, the\n\ -plugin will return an OK state. If the battery is on it will return a WARNING\n\ -state. If the UPS is off or has a low battery the plugin will return a CRITICAL\n\ -state.\n\n")); - - printf (_("\ -You may also specify a variable to check [such as temperature, utility voltage,\n\ -battery load, etc.] as well as warning and critical thresholds for the value of\n\ -that variable. If the remote host has multiple UPS that are being monitored you\n\ -will have to use the [ups] option to specify which UPS to check.\n\n")); - - printf (_("Notes:\n\n\ -This plugin requires that the UPSD daemon distributed with Russel Kroll's\n\ -Smart UPS Tools be installed on the remote host. If you do not have the\n\ -package installed on your system, you can download it from\n\ -http://www.exploits.org/nut\n\n")); - - printf (_(UT_SUPPORT)); -} - #define CHECK_NONE 0 #define UPS_NONE 0 /* no supported options */ @@ -110,7 +48,7 @@ http://www.exploits.org/nut\n\n")); #define UPSSTATUS_UNKOWN 64 int server_port = PORT; -char *server_address = "127.0.0.1"; +char *server_address; char *ups_name = NULL; double warning_value = 0.0; double critical_value = 0.0; @@ -124,14 +62,16 @@ double ups_utility_voltage = 0.0; double ups_battery_percent = 0.0; double ups_load_percent = 0.0; double ups_temperature = 0.0; -char *ups_status = "N/A"; +char *ups_status; int determine_status (void); int determine_supported_vars (void); -int get_ups_variable (const char *, char *, int); +int get_ups_variable (const char *, char *, size_t); int process_arguments (int, char **); int validate_arguments (void); +void print_help (void); +void print_usage (void); int main (int argc, char **argv) @@ -141,6 +81,7 @@ main (int argc, char **argv) char temp_buffer[MAX_INPUT_BUFFER]; double ups_utility_deviation = 0.0; + ups_status = strdup ("N/A"); if (process_arguments (argc, argv) != OK) usage ("Invalid command arguments supplied\n"); @@ -160,7 +101,7 @@ main (int argc, char **argv) if (determine_status () != OK) return STATE_CRITICAL; - asprintf (&ups_status, ""); + ups_status = strdup (""); result = STATE_OK; if (status & UPSSTATUS_OFF) { @@ -395,7 +336,7 @@ determine_supported_vars (void) /* gets a variable value for a specific UPS */ int -get_ups_variable (const char *varname, char *buf, int buflen) +get_ups_variable (const char *varname, char *buf, size_t buflen) { /* char command[MAX_INPUT_BUFFER]; */ char temp_buffer[MAX_INPUT_BUFFER]; @@ -569,6 +510,9 @@ process_arguments (int argc, char **argv) usage ("Invalid host name"); } + if (server_address == NULL) + server_address = strdup("127.0.0.1"); + return validate_arguments(); } @@ -581,3 +525,73 @@ validate_arguments (void) { return OK; } + + + + + + +void +print_help (void) +{ + char *myport; + asprintf (&myport, "%d", PORT); + + print_revision (progname, revision); + + printf (_("Copyright (c) 2000 Tom Shields")); + printf (_(COPYRIGHT), copyright, email); + + printf (_("This plugin tests the UPS service on the specified host.\n\ +Network UPS Tools from www.exploits.org must be running for this plugin to\n\ +work.\n\n")); + + print_usage (); + + printf (_(UT_HELP_VRSN)); + + printf (_(UT_HOST_PORT), 'p', myport); + + printf (_("\ + -u, --ups=STRING\n\ + Name of UPS\n")); + + printf (_(UT_WARN_CRIT)); + + printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT); + + printf (_(UT_VERBOSE)); + + printf (_("\ +This plugin attempts to determine the status of a UPS (Uninterruptible Power\n\ +Supply) on a local or remote host. If the UPS is online or calibrating, the\n\ +plugin will return an OK state. If the battery is on it will return a WARNING\n\ +state. If the UPS is off or has a low battery the plugin will return a CRITICAL\n\ +state.\n\n")); + + printf (_("\ +You may also specify a variable to check [such as temperature, utility voltage,\n\ +battery load, etc.] as well as warning and critical thresholds for the value of\n\ +that variable. If the remote host has multiple UPS that are being monitored you\n\ +will have to use the [ups] option to specify which UPS to check.\n\n")); + + printf (_("Notes:\n\n\ +This plugin requires that the UPSD daemon distributed with Russel Kroll's\n\ +Smart UPS Tools be installed on the remote host. If you do not have the\n\ +package installed on your system, you can download it from\n\ +http://www.exploits.org/nut\n\n")); + + printf (_(UT_SUPPORT)); +} + + + + +void +print_usage (void) +{ + printf (_("\ +Usage: %s -H host [-e expect] [-p port] [-w warn] [-c crit]\n\ + [-t timeout] [-v]\n"), progname); + printf (_(UT_HLP_VRS), progname, progname); +} |