check_fuer_hp_smart_array_controller

Check für HP Smart Array Controller

Benötigt hpacucli und läuft nur als Bash-Script.

Getestet mit: P410, P410i, P210

Download: http://downloads.linux.hp.com/SDR/downloads/ProLiantSupportPack/

Leider ist der Check sehr langsam obwohl das Script so gut optimiert ist wie es mir möglich ist. Es leigt in erstere Linie an dem „hpacucli“ welches wirklich nicht als schnell bezeichnet werden kann.

Update: Auf Anregung von Marco S. prüft der Check jetzt auch Batterie- und Cache-Status.

Empfehlung: Ausführung 5 Minuten asynchron.

#!/bin/bash

# check_mk check f. HP Smart Array Controller
#
# 01/2011 Matthias Henze
# Lizenz: GPL v2

# sample output - requires hpacucli
#
#
# hpacucli controller all show 
#
#Smart Array P410 in Slot 4                (sn: PACCR9SY0AXY  )
#
#
# hpacucli controller slot=4 array all show 
#
#Smart Array P410 in Slot 4
#
#   array A (SATA, Unused Space: 0 MB)
#
#
# hpacucli controller slot=4 array A physicaldrive all show
#
#Smart Array P410 in Slot 4
#
#   array A
#
#      physicaldrive 1I:1:1 (port 1I:box 1:bay 1, SATA, 500 GB, OK)
#      physicaldrive 1I:1:2 (port 1I:box 1:bay 2, SATA, 500 GB, OK)
#      physicaldrive 1I:1:3 (port 1I:box 1:bay 3, SATA, 500 GB, OK)
#      physicaldrive 1I:1:4 (port 1I:box 1:bay 4, SATA, 500 GB, OK, spare)
#

function is_integer() {
    [ "$1" -eq "$1" ] > /dev/null 2>&1
    return $?
}

if [ -x `which /usr/sbin/hpacucli` ]; then

  echo '<<<hpsa_controller>>>'
  cc=-1
  CMD="hpacucli controller all show"
  while read -a cont; do
    if is_integer ${cont[5]}; then
      cc=$(($cc+1))
      cstat=$(hpacucli controller slot=${cont[5]} show | egrep "Controller Status|Cache Status|Battery.*Status"|cut -d " " -f 3,6,9|tr -d '\n')
      case $(echo $cstat | wc -w) in
         1)
           cstat=$cstat" Not Not"
           ;;
         2)
           cstat=$cstat" Not"
           ;;
      esac
      if [ "$cstat" = " OK OK OK" -o "$cstat" = " OK OK Not" -o "$cstat" = " OK Not Not" ]; then
        echo "${cont[5]} OK ${cont[2]}$cstat"
      else
        echo "${cont[5]} CRIT ${cont[2]}$cstat"
      fi
      controllers[$cc]=${cont[5]}
    fi
  done < <( $CMD )

  echo '<<<hpsa_array>>>'
  for c in $(seq 0 $cc)
  do
    ac=-1
    CMD="hpacucli controller slot=${controllers[$c]} array all show"
    while read -a cary; do
      if [ "X${cary[0]}X" = "XarrayX" ]; then
        ac=$(($ac+1))
        # collect lines
        read -d + -a x <<< $(hpacucli controller slot=${controllers[$c]} array ${cary[1]} show | sed 's/(Embedded)//')
        # collect words
        read -a ary <<< ${x[*]}
        echo "${controllers[$c]}:${cary[1]} ${ary[16]} ${ary[10]} unused: ${ary[13]} ${ary[14]}"
        arrays[$ac]=${cary[1]}
      fi
    done < <( $CMD )
  done

  echo '<<<hpsa_drive>>>'
  for c in $(seq 0 $cc)
  do
    for a in $(seq 0 $ac)
    do
      CMD="hpacucli controller slot=${controllers[$c]} array ${arrays[$a]} physicaldrive all show"
      while read -a pdrv; do
        if [ "X${pdrv[0]}X" = "XphysicaldriveX" ]; then
          echo -n "${controllers[$c]}:${arrays[$a]}:${pdrv[1]} ${pdrv[9]/[),]/} ${pdrv[6]/,/} ${pdrv[7]} ${pdrv[8]/,/} "
          if [ ${pdrv[10]} ]; then 
            echo ${pdrv[10]/)/}
          else
            echo "assigned"
          fi
        fi
      done < <( $CMD )
    done
  done
