#!/bin/bash #Roy Cohen :roy@wondercohen.nl #objective :Gluster check bricks for Nagios #First line of code :15/01/2019 #last update :28/01/2019 #version :1.1 ######START OF SCRIPT####### IP_OF_DOWN_BRICK=$(cat /tmp/brick_status |grep -v "Self-heal" | grep -E 'Brick|N/A|N' |grep -v "Y"| grep -B1 "N/A" | grep Brick| uniq | cut -d ":" -f1| cut -d " " -f2) NUMBER_OF_DOWN_BRICKS=$(cat /tmp/brick_status |grep -v "Self-heal" | grep -E 'Brick|N'|grep "N/A"| awk '{print $4}'|grep N |wc -l) if [[ $(find /tmp -name "brick_status" -mmin +4 -print) ]]; then echo "WARNING: there was an error during the gluster birck check. please check the output of /root/scripts/check_gluster.sh or the nrpe status" exit 1 # check number of active bricks elif [ "$NUMBER_OF_DOWN_BRICKS" -eq 0 ] ; then echo "OK: All bricks on are up" exit 0 else echo "CRITICAL: There are one or more bricks down on $IP_OF_DOWN_BRICK" exit 2 fi