aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/check_dns.c18
-rw-r--r--plugins/t/check_dns.t3
2 files changed, 19 insertions, 2 deletions
diff --git a/plugins/check_dns.c b/plugins/check_dns.c
index eebe72cc..31a953d7 100644
--- a/plugins/check_dns.c
+++ b/plugins/check_dns.c
@@ -242,7 +242,23 @@ main (int argc, char **argv)
}
printf (ngettext("%.3f second response time", "%.3f seconds response time", elapsed_time), elapsed_time);
printf (_(". %s returns %s"), query_address, address);
- printf ("|%s\n", fperfdata ("time", elapsed_time, "s", FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0));
+ if ((time_thresholds->warning != NULL) && (time_thresholds->critical != NULL)) {
+ printf ("|%s\n", fperfdata ("time", elapsed_time, "s",
+ TRUE, time_thresholds->warning->end,
+ TRUE, time_thresholds->critical->end,
+ TRUE, 0, FALSE, 0));
+ } else if ((time_thresholds->warning == NULL) && (time_thresholds->critical != NULL)) {
+ printf ("|%s\n", fperfdata ("time", elapsed_time, "s",
+ FALSE, 0,
+ TRUE, time_thresholds->critical->end,
+ TRUE, 0, FALSE, 0));
+ } else if ((time_thresholds->warning != NULL) && (time_thresholds->critical == NULL)) {
+ printf ("|%s\n", fperfdata ("time", elapsed_time, "s",
+ TRUE, time_thresholds->warning->end,
+ FALSE, 0,
+ TRUE, 0, FALSE, 0));
+ } else
+ printf ("|%s\n", fperfdata ("time", elapsed_time, "s", FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0));
}
else if (result == STATE_WARNING)
printf (_("DNS WARNING - %s\n"),
diff --git a/plugins/t/check_dns.t b/plugins/t/check_dns.t
index 2c903db9..4ff553f7 100644
--- a/plugins/t/check_dns.t
+++ b/plugins/t/check_dns.t
@@ -10,7 +10,7 @@ use NPTest;
plan skip_all => "check_dns not compiled" unless (-x "check_dns");
-plan tests => 13;
+plan tests => 14;
my $successOutput = '/DNS OK: [\.0-9]+ seconds? response time/';
@@ -54,6 +54,7 @@ cmp_ok( $res->return_code, '==', 2, "Critical threshold passed");
$res = NPTest->testCmd("./check_dns -H $hostname_valid -t 5 -w 0 -c 5");
cmp_ok( $res->return_code, '==', 1, "Warning threshold passed");
+like( $res->output, "/\|time=[\d\.]+s;0.0*;5\.0*;0\.0*/", "Output performance data OK" );
$res = NPTest->testCmd("./check_dns -H $hostname_invalid -t 1");
cmp_ok( $res->return_code, '==', 2, "Invalid $hostname_invalid");