'class="active"');
DeviceCache::setPrimary($vars['device']);
$device = device_by_id_cache($vars['device']);
$attribs = get_dev_attribs($device['device_id']);
$device['attribs'] = $attribs;
load_os($device);
$entity_state = get_dev_entity_state($device['device_id']);
// print_r($entity_state);
$pagetitle[] = format_hostname($device, $device['hostname']);
$component = new LibreNMS\Component();
$component_count = $component->getComponentCount($device['device_id']);
$alert_class = '';
if ($device['disabled'] == '1') {
$alert_class = 'alert-info';
} elseif ($device['status'] == '0') {
$alert_class = 'alert-danger';
}
echo '
';
echo '
';
require 'includes/html/device-header.inc.php';
echo '
';
echo '
';
if (device_permitted($device['device_id'])) {
echo '';
if (Config::get('show_overview_tab')) {
echo '
Overview
';
}
echo '
Graphs
';
$health = dbFetchCell("SELECT COUNT(*) FROM storage WHERE device_id = ?", array($device['device_id'])) +
dbFetchCell("SELECT COUNT(*) FROM sensors WHERE device_id = ?", array($device['device_id'])) +
dbFetchCell("SELECT COUNT(*) FROM mempools WHERE device_id = ?", array($device['device_id'])) +
dbFetchCell("SELECT COUNT(*) FROM processors WHERE device_id = ?", array($device['device_id'])) +
count_mib_health($device);
if ($health) {
echo '
Health
';
}
if (dbFetchCell("SELECT 1 FROM applications WHERE device_id = ?", array($device['device_id']))) {
echo '
Apps
';
}
if (dbFetchCell("SELECT 1 FROM processes WHERE device_id = ?", array($device['device_id']))) {
echo '
Processes
';
}
if (Config::has('collectd_dir') && is_dir(Config::get('collectd_dir') . '/' . $device['hostname'] . '/')) {
echo '
CollectD
';
}
if (dbFetchCell("SELECT 1 FROM munin_plugins WHERE device_id = ?", array($device['device_id']))) {
echo '
Munin
';
}
if (dbFetchCell("SELECT 1 FROM ports WHERE device_id = ?", array($device['device_id']))) {
echo '
Ports
';
}
if (dbFetchCell("SELECT 1 FROM slas WHERE device_id = ?", array($device['device_id']))) {
echo '
SLAs
';
}
if (dbFetchCell('SELECT 1 FROM `wireless_sensors` WHERE `device_id`=?', array($device['device_id']))) {
echo '
Wireless
';
}
if (dbFetchCell("SELECT 1 FROM access_points WHERE device_id = ?", array($device['device_id']))) {
echo '
Access Points
';
}
$smokeping_files = get_smokeping_files($device);
if (count($smokeping_files['in'][$device['hostname']]) || count($smokeping_files['out'][$device['hostname']])) {
echo '
Ping
';
}
if (dbFetchCell("SELECT 1 FROM vlans WHERE device_id = ?", array($device['device_id']))) {
echo '
VLANs
';
}
if (dbFetchCell("SELECT 1 FROM vminfo WHERE device_id = ?", array($device['device_id']))) {
echo '
Virtual Machines
';
}
if (dbFetchCell("SELECT 1 FROM mefinfo WHERE device_id = ?", array($device['device_id']))) {
echo '
Metro Ethernet
';
}
if ($device['os'] == 'coriant') {
if (dbFetchCell("SELECT 1 FROM tnmsneinfo WHERE device_id = ?", array($device['device_id']))) {
echo '
Hardware
';
}
}
// $loadbalancer_tabs is used in device/loadbalancer/ to build the submenu. we do it here to save queries
if ($device['os'] == 'netscaler') {
// Netscaler
$device_loadbalancer_count['netscaler_vsvr'] = dbFetchCell('SELECT COUNT(*) FROM `netscaler_vservers` WHERE `device_id` = ?', array($device['device_id']));
if ($device_loadbalancer_count['netscaler_vsvr']) {
$loadbalancer_tabs[] = 'netscaler_vsvr';
}
}
if ($device['os'] == 'acsw') {
// Cisco ACE
$device_loadbalancer_count['loadbalancer_vservers'] = dbFetchCell('SELECT COUNT(*) FROM `loadbalancer_vservers` WHERE `device_id` = ?', array($device['device_id']));
if ($device_loadbalancer_count['loadbalancer_vservers']) {
$loadbalancer_tabs[] = 'loadbalancer_vservers';
}
}
// F5 LTM
if (isset($component_count['f5-ltm-vs'])) {
$device_loadbalancer_count['ltm_vs'] = $component_count['f5-ltm-vs'];
$loadbalancer_tabs[] = 'ltm_vs';
}
if (isset($component_count['f5-ltm-pool'])) {
$device_loadbalancer_count['ltm_pool'] = $component_count['f5-ltm-pool'];
$loadbalancer_tabs[] = 'ltm_pool';
}
if (isset($component_count['f5-gtm-wide'])) {
$device_loadbalancer_count['gtm_wide'] = $component_count['f5-gtm-wide'];
$loadbalancer_tabs[] = 'gtm_wide';
}
if (isset($component_count['f5-gtm-pool'])) {
$device_loadbalancer_count['gtm_pool'] = $component_count['f5-gtm-pool'];
$loadbalancer_tabs[] = 'gtm_pool';
}
if (is_array($loadbalancer_tabs)) {
echo '
Load Balancer
';
}
// $routing_tabs is used in device/routing/ to build the tabs menu. we built it here to save some queries
$device_routing_count['loadbalancer_rservers'] = dbFetchCell('SELECT COUNT(*) FROM `loadbalancer_rservers` WHERE `device_id` = ?', array($device['device_id']));
if ($device_routing_count['loadbalancer_rservers']) {
$routing_tabs[] = 'loadbalancer_rservers';
}
$device_routing_count['ipsec_tunnels'] = dbFetchCell('SELECT COUNT(*) FROM `ipsec_tunnels` WHERE `device_id` = ?', array($device['device_id']));
if ($device_routing_count['ipsec_tunnels']) {
$routing_tabs[] = 'ipsec_tunnels';
}
$device_routing_count['bgp'] = dbFetchCell('SELECT COUNT(*) FROM `bgpPeers` WHERE `device_id` = ?', array($device['device_id']));
if ($device_routing_count['bgp']) {
$routing_tabs[] = 'bgp';
}
$device_routing_count['ospf'] = dbFetchCell("SELECT COUNT(*) FROM `ospf_instances` WHERE `ospfAdminStat` = 'enabled' AND `device_id` = ?", array($device['device_id']));
if ($device_routing_count['ospf']) {
$routing_tabs[] = 'ospf';
}
$device_routing_count['cef'] = dbFetchCell('SELECT COUNT(*) FROM `cef_switching` WHERE `device_id` = ?', array($device['device_id']));
if ($device_routing_count['cef']) {
$routing_tabs[] = 'cef';
}
$device_routing_count['vrf'] = @dbFetchCell('SELECT COUNT(*) FROM `vrfs` WHERE `device_id` = ?', array($device['device_id']));
if ($device_routing_count['vrf']) {
$routing_tabs[] = 'vrf';
}
$device_routing_count['mpls'] = @dbFetchCell('SELECT COUNT(*) FROM `mpls_lsps` WHERE `device_id` = ?', array($device['device_id']));
if ($device_routing_count['mpls']) {
$routing_tabs[] = 'mpls';
}
$device_routing_count['cisco-otv'] = $component_count['Cisco-OTV'];
if ($device_routing_count['cisco-otv'] > 0) {
$routing_tabs[] = 'cisco-otv';
}
if (is_array($routing_tabs)) {
echo '
Routing
';
}
if (dbFetchCell('SELECT 1 FROM `pseudowires` WHERE `device_id` = ?', array($device['device_id']))) {
echo '
Pseudowires
';
}
if (dbFetchCell("SELECT 1 FROM `links` where `local_device_id`=?", array($device['device_id']))) {
echo '
Neighbours
';
}
if (dbFetchCell("SELECT 1 FROM stp WHERE device_id = ?", array($device['device_id']))) {
echo '
STP
';
}
if (dbFetchCell("SELECT 1 FROM `packages` WHERE device_id = ?", array($device['device_id']))) {
echo '
Pkgs
';
}
if (Config::get('enable_inventory')) {
if (dbFetchCell("SELECT 1 FROM `entPhysical` WHERE device_id = ?", array($device['device_id']))) {
echo '
Inventory
';
} elseif (@dbFetchCell("SELECT 1 FROM `hrDevice` WHERE device_id = ?", array($device['device_id']))) {
echo '
Inventory
';
}
}
if (Config::get('show_services')) {
echo '
Services
';
}
if (dbFetchCell("SELECT 1 FROM toner WHERE device_id = ?", array($device['device_id']))) {
echo '
Toner
';
}
echo '
Logs
';
echo '
Alerts
';
echo '
Alert Stats
';
if (Auth::user()->hasGlobalAdmin()) {
foreach ((array)Config::get('rancid_configs', []) as $configs) {
if ($configs[(strlen($configs) - 1)] != '/') {
$configs .= '/';
}
if (is_file($configs.$device['hostname'])) {
$device_config_file = $configs.$device['hostname'];
} elseif (is_file($configs.strtok($device['hostname'], '.'))) { // Strip domain
$device_config_file = $configs.strtok($device['hostname'], '.');
} else {
if (!empty(Config::get('mydomain'))) { // Try with domain name if set
if (is_file($configs . $device['hostname'] . '.' . Config::get('mydomain'))) {
$device_config_file = $configs . $device['hostname'] . '.' . Config::get('mydomain');
}
}
} // end if
}
if (Config::get('oxidized.enabled') === true && !in_array($device['type'], Config::get('oxidized.ignore_types')) && Config::has('oxidized.url')) {
$device_config_file = true;
}
}
if ($device_config_file) {
if (!get_dev_attrib($device, 'override_Oxidized_disable') === 'true') {
echo '
Config
';
}
}
if (Config::get('nfsen_enable')) {
foreach ((array)Config::get('nfsen_rrds', []) as $nfsenrrds) {
if ($nfsenrrds[(strlen($nfsenrrds) - 1)] != '/') {
$nfsenrrds .= '/';
}
$nfsensuffix = Config::get('nfsen_suffix', '');
if (Config::get('nfsen_split_char')) {
$basefilename_underscored = preg_replace('/\./', Config::get('nfsen_split_char'), $device['hostname']);
} else {
$basefilename_underscored = $device['hostname'];
}
$nfsen_filename = preg_replace('/'.$nfsensuffix.'/', '', $basefilename_underscored);
if (is_file($nfsenrrds.$nfsen_filename.'.rrd')) {
$nfsen_rrd_file = $nfsenrrds.$nfsen_filename.'.rrd';
}
}
}//end if
if ($nfsen_rrd_file) {
echo '
Netflow
';
}
if (can_ping_device($attribs) === true) {
echo '
Performance
';
}
if (PortsNac::where('device_id', $device['device_id'])->exists()) {
echo '
NAC
';
}
echo '
Notes
';
if (is_mib_poller_enabled($device)) {
echo '
MIB
';
}
echo '
';
echo ' ';
}//end if device_permitted
// include the tabcontent
echo '';
require 'includes/html/pages/device/'.filter_var(basename($tab), FILTER_SANITIZE_URL).'.inc.php';
echo '
';
} else {
// no device permissions
require 'includes/html/error-no-perm.inc.php';
}