summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4784cac)
raw | patch | inline | side by side (parent: 4784cac)
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Sat, 9 Aug 2003 13:36:49 +0000 (13:36 +0000) | ||
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Sat, 9 Aug 2003 13:36:49 +0000 (13:36 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@674 f882894a-f735-0410-b71e-b25c423dba1c
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c
index f7c826b2a25729f97e83299cb28eed2884f161cd..c4e427a655652d56bd8d150198fbd778c1f18940 100644 (file)
--- a/plugins/check_smtp.c
+++ b/plugins/check_smtp.c
char *server_address = NULL;
char *server_expect = NULL;
int smtp_use_dummycmd = 1;
-char *mail_command = "MAIL ";
-char *from_arg = " ";
+char *mail_command;
+char *from_arg;
int warning_time = 0;
int check_warning_time = FALSE;
int critical_time = 0;
int sd;
double elapsed_time;
int result = STATE_UNKNOWN;
- char buffer[MAX_INPUT_BUFFER] = "";
+ char buffer[MAX_INPUT_BUFFER];
char *from_str = NULL;
char *helocmd = NULL;
struct timeval tv;
}
if (server_expect == NULL)
- asprintf (&server_expect, SMTP_EXPECT);
+ server_expect = strdup (SMTP_EXPECT);
+
+ if (mail_command == NULL)
+ mail_command = strdup("MAIL ");
+
+ if (from_arg==NULL)
+ from_arg = strdup(" ");
return validate_arguments ();
}
diff --git a/plugins/check_ssh.c b/plugins/check_ssh.c
index 7fcb81198ca046b05f7284b63f65203be618b2fd..fdded583b70ea06c1163f7227408f4619a3449e3 100644 (file)
--- a/plugins/check_ssh.c
+++ b/plugins/check_ssh.c
#define SSH_DFL_PORT 22
#define BUFF_SZ 256
-short port = -1;
+int port = -1;
char *server_name = NULL;
int verbose = FALSE;
void print_help (void);
void print_usage (void);
-int ssh_connect (char *haddr, short hport);
+int ssh_connect (char *haddr, int hport);
int
main (int argc, char **argv)
case 't': /* timeout period */
if (!is_integer (optarg))
usage (_("Timeout Interval must be an integer!\n\n"));
- socket_timeout = atoi (optarg);
+ else
+ socket_timeout = atoi (optarg);
break;
case '4':
address_family = AF_INET;
*-----------------------------------------------------------------------*/
int
-ssh_connect (char *haddr, short hport)
+ssh_connect (char *haddr, int hport)
{
int sd;
int result;
diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c
index a897d8e8ec96b446dd579af66297c4c72a14ef7b..fc0572cc3f19d11b752e5f80c284344577466369 100644 (file)
--- a/plugins/check_tcp.c
+++ b/plugins/check_tcp.c
/*****************************************************************************
-*
-* This program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
*****************************************************************************/
-#include "config.h"
+
+/* progname changes depending on symlink called */
+char *progname = "check_tcp";
+const char *revision = "$Revision$";
+const char *copyright = "1999-2003";
+const char *email = "nagiosplug-devel@lists.sourceforge.net";
+
#include "common.h"
#include "netutils.h"
#include "utils.h"
};
int process_arguments (int, char **);
-void print_usage (void);
-void print_help (void);
int my_recv (void);
+void print_help (void);
+void print_usage (void);
char *SERVICE = NULL;
char *SEND = NULL;
char *server_send = NULL;
char *server_quit = NULL;
char **server_expect = NULL;
-int server_expect_count = 0;
+size_t server_expect_count = 0;
int maxbytes = 0;
char **warn_codes = NULL;
-int warn_codes_count = 0;
+size_t warn_codes_count = 0;
char **crit_codes = NULL;
-int crit_codes_count = 0;
-int delay = 0;
+size_t crit_codes_count = 0;
+unsigned int delay = 0;
double warning_time = 0;
int check_warning_time = FALSE;
double critical_time = 0;
int check_critical_time = FALSE;
double elapsed_time = 0;
+long microsec;
int verbose = FALSE;
int use_ssl = FALSE;
int sd = 0;
-char *buffer = "";
-
-/* progname changes depending on symlink called */
-char *progname = "check_tcp";
-const char *revision = "$Revision$";
-const char *copyright = "1999-2003";
-const char *email = "nagiosplug-devel@lists.sourceforge.net";
-\f
-
-
-
-void
-print_usage (void)
-{
- printf (_("\
-Usage: %s -H host -p port [-w <warning time>] [-c <critical time>]\n\
- [-s <send string>] [-e <expect string>] [-q <quit string>]\n\
- [-m <maximum bytes>] [-d <delay>] [-t <timeout seconds>]\n\
- [-r <refuse state>] [-v] [-4|-6]\n"), progname);
- printf (" %s (-h|--help)\n", progname);
- printf (" %s (-V|--version)\n", progname);
-}
-void
-print_help (void)
-{
- print_revision (progname, revision);
-
- printf (_(COPYRIGHT), copyright, email);
-
- printf (_("This plugin tests %s connections with the specified host.\n\n"),
- SERVICE);
-
- print_usage ();
-
- printf (_(UT_HELP_VRSN));
-
- printf (_(UT_HOST_PORT), 'p', "none");
-
- printf (_(UT_IPv46));
-
- printf (_("\
- -s, --send=STRING\n\
- String to send to the server\n\
- -e, --expect=STRING\n\
- String to expect in server response\n\
- -q, --quit=STRING\n\
- String to send server to initiate a clean close of the connection\n"));
+char *buffer;
- printf (_("\
- -r, --refuse=ok|warn|crit\n\
- Accept tcp refusals with states ok, warn, crit (default: crit)\n\
- -m, --maxbytes=INTEGER\n\
- Close connection once more than this number of bytes are received\n\
- -d, --delay=INTEGER\n\
- Seconds to wait between sending string and polling for response\n"));
- printf (_(UT_WARN_CRIT));
- printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
- printf (_(UT_VERBOSE));
- printf (_(UT_SUPPORT));
-}
\f
-
-
int
main (int argc, char **argv)
{
int result;
int i;
- char *status = "";
+ char *status;
struct timeval tv;
setlocale (LC_ALL, "");
asprintf (&server_send, "%s\r\n", server_send);
#ifdef HAVE_SSL
if (use_ssl)
- SSL_write(ssl, server_send, strlen (server_send));
+ SSL_write(ssl, server_send, (int)strlen(server_send));
else
#endif
- send (sd, server_send, strlen (server_send), 0);
+ send (sd, server_send, strlen(server_send), 0);
}
if (delay > 0) {
buffer = malloc (MAXBUF);
memset (buffer, '\0', MAXBUF);
+ status = strdup ("");
/* watch for the expect string */
while ((i = my_recv ()) > 0) {
buffer[i] = '\0';
if (server_expect_count > 0) {
for (i = 0;; i++) {
if (verbose)
- printf ("%d %d\n", i, server_expect_count);
- if (i >= server_expect_count)
+ printf ("%d %d\n", i, (int)server_expect_count);
+ if (i >= (int)server_expect_count)
die (STATE_WARNING, _("Invalid response from host\n"));
if (strstr (status, server_expect[i]))
break;
if (server_quit != NULL) {
#ifdef HAVE_SSL
if (use_ssl) {
- SSL_write (ssl, server_quit, strlen (server_quit));
+ SSL_write (ssl, server_quit, (int)strlen(server_quit));
SSL_shutdown (ssl);
SSL_free (ssl);
SSL_CTX_free (ctx);
if (sd)
close (sd);
- elapsed_time = delta_time (tv);
+ microsec = deltime (tv);
+ elapsed_time = (double)microsec / 1.0e6;
if (check_critical_time == TRUE && elapsed_time > critical_time)
result = STATE_CRITICAL;
if (status && strlen(status) > 0)
printf (" [%s]", status);
- printf ("|time=%.3f\n", elapsed_time);
+ printf ("|time=%ldus\n", microsec);
return result;
}
case 'c': /* critical */
if (!is_intnonneg (optarg))
usage (_("Critical threshold must be a nonnegative integer\n"));
- critical_time = strtod (optarg, NULL);
+ else
+ critical_time = strtod (optarg, NULL);
check_critical_time = TRUE;
break;
case 'w': /* warning */
if (!is_intnonneg (optarg))
usage (_("Warning threshold must be a nonnegative integer\n"));
- warning_time = strtod (optarg, NULL);
+ else
+ warning_time = strtod (optarg, NULL);
check_warning_time = TRUE;
break;
case 'C':
case 't': /* timeout */
if (!is_intpos (optarg))
usage (_("Timeout interval must be a positive integer\n"));
- socket_timeout = atoi (optarg);
+ else
+ socket_timeout = atoi (optarg);
break;
case 'p': /* port */
if (!is_intpos (optarg))
usage (_("Server port must be a positive integer\n"));
- server_port = atoi (optarg);
+ else
+ server_port = atoi (optarg);
break;
case 's':
server_send = optarg;
case 'm':
if (!is_intpos (optarg))
usage (_("Maxbytes must be a positive integer\n"));
- maxbytes = atoi (optarg);
+ else
+ maxbytes = atoi (optarg);
case 'q':
server_quit = optarg;
break;
return i;
}
+
+
+
+
+
+\f
+void
+print_help (void)
+{
+ print_revision (progname, revision);
+
+ printf (_(COPYRIGHT), copyright, email);
+
+ printf (_("This plugin tests %s connections with the specified host.\n\n"),
+ SERVICE);
+
+ print_usage ();
+
+ printf (_(UT_HELP_VRSN));
+
+ printf (_(UT_HOST_PORT), 'p', "none");
+
+ printf (_(UT_IPv46));
+
+ printf (_("\
+ -s, --send=STRING\n\
+ String to send to the server\n\
+ -e, --expect=STRING\n\
+ String to expect in server response\n\
+ -q, --quit=STRING\n\
+ String to send server to initiate a clean close of the connection\n"));
+
+ printf (_("\
+ -r, --refuse=ok|warn|crit\n\
+ Accept tcp refusals with states ok, warn, crit (default: crit)\n\
+ -m, --maxbytes=INTEGER\n\
+ Close connection once more than this number of bytes are received\n\
+ -d, --delay=INTEGER\n\
+ Seconds to wait between sending string and polling for response\n"));
+
+ printf (_(UT_WARN_CRIT));
+
+ printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
+
+ printf (_(UT_VERBOSE));
+
+ printf (_(UT_SUPPORT));
+}
+
+
+
+
+void
+print_usage (void)
+{
+ printf (_("\
+Usage: %s -H host -p port [-w <warning time>] [-c <critical time>]\n\
+ [-s <send string>] [-e <expect string>] [-q <quit string>]\n\
+ [-m <maximum bytes>] [-d <delay>] [-t <timeout seconds>]\n\
+ [-r <refuse state>] [-v] [-4|-6]\n"), progname);
+ printf (" %s (-h|--help)\n", progname);
+ printf (" %s (-V|--version)\n", progname);
+}
diff --git a/plugins/check_time.c b/plugins/check_time.c
index dde6eeaf7cca411aea1ba7578f89ba7fba000f46..36b622fbfa3808de9170d3a4ee90a8dbad2da1cf 100644 (file)
--- a/plugins/check_time.c
+++ b/plugins/check_time.c
TIME_PORT = 37
};
-void
-print_usage (void)
-{
- printf (_("\
-Usage: %s -H <host_address> [-p port] [-w variance] [-c variance]\n\
- [-W connect_time] [-C connect_time] [-t timeout]\n"), progname);
- printf (_(UT_HLP_VRS), progname, progname);
-}
-
-void
-print_help (void)
-{
- char *myport;
- asprintf (&myport, "%d", TIME_PORT);
-
- print_revision (progname, revision);
-
- printf (_("Copyright (c) 1999 Ethan Galstad\n"));
- printf (_(COPYRIGHT), copyright, email);
-
- printf (_("\
-This plugin will check the time on the specified host.\n\n"));
-
- print_usage ();
-
- printf (_(UT_HELP_VRSN));
-
- printf (_(UT_HOST_PORT), 'p', myport);
-
- printf (_("\
- -w, --warning-variance=INTEGER\n\
- Time difference (sec.) necessary to result in a warning status\n\
- -c, --critical-variance=INTEGER\n\
- Time difference (sec.) necessary to result in a critical status\n\
- -W, --warning-connect=INTEGER\n\
- Response time (sec.) necessary to result in warning status\n\
- -C, --critical-connect=INTEGER\n\
- Response time (sec.) necessary to result in critical status\n"));
-
- printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
-
- support ();
-}
-\f
-
#define UNIX_EPOCH 2208988800UL
unsigned long server_time, raw_server_time;
int server_port = TIME_PORT;
char *server_address = NULL;
-
int process_arguments (int, char **);
-void print_usage (void);
void print_help (void);
-
+void print_usage (void);
int
main (int argc, char **argv)
case 'W': /* warning-connect */
if (!is_intnonneg (optarg))
usage (_("Warning threshold must be a nonnegative integer\n"));
- warning_time = atoi (optarg);
+ else
+ warning_time = atoi (optarg);
check_warning_time = TRUE;
break;
case 'C': /* critical-connect */
if (!is_intnonneg (optarg))
usage (_("Critical threshold must be a nonnegative integer\n"));
- critical_time = atoi (optarg);
+ else
+ critical_time = atoi (optarg);
check_critical_time = TRUE;
break;
case 'p': /* port */
if (!is_intnonneg (optarg))
usage (_("Server port must be a nonnegative integer\n"));
- server_port = atoi (optarg);
+ else
+ server_port = atoi (optarg);
break;
case 't': /* timeout */
if (!is_intnonneg (optarg))
usage (_("Timeout interval must be a nonnegative integer\n"));
- socket_timeout = atoi (optarg);
+ else
+ socket_timeout = atoi (optarg);
break;
}
}
return OK;
}
+
+
+
+
+
+\f
+void
+print_help (void)
+{
+ char *myport;
+ asprintf (&myport, "%d", TIME_PORT);
+
+ print_revision (progname, revision);
+
+ printf (_("Copyright (c) 1999 Ethan Galstad\n"));
+ printf (_(COPYRIGHT), copyright, email);
+
+ printf (_("\
+This plugin will check the time on the specified host.\n\n"));
+
+ print_usage ();
+
+ printf (_(UT_HELP_VRSN));
+
+ printf (_(UT_HOST_PORT), 'p', myport);
+
+ printf (_("\
+ -w, --warning-variance=INTEGER\n\
+ Time difference (sec.) necessary to result in a warning status\n\
+ -c, --critical-variance=INTEGER\n\
+ Time difference (sec.) necessary to result in a critical status\n\
+ -W, --warning-connect=INTEGER\n\
+ Response time (sec.) necessary to result in warning status\n\
+ -C, --critical-connect=INTEGER\n\
+ Response time (sec.) necessary to result in critical status\n"));
+
+ printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
+
+ support ();
+}
+
+
+
+
+void
+print_usage (void)
+{
+ printf (_("\
+Usage: %s -H <host_address> [-p port] [-w variance] [-c variance]\n\
+ [-W connect_time] [-C connect_time] [-t timeout]\n"), progname);
+ printf (_(UT_HLP_VRS), progname, progname);
+}
diff --git a/plugins/check_udp.c b/plugins/check_udp.c
index 11b942a4e303e4d9fe995a411e5cd11182f1f287..bd5de5864d7c97e4d0fa6a57adcb347de41a3ab5 100644 (file)
--- a/plugins/check_udp.c
+++ b/plugins/check_udp.c
#include "netutils.h"
#include "utils.h"
-/* Original Command line:
- check_udp <host_address> [-p port] [-s send] [-e expect] \
- [-wt warn_time] [-ct crit_time] [-to to_sec] */
-void
-print_usage (void)
-{
- printf (_("\
-Usage: %s -H <host_address> [-p port] [-w warn_time] [-c crit_time]\n\
- [-e expect] [-s send] [-t to_sec] [-v]\n"), progname);
- printf (_(UT_HLP_VRS), progname, progname);
-}
-
-void
-print_help (void)
-{
- print_revision (progname, revision);
-
- printf (_("Copyright (c) 1999 Ethan Galstad\n"));
- printf (_(COPYRIGHT), copyright, email);
-
- printf (_("\
-This plugin tests an UDP connection with the specified host.\n\n"));
-
- print_usage ();
-
- printf (_(UT_HELP_VRSN));
-
- printf (_(UT_HOST_PORT), 'p', "none");
-
- printf (_("\
- -e, --expect=STRING <optional>\n\
- String to expect in first line of server response\n\
- -s, --send=STRING <optional>\n\
- String to send to the server when initiating the connection\n"));
-
- printf (_(UT_WARN_CRIT));
-
- printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
-
- printf (_(UT_VERBOSE));
-
- printf (_("\
-This plugin will attempt to connect to the specified port on the host.\n\
-Successful connects return STATE_OK, refusals and timeouts return\n\
-STATE_CRITICAL, other errors return STATE_UNKNOWN.\n\n"));
-
- printf(_(UT_SUPPORT));
-}
-\f
int process_arguments (int, char **);
+void print_help (void);
+void print_usage (void);
int warning_time = 0;
int check_warning_time = FALSE;
int server_port = 0;
char *server_address = NULL;
char *server_expect = NULL;
-char *server_send = "";
+char *server_send;
int
main (int argc, char **argv)
case 'c': /* critical */
if (!is_intnonneg (optarg))
usage (_("Critical threshold must be a nonnegative integer\n"));
- critical_time = atoi (optarg);
+ else
+ critical_time = atoi (optarg);
check_critical_time = TRUE;
break;
case 'w': /* warning */
if (!is_intnonneg (optarg))
usage (_("Warning threshold must be a nonnegative integer\n"));
- warning_time = atoi (optarg);
+ else
+ warning_time = atoi (optarg);
check_warning_time = TRUE;
break;
case 't': /* timeout */
if (!is_intnonneg (optarg))
usage (_("Timeout interval must be a nonnegative integer\n"));
- socket_timeout = atoi (optarg);
+ else
+ socket_timeout = atoi (optarg);
break;
case 'p': /* port */
if (!is_intnonneg (optarg))
usage (_("Server port must be a nonnegative integer\n"));
- server_port = atoi (optarg);
+ else
+ server_port = atoi (optarg);
break;
case 'e': /* expect */
server_expect = optarg;
if (server_address == NULL)
usage (_("Host name was not supplied\n"));
+ if (server_send == NULL)
+ server_send = strdup("");
+
return c;
}
+
+
+
+
+
+\f
+void
+print_help (void)
+{
+ print_revision (progname, revision);
+
+ printf (_("Copyright (c) 1999 Ethan Galstad\n"));
+ printf (_(COPYRIGHT), copyright, email);
+
+ printf (_("\
+This plugin tests an UDP connection with the specified host.\n\n"));
+
+ print_usage ();
+
+ printf (_(UT_HELP_VRSN));
+
+ printf (_(UT_HOST_PORT), 'p', "none");
+
+ printf (_("\
+ -e, --expect=STRING <optional>\n\
+ String to expect in first line of server response\n\
+ -s, --send=STRING <optional>\n\
+ String to send to the server when initiating the connection\n"));
+
+ printf (_(UT_WARN_CRIT));
+
+ printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
+
+ printf (_(UT_VERBOSE));
+
+ printf (_("\
+This plugin will attempt to connect to the specified port on the host.\n\
+Successful connects return STATE_OK, refusals and timeouts return\n\
+STATE_CRITICAL, other errors return STATE_UNKNOWN.\n\n"));
+
+ printf(_(UT_SUPPORT));
+}
+
+
+
+
+/* Original Command line:
+ check_udp <host_address> [-p port] [-s send] [-e expect] \
+ [-wt warn_time] [-ct crit_time] [-to to_sec] */
+void
+print_usage (void)
+{
+ printf (_("\
+Usage: %s -H <host_address> [-p port] [-w warn_time] [-c crit_time]\n\
+ [-e expect] [-s send] [-t to_sec] [-v]\n"), progname);
+ printf (_(UT_HLP_VRS), progname, progname);
+}
diff --git a/plugins/check_ups.c b/plugins/check_ups.c
index 499b92221e35e59e0eb9e1ce157b44e1f51a7dbb..fcee747770ff00b30b9007a33cc8b600b0850225 100644 (file)
--- a/plugins/check_ups.c
+++ b/plugins/check_ups.c
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));
-}
-\f
#define CHECK_NONE 0
#define UPS_NONE 0 /* no supported options */
#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;
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)
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");
if (determine_status () != OK)
return STATE_CRITICAL;
- asprintf (&ups_status, "");
+ ups_status = strdup ("");
result = STATE_OK;
if (status & UPSSTATUS_OFF) {
/* 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];
usage ("Invalid host name");
}
+ if (server_address == NULL)
+ server_address = strdup("127.0.0.1");
+
return validate_arguments();
}
{
return OK;
}
+
+
+
+
+
+\f
+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);
+}
diff --git a/plugins/check_users.c b/plugins/check_users.c
index d4480e70df3182557227737e639c3b3e6d6cc999..9e182015e21c6c07e4df41303d1b1cfe910bc8d3 100644 (file)
--- a/plugins/check_users.c
+++ b/plugins/check_users.c
#include "popen.h"
#include "utils.h"
-void
-print_usage (void)
-{
- printf ("Usage: %s -w <users> -c <users>\n", progname);
- printf (_(UT_HLP_VRS), progname, progname);
-}
-
-void
-print_help (void)
-{
- print_revision (progname, revision);
-
- printf (_("Copyright (c) 1999 Ethan Galstad\n"));
- printf (_(COPYRIGHT), copyright, email);
-
- printf (_("\
-This plugin checks the number of users currently logged in on the local\n\
-system and generates an error if the number exceeds the thresholds specified.\n"));
-
- print_usage ();
-
- printf (_(UT_HELP_VRSN));
-
- printf (_("\
- -w, --warning=INTEGER\n\
- Set WARNING status if more than INTEGER users are logged in\n\
- -c, --critical=INTEGER\n\
- Set CRITICAL status if more than INTEGER users are logged in\n"));
-
- printf (_(UT_SUPPORT));
-}
-\f
#define possibly_set(a,b) ((a) == 0 ? (b) : 0)
int process_arguments (int, char **);
-void print_usage (void);
void print_help (void);
+void print_usage (void);
int wusers = -1;
int cusers = -1;
case 'c': /* critical */
if (!is_intnonneg (optarg))
usage (_("Critical threshold must be a nonnegative integer\n"));
- cusers = atoi (optarg);
+ else
+ cusers = atoi (optarg);
break;
case 'w': /* warning */
if (!is_intnonneg (optarg))
usage (_("Warning threshold must be a nonnegative integer\n"));
- wusers = atoi (optarg);
+ else
+ wusers = atoi (optarg);
break;
}
}
if (wusers == -1 && argc > c) {
if (is_intnonneg (argv[c]) == FALSE)
usage (_("Warning threshold must be a nonnegative integer\n"));
- wusers = atoi (argv[c++]);
+ else
+ wusers = atoi (argv[c++]);
}
if (cusers == -1 && argc > c) {
if (is_intnonneg (argv[c]) == FALSE)
usage (_("Warning threshold must be a nonnegative integer\n"));
- cusers = atoi (argv[c]);
+ else
+ cusers = atoi (argv[c]);
}
return OK;
}
+
+
+
+
+
+\f
+void
+print_help (void)
+{
+ print_revision (progname, revision);
+
+ printf (_("Copyright (c) 1999 Ethan Galstad\n"));
+ printf (_(COPYRIGHT), copyright, email);
+
+ printf (_("\
+This plugin checks the number of users currently logged in on the local\n\
+system and generates an error if the number exceeds the thresholds specified.\n"));
+
+ print_usage ();
+
+ printf (_(UT_HELP_VRSN));
+
+ printf (_("\
+ -w, --warning=INTEGER\n\
+ Set WARNING status if more than INTEGER users are logged in\n\
+ -c, --critical=INTEGER\n\
+ Set CRITICAL status if more than INTEGER users are logged in\n"));
+
+ printf (_(UT_SUPPORT));
+}
+
+
+
+
+void
+print_usage (void)
+{
+ printf ("Usage: %s -w <users> -c <users>\n", progname);
+ printf (_(UT_HLP_VRS), progname, progname);
+}