A simple script is checking if the Smart Steppers are connected by USB.

vim /opt/iostat.sh
#!/bin/bash
while true; do

  VAL_USER=$(iostat -c|awk '/^ /{print $1}')
  VAL_NICE=$(iostat -c|awk '/^ /{print $2}')
VAL_SYSTEM=$(iostat -c|awk '/^ /{print $3}')
VAL_IOWAIT=$(iostat -c|awk '/^ /{print $4}')
 VAL_STEAL=$(iostat -c|awk '/^ /{print $5}')
  VAL_IDLE=$(iostat -c|awk '/^ /{print $6}')

        curl -k -XPOST "http://localhost:8086/write?db=trikarus" --data-binary "iostat,host=hangdevice.fablabchemnitz.de val_user=${VAL_USER},val_nice=${VAL_NICE},val_system=${VAL_SYSTEM},val_iowait=${VAL_IOWAIT},val_steal=${VAL_STEAL},val_idle=${VAL_IDLE}" --user user:password
sleep 10
done
chmod +x /opt/iostat.sh
vim /opt/iostat.service
[Unit]
After=network.target
Description=iostat Monitoring Service

[Service]
Type=simple
ExecStart=/opt/iostat.sh
KillMode=process
Restart=on-failure
RestartSec=10
RemainAfterExit=no
User=root
Group=root

[Install]
WantedBy= multi-user.target
systemctl enable /opt/iostat.service

service start iostat.service && journalctl -f -u iostat.service
  • No labels
Write a comment…