diff options
author | waja <waja@users.noreply.github.com> | 2024-03-23 10:02:18 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-23 10:02:18 (GMT) |
commit | 152acfabcf9faa3600b5ebb80a3fb569cd691ef3 (patch) | |
tree | de98ecf8a9782d16ce4de8b43132253404f4a3f6 /plugins | |
parent | 93cd51bc6221ffc846c69135f2746120683b44c5 (diff) | |
download | monitoring-plugins-152acfabcf9faa3600b5ebb80a3fb569cd691ef3.tar.gz |
check_nwstat: adds percentage used space (#1183)
* check_nwstat: adds percentage used space
This adds the new VPU parameter to the check_nwstat plugin.
This parameter returns the percentage used space on a Netware volume.
Now you can monitor your Netware volumes easy. We use it with a warning
85% and critical 90%.
eg: check_nwstat -H your.netware.host -v VPUvol1 -c 85 -w 90 returns
324653 MB (95%) used on volume vol1 - total 340212 MB|Used space in percent
on vol1=95;90;80;0;100.
* check_nwstat: Fixing whitespaces and tabs
* Update translation files
* check_nwstat: Use C99 booleans also with the patch
* Some formatting
---------
Co-authored-by: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/check_nwstat.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/plugins/check_nwstat.c b/plugins/check_nwstat.c index 12a729e..10c493b 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>")); |