Below is the script to monitor the Cassandra Database nodes with nodetool status command.
Schedule to run the script at certain frequency with crontab, possible every 5 Minutes.
#!/bin/bash ####### # Author : Pramod P # Purpose: Monitor Cassandra instance # Date : Created Date ####### PRIMARY_DBA="primary@primary.com" ON_CALL_DBA="oncall@oncall.com" #Create a temporary file with under maintenance with empty content. And uncomment below line when doing some maintenance. #$MAINT_LOC=/path/to/tmpfile #Monitor if the node is under maintenance. if [ -f $MAINT_LOC/under_maintenance ] then echo "===========================" echo "$MAINT_LOC/under_maintenance file exists." echo "Monitoring script detected so Cassandra instance is in maintenance mode. Cassandra will not be monitored." exit 1 fi # Monitor Cassandra nodes by nodetool. DOWN_NO=`/usr/bin/nodetool status | grep UD | wc -l` echo $DOWN_NO if [ $DOWN_NO -gt 0 ] then DOWN_HOST=`/usr/bin/nodetool status | grep UD | awk '{print $2}'` printf "\n\nCassandra Instance is not running on $DOWN_HOST" | mail -s "Attention >> Cassandra Instance is down on Production" $PRIMARY_DBA $ON_CALL_DBA exit 1 fi
***
No comments:
Post a Comment