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>
This commit is contained in:
waja 2024-03-23 11:02:18 +01:00 committed by GitHub
parent 93cd51bc62
commit 152acfabcf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 54 additions and 0 deletions

View file

@ -406,6 +406,7 @@ Wolfgang Nieder
andrew bezella
Lorenz Gruenwald
John Morrissey
Ralph Gottschalkson
Arkadiusz Miśkiewicz
Björn Berg
Franz Schwartau

View file

@ -46,6 +46,7 @@ enum checkvar {
VPF, /* check % free space on volume */
VMF, /* check MB free space on volume */
VMU, /* check MB used space on volume */
VPU, /* check % used space on volume */
VMP, /* check MB purgeable space on volume */
VKF, /* check KB free space on volume */
LTCH, /* check long-term cache hit percentage */
@ -146,6 +147,8 @@ main(int argc, char **argv) {
unsigned long nss6_value=0L;
unsigned long nss7_value=0L;
unsigned long total_disk_space=0L;
unsigned long used_disk_space=0L;
unsigned long percent_used_disk_space=0L;
unsigned long purgeable_disk_space=0L;
unsigned long non_purgeable_disk_space=0L;
unsigned long percent_free_space=0;
@ -452,7 +455,50 @@ main(int argc, char **argv) {
warning_value,
critical_value);
}
/* check % used space on volume */
} else if (vars_to_check==VPU) {
close(sd);
my_tcp_connect (server_address, server_port, &sd);
asprintf (&send_buffer,"VMU%s\r\n",volume_name);
result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
if (result!=STATE_OK)
return result;
if (!strcmp(recv_buffer,"-1\n")) {
asprintf (&output_message,_("CRITICAL - Volume '%s' does not exist!"),volume_name);
result=STATE_CRITICAL;
} else {
used_disk_space=strtoul(recv_buffer,NULL,10);
close(sd);
my_tcp_connect (server_address, server_port, &sd);
/* get total volume in MB */
asprintf (&send_buffer,"VMS%s\r\n",volume_name);
result=send_tcp_request(sd,send_buffer,recv_buffer,sizeof(recv_buffer));
if (result!=STATE_OK)
return result;
total_disk_space=strtoul(recv_buffer,NULL,10);
/* calculate percent used on volume */
percent_used_disk_space=(unsigned long)(((double)used_disk_space/(double)total_disk_space)*100.0);
if (check_critical_value && percent_used_disk_space >= critical_value)
result=STATE_CRITICAL;
else if (check_warning_value && percent_used_disk_space >= warning_value)
result=STATE_WARNING;
asprintf (&output_message,_("%lu MB (%lu%%) used on volume %s - total %lu MB|Used space in percent on %s=%lu;%lu;%lu;0;100"),
used_disk_space,
percent_used_disk_space,
volume_name,
total_disk_space,
volume_name,
percent_used_disk_space,
warning_value,
critical_value
);
}
/* check % free space on volume */
} else if (vars_to_check==VPF) {
@ -1450,6 +1496,12 @@ int process_arguments(int argc, char **argv) {
if (!strcmp(volume_name,""))
volume_name = strdup ("SYS");
}
else if (strncmp(optarg,"VPU",3)==0) {
vars_to_check=VPU;
volume_name = strdup (optarg+3);
if (!strcmp(volume_name,""))
volume_name = strdup ("SYS");
}
else if (strncmp(optarg,"VPP",3)==0) {
vars_to_check=VPP;
volume_name = strdup (optarg+3);
@ -1626,6 +1678,7 @@ void print_help(void)
printf (" %s\n", _("OFILES = number of open files"));
printf (" %s\n", _(" VMF<vol> = MB of free space on Volume <vol>"));
printf (" %s\n", _(" VMU<vol> = MB used space on Volume <vol>"));
printf (" %s\n", _(" VPU<vol> = percent used space on Volume <vol>"));
printf (" %s\n", _(" VMP<vol> = MB of purgeable space on Volume <vol>"));
printf (" %s\n", _(" VPF<vol> = percent free space on volume <vol>"));
printf (" %s\n", _(" VKF<vol> = KB of free space on volume <vol>"));