mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
CEF switching web module :):):):):):):):)
git-svn-id: http://www.observium.org/svn/observer/trunk@2064 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -131,6 +131,18 @@ if (device_permitted($_GET['id']) || $check_device == $_GET['id'])
|
||||
</li>');
|
||||
}
|
||||
|
||||
$cef_query = mysql_query("SELECT COUNT(*) FROM `cef_switching` WHERE `device_id` = '".$device['device_id']."'");
|
||||
$cef_count = mysql_result($cef_query,0);
|
||||
|
||||
if ($cef_count)
|
||||
{
|
||||
echo('<li class="' . $select['cefswitching'] . '">
|
||||
<a href="'.$config['base_url'].'/device/' . $device['device_id'] . '/cefswitching/">
|
||||
<img src="images/16/car.png" align="absmiddle" border="0" /> CEF
|
||||
</a>
|
||||
</li>');
|
||||
}
|
||||
|
||||
if ($_SESSION['userlevel'] >= "5" && mysql_result(mysql_query("SELECT count(*) FROM links AS L, ports AS I WHERE I.device_id = '".$device['device_id']."' AND I.interface_id = L.local_interface_id"),0))
|
||||
{
|
||||
echo('<li class="' . $select['map'] . '">
|
||||
|
67
html/pages/device/cefswitching.inc.php
Normal file
67
html/pages/device/cefswitching.inc.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
print_optionbar_start();
|
||||
|
||||
$menu_options = array('basic' => 'Basic',
|
||||
'graphs' => 'Graphs',
|
||||
);
|
||||
|
||||
if (!$_GET['opta']) { $_GET['opta'] = "basic"; }
|
||||
|
||||
$sep = "";
|
||||
foreach ($menu_options as $option => $text)
|
||||
{
|
||||
echo($sep);
|
||||
if ($_GET['opta'] == $option) { echo("<span class='pagemenu-selected'>"); }
|
||||
echo('<a href="'.$config['base_url'].'/device/' . $device['device_id'] . '/cefswitching/' . $option . ($_GET['optb'] ? '/' . $_GET['optb'] : ''). '/">' . $text
|
||||
. '</a>');
|
||||
if ($_GET['opta'] == $option) { echo("</span>"); }
|
||||
$sep = " | ";
|
||||
}
|
||||
|
||||
unset($sep);
|
||||
|
||||
print_optionbar_end();
|
||||
|
||||
|
||||
echo("<table width=100%>");
|
||||
|
||||
$cef_query = mysql_query("SELECT * FROM `cef_switching` WHERE `device_id` = '".$device['device_id']."' ORDER BY `entPhysicalIndex`, `afi`, `cef_index`");
|
||||
|
||||
echo("<tr><th>Entity</th><th>AFI</th><th>Path</th><th>Drop</th><th>Punt</th><th>Punt2Host</th>
|
||||
</tr>");
|
||||
|
||||
$i=0;
|
||||
|
||||
while ($cef = mysql_fetch_assoc($cef_query))
|
||||
{
|
||||
|
||||
$entity_query = mysql_query("SELECT * FROM `entPhysical` WHERE device_id = '".$device['device_id']."' AND `entPhysicalIndex` = '".$cef['entPhysicalIndex']."'");
|
||||
$entity = mysql_fetch_assoc($entity_query);
|
||||
|
||||
if (!is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; }
|
||||
|
||||
$interval = $cef['updated'] - $cef['updated_prev'];
|
||||
|
||||
echo("<tr bgcolor=$bg_colour><td>".$entity['entPhysicalName']." - ".$entity['entPhysicalModelName']."</td>
|
||||
<td>".$cef['afi']."</td>
|
||||
<td>".$cef['cef_path']."</td>");
|
||||
|
||||
echo("<td>".format_si($cef['drop']));
|
||||
if($cef['drop'] > $cef['drop_prev']) { echo(" <span style='color:red;'>(".round(($cef['drop']-$cef['drop_prev'])/$interval,2)."/sec)</span>"); }
|
||||
echo("</td>");
|
||||
echo("<td>".format_si($cef['punt']));
|
||||
if($cef['punt'] > $cef['punt_prev']) { echo(" <span style='color:red;'>(".round(($cef['punt']-$cef['punt_prev'])/$interval,2)."/sec)</span>"); }
|
||||
echo("</td>");
|
||||
echo("<td>".format_si($cef['punt']));
|
||||
if($cef['punt2host'] > $cef['punt2host_prev']) { echo(" <span style='color:red;'>(".round(($cef['punt2host']-$cef['punt2host_prev'])/$interval,2)."/sec)</span>"); }
|
||||
echo("</td>");
|
||||
|
||||
echo("</tr>
|
||||
");
|
||||
$i++;
|
||||
}
|
||||
|
||||
echo("</table>");
|
||||
|
||||
?>
|
@@ -4,6 +4,8 @@ echo("Cisco CEF Switching Path: ");
|
||||
|
||||
$cefs = array();
|
||||
$cefs = snmpwalk_cache_threepart_oid($device, "CISCO-CEF-MIB::cefSwitchingStatsEntry", $cefs);
|
||||
$polled = time();
|
||||
|
||||
if ($debug) { print_r($cefs); }
|
||||
|
||||
if (is_array($cefs))
|
||||
@@ -26,20 +28,26 @@ if (is_array($cefs))
|
||||
foreach($afis as $afi => $paths)
|
||||
{
|
||||
echo(" |- $afi\n");
|
||||
foreach($paths as $path => $path_name)
|
||||
foreach($paths as $path => $cef_stat)
|
||||
{
|
||||
echo(" | |-".$path.": ".$path_name['cefSwitchingPath']);
|
||||
echo(" | |-".$path.": ".$cef_stat['cefSwitchingPath']);
|
||||
|
||||
|
||||
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `cef_switching` WHERE `device_id` = '".$device['device_id']."' AND `entPhysicalIndex` = '".$entity."'
|
||||
AND `afi` = '".$afi."' AND `cef_index` = '".$path."'"),0) != "1")
|
||||
{
|
||||
$sql = "INSERT INTO `cef_switching` (`device_id`, `entPhysicalIndex`, `afi`, `cef_index`, `cef_path`)
|
||||
VALUES ('".$device['device_id']."', '".$entity."', '".$afi."', '".$path."', '".$path_name['cefSwitchingPath']."')";
|
||||
VALUES ('".$device['device_id']."', '".$entity."', '".$afi."', '".$path."', '".$cef_stat['cefSwitchingPath']."')";
|
||||
mysql_query($sql);
|
||||
echo("+");
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM `cef_switching` WHERE `device_id` = '".$device['device_id']."' AND `entPhysicalIndex` = '".$entity."'
|
||||
AND `afi` = '".$afi."' AND `cef_index` = '".$path."'";
|
||||
|
||||
$query = mysql_query($sql);
|
||||
$cef_entry = mysql_fetch_assoc($query);
|
||||
|
||||
$filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("cefswitching-".$entity."-".$afi."-".$path.".rrd");
|
||||
|
||||
if (!is_file($filename))
|
||||
@@ -54,20 +62,31 @@ if (is_array($cefs))
|
||||
RRA:LAST:0.5:1:600 RRA:LAST:0.5:6:700 RRA:LAST:0.5:24:775 RRA:LAST:0.5:288:797");
|
||||
}
|
||||
|
||||
$path_name['cefSwitchingPath'];
|
||||
$path_name['cefSwitchingDrop'];
|
||||
$path_name['cefSwitchingPunt'];
|
||||
$path_name['cefSwitchingPunt2Host'];
|
||||
|
||||
### Copy HC to non-HC if they exist
|
||||
if (is_numeric($this_port['cefSwitchingPath'])) { $this_port['cefSwitchingPath'] = $this_port['cefSwitchingHCDrop']; }
|
||||
if (is_numeric($this_port['cefSwitchingPunt'])) { $this_port['cefSwitchingPunt'] = $this_port['cefSwitchingHCPunt']; }
|
||||
if (is_numeric($this_port['cefSwitchingPunt2Host'])) { $this_port['cefSwitchingPunt2Host'] = $this_port['cefSwitchingHCPunt2Host']; }
|
||||
if (is_numeric($cef_stat['cefSwitchingHCDrop'])) { $cef_stat['cefSwitchingDrop'] = $cef_stat['cefSwitchingHCDrop']; }
|
||||
if (is_numeric($cef_stat['cefSwitchingHCPunt'])) { $cef_stat['cefSwitchingPunt'] = $cef_stat['cefSwitchingHCPunt']; }
|
||||
if (is_numeric($cef_stat['cefSwitchingHCPunt2Host'])) { $cef_stat['cefSwitchingPunt2Host'] = $cef_stat['cefSwitchingHCPunt2Host']; }
|
||||
|
||||
$rrd_update = "N:".$path_name['cefSwitchingDrop'].":".$path_name['cefSwitchingPunt'].":".$path_name['cefSwitchingPunt2Host'];
|
||||
$update = " `drop` = '".$cef_stat['cefSwitchingDrop']."'";
|
||||
$update .= ", `punt` = '".$cef_stat['cefSwitchingPunt']."'";
|
||||
$update .= ", `punt2host` = '".$cef_stat['cefSwitchingPunt2Host']."'";
|
||||
|
||||
$update .= ", `drop_prev` = '".$cef_entry['drop']."'";
|
||||
$update .= ", `punt_prev` = '".$cef_entry['punt']."'";
|
||||
$update .= ", `punt2host_prev` = '".$cef_entry['punt2host']."'";
|
||||
|
||||
$update .= ", `updated` = '".$polled."'";
|
||||
$update .= ", `updated_prev` = '".$cef_entry['updated']."'";
|
||||
|
||||
$update_query = "UPDATE `cef_switching` SET ".$update." WHERE `device_id` = '".$device['device_id']."' AND `entPhysicalIndex` = '".$entity."'
|
||||
AND `afi` = '".$afi."' AND `cef_index` = '".$path."'";
|
||||
@mysql_query($update_query);
|
||||
if ($debug) {echo("\nMYSQL : [ $update_query ]"); }
|
||||
|
||||
$rrd_update = "N:".$cef_stat['cefSwitchingDrop'].":".$cef_stat['cefSwitchingPunt'].":".$cef_stat['cefSwitchingPunt2Host'];
|
||||
$ret = rrdtool_update("$filename", $rrd_update);
|
||||
|
||||
if($debug) { echo(" Values: ".$path_name['cefSwitchingDrop'].":".$path_name['cefSwitchingPunt'].":".$path_name['cefSwitchingPunt2Host']); }
|
||||
if($debug) { echo(" Values: ".$cef_stat['cefSwitchingDrop'].":".$cef_stat['cefSwitchingPunt'].":".$cef_stat['cefSwitchingPunt2Host']); }
|
||||
|
||||
echo("\n");
|
||||
|
||||
|
Reference in New Issue
Block a user