A bash script to help you get systemd services status with Telegraf + InfluxDB + Grafana
Support system systemd services and user systemd services
It use some cli tool to get info from systemctl
invoke, output the info use InfluxDB line protocal format
- bash > 4.0 (because of
mapfile
use, you can also follow this changing this script for lower version bash - coreutils (for
date, tr
- grep
- sudo
- systemd
Your need install Telegraf + InfluxDB + Grafana before use this script.
mkdir -p ~/.config/user_telegraf_plugin/shell
cd ~/.config/user_telegraf_plugin/shell
git clone https://github.com/zzndb/srvstatus
cd srvstatus
chmod +x srvstatus.sh
Add your needed system service name into service_list
file, one name per line.
Then configure the Telegraf [[inputs.exec]]
section like this:
[[inputs.exec]]
commands = [
"/home/your_user_name/.config/user_telegraf_plugin/shell/srvstatus/srvstatus.sh"
]
timeout = "5s"
data_format = "influx"
Use https://grafana.com/dashboards/8348 Grafana dashboard json file, thanks @ratibor78 work
If you also want to use this with your user systemd service
- create
user_service_list
file - add user the service name into
user_service_list
, also one name per line. - change the script
- change
Uid=1000
into your user id, you can get your user id useid --user
in your terminal
- change
telegraf --input-filter exec --test
Maybe your also need test with sudo
sudo telegraf --input-filter exec --test
more info you can check srvstatus.sh
file
- srvstatus the original python version