[Nagiosplug-checkins] CVS: nagiosplug/plugins check_swap.c,1.18,1.19
Karl DeBisschop
kdebisschop at users.sourceforge.net
Thu Sep 11 01:10:20 CEST 2003
Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory sc8-pr-cvs1:/tmp/cvs-serv22727/plugins
Modified Files:
check_swap.c
Log Message:
last changes to configure broke check_swap on RHLinux. Restore /proc/meminfo check and make check_swap ifdefs safer
Index: check_swap.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_swap.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -r1.18 -r1.19
*** check_swap.c 22 Aug 2003 06:22:38 -0000 1.18
--- check_swap.c 11 Sep 2003 08:02:04 -0000 1.19
***************
*** 60,71 ****
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;
! #endif
! #ifdef HAVE_PROC_MEMINFO
! FILE *fp;
#endif
char str[32];
--- 60,72 ----
int result = STATE_OK;
char input_buffer[MAX_INPUT_BUFFER];
! #ifdef HAVE_PROC_MEMINFO
! FILE *fp;
! #else
! # ifdef HAVE_SWAP
int conv_factor; /* Convert to MBs */
char *temp_buffer;
char *swap_command;
char *swap_format;
! # endif
#endif
char str[32];
***************
*** 89,94 ****
dskused = dskused / 1048576;
dskfree = dskfree / 1048576;
! #endif
! #ifdef HAVE_SWAP
if (!allswaps && sun) {
asprintf(&swap_command, "%s", "/usr/sbin/swap -s");
--- 90,107 ----
dskused = dskused / 1048576;
dskfree = dskfree / 1048576;
! total_swap += dsktotal;
! used_swap += dskused;
! free_swap += dskfree;
! if (allswaps) {
! percent = 100 * (((double) dskused) / ((double) dsktotal));
! result = max_state (result, check_swap (percent, dskfree));
! if (verbose)
! asprintf (&status, "%s [%lu (%d%%)]", status, dskfree, 100 - percent);
! }
! }
! }
! fclose(fp);
! #else
! # ifdef HAVE_SWAP
if (!allswaps && sun) {
asprintf(&swap_command, "%s", "/usr/sbin/swap -s");
***************
*** 104,108 ****
printf (_("Command: %s\n"), swap_command);
if (verbose >= 3)
! printf ("_(Format: %s\n"), swap_format);
child_process = spopen (swap_command);
--- 117,121 ----
printf (_("Command: %s\n"), swap_command);
if (verbose >= 3)
! printf (_("Format: %s\n"), swap_format);
child_process = spopen (swap_command);
***************
*** 147,151 ****
dskused = dsktotal - dskfree;
- #endif
total_swap += dsktotal;
used_swap += dskused;
--- 160,163 ----
***************
*** 159,171 ****
}
}
- percent_used = 100 * ((double) used_swap) / ((double) total_swap);
- result = max_state (result, check_swap (percent_used, free_swap));
- asprintf (&status, _(" %d%% free (%lu MB out of %lu MB)%s"),
- (100 - percent_used), free_swap, total_swap, status);
-
- #ifdef HAVE_PROC_MEMINFO
- fclose(fp);
- #endif
- #ifdef HAVE_SWAP
/* If we get anything on STDERR, at least set warning */
while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr))
--- 171,174 ----
***************
*** 178,182 ****
--- 181,191 ----
if (spclose (child_process))
result = max_state (result, STATE_WARNING);
+ # endif
#endif
+
+ percent_used = 100 * ((double) used_swap) / ((double) total_swap);
+ result = max_state (result, check_swap (percent_used, free_swap));
+ asprintf (&status, _(" %d%% free (%lu MB out of %lu MB)%s"),
+ (100 - percent_used), free_swap, total_swap, status);
die (result, "SWAP %s:%s\n", state_text (result), status);
More information about the Commits
mailing list