'); echo('DeviceRouter IdStatusABRASBRAreasPortsNeighbours'); // Counts $area_counts = []; foreach (dbFetchRows('SELECT `device_id`, COUNT(*) AS `count` FROM `ospf_areas`' . generate_where_clause($GLOBALS['cache']['where']['devices_permitted']) . ' GROUP BY `device_id`') as $entry) { $area_counts[$entry['device_id']] = $entry['count']; } $port_counts = []; foreach (dbFetchRows('SELECT `device_id`, COUNT(*) AS `count` FROM `ospf_ports`' . generate_where_clause($GLOBALS['cache']['where']['devices_permitted']) . ' GROUP BY `device_id`') as $entry) { $port_counts[$entry['device_id']] = $entry['count']; } $port_counts_enabled = []; foreach (dbFetchRows('SELECT `device_id`, COUNT(*) AS `count` FROM `ospf_ports`' . generate_where_clause($GLOBALS['cache']['where']['devices_permitted'], '`ospfIfAdminStat` = "enabled"') . ' GROUP BY `device_id`') as $entry) { $port_counts_enabled[$entry['device_id']] = $entry['count']; } $neighbour_counts = []; foreach (dbFetchRows('SELECT `device_id`, COUNT(*) AS `count` FROM `ospf_nbrs`' . generate_where_clause($GLOBALS['cache']['where']['devices_permitted']) . ' GROUP BY `device_id`') as $entry) { $neighbour_counts[$entry['device_id']] = $entry['count']; } // Loop Instances foreach (dbFetchRows('SELECT * FROM `ospf_instances`' . generate_where_clause($GLOBALS['cache']['where']['devices_permitted'], "`ospfAdminStat` IN ('enabled', 'disabled')")) as $instance) { $device = device_by_id_cache($instance['device_id']); $row_class = ''; if ($instance['ospfAdminStat'] === "enabled") { $enabled = 'enabled'; //$area_count = dbFetchCell('SELECT COUNT(*) FROM `ospf_areas` WHERE `device_id` = ?', array($device['device_id'])); //$port_count = dbFetchCell('SELECT COUNT(*) FROM `ospf_ports` WHERE `device_id` = ?', array($device['device_id'])); //$port_count_enabled = dbFetchCell("SELECT COUNT(*) FROM `ospf_ports` WHERE `ospfIfAdminStat` = 'enabled' AND `device_id` = ?", array($device['device_id'])); //$neighbour_count = dbFetchCell('SELECT COUNT(*) FROM `ospf_nbrs` WHERE `device_id` = ?', array($device['device_id'])); } else { // Skip disabled OSPF processes if (!isset($vars['show_disabled']) && !$vars['show_disabled']) { continue; } $enabled = 'disabled'; $row_class = 'error'; } $area_count = isset($area_counts[$device['device_id']]) ? $area_counts[$device['device_id']] : 0; $port_count = isset($port_counts[$device['device_id']]) ? $port_counts[$device['device_id']] : 0; $port_count_enabled = isset($port_counts_enabled[$device['device_id']]) ? $port_counts_enabled[$device['device_id']] : 0; $neighbour_count = isset($neighbour_counts[$device['device_id']]) ? $neighbour_counts[$device['device_id']] : 0; if ((!$port_count_enabled || !$neighbour_count) && safe_empty($row_class)) { $row_class = 'warning'; } /* $ip_query = "SELECT * FROM ipv4_addresses AS A, ports AS I WHERE "; $ip_query .= "(A.ipv4_address = ? AND I.port_id = A.port_id)"; $ip_query .= " AND I.device_id = ?"; $ipv4_host = dbFetchRow($ip_query, array($peer['bgpPeerIdentifier'], $device['device_id'])); */ if ($instance['ospfAreaBdrRtrStatus'] === "true") { $abr = 'yes'; } else { $abr = 'no'; } if ($instance['ospfASBdrRtrStatus'] === "true") { $asbr = 'yes'; } else { $asbr = 'no'; } echo(''); echo(' ' . generate_device_link($device, NULL, ['tab' => 'routing', 'proto' => 'ospf']) . ''); echo(' ' . $instance['ospfRouterId'] . ''); echo(' ' . $enabled . ''); echo(' ' . $abr . ''); echo(' ' . $asbr . ''); echo(' ' . $area_count . ''); echo(' ' . $port_count . '(' . $port_count_enabled . ')'); echo(' ' . $neighbour_count . ''); echo(''); } // End loop instances echo(''); echo generate_box_close(); // EOF