[Nagiosplug-checkins] CVS: nagiosplug/plugins check_swap.c,1.29,1.30 common.h,1.11,1.12

Ton Voon tonvoon at users.sourceforge.net
Thu Aug 19 12:06:17 CEST 2004


Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1241/plugins

Modified Files:
	check_swap.c common.h 
Log Message:
Patch for tru64 using swapctl calls (Sean Finney)


Index: check_swap.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_swap.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -r1.29 -r1.30
*** check_swap.c	2 Mar 2004 05:01:19 -0000	1.29
--- check_swap.c	19 Aug 2004 19:05:49 -0000	1.30
***************
*** 53,57 ****
  	int percent_used, percent;
  	unsigned long long total_swap = 0, used_swap = 0, free_swap = 0;
! 	unsigned long long dsktotal, dskused, dskfree, tmp;
  	int result = STATE_OK;
  	char input_buffer[MAX_INPUT_BUFFER];
--- 53,57 ----
  	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;
  	char input_buffer[MAX_INPUT_BUFFER];
***************
*** 65,68 ****
--- 65,73 ----
  	char *swap_command;
  	char *swap_format;
+ # else
+ #  ifdef HAVE_DECL_SWAPCTL
+ 	int i=0, nswaps=0;
+ 	swaptbl_t tbl;
+ #  endif /* HAVE_DECL_SWAPCTL */
  # endif
  #endif
***************
*** 231,234 ****
--- 236,276 ----
  	if (spclose (child_process))
  		result = max_state (result, STATE_WARNING);
+ # else
+ #  ifdef HAVE_DECL_SWAPCTL
+ 
+ 	/* initialize swap table entries */
+ 	memset(&tbl, 0, sizeof(swaptbl_t));
+ 	tbl.swt_ent[0].ste_path=(char*)malloc(sizeof(char)*(MAXPATHLEN+1));
+ 	memset(tbl.swt_ent[0].ste_path, 0, sizeof(char)*(MAXPATHLEN+1));
+ 	tbl.swt_n=1;
+ 
+ 	/* get the number of active swap devices */
+ 	nswaps=swapctl(SC_GETNSWP, NULL);
+ 
+ 	/* and now, tally 'em up */
+ 	for(i=0;i<nswaps;i++){
+ 		swapctl(SC_LIST, &tbl);
+ 		/* on tru64, swap is stored in 8k pages.  i'd
+ 		   use conv_factor or SWAP_CONVERSION, but they're
+ 		   both buried under a bunch of ifdef's.  ideally
+ 		   all functions could call getpagesize(2)...  */
+ 		dsktotal = tbl.swt_ent[0].ste_pages / 128;
+ 		dskfree = tbl.swt_ent[0].ste_free / 128;
+ 		dskused = ( total_swap - free_swap );
+ 
+ 		if(allswaps && dsktotal > 0){
+ 			percent = 100 * (((double) dskused) / ((double) dsktotal));
+ 			result = max_state (result, check_swap (percent, dskfree));
+ 		}
+ 
+ 		total_swap += dsktotal;
+ 		free_swap += dskfree;
+ 		used_swap += dskused;
+ 	}
+ 
+ 	/* and clean up after ourselves */
+ 	free(tbl.swt_ent[0].ste_path);
+ 
+ #  endif /* HAVE_DECL_SWAPCTL */
  # endif /* HAVE_SWAP */
  #endif /* HAVE_PROC_MEMINFO */

Index: common.h
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/common.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -r1.11 -r1.12
*** common.h	24 Oct 2003 13:28:24 -0000	1.11
--- common.h	19 Aug 2004 19:05:49 -0000	1.12
***************
*** 99,102 ****
--- 99,114 ----
  #endif
  
+ #ifdef HAVE_DECL_SWAPCTL
+ # ifdef HAVE_SYS_SWAP_H
+ #  include <sys/swap.h>
+ # endif
+ # ifdef HAVE_SYS_STAT_H
+ #  include <sys/stat.h>
+ # endif
+ # ifdef HAVE_SYS_PARAM_H
+ #  include <sys/param.h>
+ # endif
+ #endif
+ 
  /*
   *





More information about the Commits mailing list