summaryrefslogtreecommitdiff
path: root/src/feature/control/control.c
diff options
context:
space:
mode:
authorKevin Gallagher <kgallagher@pandora.com>2018-07-16 19:19:10 -0700
committerKevin Gallagher <kgallagher@pandora.com>2018-07-16 19:19:10 -0700
commit4ba26f95d5b2ba8a3795317f4777bfefff0e62a9 (patch)
treeb5b32b6c839b9431a43b29ec865dac76519c28a7 /src/feature/control/control.c
parent5aaea38d889ae558ea0e9b01b4c5b58f3935b542 (diff)
downloadtor-4ba26f95d5b2ba8a3795317f4777bfefff0e62a9.tar.gz
tor-4ba26f95d5b2ba8a3795317f4777bfefff0e62a9.zip
control: Add new 'uptime' message to GETINFO
Sends the Tor controller the uptime in seconds. Highly useful for monitoring purposes.
Diffstat (limited to 'src/feature/control/control.c')
-rw-r--r--src/feature/control/control.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/feature/control/control.c b/src/feature/control/control.c
index 12f10926b7..e2611ee504 100644
--- a/src/feature/control/control.c
+++ b/src/feature/control/control.c
@@ -1896,6 +1896,9 @@ getinfo_helper_misc(control_connection_t *conn, const char *question,
tor_asprintf(answer, "%"PRIu64, (get_bytes_read()));
} else if (!strcmp(question, "traffic/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")) {
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/written", misc,
"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/uid", misc, "User id running the tor process."),
ITEM("process/user", misc,