Reading A Raspberry PI CPU and GPU Temperature Via SNMP
The following is a way to access the CPU and GPU temperature on a raspberry Pi using SNMP
Note – I am using Centos 7 on my Raspberry Pi
Edit /etc/sysconfig/selinux
change the line:
SELINUX=enabled
to read
SELINUX=disabled
Save your changes
Create a file named /usr/local/sbin/cputemp and put the following in it
#!/bin/bash cpu=$(</sys/class/thermal/thermal_zone0/temp) echo print $cpu/1000 | /bin/perl echo
chmod the file to be 755 and chown to root.root
Create a file named /usr/local/sbin/gputemp
#!/bin/bash gpu=$(/usr/bin/vcgencmd measure_temp) echo $gpu | /bin/awk -F ‘=’ {‘print $2’} | /bin/awk -F “‘” {‘print $1’}
chmod the file to be 755 and chown to root.root
yum -y install net-snmp
edit the file /etc/snmp/snmpd.conf file and add the following two lines to the end
extend cputemp /usr/local/sbin/cputemp extend gputemp /usr/local/sbin/gputemp
Scroll up the snmpd.conf file and find the lines that start with
view systemvew included....
and add the following line:
view systemview included .1.3.6.1.4.1.8072.1.3.2
save your changes and exit your editor
execute
systemctl enable snmpd
edit iptables or ipchains (which ever you are using) to permit inbound udp traffic to port 161
Important: Remote the pi now
Then you can test it from another computer that has net-snmp-utils installed:
[user@desktop ~]$ snmpwalk -v 1 -c public MyPiIPAddress nsExtendOutLine NET-SNMP-EXTEND-MIB::nsExtendOutLine.”cputemp”.1 = STRING: 49.388 NET-SNMP-EXTEND-MIB::nsExtendOutLine.”gputemp”.1 = STRING: 49.9
Now you can use nagios, cacti or any of your other favorite snmp based monitoring systems to watch your pi’s temp