Poor Man's Monitoring for Solr
Join the DZone community and get the full member experience.
Join For Free
as well as being the developer and pr agent for
jetwick
, sadly i'm also the admin
. all in one... at once. here is a minor snippet to get an alert email if
your solr index is either not available or contains too few entries. you'llĀ get a resolved mail if all is fine again.
cd /path/
file=bla.log
emails="your@email.here"
subject="ok: jetwick"
status=ok
cnt=`wget --http-user=user --http-password=password -t 10 -q "http://your-host.com/solr/select?q=&rows=1&wt=json" -o - | tr ',' '\n' |grep numfound|tr ':' ' '|awk '{print $3}'`
if [ "x$cnt" == x ] || [ "$cnt" -lt 500000 ]; then
subject="critical: check http://your-host.com/solr"
status=critical
fi
prev_stat=`cat .status`
if [ "$status" == "critical" ]; then
if [ "$prev_stat" == "ok" ]; then
cat $file | mail $emails -a $file -s "$subject. doc count was only $cnt"
fi
echo critical > .status
else
if [ "$prev_stat" == "critical" ]; then
cat $file | mail $emails -a $file -s "solved: http://your-host.com/solr"
fi
echo ok > .status
fi
echo $status > .status
add via this via crontab -e
*/2 * * * * /path/check-health.sh
if you look at the code there is one mini hack which is necessary if the solr index is down and the cnt is empty:
"x$cnt" == x
from
http://karussell.wordpress.com/2010/11/25/poor-men-monitoring-for-solr/
Snippet (programming)
Hack (falconry)
dev
Mail (Apple)
Opinions expressed by DZone contributors are their own.
Comments