Continuing the documentation effort. This is a shell script you run from Unraid in a cron job to feed stats to InfluxDB. You can then present them in Grafana. Note about that, I was having a lot of trouble getting the Grafana graphs to present correctly for anything coming from this script. I had to change the Fill from "null" to "none" in the graph. Not sure why that's happening, but "none" gets it to behave just like everything else.
DBURL=http://192.168.x.x:8086 ## IP address of your InfluxDB server
DBNAME=dashboard ## Easier if you pick an existing DB
DEVICE="UNRAID"
CURDATE=date +%s
DISK_ARRAY=( sdn sdl sdf sdc sdj sde sdo sdh sdi sdd sdk sdm sdg sdp sdb )
DESCRIPTION=( parity disk1 disk2 disk3 disk4 disk5 disk6 disk7 disk8 disk9 disk10 disk11 disk12 disk13 cache )
i=0
for DISK in "${DISK_ARRAY[@]}"
do
smartctl -n standby -A /dev/$DISK | grep "Temperature_Celsius" | awk '{print $10}' | while read TEMP
do
curl -is -XPOST "$DBURL/write?db=$DBNAME" --data-binary "DiskTempStats,DEVICE=${DEVICE},DISK=${DESCRIPTION[$i]} Temperature=${TEMP} ${CURDATE}000000000" >/dev/null 2>&1
done
((i++))
done
top -b -n 10 -d.2 | grep "Cpu" | tail -n 1 | awk '{print $2,$4,$6,$8,$10,$12,$14,$16}' | while read CPUusr CPUsys CPUnic CPUidle CPUio CPUirq CPUsirq CPUst
do
top -bn1 | head -3 | awk '/load average/ {print $12,$13,$14}' | sed 's/,//g' | while read LAVG1 LAVG5 LAVG15
do
curl -is -XPOST "$DBURL/write?db=$DBNAME" --data-binary "cpuStats,Device=${DEVICE} CPUusr=${CPUusr},CPUsys=${CPUsys},CPUnic=${CPUnic},CPUidle=${CPUidle},CPUio=${CPUio},CPUirq=${CPUirq},
CPUsirq=${CPUsirq},CPUst=${CPUst},CPULoadAvg1m=${LAVG1},CPULoadAvg5m=${LAVG5},CPULoadAvg15m=${LAVG15} ${CURDATE}000000000" >/dev/null 2>&1
done
done
if [[ -f byteCount.tmp ]] ; then
grep "eth0" byteCount.tmp | while read dev lastBytesIn lastBytesOut
do
cat /proc/net/dev | grep "eth0" | grep -v "veth" | awk '{print $2, $10}' | while read currentBytesIn currentBytesOut
do
echo "eth0" ${currentBytesIn} ${currentBytesOut} > byteCount.tmp
totalBytesIn=expr ${currentBytesIn} - ${lastBytesIn}
totalBytesOut=expr ${currentBytesOut} - ${lastBytesOut}
curl -is -XPOST "$DBURL/write?db=$DBNAME" --data-binary "interfaceStats,Interface=eth0,Device=${DEVICE} bytesIn=${totalBytesIn},bytesOut=${totalBytesOut} ${CURDATE}000000000" >/
dev/null 2>&1
done
done
else
echo "eth0 0 0" > byteCount.tmp
fi
df | grep "mnt/|/boot|docker" | grep -v "user0|containers" | sed 's//mnt///g' | sed 's/%//g' | sed 's//var/lib///g'| sed 's////g' | while read MOUNT TOTAL USED FREE UTILIZATION DISK
do
if [ "${DISK}" = "user" ]; then
DISK="array_total"
fi
curl -is -XPOST "$DBURL/write?db=$DBNAME" --data-binary "drive_spaceStats,Device=${DEVICE},Drive=${DISK} Free=${FREE},Used=${USED},Utilization=${UTILIZATION} ${CURDATE}000000000" >/dev/null 2>&
1
done