[Nagiosplug-checkins] CVS: nagiosplug/plugins check_nt.c,1.22,1.23

Ton Voon tonvoon at users.sourceforge.net
Wed Aug 18 12:41:29 CEST 2004


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

Modified Files:
	check_nt.c 
Log Message:
Perfdata added (Gary Cook)


Index: check_nt.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_nt.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -r1.22 -r1.23
*** check_nt.c	31 Mar 2004 22:53:25 -0000	1.22
--- check_nt.c	18 Aug 2004 19:40:46 -0000	1.23
***************
*** 3,7 ****
   * CHECK_NT.C
   *
!  * Program: Windows NT plugin for NetSaint
   * License: GPL
   * Copyright (c) 2000-2002 Yves Rubin (rubiyz at yahoo.com)
--- 3,7 ----
   * CHECK_NT.C
   *
!  * Program: Windows NT plugin for Nagios
   * License: GPL
   * Copyright (c) 2000-2002 Yves Rubin (rubiyz at yahoo.com)
***************
*** 79,83 ****
--- 79,85 ----
  	char *send_buffer=NULL;
  	char *output_message=NULL;
+ 	char *perfdata=NULL;
  	char *temp_string=NULL;
+ 	char *temp_string_perf=NULL;
  	char *description=NULL;
  
***************
*** 85,88 ****
--- 87,92 ----
  	double free_disk_space=0;
  	double percent_used_space=0;
+ 	double warning_used_space=0;
+ 	double critical_used_space=0;
  	double mem_commitLimit=0;
  	double mem_commitByte=0;
***************
*** 134,137 ****
--- 138,143 ----
  			return_code=STATE_OK;
  			temp_string = strdup (_("CPU Load"));
+ 			temp_string_perf = strdup (_(" "));
+       
  			/* loop until one of the parameters is wrong or not present */
  			while (lvalue_list[0+offset]> (unsigned long)0 &&
***************
*** 156,164 ****
  				asprintf(&output_message,_(" %lu%% (%lu min average)"), utilization, lvalue_list[0+offset]);
  				asprintf(&temp_string,"%s%s",temp_string,output_message);
  				offset+=3;	/* move across the array */
  			}
! 			if (strlen(temp_string)>10)  /* we had at least one loop */
  				output_message = strdup (temp_string);
! 			else
  				output_message = strdup (_("not enough values for -l parameters"));
  		}	
--- 162,175 ----
  				asprintf(&output_message,_(" %lu%% (%lu min average)"), utilization, lvalue_list[0+offset]);
  				asprintf(&temp_string,"%s%s",temp_string,output_message);
+ 				asprintf(&perfdata,_(" '%lu min avg Load'=%lu%%;%lu;%lu;0;100"), lvalue_list[0+offset], utilization,
+ 				  lvalue_list[1+offset], lvalue_list[2+offset]);
+ 				asprintf(&temp_string_perf,"%s%s",temp_string_perf,perfdata);
  				offset+=3;	/* move across the array */
  			}
!       
! 			if (strlen(temp_string)>10) {  /* we had at least one loop */
  				output_message = strdup (temp_string);
! 				perfdata = temp_string_perf;
! 			} else
  				output_message = strdup (_("not enough values for -l parameters"));
  		}	
