From 0fd0421052fed1972ecbdfdabecba5a616eaa109 Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Fri, 6 Sep 2024 01:53:47 +0200 Subject: 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. 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 char *ssh_server = NULL; static char *rev_no = VERSION; struct timeval tv; - double elapsed_time = 0; gettimeofday(&tv, NULL); @@ -334,6 +333,7 @@ ssh_connect (char *haddr, int hport, char *remote_version, char *remote_protocol exit (STATE_CRITICAL); } + double elapsed_time = (double)deltime(tv) / 1.0e6; if (remote_protocol && strcmp(remote_protocol, ssh_proto)) { printf (_("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 close(sd); exit (STATE_CRITICAL); } - elapsed_time = (double)deltime(tv) / 1.0e6; printf (_("SSH OK - %s (protocol %s) | %s\n"), -- cgit v0.10-9-g596f