To monitor HP SMART arrays, I use the hpacucli utility in version 8.x together with a small perl script and a little shell script running in a cronjob. Here is my recipe for redhat based distros (e.g. CentOS 4 / 5):
1) download and install hpacucli rpm from hp homepage (must be version >8.0)
2) create a simple script /etc/zabbix/bin/custom.smartstate and chmod 700 (see below)
3) create a fifo in /root:
cd /root
mkfifo raidstatepipe
4) create a file /etc/cron.hourly/smartstate.cron and chmod 700 (see below)
5) execute /etc/cron.hourly/smartstate.cron and tail /var/log/messages to verify the result
Now your system logs the state of each logical and physical drive to the syslog hourly (for later analysis) and logs the return code to zabbix simultaneously. I have used the key "custom.raidstate" which indicates 0=ok, >0=error.
I hope this is useful for someone else, too.
Regards
--Marcel
/etc/zabbix/bin/custom.smartstate:
#----------------------------------
#!/usr/bin/perl
#
# process output of the command
# /opt/compaq/hpacucli/bld/hpacucli controller all show config
# and generate zabbix events
#
use strict;
use warnings;
my $zabbixserver = $ARGV[0];
my $hostname = $ARGV[1];
my $zabbix_sender = "/usr/sbin/zabbix_sender";
my $term = -1;
while (<STDIN>) {
my $line = $_;
if ($line =~ m/icaldrive/) {
if ($term<1) {
if ($line =~ m/, OK[\)\,]/) {
$term=0;
} else {
$term=1;
};
};
};
};
if ($term >= 0) {
my $cmd = $zabbix_sender." -z ".$zabbixserver." -s ".$hostname." -k custom.raidstate -o ".$term;
my $return = `$cmd`;
};
exit 0;
#-------------------------------
/etc/cron.hourly/smartstate.cron:
(remove the backslashes, put everything except the #!/bin/bash on one line)
(replace zabbix.host.lan by your zabbix server's DNS name or IP address)
(replace zabbix_hostname by the name of your host within ZABBIX)
#-------------------------------
#!/bin/bash
/opt/compaq/hpacucli/bld/hpacucli controller all show config | \
/bin/fgrep icaldrive | /usr/bin/tee /root/raidstatepipe | \
/usr/bin/logger -t raidstate & \
/etc/zabbix/bin/custom.smartstate zabbix.host.lan zabbix_hostname < /root/raidstatepipe
1) download and install hpacucli rpm from hp homepage (must be version >8.0)
2) create a simple script /etc/zabbix/bin/custom.smartstate and chmod 700 (see below)
3) create a fifo in /root:
cd /root
mkfifo raidstatepipe
4) create a file /etc/cron.hourly/smartstate.cron and chmod 700 (see below)
5) execute /etc/cron.hourly/smartstate.cron and tail /var/log/messages to verify the result
Now your system logs the state of each logical and physical drive to the syslog hourly (for later analysis) and logs the return code to zabbix simultaneously. I have used the key "custom.raidstate" which indicates 0=ok, >0=error.
I hope this is useful for someone else, too.
Regards
--Marcel
/etc/zabbix/bin/custom.smartstate:
#----------------------------------
#!/usr/bin/perl
#
# process output of the command
# /opt/compaq/hpacucli/bld/hpacucli controller all show config
# and generate zabbix events
#
use strict;
use warnings;
my $zabbixserver = $ARGV[0];
my $hostname = $ARGV[1];
my $zabbix_sender = "/usr/sbin/zabbix_sender";
my $term = -1;
while (<STDIN>) {
my $line = $_;
if ($line =~ m/icaldrive/) {
if ($term<1) {
if ($line =~ m/, OK[\)\,]/) {
$term=0;
} else {
$term=1;
};
};
};
};
if ($term >= 0) {
my $cmd = $zabbix_sender." -z ".$zabbixserver." -s ".$hostname." -k custom.raidstate -o ".$term;
my $return = `$cmd`;
};
exit 0;
#-------------------------------
/etc/cron.hourly/smartstate.cron:
(remove the backslashes, put everything except the #!/bin/bash on one line)
(replace zabbix.host.lan by your zabbix server's DNS name or IP address)
(replace zabbix_hostname by the name of your host within ZABBIX)
#-------------------------------
#!/bin/bash
/opt/compaq/hpacucli/bld/hpacucli controller all show config | \
/bin/fgrep icaldrive | /usr/bin/tee /root/raidstatepipe | \
/usr/bin/logger -t raidstate & \
/etc/zabbix/bin/custom.smartstate zabbix.host.lan zabbix_hostname < /root/raidstatepipe
Comment