summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorTon Voon <tonvoon@users.sourceforge.net>2003-01-31 01:26:40 (GMT)
committerTon Voon <tonvoon@users.sourceforge.net>2003-01-31 01:26:40 (GMT)
commit804c6251f22ea47a0c9446b78c39329b2b2e46ae (patch)
tree54d3c0f62145ebb834b0f00de3d6b394c59bff06 /plugins
parentd0df392e2b858d3ae633f701db92a8b15843cc38 (diff)
downloadmonitoring-plugins-804c6251f22ea47a0c9446b78c39329b2b2e46ae.tar.gz
Removed all unnecessary asprintf calls. Replaced with original check_nt.c
to minimise amount of changes (reported by Reuben Farrelly) git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@275 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_nt.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/plugins/check_nt.c b/plugins/check_nt.c
index 4d43f54..32c180f 100644
--- a/plugins/check_nt.c
+++ b/plugins/check_nt.c
@@ -97,7 +97,7 @@ int main(int argc, char **argv){
97 int updays=0; 97 int updays=0;
98 int uphours=0; 98 int uphours=0;
99 int upminutes=0; 99 int upminutes=0;
100 asprintf(&req_password,"None"); 100 req_password=strscpy(req_password,"None");
101 101
102 if(process_arguments(argc,argv)==ERROR) 102 if(process_arguments(argc,argv)==ERROR)
103 usage("Could not parse arguments\n"); 103 usage("Could not parse arguments\n");
@@ -110,11 +110,11 @@ int main(int argc, char **argv){
110 110
111 if (vars_to_check==CHECK_CLIENTVERSION) { 111 if (vars_to_check==CHECK_CLIENTVERSION) {
112 112
113 asprintf(&send_buffer,strcat(req_password,"&1")); 113 send_buffer = strscpy(send_buffer,strcat(req_password,"&1"));
114 result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); 114 result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer));
115 if(result!=STATE_OK) 115 if(result!=STATE_OK)
116 return result; 116 return result;
117 asprintf(&output_message,recv_buffer); 117 output_message = strscpy(output_message,recv_buffer);
118 return_code=STATE_OK; 118 return_code=STATE_OK;
119 } 119 }
120 else if(vars_to_check==CHECK_CPULOAD){ 120 else if(vars_to_check==CHECK_CPULOAD){
@@ -123,7 +123,7 @@ int main(int argc, char **argv){
123 if (strtolarray(&lvalue_list,value_list,",")==TRUE) { 123 if (strtolarray(&lvalue_list,value_list,",")==TRUE) {
124 // -l parameters is present with only integers 124 // -l parameters is present with only integers
125 return_code=STATE_OK; 125 return_code=STATE_OK;
126 asprintf(&temp_string,"CPU Load"); 126 temp_string = strscpy(temp_string,"CPU Load");
127 while (lvalue_list[0+offset]>0 && lvalue_list[0+offset]<=17280 && 127 while (lvalue_list[0+offset]>0 && lvalue_list[0+offset]<=17280 &&
128 lvalue_list[1+offset]>=0 && lvalue_list[1+offset]<=100 && 128 lvalue_list[1+offset]>=0 && lvalue_list[1+offset]<=100 &&
129 lvalue_list[2+offset]>=0 && lvalue_list[2+offset]<=100) { 129 lvalue_list[2+offset]>=0 && lvalue_list[2+offset]<=100) {
@@ -149,7 +149,7 @@ int main(int argc, char **argv){
149 return_code=STATE_WARNING; 149 return_code=STATE_WARNING;
150 150
151 asprintf(&output_message," (%lu min. %lu%)",lvalue_list[0+offset], utilization); 151 asprintf(&output_message," (%lu min. %lu%)",lvalue_list[0+offset], utilization);
152 asprintf(&temp_string,"%s%s",temp_string,output_message); 152 temp_string = strscat(temp_string,output_message);
153 offset+=3; //move accross the array 153 offset+=3; //move accross the array
154 } 154 }
155 if (strlen(temp_string)>10) { 155 if (strlen(temp_string)>10) {
@@ -157,18 +157,18 @@ int main(int argc, char **argv){
157 asprintf(&output_message,"%s",temp_string); 157 asprintf(&output_message,"%s",temp_string);
158 } 158 }
159 else 159 else
160 asprintf(&output_message,"%s","not enough values for -l parameters"); 160 output_message = strscpy(output_message,"not enough values for -l parameters");
161 161
162 } else 162 } else
163 asprintf(&output_message,"wrong -l parameter."); 163 output_message = strscpy(output_message,"wrong -l parameter.");
164 164
165 } else 165 } else
166 asprintf(&output_message,"missing -l parameters"); 166 output_message = strscpy(output_message,"missing -l parameters");
167 } 167 }
168 168
169 else if(vars_to_check==CHECK_UPTIME){ 169 else if(vars_to_check==CHECK_UPTIME){
170 170
171 asprintf(&send_buffer,strcat(req_password,"&3")); 171 send_buffer = strscpy(send_buffer,strcat(req_password,"&3"));
172 result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); 172 result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer));
173 if(result!=STATE_OK) 173 if(result!=STATE_OK)
174 return result; 174 return result;
@@ -227,9 +227,9 @@ int main(int argc, char **argv){
227 } 227 }
228 } 228 }
229 else 229 else
230 asprintf(&output_message,"wrong -l argument"); 230 output_message = strscpy(output_message,"wrong -l argument");
231 } else 231 } else
232 asprintf(&output_message,"missing -l parameters"); 232 output_message = strscpy(output_message,"missing -l parameters");
233 233
234 } 234 }
235 235
@@ -252,7 +252,7 @@ int main(int argc, char **argv){
252 asprintf(&output_message, "%s",temp_string); 252 asprintf(&output_message, "%s",temp_string);
253 } 253 }
254 else 254 else
255 asprintf(&output_message,"No service/process specified"); 255 output_message = strscpy(output_message,"No service/process specified");
256 } 256 }
257 257
258 else if(vars_to_check==CHECK_MEMUSE) { 258 else if(vars_to_check==CHECK_MEMUSE) {
@@ -326,7 +326,7 @@ int main(int argc, char **argv){
326 326
327 } 327 }
328 else { 328 else {
329 asprintf(&output_message,"No counter specified"); 329 output_message = strscpy(output_message,"No counter specified");
330 result=STATE_UNKNOWN; 330 result=STATE_UNKNOWN;
331 } 331 }
332 } 332 }
@@ -369,7 +369,7 @@ int main(int argc, char **argv){
369 369
370 } 370 }
371 else { 371 else {
372 asprintf(&output_message,"No file specified"); 372 output_message = strscpy(output_message,"No file specified");
373 result=STATE_UNKNOWN; 373 result=STATE_UNKNOWN;
374 } 374 }
375 } 375 }
@@ -449,7 +449,7 @@ int process_arguments(int argc, char **argv){
449 server_address=optarg; 449 server_address=optarg;
450 break; 450 break;
451 case 's': /* password */ 451 case 's': /* password */
452 asprintf(&req_password,optarg); 452 req_password=strscpy(req_password,optarg);
453 break; 453 break;
454 case 'p': /* port */ 454 case 'p': /* port */
455 if (is_intnonneg(optarg)) 455 if (is_intnonneg(optarg))
@@ -482,7 +482,7 @@ int process_arguments(int argc, char **argv){
482 return ERROR; 482 return ERROR;
483 break; 483 break;
484 case 'l': /* value list */ 484 case 'l': /* value list */
485 asprintf(&value_list,optarg); 485 value_list=strscpy(value_list,optarg);
486 check_value_list=TRUE; 486 check_value_list=TRUE;
487 break; 487 break;
488 case 'w': /* warning threshold */ 488 case 'w': /* warning threshold */