[Nagiosplug-devel] [ nagiosplug-Patches-868900 ] check_swap fix for more than 4GB of swap
SourceForge.net
noreply at sourceforge.net
Sun Nov 28 21:16:04 CET 2004
Patches item #868900, was opened at 2004-01-01 11:43
Message generated for change (Comment added) made by mattkent
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=397599&aid=868900&group_id=29880
Category: Bugfix
Group: None
>Status: Closed
>Resolution: Out of Date
Priority: 5
Submitted By: Johannes Formann (jformann)
>Assigned to: Matthew Kent (mattkent)
Summary: check_swap fix for more than 4GB of swap
Initial Comment:
This patch fixes the problem with wron warning when using
more than 4GB of swap.
*** ../nagios-plugins-1.4.0alpha1/plugins/check_swap.c
Wed Nov 12 05:37:19 2003
--- plugins/check_swap.c Thu Jan 1 19:28:34 2004
***************
*** 82,87 ****
--- 82,95 ----
#ifdef HAVE_PROC_MEMINFO
fp = fopen (PROC_MEMINFO, "r");
while (fgets (input_buffer, MAX_INPUT_BUFFER - 1,
fp)) {
+ unsigned long tmp;
+ if(sscanf(input_buffer, "%s %lu", str,
&tmp)==2) {
+ if(!
strncmp(str,"SwapTotal",strlen("SwapTotal")))
+ total_swap+=(tmp>>10);
+ else if(!
strncmp(str,"SwapFree",strlen("SwapFree")))
+ free_swap+=(tmp>>10);
+ }
+ /*
if (sscanf (input_buffer, " %s %lu %lu %lu",
str, &dsktotal, &dskused, &dskfree) == 4 &&
strstr (str, "Swap")) {
dsktotal = dsktotal / 1048576;
***************
*** 97,104 ****
--- 105,114 ----
asprintf (&status, "%s [%lu
(%d%%)]", status, dskfree, 100 - percent);
}
}
+ */
}
fclose(fp);
+ used_swap=total_swap-free_swap;
#else
# ifdef HAVE_SWAP
asprintf(&swap_command, "%s", SWAP_COMMAND);
***************
*** 240,246 ****
check_swap (int usp, long unsigned int free_swap)
{
int result = STATE_UNKNOWN;
- free_swap = free_swap * 1024; /* Convert
back to bytes as warn and crit specified in bytes */
if (usp >= 0 && crit_percent != 0 && usp >= (100.0 -
crit_percent))
result = STATE_CRITICAL;
else if (crit_size > 0 && free_swap <= crit_size)
--- 251,256 ----
***************
*** 399,411 ****
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"));
--- 410,422 ----
printf (_("\n -w, --warning=INTEGER\n! Exit with WARNING status if less than INTEGER mega
bytes of swap space are free\n -w, --warning=PERCENT%%\n! Exit with WARNING status if less than PERCENT of swap
space are free\n -c, --critical=INTEGER\n! Exit with CRITICAL status if less than INTEGER mega
bytes of swap space are free\n -c, --critical=PERCENT%%\n! Exit with CRITCAL status if less than PERCENT of swap
space are free\n -a, --allswaps\n Conduct comparisons for all swap partitions, one by
one\n"));
***************
*** 426,433 ****
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);
--- 437,444 ----
print_usage (void)
{
printf (_("Usage:\n! %s [-a] -w <free_percentage>%% -c
<free_percentage>%%\n! %s [-a] -w <mega_bytes_free> -c <mega_bytes_free>\n %s (-h | --help) for detailed help\n %s (-V | --version) for version information\n"),
progname, progname, progname, progname);
----------------------------------------------------------------------
>Comment By: Matthew Kent (mattkent)
Date: 2004-11-28 21:15
Message:
Logged In: YES
user_id=983566
Looks like this was fixed in Feb. Sorry for the delay.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=397599&aid=868900&group_id=29880
More information about the Devel
mailing list