tayab@MX> show bgp summary | display xml
or
tayab@DOL-MX> show route protocol bgp | display xml
XML Output of BGP Summary
--------------------------------------
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/13.3R1/junos">
<bgp-information xmlns="http://xml.juniper.net/junos/13.3R1/junos-routing">
<group-count>4</group-count>
<peer-count>4</peer-count>
<down-peer-count>0</down-peer-count>
<bgp-rib junos:style="brief">
<name>inet.0</name>
<total-prefix-count>1921</total-prefix-count>
<received-prefix-count>1921</received-prefix-count>
<accepted-prefix-count>1879</accepted-prefix-count>
<active-prefix-count>1878</active-prefix-count>
<suppressed-prefix-count>0</suppressed-prefix-count>
<history-prefix-count>0</history-prefix-count>
<damped-prefix-count>0</damped-prefix-count>
<total-external-prefix-count>1921</total-external-prefix-count>
<active-external-prefix-count>1878</active-external-prefix-count>
<accepted-external-prefix-count>1879</accepted-external-prefix-count>
<suppressed-external-prefix-count>0</suppressed-external-prefix-count>
<total-internal-prefix-count>0</total-internal-prefix-count>
<active-internal-prefix-count>0</active-internal-prefix-count>
<accepted-internal-prefix-count>0</accepted-internal-prefix-count>
<suppressed-internal-prefix-count>0</suppressed-internal-prefix-count>
<pending-prefix-count>0</pending-prefix-count>
<bgp-rib-state>BGP restart is complete</bgp-rib-state>
</bgp-rib>
<bgp-peer junos:style="terse" heading="Peer AS InPkt Ou
ted/Damped...">
<peer-address>43.245.235.1</peer-address>
<peer-as>58691</peer-as>
<input-messages>59785</input-messages>
<output-messages>60259</output-messages>
<route-queue-count>0</route-queue-count>
<flap-count>8</flap-count>
<elapsed-time junos:seconds="1643733">2w5d0h</elapsed-time>
<peer-state junos:format="1/43/1/0 0/0/0/0">Established</peer-state>
<bgp-rib>
<name>inet.0</name>
<active-prefix-count>1</active-prefix-count>
<received-prefix-count>43</received-prefix-count>
<accepted-prefix-count>1</accepted-prefix-count>
<suppressed-prefix-count>0</suppressed-prefix-count>
</bgp-rib>
</bgp-peer>
<bgp-peer junos:style="terse">
<peer-address>59.152.98.41</peer-address>
<peer-as>58715</peer-as>
<input-messages>15930</input-messages>
<output-messages>16501</output-messages>
<route-queue-count>0</route-queue-count>
<flap-count>28</flap-count>
<elapsed-time junos:seconds="357732">4d 3:22:12</elapsed-time>
<peer-state junos:format="0/1/1/0 0/0/0/0">Established</peer-state>
<bgp-rib>
<name>inet.0</name>
<active-prefix-count>0</active-prefix-count>
<received-prefix-count>1</received-prefix-count>
<accepted-prefix-count>1</accepted-prefix-count>
<suppressed-prefix-count>0</suppressed-prefix-count>
</bgp-rib>
</bgp-peer>
<bgp-peer junos:style="terse">
<peer-address>59.152.98.45</peer-address>
<peer-as>58715</peer-as>
<input-messages>16048</input-messages>
<output-messages>16559</output-messages>
<route-queue-count>0</route-queue-count>
<flap-count>26</flap-count>
<elapsed-time junos:seconds="357731">4d 3:22:11</elapsed-time>
<peer-state junos:format="2/2/2/0 0/0/0/0">Established</peer-state>
<bgp-rib>
<name>inet.0</name>
<active-prefix-count>2</active-prefix-count>
<received-prefix-count>2</received-prefix-count>
<accepted-prefix-count>2</accepted-prefix-count>
<suppressed-prefix-count>0</suppressed-prefix-count>
</bgp-rib>
</bgp-peer>
<bgp-peer junos:style="terse">
<peer-address>198.32.167.1</peer-address>
<peer-as>65534</peer-as>
<input-messages>34634</input-messages>
<output-messages>25520</output-messages>
<route-queue-count>0</route-queue-count>
<flap-count>93</flap-count>
<elapsed-time junos:seconds="677003">1w0d20h</elapsed-time>
<peer-state junos:format="1875/1875/1875/0 0/0/0/0">Established</peer-state>
<bgp-rib>
<name>inet.0</name>
<active-prefix-count>1875</active-prefix-count>
<received-prefix-count>1875</received-prefix-count>
<accepted-prefix-count>1875</accepted-prefix-count>
<suppressed-prefix-count>0</suppressed-prefix-count>
</bgp-rib>
</bgp-peer>
</bgp-information>
<cli>
<banner></banner>
</cli>
</rpc-reply>
---------------------------
** Copy this XML to paste in any web server
You can also convert this XML file to HTML file online
http://codebeautify.org/xml-to-html-converter
***** call this route.xml file to an HTML file this way....
-----------------------------------------------------------------------
<html>
<head>
<title>BGP Route OUTPUT</title>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</head>
<body>
<?php
// Loading the XML file
$xml = new SimpleXMLElement("route.xml", 0, true);
?>
<div class="container">
<div class="page-header">
<h3><a href="testcode1.php">Test-ISP</a> <small>ISP Description</small></h3>
</div>
<table class="table table-hover">
<thead>
<tr>
<th>Route</th>
<th>AS Path</th>
<th>Protocol</th>
<th>Validation</th>
</tr>
</thead>
<?php
$startPage = $_GET['page'];
$perPage = 500;
$currentRecord = 0;
foreach($xml->{'route-information'}->{'route-table'}->{'rt'} as $record){
$currentRecord += 1;
if($currentRecord > ($startPage * $perPage) && $currentRecord < ($startPage * $perPage + $perPage)){
$route = str_replace("\n", "", $record->{'rt-destination'});
$aspath = str_replace("\n", "", $record->{'rt-entry'}->{'as-path'});
$protocolname = str_replace("\n", "", $record->{'rt-entry'}->{'protocol-name'});
$validation = str_replace("\n", "", $record->{'rt-entry'}->{'validation-state'});
echo "<tbody>";
echo "<tr>";
echo "<td class=\"small\">{$route}</td>";
echo "<td class=\"small\">{$aspath}</td>";
echo "<td class=\"small\">{$protocolname}</td>";
if ($validation=="invalid")
{echo "<td class=\"small\"><span class=\"label label-danger\">$validation</span></td>";}
elseif ($validation=="valid")
{echo "<td class=\"small\"><span class=\"label label-success\">$validation</span></td>";}
else
{echo "<td class=\"small\"><span class=\"label label-default\">$validation</span></td>";}
echo "</tr>";
echo "</tbody>";
}//end of if loop
}//endo of foreach loop
//pagination
for ($i = 1; $i <= ($currentRecord / $perPage); $i++) {
echo("<a href='testcode1.php?page=".$i."'>\t".$i."</a>");
}
?>
</table>
</div>
</body>
</html>
--------------------------------------------------------------------------------------------
No comments:
Post a Comment