-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Add support for --user in systemd_units input plugin #12053
Comments
Hi,
You wish to do something like this in your Telegraf config:
And then telegraf would run:
Is that inline with your thinking? However, unless run as root or the user you want to monitor as, Telegraf would get operating not permitted errors? I am concerned given I like to think most people install Telegraf and run it from a deb/rpm, which would be the telegraf user. tester@j:~$ whoami
tester
tester@j:~$ systemctl list-units --all --plain --type=service --machine=ubuntu@.host --user
Failed to connect to bus: Operation not permitted (consider using --machine=<user>@.host --user to connect to bus of other user)
Failed to list units: Transport endpoint is not connected Thoughts? |
Yeah, that's exactly what I'd wish for it to run and yes, you are right about the problem it being the telegraf user. Right out of the box it wouldn't work no. But could the user add that exact line to visudo allowing telegraf to run the user query with sudo without password? It clearly would be complicated to document that the user needs to do manual visudo magic in case they want to use that --user parameter, but what else would work? I'd still prefer that instead of having to jump to own scripts that would be invoked from telegraf, which would still have to do the sudo magic. |
The configuring of this input would have to be more complicated than that. What if you wanted to check for 2 things, a root run service like sshd.service and a user run service like jenkins.service. You couldn't just 'pattern = "sshd.service jenkins.service"', since you'd need to specify patterns for a given user, smt like 'pattern.<user> = "jenkins.service"'. |
That seems to do the trick as a bash script.
And I had to add this to /etc/sudoers:
It's not pretty, but I got it to work and I now can show / track and alarm the state of services running under personal space in Grafana |
correct, but would need to specify every user and service or use wildcards. Something like what you used:
You would use two instances of this plugin: one for the root and one for the user? We would need to add the user as a tag to differentiate as well. Still something you are interested in? |
I am. Even though I made that bash script that does what I need, I would jump to a native solution just to skip possible maintaining of my own code 😊 Not to mention that my Ansible becomes prettier when I dont have own scripts mentioned there that I need to install. |
+1 for this. Any updates? |
Use Case
We want to monitor the service running under a user not visible for root by default. After systemd version >= 248 one can apparently add --user --machine=@ to see the status of services under a given user. Telegraf doesn't support this yet however.
Expected behavior
Expecting to be able to monitor the services under a given user.
Actual behavior
This isn't supported yet.
Additional info
No response
The text was updated successfully, but these errors were encountered: