inputs.systemd_status
ne fonctionne pas dans un container Docker. Voir : https://github.com/influxdata/telegraf/issues/7689systemctl list-units --type service --full --all --plain --no-legend --no-pager | sed 's/ \{1,\}/,/g' | jq --raw-input --slurp 'split("\n") | map(split(",")) | .[0:-1] | map( { "unit": .[0], "load": .[1], "active": .[2], "sub": .[3], "description": .[4] } )
systemctl list-units -t service --full --all --output=json --no-pager
cd /opt
git clone https://github.com/ratibor78/srvstatus.git
cd /opt/srvstatus
apt install python3-venv
python3 -m 'venv' ./venv
source venv/bin/activate
pip install -r requirements.txt
chmod +x ./service.py
cd /opt/srvstatus
git pull
source venv/bin/activate
pip install -r requirements.txt
deactivate
vi status.json
wget https://raw.githubusercontent.com/cbn-alpin/sinp-<region>-srv/main/<instance>-srv/opt/srvstatus/settings.ini
<region>
(par paca
ou aura
) et instance
(par web
ou db
)cp settings.ini.back settings.ini
vi settings.ini
wget https://raw.githubusercontent.com/cbn-alpin/sinp-<region>-srv/main/<instance>-srv/opt/srvstatus/srvstatus.cron
<region>
(par paca
ou aura
) et instance
(par web
ou db
) vi srvstatus.cron
# /etc/cron.d/srvstatus: crontab entries for the srvstatus script # Copy this file into /etc/cron.d/ without .cron extension : cp srvstatus.cron /etc/cron.d/srvstatus SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin * * * * * root (sleep 10 ; /opt/srvstatus/venv/bin/python /opt/srvstatus/service.py > /opt/srvstatus/status.json) * * * * * root (sleep 20 ; /opt/srvstatus/venv/bin/python /opt/srvstatus/service.py > /opt/srvstatus/status.json) * * * * * root (sleep 30 ; /opt/srvstatus/venv/bin/python /opt/srvstatus/service.py > /opt/srvstatus/status.json) * * * * * root (sleep 40 ; /opt/srvstatus/venv/bin/python /opt/srvstatus/service.py > /opt/srvstatus/status.json) * * * * * root (sleep 50 ; /opt/srvstatus/venv/bin/python /opt/srvstatus/service.py > /opt/srvstatus/status.json) * * * * * root (sleep 60 ; /opt/srvstatus/venv/bin/python /opt/srvstatus/service.py > /opt/srvstatus/status.json)
cp srvstatus.cron /etc/cron.d/srvstatus
/opt/srvstatus/venv/bin/python /opt/srvstatus/service.py > /opt/srvstatus/status.json
services: telegraf: volumes: - /opt/srvstatus/status.json:/opt/srvstatus/status.json
[[inputs.exec]] commands = ["cat /opt/srvstatus/status.json"] timeout = "5s" name_override = "services_stats" data_format = "json" tag_keys = ["service"]
srvstatus
écrit plusieurs lignes de log toutes les minutes.vi /etc/rsyslog.conf
*.*;auth,authpriv.none -/var/log/syslog
par
*.*;cron,auth,authpriv.none -/var/log/syslog
# cron.* /var/log/cron.log
systemctl restart rsyslog.service
systemctl restart cron.service
cron.log
et l'ajout de nouveaux logs avec : vi /var/log/cron.log
syslog
avec : vi /var/log/syslog