***************
*** 189,198 ****
  			total_disk_space=atof(strtok(NULL,"&"));
  			percent_used_space = ((total_disk_space - free_disk_space) / total_disk_space) * 100;
  
  			if (free_disk_space>=0) {
  				asprintf(&temp_string,_("%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)"),
! 								 value_list, total_disk_space / 1073741824, (total_disk_space - free_disk_space) / 1073741824, percent_used_space,
! 								 free_disk_space / 1073741824, (free_disk_space / total_disk_space)*100); 
! 
  
  				if(check_critical_value==TRUE && percent_used_space >= critical_value)
--- 200,213 ----
  			total_disk_space=atof(strtok(NULL,"&"));
  			percent_used_space = ((total_disk_space - free_disk_space) / total_disk_space) * 100;
+ 			warning_used_space = ((float)warning_value / 100) * total_disk_space;
+ 			critical_used_space = ((float)critical_value / 100) * total_disk_space;
  
  			if (free_disk_space>=0) {
  				asprintf(&temp_string,_("%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)"),
! 				  value_list, total_disk_space / 1073741824, (total_disk_space - free_disk_space) / 1073741824,
! 				  percent_used_space, free_disk_space / 1073741824, (free_disk_space / total_disk_space)*100);
! 				asprintf(&temp_string_perf,_("'%s:\\ Used Space'=%.2fGb;%.2f;%.2f;0.00;%.2f"), value_list,
! 				  (total_disk_space - free_disk_space) / 1073741824, warning_used_space / 1073741824,
! 				  critical_used_space / 1073741824, total_disk_space / 1073741824);
  
  				if(check_critical_value==TRUE && percent_used_space >= critical_value)
***************
*** 204,209 ****
  
  				output_message = strdup (temp_string);
! 			}
! 			else {
  				output_message = strdup (_("Free disk space : Invalid drive "));
  				return_code=STATE_UNKNOWN;
--- 219,224 ----
  
  				output_message = strdup (temp_string);
! 				perfdata = temp_string_perf;
! 			} else {
  				output_message = strdup (_("Free disk space : Invalid drive "));
  				return_code=STATE_UNKNOWN;
***************
*** 235,241 ****
  		mem_commitByte=atof(strtok(NULL,"&"));
  		percent_used_space = (mem_commitByte / mem_commitLimit) * 100;
  		asprintf(&output_message,_("Memory usage: total:%.2f Mb - used: %.2f Mb (%.0f%%) - free: %.2f Mb (%.0f%%)"), 
! 			mem_commitLimit / 1048576, mem_commitByte / 1048567, percent_used_space,  
! 			(mem_commitLimit - mem_commitByte) / 1048576, (mem_commitLimit - mem_commitByte) / mem_commitLimit * 100);
  	
  		return_code=STATE_OK;
--- 250,262 ----
  		mem_commitByte=atof(strtok(NULL,"&"));
  		percent_used_space = (mem_commitByte / mem_commitLimit) * 100;
+ 		warning_used_space = ((float)warning_value / 100) * mem_commitLimit;
+ 		critical_used_space = ((float)critical_value / 100) * mem_commitLimit;
+ 
+ 		// Changed divisor in following line from 1048567 to 3044515 to accurately reflect memory size
  		asprintf(&output_message,_("Memory usage: total:%.2f Mb - used: %.2f Mb (%.0f%%) - free: %.2f Mb (%.0f%%)"), 
! 		  mem_commitLimit / 3044515, mem_commitByte / 3044515, percent_used_space,  
! 		  (mem_commitLimit - mem_commitByte) / 3044515, (mem_commitLimit - mem_commitByte) / mem_commitLimit * 100);
! 		asprintf(&perfdata,_("'Memory usage'=%.2fMb;%.2f;%.2f;0.00;%.2f"), mem_commitByte / 3044515,
! 		  warning_used_space / 3044515, critical_used_space / 3044515, mem_commitLimit / 3044515);
  	
  		return_code=STATE_OK;
***************
*** 263,266 ****
--- 284,288 ----
  			else
  				asprintf(&output_message,"%s = %.f",  description, counter_value);
+ 			asprintf(&perfdata,"'%s'=%.f",  description, counter_value);
  	
  			if (critical_value > warning_value) {        /* Normal thresholds */
***************
*** 323,328 ****
  	alarm(0);
  
! 	printf("%s\n",output_message);
! 
  	return return_code;
  }
--- 345,352 ----
  	alarm(0);
  
! 	if (perfdata==NULL)
! 		printf("%s\n",output_message);
! 	else
! 		printf("%s | %s\n",output_message,perfdata);
  	return return_code;
  }
***************
*** 576,580 ****
         \"Paging file usage is %%.2f %%%%\"\n\
         \"%%.f %%%% paging file used.\"\n"));
! 	printf (_("Notes:\n\
   - The NSClient service should be running on the server to get any information\n\
     (http://nsclient.ready2run.nl).\n\
--- 600,604 ----
         \"Paging file usage is %%.2f %%%%\"\n\
         \"%%.f %%%% paging file used.\"\n"));
!   printf (_("Notes:\n\
   - The NSClient service should be running on the server to get any information\n\
     (http://nsclient.ready2run.nl).\n\





More information about the Commits mailing list