Skip to content

Instantly share code, notes, and snippets.

@halmartin
Created January 10, 2018 20:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save halmartin/516976f807b228f11fc8aa091f7fc6ec to your computer and use it in GitHub Desktop.
Save halmartin/516976f807b228f11fc8aa091f7fc6ec to your computer and use it in GitHub Desktop.
FreeBSD: collectd temperature Dell R210 II CPU & BMC
#!/bin/sh
HOSTNAME="${COLLECTD_HOSTNAME:-`hostname -f`}"
INTERVAL="${COLLECTD_INTERVAL:-30}"
while sleep "$INTERVAL"; do
/sbin/sysctl -a | awk -F'[. ]' '/dev\.cpu\.[0-9]\.temperature/ {printf "%s %s\n",$3,$5}'|while read c t
do
echo "PUTVAL \"$HOSTNAME/temperature/temperature-cpu${c}\" interval=$INTERVAL N:${t%%.*}"
done
ipmi_output=$(/usr/local/bin/ipmitool sensor)
echo "$ipmi_output" | awk -F"|" '/Ambient Temp/ {printf "%d\n",$2}'|while read c
do
echo "PUTVAL \"$HOSTNAME/temperature/temperature-ambient\" interval=$INTERVAL N:${c%%.*}"
done
# this works to collectd but not to influxdb for some reason...
echo "$ipmi_output" | awk -F"[| ]" '/FAN [1-3] RPM/ {printf "%s %d\n",$2,$13}'|while read c t
do
echo "PUTVAL \"$HOSTNAME/rpm/count-fan${c}\" interval=$INTERVAL N:${t%%.*}"
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment