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:
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
Post a Comment