#!/bin/bash #Roy Cohen :roy@wondercohen.nl #objective :Gluster check peer for Nagios #First line of code :15/01/2019 #last update :31/01/2019 #version :1.0 ######START OF SCRIPT####### SATE_OF_DOWN_PEER=$(cat /tmp/peer_status | grep -a Disconnected | wc -l) IP_OF_DOWN_PEER=$(cat /tmp/peer_status| grep -a -E "Hostname|Disconnected"| grep -a -B1 Disconnected | grep -a Hostname | cut -d ":" -f2| sed "s/^[ \t]*//") if [[ $(find /tmp -name "peer_status" -mmin +4 -print) ]]; then echo "WARNING: there was an error during the gluster peer check. please check the output of /root/scripts/check_gluster.sh or the nrpe status" exit 1 # check number of active bricks elif [ "$SATE_OF_DOWN_PEER" -eq 0 ] ; then echo "OK: All bricks on are up" exit 0 else echo "CRITICAL: There are one or more peers down on $IP_OF_DOWN_PEER" exit 2 fi