[Nagiosplug-checkins] CVS: nagiosplug/plugins check_swap.c,1.19,1.20

Ton Voon tonvoon at users.sourceforge.net
Wed Sep 17 02:32:10 CEST 2003


Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory sc8-pr-cvs1:/tmp/cvs-serv2577/plugins

Modified Files:
	check_swap.c 
Log Message:
Support for check_swap in AIX (tested on 5.1)


Index: check_swap.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_swap.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -r1.19 -r1.20
*** check_swap.c	11 Sep 2003 08:02:04 -0000	1.19
--- check_swap.c	17 Sep 2003 09:31:56 -0000	1.20
***************
*** 48,55 ****
  int allswaps;
  
- #if !defined(sun)
- int sun = 0;	/* defined by compiler if it is a sun solaris system */
- #endif
- 
  int
  main (int argc, char **argv)
--- 48,51 ----
***************
*** 104,111 ****
  #else
  # ifdef HAVE_SWAP
! 	if (!allswaps && sun) {
  		asprintf(&swap_command, "%s", "/usr/sbin/swap -s");
  		asprintf(&swap_format, "%s", "%*s %*dk %*s %*s + %*dk %*s = %dk %*s %dk %*s");
  		conv_factor = 2048;
  	} else {
  		asprintf(&swap_command, "%s", SWAP_COMMAND);
--- 100,115 ----
  #else
  # ifdef HAVE_SWAP
! 	if (!allswaps) {
! #ifdef _AIX
! 		asprintf(&swap_command, "%s", "/usr/sbin/lsps -s");
! 		asprintf(&swap_format, "%s", "%d%*s %d");
! 		conv_factor = 1;
! #else
! # ifdef sun
  		asprintf(&swap_command, "%s", "/usr/sbin/swap -s");
  		asprintf(&swap_format, "%s", "%*s %*dk %*s %*s + %*dk %*s = %dk %*s %dk %*s");
  		conv_factor = 2048;
+ # endif
+ #endif
  	} else {
  		asprintf(&swap_command, "%s", SWAP_COMMAND);
***************
*** 145,153 ****
  	}
  
! 	if (!allswaps && sun) {
  		sscanf (input_buffer, swap_format, &used_swap, &free_swap);
  		used_swap = used_swap / 1024;
  		free_swap = free_swap / 1024;
  		total_swap = used_swap + free_swap;
  	} else {
  		while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) {
--- 149,168 ----
  	}
  
! 	if (!allswaps) {
! #ifdef _AIX
! 		fgets(input_buffer, MAX_INPUT_BUFFER - 1, child_process);	/* Ignore first line */
! 		sscanf (input_buffer, swap_format, &total_swap, &used_swap);
! 		free_swap = total_swap * (100 - used_swap) /100;
! 		used_swap = total_swap - free_swap;
! 		if (verbose >= 3)
! 			printf (_("total=%d, used=%d, free=%d\n"), total_swap, used_swap, free_swap);
! #else
! # ifdef sun
  		sscanf (input_buffer, swap_format, &used_swap, &free_swap);
  		used_swap = used_swap / 1024;
  		free_swap = free_swap / 1024;
  		total_swap = used_swap + free_swap;
+ # endif
+ #endif
  	} else {
  		while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) {
***************
*** 155,159 ****
--- 170,179 ----
  
  			dsktotal = dsktotal / conv_factor;
+ 			/* AIX lists percent used, so this converts to dskfree in MBs */
+ #ifdef _AIX
+ 			dskfree = dsktotal * (100 - dskfree) / 100;
+ #else
  			dskfree = dskfree / conv_factor;
+ #endif
  			if (verbose >= 3)
  				printf (_("total=%d, free=%d\n"), dsktotal, dskfree);
***************
*** 373,376 ****
--- 393,400 ----
  Will be discrepencies because swap -s counts allocated swap and includes\n\
  real memory\n"));
+ #endif
+ #ifdef _AIX
+ 	printf (_("\n\
+ On AIX, if -a is specified, uses lsps -a, otherwise uses lsps -s.\n"));
  #endif
  





More information about the Commits mailing list