Since Odroid isn't as widespread as Raspberry Pi, I had to do some digging to find out how to monitor its temperature, CPU frequency, and fan speed. Odroid comes with 5 temperature sensors on its chip, each of which can be read by the command
[cc lang="bash"]$ cat /sys/devices/virtual/thermal/thermal_zone0/temp[/cc]
where the [cci]zone0[/cci] can also be replaced by [cci]zone1[/cci] through [cci]zone4[/cci]. The frequencies of the 8 CPU cores are controlled by 2 "policies", one for cpu0 through cpu3 and another for cpu4 through cpu7. The 2 frequencies can be read by the commands
[cc lang="bash"]$ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
$ cat /sys/devices/system/cpu/cpu4/cpufreq/scaling_cur_freq[/cc]
Finally, the fan speed is given by
[cc lang="bash"]$ cat /sys/devices/platform/pwm-fan/hwmon/hwmon0/pwm1[/cc]
Python plugin
Since netdata supports plugins written in Python, adding a new chart that uses the above command is easy. What isn't straightforward is figuring out the netdata API. Save the following script to [cci]/usr/lib/netdata/python.d/temperature.chart.py[/cci].
[cc lang="python"]
from bases.FrameworkServices.ExecutableService import ExecutableService
ORDER = ['temperature', 'cpufrequency', 'fanspeed']
CHARTS = {
'temperature': {
'options': ['temperature', 'Temperature', 'Celsius', 'temperature', 'custom.temperature', 'line'],
'lines': [
['zone0', None, 'absolute', 1, 1000],
['zone1', None, 'absolute', 1, 1000],
['zone2', None, 'absolute', 1, 1000],
['zone3', None, 'absolute', 1, 1000],
['zone4', None, 'absolute', 1, 1000],
]},
'cpufrequency': {
'options': ['cpufrequency', 'CPU frequency', 'GHz', 'cpufrequency', 'custom.cpufrequency', 'line'],
'lines': [
['policy0', None, 'absolute', 1, 1000000],
['policy4', None, 'absolute', 1, 1000000],
]},
'fanspeed': {
'options': ['fanspeed', 'Fan speed', '', 'fanspeed', 'custom.fanspeed', 'line'],
'lines': [
['fan', None, 'absolute', 1, 255],
]},
}
class Service(ExecutableService):
def __init__(self, configuration=None, name=None):
ExecutableService.__init__(self, configuration=configuration, name=name)
self.commands = {
'zone0': ['cat', '/sys/devices/virtual/thermal/thermal_zone0/temp'],
'zone1': ['cat', '/sys/devices/virtual/thermal/thermal_zone1/temp'],
'zone2': ['cat', '/sys/devices/virtual/thermal/thermal_zone2/temp'],
'zone3': ['cat', '/sys/devices/virtual/thermal/thermal_zone3/temp'],
'zone4': ['cat', '/sys/devices/virtual/thermal/thermal_zone4/temp'],
'policy0': ['cat', '/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq'],
'policy4': ['cat', '/sys/devices/system/cpu/cpu4/cpufreq/scaling_cur_freq'],
'fan': ['cat', '/sys/devices/platform/pwm-fan/hwmon/hwmon0/pwm1'],
}
self.order = ORDER
self.definitions = CHARTS
def check(self):
data = self._get_data()
if not data:
return False
return True
def _get_data(self):
data = {}
for key in self.commands:
self.command = self.commands[key]
try:
out = int(self._get_raw_data()[0])
data[key] = out
except (ValueError, AttributeError):
continue
return data
[/cc]
Then, enable this new plugin by adding the line
[cc]temperature: yes[/cc]
at the end of [cci]/etc/netdata/python.d.conf[/cci]. Finally, restart netdata:
[cc lang="bash"]$ sudo systemctl restart netdata[/cc]
In the netdata web UI, you should see all five temperatures monitored in the new chart called "temperature".
Alarm
Netdata also has the ability to send alerts when a certain chart reaches a particular value. To add such an alert for the temperature chart, add the following code to [cci]/etc/netdata/health.d/temperature.conf[/cci].
[cc]
# you can disable an alarm notification by setting the 'to' line to: silent
alarm: temperature
on: temperature.temperature
os: linux
hosts: *
lookup: average -1m of zone0,zone1,zone2,zone3,zone4
calc: $this / 5
units: Celcius
every: 5s
warn: $this >= 65
crit: $this >= 72
delay: down 1m multiplier 1.5 max 10m
info: average temperature of all zones in the past 1 minute
to: sysadmin
[/cc]
The meaning of each of these lines can be found on the official page.
Hi above did not work for me on my XU4.
I folowed instructions as written above.
I tested ;
]?odroid-buster?[~: python /usr/lib/netdata/python.d/temperature.chart.py
File “/usr/lib/netdata/python.d/temperature.chart.py”, line 29
def __init__(self, configuration=None, name=None):
^
IndentationError: expected an indented block
]?odroid-buster?[~:
So not sure if there is an error on the copy paste. The /etc/netdata/python.d.conf had to be created I sure would like to get this working please ? Feel free to email me please ?