Imported Upstream version 2.0

This commit is contained in:
Jan Wagner 2014-07-11 21:01:00 +02:00
parent c89ccc3c74
commit 0841b5c7c7
165 changed files with 25440 additions and 4442 deletions

View file

@ -1,14 +1,14 @@
/*****************************************************************************
*
* Nagios check_disk plugin
* Monitoring check_disk plugin
*
* License: GPL
* Copyright (c) 2000 Karl DeBisschop (kdebisschop@users.sourceforge.net)
* Copyright (c) 2000-2007 Nagios Plugins Development Team
* Copyright (c) 2000-2007 Monitoring Plugins Development Team
*
* Description:
*
* This file contains the check_disk plugin
* This file contains the check_swap plugin
*
*
* This program is free software: you can redistribute it and/or modify
@ -29,7 +29,7 @@
const char *progname = "check_swap";
const char *copyright = "2000-2007";
const char *email = "nagiosplug-devel@lists.sourceforge.net";
const char *email = "devel@monitoring-plugins.org";
#include "common.h"
#include "popen.h"
@ -60,9 +60,10 @@ void print_help (void);
int warn_percent = 0;
int crit_percent = 0;
float warn_size_bytes = 0;
float crit_size_bytes= 0;
float crit_size_bytes = 0;
int verbose;
int allswaps;
int no_swap_state = STATE_CRITICAL;
int
main (int argc, char **argv)
@ -350,7 +351,7 @@ main (int argc, char **argv)
if(total_swap_mb) {
percent_used = 100 * ((double) used_swap_mb) / ((double) total_swap_mb);
} else {
percent_used = 0;
percent_used = 100;
}
result = max_state (result, check_swap (percent_used, free_swap_mb));
@ -372,6 +373,9 @@ main (int argc, char **argv)
int
check_swap (int usp, float free_swap_mb)
{
if (!free_swap_mb) return no_swap_state;
int result = STATE_UNKNOWN;
float free_swap = free_swap_mb * (1024 * 1024); /* Convert back to bytes as warn and crit specified in bytes */
if (usp >= 0 && crit_percent != 0 && usp >= (100.0 - crit_percent))
@ -400,6 +404,7 @@ process_arguments (int argc, char **argv)
{"warning", required_argument, 0, 'w'},
{"critical", required_argument, 0, 'c'},
{"allswaps", no_argument, 0, 'a'},
{"no-swap", required_argument, 0, 'n'},
{"verbose", no_argument, 0, 'v'},
{"version", no_argument, 0, 'V'},
{"help", no_argument, 0, 'h'},
@ -410,7 +415,7 @@ process_arguments (int argc, char **argv)
return ERROR;
while (1) {
c = getopt_long (argc, argv, "+?Vvhac:w:", longopts, &option);
c = getopt_long (argc, argv, "+?Vvhac:w:n:", longopts, &option);
if (c == -1 || c == EOF)
break;
@ -455,6 +460,10 @@ process_arguments (int argc, char **argv)
case 'a': /* all swap */
allswaps = TRUE;
break;
case 'n':
if ((no_swap_state = mp_translate_state(optarg)) == ERROR) {
usage4 (_("no-swap result must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3)."));
}
case 'v': /* verbose */
verbose++;
break;
@ -538,13 +547,16 @@ print_help (void)
printf (" %s\n", "-c, --critical=INTEGER");
printf (" %s\n", _("Exit with CRITICAL status if less than INTEGER bytes of swap space are free"));
printf (" %s\n", "-c, --critical=PERCENT%%");
printf (" %s\n", _("Exit with CRITCAL status if less than PERCENT of swap space is free"));
printf (" %s\n", _("Exit with CRITICAL status if less than PERCENT of swap space is free"));
printf (" %s\n", "-a, --allswaps");
printf (" %s\n", _("Conduct comparisons for all swap partitions, one by one"));
printf (" %s\n", "-n, --no-swap=<ok|warning|critical|unknown>");
printf (" %s %s\n", _("Resulting state when there is no swap regardless of thresholds. Default:"), state_text(no_swap_state));
printf (UT_VERBOSE);
printf ("\n");
printf ("%s\n", _("Notes:"));
printf (" %s\n", _("Both INTEGER and PERCENT thresholds can be specified, they are all checked."));
printf (" %s\n", _("On AIX, if -a is specified, uses lsps -a, otherwise uses lsps -s."));
printf (UT_SUPPORT);
@ -556,6 +568,6 @@ void
print_usage (void)
{
printf ("%s\n", _("Usage:"));
printf ("%s [-av] -w <percent_free>%% -c <percent_free>%%\n",progname);
printf ("%s [-av] -w <bytes_free> -c <bytes_free>\n", progname);
printf (" %s [-av] -w <percent_free>%% -c <percent_free>%%\n",progname);
printf (" -w <bytes_free> -c <bytes_free> [-n <state>]\n");
}