Files
librenms-librenms/includes/polling/entity-physical.inc.php
T

97 lines
3.0 KiB
PHP
Raw Normal View History

2011-11-14 16:53:37 +00:00
<?php
echo("Entity Physical: ");
if($device['os'] == "ios")
{
echo("Cisco Cat6xxx/76xx Crossbar : \n");
$mod_stats = snmpwalk_cache_oid($device, "cc6kxbarModuleModeTable", array(), "CISCO-CAT6K-CROSSBAR-MIB");
$chan_stats = snmpwalk_cache_oid($device, "cc6kxbarModuleChannelTable", array(), "CISCO-CAT6K-CROSSBAR-MIB");
$chan_stats = snmpwalk_cache_oid($device, "cc6kxbarStatisticsTable", $chan_stats, "CISCO-CAT6K-CROSSBAR-MIB");
2012-04-05 16:37:46 +00:00
foreach ($mod_stats as $index => $entry)
2011-11-14 16:53:37 +00:00
{
$group = 'c6kxbar';
2012-04-05 16:37:46 +00:00
foreach ($entry as $key => $value)
2011-11-14 16:53:37 +00:00
{
$subindex = NULL;
$entPhysical_state[$index][$subindex][$group][$key] = $value;
2011-11-14 16:53:37 +00:00
}
}
2012-04-05 16:37:46 +00:00
foreach ($chan_stats as $index => $entry)
2011-11-14 16:53:37 +00:00
{
list($index,$subindex) = explode(".", $index, 2);
$group = 'c6kxbar';
2012-04-05 16:37:46 +00:00
foreach ($entry as $key => $value)
2011-11-14 16:53:37 +00:00
{
$entPhysical_state[$index][$subindex][$group][$key] = $value;
2011-11-14 16:53:37 +00:00
}
2011-11-14 20:25:13 +00:00
$chan_update = $entry['cc6kxbarStatisticsInUtil'];
$chan_update .= ":".$entry['cc6kxbarStatisticsOutUtil'];
$chan_update .= ":".$entry['cc6kxbarStatisticsOutDropped'];
$chan_update .= ":".$entry['cc6kxbarStatisticsOutErrors'];
$chan_update .= ":".$entry['cc6kxbarStatisticsInErrors'];
2011-11-14 16:53:37 +00:00
2011-11-14 20:25:13 +00:00
$rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("c6kxbar-".$index."-".$subindex.".rrd");
if ($debug) { echo("$rrd "); }
if (!is_file($rrd))
{
rrdtool_create ($rrd, "--step 300 \
DS:inutil:GAUGE:600:0:100 \
DS:oututil:GAUGE:600:0:100 \
DS:outdropped:DERIVE:600:0:125000000000 \
DS:outerrors:DERIVE:600:0:125000000000 \
DS:inerrors:DERIVE:600:0:125000000000 ".$config['rrd_rra']);
2011-11-14 20:25:13 +00:00
}
rrdtool_update($rrd,"N:$chan_update");
2011-11-14 16:53:37 +00:00
}
#print_r($entPhysical_state);
2011-11-14 16:53:37 +00:00
}
// Set Entity state
foreach (dbFetch("SELECT * FROM `entPhysical_state` WHERE `device_id` = ?", array($device['device_id'])) as $entity)
2011-11-14 16:53:37 +00:00
{
if (!isset($entPhysical_state[$entity['entPhysicalIndex']][$entity['subindex']][$entity['group']][$entity['key']]))
2011-11-14 16:53:37 +00:00
{
dbDelete('entPhysical_state', "`device_id` = ? AND `entPhysicalIndex` = ? AND `subindex` = ? AND `group` = ? AND `key` = ?",
2011-11-14 16:53:37 +00:00
array($device['device_id'], $entity['entPhysicalIndex'], $entity['subindex'], $entity['group'], $entity['key']));
} else {
2012-04-05 16:37:46 +00:00
if ($entPhysical_state[$entity['entPhysicalIndex']][$entity['subindex']][$entity['group']][$entity['key']] != $entity['value'])
2011-11-14 16:53:37 +00:00
{
echo("no match!");
}
unset($entPhysical_state[$entity['entPhysicalIndex']][$entity['subindex']][$entity['group']][$entity['key']]);
2011-11-14 16:53:37 +00:00
}
}
// End Set Entity Attrivs
// Delete Entity state
foreach ($entPhysical_state as $epi => $entity)
2011-11-14 16:53:37 +00:00
{
2012-04-05 16:37:46 +00:00
foreach ($entity as $subindex => $si)
2011-11-14 16:53:37 +00:00
{
2012-04-05 16:37:46 +00:00
foreach ($si as $group => $ti)
2011-11-14 16:53:37 +00:00
{
2012-04-05 16:37:46 +00:00
foreach ($ti as $key => $value)
2011-11-14 16:53:37 +00:00
{
dbInsert(array('device_id' => $device['device_id'], 'entPhysicalIndex' => $epi, 'subindex' => $subindex, 'group' => $group, 'key' => $key, 'value' => $value), 'entPhysical_state');
2011-11-14 16:53:37 +00:00
}
}
}
}
// End Delete Entity state
2011-11-14 16:53:37 +00:00
2012-04-08 16:00:32 +00:00
echo("\n");
2011-11-14 16:53:37 +00:00
?>