summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--THANKS.in1
-rw-r--r--plugins/check_nwstat.c53
2 files changed, 54 insertions, 0 deletions
diff --git a/THANKS.in b/THANKS.in
index 0ef7d480..69b32244 100644
--- a/THANKS.in
+++ b/THANKS.in
@@ -406,6 +406,7 @@ Wolfgang Nieder
406andrew bezella 406andrew bezella
407Lorenz Gruenwald 407Lorenz Gruenwald
408John Morrissey 408John Morrissey
409Ralph Gottschalkson
409Arkadiusz Miśkiewicz 410Arkadiusz Miśkiewicz
410Björn Berg 411Björn Berg
411Franz Schwartau 412Franz Schwartau
diff --git a/plugins/check_nwstat.c b/plugins/check_nwstat.c
index 12a729e0..10c493b6 100644
--- a/plugins/check_nwstat.c
+++ b/plugins/check_nwstat.c
@@ -46,6 +46,7 @@ enum checkvar {
46 VPF, /* check % free space on volume */ 46 VPF, /* check % free space on volume */
47 VMF, /* check MB free space on volume */ 47 VMF, /* check MB free space on volume */
48 VMU, /* check MB used space on volume */ 48 VMU, /* check MB used space on volume */
49 VPU, /* check % used space on volume */
49 VMP, /* check MB purgeable space on volume */ 50 VMP, /* check MB purgeable space on volume */
50 VKF, /* check KB free space on volume */ 51 VKF, /* check KB free space on volume */
51 LTCH, /* check long-term cache hit percentage */ 52 LTCH, /* check long-term cache hit percentage */
@@ -146,6 +147,8 @@ main(int argc, char **argv) {
146 unsigned long nss6_value=0L; 147 unsigned long nss6_value=0L;
147 unsigned long nss7_value=0L; 148 unsigned long nss7_value=0L;
148 unsigned long total_disk_space=0L; 149 unsigned long total_disk_space=0L;
150 unsigned long used_disk_space=0L;
151 unsigned long percent_used_disk_space=0L;
149 unsigned long purgeable_disk_space=0L; 152 unsigned long purgeable_disk_space=0L;
150 unsigned long non_purgeable_disk_space=0L; 153 unsigned long non_purgeable_disk_space=0L;
151 unsigned long percent_free_space=0; 154 unsigned long percent_free_space=0;
@@ -452,7 +455,50 @@ main(int argc, char **argv) {
452 warning_value, 455 warning_value,
453 critical_value); 456 critical_value);
454 } 457 }
458 /* check % used space on volume */
459 } else if (vars_to_check==VPU) {
460 close(sd);
461 my_tcp_connect (server_address, server_port, &sd);
462
463 asprintf (&send_buffer,"VMU%s\r\n",volume_name);
464 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
465
466 if (result!=STATE_OK)
467 return result;
468
469 if (!strcmp(recv_buffer,"-1\n")) {
470 asprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name);
471 result=STATE_CRITICAL;
472
473 } else {
474 used_disk_space=strtoul(recv_buffer,NULL,10);
475 close(sd);
476 my_tcp_connect (server_address, server_port, &sd);
477 /* get total volume in MB */
478 asprintf (&send_buffer,"VMS%s\r\n",volume_name);
479 result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
480 if (result!=STATE_OK)
481 return result;
482 total_disk_space=strtoul(recv_buffer,NULL,10);
483 /* calculate percent used on volume */
484 percent_used_disk_space=(unsigned long)(((double)used_disk_space/(double)total_disk_space)*100.0);
455 485
486 if (check_critical_value && percent_used_disk_space >= critical_value)
487 result=STATE_CRITICAL;
488 else if (check_warning_value && percent_used_disk_space >= warning_value)
489 result=STATE_WARNING;
490
491 asprintf (&output_message,_("%lu MB (%lu%%) used on volume %s - total %lu MB|Used space in percent on %s=%lu;%lu;%lu;0;100"),
492 used_disk_space,
493 percent_used_disk_space,
494 volume_name,
495 total_disk_space,
496 volume_name,
497 percent_used_disk_space,
498 warning_value,
499 critical_value
500 );
501 }
456 502
457 /* check % free space on volume */ 503 /* check % free space on volume */
458 } else if (vars_to_check==VPF) { 504 } else if (vars_to_check==VPF) {
@@ -1450,6 +1496,12 @@ int process_arguments(int argc, char **argv) {
1450 if (!strcmp(volume_name,"")) 1496 if (!strcmp(volume_name,""))
1451 volume_name = strdup ("SYS"); 1497 volume_name = strdup ("SYS");
1452 } 1498 }
1499 else if (strncmp(optarg,"VPU",3)==0) {
1500 vars_to_check=VPU;
1501 volume_name = strdup (optarg+3);
1502 if (!strcmp(volume_name,""))
1503 volume_name = strdup ("SYS");
1504 }
1453 else if (strncmp(optarg,"VPP",3)==0) { 1505 else if (strncmp(optarg,"VPP",3)==0) {
1454 vars_to_check=VPP; 1506 vars_to_check=VPP;
1455 volume_name = strdup (optarg+3); 1507 volume_name = strdup (optarg+3);
@@ -1626,6 +1678,7 @@ void print_help(void)
1626 printf (" %s\n", _("OFILES = number of open files")); 1678 printf (" %s\n", _("OFILES = number of open files"));
1627 printf (" %s\n", _(" VMF<vol> = MB of free space on Volume <vol>")); 1679 printf (" %s\n", _(" VMF<vol> = MB of free space on Volume <vol>"));
1628 printf (" %s\n", _(" VMU<vol> = MB used space on Volume <vol>")); 1680 printf (" %s\n", _(" VMU<vol> = MB used space on Volume <vol>"));
1681 printf (" %s\n", _(" VPU<vol> = percent used space on Volume <vol>"));
1629 printf (" %s\n", _(" VMP<vol> = MB of purgeable space on Volume <vol>")); 1682 printf (" %s\n", _(" VMP<vol> = MB of purgeable space on Volume <vol>"));
1630 printf (" %s\n", _(" VPF<vol> = percent free space on volume <vol>")); 1683 printf (" %s\n", _(" VPF<vol> = percent free space on volume <vol>"));
1631 printf (" %s\n", _(" VKF<vol> = KB of free space on volume <vol>")); 1684 printf (" %s\n", _(" VKF<vol> = KB of free space on volume <vol>"));