This shows you the differences between two versions of the page.
monitor_snmpd_for_cacti [2011/04/13 03:59] k2patel created |
monitor_snmpd_for_cacti [2020/08/10 02:35] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Monitor SNMPD for all cacti host ====== | ||
- | This script will test SNMPD against all host in cacti database. | ||
- | |||
- | <code bash> | ||
- | #!/bin/bash | ||
- | # Powered by k2patel :) | ||
- | # please send suggestion to k2patel@hotmail.com | ||
- | |||
- | ################################################# | ||
- | ### ### | ||
- | ### MySQL Information used on Cacti ### | ||
- | ################################################# | ||
- | sqlu=<mysql_user> | ||
- | sqlp=<mysql_pass> | ||
- | sqld=<mysql_database> | ||
- | |||
- | ################################################# | ||
- | ### ### | ||
- | ### List of person / group notified on faliur ### | ||
- | ################################################# | ||
- | |||
- | export receipients="test@k2.com test@notify.com" | ||
- | |||
- | ##################################################### | ||
- | ### ### | ||
- | ### Folloving variable defines the skipped Host ### | ||
- | ##################################################### | ||
- | |||
- | hstskip=(test.dummy.com test.dummy.net) | ||
- | |||
- | |||
- | ################################################### | ||
- | ### ### | ||
- | ### Variables Used in System ### | ||
- | ################################################### | ||
- | |||
- | timeout=5 | ||
- | isskip=0 | ||
- | |||
- | export prefix=/usr/lib64/nagios | ||
- | export PATH=$PATH:/usr/lib64/nagios/plugins:/usr/local/bin:/bin | ||
- | |||
- | |||
- | |||
- | #$$$$$$$$$$$$$$$ END Of Customization $$$$$$$$$$$$$$$$$$$$ | ||
- | |||
- | |||
- | |||
- | notify(){ | ||
- | for n in $receipients; do | ||
- | echo $1 | /bin/mail -s "[SNMPD] on $i Failed" $n | ||
- | done | ||
- | } | ||
- | |||
- | for i in `mysql -N -u $sqlu -p$sqlp -e "select hostname from $sqld.host"`; do | ||
- | for k in ${hstskip[@]}; do | ||
- | if [ $i == $k ]; then | ||
- | isskip=1 | ||
- | fi | ||
- | done | ||
- | if [ $isskip -eq 1 ]; then | ||
- | echo "Skipped $i" | ||
- | isskip=0 | ||
- | else | ||
- | echo Running check_snmp -C public -H $i -P 2c -o system -t $timeout | ||
- | check_snmp -C public -H $i -P 2c -o system -t $timeout | ||
- | status=$? | ||
- | echo | ||
- | if [ $status -ne 0 ]; then | ||
- | notify "SNMPD failure, Please login to box and try to start SNMPD " | ||
- | else | ||
- | echo "Status OK" | ||
- | fi | ||
- | fi | ||
- | done | ||
- | </code> |