nagios脚本监控硬盘故障
来自:网络
#!/usr/bin/perl
use strict;
use warnings;
use lib "/usr/lib64/nagios/plugins"; nagios安装
use utils qw(%ERRORS);
my $usage = "
Usage: $0 host_addr ipmi_user ipmi_pass
Connects to a Dell BMC and parses the Drive token for RAID status
and disk slot errors.";
if (my $result = `/usr/bin/ipmitoolchassis status 2>/dev/null `) { 开源监控软件
my $err_lvl = 0;
my $status="";
my $key="";
foreach my $line (split /\n/s, $result){
if (my @fields = split(/:/,$line)){ nagios配置
# print $fields;
# print $fields;
chomp($status = $fields);
chomp($key = $fields);
if($key =~ m/Drive(\s+)Fault/g ){
if ( $status =~ m/true/g){
$err_lvl++; 监控软件
}
}
}
}
if ($err_lvl > 0) {
print "CRITICAL: Hard Disk is Fault\n";
exit $ERRORS{'CRITICAL'}
} else {
print "OK: Hard Disks is ok \n";
exit $ERRORS{'OK'} nagios实施
}
} else {
可以用。能及时发现硬盘的故障
然后可以用
ipmitool sel listnagios培训
检查日志
想做Nagios, Zabbix,Cacti,iTop各种交流的,可以进入开源监控工具Nagios交流QQ群号 :476809427
页:
[1]