summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTon Voon <tonvoon@users.sourceforge.net>2004-08-18 19:40:46 (GMT)
committerTon Voon <tonvoon@users.sourceforge.net>2004-08-18 19:40:46 (GMT)
commit1321f206eb4afb2f877adc5811ad790a732a7cc5 (patch)
treecc23196abc7ce7e0541209cf708a5d6bead6f55e
parent2243e52612c93ea5c07dfe7a4fb68d2471283ce3 (diff)
downloadmonitoring-plugins-1321f206eb4afb2f877adc5811ad790a732a7cc5.tar.gz
Perfdata added (Gary Cook)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@881 f882894a-f735-0410-b71e-b25c423dba1c
-rw-r--r--plugins/check_nt.c50
1 files changed, 37 insertions, 13 deletions
diff --git a/plugins/check_nt.c b/plugins/check_nt.c
index 605d479..ef0a66b 100644
--- a/plugins/check_nt.c
+++ b/plugins/check_nt.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * CHECK_NT.C 3 * CHECK_NT.C
4 * 4 *
5 * Program: Windows NT plugin for NetSaint 5 * Program: Windows NT plugin for Nagios
6 * License: GPL 6 * License: GPL
7 * Copyright (c) 2000-2002 Yves Rubin (rubiyz@yahoo.com) 7 * Copyright (c) 2000-2002 Yves Rubin (rubiyz@yahoo.com)
8 * 8 *
@@ -78,12 +78,16 @@ int main(int argc, char **argv){
78 int return_code = STATE_UNKNOWN; 78 int return_code = STATE_UNKNOWN;
79 char *send_buffer=NULL; 79 char *send_buffer=NULL;
80 char *output_message=NULL; 80 char *output_message=NULL;
81 char *perfdata=NULL;
81 char *temp_string=NULL; 82 char *temp_string=NULL;
83 char *temp_string_perf=NULL;
82 char *description=NULL; 84 char *description=NULL;
83 85
84 double total_disk_space=0; 86 double total_disk_space=0;
85 double free_disk_space=0; 87 double free_disk_space=0;
86 double percent_used_space=0; 88 double percent_used_space=0;
89 double warning_used_space=0;
90 double critical_used_space=0;
87 double mem_commitLimit=0; 91 double mem_commitLimit=0;
88 double mem_commitByte=0; 92 double mem_commitByte=0;
89 unsigned long utilization; 93 unsigned long utilization;
@@ -133,6 +137,8 @@ int main(int argc, char **argv){
133 /* -l parameters is present with only integers */ 137 /* -l parameters is present with only integers */
134 return_code=STATE_OK; 138 return_code=STATE_OK;
135 temp_string = strdup (_("CPU Load")); 139 temp_string = strdup (_("CPU Load"));
140 temp_string_perf = strdup (_(" "));
141
136 /* loop until one of the parameters is wrong or not present */ 142 /* loop until one of the parameters is wrong or not present */
137 while (lvalue_list[0+offset]> (unsigned long)0 && 143 while (lvalue_list[0+offset]> (unsigned long)0 &&
138 lvalue_list[0+offset]<=(unsigned long)17280 && 144 lvalue_list[0+offset]<=(unsigned long)17280 &&
@@ -155,11 +161,16 @@ int main(int argc, char **argv){
155 161
156 asprintf(&output_message,_(" %lu%% (%lu min average)"), utilization, lvalue_list[0+offset]); 162 asprintf(&output_message,_(" %lu%% (%lu min average)"), utilization, lvalue_list[0+offset]);
157 asprintf(&temp_string,"%s%s",temp_string,output_message); 163 asprintf(&temp_string,"%s%s",temp_string,output_message);
164 asprintf(&perfdata,_(" '%lu min avg Load'=%lu%%;%lu;%lu;0;100"), lvalue_list[0+offset], utilization,
165 lvalue_list[1+offset], lvalue_list[2+offset]);
166 asprintf(&temp_string_perf,"%s%s",temp_string_perf,perfdata);
158 offset+=3; /* move across the array */ 167 offset+=3; /* move across the array */
159 } 168 }
160 if (strlen(temp_string)>10) /* we had at least one loop */ 169
170 if (strlen(temp_string)>10) { /* we had at least one loop */
161 output_message = strdup (temp_string); 171 output_message = strdup (temp_string);
162 else 172 perfdata = temp_string_perf;
173 } else
163 output_message = strdup (_("not enough values for -l parameters")); 174 output_message = strdup (_("not enough values for -l parameters"));
164 } 175 }
165 break; 176 break;
@@ -188,12 +199,16 @@ int main(int argc, char **argv){
188 free_disk_space=atof(strtok(recv_buffer,"&")); 199 free_disk_space=atof(strtok(recv_buffer,"&"));
189 total_disk_space=atof(strtok(NULL,"&")); 200 total_disk_space=atof(strtok(NULL,"&"));
190 percent_used_space = ((total_disk_space - free_disk_space) / total_disk_space) * 100; 201 percent_used_space = ((total_disk_space - free_disk_space) / total_disk_space) * 100;
202 warning_used_space = ((float)warning_value / 100) * total_disk_space;
203 critical_used_space = ((float)critical_value / 100) * total_disk_space;
191 204
192 if (free_disk_space>=0) { 205 if (free_disk_space>=0) {
193 asprintf(&temp_string,_("%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)"), 206 asprintf(&temp_string,_("%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)"),
194 value_list, total_disk_space / 1073741824, (total_disk_space - free_disk_space) / 1073741824, percent_used_space, 207 value_list, total_disk_space / 1073741824, (total_disk_space - free_disk_space) / 1073741824,
195 free_disk_space / 1073741824, (free_disk_space / total_disk_space)*100); 208 percent_used_space, free_disk_space / 1073741824, (free_disk_space / total_disk_space)*100);
196 209 asprintf(&temp_string_perf,_("'%s:\\ Used Space'=%.2fGb;%.2f;%.2f;0.00;%.2f"), value_list,
210 (total_disk_space - free_disk_space) / 1073741824, warning_used_space / 1073741824,
211 critical_used_space / 1073741824, total_disk_space / 1073741824);
197 212
198 if(check_critical_value==TRUE && percent_used_space >= critical_value) 213 if(check_critical_value==TRUE && percent_used_space >= critical_value)
199 return_code=STATE_CRITICAL; 214 return_code=STATE_CRITICAL;
@@ -203,8 +218,8 @@ int main(int argc, char **argv){
203 return_code=STATE_OK; 218 return_code=STATE_OK;
204 219
205 output_message = strdup (temp_string); 220 output_message = strdup (temp_string);
206 } 221 perfdata = temp_string_perf;
207 else { 222 } else {
208 output_message = strdup (_("Free disk space : Invalid drive ")); 223 output_message = strdup (_("Free disk space : Invalid drive "));
209 return_code=STATE_UNKNOWN; 224 return_code=STATE_UNKNOWN;
210 } 225 }
@@ -234,9 +249,15 @@ int main(int argc, char **argv){
234 mem_commitLimit=atof(strtok(recv_buffer,"&")); 249 mem_commitLimit=atof(strtok(recv_buffer,"&"));
235 mem_commitByte=atof(strtok(NULL,"&")); 250 mem_commitByte=atof(strtok(NULL,"&"));
236 percent_used_space = (mem_commitByte / mem_commitLimit) * 100; 251 percent_used_space = (mem_commitByte / mem_commitLimit) * 100;
252 warning_used_space = ((float)warning_value / 100) * mem_commitLimit;
253 critical_used_space = ((float)critical_value / 100) * mem_commitLimit;
254
255 // Changed divisor in following line from 1048567 to 3044515 to accurately reflect memory size
237 asprintf(&output_message,_("Memory usage: total:%.2f Mb - used: %.2f Mb (%.0f%%) - free: %.2f Mb (%.0f%%)"), 256 asprintf(&output_message,_("Memory usage: total:%.2f Mb - used: %.2f Mb (%.0f%%) - free: %.2f Mb (%.0f%%)"),
238 mem_commitLimit / 1048576, mem_commitByte / 1048567, percent_used_space, 257 mem_commitLimit / 3044515, mem_commitByte / 3044515, percent_used_space,
239 (mem_commitLimit - mem_commitByte) / 1048576, (mem_commitLimit - mem_commitByte) / mem_commitLimit * 100); 258 (mem_commitLimit - mem_commitByte) / 3044515, (mem_commitLimit - mem_commitByte) / mem_commitLimit * 100);
259 asprintf(&perfdata,_("'Memory usage'=%.2fMb;%.2f;%.2f;0.00;%.2f"), mem_commitByte / 3044515,
260 warning_used_space / 3044515, critical_used_space / 3044515, mem_commitLimit / 3044515);
240 261
241 return_code=STATE_OK; 262 return_code=STATE_OK;
242 if(check_critical_value==TRUE && percent_used_space >= critical_value) 263 if(check_critical_value==TRUE && percent_used_space >= critical_value)
@@ -262,6 +283,7 @@ int main(int argc, char **argv){
262 asprintf(&output_message, "%.f", counter_value); 283 asprintf(&output_message, "%.f", counter_value);
263 else 284 else
264 asprintf(&output_message,"%s = %.f", description, counter_value); 285 asprintf(&output_message,"%s = %.f", description, counter_value);
286 asprintf(&perfdata,"'%s'=%.f", description, counter_value);
265 287
266 if (critical_value > warning_value) { /* Normal thresholds */ 288 if (critical_value > warning_value) { /* Normal thresholds */
267 if(check_critical_value==TRUE && counter_value >= critical_value) 289 if(check_critical_value==TRUE && counter_value >= critical_value)
@@ -322,8 +344,10 @@ int main(int argc, char **argv){
322 /* reset timeout */ 344 /* reset timeout */
323 alarm(0); 345 alarm(0);
324 346
325 printf("%s\n",output_message); 347 if (perfdata==NULL)
326 348 printf("%s\n",output_message);
349 else
350 printf("%s | %s\n",output_message,perfdata);
327 return return_code; 351 return return_code;
328} 352}
329 353
@@ -575,7 +599,7 @@ Windows NT/2000/XP server.\n\n"));
575 Some examples:\n\ 599 Some examples:\n\
576 \"Paging file usage is %%.2f %%%%\"\n\ 600 \"Paging file usage is %%.2f %%%%\"\n\
577 \"%%.f %%%% paging file used.\"\n")); 601 \"%%.f %%%% paging file used.\"\n"));
578 printf (_("Notes:\n\ 602 printf (_("Notes:\n\
579 - The NSClient service should be running on the server to get any information\n\ 603 - The NSClient service should be running on the server to get any information\n\
580 (http://nsclient.ready2run.nl).\n\ 604 (http://nsclient.ready2run.nl).\n\
581 - Critical thresholds should be lower than warning thresholds\n")); 605 - Critical thresholds should be lower than warning thresholds\n"));