mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
more fixes and updates from sid3windr
git-svn-id: http://www.observium.org/svn/observer/trunk@579 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -18,6 +18,15 @@ $config['community'] = "public";
|
|||||||
|
|
||||||
$config['base_url'] = "http://observer2.as8681.net";
|
$config['base_url'] = "http://observer2.as8681.net";
|
||||||
|
|
||||||
|
### Authentication model
|
||||||
|
$config['auth_mechanism'] = "mysql"; # default, other options: ldap
|
||||||
|
|
||||||
|
# LDAP module configuration
|
||||||
|
$config['auth_ldap_server'] = "ldap.yourserver.com";
|
||||||
|
$config['auth_ldap_port'] = 389;
|
||||||
|
$config['auth_ldap_suffix'] = ",ou=People,dc=example,dc=com";
|
||||||
|
$config['auth_ldap_prefix'] = "uid=";
|
||||||
|
|
||||||
### Location of executables
|
### Location of executables
|
||||||
|
|
||||||
$config['rrdtool'] = "/usr/bin/rrdtool";
|
$config['rrdtool'] = "/usr/bin/rrdtool";
|
||||||
|
|||||||
@@ -26,12 +26,39 @@ if($_COOKIE['username'] && $_COOKIE['password']){
|
|||||||
$_SESSION['password'] = mres($_COOKIE['password']);
|
$_SESSION['password'] = mres($_COOKIE['password']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$auth_success = 0;
|
||||||
|
|
||||||
$encrypted = md5($_SESSION['password']);
|
if ($config['auth_mechanism'] == "mysql")
|
||||||
$sql = "SELECT * FROM `users` WHERE `username`='".$_SESSION['username']."' AND `password`='".$encrypted."'";
|
{
|
||||||
$query = mysql_query($sql);
|
$encrypted = md5($_SESSION['password']);
|
||||||
$row = @mysql_fetch_array($query);
|
$sql = "SELECT username FROM `users` WHERE `username`='".$_SESSION['username']."' AND `password`='".$encrypted."'";
|
||||||
if($row['username'] && $row['username'] == $_SESSION['username']) {
|
$query = mysql_query($sql);
|
||||||
|
$row = @mysql_fetch_array($query);
|
||||||
|
if($row['username'] && $row['username'] == $_SESSION['username']) {
|
||||||
|
$auth_success = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ($config['auth_mechanism'] == "ldap")
|
||||||
|
{
|
||||||
|
$ds=@ldap_connect($config['auth_ldap_server'],$config['auth_ldap_port']);
|
||||||
|
if ($ds)
|
||||||
|
{
|
||||||
|
if (ldap_bind($ds, $config['auth_ldap_prefix'] . $_SESSION['username'] . $config['auth_ldap_suffix'], $_SESSION['password']))
|
||||||
|
{
|
||||||
|
$auth_success = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
echo "ERROR: no valid auth_mechanism defined.";
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($auth_success) {
|
||||||
|
$sql = "SELECT * FROM `users` WHERE `username`='".$_SESSION['username']."'";
|
||||||
|
$query = mysql_query($sql);
|
||||||
|
$row = @mysql_fetch_array($query);
|
||||||
$_SESSION['userlevel'] = $row['level'];
|
$_SESSION['userlevel'] = $row['level'];
|
||||||
$_SESSION['user_id'] = $row['user_id'];
|
$_SESSION['user_id'] = $row['user_id'];
|
||||||
if(!$_SESSION['authenticated']) {
|
if(!$_SESSION['authenticated']) {
|
||||||
@@ -39,11 +66,12 @@ if($row['username'] && $row['username'] == $_SESSION['username']) {
|
|||||||
mysql_query("INSERT INTO authlog (`user`,`address`,`result`) VALUES ('".$_SESSION['username']."', '".$_SERVER["REMOTE_ADDR"]."', 'logged in')");
|
mysql_query("INSERT INTO authlog (`user`,`address`,`result`) VALUES ('".$_SESSION['username']."', '".$_SERVER["REMOTE_ADDR"]."', 'logged in')");
|
||||||
header("Location: ".$_SERVER['REQUEST_URI']);
|
header("Location: ".$_SERVER['REQUEST_URI']);
|
||||||
}
|
}
|
||||||
if(isset($_POST['remember'])){
|
if(isset($_POST['remember'])) {
|
||||||
setcookie("username", $_SESSION['username'], time()+60*60*24*100, "/");
|
setcookie("username", $_SESSION['username'], time()+60*60*24*100, "/");
|
||||||
setcookie("password", $_SESSION['password'], time()+60*60*24*100, "/");
|
setcookie("password", $_SESSION['password'], time()+60*60*24*100, "/");
|
||||||
}
|
}
|
||||||
} elseif ($_SESSION['username']) {
|
}
|
||||||
|
elseif ($_SESSION['username']) {
|
||||||
$auth_message = "Authentication Failed";
|
$auth_message = "Authentication Failed";
|
||||||
unset ($_SESSION['authenticated']);
|
unset ($_SESSION['authenticated']);
|
||||||
mysql_query("INSERT INTO authlog (`user`,`address`,`result`) VALUES ('".$_SESSION['username']."', '".$_SERVER["REMOTE_ADDR"]."', 'authentication failure')");
|
mysql_query("INSERT INTO authlog (`user`,`address`,`result`) VALUES ('".$_SESSION['username']."', '".$_SERVER["REMOTE_ADDR"]."', 'authentication failure')");
|
||||||
|
|||||||
@@ -36,13 +36,6 @@
|
|||||||
} ?>
|
} ?>
|
||||||
<!-- <li><a href="alerts/"><img src='images/16/exclamation.png' border=0 align=absmiddle> Alerts</a></li> -->
|
<!-- <li><a href="alerts/"><img src='images/16/exclamation.png' border=0 align=absmiddle> Alerts</a></li> -->
|
||||||
<li><a href="inventory/"><img src='images/16/bricks.png' border=0 align=absmiddle> Inventory</a></li>
|
<li><a href="inventory/"><img src='images/16/bricks.png' border=0 align=absmiddle> Inventory</a></li>
|
||||||
<?php
|
|
||||||
if($_SESSION['userlevel'] >= '10') {
|
|
||||||
echo("
|
|
||||||
|
|
||||||
<li><a href='authlog/'><img src='images/16/lock.png' border=0 align=absmiddle> Authlog</a></li>");
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</ul>
|
</ul>
|
||||||
</td></tr></table>
|
</td></tr></table>
|
||||||
|
|
||||||
@@ -204,7 +197,9 @@ echo(" <li><hr /></li>
|
|||||||
<li><hr width=140/></li>
|
<li><hr width=140/></li>
|
||||||
<li><a href='?page=adduser'><img src='images/16/user_add.png' border=0 align=absmiddle> Add User</a></li>
|
<li><a href='?page=adduser'><img src='images/16/user_add.png' border=0 align=absmiddle> Add User</a></li>
|
||||||
<li><a href='?page=deluser'><img src='images/16/user_delete.png' border=0 align=absmiddle> Remove User</a></li>
|
<li><a href='?page=deluser'><img src='images/16/user_delete.png' border=0 align=absmiddle> Remove User</a></li>
|
||||||
<li><a href='?page=edituser'><img src='images/16/user_edit.png' border=0 align=absmiddle> Edit User</a></li>");
|
<li><a href='?page=edituser'><img src='images/16/user_edit.png' border=0 align=absmiddle> Edit User</a></li>
|
||||||
|
<li><hr width=140 /></li>
|
||||||
|
<li><a href='authlog/'><img src='images/16/lock.png' border=0 align=absmiddle> Authlog</a></li>");
|
||||||
} ?>
|
} ?>
|
||||||
</ul>
|
</ul>
|
||||||
</td></tr></table>
|
</td></tr></table>
|
||||||
|
|||||||
@@ -22,7 +22,11 @@ function generate_front_box ($type, $content) {
|
|||||||
|
|
||||||
echo("<div style='padding: 3px 10px; background: #fff;'>");
|
echo("<div style='padding: 3px 10px; background: #fff;'>");
|
||||||
|
|
||||||
|
if($_SESSION['userlevel'] == '10') {
|
||||||
$sql = mysql_query("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'");
|
$sql = mysql_query("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'");
|
||||||
|
} else {
|
||||||
|
$sql = mysql_query("SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND D.status = '0' AND D.ignore = '0'");
|
||||||
|
}
|
||||||
while($device = mysql_fetch_array($sql)){
|
while($device = mysql_fetch_array($sql)){
|
||||||
|
|
||||||
generate_front_box("alert", "<center><strong>".generatedevicelink($device, shorthost($device['hostname']))."</strong><br />
|
generate_front_box("alert", "<center><strong>".generatedevicelink($device, shorthost($device['hostname']))."</strong><br />
|
||||||
@@ -33,9 +37,12 @@ while($device = mysql_fetch_array($sql)){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($_SESSION['userlevel'] == '10') {
|
||||||
$sql = mysql_query("SELECT * FROM `interfaces` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'");
|
$sql = mysql_query("SELECT * FROM `interfaces` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'");
|
||||||
|
} else {
|
||||||
|
$sql = mysql_query("SELECT * FROM `interfaces` AS I, `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'");
|
||||||
|
}
|
||||||
while($interface = mysql_fetch_array($sql)){
|
while($interface = mysql_fetch_array($sql)){
|
||||||
|
|
||||||
generate_front_box("warn", "<center><strong>".generatedevicelink($interface, shorthost($interface['hostname']))."</strong><br />
|
generate_front_box("warn", "<center><strong>".generatedevicelink($interface, shorthost($interface['hostname']))."</strong><br />
|
||||||
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Port Down</span><br />
|
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Port Down</span><br />
|
||||||
<!-- <img src='graph.php?type=bits&if=".$interface['interface_id']."&from=$day&to=$now&width=100&height=32' /> -->
|
<!-- <img src='graph.php?type=bits&if=".$interface['interface_id']."&from=$day&to=$now&width=100&height=32' /> -->
|
||||||
@@ -45,10 +52,9 @@ while($interface = mysql_fetch_array($sql)){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* FIXME service permissions? seem nonexisting now.. */
|
||||||
$sql = mysql_query("SELECT * FROM `services` AS S, `devices` AS D WHERE S.service_host = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'");
|
$sql = mysql_query("SELECT * FROM `services` AS S, `devices` AS D WHERE S.service_host = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'");
|
||||||
while($service = mysql_fetch_array($sql)){
|
while($service = mysql_fetch_array($sql)){
|
||||||
|
|
||||||
|
|
||||||
generate_front_box("alert", "<center><strong>".generatedevicelink($service, shorthost($service['hostname']))."</strong><br />
|
generate_front_box("alert", "<center><strong>".generatedevicelink($service, shorthost($service['hostname']))."</strong><br />
|
||||||
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Service Down</span>
|
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Service Down</span>
|
||||||
<strong>".$service['service_type']."</strong><br />
|
<strong>".$service['service_type']."</strong><br />
|
||||||
@@ -57,7 +63,11 @@ while($service = mysql_fetch_array($sql)){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = mysql_query("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerState != 'established' AND B.device_id = D.device_id");
|
if($_SESSION['userlevel'] == '10') {
|
||||||
|
$sql = mysql_query("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerState != 'established' AND B.device_id = D.device_id AND D.ignore = 0");
|
||||||
|
} else {
|
||||||
|
$sql = mysql_query("SELECT * FROM `devices` AS D, bgpPeers AS B, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND bgpPeerState != 'established' AND B.device_id = D.device_id AND D.ignore = 0");
|
||||||
|
}
|
||||||
while($peer = mysql_fetch_array($sql)){
|
while($peer = mysql_fetch_array($sql)){
|
||||||
|
|
||||||
generate_front_box("alert", "<center><strong>".generatedevicelink($peer, shorthost($peer['hostname']))."</strong><br />
|
generate_front_box("alert", "<center><strong>".generatedevicelink($peer, shorthost($peer['hostname']))."</strong><br />
|
||||||
@@ -68,7 +78,11 @@ while($peer = mysql_fetch_array($sql)){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = mysql_query("SELECT * FROM `devices` WHERE status = '1' AND `uptime` < '84600'");
|
if($_SESSION['userlevel'] == '10') {
|
||||||
|
$sql = mysql_query("SELECT * FROM `devices` AS D WHERE D.status = '1' AND D.uptime < '84600' AND D.ignore = 0");
|
||||||
|
} else {
|
||||||
|
$sql = mysql_query("SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND D.status = '1' AND D.uptime < '84600' AND D.ignore = 0");
|
||||||
|
}
|
||||||
while($device = mysql_fetch_array($sql)){
|
while($device = mysql_fetch_array($sql)){
|
||||||
generate_front_box("info", "<center><strong>".generatedevicelink($device, shorthost($device['hostname']))."</strong><br />
|
generate_front_box("info", "<center><strong>".generatedevicelink($device, shorthost($device['hostname']))."</strong><br />
|
||||||
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #009;'>Device<br />Rebooted</span><br />
|
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #009;'>Device<br />Rebooted</span><br />
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
### Discover BGP peers on Cisco devices
|
### Discover BGP peers on Cisco and Juniper devices
|
||||||
|
|
||||||
echo("BGP Sessions : ");
|
echo("BGP Sessions : ");
|
||||||
|
|
||||||
@@ -34,10 +34,11 @@
|
|||||||
echo("+");
|
echo("+");
|
||||||
} else {
|
} else {
|
||||||
$update = mysql_query("UPDATE `bgpPeers` SET astext = '$astext' WHERE `device_id` = '".$device['device_id']."' AND bgpPeerIdentifier = '$peer_ip'");
|
$update = mysql_query("UPDATE `bgpPeers` SET astext = '$astext' WHERE `device_id` = '".$device['device_id']."' AND bgpPeerIdentifier = '$peer_ip'");
|
||||||
|
echo(".");
|
||||||
}
|
}
|
||||||
|
|
||||||
## Get afi/safi and populate cbgp on cisco ios (xe/xr)
|
## Get afi/safi and populate cbgp on cisco ios (xe/xr)
|
||||||
if($device['os_type'] == "ios") {
|
if($device['os'] == "ios") {
|
||||||
unset($af_list);
|
unset($af_list);
|
||||||
$af_cmd = $config['snmpwalk'] . " -CI -m CISCO-BGP4-MIB -OsQ -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'].":".$device['port'] . " ";
|
$af_cmd = $config['snmpwalk'] . " -CI -m CISCO-BGP4-MIB -OsQ -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'].":".$device['port'] . " ";
|
||||||
$af_cmd .= "cbgpPeerAddrFamilyName." . $peer_ip;
|
$af_cmd .= "cbgpPeerAddrFamilyName." . $peer_ip;
|
||||||
@@ -61,7 +62,39 @@
|
|||||||
mysql_query("DELETE FROM `bgpPeers_cbgp` WHERE `device_id` = '".$device['device_id']."' AND bgpPeerIdentifier = '$peer_ip' AND afi = '$afi' AND safi = '$safi'");
|
mysql_query("DELETE FROM `bgpPeers_cbgp` WHERE `device_id` = '".$device['device_id']."' AND bgpPeerIdentifier = '$peer_ip' AND afi = '$afi' AND safi = '$safi'");
|
||||||
}
|
}
|
||||||
} # AF list
|
} # AF list
|
||||||
} # if os_type = ios
|
} # if os = ios
|
||||||
|
} # If Peer
|
||||||
|
} # Foreach
|
||||||
|
|
||||||
|
if ($device['os'] == "junos")
|
||||||
|
## Juniper BGP4-V2 MIB, ipv6 only for now, because v4 should be covered in BGP4-MIB above
|
||||||
|
$peers_cmd = $config['snmpwalk'] . " -m BGP4-V2-MIB-JUNIPER -CI -Onq -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'].":".$device['port'] . " ";
|
||||||
|
$peers_cmd .= "jnxBgpM2PeerRemoteAs.0.ipv6"; # FIXME: is .0 the only possible value here?
|
||||||
|
$peers = trim(str_replace(".1.3.6.1.4.1.2636.5.1.1.2.1.1.1.13.0.","", `$peers_cmd`));
|
||||||
|
foreach (explode("\n", $peers) as $peer) {
|
||||||
|
list($peer_ip_snmp, $peer_as) = split(" ", $peer);
|
||||||
|
$peer_ip_ex = explode('.',$peer_ip_snmp);
|
||||||
|
$peer_ip_ex = array_slice($peer_ip_ex,count($peer_ip_ex)-16);
|
||||||
|
for ($i = 0;$i <= 15;$i++) { $peer_ip_ex[$i] = dechex($peer_ip_ex[$i]); if (strlen($peer_ip_ex[$i]) < 2) $peer_ip_ex[$i] = '0' . $peer_ip_ex[$i]; }
|
||||||
|
for ($i = 0;$i <= 15;$i+=2) { $peer_ip_ex2[] = $peer_ip_ex[$i] . $peer_ip_ex[$i+1]; }
|
||||||
|
$peer_ip = implode(':',$peer_ip_ex2); unset($peer_ip_ex2);
|
||||||
|
$peer_ip = Net_IPv6::compress($peer_ip);
|
||||||
|
|
||||||
|
if($peer) {
|
||||||
|
|
||||||
|
$peerlist[] = $device['device_id'] ." $peer_ip";
|
||||||
|
|
||||||
|
$astext = trim(str_replace("\"", "", shell_exec("/usr/bin/dig +short AS$peer_as.asn.cymru.com TXT | cut -d '|' -f 5 | sed s/\\\"//g")));
|
||||||
|
|
||||||
|
#echo("$peer_ip AS$peer_as ");
|
||||||
|
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `bgpPeers` WHERE `device_id` = '".$device['device_id']."' AND bgpPeerIdentifier = '$peer_ip'"),0) < '1') {
|
||||||
|
$add = mysql_query("INSERT INTO bgpPeers (`device_id`, `bgpPeerIdentifier`, `bgpPeerRemoteAS`) VALUES ('".$device['device_id']."','$peer_ip','$peer_as')");
|
||||||
|
echo("+");
|
||||||
|
} else {
|
||||||
|
$update = mysql_query("UPDATE `bgpPeers` SET astext = '$astext' WHERE `device_id` = '".$device['device_id']."' AND bgpPeerIdentifier = '$peer_ip'");
|
||||||
|
echo(".");
|
||||||
|
}
|
||||||
|
|
||||||
} # If Peer
|
} # If Peer
|
||||||
} # Foreach
|
} # Foreach
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
echo("CISCO-PROCESS-MIB : ");
|
echo("CISCO-PROCESS-MIB : ");
|
||||||
|
|
||||||
## Cisco Processors
|
## Cisco Processors
|
||||||
if($device['os_type'] == "ios") {
|
if($device['os'] == "ios") {
|
||||||
$oids = shell_exec($config['snmpwalk'] . " -m CISCO-PROCESS-MIB -".$device['snmpver']." -CI -Osqn -c ".$community." ".$hostname.":".$port." .1.3.6.1.4.1.9.9.109.1.1.1.1.2 | sed s/.1.3.6.1.4.1.9.9.109.1.1.1.1.2.//g");
|
$oids = shell_exec($config['snmpwalk'] . " -m CISCO-PROCESS-MIB -".$device['snmpver']." -CI -Osqn -c ".$community." ".$hostname.":".$port." .1.3.6.1.4.1.9.9.109.1.1.1.1.2 | sed s/.1.3.6.1.4.1.9.9.109.1.1.1.1.2.//g");
|
||||||
$oids = trim($oids);
|
$oids = trim($oids);
|
||||||
foreach(explode("\n", $oids) as $data) {
|
foreach(explode("\n", $oids) as $data) {
|
||||||
|
|||||||
@@ -119,7 +119,7 @@
|
|||||||
} ## End Supermicro Temperatures
|
} ## End Supermicro Temperatures
|
||||||
|
|
||||||
## Cisco Temperatures
|
## Cisco Temperatures
|
||||||
if($device['os_type'] == "ios") {
|
if($device['os'] == "ios") {
|
||||||
echo("Cisco ");
|
echo("Cisco ");
|
||||||
$oids = shell_exec($config['snmpwalk'] . " -m CISCO-ENVMON-MIB -$snmpver -CI -Osqn -c $community $hostname:$port .1.3.6.1.4.1.9.9.13.1.3.1.2 | sed s/.1.3.6.1.4.1.9.9.13.1.3.1.2.//g");
|
$oids = shell_exec($config['snmpwalk'] . " -m CISCO-ENVMON-MIB -$snmpver -CI -Osqn -c $community $hostname:$port .1.3.6.1.4.1.9.9.13.1.3.1.2 | sed s/.1.3.6.1.4.1.9.9.13.1.3.1.2.//g");
|
||||||
$oids = trim($oids);
|
$oids = trim($oids);
|
||||||
|
|||||||
@@ -12,12 +12,65 @@ while($peer = mysql_fetch_array($peers)) {
|
|||||||
|
|
||||||
echo("Checking ".$peer['bgpPeerIdentifier']." ");
|
echo("Checking ".$peer['bgpPeerIdentifier']." ");
|
||||||
|
|
||||||
|
if (!strstr($peer['bgpPeerIdentifier'],':'))
|
||||||
|
{
|
||||||
|
# v4 BGP4 MIB
|
||||||
$peer_cmd = $config['snmpget'] . " -m BGP4-MIB -Ovq -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'].":".$device['port'] . " ";
|
$peer_cmd = $config['snmpget'] . " -m BGP4-MIB -Ovq -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'].":".$device['port'] . " ";
|
||||||
$peer_cmd .= "bgpPeerState." . $peer['bgpPeerIdentifier'] . " bgpPeerAdminStatus." . $peer['bgpPeerIdentifier'] . " bgpPeerInUpdates." . $peer['bgpPeerIdentifier'] . " bgpPeerOutUpdates." . $peer['bgpPeerIdentifier'] . " bgpPeerInTotalMessages." . $peer['bgpPeerIdentifier'] . " ";
|
$peer_cmd .= "bgpPeerState." . $peer['bgpPeerIdentifier'] . " bgpPeerAdminStatus." . $peer['bgpPeerIdentifier'] . " bgpPeerInUpdates." . $peer['bgpPeerIdentifier'] . " bgpPeerOutUpdates." . $peer['bgpPeerIdentifier'] . " bgpPeerInTotalMessages." . $peer['bgpPeerIdentifier'] . " ";
|
||||||
$peer_cmd .= "bgpPeerOutTotalMessages." . $peer['bgpPeerIdentifier'] . " bgpPeerFsmEstablishedTime." . $peer['bgpPeerIdentifier'] . " bgpPeerInUpdateElapsedTime." . $peer['bgpPeerIdentifier'] . " ";
|
$peer_cmd .= "bgpPeerOutTotalMessages." . $peer['bgpPeerIdentifier'] . " bgpPeerFsmEstablishedTime." . $peer['bgpPeerIdentifier'] . " bgpPeerInUpdateElapsedTime." . $peer['bgpPeerIdentifier'] . " ";
|
||||||
$peer_cmd .= "bgpPeerLocalAddr." . $peer['bgpPeerIdentifier'] . "";
|
$peer_cmd .= "bgpPeerLocalAddr." . $peer['bgpPeerIdentifier'] . "";
|
||||||
$peer_data = trim(`$peer_cmd`);
|
$peer_data = trim(`$peer_cmd`);
|
||||||
list($bgpPeerState, $bgpPeerAdminStatus, $bgpPeerInUpdates, $bgpPeerOutUpdates, $bgpPeerInTotalMessages, $bgpPeerOutTotalMessages, $bgpPeerFsmEstablishedTime, $bgpPeerInUpdateElapsedTime, $bgpLocalAddr) = explode("\n", $peer_data);
|
list($bgpPeerState, $bgpPeerAdminStatus, $bgpPeerInUpdates, $bgpPeerOutUpdates, $bgpPeerInTotalMessages, $bgpPeerOutTotalMessages, $bgpPeerFsmEstablishedTime, $bgpPeerInUpdateElapsedTime, $bgpLocalAddr) = explode("\n", $peer_data);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if ($device['os'] == "junos")
|
||||||
|
{
|
||||||
|
# v6 for JunOS via Juniper MIB
|
||||||
|
$peer_ip_ex = explode(':',Net_IPv6::uncompress($peer['bgpPeerIdentifier']));
|
||||||
|
for ($i = 0;$i < 8;$i++) { while (strlen($peer_ip_ex[$i]) < 4) $peer_ip_ex[$i] = "0" . $peer_ip_ex[$i]; } # Pad zeroes back
|
||||||
|
$peer_ip = implode('',$peer_ip_ex);
|
||||||
|
for ($i = 0;$i < 16;$i+=2) $peer_ip_split[] = hexdec(substr($peer_ip,$i,2));
|
||||||
|
$peer_ip = implode($peer_ip_split,'.'); unset($peer_ip_split); # Now in JunOS SNMP format
|
||||||
|
|
||||||
|
if (!isset($junos_v6))
|
||||||
|
{
|
||||||
|
echo "\nCaching Oids...";
|
||||||
|
$peer_cmd = $config['snmpwalk'] . " -m BGP4-V2-MIB-JUNIPER -Onq -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'].":".$device['port'];
|
||||||
|
$peer_cmd .= " jnxBgpM2PeerStatus.0.ipv6";
|
||||||
|
foreach (explode("\n",trim(`$peer_cmd`)) as $oid)
|
||||||
|
{
|
||||||
|
list($peer_oid) = split(' ',$oid);
|
||||||
|
$peer_id = explode('.',$peer_oid);
|
||||||
|
$junos_v6[implode('.',array_slice($peer_id,35,8))] = implode('.',array_slice($peer_id,18));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$peer_cmd = $config['snmpget'] . " -m BGP4-V2-MIB-JUNIPER -Ovq -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'].":".$device['port'];
|
||||||
|
$peer_cmd .= " jnxBgpM2PeerState.0.ipv6." . $junos_v6[$peer_ip];
|
||||||
|
$peer_cmd .= " jnxBgpM2PeerStatus.0.ipv6." . $junos_v6[$peer_ip];
|
||||||
|
$peer_cmd .= " jnxBgpM2PeerInUpdates.0.ipv6." . $junos_v6[$peer_ip];
|
||||||
|
$peer_cmd .= " jnxBgpM2PeerOutUpdates.0.ipv6." . $junos_v6[$peer_ip];
|
||||||
|
$peer_cmd .= " jnxBgpM2PeerInTotalMessages.0.ipv6." . $junos_v6[$peer_ip];
|
||||||
|
$peer_cmd .= " jnxBgpM2PeerOutTotalMessages.0.ipv6." . $junos_v6[$peer_ip];
|
||||||
|
$peer_cmd .= " jnxBgpM2PeerFsmEstablishedTime.0.ipv6." . $junos_v6[$peer_ip];
|
||||||
|
$peer_cmd .= " jnxBgpM2PeerInUpdatesElapsedTime.0.ipv6." . $junos_v6[$peer_ip];
|
||||||
|
$peer_cmd .= " jnxBgpM2PeerLocalAddr.0.ipv6." . $junos_v6[$peer_ip];
|
||||||
|
$peer_data = trim(`$peer_cmd`);
|
||||||
|
list($bgpPeerState, $bgpPeerAdminStatus, $bgpPeerInUpdates, $bgpPeerOutUpdates, $bgpPeerInTotalMessages, $bgpPeerOutTotalMessages, $bgpPeerFsmEstablishedTime, $bgpPeerInUpdateElapsedTime, $bgpLocalAddr) = explode("\n", $peer_data);
|
||||||
|
|
||||||
|
$bgpLocalAddr = str_replace('"','',str_replace(' ','',$bgpLocalAddr));
|
||||||
|
if ($bgpLocalAddr == "00000000000000000000000000000000")
|
||||||
|
{
|
||||||
|
$bgpLocalAddr = ''; # Unknown?
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$bgpLocalAddr = strtolower($bgpLocalAddr);
|
||||||
|
for ($i = 0;$i < 32;$i+=4)
|
||||||
|
$bgpLocalAddr6[] = substr($bgpLocalAddr,$i,4);
|
||||||
|
$bgpLocalAddr = Net_IPv6::compress(implode(':',$bgpLocalAddr6)); unset($bgpLocalAddr6);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$peerrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/bgp-" . $peer['bgpPeerIdentifier'] . ".rrd";
|
$peerrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/bgp-" . $peer['bgpPeerIdentifier'] . ".rrd";
|
||||||
if(!is_file($peerrrd)) {
|
if(!is_file($peerrrd)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user