ports/128220: [patch] net-mgmt/nagios-plugins Exception in check_nt.c
olli hauer
ohauer at gmx.de
Sun Oct 19 13:30:03 UTC 2008
>Number: 128220
>Category: ports
>Synopsis: [patch] net-mgmt/nagios-plugins Exception in check_nt.c
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Sun Oct 19 13:30:02 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator: olli hauer
>Release:
>Organization:
>Environment:
>Description:
routine CHECK_USEDDISKSPACE in check_nt.c do not handle correct unknown/missing drives.
# /usr/local/libexec/nagios/check_nt -H HOSTNAME -p 12489 -v USEDDISKSPACE -l d
Segmentation fault: 11 (core dumped)
# /usr/local/libexec/nagios/check_nt -H HOSTNAME -p 12489 -v USEDDISKSPACE -l e
Segmentation fault: 11 (core dumped)
# echo "None&4&d" | nc HOSTNAME 12489
UNKNOWN: Drive is not a fixed drive: d: (it is a cdrom drive)
# echo "None&4&e" | nc HOSTNAME 12489
UNKNOWN: Could not get free space for: e: e: reason: 3: The system cannot find the path specified.
# echo "None&4&c" | nc HOSTNAME 12489
7506677760&12872527872
#################################
snipped from the code:
#################################
case CHECK_USEDDISKSPACE:
fetch_data (server_address, server_port, send_buffer);
/* --> no further checks, blind trust and death (no exception handling) */
free_disk_space=atof(strtok(recv_buffer,"&"));
total_disk_space=atof(strtok(NULL,"&"));
>How-To-Repeat:
query a window machine which has installed NSClient++ for not existing drives
>Fix:
Patch attached with submission follows:
--- plugins/check_nt.c.orig 2008-10-19 14:39:43.000000000 +0200
+++ plugins/check_nt.c 2008-10-19 14:47:19.000000000 +0200
@@ -97,6 +97,8 @@
char *temp_string_perf=NULL;
char *description=NULL,*counter_unit = NULL;
char *minval = NULL, *maxval = NULL, *errcvt = NULL;
+ char *fds=NULL;
+ char *tds=NULL;
double total_disk_space=0;
double free_disk_space=0;
@@ -218,33 +220,41 @@
else {
asprintf(&send_buffer,"%s&4&%s", req_password, value_list);
fetch_data (server_address, server_port, send_buffer);
- free_disk_space=atof(strtok(recv_buffer,"&"));
- total_disk_space=atof(strtok(NULL,"&"));
- percent_used_space = ((total_disk_space - free_disk_space) / total_disk_space) * 100;
- warning_used_space = ((float)warning_value / 100) * total_disk_space;
- critical_used_space = ((float)critical_value / 100) * total_disk_space;
-
- if (free_disk_space>=0) {
- asprintf(&temp_string,_("%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)"),
- value_list, total_disk_space / 1073741824, (total_disk_space - free_disk_space) / 1073741824,
- percent_used_space, free_disk_space / 1073741824, (free_disk_space / total_disk_space)*100);
- asprintf(&temp_string_perf,_("'%s:\\ Used Space'=%.2fGb;%.2f;%.2f;0.00;%.2f"), value_list,
- (total_disk_space - free_disk_space) / 1073741824, warning_used_space / 1073741824,
- critical_used_space / 1073741824, total_disk_space / 1073741824);
+ fds=strtok(recv_buffer,"&");
+ tds=strtok(NULL,"&");
- if(check_critical_value==TRUE && percent_used_space >= critical_value)
- return_code=STATE_CRITICAL;
- else if (check_warning_value==TRUE && percent_used_space >= warning_value)
- return_code=STATE_WARNING;
- else
- return_code=STATE_OK;
-
- output_message = strdup (temp_string);
- perfdata = temp_string_perf;
+ if (fds != NULL)
+ free_disk_space=atof(fds);
+ if (tds != NULL)
+ total_disk_space=atof(tds);
+
+ if (total_disk_space>0) {
+ percent_used_space = ((total_disk_space - free_disk_space) / total_disk_space) * 100;
+ warning_used_space = ((float)warning_value / 100) * total_disk_space;
+ critical_used_space = ((float)critical_value / 100) * total_disk_space;
+
+ if (free_disk_space>=0) {
+ asprintf(&temp_string,_("%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)"),
+ value_list, total_disk_space / 1073741824, (total_disk_space - free_disk_space) / 1073741824,
+ percent_used_space, free_disk_space / 1073741824, (free_disk_space / total_disk_space)*100);
+ asprintf(&temp_string_perf,_("'%s:\\ Used Space'=%.2fGb;%.2f;%.2f;0.00;%.2f"), value_list,
+ (total_disk_space - free_disk_space) / 1073741824, warning_used_space / 1073741824,
+ critical_used_space / 1073741824, total_disk_space / 1073741824);
+
+ if(check_critical_value==TRUE && percent_used_space >= critical_value)
+ return_code=STATE_CRITICAL;
+ else if (check_warning_value==TRUE && percent_used_space >= warning_value)
+ return_code=STATE_WARNING;
+ else
+ return_code=STATE_OK;
+
+ output_message = strdup (temp_string);
+ perfdata = temp_string_perf;
+ }
} else {
- output_message = strdup (_("Free disk space : Invalid drive "));
- return_code=STATE_UNKNOWN;
- }
+ output_message = strdup (_("Free disk space : Invalid drive "));
+ return_code=STATE_UNKNOWN;
+ }
}
break;
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list