summaryrefslogtreecommitdiffstats
path: root/plugins/check_nt.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_nt.c')
-rw-r--r--plugins/check_nt.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/plugins/check_nt.c b/plugins/check_nt.c
index b29d8b7a..1305a333 100644
--- a/plugins/check_nt.c
+++ b/plugins/check_nt.c
@@ -28,7 +28,6 @@
28 * 28 *
29 *****************************************************************************/ 29 *****************************************************************************/
30 30
31//#include "stdlib.h"
32#include "config.h" 31#include "config.h"
33#include "common.h" 32#include "common.h"
34#include "netutils.h" 33#include "netutils.h"
@@ -121,15 +120,15 @@ int main(int argc, char **argv){
121 120
122 if (check_value_list==TRUE) { 121 if (check_value_list==TRUE) {
123 if (strtolarray(&lvalue_list,value_list,",")==TRUE) { 122 if (strtolarray(&lvalue_list,value_list,",")==TRUE) {
124 // -l parameters is present with only integers 123 /* -l parameters is present with only integers */
125 return_code=STATE_OK; 124 return_code=STATE_OK;
126 asprintf(&temp_string,"CPU Load"); 125 asprintf(&temp_string,"CPU Load");
127 while (lvalue_list[0+offset]>0 && lvalue_list[0+offset]<=17280 && 126 while (lvalue_list[0+offset]>0 && lvalue_list[0+offset]<=17280 &&
128 lvalue_list[1+offset]>=0 && lvalue_list[1+offset]<=100 && 127 lvalue_list[1+offset]>=0 && lvalue_list[1+offset]<=100 &&
129 lvalue_list[2+offset]>=0 && lvalue_list[2+offset]<=100) { 128 lvalue_list[2+offset]>=0 && lvalue_list[2+offset]<=100) {
130 // loop until one of the parameters is wrong or not present 129 /* loop until one of the parameters is wrong or not present */
131 130
132 // Send request and retrieve data 131 /* Send request and retrieve data */
133 asprintf(&send_buffer,"%s&2&%lu",req_password,lvalue_list[0+offset]); 132 asprintf(&send_buffer,"%s&2&%lu",req_password,lvalue_list[0+offset]);
134 result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); 133 result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer));
135 if(result!=STATE_OK) 134 if(result!=STATE_OK)
@@ -142,7 +141,7 @@ int main(int argc, char **argv){
142 141
143 utilization=strtoul(recv_buffer,NULL,10); 142 utilization=strtoul(recv_buffer,NULL,10);
144 143
145 // Check if any of the request is in a warning or critical state 144 /* Check if any of the request is in a warning or critical state */
146 if(utilization >= lvalue_list[2+offset]) 145 if(utilization >= lvalue_list[2+offset])
147 return_code=STATE_CRITICAL; 146 return_code=STATE_CRITICAL;
148 else if(utilization >= lvalue_list[1+offset] && return_code<STATE_WARNING) 147 else if(utilization >= lvalue_list[1+offset] && return_code<STATE_WARNING)
@@ -150,10 +149,10 @@ int main(int argc, char **argv){
150 149
151 asprintf(&output_message," %lu%% (%lu min average)", utilization, lvalue_list[0+offset]); 150 asprintf(&output_message," %lu%% (%lu min average)", utilization, lvalue_list[0+offset]);
152 asprintf(&temp_string,"%s%s",temp_string,output_message); 151 asprintf(&temp_string,"%s%s",temp_string,output_message);
153 offset+=3; //move across the array 152 offset+=3; /* move across the array */
154 } 153 }
155 if (strlen(temp_string)>10) { 154 if (strlen(temp_string)>10) {
156 // we had at least on loop 155 /* we had at least on loop */
157 asprintf(&output_message,"%s",temp_string); 156 asprintf(&output_message,"%s",temp_string);
158 } 157 }
159 else 158 else
@@ -236,7 +235,7 @@ int main(int argc, char **argv){
236 else if(vars_to_check==CHECK_SERVICESTATE || vars_to_check==CHECK_PROCSTATE){ 235 else if(vars_to_check==CHECK_SERVICESTATE || vars_to_check==CHECK_PROCSTATE){
237 236
238 if (check_value_list==TRUE) { 237 if (check_value_list==TRUE) {
239 preparelist(value_list); // replace , between services with & to send the request 238 preparelist(value_list); /* replace , between services with & to send the request */
240 asprintf(&send_buffer,"%s&%u&%s&%s", req_password,(vars_to_check==CHECK_SERVICESTATE)?5:6, 239 asprintf(&send_buffer,"%s&%u&%s&%s", req_password,(vars_to_check==CHECK_SERVICESTATE)?5:6,
241 (show_all==TRUE)?"ShowAll":"ShowFail",value_list); 240 (show_all==TRUE)?"ShowAll":"ShowFail",value_list);
242 result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); 241 result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer));
@@ -286,7 +285,7 @@ int main(int argc, char **argv){
286 else if(vars_to_check==CHECK_COUNTER) { 285 else if(vars_to_check==CHECK_COUNTER) {
287 286
288 if (check_value_list==TRUE) { 287 if (check_value_list==TRUE) {
289 preparelist(value_list); // replace , between services with & to send the request 288 preparelist(value_list); /* replace , between services with & to send the request */
290 asprintf(&send_buffer,"%s&8&%s", req_password,value_list); 289 asprintf(&send_buffer,"%s&8&%s", req_password,value_list);
291 result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); 290 result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer));
292 if (result!=STATE_OK) 291 if (result!=STATE_OK)
@@ -297,7 +296,7 @@ int main(int argc, char **argv){
297 exit(STATE_UNKNOWN); 296 exit(STATE_UNKNOWN);
298 } 297 }
299 298
300 strtok(value_list,"&"); // burn the first parameters 299 strtok(value_list,"&"); /* burn the first parameters */
301 description = strtok(NULL,"&"); 300 description = strtok(NULL,"&");
302 counter_value = atof(recv_buffer); 301 counter_value = atof(recv_buffer);
303 if (description == NULL) 302 if (description == NULL)
@@ -306,7 +305,7 @@ int main(int argc, char **argv){
306 asprintf(&output_message, description, counter_value); 305 asprintf(&output_message, description, counter_value);
307 306
308 if (critical_value > warning_value) { 307 if (critical_value > warning_value) {
309 // Normal thresholds 308 /* Normal thresholds */
310 if(check_critical_value==TRUE && counter_value >= critical_value) 309 if(check_critical_value==TRUE && counter_value >= critical_value)
311 return_code=STATE_CRITICAL; 310 return_code=STATE_CRITICAL;
312 else if (check_warning_value==TRUE && counter_value >= warning_value) 311 else if (check_warning_value==TRUE && counter_value >= warning_value)
@@ -315,7 +314,7 @@ int main(int argc, char **argv){
315 return_code=STATE_OK; 314 return_code=STATE_OK;
316 } 315 }
317 else { 316 else {
318 // inverse thresholds 317 /* inverse thresholds */
319 if(check_critical_value==TRUE && counter_value <= critical_value) 318 if(check_critical_value==TRUE && counter_value <= critical_value)
320 return_code=STATE_CRITICAL; 319 return_code=STATE_CRITICAL;
321 else if (check_warning_value==TRUE && counter_value <= warning_value) 320 else if (check_warning_value==TRUE && counter_value <= warning_value)
@@ -333,7 +332,7 @@ int main(int argc, char **argv){
333 else if(vars_to_check==CHECK_FILEAGE) { 332 else if(vars_to_check==CHECK_FILEAGE) {
334 333
335 if (check_value_list==TRUE) { 334 if (check_value_list==TRUE) {
336 preparelist(value_list); // replace , between services with & to send the request 335 preparelist(value_list); /* replace , between services with & to send the request */
337 asprintf(&send_buffer,"%s&9&%s", req_password,value_list); 336 asprintf(&send_buffer,"%s&9&%s", req_password,value_list);
338 result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); 337 result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer));
339 if (result!=STATE_OK) 338 if (result!=STATE_OK)
@@ -349,7 +348,7 @@ int main(int argc, char **argv){
349 asprintf(&output_message, description); 348 asprintf(&output_message, description);
350 349
351 if (critical_value > warning_value) { 350 if (critical_value > warning_value) {
352 // Normal thresholds 351 /* Normal thresholds */
353 if(check_critical_value==TRUE && age_in_minutes >= critical_value) 352 if(check_critical_value==TRUE && age_in_minutes >= critical_value)
354 return_code=STATE_CRITICAL; 353 return_code=STATE_CRITICAL;
355 else if (check_warning_value==TRUE && age_in_minutes >= warning_value) 354 else if (check_warning_value==TRUE && age_in_minutes >= warning_value)
@@ -358,7 +357,7 @@ int main(int argc, char **argv){
358 return_code=STATE_OK; 357 return_code=STATE_OK;
359 } 358 }
360 else { 359 else {
361 // inverse thresholds 360 /* inverse thresholds */
362 if(check_critical_value==TRUE && age_in_minutes <= critical_value) 361 if(check_critical_value==TRUE && age_in_minutes <= critical_value)
363 return_code=STATE_CRITICAL; 362 return_code=STATE_CRITICAL;
364 else if (check_warning_value==TRUE && age_in_minutes <= warning_value) 363 else if (check_warning_value==TRUE && age_in_minutes <= warning_value)
@@ -563,7 +562,7 @@ void print_help(void)
563} 562}
564 563
565int strtolarray(unsigned long *array, char *string, char *delim) { 564int strtolarray(unsigned long *array, char *string, char *delim) {
566 // split a <delim> delimited string into a long array 565 /* split a <delim> delimited string into a long array */
567 int idx=0; 566 int idx=0;
568 char *t1; 567 char *t1;
569 568
@@ -582,7 +581,7 @@ int strtolarray(unsigned long *array, char *string, char *delim) {
582} 581}
583 582
584void preparelist(char *string) { 583void preparelist(char *string) {
585 // Replace all , with & which is the delimiter for the request 584 /* Replace all , with & which is the delimiter for the request */
586 int i; 585 int i;
587 586
588 for (i = 0; i < strlen(string); i++) 587 for (i = 0; i < strlen(string); i++)