From owner-freebsd-ports-bugs@FreeBSD.ORG Sun Oct 19 13:30:03 2008 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8C79C1065690 for ; Sun, 19 Oct 2008 13:30:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 5B1308FC21 for ; Sun, 19 Oct 2008 13:30:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id m9JDU3wD030645 for ; Sun, 19 Oct 2008 13:30:03 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id m9JDU3Zb030642; Sun, 19 Oct 2008 13:30:03 GMT (envelope-from gnats) Resent-Date: Sun, 19 Oct 2008 13:30:03 GMT Resent-Message-Id: <200810191330.m9JDU3Zb030642@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, olli hauer Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 072DB106564A for ; Sun, 19 Oct 2008 13:29:44 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id E9E6C8FC1D for ; Sun, 19 Oct 2008 13:29:43 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id m9JDThZj094832 for ; Sun, 19 Oct 2008 13:29:43 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id m9JDThRS094831; Sun, 19 Oct 2008 13:29:43 GMT (envelope-from nobody) Message-Id: <200810191329.m9JDThRS094831@www.freebsd.org> Date: Sun, 19 Oct 2008 13:29:43 GMT From: olli hauer To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: ports/128220: [patch] net-mgmt/nagios-plugins Exception in check_nt.c X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Oct 2008 13:30:03 -0000 >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: