summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_time.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/plugins/check_time.c b/plugins/check_time.c
index f73005d..0de6718 100644
--- a/plugins/check_time.c
+++ b/plugins/check_time.c
@@ -54,6 +54,7 @@ main (int argc, char **argv)
54{ 54{
55 int sd; 55 int sd;
56 int result; 56 int result;
57 time_t conntime;
57 58
58 setlocale (LC_ALL, ""); 59 setlocale (LC_ALL, "");
59 bindtextdomain (PACKAGE, LOCALEDIR); 60 bindtextdomain (PACKAGE, LOCALEDIR);
@@ -127,14 +128,19 @@ main (int argc, char **argv)
127 128
128 result = STATE_OK; 129 result = STATE_OK;
129 130
130 if (check_critical_time == TRUE && (end_time - start_time) > critical_time) 131 conntime = (end_time - start_time);
132 if (check_critical_time == TRUE && conntime > critical_time)
131 result = STATE_CRITICAL; 133 result = STATE_CRITICAL;
132 else if (check_warning_time == TRUE 134 else if (check_warning_time == TRUE && conntime > warning_time)
133 && (end_time - start_time) > warning_time) result = STATE_WARNING; 135 result = STATE_WARNING;
134 136
135 if (result != STATE_OK) 137 if (result != STATE_OK)
136 die (result, _("TIME %s - %d second response time\n"), 138 die (result, _("TIME %s - %d second response time|%s\n"),
137 state_text (result), (int) (end_time - start_time)); 139 state_text (result), (int)conntime,
140 perfdata ("time", (long)conntime, "s",
141 check_warning_time, (long)warning_time,
142 check_critical_time, (long)critical_time,
143 TRUE, 0, FALSE, 0));
138 144
139 server_time = ntohl (raw_server_time) - UNIX_EPOCH; 145 server_time = ntohl (raw_server_time) - UNIX_EPOCH;
140 if (server_time > (unsigned long)end_time) 146 if (server_time > (unsigned long)end_time)
@@ -147,8 +153,16 @@ main (int argc, char **argv)
147 else if (check_warning_diff == TRUE && diff_time > (time_t)warning_diff) 153 else if (check_warning_diff == TRUE && diff_time > (time_t)warning_diff)
148 result = STATE_WARNING; 154 result = STATE_WARNING;
149 155
150 printf (_("TIME %s - %lu second time difference\n"), state_text (result), 156 printf (_("TIME %s - %lu second time difference|%s %s\n"),
151 diff_time); 157 state_text (result), diff_time,
158 perfdata ("time", (long)conntime, "s",
159 check_warning_time, (long)warning_time,
160 check_critical_time, (long)critical_time,
161 TRUE, 0, FALSE, 0),
162 perfdata ("offset", (long)diff_time, "s",
163 check_warning_diff, (long)warning_diff,
164 check_critical_diff, (long)critical_diff,
165 TRUE, 0, FALSE, 0));
152 return result; 166 return result;
153} 167}
154 168