check_smtp: double threshold

This commit is contained in:
Jan Wagner 2013-07-11 12:45:52 +00:00
parent 012f62be3b
commit 2d7c36b1c6
3 changed files with 77 additions and 1 deletions

2
debian/changelog vendored
View file

@ -1,6 +1,8 @@
nagios-plugins (1.4.16-3) UNRELEASED; urgency=low nagios-plugins (1.4.16-3) UNRELEASED; urgency=low
* Fixed check_squid* command definitions * Fixed check_squid* command definitions
* Add double threshold to check_smtp (LP: #318703)
- 12_check_smtp_double_threshold.dpatch
-- Jan Wagner <waja@cyconet.org> Wed, 10 Jul 2013 15:16:26 +0200 -- Jan Wagner <waja@cyconet.org> Wed, 10 Jul 2013 15:16:26 +0200

View file

@ -1,6 +1,7 @@
02_check_icmp_links.dpatch 02_check_icmp_links.dpatch
05_fix_gets_undefined_in_iso_c11.dpatch 05_fix_gets_undefined_in_iso_c11.dpatch
# commited upstream
10_check_apt_perfdata.dpatch 10_check_apt_perfdata.dpatch
11_check_nt_npe.dpatch 11_check_nt_npe.dpatch
# commited upstream 12_check_smtp_double_threshold.dpatch

View file

@ -0,0 +1,73 @@
#! /bin/sh /usr/share/dpatch/dpatch-run
## 12_check_smtp_double_threshold.dpatch by Roman Fiedler
##
## From 9839a1b9945400bb4a00a1dd9858d1c98267b284 Mon Sep 17 00:00:00 2001
## From: Jan Wagner <waja@cyconet.org>
## Date: Thu, 11 Jul 2013 14:11:09 +0200
## Subject: [PATCH] Fixed SF.net bug 2555775, threshold can be double for
## check_smtp
##
## DP: Adds threshold in double to check_smtp
@DPATCH@
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c
index 79fa482..d477a51 100644
--- a/plugins/check_smtp.c
+++ b/plugins/check_smtp.c
@@ -99,9 +99,9 @@ enum {
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;
@@ -417,9 +417,9 @@ enum {
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;
}
@@ -552,21 +552,19 @@ enum {
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 */
--
1.8.1.6