#!/bin/bash #Panzura Space Usage check #by George Pereira #Email: firstnameabove_lastnameabove(at)gensler.com version () { echo "check_panzura Version 0.89" exit } usage () { echo "Usage: $0 -H -C -t -w -c | -h | -V ------------------------------------------------------------------------------ Options: -H The hostname or IP address of the panzura unit. -C The SNMP community name. Default is "public". -t Storage type to check. Either local or cloud (case sensitive) -w The warning threshold (in % used, number only) -c The critical threshold (in % used, number only) -h Shows this help screen. -V Shows the current version. Example: $0 -H 192.168.1.2 -C public -t local -w 85 -c 90 Will warn if the % used of the local or cloud disk space is above 85%, and critical if it's above 90% ------------------------------------------------------------------------------" exit } community="public" while getopts "H:VC:t:w:c:h" opt; do case $opt in H) hostname=$OPTARG;; V) version;; C) community=$OPTARG;; t) type=$OPTARG;; w) warning=$OPTARG;; c) critical=$OPTARG;; h) usage;; *) usage;; esac done shift $((OPTIND-1)) if [[ -n "$community" && -n "$hostname" && -n "$type" && -n "$warning" && -n "$critical" ]] ; then if [[ "$type" == "local" ]]; then panzuraHDused=$(snmpget -v2c -Ovq -c $community $hostname 1.3.6.1.4.1.32853.1.3.1.3.1.0 2>/dev/null) panzuraHDtotal=$(snmpget -v2c -Ovq -c $community $hostname 1.3.6.1.4.1.32853.1.3.1.3.3.0 2>/dev/null) ttype=$(echo "LocalHD") fi if [[ "$type" == "cloud" ]]; then panzuraHDused=$(snmpget -v2c -Ovq -c $community $hostname 1.3.6.1.4.1.32853.1.3.1.4.1.0 2>/dev/null) panzuraHDtotal=$(snmpget -v2c -Ovq -c $community $hostname 1.3.6.1.4.1.32853.1.3.1.4.3.0 2>/dev/null) ttype=$(echo "CloudHD") fi if [[ -n "$panzuraHDused" && -n "$panzuraHDtotal" ]]; then used=$(printf '%.2f\n' $(echo "100 * ($panzuraHDused / $panzuraHDtotal)"|bc -l)) free=$(printf '%.2f\n' $(echo "100 - $used"|bc -l)) usedGB=$(printf '%.2f\n' $(echo "($panzuraHDused / 1024) / 1024"|bc -l)) totalGB=$(printf '%.2f\n' $(echo "($panzuraHDtotal / 1024) / 1024"|bc -l)) if [ $(echo "$used >= $critical" | bc) -eq 1 ] then echo "CRITICAL - $ttype usage: $usedGB / $totalGB GB ($used%)|$ttype=$used%;$warning;$critical" exit 2 elif [ $(echo "$used >= $warning" | bc) -eq 1 ] then echo "WARNING - $ttype usage: $usedGB / $totalGB GB ($used%)|$tttpe=$used%;$warning;$critical" exit 1 elif [ $(echo "$used < $warning" | bc) -eq 1 ] then echo "OK - $ttype usage: $usedGB / $totalGB GB ($used%)|LocalHD=$used%;$warning;$critical" exit 0 else echo "UNKNOWN - $ttype usage: $usedGB / $totalGB GB ($used%)|LocalHD=$used%;$warning;$critical" exit 3 fi else echo "UNKNOWN - Check host/community name" exit 3 fi else usage fi