DZone
Java Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Java Zone > Poor Man's Monitoring for Solr

Poor Man's Monitoring for Solr

Peter Karussell user avatar by
Peter Karussell
·
Nov. 26, 10 · Java Zone · Interview
Like (0)
Save
Tweet
7.25K Views

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.

Popular on DZone

  • An Overview of 3 Java Embedded Databases
  • The Most Popular Kubernetes Alternatives and Competitors
  • Is Java Still Relevant?
  • 10 Steps to Become an Outstanding Java Developer

Comments

Java Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo