Over a million developers have joined DZone.

Poor Man's Monitoring for Solr

DZone's Guide to

Poor Man's Monitoring for Solr

· Java Zone ·
Free Resource

FlexNet Code Aware, a free scan tool for developers. Scan Java, NuGet, and NPM packages for open source security and open source license compliance issues.

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/
SUBJECT="OK: jetwick"

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"

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"
echo CRITICAL > .status
if [ "$PREV_STAT" == "CRITICAL" ]; then
cat $FILE | mail $EMAILS -a $FILE -s "SOLVED: http://your-host.com/solr"
echo OK > .status

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/

 Scan Java, NuGet, and NPM packages for open source security and license compliance issues. 


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}