Tracking Solr Replication Delay via Scout or Sheriff

We now keep track of our solr replication delay, maybe you should too ;)

Works with scout-app or sheriff(free/self-hosted)

class SolrReplication < Scout::Plugin
  needs 'open-uri'

  OPTIONS=<<-EOS
    master:
      default: http://192.168.2.114:8983
    slave:
      default: http://localhost:8765
  EOS

  def build_report
    replication_path = '/solr/admin/replication/index.jsp'
    rex = /Generation: (\d+)/
    master = open(option(:master)+replication_path).read.match(rex)[1]
    slave = open(option(:slave)+replication_path).read.match(rex)[1]
    if master and slave
      report 'delay' => master.to_i - slave.to_i
    else
      error "Incorrect values found master:#{master} slave:#{slave}"
    end
  end
end

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s