Opened 16 months ago

Closed 9 months ago

#25132 closed enhancement (implemented)

Add uptime messages to control protocol GETINFO

Reported by: ageisp0lis Owned by:
Priority: Medium Milestone: Tor: 0.3.5.x-final
Component: Core Tor/Tor Version: Tor: unspecified
Severity: Normal Keywords: control protocol, GETINFO, uptime
Cc: Actual Points:
Parent ID: Points:
Reviewer: dgoulet Sponsor:

Description

I am helping to maintain a fleet of relays and intended to write a Prometheus exporter (that's a numerical time-series databases and monitoring system) in Python using stem in order to aggregate statistics from them, such as traffic/read and traffic/written, from which I can then build pretty graphs and metrics visualization/analytics. I discovered that there was no way to get the uptime in the control protocol. My first approach was to parse the heartbeat message in the logs via Logstash, but that's not good enough.

This would very useful to have for sysadmins/SRE/DevOps to monitor their relays.

I have done the implementation which adds two new commands: 'uptime' (seconds) and 'uptime_str' (in the heartbeat format). They're in separate commits.

It's pushed up to this branch: https://github.com/ageis/tor/tree/control-getinfo-uptime

I also have the accompanying update to torspec: https://github.com/ageis/torspec/tree/control-getinfo-uptime

Please review and let me know what else I need to do in order to further this patch along. I actually couldn't find much information about your development/contribution processes.

Child Tickets

Change History (9)

comment:1 Changed 16 months ago by ageisp0lis

Can't edit the description; so just a minor correction, the commands are uptime and uptime/str (no underscore).

comment:2 Changed 16 months ago by ageisp0lis

Status: newneeds_review

comment:3 Changed 16 months ago by atagar

Hi ageisp0lis. I'd be happy for tor to add uptime but for what it's worth since you're using Stem you can also get it through...

https://stem.torproject.org/api/util/system.html#stem.util.system.start_time

comment:4 in reply to:  3 Changed 15 months ago by ageisp0lis

Replying to atagar:

Hi ageisp0lis. I'd be happy for tor to add uptime but for what it's worth since you're using Stem you can also get it through...

https://stem.torproject.org/api/util/system.html#stem.util.system.start_time

Hey atagar, I since figured this out. Someone wrote a [more advanced Prometheus exporter](https://github.com/atx/prometheus-tor_exporter) than [mine](https://gist.github.com/ageis/bb45fe818e9fbce95c4f23ce31a7b0dc). But I'd talked this issue through with @arma and he had no problem with it. I'd really appreciate including this addition to the control protocol anyway.

comment:5 Changed 15 months ago by atagar

Sounds good, glad you figured this out! I don't have an opinion on the tor addition either way, I just chimed in since you were using stem. :)

comment:6 Changed 9 months ago by nickm

Component: Core TorCore Tor/Tor

comment:7 Changed 9 months ago by asn

Reviewer: dgoulet

comment:8 Changed 9 months ago by dgoulet

Status: needs_reviewmerge_ready

The GETINFO uptime command seems quite straight forward. Code looks good and spec patch also. ACK.

comment:9 Changed 9 months ago by nickm

Milestone: Tor: unspecifiedTor: 0.3.5.x-final
Resolution: implemented
Status: merge_readyclosed

Added a changes file and merged.

Note: See TracTickets for help on using tickets.