[Nagiosplug-devel] [ nagiosplug-Bugs-2555775 ] nagios check_smtp expects integer instead of double

SourceForge.net noreply at sourceforge.net
Sun Feb 1 17:36:10 CET 2009


Bugs item #2555775, was opened at 2009-02-01 17:36
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=397597&aid=2555775&group_id=29880

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Argument proccessing
Group: Release (specify)
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Jan Wagner (cyco_dd)
Assigned to: Nobody/Anonymous (nobody)
Summary: nagios check_smtp expects integer instead of double

Initial Comment:
The following Bugreport we got against the ubuntu package:

Command execution returns error with double value:
# /usr/lib/nagios/plugins/check_smtp -H localhost -w 0.2
check_smtp: Warning time must be a positive integer
Usage:check_smtp -H host [-p port] [-e expect] [-C command] [-f from addr][-A authtype -U authuser -P authpass] [-w warn] [-c crit] [-t timeout]
[-S] [-D days] [-n] [-v] [-4|-6]

But docu ( /usr/lib/nagios/plugins/check_smtp -h) says:
 -w, --warning=DOUBLE
    Response time to result in warning status (seconds)
 -c, --critical=DOUBLE
    Response time to result in critical status (seconds)

I think, that the integer check is done on error, since all other commands with -w / -c option take double arguments and sub second response time checks are really useful.

-----------------------------------------
Current package:

Status: install ok installed
Priority: extra
Section: net
Installed-Size: 1252
Maintainer: Ubuntu Core Developers <ubuntu-devel-discuss at lists.ubuntu.com>
Architecture: i386
Source: nagios-plugins
Version: 1.4.11-1ubuntu5

----------------------------------------
Patch vs nagios-plugins-1.4.12 source (untested):

--- check_smtp.orig 2009-01-19 10:57:05.000000000 +0100
+++ check_smtp.c 2009-01-19 11:34:04.000000000 +0100
@@ -103,9 +103,9 @@
 char *authtype = NULL;
 char *authuser = NULL;
 char *authpass = NULL;
-int warning_time = 0;
+double warning_time = 0;
 int check_warning_time = FALSE;
-int critical_time = 0;
+double critical_time = 0;
 int check_critical_time = FALSE;
 int verbose = 0;
 int use_ssl = FALSE;
@@ -432,9 +432,9 @@
        elapsed_time = (double)microsec / 1.0e6;

        if (result == STATE_OK) {
- if (check_critical_time && elapsed_time > (double) critical_time)
+ if (check_critical_time && elapsed_time > critical_time)
                        result = STATE_CRITICAL;
- else if (check_warning_time && elapsed_time > (double) warning_time)
+ else if (check_warning_time && elapsed_time > warning_time)
                        result = STATE_WARNING;
        }

@@ -565,21 +565,19 @@
                        nresponses++;
                        break;
                case 'c': /* critical time threshold */
- if (is_intnonneg (optarg)) {
- critical_time = atoi (optarg);
- check_critical_time = TRUE;
- }
+ if (!is_nonnegative (optarg))
+ usage4 (_("Critical time must be a positive"));
                        else {
- usage4 (_("Critical time must be a positive integer"));
+ critical_time = strtod (optarg, NULL);
+ check_critical_time = TRUE;
                        }
                        break;
                case 'w': /* warning time threshold */
- if (is_intnonneg (optarg)) {
- warning_time = atoi (optarg);
- check_warning_time = TRUE;
- }
+ if (!is_nonnegative (optarg))
+ usage4 (_("Warning time must be a positive"));
                        else {
- usage4 (_("Warning time must be a positive integer"));
+ warning_time = strtod (optarg, NULL);
+ check_warning_time = TRUE;
                        }
                        break;
                case 'v': /* verbose */

Cross comparison with other files (e.g. check_http.c) showed that there might be more of these issues, e.g. wrong message outputs/conversions

    case 'w': /* warning time threshold */
      if (!is_nonnegative (optarg))
        usage2 (_("Warning threshold must be integer"), optarg);
      else {
        warning_time = strtod (optarg, NULL);
        check_warning_time = TRUE;
      }
      break;

You can track the whole bugreport at https://bugs.launchpad.net/ubuntu/+source/nagios-plugins/+bug/318703

Thank, Jan.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=397597&aid=2555775&group_id=29880




More information about the Devel mailing list