Skip to main content

Solr Replication Monitoring

in this examle i am going to use php for getting solr index replication xml and parsing it. There are two urls. One is inicating master solr server's status, second one is indicating slave solr server's status.

Urls are like:
http://<master server ip>:8080/solr/admin/cores
http://<slave server ip>:8080/solr/admin/cores


php code is:

<?php

@require_once ('stil1.css');

// set name of XML file 
$source1 = "http://<master ip>:8080/solr/admin/cores"; 
$source2 = "http://<slave ip>:8080/solr/admin/cores"; 

// load file 
$xml1 = new SimpleXMLElement($source1,null,true);
$xml2 = new SimpleXMLElement($source2,null,true);

?>
<div style="float: left">
   <table class="liste">
<tr>
<th colspan=2>Master Server</th>
</tr>
<tr>
<th>INDEX NAME</th>
<th>VERSION</th>
</tr>
<?php  
foreach($xml1->children() as $child) {
  $attr = $child->attributes();
if ($attr == "status") {
foreach($child->children() as $subchild) {
$attr = $subchild->attributes();
echo "<tr>";
foreach($subchild->children() as $sub2child) {
$attr = $sub2child->attributes();
if ($attr == "name") { 
echo "<td>" . $sub2child . "</td>";
}
if ($attr == "index") {
foreach($sub2child->children() as $sub3child) {
$attr = $sub3child->attributes();
if ($attr == "version") {
echo "<td>" . $sub3child . "</td>";
}
}
}
}
echo "</tr>";
}
}
}
?>
</table>
</div>

<div style="float: right">
   <table class="liste">
<tr>
<th colspan=2>SOLR StandBy</th>
</tr>
<tr>
<th>INDEX NAME</th>
<th>VERSION</th>
</tr>
<?php
foreach($xml2->children() as $child) {
  $attr = $child->attributes();
if ($attr == "status") {
foreach($child->children() as $subchild) {
$attr = $subchild->attributes();
echo "<tr>";
foreach($subchild->children() as $sub2child) {
$attr = $sub2child->attributes();
if ($attr == "name") { 
echo "<td>" . $sub2child . "</td>";
}
if ($attr == "index") {
foreach($sub2child->children() as $sub3child) {
$attr = $sub3child->attributes();
if ($attr == "version") {
echo "<td>" . $sub3child . "</td>";
}
}
}
}
echo "</tr>";
}
}
}
?>
</table>
</div>

stil1.css is the stylesheet:

<style type="text/css">
table.liste {
border-width: 1px;
border-spacing: 0px;
border-style: outset;
border-color: #CBE09D;
border-collapse: separate;
background-color: white;
}
table.liste th {
border-width: 1px;
padding: 1px;
border-style: groove;
border-color: #CBE09D;
background-color: white;
}
table.liste td {
border-width: 1px;
padding: 1px;
border-style: groove;
border-color: #CBE09D;
background-color: white;
}
</style>

Comments

Popular posts from this blog

Find and replace with sed command in Linux

Find and replace feature is always handy. It can turn into a torture when it comes to change or delete a simple constant string in a text file. There is a handy tool in linux for doing these kind of tihngs. Actually sed is not a text editor but it is used outside of the text file to make changes.

Sending Jboss Server Logs to Logstash Using Filebeat with Multiline Support

In addition to sending system logs to logstash, it is possible to add a prospector section to the filebeat.yml for jboss server logs. Sometimes jboss server.log has single events made up from several lines of messages. In such cases Filebeat should be configured for a multiline prospector.
Filebeat takes lines do not start with a date pattern (look at pattern in the multiline section "^[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}" and negate section is set to true) and combines them with the previous line that starts with a date pattern.

server.log file excerpt where DatePattern: yyyy-MM-dd-HH and ConversionPattern: %d %-5p [%c] %m%n
Logstash filter: