From 935490d4905bda99d7aa5a4d2dca5b4f6c84a720 Mon Sep 17 00:00:00 2001 From: dbroqua Date: Sun, 29 Mar 2020 11:09:10 +0200 Subject: [PATCH] Added script for controller and disks temperatures --- smart_array_temperatures | 100 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100755 smart_array_temperatures diff --git a/smart_array_temperatures b/smart_array_temperatures new file mode 100755 index 0000000..c24a2c7 --- /dev/null +++ b/smart_array_temperatures @@ -0,0 +1,100 @@ +#! /bin/bash +: << =cut + +=head1 NAME + +smart_array_temperatures - Plugin to monitor temperature of disks and controller on HP Smart Array. + +=head1 APPLICABLE SYSTEMS + +Only tested on HP Microserver Gen8 with Smart Array P222. + +Maybe works with other HP Prolant Raid cards. + +=head1 CONFIGURATION + +/etc/munin/plugin-conf.d/global or other file in that dir must contain: + +[smart_array_disks_temperature] + user root + +=head1 NOTES + +Uses the command "ssacli" and "hpacucli" (http://hwraid.le-vert.net/wiki/DebianPackages) + +=head1 AUTHOR + +Damien Broqua (https://framagit.org/dbroqua) + +=head1 LICENSE + +GPLv2 + +=head1 MAGIC MARKERS + + #%# family=auto + #%# capabilities=autoconf + +=cut + +IFS=$'\n' + +# Function to list all slots +getSlots () { + list=`ssacli ctrl all show config|grep "Slot"|awk -F'Slot ' '{print $2}'|cut -d' ' -f1` + + return $list +} + +# Function to get disk of one specified slot +getDisks () { + slot=$1 + + list=`ssacli ctrl slot=${slot} pd all show status|grep "physicaldrive"|awk -F 'physicaldrive' '{print $2}'|cut -d ' ' -f2` + for disk in ${list[@]} ; do + if [ "${2}" = "config" ]; then + diskName=`ssacli ctrl slot=${slot} pd ${disk} show detail|grep "Model"|cut -d':' -f2` + + echo "${slot}${disk}CurrentTemperature(C).label (${disk}) ${diskName} " + else + temp=`ssacli ctrl slot=${slot} pd ${disk} show detail|grep 'Current Temperature'` + line="$(echo -e "${temp}" | tr -d '[:space:]'|sed -e "s/:/.value /g")" + echo ${slot}${disk}${line} + fi + done +} + +# Function to get temperatures of one specified slot +getTemperatures () { + slot=$1 + + temps=`hpacucli ctrl slot=${slot} show|grep "Temperature"` + for temp in ${temps[@]}; do + id=`echo ${temp}|cut -d':' -f1| tr -d '[:space:]'` + value=`echo ${temp}|cut -d':' -f2| tr -d '[:space:]'` + label=`echo ${temp}|cut -d':' -f1` + + if [ "${2}" = "config" ]; then + echo "${slot}${id}.label (slot ${slot}) ${label} " + else + echo ${slot}${id}.value ${value} + fi + done +} + +# Config, set graph title +if [ "${1}" = "config" ]; then + echo "graph_title SMART Array temperatures" + echo "graph_vlabel Degrees celcius" + echo "graph_category sensors" +fi + +# Start script by getting list of slots +getSlots +slots=$? + +# For each slot, get disks +for i in ${list[@]} ; do + getDisks $i $1 + getTemperatures $i $1 +done \ No newline at end of file