prometheus client

systemd file

cat /usr/lib/systemd/system/prometheus-web-client.service
[Unit]
Description=prometheus web client

[Service]
User=syscollector
Group=syscollector
ExecStart=/srv/apps/thttpd/thttpd -p 9100 -dd /srv/apps/prometheus/www -D -l /dev/null
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID

[Install]
WantedBy=multi-user.target

cronfile

cat /var/spool/cron/syscollector
*/1 * * * * /bin/bash /home/syscollector/RUN_ALL.sh

script, which run other scripts )

cat RUN_ALL.sh
for SCRIPT in /home/syscollector/scripts/*
  do
    if [ -f $SCRIPT -a -x $SCRIPT ]
    then
    $SCRIPT&
  fi
done
cat /var/log/syscollector/*.prom > /srv/apps/prometheus/www/metrics

CPU monitoring

cat hd_cpu_used_percent.sh
#!/bin/bash
hd_cpu_used_percent=`top -n2 -b | grep Cpu | tail -n 1 | awk -F ':' '{print $2}' | awk '{print $1+$3+$5}'`
echo 'hd_cpu_used_percent' $hd_cpu_used_percent > /var/log/syscollector/hd_cpu_used_percent.prom.tmp
mv -f /var/log/syscollector/hd_cpu_used_percent.prom.tmp /var/log/syscollector/hd_cpu_used_percent.prom

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>