fi

#!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-

# check_mk check f. HP Smart Array Controller
#
# 01/2011 Matthias Henze
# Lizenz: GPL v2


# Example output from agent:
# <<<hpsa>>>
# 4 OK PACCR9SY0AXY P410

# inventory
def inventory_hpsa_controller(checkname, info):
    inventory = []
    for line in info:
 	item = line[0]
	inventory.append( (item, None) )
    return inventory

# check
def check_hpsa_controller(item, param, info):
    for line in info:
        if line[0] == item:
            status = line[1]
            type = line[2]
            controller = line[3]
            cache = line[4]
            battery = line[5]
            infotext = "status is %s  (Slot: %s, Type: %s, Controller: %s, Cache: %s, Battery: %s)" % (status, item, type, controller, cache, battery)
            if status == "OK":
                return (0, "OK - " + infotext)
            else:
                return (2, "CRITICAL - " + infotext)
    return (3, "UNKNOWN - Controller %s not found in agent output" % item) 

# declare the check to Check_MK
check_info['hpsa_controller'] = \
	(check_hpsa_controller, "HP Smart Array Controller Slot %s", 1, inventory_hpsa_controller)

#!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-

# check_mk check f. HP Smart Array Controller
#
# 01/2011 Matthias Henze
# Lizenz: GPL v2


# Example output from agent:
# <<<hpsa_array>>>
# 4:A OK SATA 0 MB


# inventory
def inventory_hpsa_array(checkname, info):
    inventory = []
    for line in info:
 	item = line[0]
	inventory.append( (item, None) )
    return inventory

# check
def check_hpsa_array(item, param, info):
    for line in info:
        if line[0] == item:
            hw = item.split(":")
            slot = hw[0]
            array = hw[1]
            status = line[1]
            type = line[2]
            free = line[3]
            unit = line[4]
            infotext = "status is %s  (slot: %s, array: %s, type: %s free: %s %s)" % (status, slot, array, type, free, unit)
            if status == "OK":
                return (0, "OK - " + infotext)
            else:
                return (2, "CRITICAL - " + infotext)
    return (3, "UNKNOWN - Array %s not found in agent output" % item) 

# declare the check to Check_MK
check_info['hpsa_array'] = \
	(check_hpsa_array, "HP Smart Array Controller Array %s", 1, inventory_hpsa_array)

#!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-

# check_mk check f. HP Smart Array Controller
#
# 01/2011 Matthias Henze
# Lizenz: GPL v2


# Example output from agent:
# <<<hpsa_drive>>>
# 4:A:1I:1:1 OK SATA 500 GB assigned
# 4:A:1I:1:2 OK SATA 500 GB assigned
# 4:A:1I:1:3 OK SATA 500 GB assigned
# 4:A:1I:1:4 OK SATA 500 GB spare



# inventory
def inventory_hpsa_drive(checkname, info):
    inventory = []
    for line in info:
 	item = line[0]
	inventory.append( (item, None) )
    return inventory

# check
def check_hpsa_drive(item, param, info):
    for line in info:
        if line[0] == item:
            hw = item.split(":")
            slot = hw[0]
            array = hw[1]
            port = hw[2]
            box = hw[3]
            bay = hw[4]
            status = line[1]
            type = line[2]
            free = line[3]
            unit = line[4]
            usage = line[5]
            infotext = "status is %s  (slot: %s, array: %s, port: %s, box: %s, bay: %s, type: %s size: %s %s, usage: %s)" % (status, slot, array, port, box, bay, type, free, unit, usage)
            if status == "OK":
                return (0, "OK - " + infotext)
            else:
                return (2, "CRITICAL - " + infotext)
    return (3, "UNKNOWN - Array %s not found in agent output" % item) 

# declare the check to Check_MK
check_info['hpsa_drive'] = \
	(check_hpsa_drive, "HP Smart Array Controller Drive %s", 1, inventory_hpsa_drive)

  • check_fuer_hp_smart_array_controller.txt
  • Zuletzt geändert: 2017/03/17 12:37
  • (Externe Bearbeitung)