summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5c93a3f)
raw | patch | inline | side by side (parent: 5c93a3f)
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Fri, 18 Oct 2002 03:48:53 +0000 (03:48 +0000) | ||
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Fri, 18 Oct 2002 03:48:53 +0000 (03:48 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@139 f882894a-f735-0410-b71e-b25c423dba1c
plugins/check_tcp.c | patch | blob | history |
diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c
index 140915abe98732e88b6326c094253cf808439202..2822940ebf5dc393244fa127867e7655a8f1b3ef 100644 (file)
--- a/plugins/check_tcp.c
+++ b/plugins/check_tcp.c
char **crit_codes = NULL;
int crit_codes_count = 0;
int delay = 0;
-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;
+double elapsed_time = 0;
int verbose = FALSE;
int use_ssl = FALSE;
int sd;
char *status = NULL;
char *output = NULL;
char *ptr = NULL;
+ struct timeval tv;
if (strstr (argv[0], "check_udp")) {
PROGNAME = strscpy (PROGNAME, "check_udp");
alarm (socket_timeout);
/* try to connect to the host at the given port number */
- time (&start_time);
+ gettimeofday (&tv, NULL);
#ifdef HAVE_SSL
if (use_ssl)
result = connect_SSL ();
}
if (delay > 0) {
- start_time = start_time + delay;
+ tv.tv_sec += delay;
sleep (delay);
}
/* close the connection */
close (sd);
- time (&end_time);
+ elapsed_time = delta_time (tv);
- if (check_critical_time == TRUE && (end_time - start_time) > critical_time)
+ if (check_critical_time == TRUE && elapsed_time > critical_time)
result = STATE_CRITICAL;
- else if (check_warning_time == TRUE
- && (end_time - start_time) > warning_time) result = STATE_WARNING;
+ else if (check_warning_time == TRUE && elapsed_time > warning_time)
+ result = STATE_WARNING;
/* reset the alarm */
alarm (0);
printf
- ("%s %s - %d second response time on port %d",
+ ("%s %s - %7.3f second response time on port %d",
SERVICE,
- state_text (result), (int) (end_time - start_time), server_port);
+ state_text (result), elapsed_time, server_port);
if (status)
printf (" [%s]", status);
- printf ("|time=%d\n", (int) (end_time - start_time));
+ printf ("|time=%7.3f\n", elapsed_time);
return result;
}
case 'c': /* critical */
if (!is_intnonneg (optarg))
usage ("Critical threshold must be a nonnegative integer\n");
- critical_time = atoi (optarg);
+ critical_time = strtod (optarg, NULL);
check_critical_time = TRUE;
break;
case 'w': /* warning */
if (!is_intnonneg (optarg))
usage ("Warning threshold must be a nonnegative integer\n");
- warning_time = atoi (optarg);
+ warning_time = strtod (optarg, NULL);
check_warning_time = TRUE;
break;
case 'C':
" String to expect in server response"
" -W, --wait=INTEGER\n"
" Seconds to wait between sending string and polling for response\n"
- " -w, --warning=INTEGER\n"
+ " -w, --warning=DOUBLE\n"
" Response time to result in warning status (seconds)\n"
- " -c, --critical=INTEGER\n"
+ " -c, --critical=DOUBLE\n"
" Response time to result in critical status (seconds)\n"
" -t, --timeout=INTEGER\n"
" Seconds before connection times out (default: %d)\n"