1 ------- DEFAULT SETTINGS :------------------------------------------------------
5 update_interval = 5*1000,
9 fan_file = '/sys/class/i2c-adapter/i2c-0/0-002d/fan1_input',
10 mb_file = '/sys/class/i2c-adapter/i2c-0/0-002d/temp1_input',
11 cpu_file = '/sys/class/i2c-adapter/i2c-0/0-002d/temp2_input',
13 local settings = table.join(statusd.get_config("sensors"), defaults)
15 ------- SENSORS MONITOR :-------------------------------------------------------
17 local function inform_fan(name, file, alarm)
18 file = io.open(file, 'r')
20 local level = 'normal'
21 local var = file:read('*n')
23 if var <= alarm then level = 'critical' end
24 statusd.inform("sensors_" .. name, string.format('%d', var))
25 statusd.inform('sensors_' .. name .. '_hint', level)
29 local function inform_temp(name, file, alarm)
30 file = io.open(file, 'r')
32 local level = 'normal'
33 local var = file:read('*n') / 1000
35 if var >= alarm then level = 'critical' end
36 statusd.inform("sensors_" .. name, string.format('%0.1f', var))
37 statusd.inform('sensors_' .. name .. '_hint', level)
41 local function inform_sensors()
42 inform_fan('fan', settings.fan_file, settings.fan_alarm + 0)
43 inform_temp('mb', settings.mb_file, settings.mb_alarm + 0)
44 inform_temp('cpu', settings.cpu_file, settings.cpu_alarm + 0)
49 local function update_sensors()
51 sensors_timer:set(settings.update_interval, update_sensors)
55 sensors_timer=statusd.create_timer()