nagios check_smtp expects integer instead of double

Bug #318703 reported by Roman Fiedler
6
Affects Status Importance Assigned to Milestone
Nagios Plugins
In Progress
Undecided
Unassigned
nagios-plugins (Ubuntu)
Fix Released
Low
Unassigned

Bug Description

Binary package hint: nagios-plugins-basic

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 <email address hidden>
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;

Revision history for this message
Roman Fiedler (roman-fiedler-deactivatedaccount) wrote :
Revision history for this message
Andreas Olsson (andol) wrote :

I can confirm the problem described; how the help asks for a double but the actual command complains unless it gets an integer. I haven't looked at the root cause.

This goes for for 1.4.11-1ubuntu5 (Hardy) as well as for 1.4.11-2ubuntu2.1 (Intrepid)

Changed in nagios-plugins:
status: New → Confirmed
Revision history for this message
Chuck Short (zulcss) wrote :

If possible can you send this patch upstream to the nagios-plugin developers?

Thanks
chuck

Revision history for this message
Jan Wagner (waja) wrote :
Revision history for this message
Jan Wagner (waja) wrote :

Hi,

upstream stated the following:

"The proper fix would rather be using the nagios thresholds functions. OTOH
it's more likely that we put time toward implementing the new thresholds
format than fixing plugins that were never converted to the old one.

Feel free to attach a working patch if you wish - we'll consider it
anyway. Otherwise a quick fix would rather be fixing the documentation."

Please provide further informations to launchpad and the upstreambug too.

Thanks, Jan.

Thierry Carrez (ttx)
Changed in nagios-plugins:
importance: Undecided → Low
Changed in nagios-plugins (Ubuntu):
status: Confirmed → Triaged
David Futcher (bobbo)
tags: added: patch-forwarded-upstream
Revision history for this message
Jan Wagner (waja) wrote :
Revision history for this message
Jan Wagner (waja) wrote :

This is fixed in version 1.5 of nagios-plugins

Changed in nagios-plugins:
importance: Unknown → Undecided
status: Unknown → New
importance: Undecided → Unknown
status: New → Unknown
importance: Unknown → Undecided
status: Unknown → New
status: New → In Progress
Revision history for this message
Launchpad Janitor (janitor) wrote :
Download full text (4.0 KiB)

This bug was fixed in the package nagios-plugins - 1.5-1ubuntu2

---------------
nagios-plugins (1.5-1ubuntu2) trusty; urgency=medium

  * Drop universe and not-needed freradius build dependency.

nagios-plugins (1.5-1ubuntu1) trusty; urgency=low

  * Merge from Debian unstable (LP: #1259863). Remaining changes:
    - debian/control, debian/rules, debian/nagios-plugins-extra.dirs
       + add package nagios-plugins-extra
       + Suggest nagios-plugins-contrib in the universe package (-extras).
    - debian/control
       - replaces on nagios-plugins-basic (<< 1.4.16-1ubuntu1)
       - conflicts and replaces on nagios-plugins-extra

nagios-plugins (1.5-1) unstable; urgency=medium

  * New upstream release

nagios-plugins (1.4.16+git20130926-1) unstable; urgency=medium

  * New upstream git snapshot (d4c5730464)
    - check_http: Die on SSL initialization errors
    - several updates to the upstream README

nagios-plugins (1.4.16+git20130919-1) unstable; urgency=medium

  * New upstream git snapshot (6f0366c8b8)
    - check_pgsql: Don't exit UNKNOWN instead of OK (Closes: #723738)
    - check_dhcp: fix mac address and interface number detection on solaris
    - check_disk: get_fs_usage hasn't been run if using groups
    - check_disk_smb: verify path to smbclient
    - check_tcp: use receive timeout for checks that expect response
    - check_load: add alternative uptime syntaxcheck_udp: try nc.traditional too
    - check_udp: unified nc syntax
    - check_fping: some fping versions set loss to 0% by mistake

nagios-plugins (1.4.16+git20130912-1) unstable; urgency=medium

  * New upstream git snapshot (4933146e00) (Closes: #722576)
    - check_snmp: add timeout handler befor running snmpget
    - check_tcp: only test ipv6 if ping6 works
    - tests: sort cached settings before save
    - tests: make sure tests don't hang
    - check_tcp: Fix checks without --expect string
    - check_tcp: Properly deal will partial recv(3)s
    - Improve interface of np_expect_match() function

nagios-plugins (1.4.16+git20130911-1) unstable; urgency=medium

  * New upstream git snapshot (ca9ce71576)
    - Don't mark SSL_METHOD variable as "const"
    - Move global variables from .h to .c files
    - Fix GCC's -Wimplicit-function-declaration warnings
    - Fix GCC's -Wuninitialized warnings

nagios-plugins (1.4.16+git20130910-1) unstable; urgency=medium

  * New upstream git snapshot (cfb50add53)
    - check_tcp: Don't close connection too early
    - check_http: s/--proxy_authorization/--proxy-authorization/
    - check_snmp: Initialize size_t value to 0, not NULL
    - Update bundled libtool files
    - check_icmp: Minor whitespace/indentation fixes
    - check_icmp: Support "--help" and "--version"

nagios-plugins (1.4.16+git20130902-1) unstable; urgency=medium

  * New upstream git snapshot (5789548373)
    - Adjust debian/copyright
  * Droped the following upstream integrated patches
    - 05_fix_gets_undefined_in_iso_c11.dpatch
    - 10_check_apt_perfdata.dpatch
    - 11_check_nt_npe.dpatch
    - 12_check_smtp_double_threshold.dpatch
  * Fix removing empty /usr/include
  * Add new check_dbi into nagios-plugins-standard
  * Remove whois from Recommands, a...

Read more...

Changed in nagios-plugins (Ubuntu):
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.