/** * Display device inventory hierarchy. * * @param string $ent, $level, $class * @return none * */ function print_ent_physical($ent, $level, $class) { global $device; $ents = dbFetchRows("SELECT * FROM `entPhysical` WHERE `device_id` = ? AND `entPhysicalContainedIn` = ? ORDER BY `entPhysicalContainedIn`, `entPhysicalIndex`", array($device['device_id'], $ent)); foreach ($ents as $ent) { $link = ''; $text = " <li class='{$class}'>"; /* Currently no icons for: JUNIPER-MIB::jnxFruType.10.1.1.0 = INTEGER: frontPanelModule(8) JUNIPER-MIB::jnxFruType.12.1.0.0 = INTEGER: controlBoard(5) For Geist RCX, IPOMan: outlet relay */ switch ($ent['entPhysicalClass']) { case 'chassis': $text .= '<i class="oicon-database"></i> '; break; case 'module': case 'portInterfaceCard': $text .= '<i class="oicon-drive"></i> '; break; case 'port': $text .= '<i class="oicon-network-ethernet"></i> '; break; case 'container': case 'flexiblePicConcentrator': $text .= '<i class="oicon-box-zipper"></i> '; break; case 'stack': $text .= '<i class="oicon-databases"></i> '; break; case 'fan': case 'airflowSensor': $text .= '<i class="oicon-weather-wind"></i> '; break; case 'powerSupply': case 'powerEntryModule': $text .= '<i class="oicon-plug"></i> '; break; case 'backplane': $text .= '<i class="oicon-zones"></i> '; break; case 'sensor': $text .= '<i class="oicon-asterisk"></i> '; $sensor = dbFetchRow("SELECT * FROM `sensors` AS S\n LEFT JOIN `sensors-state` AS ST ON S.`sensor_id` = ST.`sensor_id`\n WHERE `device_id` = ? AND (`entPhysicalIndex` = ? OR `sensor_index` = ?)", array($device['device_id'], $ent['entPhysicalIndex'], $ent['entPhysicalIndex'])); break; default: $text .= '<i class="oicon-chain"></i> '; } if ($ent['entPhysicalParentRelPos'] > '-1') { $text .= '<strong>' . $ent['entPhysicalParentRelPos'] . '.</strong> '; } $ent_text = ''; if ($ent['ifIndex']) { $interface = get_port_by_ifIndex($device['device_id'], $ent['ifIndex']); $ent['entPhysicalName'] = generate_port_link($interface); } if ($ent['entPhysicalModelName'] && $ent['entPhysicalName']) { $ent_text .= "<strong>" . $ent['entPhysicalModelName'] . "</strong> (" . $ent['entPhysicalName'] . ")"; } elseif ($ent['entPhysicalModelName']) { $ent_text .= "<strong>" . $ent['entPhysicalModelName'] . "</strong>"; } elseif (is_numeric($ent['entPhysicalName']) && $ent['entPhysicalVendorType']) { $ent_text .= "<strong>" . $ent['entPhysicalName'] . " " . $ent['entPhysicalVendorType'] . "</strong>"; } elseif ($ent['entPhysicalName']) { $ent_text .= "<strong>" . $ent['entPhysicalName'] . "</strong>"; } elseif ($ent['entPhysicalDescr']) { $ent_text .= "<strong>" . $ent['entPhysicalDescr'] . "</strong>"; } $ent_text .= "<br /><div class='small' style='margin-left: 20px;'>" . $ent['entPhysicalDescr']; if ($ent['entPhysicalClass'] == "sensor" && $sensor['sensor_value']) { $ent_text .= ' (' . $sensor['sensor_value'] . ' ' . $sensor['sensor_class'] . ')'; $link = generate_entity_link('sensor', $sensor, $ent_text, NULL, FALSE); } $text .= $link ? $link : $ent_text; if ($ent['entPhysicalSerialNum']) { $text .= ' <span class="text-info">[Serial: ' . $ent['entPhysicalSerialNum'] . ']</span> '; } $text .= "</div>"; echo $text; $count = dbFetchCell("SELECT COUNT(*) FROM `entPhysical` WHERE `device_id` = ? AND `entPhysicalContainedIn` = ?", array($device['device_id'], $ent['entPhysicalIndex'])); if ($count) { echo "<ul>"; print_ent_physical($ent['entPhysicalIndex'], $level + 1, ''); echo "</ul>"; } echo "</li>"; } }
function get_port_by_index_cache($device_id, $ifIndex) { global $port_index_cache; if (isset($port_index_cache[$device_id][$ifIndex]) && is_array($port_index_cache[$device_id][$ifIndex])) { $port = $port_index_cache[$device_id][$ifIndex]; } else { $port = get_port_by_ifIndex($device_id, $ifIndex); $port_index_cache[$device_id][$ifIndex] = $port; } return $port; }
if ($wlan['wlan_admin_status'] == "1") { $wlan['row_class'] = "up"; } else { $wlan['row_class'] = "disabled"; } if ($wlan['wlan_igmp_snoop'] == "1") { $wlan['igmp_label'] = '<span class="label label-success">IGMP Snooping</span>'; } else { $wlan['igmp_label'] = '<span class="label label-disabled">Disabled</span>'; } if ($wlan['wlan_ssid_bcast'] == "0") { $wlan['ssid_bcast_label'] = ' <span class="pull-right label label-disabled">Hidden SSID</span>'; } else { $wlan['ssid_bcast_label'] = ''; } if ($port = get_port_by_ifIndex($device['device_id'], $wlan['wlan_index'])) { $wlan['port_link'] = generate_entity_link('port', $port); } echo '<tr class="' . $wlan['row_class'] . '"> <td class="state-marker"></td>'; echo '<td><span class="entity">' . generate_entity_link('wifi_wlan', $wlan) . $wlan['ssid_bcast_label'] . '</span><br />' . $wlan['wlan_ssid'] . '</td>'; echo '<td><span class="entity">' . $wlan['port_link'] . '</span></td>'; echo '<td>' . $wlan['wlan_bssid'] . '<br />' . $wlan['wlan_bss_type'] . '</td>'; echo '<td>' . $wlan['type'] . '<br />Ch.' . $wlan['wlan_channel'] . ' (' . $wlan['freq'] . 'MHz)</td>'; echo '<td>' . $wlan['wlan_prot_mode'] . '<br />' . $wlan['igmp_label'] . '</td>'; echo '<td>' . $wlan['wlan_beacon_period'] . 'ms<br />' . $wlan['wlan_dtim_period'] . '</td>'; echo '<td>' . $wlan['wlan_frag_thresh'] . 'B<br />' . $wlan['wlan_rts_thresh'] . 'B</td>'; echo '</tr>'; } echo "</table>"; $pagetitle[] = "Radios";
// Continue populating service policies $service_policies = snmpwalk_cache_oid($device, "cbQosPolicyDirection", $service_policies, "CISCO-CLASS-BASED-QOS-MIB"); $service_policies = snmpwalk_cache_oid($device, "cbQosIfIndex", $service_policies, "CISCO-CLASS-BASED-QOS-MIB"); # $policy_maps = snmpwalk_cache_oid($device, "cbQosPolicyMapCfgEntry", array(), "CISCO-CLASS-BASED-QOS-MIB"); # $class_maps = snmpwalk_cache_oid($device, "cbQosCMCfgEntry", array(), "CISCO-CLASS-BASED-QOS-MIB"); # $object_indexes = snmpwalk_cache_twopart_oid($device, "cbQosConfigIndex", array(), "CISCO-CLASS-BASED-QOS-MIB"); #print_r($policy_maps); #print_r($class_maps); #print_r($object_indexes); $cm_stats = array(); foreach ($oids as $oid) { $cm_stats = snmpwalk_cache_twopart_oid($device, $oid, $cm_stats, "CISCO-CLASS-BASED-QOS-MIB"); } foreach ($cm_stats as $policy_index => $policy_entry) { foreach ($policy_entry as $object_index => $object_entry) { $port = get_port_by_ifIndex($device['device_id'], $service_policies[$policy_index]['cbQosIfIndex']); $object_entry['port_id'] = $port['port_id']; $object_entry['direction'] = $service_policies[$policy_index]['cbQosPolicyDirection']; $object_entry['policy_index'] = $policy_index; $object_entry['object_index'] = $object_index; $object_entry['cm_cfg_index'] = $object_indexes[$policy_index][$object_index]['cbQosConfigIndex']; $object_entry['pm_cfg_index'] = $object_indexes[$policy_index][$policy_index]['cbQosConfigIndex']; if (!is_numeric($object_entry['pm_cfg_index'])) { $object_entry['pm_cfg_index'] = $object_indexes[$policy_index]['1']['cbQosConfigIndex']; } $object_entry['policy_name'] = $policy_maps[$object_entry['pm_cfg_index']]['cbQosPolicyMapName']; $object_entry['policy_desc'] = $policy_maps[$object_entry['pm_cfg_index']]['cbQosPolicyMapDesc']; $object_entry['cm_name'] = $class_maps[$object_entry['cm_cfg_index']]['cbQosCMName']; $object_entry['cm_desc'] = $class_maps[$object_entry['cm_cfg_index']]['cbQosCMDesc']; $object_entry['cm_info'] = $class_maps[$object_entry['cm_cfg_index']]['cbQosCMInfo']; #print_r($object_entry);
cyanTENGPortSecServState.1.1.1.1 = "80 " cyanTENGPortSignalType.1.1.1.1 = tp10gelan cyanTENGPortTransmitControl.1.1.1.1 = on cyanTENGPortTxPwr.1.1.1.1 = 0 cyanTENGPortTxStatus.1.1.1.1 = on */ $data = array(); $oids = array('cyanTENGPortRxPwr', 'cyanTENGPortTxPwr'); foreach ($oids as $oid) { $data = snmpwalk_cache_oid($device, $oid, $data, 'CYAN-TENGPORT-MIB'); } // Try to identify which IF-MIB port is being referred to, and populate the 'measured_entity' if we can. $ifNames = snmpwalk_cache_oid($device, 'ifName', array(), 'IF-MIB'); foreach ($ifNames as $ifIndex => $entry) { list(, $cyan_index) = explode("-", $entry['ifName'], 2); if ($port = get_port_by_ifIndex($device['device_id'], $ifIndex)) { $port_translates[$cyan_index]['measured_entity'] = $port['port_id']; } } foreach ($data as $index => $entry) { list($shelf_id, $mod_id, $xcvr_id, $port_id) = explode(".", $index); $descr = "Transceiver " . $shelf_id . "-" . $mod_id . "-" . $xcvr_id . " (" . $port_id . ")"; $xcvr_string = $shelf_id . "-" . $mod_id . "-" . $xcvr_id; $options = array(); if (isset($port_translates[$xcvr_string]['measured_entity'])) { $options['measured_entity'] = $port_translates[$xcvr_string]['measured_entity']; $options['measured_class'] = 'port'; } // $options['limit_high'] = $entry['cyanXcvrTxBiasHiAlrmThres'] * 0.001; // $options['limit_low'] = $entry['cyanXcvrTxBiasLoAlrmThres'] * 0.001; // $options['warn_high'] = $entry['cyanXcvrTxBiasHiWarnThres'] * 0.001;
# foreach ($a as $key_b => $b) # { # foreach ($b as $key_c => $c) # { # $new_array[] = array($key_a, $key_b, $key_c, $c); # } # } # } # return $new_array; #} if (count($ma_array)) { $polled = time(); $mac_entries = 0; echo "Entries: " . $ma_db[$id] . PHP_EOL; foreach ($ma_array as $id => $ma) { $port = get_port_by_ifIndex($device['device_id'], $ma['ifIndex']); echo ' ' . $id . ' '; if (!is_array($ma_db_array[$id])) { dbInsert(array('port_id' => $port['port_id'], 'device_id' => $device['device_id'], 'vlan_id' => $ma['vlan'], 'mac' => $ma['mac']), 'mac_accounting'); $ma_id = dbFetchCell("SELECT * FROM mac_accounting WHERE port_id = ? AND device_id = ? AND vlan_id = ? AND mac = ?", array($port['port_id'], $device['device_id'], $ma['vlan'], $ma['mac'])); dbInsert(array('ma_id' => $ma_id), 'mac_accounting-state'); echo "+"; } else { $ma_db = $ma_db_array[$id]; } $polled_period = $polled - $acc['poll_time']; if ($debug) { print_vars($ma_array[$ifIndex][$vlan_id][$mac]); } $ma['update']['poll_time'] = $polled; $ma['update']['poll_period'] = $polled_period;