5.02021-11-25T12:36:39ZTemplatesESXi HP Smart ArrayESXi HP Smart ArrayTemplatesHP Smart Array- Smart Array: Data RetrievalSSHssh.run[hpraid.data.retrieval]6000TEXTdata_tmp="/tmp/hp-raid-data-harvester.tmp"
data_out="/tmp/hp-raid-data-harvester.out"
hpacucli="/opt/hp/hpssacli/bin/hpssacli"
ctrl_list=$(${hpacucli} ctrl all show |grep -oE 'Slot [0-9]+.*?' |awk '{print $2}' |xargs echo)
echo -n > $data_tmp
# Get adapters list and get info about each.
echo "### ctrl section begin ###" >> $data_tmp
for slot in $ctrl_list;
do
echo "### ctrl begin $slot ###" >> $data_tmp
$hpacucli ctrl slot=$slot show >> $data_tmp
echo "### ctrl end $slot ###" >> $data_tmp
done
echo "### ctrl section end ###" >> $data_tmp
# enumerate all adapters and all logical drives on each adapter.
echo "### ld section begin ###" >> $data_tmp
for slot in $ctrl_list;
do
ld_list=$($hpacucli ctrl slot=$slot ld all show |grep -w logicaldrive |awk '{print $2}' |xargs echo)
for ld in $ld_list;
do
echo "### ld begin $slot $ld ###" >> $data_tmp
$hpacucli ctrl slot=$slot ld $ld show >> $data_tmp
echo "### ld end $slot $ld ###" >> $data_tmp
done
done
echo "### ld section end ###" >> $data_tmp
# enumerate all adapters and all physical drives on each adapter.
echo "### pd section begin ###" >> $data_tmp
for slot in $ctrl_list;
do
pd_list=$($hpacucli ctrl slot=$slot pd all show |grep -w physicaldrive |awk '{print $2}' |xargs echo)
for pd in $pd_list;
do
echo "### pd begin $slot $pd ###" >> $data_tmp
$hpacucli ctrl slot=$slot pd $pd show >> $data_tmp
echo "### pd end $slot $pd ###" >> $data_tmp
done
done
echo "### pd section end ###" >> $data_tmp
mv $data_tmp $data_out
echo "OK"{$ZABBIX_SSH_USER}{$ZABBIX_SSH_PASS}HP Smart Array
Controllers DiscoverySSHssh.run[hpraid.ctrl.discovery]86400data="/tmp/hp-raid-data-harvester.out"
if [ -f "$data" ]; then
ctrl_list=$(sed -n -e '/ctrl section begin/,/ctrl section end/p' $data |grep -oE 'Slot [0-9]+.*?' |awk '{print $2}')
else echo "$data not found."; exit 1
fi
echo -n '{"data":['
for ctrl in $ctrl_list; do echo -n "{\"{#CTRL_SLOT}\": \"$ctrl\"},"; done |sed -e 's:\},$:\}:'
echo -n ']}'{$ZABBIX_SSH_USER}{$ZABBIX_SSH_PASS}{#CTRL_SLOT}A0Smart Array: Battery status on slot {#CTRL_SLOT}SSHssh.run[hpraid.bbu.status.{#CTRL_SLOT}]216007d0TEXToutput=$(sed -n -e "/ctrl begin {#CTRL_SLOT}/,/ctrl end {#CTRL_SLOT}/p" /tmp/hp-raid-data-harvester.out |grep -wE "[ ]+Battery/Capacitor Status:" |awk '{print $3}')
if [ -z $output ]; then
echo "Not available"
else
echo "$output"
fi{$ZABBIX_SSH_USER}{$ZABBIX_SSH_PASS}HP Smart Array{regexp(OK|Not available)}=0Smart Array: Controller Battery in slot {#CTRL_SLOT} state is {ITEM.LASTVALUE}HIGHSmart Array: Cache $2 status on slot {#CTRL_SLOT}SSHssh.run[hpraid.cache.status.{#CTRL_SLOT}]216007d0TEXToutput=$(sed -n -e "/ctrl begin {#CTRL_SLOT}/,/ctrl end {#CTRL_SLOT}/p" /tmp/hp-raid-data-harvester.out |grep -wE "[ ]+Cache Status:" |awk '{print $3}')
if [ -z $output ]; then
echo "Not available"
else
echo "$output"
fi{$ZABBIX_SSH_USER}{$ZABBIX_SSH_PASS}HP Smart Array{regexp(OK|Not available)}=0Smart Array: Controller Cache in slot {#CTRL_SLOT} state is {ITEM.LASTVALUE}HIGHSmart Array: Controller status on slot {#CTRL_SLOT}SSHssh.run[hpraid.ctrl.status.{#CTRL_SLOT}]216007d0TEXTsed -n -e "/ctrl begin {#CTRL_SLOT}/,/ctrl end {#CTRL_SLOT}/p" /tmp/hp-raid-data-harvester.out |grep -wE "[ ]+Controller Status:" |awk '{print $3}'{$ZABBIX_SSH_USER}{$ZABBIX_SSH_PASS}HP Smart Array{regexp(OK)}=0Smart Array: Controller in slot {#CTRL_SLOT} state is {ITEM.LASTVALUE}HIGH{nodata(24h)}=1Smart Array: No controller data received for >24hHIGHLogical Volumes DiscoverySSHssh.run[hpraid.ld.discovery]21600data="/tmp/hp-raid-data-harvester.out"
if [ -f $data ]; then
ld_list=$(sed -n -e '/ld section begin/,/ld section end/p' $data |grep -w 'ld begin' |awk '{OFS=":"} {print $4,$5}')
else echo "$data not found."; exit 1
fi
echo -n '{"data":['
for ld in $ld_list; do echo -n "{\"{#LD}\":\"$ld\"},"; done |sed -e 's:\},$:\}:'
echo -n ']}'{$ZABBIX_SSH_USER}{$ZABBIX_SSH_PASS}{#LD}A0Logical volume $1 statusSSHssh.run[hpraid.ld.status.{#LD}]6007d0TEXTslot=$(echo "{#LD}" | cut -d ":" -f 1)
ld=$(echo "{#LD}" | cut -d ":" -f 2)
sed -n -e "/ld begin $slot $ld/,/ld end $slot $ld/p" /tmp/hp-raid-data-harvester.out |grep -wE "[ ]+Status:" |awk '{print $2}'{$ZABBIX_SSH_USER}{$ZABBIX_SSH_PASS}HP Smart Array{str(OK)}=0Smart Array: Logical Volume state is {ITEM.LASTVALUE} on {HOSTNAME}HIGHPhysical Drives DiscoverySSHssh.run[hpraid.pd.discovery]86400data="/tmp/hp-raid-data-harvester.out"
if [ -f $data ]; then
pd_list=$(sed -n -e '/pd section begin/,/pd section end/p' $data |grep -w 'pd begin' |awk '{OFS=":"} {print $4,$5}')
else echo "$data not found."; exit 1
fi
echo -n '{"data":['
for pd in $pd_list; do echo -n "{\"{#PD}\":\"$pd\"},"; done |sed -e 's:\},$:\}:'
echo -n ']}'{$ZABBIX_SSH_USER}{$ZABBIX_SSH_PASS}{#PD}A0Physical drive {#PD} statusSSHssh.run[hpraid.pd.status.{#PD}]6007d0TEXTslot=$(echo "{#PD}" | cut -d ":" -f 1)
pd=$(echo "{#PD}" | cut -d ":" -f 2-)
sed -n -e "/pd begin $slot $pd/,/pd end $slot $pd/p" /tmp/hp-raid-data-harvester.out |grep -wE '[ ]+Status:' |awk '{print $2}'{$ZABBIX_SSH_USER}{$ZABBIX_SSH_PASS}HP Smart Array{str(OK)}=0Smart Array: Disk state is {ITEM.LASTVALUE} on {HOSTNAME}HIGHPhysical drive {#PD} temperatureSSHssh.run[hpraid.pd.temperature.{#PD}]6007dslot=$(echo "{#PD}" | cut -d ":" -f 1)
pd=$(echo "{#PD}" | cut -d ":" -f 2-)
sed -n -e "/pd begin $slot $pd/,/pd end $slot $pd/p" /tmp/hp-raid-data-harvester.out |grep -wE '[ ]+Current Temperature \(C\):' |awk '{print $4}'{$ZABBIX_SSH_USER}{$ZABBIX_SSH_PASS}HP Smart Array{$ZABBIX_SSH_PASS}zabbixPassword{$ZABBIX_SSH_USER}zabbixUsername