Add needrestart_info.py to monitore needrestart.
Hi,
I've made a small script to retrieve some metrics from needrestart, and perhaps it could be useful for others?
The script runs needrestart -b (batch mode), parses the output, and displays some metrics. It looks like this:
# HELP needrestart_timestamp information about the version and when it was last run
# TYPE needrestart_timestamp gauge
needrestart_timestamp{version="3.5"} 1.702655157e+09
# HELP needrestart_kernel_status information about the kernel status
# TYPE needrestart_kernel_status gauge
needrestart_kernel_status{current="5.10.0-26-amd64",expected="5.10.0-26-amd64"} 1.0
# HELP needrestart_services_count number of services requiring a restart
# TYPE needrestart_services_count gauge
needrestart_services_count 0.0
# HELP needrestart_containers_count number of containers requiring a restart
# TYPE needrestart_containers_count gauge
needrestart_containers_count 0.0
# HELP needrestart_sessions_count number of sessions requiring a restart
# TYPE needrestart_sessions_count gauge
needrestart_sessions_count 0.0
Hello @funkyfuture, thanks for all your feedback, they are very appreciate for a beginner like me. I've try to take all of them into account.
Is there anything missing to merge this PR? Anything I can do?
Please also check that your metric names conform to the Prometheus best practice guide: https://prometheus.io/docs/practices/naming/
Just for the records: There's has also been something coded in needrestart itself: https://github.com/liske/needrestart/issues/291
Just for the records: There's has also been something coded in
needrestartitself: liske/needrestart#291
should we consider removing this code, considering there's now something upstream? as one of those who worked on the upstream code, i would much rather see people collaborate there instead of duplicating the efforts here...
Just for the records: There's has also been something coded in
needrestartitself: liske/needrestart#291should we consider removing this code, considering there's now something upstream? as one of those who worked on the upstream code, i would much rather see people collaborate there instead of duplicating the efforts here...
fwiw the new needrestart -o has been merged upstream, but it'll take a while for that version to be included in a new distro release anywhere. for example in debian it's going to be available in Trixie when it's released.
So I'm guessing this script will still be useful for some folks until the new option becomes widely available. Maybe we should mark this script as deprecated somehow and wait for the new needrestart option to become more widely available before actually removing it
On 2025-01-09 07:34:34, Gabriel Filion wrote:
Just for the records: There's has also been something coded in
needrestartitself: liske/needrestart#291should we consider removing this code, considering there's now something upstream? as one of those who worked on the upstream code, i would much rather see people collaborate there instead of duplicating the efforts here...
fwiw the new
needrestart -ohas been merged upstream, but it'll take a while for that version to be included in a new distro release anywhere. for example in debian it's going to be available in Trixie when it's released.So I'm guessing this script will still be useful for some folks until the new option becomes widely available. Maybe we should mark this script as deprecated somehow and wait for the new needrestart option to become more widely available before actually removing it
Yeah, that makes sense. In that case Someone should at least make sure the metrics are either similar enough that they're compatible, or that the namespaces are distinct to provide a clean transition. :)