You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2020/05/27 04:11:53 UTC

[GitHub] [trafficcontrol] rob05c commented on a change in pull request #4713: Add csv as an output format option for astats via header

rob05c commented on a change in pull request #4713:
URL: https://github.com/apache/trafficcontrol/pull/4713#discussion_r430501584



##########
File path: traffic_server/plugins/astats_over_http/astats_over_http.c
##########
@@ -326,7 +383,40 @@ static void appendSystemState(stats_state *my_state) {
 		end = strstr(str, "\n");
 		if (end)
 			*end = 0;
-		APPEND_STAT("proc.loadavg", "\"%s\"", str);
+		APPEND_STAT_JSON("proc.loadavg", "\"%s\"", str);
+	}
+}
+
+static void appendSystemStateCsv(stats_state *my_state) {
+	char *interface = my_state->interfaceName;
+	char buffer[16384];
+	char *str;
+	char *end;
+	int speed = 0;
+
+	APPEND_STAT_CSV("inf.name", "%s", interface);
+
+	speed = getSpeed(interface, buffer, sizeof(buffer));
+
+	APPEND_STAT_CSV("inf.speed", "%d", speed);
+
+	str = getFile("/proc/net/dev", buffer, sizeof(buffer));
+	if (str && interface) {
+		str = strstr(str, interface);
+		if (str) {
+			end = strstr(str, "\n");
+			if (end)
+				*end = 0;
+			APPEND_STAT_CSV("proc.net.dev", "%s", str);
+		}
+	}
+
+	str = getFile("/proc/loadavg", buffer, sizeof(buffer));
+	if (str) {
+		end = strstr(str, "\n");
+		if (end)
+			*end = 0;
+		APPEND_STAT_CSV("proc.loadavg", "%s", str);

Review comment:
       +1, to both




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org