Skip to content

Instantly share code, notes, and snippets.

@maggiben
Last active July 31, 2024 15:51
Show Gist options
  • Save maggiben/e578812c27eda08286aef7d9fc99cae0 to your computer and use it in GitHub Desktop.
Save maggiben/e578812c27eda08286aef7d9fc99cae0 to your computer and use it in GitHub Desktop.
Base sensor monitor
#!/bin/bash
# Get the size of /snapshots
SNAPSHOT_SIZE=$(du -hs /snapshots 2>/dev/null | awk '{print $1}')
SNAPSHOT_TOTAL=$(ls | grep *.jpg | wc -l 2>/dev/null)
echo "[snapshots]"
echo "size: $SNAPSHOT_SIZE"
echo "total: $SNAPSHOT_TOTAL"
# Get the available space on the root partition
AVAILABLE_SPACE=$(df -Bh / 2>/dev/null | grep -E '^/dev' | awk '{print $4}')
echo "[hdd]"
echo "available space on /: $AVAILABLE_SPACE"
# Get the temperature
TEMPERATURE=$(vcgencmd measure_temp 2>/dev/null | awk -F'=' '{print $2}')
echo "[sensors]"
echo "temperature: $TEMPERATURE"
# Get the load average
LOAD_AVERAGE=$(uptime 2>/dev/null | awk -F'load average: ' '{print $2}')
echo "[cpu]"
echo "Load average: $LOAD_AVERAGE"
# Get the RAM status
RAM_STATUS=$(free -h 2>/dev/null | grep Mem)
RAM_TOTAL=$(echo $RAM_STATUS | awk '{print $2}')
RAM_USED=$(echo $RAM_STATUS | awk '{print $3}')
RAM_FREE=$(echo $RAM_STATUS | awk '{print $4}')
echo "[ram]"
echo "total: $RAM_TOTAL, used: $RAM_USED, free: $RAM_FREE"
# Get network throughput
NETWORK_THROUGHPUT=$(cd /monitor && ./network-throughput.sh)
echo "[network]"
echo $NETWORK_THROUGHPUT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment