Skip to content

Add needrestart_info.py to monitore needrestart. #195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

RomainMou
Copy link
Contributor

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

@RomainMou RomainMou force-pushed the feat/needrestart-script branch from 5b4eb3b to eb588ef Compare December 15, 2023 15:54
@RomainMou RomainMou force-pushed the feat/needrestart-script branch from 80c82a9 to d805647 Compare June 3, 2024 08:18
@RomainMou RomainMou requested a review from funkyfuture June 3, 2024 08:21
@RomainMou
Copy link
Contributor Author

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.

Copy link
Contributor

@funkyfuture funkyfuture left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, i've been using it for some weeks now.

@RomainMou
Copy link
Contributor Author

Is there anything missing to merge this PR? Anything I can do?

@dswarbrick
Copy link
Member

Please also check that your metric names conform to the Prometheus best practice guide: https://prometheus.io/docs/practices/naming/

@RomainMou RomainMou force-pushed the feat/needrestart-script branch from 62b5d2e to ce87ff3 Compare October 18, 2024 16:18
Signed-off-by: RomainMou <[email protected]>
@RomainMou RomainMou requested a review from dswarbrick October 18, 2024 16:22
Signed-off-by: RomainMou <[email protected]>
@RomainMou RomainMou requested a review from dswarbrick October 21, 2024 08:50
@dswarbrick dswarbrick merged commit 88a82d6 into prometheus-community:master Oct 21, 2024
4 checks passed
allamiro pushed a commit to allamiro/node-exporter-textfile-collector-scripts that referenced this pull request Nov 16, 2024
…y#195)

Add needrestart_info.py to monitor needrestart

Signed-off-by: RomainMou <[email protected]>
@calestyo
Copy link

calestyo commented Dec 2, 2024

Just for the records: There's has also been something coded in needrestart itself: liske/needrestart#291

@RomainMou RomainMou deleted the feat/needrestart-script branch December 2, 2024 08:43
@anarcat
Copy link
Contributor

anarcat commented Jan 9, 2025

Just for the records: There's has also been something coded in needrestart itself: 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...

@lelutin
Copy link

lelutin commented Jan 9, 2025

Just for the records: There's has also been something coded in needrestart itself: 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...

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

@anarcat
Copy link
Contributor

anarcat commented Jan 9, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants