diff --git a/plugins/check_swap.c b/plugins/check_swap.c
index 3016e1ad5c63fbd441a09527e47c1dd23a67779b..bcc6b170c6d4e554682d8c2c5fa94032828c696b 100644 (file)
--- a/plugins/check_swap.c
+++ b/plugins/check_swap.c
*
*****************************************************************************/
*
*****************************************************************************/
-#include "common.h"
-#include "popen.h"
-#include "utils.h"
-
const char *progname = "check_swap";
const char *revision = "$Revision$";
const char *progname = "check_swap";
const char *revision = "$Revision$";
-const char *copyright = "2000-2003";
+const char *copyright = "2000-2004";
const char *email = "nagiosplug-devel@lists.sourceforge.net";
const char *email = "nagiosplug-devel@lists.sourceforge.net";
+#include "common.h"
+#include "popen.h"
+#include "utils.h"
+
int check_swap (int usp, long unsigned int free_swap);
int process_arguments (int argc, char **argv);
int validate_arguments (void);
int check_swap (int usp, long unsigned int free_swap);
int process_arguments (int argc, char **argv);
int validate_arguments (void);
int percent_used, percent;
unsigned long long total_swap = 0, used_swap = 0, free_swap = 0;
unsigned long long dsktotal = 0, dskused = 0, dskfree = 0, tmp = 0;
int percent_used, percent;
unsigned long long total_swap = 0, used_swap = 0, free_swap = 0;
unsigned long long dsktotal = 0, dskused = 0, dskfree = 0, tmp = 0;
- int result = STATE_OK;
+ int result = STATE_UNKNOWN;
char input_buffer[MAX_INPUT_BUFFER];
char *perf;
char input_buffer[MAX_INPUT_BUFFER];
char *perf;
- int conv_factor = SWAP_CONVERSION;
#ifdef HAVE_PROC_MEMINFO
FILE *fp;
#else
#ifdef HAVE_PROC_MEMINFO
FILE *fp;
#else
+ int conv_factor = SWAP_CONVERSION;
# ifdef HAVE_SWAP
char *temp_buffer;
char *swap_command;
# ifdef HAVE_SWAP
char *temp_buffer;
char *swap_command;
tmp_status = strdup ("");
perf = strdup ("");
tmp_status = strdup ("");
perf = strdup ("");
- if (process_arguments (argc, argv) != OK)
- usage (_("Incorrect arguments supplied\n"));
+ if (process_arguments (argc, argv) == ERROR)
+ usage4 (_("Could not parse arguments"));
#ifdef HAVE_PROC_MEMINFO
fp = fopen (PROC_MEMINFO, "r");
#ifdef HAVE_PROC_MEMINFO
fp = fopen (PROC_MEMINFO, "r");
dskfree = dskfree / conv_factor;
# endif
if (verbose >= 3)
dskfree = dskfree / conv_factor;
# endif
if (verbose >= 3)
- printf (_("total=%d, free=%d\n"), dsktotal, dskfree);
+ printf (_("total=%llu, free=%llu\n"), dsktotal, dskfree);
dskused = dsktotal - dskfree;
total_swap += dsktotal;
dskused = dsktotal - dskfree;
total_swap += dsktotal;
/* and now, tally 'em up */
swapctl_res=swapctl(SC_LIST, tbl);
if(swapctl_res < 0){
/* and now, tally 'em up */
swapctl_res=swapctl(SC_LIST, tbl);
if(swapctl_res < 0){
- perror("swapctl failed: ");
+ perror(_("swapctl failed: "));
result = STATE_WARNING;
}
result = STATE_WARNING;
}
/* and now, tally 'em up */
swapctl_res=swapctl(SWAP_STATS, ent, nswaps);
if(swapctl_res < 0){
/* and now, tally 'em up */
swapctl_res=swapctl(SWAP_STATS, ent, nswaps);
if(swapctl_res < 0){
- perror("swapctl failed: ");
+ perror(_("swapctl failed: "));
result = STATE_WARNING;
}
result = STATE_WARNING;
}
-\f
int
check_swap (int usp, long unsigned int free_swap)
{
int
check_swap (int usp, long unsigned int free_swap)
{
}
}
+
/* process command-line arguments */
int
process_arguments (int argc, char **argv)
/* process command-line arguments */
int
process_arguments (int argc, char **argv)
break;
}
else {
break;
}
else {
- usage (_("Warning threshold must be integer or percentage!\n"));
+ usage4 (_("Warning threshold must be integer or percentage!"));
}
case 'c': /* critical size threshold */
if (is_intnonneg (optarg)) {
}
case 'c': /* critical size threshold */
if (is_intnonneg (optarg)) {
break;
}
else {
break;
}
else {
- usage (_("Critical threshold must be integer or percentage!\n"));
+ usage4 (_("Critical threshold must be integer or percentage!"));
}
case 'a': /* all swap */
allswaps = TRUE;
}
case 'a': /* all swap */
allswaps = TRUE;
print_help ();
exit (STATE_OK);
case '?': /* error */
print_help ();
exit (STATE_OK);
case '?': /* error */
- usage (_("Invalid argument\n"));
+ usage2 (_("Unknown argument"), optarg);
}
}
}
}
-
-
int
validate_arguments (void)
{
int
validate_arguments (void)
{
return ERROR;
}
else if (warn_percent < crit_percent) {
return ERROR;
}
else if (warn_percent < crit_percent) {
- usage
- (_("Warning percentage should be more than critical percentage\n"));
+ usage4
+ (_("Warning percentage should be more than critical percentage"));
}
else if (warn_size < crit_size) {
}
else if (warn_size < crit_size) {
- usage
- (_("Warning free space should be more than critical free space\n"));
+ usage4
+ (_("Warning free space should be more than critical free space"));
}
return OK;
}
}
return OK;
}
-
-
-\f
void
print_help (void)
{
void
print_help (void)
{
printf (_(COPYRIGHT), copyright, email);
printf (_(COPYRIGHT), copyright, email);
- printf (_("Check swap space on local server.\n\n"));
+ printf (_("Check swap space on local machine.\n\n"));
print_usage ();
print_usage ();
-
void
print_usage (void)
{
void
print_usage (void)
{
- printf (_("Usage:\n\
- %s [-av] -w <percent_free>%% -c <percent_free>%%\n\
- %s [-av] -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);
+ printf ("\
+Usage: %s [-av] -w <percent_free>%% -c <percent_free>%%\n\
+ %s [-av] -w <bytes_free> -c <bytes_free>\n", progname, progname);
}
}