diff options
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2004-02-29 04:09:34 (GMT) |
---|---|---|
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2004-02-29 04:09:34 (GMT) |
commit | dc8f5c0f658b5e060fc17a4beb4a0a2b195ba470 (patch) | |
tree | d8239d5c49ddce04fbc661046e2c5670b65feb60 /plugins/check_nwstat.c | |
parent | 5316da0b8d35823ce52bed41487292bcfff1a0b2 (diff) | |
download | monitoring-plugins-dc8f5c0f658b5e060fc17a4beb4a0a2b195ba470.tar.gz |
was making up to 34 separate tcp connections - now we open one and reuse
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@831 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_nwstat.c')
-rw-r--r-- | plugins/check_nwstat.c | 76 |
1 files changed, 41 insertions, 35 deletions
diff --git a/plugins/check_nwstat.c b/plugins/check_nwstat.c index 4ceb58f..dc8ce21 100644 --- a/plugins/check_nwstat.c +++ b/plugins/check_nwstat.c | |||
@@ -86,6 +86,7 @@ void print_usage(void); | |||
86 | int | 86 | int |
87 | main(int argc, char **argv) { | 87 | main(int argc, char **argv) { |
88 | int result; | 88 | int result; |
89 | int sd; | ||
89 | char *send_buffer=NULL; | 90 | char *send_buffer=NULL; |
90 | char recv_buffer[MAX_INPUT_BUFFER]; | 91 | char recv_buffer[MAX_INPUT_BUFFER]; |
91 | char *output_message=NULL; | 92 | char *output_message=NULL; |
@@ -129,11 +130,14 @@ main(int argc, char **argv) { | |||
129 | 130 | ||
130 | /* set socket timeout */ | 131 | /* set socket timeout */ |
131 | alarm(socket_timeout); | 132 | alarm(socket_timeout); |
132 | 133 | ||
134 | /* open connection */ | ||
135 | my_tcp_connect (server_address, server_port, &sd); | ||
136 | |||
133 | /* get OS version string */ | 137 | /* get OS version string */ |
134 | if (check_netware_version==TRUE) { | 138 | if (check_netware_version==TRUE) { |
135 | send_buffer = strdup ("S19\r\n"); | 139 | send_buffer = strdup ("S19\r\n"); |
136 | result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); | 140 | result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); |
137 | if (result!=STATE_OK) | 141 | if (result!=STATE_OK) |
138 | return result; | 142 | return result; |
139 | if (!strcmp(recv_buffer,"-1\n")) | 143 | if (!strcmp(recv_buffer,"-1\n")) |
@@ -162,12 +166,12 @@ main(int argc, char **argv) { | |||
162 | } | 166 | } |
163 | 167 | ||
164 | asprintf (&send_buffer,"UTIL%s\r\n",temp_buffer); | 168 | asprintf (&send_buffer,"UTIL%s\r\n",temp_buffer); |
165 | result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); | 169 | result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); |
166 | if (result!=STATE_OK) | 170 | if (result!=STATE_OK) |
167 | return result; | 171 | return result; |
168 | utilization=strtoul(recv_buffer,NULL,10); | 172 | utilization=strtoul(recv_buffer,NULL,10); |
169 | send_buffer = strdup ("UPTIME\r\n"); | 173 | send_buffer = strdup ("UPTIME\r\n"); |
170 | result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); | 174 | result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); |
171 | if (result!=STATE_OK) | 175 | if (result!=STATE_OK) |
172 | return result; | 176 | return result; |
173 | recv_buffer[strlen(recv_buffer)-1]=0; | 177 | recv_buffer[strlen(recv_buffer)-1]=0; |
@@ -189,7 +193,7 @@ main(int argc, char **argv) { | |||
189 | } else if (vars_to_check==CONNS) { | 193 | } else if (vars_to_check==CONNS) { |
190 | 194 | ||
191 | send_buffer = strdup ("CONNECT\r\n"); | 195 | send_buffer = strdup ("CONNECT\r\n"); |
192 | result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); | 196 | result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); |
193 | if (result!=STATE_OK) | 197 | if (result!=STATE_OK) |
194 | return result; | 198 | return result; |
195 | current_connections=strtoul(recv_buffer,NULL,10); | 199 | current_connections=strtoul(recv_buffer,NULL,10); |
@@ -208,7 +212,7 @@ main(int argc, char **argv) { | |||
208 | } else if (vars_to_check==LTCH) { | 212 | } else if (vars_to_check==LTCH) { |
209 | 213 | ||
210 | send_buffer = strdup ("S1\r\n"); | 214 | send_buffer = strdup ("S1\r\n"); |
211 | result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); | 215 | result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); |
212 | if (result!=STATE_OK) | 216 | if (result!=STATE_OK) |
213 | return result; | 217 | return result; |
214 | cache_hits=atoi(recv_buffer); | 218 | cache_hits=atoi(recv_buffer); |
@@ -227,7 +231,7 @@ main(int argc, char **argv) { | |||
227 | } else if (vars_to_check==CBUFF) { | 231 | } else if (vars_to_check==CBUFF) { |
228 | 232 | ||
229 | send_buffer = strdup ("S2\r\n"); | 233 | send_buffer = strdup ("S2\r\n"); |
230 | result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); | 234 | result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); |
231 | if (result!=STATE_OK) | 235 | if (result!=STATE_OK) |
232 | return result; | 236 | return result; |
233 | cache_buffers=strtoul(recv_buffer,NULL,10); | 237 | cache_buffers=strtoul(recv_buffer,NULL,10); |
@@ -246,7 +250,7 @@ main(int argc, char **argv) { | |||
246 | } else if (vars_to_check==CDBUFF) { | 250 | } else if (vars_to_check==CDBUFF) { |
247 | 251 | ||
248 | send_buffer = strdup ("S3\r\n"); | 252 | send_buffer = strdup ("S3\r\n"); |
249 | result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); | 253 | result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); |
250 | if (result!=STATE_OK) | 254 | if (result!=STATE_OK) |
251 | return result; | 255 | return result; |
252 | cache_buffers=strtoul(recv_buffer,NULL,10); | 256 | cache_buffers=strtoul(recv_buffer,NULL,10); |
@@ -265,7 +269,7 @@ main(int argc, char **argv) { | |||
265 | } else if (vars_to_check==LRUM) { | 269 | } else if (vars_to_check==LRUM) { |
266 | 270 | ||
267 | send_buffer = strdup ("S5\r\n"); | 271 | send_buffer = strdup ("S5\r\n"); |
268 | result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); | 272 | result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); |
269 | if (result!=STATE_OK) | 273 | if (result!=STATE_OK) |
270 | return result; | 274 | return result; |
271 | lru_time=strtoul(recv_buffer,NULL,10); | 275 | lru_time=strtoul(recv_buffer,NULL,10); |
@@ -285,7 +289,7 @@ main(int argc, char **argv) { | |||
285 | } else if (vars_to_check==VKF) { | 289 | } else if (vars_to_check==VKF) { |
286 | 290 | ||
287 | asprintf (&send_buffer,"VKF%s\r\n",volume_name); | 291 | asprintf (&send_buffer,"VKF%s\r\n",volume_name); |
288 | result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); | 292 | result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); |
289 | if (result!=STATE_OK) | 293 | if (result!=STATE_OK) |
290 | return result; | 294 | return result; |
291 | 295 | ||
@@ -309,7 +313,7 @@ main(int argc, char **argv) { | |||
309 | } else if (vars_to_check==VPF) { | 313 | } else if (vars_to_check==VPF) { |
310 | 314 | ||
311 | asprintf (&send_buffer,"VKF%s\r\n",volume_name); | 315 | asprintf (&send_buffer,"VKF%s\r\n",volume_name); |
312 | result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); | 316 | result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); |
313 | if (result!=STATE_OK) | 317 | if (result!=STATE_OK) |
314 | return result; | 318 | return result; |
315 | 319 | ||
@@ -323,7 +327,7 @@ main(int argc, char **argv) { | |||
323 | free_disk_space=strtoul(recv_buffer,NULL,10); | 327 | free_disk_space=strtoul(recv_buffer,NULL,10); |
324 | 328 | ||
325 | asprintf (&send_buffer,"VKS%s\r\n",volume_name); | 329 | asprintf (&send_buffer,"VKS%s\r\n",volume_name); |
326 | result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); | 330 | result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); |
327 | if (result!=STATE_OK) | 331 | if (result!=STATE_OK) |
328 | return result; | 332 | return result; |
329 | total_disk_space=strtoul(recv_buffer,NULL,10); | 333 | total_disk_space=strtoul(recv_buffer,NULL,10); |
@@ -342,7 +346,7 @@ main(int argc, char **argv) { | |||
342 | } else if (vars_to_check==DSDB) { | 346 | } else if (vars_to_check==DSDB) { |
343 | 347 | ||
344 | send_buffer = strdup ("S11\r\n"); | 348 | send_buffer = strdup ("S11\r\n"); |
345 | result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); | 349 | result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); |
346 | if (result!=STATE_OK) | 350 | if (result!=STATE_OK) |
347 | return result; | 351 | return result; |
348 | if (atoi(recv_buffer)==1) | 352 | if (atoi(recv_buffer)==1) |
@@ -351,7 +355,7 @@ main(int argc, char **argv) { | |||
351 | result=STATE_WARNING; | 355 | result=STATE_WARNING; |
352 | 356 | ||
353 | send_buffer = strdup ("S13\r\n"); | 357 | send_buffer = strdup ("S13\r\n"); |
354 | result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); | 358 | result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); |
355 | temp_buffer=strtok(recv_buffer,"\r\n"); | 359 | temp_buffer=strtok(recv_buffer,"\r\n"); |
356 | 360 | ||
357 | asprintf (&output_message,_("Directory Services Database is %s (DS version %s)"),(result==STATE_OK)?"open":"closed",temp_buffer); | 361 | asprintf (&output_message,_("Directory Services Database is %s (DS version %s)"),(result==STATE_OK)?"open":"closed",temp_buffer); |
@@ -360,7 +364,7 @@ main(int argc, char **argv) { | |||
360 | } else if (vars_to_check==LOGINS) { | 364 | } else if (vars_to_check==LOGINS) { |
361 | 365 | ||
362 | send_buffer = strdup ("S12\r\n"); | 366 | send_buffer = strdup ("S12\r\n"); |
363 | result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); | 367 | result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); |
364 | if (result!=STATE_OK) | 368 | if (result!=STATE_OK) |
365 | return result; | 369 | return result; |
366 | if (atoi(recv_buffer)==1) | 370 | if (atoi(recv_buffer)==1) |
@@ -374,14 +378,14 @@ main(int argc, char **argv) { | |||
374 | } else if (vars_to_check==UPRB || vars_to_check==PUPRB) { | 378 | } else if (vars_to_check==UPRB || vars_to_check==PUPRB) { |
375 | 379 | ||
376 | asprintf (&send_buffer,"S15\r\n"); | 380 | asprintf (&send_buffer,"S15\r\n"); |
377 | result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); | 381 | result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); |
378 | if (result!=STATE_OK) | 382 | if (result!=STATE_OK) |
379 | return result; | 383 | return result; |
380 | 384 | ||
381 | used_packet_receive_buffers=atoi(recv_buffer); | 385 | used_packet_receive_buffers=atoi(recv_buffer); |
382 | 386 | ||
383 | asprintf (&send_buffer,"S16\r\n"); | 387 | asprintf (&send_buffer,"S16\r\n"); |
384 | result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); | 388 | result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); |
385 | if (result!=STATE_OK) | 389 | if (result!=STATE_OK) |
386 | return result; | 390 | return result; |
387 | 391 | ||
@@ -410,7 +414,7 @@ main(int argc, char **argv) { | |||
410 | asprintf (&send_buffer,"S9\r\n"); | 414 | asprintf (&send_buffer,"S9\r\n"); |
411 | else | 415 | else |
412 | asprintf (&send_buffer,"S9.%d\r\n",sap_number); | 416 | asprintf (&send_buffer,"S9.%d\r\n",sap_number); |
413 | result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); | 417 | result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); |
414 | if (result!=STATE_OK) | 418 | if (result!=STATE_OK) |
415 | return result; | 419 | return result; |
416 | 420 | ||
@@ -430,7 +434,7 @@ main(int argc, char **argv) { | |||
430 | } else if (vars_to_check==VKP) { | 434 | } else if (vars_to_check==VKP) { |
431 | 435 | ||
432 | asprintf (&send_buffer,"VKP%s\r\n",volume_name); | 436 | asprintf (&send_buffer,"VKP%s\r\n",volume_name); |
433 | result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); | 437 | result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); |
434 | if (result!=STATE_OK) | 438 | if (result!=STATE_OK) |
435 | return result; | 439 | return result; |
436 | 440 | ||
@@ -450,7 +454,7 @@ main(int argc, char **argv) { | |||
450 | } else if (vars_to_check==VPP) { | 454 | } else if (vars_to_check==VPP) { |
451 | 455 | ||
452 | asprintf (&send_buffer,"VKP%s\r\n",volume_name); | 456 | asprintf (&send_buffer,"VKP%s\r\n",volume_name); |
453 | result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); | 457 | result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); |
454 | if (result!=STATE_OK) | 458 | if (result!=STATE_OK) |
455 | return result; | 459 | return result; |
456 | 460 | ||
@@ -464,7 +468,7 @@ main(int argc, char **argv) { | |||
464 | purgeable_disk_space=strtoul(recv_buffer,NULL,10); | 468 | purgeable_disk_space=strtoul(recv_buffer,NULL,10); |
465 | 469 | ||
466 | asprintf (&send_buffer,"VKS%s\r\n",volume_name); | 470 | asprintf (&send_buffer,"VKS%s\r\n",volume_name); |
467 | result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); | 471 | result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); |
468 | if (result!=STATE_OK) | 472 | if (result!=STATE_OK) |
469 | return result; | 473 | return result; |
470 | total_disk_space=strtoul(recv_buffer,NULL,10); | 474 | total_disk_space=strtoul(recv_buffer,NULL,10); |
@@ -483,7 +487,7 @@ main(int argc, char **argv) { | |||
483 | } else if (vars_to_check==VKNP) { | 487 | } else if (vars_to_check==VKNP) { |
484 | 488 | ||
485 | asprintf (&send_buffer,"VKNP%s\r\n",volume_name); | 489 | asprintf (&send_buffer,"VKNP%s\r\n",volume_name); |
486 | result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); | 490 | result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); |
487 | if (result!=STATE_OK) | 491 | if (result!=STATE_OK) |
488 | return result; | 492 | return result; |
489 | 493 | ||
@@ -503,7 +507,7 @@ main(int argc, char **argv) { | |||
503 | } else if (vars_to_check==VPNP) { | 507 | } else if (vars_to_check==VPNP) { |
504 | 508 | ||
505 | asprintf (&send_buffer,"VKNP%s\r\n",volume_name); | 509 | asprintf (&send_buffer,"VKNP%s\r\n",volume_name); |
506 | result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); | 510 | result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); |
507 | if (result!=STATE_OK) | 511 | if (result!=STATE_OK) |
508 | return result; | 512 | return result; |
509 | 513 | ||
@@ -517,7 +521,7 @@ main(int argc, char **argv) { | |||
517 | non_purgeable_disk_space=strtoul(recv_buffer,NULL,10); | 521 | non_purgeable_disk_space=strtoul(recv_buffer,NULL,10); |
518 | 522 | ||
519 | asprintf (&send_buffer,"VKS%s\r\n",volume_name); | 523 | asprintf (&send_buffer,"VKS%s\r\n",volume_name); |
520 | result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); | 524 | result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); |
521 | if (result!=STATE_OK) | 525 | if (result!=STATE_OK) |
522 | return result; | 526 | return result; |
523 | total_disk_space=strtoul(recv_buffer,NULL,10); | 527 | total_disk_space=strtoul(recv_buffer,NULL,10); |
@@ -536,7 +540,7 @@ main(int argc, char **argv) { | |||
536 | } else if (vars_to_check==OFILES) { | 540 | } else if (vars_to_check==OFILES) { |
537 | 541 | ||
538 | asprintf (&send_buffer,"S18\r\n"); | 542 | asprintf (&send_buffer,"S18\r\n"); |
539 | result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); | 543 | result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); |
540 | if (result!=STATE_OK) | 544 | if (result!=STATE_OK) |
541 | return result; | 545 | return result; |
542 | 546 | ||
@@ -553,7 +557,7 @@ main(int argc, char **argv) { | |||
553 | } else if (vars_to_check==ABENDS) { | 557 | } else if (vars_to_check==ABENDS) { |
554 | 558 | ||
555 | asprintf (&send_buffer,"S17\r\n"); | 559 | asprintf (&send_buffer,"S17\r\n"); |
556 | result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); | 560 | result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); |
557 | if (result!=STATE_OK) | 561 | if (result!=STATE_OK) |
558 | return result; | 562 | return result; |
559 | 563 | ||
@@ -570,14 +574,14 @@ main(int argc, char **argv) { | |||
570 | } else if (vars_to_check==CSPROCS) { | 574 | } else if (vars_to_check==CSPROCS) { |
571 | 575 | ||
572 | asprintf (&send_buffer,"S20\r\n"); | 576 | asprintf (&send_buffer,"S20\r\n"); |
573 | result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); | 577 | result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); |
574 | if (result!=STATE_OK) | 578 | if (result!=STATE_OK) |
575 | return result; | 579 | return result; |
576 | 580 | ||
577 | max_service_processes=atoi(recv_buffer); | 581 | max_service_processes=atoi(recv_buffer); |
578 | 582 | ||
579 | asprintf (&send_buffer,"S21\r\n"); | 583 | asprintf (&send_buffer,"S21\r\n"); |
580 | result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); | 584 | result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); |
581 | if (result!=STATE_OK) | 585 | if (result!=STATE_OK) |
582 | return result; | 586 | return result; |
583 | 587 | ||
@@ -597,7 +601,7 @@ main(int argc, char **argv) { | |||
597 | } else if (vars_to_check==TSYNC) { | 601 | } else if (vars_to_check==TSYNC) { |
598 | 602 | ||
599 | asprintf (&send_buffer,"S22\r\n"); | 603 | asprintf (&send_buffer,"S22\r\n"); |
600 | result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); | 604 | result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); |
601 | if (result!=STATE_OK) | 605 | if (result!=STATE_OK) |
602 | return result; | 606 | return result; |
603 | 607 | ||
@@ -615,7 +619,7 @@ main(int argc, char **argv) { | |||
615 | } else if (vars_to_check==LRUS) { | 619 | } else if (vars_to_check==LRUS) { |
616 | 620 | ||
617 | send_buffer = strdup ("S4\r\n"); | 621 | send_buffer = strdup ("S4\r\n"); |
618 | result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); | 622 | result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); |
619 | if (result!=STATE_OK) | 623 | if (result!=STATE_OK) |
620 | return result; | 624 | return result; |
621 | lru_time=strtoul(recv_buffer,NULL,10); | 625 | lru_time=strtoul(recv_buffer,NULL,10); |
@@ -631,7 +635,7 @@ main(int argc, char **argv) { | |||
631 | } else if (vars_to_check==DCB) { | 635 | } else if (vars_to_check==DCB) { |
632 | 636 | ||
633 | send_buffer = strdup ("S6\r\n"); | 637 | send_buffer = strdup ("S6\r\n"); |
634 | result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); | 638 | result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); |
635 | if (result!=STATE_OK) | 639 | if (result!=STATE_OK) |
636 | return result; | 640 | return result; |
637 | dirty_cache_buffers=atoi(recv_buffer); | 641 | dirty_cache_buffers=atoi(recv_buffer); |
@@ -646,7 +650,7 @@ main(int argc, char **argv) { | |||
646 | } else if (vars_to_check==TCB) { | 650 | } else if (vars_to_check==TCB) { |
647 | 651 | ||
648 | send_buffer = strdup ("S7\r\n"); | 652 | send_buffer = strdup ("S7\r\n"); |
649 | result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); | 653 | result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); |
650 | if (result!=STATE_OK) | 654 | if (result!=STATE_OK) |
651 | return result; | 655 | return result; |
652 | total_cache_buffers=atoi(recv_buffer); | 656 | total_cache_buffers=atoi(recv_buffer); |
@@ -659,7 +663,7 @@ main(int argc, char **argv) { | |||
659 | 663 | ||
660 | } else if (vars_to_check==DSVER) { | 664 | } else if (vars_to_check==DSVER) { |
661 | asprintf (&send_buffer,"S13\r\n"); | 665 | asprintf (&send_buffer,"S13\r\n"); |
662 | result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); | 666 | result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); |
663 | if (result!=STATE_OK) | 667 | if (result!=STATE_OK) |
664 | return result; | 668 | return result; |
665 | 669 | ||
@@ -668,7 +672,7 @@ main(int argc, char **argv) { | |||
668 | asprintf (&output_message,_("NDS Version %s"),recv_buffer); | 672 | asprintf (&output_message,_("NDS Version %s"),recv_buffer); |
669 | 673 | ||
670 | } else if (vars_to_check==UPTIME) { | 674 | } else if (vars_to_check==UPTIME) { |
671 | result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); | 675 | result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); |
672 | if (result!=STATE_OK) | 676 | if (result!=STATE_OK) |
673 | return result; | 677 | return result; |
674 | 678 | ||
@@ -678,7 +682,7 @@ main(int argc, char **argv) { | |||
678 | 682 | ||
679 | } else if (vars_to_check==NLM) { | 683 | } else if (vars_to_check==NLM) { |
680 | asprintf (&send_buffer,"S24:%s\r\n",nlm_name); | 684 | asprintf (&send_buffer,"S24:%s\r\n",nlm_name); |
681 | result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); | 685 | result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); |
682 | if (result!=STATE_OK) | 686 | if (result!=STATE_OK) |
683 | return result; | 687 | return result; |
684 | 688 | ||
@@ -697,6 +701,8 @@ main(int argc, char **argv) { | |||
697 | 701 | ||
698 | } | 702 | } |
699 | 703 | ||
704 | close (sd); | ||
705 | |||
700 | /* reset timeout */ | 706 | /* reset timeout */ |
701 | alarm(0); | 707 | alarm(0); |
702 | 708 | ||