Last active
July 31, 2024 15:51
-
-
Save maggiben/e578812c27eda08286aef7d9fc99cae0 to your computer and use it in GitHub Desktop.
Base sensor monitor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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