diff options
author | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2024-09-05 23:53:47 (GMT) |
---|---|---|
committer | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2024-09-05 23:53:47 (GMT) |
commit | 0fd0421052fed1972ecbdfdabecba5a616eaa109 (patch) | |
tree | d11d6ee8850c404be221069efc4e0a84cb02d03f /plugins/check_ssh.c | |
parent | 829ec76f00f33f7015936dcccca60661ca459252 (diff) | |
download | monitoring-plugins-0fd0421052fed1972ecbdfdabecba5a616eaa109.tar.gz |
check_ssh: set elapsed time properly
Previous to this commit, `elapsed_time` was only set after being read,
which was quite likely wrong and a bug.
This commit actually set the value before it is being read again.
Diffstat (limited to 'plugins/check_ssh.c')
-rw-r--r-- | plugins/check_ssh.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/plugins/check_ssh.c b/plugins/check_ssh.c index a3b5358..d162e42 100644 --- a/plugins/check_ssh.c +++ b/plugins/check_ssh.c | |||
@@ -222,7 +222,6 @@ ssh_connect (char *haddr, int hport, char *remote_version, char *remote_protocol | |||
222 | char *ssh_server = NULL; | 222 | char *ssh_server = NULL; |
223 | static char *rev_no = VERSION; | 223 | static char *rev_no = VERSION; |
224 | struct timeval tv; | 224 | struct timeval tv; |
225 | double elapsed_time = 0; | ||
226 | 225 | ||
227 | gettimeofday(&tv, NULL); | 226 | gettimeofday(&tv, NULL); |
228 | 227 | ||
@@ -334,6 +333,7 @@ ssh_connect (char *haddr, int hport, char *remote_version, char *remote_protocol | |||
334 | exit (STATE_CRITICAL); | 333 | exit (STATE_CRITICAL); |
335 | } | 334 | } |
336 | 335 | ||
336 | double elapsed_time = (double)deltime(tv) / 1.0e6; | ||
337 | if (remote_protocol && strcmp(remote_protocol, ssh_proto)) { | 337 | if (remote_protocol && strcmp(remote_protocol, ssh_proto)) { |
338 | printf | 338 | printf |
339 | (_("SSH CRITICAL - %s (protocol %s) protocol version mismatch, expected '%s' | %s\n"), | 339 | (_("SSH CRITICAL - %s (protocol %s) protocol version mismatch, expected '%s' | %s\n"), |
@@ -342,7 +342,6 @@ ssh_connect (char *haddr, int hport, char *remote_version, char *remote_protocol | |||
342 | close(sd); | 342 | close(sd); |
343 | exit (STATE_CRITICAL); | 343 | exit (STATE_CRITICAL); |
344 | } | 344 | } |
345 | elapsed_time = (double)deltime(tv) / 1.0e6; | ||
346 | 345 | ||
347 | printf | 346 | printf |
348 | (_("SSH OK - %s (protocol %s) | %s\n"), | 347 | (_("SSH OK - %s (protocol %s) | %s\n"), |