summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 99653f1)
raw | patch | inline | side by side (parent: 99653f1)
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Tue, 29 Jul 2003 11:58:16 +0000 (11:58 +0000) | ||
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Tue, 29 Jul 2003 11:58:16 +0000 (11:58 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@619 f882894a-f735-0410-b71e-b25c423dba1c
plugins/check_pgsql.c | patch | blob | history | |
plugins/check_swap.c | patch | blob | history | |
plugins/check_tcp.c | patch | blob | history |
diff --git a/plugins/check_pgsql.c b/plugins/check_pgsql.c
index dea39cf9702ef831939046a5ec32277e43a9f7f9..b532d6816af94295bff99dbc72fa7f8d03a702d5 100644 (file)
--- a/plugins/check_pgsql.c
+++ b/plugins/check_pgsql.c
*
*****************************************************************************/
-const char *progname = "check_pgsql";
-#define REVISION "$Revision$"
-#define COPYRIGHT "1999-2001"
-#define AUTHOR "Karl DeBisschop"
-#define EMAIL "kdebisschop@users.sourceforge.net"
-#define SUMMARY "Tests to see if a PostgreSQL DBMS is accepting connections.\n"
-
#define DEFAULT_DB "template1"
#define DEFAULT_HOST "127.0.0.1"
PGconn *conn;
/*PGresult *res;*/
+
+const char *progname = "check_pgsql";
+const char *revision = "$Revision$";
+const char *copyright = "1999-2003";
+const char *email = "nagiosplug-devel@lists.sourceforge.net";
\f
/******************************************************************************
void
print_help (void)
{
- print_revision (progname, REVISION);
- printf
- ("Copyright (c) %s %s <%s>\n\n%s\n",
- COPYRIGHT, AUTHOR, EMAIL, SUMMARY);
+ print_revision (progname, revision);
+
+ printf (_(COPYRIGHT), copyright, email);
+
+ printf (_("Test whether a PostgreSQL DBMS is accepting connections.\n\n"));
+
print_usage ();
- printf (_("\
-\nOptions:\n\
- -H, --hostname=ADDRESS\n\
- Host name argument for servers using host headers (use numeric\n\
- address if possible to bypass DNS lookup).\n\
- -P, --port=INTEGER\n\
- Port number (default: %d)\n\
- -4, --use-ipv4\n\
- Use IPv4 connection\n\
- -6, --use-ipv6\n\
- Use IPv6 connection\n"), DEFAULT_PORT);
+
+ printf (_(HELP_VRSN));
+
+ printf (_(HOST_PORT_46), 'P', "5432");
+
printf (S_("\
-d, --database=STRING\n\
Database to check (default: %s)\n\
Login name of user\n\
-p, --password = STRING\n\
Password (BIG SECURITY ISSUE)\n\n"), DEFAULT_DB);
- printf (S_("\nOptions:\n\
- -c, --critical=INTEGER\n\
- Exit STATE_CRITICAL if connection time exceeds threshold (default: %d)\n\
- -w, --warning=INTEGER\n\
- Exit STATE_WARNING if connection time exceeds threshold (default: %d)\n\
- -t, --timeout=INTEGER\n\
- Terminate test if timeout limit is exceeded (default: %d)\n"),
- DEFAULT_WARN, DEFAULT_CRIT, DEFAULT_TIMEOUT);
- printf (_("\
- -v, --verbose\n\
- Show details for command-line debugging (Nagios may truncate output)\n\
- -h, --help\n\
- Print detailed help screen\n\
- -V, --version\n\
- Print version information\n\n"));
- printf (S_("All parameters are optional.\n\
+
+ printf (_(WARN_CRIT_TO), DEFAULT_SOCKET_TIMEOUT);
+
+ printf (_(VRBS));
+
+ printf (S_("\nAll parameters are optional.\n\
\n\
This plugin tests a PostgreSQL DBMS to determine whether it is active and\n\
accepting queries. In its current operation, it simply connects to the\n\
print_help ();
exit (STATE_OK);
case 'V': /* version */
- print_revision (progname, REVISION);
+ print_revision (progname, revision);
exit (STATE_OK);
case 't': /* timeout period */
if (!is_integer (optarg))
diff --git a/plugins/check_swap.c b/plugins/check_swap.c
index 96eacf359ca79fec66ff517e5e8942c9072dfd2f..5edb8061f25dcd8e1c8184b72ee2ce96513fbb98 100644 (file)
--- a/plugins/check_swap.c
+++ b/plugins/check_swap.c
#include "utils.h"
const char *progname = "check_swap";
-#define REVISION "$Revision$"
-#define COPYRIGHT "2000-2002"
-#define AUTHOR "Karl DeBisschop"
-#define EMAIL "kdebisschop@users.sourceforge.net"
-#define SUMMARY "Check swap space on local server.\n"
+const char *revision = "$Revision$";
+const char *copyright = "2000-2003";
+const char *email = "nagiosplug-devel@lists.sourceforge.net";
+int check_swap (int usp, int free_swap);
int process_arguments (int argc, char **argv);
int validate_arguments (void);
void print_usage (void);
int sun = 0; /* defined by compiler if it is a sun solaris system */
#endif
+void
+print_usage (void)
+{
+ printf (_("Usage:\n\
+ %s [-a] -w <used_percentage>%% -c <used_percentage>%%\n\
+ %s [-a] -w <bytes_free> -c <bytes_free>\n\
+ %s (-h | --help) for detailed help\n\
+ %s (-V | --version) for version information\n"),
+ progname, progname, progname, progname);
+}
+
+
+
+
+
+void
+print_help (void)
+{
+ print_revision (progname, revision);
+
+ printf (_(COPYRIGHT), copyright, email);
+
+ printf (_("Check swap space on local server.\n\n"));
+
+ print_usage ();
+
+ printf (_(HELP_VRSN));
+
+ printf (_("\n\
+ -w, --warning=INTEGER\n\
+ Exit with WARNING status if less than INTEGER bytes of swap space are free\n\
+ -w, --warning=PERCENT%%\n\
+ Exit with WARNING status if less than PERCENT of swap space has been used\n\
+ -c, --critical=INTEGER\n\
+ Exit with CRITICAL status if less than INTEGER bytes of swap space are free\n\
+ -c, --critical=PERCENT%%\n\
+ Exit with CRITCAL status if less than PERCENT of swap space has been used\n\
+ -a, --allswaps\n\
+ Conduct comparisons for all swap partitions, one by one\n"));
+
+#ifdef sun
+ printf (_("\n\
+On Solaris, if -a specified, uses swap -l, otherwise uses swap -s.\n\
+Will be discrepencies because swap -s counts allocated swap and includes\n\
+real memory\n"));
+#endif
+
+ support ();
+}
+\f
+
+
int
main (int argc, char **argv)
{
int percent_used, percent;
long unsigned int total_swap = 0, used_swap = 0, free_swap = 0;
- long unsigned int total, used, free;
- int conv_factor; /* Convert to MBs */
+ long unsigned int dsktotal, dskused, dskfree;
int result = STATE_OK;
char input_buffer[MAX_INPUT_BUFFER];
#ifdef HAVE_SWAP
+ int conv_factor; /* Convert to MBs */
char *temp_buffer;
char *swap_command;
char *swap_format;
#ifdef HAVE_PROC_MEMINFO
fp = fopen (PROC_MEMINFO, "r");
while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, fp)) {
- if (sscanf (input_buffer, " %s %lu %lu %lu", str, &total, &used, &free) == 4 &&
+ if (sscanf (input_buffer, " %s %lu %lu %lu", str, &dsktotal, &dskused, &dskfree) == 4 &&
strstr (str, "Swap")) {
- total = total / 1048576;
- used = used / 1048576;
- free = free / 1048576;
+ dsktotal = dsktotal / 1048576;
+ dskused = dskused / 1048576;
+ dskfree = dskfree / 1048576;
#endif
#ifdef HAVE_SWAP
if (!allswaps && sun) {
while (temp_buffer) {
if (strstr (temp_buffer, "blocks"))
sprintf (str, "%s %s", str, "%f");
- else if (strstr (temp_buffer, "free"))
+ else if (strstr (temp_buffer, "dskfree"))
sprintf (str, "%s %s", str, "%f");
else
sprintf (str, "%s %s", str, "%*s");
total_swap = used_swap + free_swap;
} else {
while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) {
- sscanf (input_buffer, swap_format, &total, &free);
+ sscanf (input_buffer, swap_format, &dsktotal, &dskfree);
- total = total / conv_factor;
- free = free / conv_factor;
+ dsktotal = dsktotal / conv_factor;
+ dskfree = dskfree / conv_factor;
if (verbose >= 3)
- printf ("total=%d, free=%d\n", total, free);
+ printf ("total=%d, free=%d\n", dsktotal, dskfree);
- used = total - free;
+ dskused = dsktotal - dskfree;
#endif
- total_swap += total;
- used_swap += used;
- free_swap += free;
+ total_swap += dsktotal;
+ used_swap += dskused;
+ free_swap += dskfree;
if (allswaps) {
- percent = 100 * (((double) used) / ((double) total));
- result = max_state (result, check_swap (percent, free));
+ percent = 100 * (((double) dskused) / ((double) dsktotal));
+ result = max_state (result, check_swap (percent, dskfree));
if (verbose)
- asprintf (&status, "%s [%lu (%d%%)]", status, free, 100 - percent);
+ asprintf (&status, "%s [%lu (%d%%)]", status, dskfree, 100 - percent);
}
}
}
#endif
terminate (result, "SWAP %s:%s\n", state_text (result), status);
+ return STATE_UNKNOWN;
}
int result = STATE_UNKNOWN;
if (usp >= 0 && usp >= (100.0 - crit_percent))
result = STATE_CRITICAL;
- else if (crit_size >= 0 && free_swap <= crit_size)
+ else if (crit_size > 0 && (unsigned)free_swap <= crit_size)
result = STATE_CRITICAL;
else if (usp >= 0 && usp >= (100.0 - warn_percent))
result = STATE_WARNING;
- else if (warn_size >= 0 && free_swap <= warn_size)
+ else if (warn_size > 0 && (unsigned)free_swap <= warn_size)
result = STATE_WARNING;
else if (usp >= 0.0)
result = STATE_OK;
verbose++;
break;
case 'V': /* version */
- print_revision (progname, "$Revision$");
+ print_revision (progname, revision);
exit (STATE_OK);
case 'h': /* help */
print_help ();
if (c == argc)
return validate_arguments ();
- if (warn_size < 0 && is_intnonneg (argv[c]))
+ if (warn_size == 0 && is_intnonneg (argv[c]))
warn_size = atoi (argv[c++]);
if (c == argc)
return validate_arguments ();
- if (crit_size < 0 && is_intnonneg (argv[c]))
+ if (crit_size == 0 && is_intnonneg (argv[c]))
crit_size = atoi (argv[c++]);
return validate_arguments ();
int
validate_arguments (void)
{
- if (warn_percent > 100 && crit_percent > 100 && warn_size < 0
- && crit_size < 0) {
+ if (warn_percent > 100 && crit_percent > 100 && warn_size == 0
+ && crit_size == 0) {
return ERROR;
}
else if (warn_percent < crit_percent) {
}
return OK;
}
-
-
-
-
-
-void
-print_usage (void)
-{
- printf
- ("Usage:\n"
- " %s [-a] -w <used_percentage>%% -c <used_percentage>%%\n"
- " %s [-a] -w <bytes_free> -c <bytes_free>\n"
- " %s (-h | --help) for detailed help\n"
- " %s (-V | --version) for version information\n",
- progname, progname, progname, progname);
-}
-
-
-
-
-
-void
-print_help (void)
-{
- print_revision (progname, REVISION);
- printf
- ("Copyright (c) %s %s <%s>\n\n%s\n", COPYRIGHT, AUTHOR, EMAIL, SUMMARY);
- print_usage ();
- printf
- ("\nOptions:\n"
- " -w, --warning=INTEGER\n"
- " Exit with WARNING status if less than INTEGER bytes of swap space are free\n"
- " -w, --warning=PERCENT%%\n"
- " Exit with WARNING status if less than PERCENT of swap space has been used\n"
- " -c, --critical=INTEGER\n"
- " Exit with CRITICAL status if less than INTEGER bytes of swap space are free\n"
- " -c, --critical=PERCENT%%\n"
- " Exit with CRITCAL status if less than PERCENT of swap space has been used\n"
- " -a, --allswaps\n"
- " Conduct comparisons for all swap partitions, one by one\n"
- " -h, --help\n"
- " Print detailed help screen\n"
- " -V, --version\n" " Print version information\n"
-#ifdef sun
- "\nOn Solaris, if -a specified, uses swap -l, otherwise uses swap -s.\n"
- "Will be discrepencies because swap -s counts allocated swap and includes real memory\n"
-#endif
- "\n"
- );
- support ();
-}
diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c
index 872a3ccdac4ed68b6a34d2f1b747741833d3e94c..eb31774d1fa4f01f54b9f6aec5c38014f5449db1 100644 (file)
--- a/plugins/check_tcp.c
+++ b/plugins/check_tcp.c
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\
+ [-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 (c) %s Nagios Plugin Development Team\n\
-\t<%s>\n\n"),
- copyright, email);
+ printf (_(COPYRIGHT), copyright, email);
- printf (_("\
-This plugin tests %s connections with the specified host.\n\n"),
+ printf (_("This plugin tests %s connections with the specified host.\n\n"),
SERVICE);
print_usage ();
- printf (_("\
-\nOptions:\n\
- -H, --hostname=ADDRESS\n\
- Host name argument for servers using host headers (use numeric\n\
- address if possible to bypass DNS lookup).\n\
- -p, --port=INTEGER\n\
- Port number\n\
- -4, --use-ipv4\n\
- Use IPv4 connection\n\
- -6, --use-ipv6\n\
- Use IPv6 connection\n"));
+ printf (_(HELP_VRSN));
+
+ printf (_(HOST_PORT_46), 'p', "none");
printf (_("\
-s, --send=STRING\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\
- -w, --warning=DOUBLE\n\
- Response time to result in warning status (seconds)\n\
- -c, --critical=DOUBLE\n\
- Response time to result in critical status (seconds)\n"));
+ Seconds to wait between sending string and polling for response\n"));
- printf (_("\
- -t, --timeout=INTEGER\n\
- Seconds before connection times out (default: %d)\n\
- -v, --verbose\n\
- Show details for command-line debugging (Nagios may truncate output)\n\
- -h, --help\n\
- Print detailed help screen\n\
- -V, --version\n\
- Print version information\n\n"),
- DEFAULT_SOCKET_TIMEOUT);
+ printf (_(WARN_CRIT_TO), DEFAULT_SOCKET_TIMEOUT);
+
+ printf (_(VRBS));
support ();
}