Files
gmetric-scripts/smart2ganglia
T
2026-11-02 17:55:03 -08:00

16 lines
546 B
Bash
Executable File

#!/bin/bash
# Loop through all hard drives and read their temperatures
for DEVICE in /dev/sd[a-z]; do
# Check if the device is a disk (not a partition)
if [ -b "$DEVICE" ]; then
# Get the temperature from smartctl
TEMPERATURE=$(/usr/sbin/smartctl -A $DEVICE | grep "Temperature_Celsius" | awk '{print $10}')
# If the temperature is not empty, push it to Ganglia using gmetric
if [ -n "$TEMPERATURE" ]; then
gmetric --name ${DEVICE##*/}_temp --value $TEMPERATURE --type float --units C --group=sensors
fi
fi
done