|
|
@ -4,6 +4,7 @@ use strict; |
|
|
|
use warnings; |
|
|
|
use warnings; |
|
|
|
use Config::Simple '-strict'; |
|
|
|
use Config::Simple '-strict'; |
|
|
|
use Getopt::Long; |
|
|
|
use Getopt::Long; |
|
|
|
|
|
|
|
use File::Which; |
|
|
|
use File::Basename; |
|
|
|
use File::Basename; |
|
|
|
use Zabbix::Agent::Addons::Disks; |
|
|
|
use Zabbix::Agent::Addons::Disks; |
|
|
|
use Zabbix::Agent::Addons::UPS; |
|
|
|
use Zabbix::Agent::Addons::UPS; |
|
|
@ -53,16 +54,16 @@ unless ($output){ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
# Path |
|
|
|
# Path |
|
|
|
my $ipmitool = '/usr/bin/ipmitool'; |
|
|
|
my $ipmitool = which('ipmitool'); |
|
|
|
my $smartctl = '/usr/sbin/smartctl'; |
|
|
|
my $smartctl = which('smartctl'); |
|
|
|
my $upsc = '/usr/bin/upsc'; |
|
|
|
my $upsc = which('upsc'); |
|
|
|
|
|
|
|
|
|
|
|
my $cfg = new Config::Simple(syntax => 'ini'); |
|
|
|
my $cfg = new Config::Simple(syntax => 'ini'); |
|
|
|
|
|
|
|
|
|
|
|
my $sensors = {}; |
|
|
|
my $sensors = {}; |
|
|
|
|
|
|
|
|
|
|
|
# Try to detect IPMI sensors |
|
|
|
# Try to detect IPMI sensors |
|
|
|
if (-x $ipmitool){ |
|
|
|
if ($ipmitool && -x $ipmitool){ |
|
|
|
# First check for temperature sensors |
|
|
|
# First check for temperature sensors |
|
|
|
my @lines = qx($ipmitool sdr type Temperature); |
|
|
|
my @lines = qx($ipmitool sdr type Temperature); |
|
|
|
if ($? == 0){ |
|
|
|
if ($? == 0){ |
|
|
@ -182,10 +183,10 @@ if (-x $ipmitool){ |
|
|
|
next SENSOR; |
|
|
|
next SENSOR; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
elsif ($d =~ m/^\s*Upper\scritical\s*:\s*(\d+(\.\d+))/){ |
|
|
|
elsif ($d =~ m/^\s*Upper\scritical\s*:\s*(\d+(\.\d+)?)/){ |
|
|
|
$sensor->{threshold_high} = $1-$pwr_margin; |
|
|
|
$sensor->{threshold_high} = $1-$pwr_margin; |
|
|
|
} |
|
|
|
} |
|
|
|
elsif ($d =~ m/^\s*Upper\snon\-critical\s*:\s*(\d+(\.\d+))/){ |
|
|
|
elsif ($d =~ m/^\s*Upper\snon\-critical\s*:\s*(\d+(\.\d+)?)/){ |
|
|
|
$sensor->{threshold_low} = $1-$pwr_margin; |
|
|
|
$sensor->{threshold_low} = $1-$pwr_margin; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -207,7 +208,7 @@ if (-x $ipmitool){ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
# Now, try to detect smart capable HDD |
|
|
|
# Now, try to detect smart capable HDD |
|
|
|
if (-x $smartctl){ |
|
|
|
if ($smartctl && -x $smartctl){ |
|
|
|
foreach my $block (Zabbix::Agent::Addons::Disks::list_smart_hdd({ skip_remouvable => 1 })){ |
|
|
|
foreach my $block (Zabbix::Agent::Addons::Disks::list_smart_hdd({ skip_remouvable => 1 })){ |
|
|
|
my @lines = qx($smartctl -A /dev/$block); |
|
|
|
my @lines = qx($smartctl -A /dev/$block); |
|
|
|
next if ($? != 0); |
|
|
|
next if ($? != 0); |
|
|
@ -252,7 +253,7 @@ if (-x $smartctl){ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
# Now check UPS |
|
|
|
# Now check UPS |
|
|
|
if (-x $upsc){ |
|
|
|
if ($upsc && -x $upsc){ |
|
|
|
foreach my $ups (Zabbix::Agent::Addons::UPS::list_ups()){ |
|
|
|
foreach my $ups (Zabbix::Agent::Addons::UPS::list_ups()){ |
|
|
|
my @lines = qx($upsc $ups); |
|
|
|
my @lines = qx($upsc $ups); |
|
|
|
next if ($? != 0); |
|
|
|
next if ($? != 0); |
|
|
|