control: Add new 'uptime' message to GETINFO

Sends the Tor controller the uptime in seconds.
Highly useful for monitoring purposes.
This commit is contained in:
Kevin Gallagher 2018-07-16 19:19:10 -07:00
parent 5aaea38d88
commit 4ba26f95d5

View File

@ -1896,6 +1896,9 @@ getinfo_helper_misc(control_connection_t *conn, const char *question,
tor_asprintf(answer, "%"PRIu64, (get_bytes_read())); tor_asprintf(answer, "%"PRIu64, (get_bytes_read()));
} else if (!strcmp(question, "traffic/written")) { } else if (!strcmp(question, "traffic/written")) {
tor_asprintf(answer, "%"PRIu64, (get_bytes_written())); tor_asprintf(answer, "%"PRIu64, (get_bytes_written()));
} else if (!strcmp(question, "uptime")) {
long uptime_secs = get_uptime();
tor_asprintf(answer, "%ld", uptime_secs);
} else if (!strcmp(question, "process/pid")) { } else if (!strcmp(question, "process/pid")) {
int myPid = -1; int myPid = -1;
@ -3356,6 +3359,7 @@ static const getinfo_item_t getinfo_items[] = {
ITEM("traffic/read", misc,"Bytes read since the process was started."), ITEM("traffic/read", misc,"Bytes read since the process was started."),
ITEM("traffic/written", misc, ITEM("traffic/written", misc,
"Bytes written since the process was started."), "Bytes written since the process was started."),
ITEM("uptime", misc, "Uptime of the Tor daemon in seconds."),
ITEM("process/pid", misc, "Process id belonging to the main tor process."), ITEM("process/pid", misc, "Process id belonging to the main tor process."),
ITEM("process/uid", misc, "User id running the tor process."), ITEM("process/uid", misc, "User id running the tor process."),
ITEM("process/user", misc, ITEM("process/user", misc,