CPU temperature collectd report on NetBSD

pkgsrc’s collectd does not support the thermal plugin, so in order to publish thermal information I had to use the exec plugin:

1
2
3
4
5
6
LoadPlugin exec
# more plugins

<Plugin exec>
Exec "nobody:nogroup" "/home/imil/bin/temp.sh"
</Plugin>

And write this simple script that reads CPUs temperature from NetBSD’s envstat command:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
$ cat bin/temp.sh 
#!/bin/sh

hostname=$(hostname)
interval=10

while :
do
envstat|awk '/cpu[0-9]/ {printf "%s %s\n",$1,$3}'|while read c t
do
echo "PUTVAL ${hostname}/temperature/temperature-zone${c#cpu} interval=${interval} N:${t%%.*}"
done
sleep ${interval}
done

I then send those values to an influxdb server:

1
2
3
4
5
6
LoadPlugin network
# ...

<Plugin network>
Server "192.168.1.5" "25826"
</Plugin>

And display them using grafana:

grafana setup
NetBSD temperature in grafana

HTH!