summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTon Voon <tonvoon@users.sourceforge.net>2005-07-11 22:15:58 +0000
committerTon Voon <tonvoon@users.sourceforge.net>2005-07-11 22:15:58 +0000
commit129692ff6a6f601a3810d1dbe334fc25f413243d (patch)
tree34e7f680e6809666c5df939e273583fb475037b4
parentdd5249ed157af927457816c5aa79f8300506c723 (diff)
downloadmonitoring-plugins-129692ff6a6f601a3810d1dbe334fc25f413243d.tar.gz
Miscelleneous bug fixes (Gerd Mueller - 1235879)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1204 f882894a-f735-0410-b71e-b25c423dba1c
-rw-r--r--plugins/check_nwstat.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/plugins/check_nwstat.c b/plugins/check_nwstat.c
index 601b25d3..9f17a7dd 100644
--- a/plugins/check_nwstat.c
+++ b/plugins/check_nwstat.c
@@ -169,6 +169,10 @@ main(int argc, char **argv) {
169 if (result!=STATE_OK) 169 if (result!=STATE_OK)
170 return result; 170 return result;
171 utilization=strtoul(recv_buffer,NULL,10); 171 utilization=strtoul(recv_buffer,NULL,10);
172
173 close(sd);
174 my_tcp_connect (server_address, server_port, &sd);
175
172 send_buffer = strdup ("UPTIME\r\n"); 176 send_buffer = strdup ("UPTIME\r\n");
173 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 177 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
174 if (result!=STATE_OK) 178 if (result!=STATE_OK)
@@ -325,20 +329,24 @@ main(int argc, char **argv) {
325 329
326 free_disk_space=strtoul(recv_buffer,NULL,10); 330 free_disk_space=strtoul(recv_buffer,NULL,10);
327 331
332 close(sd);
333 my_tcp_connect (server_address, server_port, &sd);
334
328 asprintf (&send_buffer,"VKS%s\r\n",volume_name); 335 asprintf (&send_buffer,"VKS%s\r\n",volume_name);
329 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 336 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
330 if (result!=STATE_OK) 337 if (result!=STATE_OK)
331 return result; 338 return result;
332 total_disk_space=strtoul(recv_buffer,NULL,10); 339 total_disk_space=strtoul(recv_buffer,NULL,10);
333 340
334 percent_free_space=(int)(((double)free_disk_space/(double)total_disk_space)*100.0); 341 percent_free_space=(unsigned long)(((double)free_disk_space/(double)total_disk_space)*100.0);
335 342
336 if (check_critical_value==TRUE && percent_free_space <= critical_value) 343 if (check_critical_value==TRUE && percent_free_space <= critical_value)
337 result=STATE_CRITICAL; 344 result=STATE_CRITICAL;
338 else if (check_warning_value==TRUE && percent_free_space <= warning_value) 345 else if (check_warning_value==TRUE && percent_free_space <= warning_value)
339 result=STATE_WARNING; 346 result=STATE_WARNING;
340 free_disk_space/=1024; 347 free_disk_space/=1024;
341 asprintf (&output_message,_("%lu MB (%lu%%) free on volume %s"),free_disk_space,percent_free_space,volume_name); 348 total_disk_space/=1024;
349 asprintf (&output_message,_("%lu MB (%lu%%) free on volume %s - total %lu MB"),free_disk_space,percent_free_space,volume_name,total_disk_space);
342 } 350 }
343 351
344 /* check to see if DS Database is open or closed */ 352 /* check to see if DS Database is open or closed */
@@ -353,6 +361,9 @@ main(int argc, char **argv) {
353 else 361 else
354 result=STATE_WARNING; 362 result=STATE_WARNING;
355 363
364 close(sd);
365 my_tcp_connect (server_address, server_port, &sd);
366
356 send_buffer = strdup ("S13\r\n"); 367 send_buffer = strdup ("S13\r\n");
357 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 368 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
358 temp_buffer=strtok(recv_buffer,"\r\n"); 369 temp_buffer=strtok(recv_buffer,"\r\n");
@@ -472,7 +483,7 @@ main(int argc, char **argv) {
472 return result; 483 return result;
473 total_disk_space=strtoul(recv_buffer,NULL,10); 484 total_disk_space=strtoul(recv_buffer,NULL,10);
474 485
475 percent_purgeable_space=(int)(((double)purgeable_disk_space/(double)total_disk_space)*100.0); 486 percent_purgeable_space=(unsigned long)(((double)purgeable_disk_space/(double)total_disk_space)*100.0);
476 487
477 if (check_critical_value==TRUE && percent_purgeable_space >= critical_value) 488 if (check_critical_value==TRUE && percent_purgeable_space >= critical_value)
478 result=STATE_CRITICAL; 489 result=STATE_CRITICAL;
@@ -525,7 +536,7 @@ main(int argc, char **argv) {
525 return result; 536 return result;
526 total_disk_space=strtoul(recv_buffer,NULL,10); 537 total_disk_space=strtoul(recv_buffer,NULL,10);
527 538
528 percent_non_purgeable_space=(int)(((double)non_purgeable_disk_space/(double)total_disk_space)*100.0); 539 percent_non_purgeable_space=(unsigned long)(((double)non_purgeable_disk_space/(double)total_disk_space)*100.0);
529 540
530 if (check_critical_value==TRUE && percent_non_purgeable_space >= critical_value) 541 if (check_critical_value==TRUE && percent_non_purgeable_space >= critical_value)
531 result=STATE_CRITICAL; 542 result=STATE_CRITICAL;
@@ -579,6 +590,9 @@ main(int argc, char **argv) {
579 590
580 max_service_processes=atoi(recv_buffer); 591 max_service_processes=atoi(recv_buffer);
581 592
593 close(sd);
594 my_tcp_connect (server_address, server_port, &sd);
595
582 asprintf (&send_buffer,"S21\r\n"); 596 asprintf (&send_buffer,"S21\r\n");
583 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 597 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
584 if (result!=STATE_OK) 598 if (result!=STATE_OK)
@@ -671,12 +685,15 @@ main(int argc, char **argv) {
671 asprintf (&output_message,_("NDS Version %s"),recv_buffer); 685 asprintf (&output_message,_("NDS Version %s"),recv_buffer);
672 686
673 } else if (vars_to_check==UPTIME) { 687 } else if (vars_to_check==UPTIME) {
688 asprintf (&send_buffer,"UPTIME\r\n");
674 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer)); 689 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
675 if (result!=STATE_OK) 690 if (result!=STATE_OK)
676 return result; 691 return result;
677 692
678 recv_buffer[strlen(recv_buffer)-1]=0;
679 693
694 recv_buffer[sizeof(recv_buffer)-1]=0;
695 recv_buffer[strlen(recv_buffer)-1]=0;
696
680 asprintf (&output_message,_("Up %s"),recv_buffer); 697 asprintf (&output_message,_("Up %s"),recv_buffer);
681 698
682 } else if (vars_to_check==NLM) { 699 } else if (vars_to_check==NLM) {
@@ -865,8 +882,9 @@ int process_arguments(int argc, char **argv) {
865 vars_to_check=TSYNC; 882 vars_to_check=TSYNC;
866 else if (!strcmp(optarg,"DSVER")) 883 else if (!strcmp(optarg,"DSVER"))
867 vars_to_check=DSVER; 884 vars_to_check=DSVER;
868 else if (!strcmp(optarg,"UPTIME")) 885 else if (!strcmp(optarg,"UPTIME")) {
869 vars_to_check=UPTIME; 886 vars_to_check=UPTIME;
887 }
870 else if (strncmp(optarg,"NLM:",4)==0) { 888 else if (strncmp(optarg,"NLM:",4)==0) {
871 vars_to_check=NLM; 889 vars_to_check=NLM;
872 nlm_name=strdup (optarg+4); 890 nlm_name=strdup (optarg+4);