Automatically migrate from the old to the new format for existing installtags/zabbix-agent-addons-0.2.20-1
parent
fd6de22593
commit
b2cc891890
6 changed files with 134 additions and 59 deletions
@ -1,29 +0,0 @@ |
|||||||
# You can configure here the sensors |
|
||||||
# Format is <sensors_name>=<command>!<high threshold>!<low threshold>!<sensor type> |
|
||||||
# An alert is triggerd if the temperature is above the high threshold |
|
||||||
# The alert is cleared if the temperature is less than low threshold |
|
||||||
# the last field (sensor type) is optional and defaults to temp |
|
||||||
# It's used if you want to monitor other sensors, like fan, or power |
|
||||||
# Example: |
|
||||||
# |
|
||||||
# |
|
||||||
## Examples with ipmitool |
|
||||||
# cpu0 = /usr/bin/ipmitool sdr get 'P1 Therm Margin' | grep 'Sensor Reading' | awk '{print $4}'!-30!-39 |
|
||||||
# mb = /usr/bin/ipmitool sdr get 'Baseboard Temp' | grep 'Sensor Reading' | awk '{print $4}'!50!45 |
|
||||||
# |
|
||||||
# fan1 = fan1a=/usr/bin/ipmitool sdr get 'Fan1A RPM' | grep 'Sensor Reading' | awk '{print $4}'!0!0!fan |
|
||||||
# pwr1=/usr/bin/ipmitool sdr get 'Pwr Consumption' | grep 'Sensor Reading' | awk '{print $4}'!0!0!power |
|
||||||
# |
|
||||||
## Examples with smartctl |
|
||||||
# sda = /usr/sbin/smartctl -a /dev/sda | grep Temperature_Celsius | awk '{print $10}'!45!40 |
|
||||||
# sdb = /usr/sbin/smartctl -a /dev/sdb | grep Temperature_Celsius | awk '{print $10}'!45!50 |
|
||||||
# |
|
||||||
## Examples with lm_sensors |
|
||||||
# cpu0=/usr/bin/sensors | grep temp1 | cut -d':' -f 2 | awk '{print $1'} | sed -e "s/+//g" -e "s/.C//g"!65!55 |
|
||||||
# |
|
||||||
## Examples with acpi |
|
||||||
# cpu0=cat /proc/acpi/thermal_zone/THRM/temperature | awk '{print $2}'!65!55 |
|
||||||
# |
|
||||||
# |
|
||||||
# !!! WARNING !!! |
|
||||||
# All the commands will be executed with root privileges |
|
@ -0,0 +1,45 @@ |
|||||||
|
# This file lets you configure which sensors will be monitored by Zabbix |
||||||
|
# Sensors defined here will be sent to Zabbix through its low level discovery feature |
||||||
|
# You then have to create discovery rules and prototypes to make use of them |
||||||
|
# |
||||||
|
# This file is in ini format, each sensor has its own block and a set of key/value pair |
||||||
|
# |
||||||
|
# Example: |
||||||
|
# |
||||||
|
# [cpu0] |
||||||
|
# description=Temperature of the first CPU |
||||||
|
# threshold_high=60 |
||||||
|
# threshold_low=50 |
||||||
|
# cmd="/usr/bin/sensors | grep temp1 | cut -d':' -f 2 | awk '{print $1}' | sed -e 's/+//g' -e 's/.C//g'" |
||||||
|
# type=temp |
||||||
|
# unit=°C |
||||||
|
# |
||||||
|
# [mb] |
||||||
|
# description=Motherboard's temperature |
||||||
|
# threshold_high=50 |
||||||
|
# threshold_low=45 |
||||||
|
# cmd="/usr/bin/ipmitool sdr get 'Baseboard Temp' | grep 'Sensor Reading' | awk '{print $4}'" |
||||||
|
# type=temp |
||||||
|
# unit=°C |
||||||
|
# |
||||||
|
# [sda] |
||||||
|
# description=hard drive temperature |
||||||
|
# threshold_high=50 |
||||||
|
# threshold_low=45 |
||||||
|
# cmd="/usr/sbin/smartctl -A /dev/sda | grep Temperature_Celsius | awk '{print $10}'" |
||||||
|
# type=temp |
||||||
|
# unit=°C |
||||||
|
# |
||||||
|
# [fan1] |
||||||
|
# description=front fan |
||||||
|
# threshold_high=12000 |
||||||
|
# threshold_low=1400 |
||||||
|
# cmd="/usr/bin/ipmitool sdr get 'Fan1A RPM' | grep 'Sensor Reading' | awk '{print $4}'" |
||||||
|
# type=fan |
||||||
|
# unit=rpm |
||||||
|
# |
||||||
|
# |
||||||
|
# !!! WARNING !!! |
||||||
|
# * All the commands will be executed with root privileges |
||||||
|
# * If your cmd contains quotes, you must double quote the whole command |
||||||
|
# * If your cmd contains double quotes, you must escape them as \" |
@ -0,0 +1,46 @@ |
|||||||
|
#!/usr/bin/env perl -w |
||||||
|
|
||||||
|
use strict; |
||||||
|
use warnings; |
||||||
|
|
||||||
|
use Config::Simple '-strict'; |
||||||
|
use JSON; |
||||||
|
|
||||||
|
my $old = '/etc/zabbix/sensors.conf'; |
||||||
|
my $new = '/etc/zabbix/sensors.ini'; |
||||||
|
|
||||||
|
my $sensors = {}; |
||||||
|
|
||||||
|
my $units = { |
||||||
|
temp => '°C', |
||||||
|
fan => 'rpm', |
||||||
|
power => 'W' |
||||||
|
}; |
||||||
|
|
||||||
|
open OLDSENSORS, ("<$old") || |
||||||
|
die "Couldn't open $old: $!\n"; |
||||||
|
|
||||||
|
|
||||||
|
foreach (<OLDSENSORS>){ |
||||||
|
next unless (/^(\w+)(\s+)?=(\s+)?(.*)!(\-?\d+)!(\-?\d+)(!(\w+))?$/); |
||||||
|
my ($sensor,$cmd,$threshigh,$threslow,$type) = ($1,$4,$5,$6,$8); |
||||||
|
$type ||= 'temp'; |
||||||
|
$sensors->{$sensor} = { |
||||||
|
description => $sensor, |
||||||
|
cmd => $cmd, |
||||||
|
threshold_high => $threshigh, |
||||||
|
threshold_low => $threslow, |
||||||
|
type => $type, |
||||||
|
unit => $units->{$type} |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
my $cfg = new Config::Simple(syntax => 'ini'); |
||||||
|
|
||||||
|
foreach my $k (keys %$sensors){ |
||||||
|
$cfg->set_block($k, $sensors->{$k}); |
||||||
|
} |
||||||
|
|
||||||
|
$cfg->write($new); |
||||||
|
|
||||||
|
rename $old, $old . '.bak'; |
Loading…
Reference in new issue