[nagiosplug] Add perfdata to check_ssh (#3244097 - Marco Beck)

Thomas Guyot-Sionnest dermoth at users.sourceforge.net
Sat Mar 26 20:45:27 CET 2011


 Module: nagiosplug
 Branch: master
 Commit: 1bc7a4a198aefde2389c9c1685baed0da7856bf5
 Author: Thomas Guyot-Sionnest <dermoth at aei.ca>
   Date: Sat Mar 26 15:44:38 2011 -0400
    URL: http://nagiosplug.git.sf.net/git/gitweb.cgi?p=nagiosplug/nagiosplug;a=commit;h=1bc7a4a

Add perfdata to check_ssh (#3244097 - Marco Beck)

---

 NEWS                |    1 +
 THANKS.in           |    1 +
 plugins/check_ssh.c |   11 +++++++++--
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index d7fea27..fcaa9c1 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,7 @@ This file documents the major additions and syntax changes between releases.
 	check_disk_smb now allows spaces in share names (#990948, #1370031, Debian #601699)
 	check_http now uses standard threshold functions (enables floating point and ranges)
 	check_http now checks for and prints the certificate cn (hostname) in SSL certificate checks (Stéphane Urbanovski)
+	Add perfdata to check_ssh (#3244097 - Marco Beck)
 
 	FIXES
 	Fix check_disk free space calculation if blocksizes differ within a disk group (Bekar - #2973603)
diff --git a/THANKS.in b/THANKS.in
index 387a379..cb8d26c 100644
--- a/THANKS.in
+++ b/THANKS.in
@@ -267,3 +267,4 @@ Craig Leres
 Brian Landers
 Ryan Kelly
 Stéphane Urbanovski
+Marco Beck
diff --git a/plugins/check_ssh.c b/plugins/check_ssh.c
index 2509b86..3bbf44d 100644
--- a/plugins/check_ssh.c
+++ b/plugins/check_ssh.c
@@ -215,6 +215,10 @@ ssh_connect (char *haddr, int hport, char *remote_version)
 	char *ssh_proto = NULL;
 	char *ssh_server = NULL;
 	static char *rev_no = VERSION;
+	struct timeval tv;
+	double elapsed_time;
+
+	gettimeofday(&tv, NULL);
 
 	result = my_tcp_connect (haddr, hport, &sd);
 
@@ -250,9 +254,12 @@ ssh_connect (char *haddr, int hport, char *remote_version)
 			exit (STATE_WARNING);
 		}
 
+		elapsed_time = (double)deltime(tv) / 1.0e6;
+
 		printf
-			(_("SSH OK - %s (protocol %s)\n"),
-			 ssh_server, ssh_proto);
+			(_("SSH OK - %s (protocol %s) | %s\n"),
+			 ssh_server, ssh_proto, fperfdata("time", elapsed_time, "s",
+			 FALSE, 0, FALSE, 0, TRUE, 0, TRUE, (int)socket_timeout));
 		close(sd);
 		exit (STATE_OK);
 	}





More information about the Commits mailing list