[Nagiosplug-checkins] CVS: nagiosplug/plugins check_swap.c,1.8,1.9
Subhendu Ghosh
sghosh at users.sourceforge.net
Mon Feb 17 19:47:04 CET 2003
Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory sc8-pr-cvs1:/tmp/cvs-serv27204
Modified Files:
check_swap.c
Log Message:
support for Large swap sizes
Index: check_swap.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_swap.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** check_swap.c 30 Jan 2003 22:57:27 -0000 1.8
--- check_swap.c 18 Feb 2003 03:46:15 -0000 1.9
***************
*** 44,49 ****
int warn_percent = 200;
int crit_percent = 200;
! int warn_size = -1;
! int crit_size = -1;
int verbose;
int allswaps;
--- 44,49 ----
int warn_percent = 200;
int crit_percent = 200;
! long unsigned int warn_size = 0;
! long unsigned int crit_size = 0;
int verbose;
int allswaps;
***************
*** 52,57 ****
main (int argc, char **argv)
{
! int total_swap = 0, used_swap = 0, free_swap = 0, percent_used;
! int total, used, free, percent;
int result = STATE_OK;
char input_buffer[MAX_INPUT_BUFFER];
--- 52,58 ----
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 result = STATE_OK;
char input_buffer[MAX_INPUT_BUFFER];
***************
*** 72,76 ****
asprintf (&status, "%s", "Swap used:");
while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, fp)) {
! if (sscanf (input_buffer, " %s %d %d %d", str, &total, &used, &free) == 4 &&
strstr (str, "Swap")) {
total_swap += total;
--- 73,77 ----
asprintf (&status, "%s", "Swap used:");
while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, fp)) {
! if (sscanf (input_buffer, " %s %lu %lu %lu", str, &total, &used, &free) == 4 &&
strstr (str, "Swap")) {
total_swap += total;
***************
*** 78,82 ****
free_swap += free;
if (allswaps) {
! percent = 100 * (((float) used) / ((float) total));
if (percent >= crit_percent || free <= crit_size)
result = max_state (STATE_CRITICAL, result);
--- 79,83 ----
free_swap += free;
if (allswaps) {
! percent = 100 * (((double) used) / ((double) total));
if (percent >= crit_percent || free <= crit_size)
result = max_state (STATE_CRITICAL, result);
***************
*** 84,97 ****
result = max_state (STATE_WARNING, result);
if (verbose)
! asprintf (&status, "%s [%d/%d]", status, used, total);
}
}
}
! percent_used = 100 * (((float) used_swap) / ((float) total_swap));
if (percent_used >= crit_percent || free_swap <= crit_size)
result = max_state (STATE_CRITICAL, result);
else if (percent_used >= warn_percent || free_swap <= warn_size)
result = max_state (STATE_WARNING, result);
! asprintf (&status, "%s %2d%% (%d out of %d)", status, percent_used,
used_swap, total_swap);
fclose (fp);
--- 85,98 ----
result = max_state (STATE_WARNING, result);
if (verbose)
! asprintf (&status, "%s [%lu/%lu]", status, used, total);
}
}
}
! percent_used = 100 * (((double) used_swap) / ((double) total_swap));
if (percent_used >= crit_percent || free_swap <= crit_size)
result = max_state (STATE_CRITICAL, result);
else if (percent_used >= warn_percent || free_swap <= warn_size)
result = max_state (STATE_WARNING, result);
! asprintf (&status, "%s %2d%% (%lu out of %lu)", status, percent_used,
used_swap, total_swap);
fclose (fp);
***************
*** 132,136 ****
free_swap += free;
if (allswaps) {
! percent = 100 * (((float) used) / ((float) total));
if (percent >= crit_percent || free <= crit_size)
result = max_state (STATE_CRITICAL, result);
--- 133,137 ----
free_swap += free;
if (allswaps) {
! percent = 100 * (((double) used) / ((double) total));
if (percent >= crit_percent || free <= crit_size)
result = max_state (STATE_CRITICAL, result);
***************
*** 138,151 ****
result = max_state (STATE_WARNING, result);
if (verbose)
! asprintf (&status, "%s [%d/%d]", status, used, total);
}
}
! percent_used = 100 * ((float) used_swap) / ((float) total_swap);
! asprintf (&status, "%s %2d%% (%d out of %d)",
! status, percent_used, used_swap, total_swap);
if (percent_used >= crit_percent || free_swap <= crit_size)
result = max_state (STATE_CRITICAL, result);
else if (percent_used >= warn_percent || free_swap <= warn_size)
result = max_state (STATE_WARNING, result);
/* If we get anything on STDERR, at least set warning */
--- 139,152 ----
result = max_state (STATE_WARNING, result);
if (verbose)
! asprintf (&status, "%s [%lu/%lu]", status, used, total);
}
}
! percent_used = 100 * ((double) used_swap) / ((double) total_swap);
if (percent_used >= crit_percent || free_swap <= crit_size)
result = max_state (STATE_CRITICAL, result);
else if (percent_used >= warn_percent || free_swap <= warn_size)
result = max_state (STATE_WARNING, result);
+ asprintf (&status, "%s %2d%% (%lu out of %lu)",
+ status, percent_used, used_swap, total_swap);
/* If we get anything on STDERR, at least set warning */
***************
*** 232,236 ****
else if (strstr (optarg, ",") &&
strstr (optarg, "%") &&
! sscanf (optarg, "%d,%d%%", &warn_size, &warn_percent) == 2) {
break;
}
--- 233,237 ----
else if (strstr (optarg, ",") &&
strstr (optarg, "%") &&
! sscanf (optarg, "%lu,%d%%", &warn_size, &warn_percent) == 2) {
break;
}
***************
*** 250,254 ****
else if (strstr (optarg, ",") &&
strstr (optarg, "%") &&
! sscanf (optarg, "%d,%d%%", &crit_size, &crit_percent) == 2) {
break;
}
--- 251,255 ----
else if (strstr (optarg, ",") &&
strstr (optarg, "%") &&
! sscanf (optarg, "%lu,%d%%", &crit_size, &crit_percent) == 2) {
break;
}
More information about the Commits
mailing list