[Nagiosplug-checkins] CVS: nagiosplug/plugins check_swap.c,1.2,1.3

Karl DeBisschop kdebisschop at users.sourceforge.net
Sun Oct 20 22:06:29 CEST 2002


Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory usw-pr-cvs1:/tmp/cvs-serv7684/plugins

Modified Files:
	check_swap.c 
Log Message:
use asprintf instead of ssprintf

Index: check_swap.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_swap.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** check_swap.c	18 Oct 2002 06:41:22 -0000	1.2
--- check_swap.c	21 Oct 2002 05:04:41 -0000	1.3
***************
*** 45,49 ****
  #ifdef HAVE_PROC_MEMINFO
  	fp = fopen (PROC_MEMINFO, "r");
! 	status = ssprintf (status, "%s", "Swap used:");
  	while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, fp)) {
  		sscanf (input_buffer, " %s %d %d %d", str, &total_swap, &used_swap,
--- 45,49 ----
  #ifdef HAVE_PROC_MEMINFO
  	fp = fopen (PROC_MEMINFO, "r");
! 	asprintf (&status, "%s", "Swap used:");
  	while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, fp)) {
  		sscanf (input_buffer, " %s %d %d %d", str, &total_swap, &used_swap,
***************
*** 51,58 ****
  		if (strstr (str, "Swap")) {
  			percent_used = 100 * (((float) used_swap) / ((float) total_swap));
! 			status = ssprintf
! 				(status,
! 				 "%s %2d%% (%d bytes out of %d)",
! 				 status, percent_used, used_swap, total_swap);
  			if (percent_used >= crit_percent || free_swap <= crit_size)
  				result = STATE_CRITICAL;
--- 51,56 ----
  		if (strstr (str, "Swap")) {
  			percent_used = 100 * (((float) used_swap) / ((float) total_swap));
! 			asprintf (&status, "%s %2d%% (%d bytes out of %d)",
! 			          status, percent_used, used_swap, total_swap);
  			if (percent_used >= crit_percent || free_swap <= crit_size)
  				result = STATE_CRITICAL;
***************
*** 91,103 ****
  	}
  
! 	status = ssprintf (status, "%s", "Swap used:");
  	while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) {
  		sscanf (input_buffer, SWAP_FORMAT, &total_swap, &free_swap);
  		used_swap = total_swap - free_swap;
  		percent_used = 100 * ((float) used_swap) / ((float) total_swap);
! 		status = ssprintf
! 			(status,
! 			 "%s %2d%% (%d bytes out of %d)",
! 			 status, percent_used, used_swap, total_swap);
  		if (percent_used >= crit_percent || free_swap <= crit_size)
  			result = STATE_CRITICAL;
--- 89,99 ----
  	}
  
! 	asprintf (&status, "%s", "Swap used:");
  	while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) {
  		sscanf (input_buffer, SWAP_FORMAT, &total_swap, &free_swap);
  		used_swap = total_swap - free_swap;
  		percent_used = 100 * ((float) used_swap) / ((float) total_swap);
! 		asprintf (&status, "%s %2d%% (%d bytes out of %d)",
! 		          status, percent_used, used_swap, total_swap);
  		if (percent_used >= crit_percent || free_swap <= crit_size)
  			result = STATE_CRITICAL;





More information about the Commits mailing list