'); echo(' Device Router Id Version Status ABR ASBR Areas Ports Neighbours '); // Counts $area_counts = []; foreach (dbFetchRows('SELECT `device_id`, `ospfVersionNumber`, COUNT(*) AS `count` FROM `ospf_areas`' . generate_where_clause($GLOBALS['cache']['where']['devices_permitted']) . ' GROUP BY `device_id`, `ospfVersionNumber`') as $entry) { $area_counts[$entry['device_id']][$entry['ospfVersionNumber']] = $entry['count']; } $port_counts = []; foreach (dbFetchRows('SELECT `device_id`, `ospfVersionNumber`, COUNT(*) AS `count` FROM `ospf_ports`' . generate_where_clause($GLOBALS['cache']['where']['devices_permitted']) . ' GROUP BY `device_id`, `ospfVersionNumber`') as $entry) { $port_counts[$entry['device_id']][$entry['ospfVersionNumber']] = $entry['count']; } $port_counts_enabled = []; foreach (dbFetchRows('SELECT `device_id`, `ospfVersionNumber`, COUNT(*) AS `count` FROM `ospf_ports`' . generate_where_clause($GLOBALS['cache']['where']['devices_permitted'], '`ospfIfAdminStat` = "enabled"') . ' GROUP BY `device_id`, `ospfVersionNumber`') as $entry) { $port_counts_enabled[$entry['device_id']][$entry['ospfVersionNumber']] = $entry['count']; } $neighbour_counts = []; foreach (dbFetchRows('SELECT `device_id`, `ospfVersionNumber`, COUNT(*) AS `count` FROM `ospf_nbrs`' . generate_where_clause($GLOBALS['cache']['where']['devices_permitted']) . ' GROUP BY `device_id`, `ospfVersionNumber`') as $entry) { $neighbour_counts[$entry['device_id']][$entry['ospfVersionNumber']] = $entry['count']; } // Loop Instances foreach (dbFetchRows('SELECT * FROM `ospf_instances`' . generate_where_clause(generate_query_values([ 'enabled', 'disabled' ], 'ospfAdminStat'), $GLOBALS['cache']['where']['devices_permitted']) . " ORDER BY `device_id`, `ospfVersionNumber`") as $instance) { $device = device_by_id_cache($instance['device_id']); $ospf_version = $instance['ospfVersionNumber']; if ($ospf_version === 'version3' && !filter_var($instance['ospfRouterId'], FILTER_VALIDATE_IP)) { $instance['ospfRouterId'] = long2ip($instance['ospfRouterId']); } $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 = $area_counts[$device['device_id']][$ospf_version] ?? 0; $port_count = $port_counts[$device['device_id']][$ospf_version] ?? 0; $port_count_enabled = $port_counts_enabled[$device['device_id']][$ospf_version] ?? 0; $neighbour_count = $neighbour_counts[$device['device_id']][$ospf_version] ?? 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 = 'ABR'; } else { $abr = 'no'; } if ($instance['ospfASBdrRtrStatus'] === "true") { $asbr = 'ASBR'; } else { $asbr = 'no'; } echo ''; echo ' ' . generate_device_link($device, NULL, ['tab' => 'routing', 'proto' => ($instance['ospfVersionNumber'] == 'version3' ? 'ospfv3' : 'ospf')]) . ''; echo ' ' . $instance['ospfRouterId'] . ''; echo ' '.($instance['ospfVersionNumber'] == "version3" ? 'v3' : 'v2').''; 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