From dde07305649e4eafcc246f770ff65544415d74ad Mon Sep 17 00:00:00 2001
From: Karl DeBisschop <kdebisschop@users.sourceforge.net>
Date: Sat, 14 Sep 2002 02:27:45 +0000
Subject: time data in performance string

git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@97 f882894a-f735-0410-b71e-b25c423dba1c

diff --git a/plugins/check_http.c b/plugins/check_http.c
index ecf6128..1b4bae3 100644
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
@@ -726,7 +726,8 @@ check_http (void)
 
 	/* Exit here if server_expect was set by user and not default */
 	if ( server_expect_yn  )  {
-		msg = ssprintf (msg, "HTTP OK: Status line output matched \"%s\"\n",server_expect);
+		msg = ssprintf (msg, "HTTP OK: Status line output matched \"%s\"\n",
+	                  server_expect);
 		if (verbose)
 			printf ("%s\n",msg);
 
@@ -821,9 +822,9 @@ check_http (void)
 			else if (onredirect == STATE_CRITICAL)
 				printf ("HTTP CRITICAL");
 			time (&end_time);
-			msg = ssprintf (msg, ": %s - %d second response time %s%s\n",
-		                status_line, (int) (end_time - start_time),
-		                timestamp, (display_html ? "</A>" : ""));
+			msg = ssprintf (msg, ": %s - %d second response time %s%s|time=%d\n",
+		                 status_line, (int) (end_time - start_time), timestamp,
+	                   (display_html ? "</A>" : ""), (int) (end_time - start_time));
 			terminate (onredirect, msg);
 		} /* end if (strstr (status_line, "30[0-4]") */
 
@@ -833,9 +834,9 @@ check_http (void)
 		
 	/* check elapsed time */
 	time (&end_time);
-	msg = ssprintf (msg, "HTTP problem: %s - %d second response time %s%s\n",
-	               status_line, (int) (end_time - start_time),
-	               timestamp, (display_html ? "</A>" : ""));
+	msg = ssprintf (msg, "HTTP problem: %s - %d second response time %s%s|time=%d\n",
+	               status_line, (int) (end_time - start_time), timestamp,
+	               (display_html ? "</A>" : ""), (int) (end_time - start_time));
 	if (check_critical_time == TRUE && (end_time - start_time) > critical_time)
 		terminate (STATE_CRITICAL, msg);
 	if (check_warning_time == TRUE && (end_time - start_time) > warning_time)
@@ -846,14 +847,14 @@ check_http (void)
 
 	if (strlen (string_expect)) {
 		if (strstr (page, string_expect)) {
-			printf ("HTTP ok: %s - %d second response time %s%s\n",
+			printf ("HTTP ok: %s - %d second response time %s%s|time=%d\n",
 			        status_line, (int) (end_time - start_time),
-			        timestamp, (display_html ? "</A>" : ""));
+			        timestamp, (display_html ? "</A>" : ""), (int) (end_time - start_time));
 			exit (STATE_OK);
 		}
 		else {
-			printf ("HTTP CRITICAL: string not found%s\n",
-			        (display_html ? "</A>" : ""));
+			printf ("HTTP CRITICAL: string not found%s|time=%d\n",
+			        (display_html ? "</A>" : ""), (int) (end_time - start_time));
 			exit (STATE_CRITICAL);
 		}
 	}
@@ -861,15 +862,15 @@ check_http (void)
 	if (strlen (regexp)) {
 		errcode = regexec (&preg, page, REGS, pmatch, 0);
 		if (errcode == 0) {
-			printf ("HTTP ok: %s - %d second response time %s%s\n",
+			printf ("HTTP ok: %s - %d second response time %s%s|time=%d\n",
 			        status_line, (int) (end_time - start_time),
-			        timestamp, (display_html ? "</A>" : ""));
+			        timestamp, (display_html ? "</A>" : ""), (int) (end_time - start_time));
 			exit (STATE_OK);
 		}
 		else {
 			if (errcode == REG_NOMATCH) {
-				printf ("HTTP CRITICAL: pattern not found%s\n",
-				        (display_html ? "</A>" : ""));
+				printf ("HTTP CRITICAL: pattern not found%s|time=%d\n",
+				        (display_html ? "</A>" : ""), (int) (end_time - start_time));
 				exit (STATE_CRITICAL);
 			}
 			else {
@@ -882,9 +883,9 @@ check_http (void)
 #endif
 
 	/* We only get here if all tests have been passed */
-	msg = ssprintf (msg, "HTTP ok: %s - %d second response time %s%s\n",
+	msg = ssprintf (msg, "HTTP ok: %s - %d second response time %s%s|time=%d\n",
 	                status_line, (int) (end_time - start_time),
-	                timestamp, (display_html ? "</A>" : ""));
+	                timestamp, (display_html ? "</A>" : ""), (int) (end_time - start_time));
 	terminate (STATE_OK, msg);
 	return STATE_UNKNOWN;
 }
diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c
index bef0e75..c537729 100644
--- a/plugins/check_tcp.c
+++ b/plugins/check_tcp.c
@@ -300,9 +300,9 @@ main (int argc, char **argv)
 		 state_text (result), (int) (end_time - start_time), server_port);
 
 	if (status)
-		printf (" [%s]\n", status);
-	else
-		printf ("\n");
+		printf (" [%s]", status);
+
+	printf ("|time=%d\n", (int) (end_time - start_time));
 
 	return result;
 }
-- 
cgit v0.10-9-g596f

