1) { $instance_id .= ' V2'; } } else { // V3 $instance_id = long2ip($instance['ospfRouterId']); if ($device_routing_count['ospfv3'] > 1) { $instance_id .= ' V3'; } } $port_count = 0; $port_count_enabled = 0; $sql = 'SELECT `ospfIfAdminStat`, COUNT(*) AS `count` FROM `ospf_ports`' . ' WHERE `device_id` = ? AND `ospfVersionNumber` = ? GROUP BY `ospfIfAdminStat`'; foreach (dbFetchRows($sql, $ospf_params) as $entry) { if ($entry['ospfIfAdminStat'] === 'enabled') { $port_count_enabled = (int)$entry['count']; } $port_count += (int)$entry['count']; } $nbr_count = dbFetchCell("SELECT COUNT(*) FROM `ospf_nbrs` WHERE `device_id` = ? AND `ospfVersionNumber` = ?", $ospf_params); if ($instance['ospfAdminStat'] === "enabled") { $enabled = 'enabled'; $row_class = 'up'; } else { $enabled = 'disabled'; $row_class = "disabled"; } if ($instance['ospfAreaBdrRtrStatus'] === "true") { $abr = 'ABR'; } else { $abr = 'no'; } if ($instance['ospfASBdrRtrStatus'] === "true") { $asbr = 'ASBR'; } else { $asbr = 'no'; } echo generate_box_open(); ?>
Router ID
Status
">
ABR
yes
'; } if ($instance['ospfASBdrRtrStatus'] === "true") { echo '
ASBR
yes
'; } ?>
Areas
Ports
Neighbours
'; echo '
'; /// Global Areas Table /// FIXME -- humanize_ospf_area() echo generate_box_open(['title' => 'Areas']); echo(''); $cols = [ [NULL, 'class="state-marker"'], ['Area Id', 'style="width: 125px;"'], 'Status', 'Auth', 'AS External', 'LSAs', 'Area Summary', 'Ports' ]; echo get_table_header($cols, $vars); //echo(''); /// Loop Areas foreach (dbFetchRows("SELECT * FROM `ospf_areas` WHERE `device_id` = ? AND `ospfVersionNumber` = ?", $ospf_params) as $area) { $where_area = []; $where_area[] = '`device_id` = ?'; $where_area[] = '`ospfVersionNumber` = ?'; $where_area[] = generate_query_values($area['ospfAreaId'], 'ospfIfAreaId'); //$port_params[] = $area['ospfAreaId']; $area_port_count = dbFetchCell("SELECT COUNT(*) FROM `ospf_ports` " . generate_where_clause($where_area), $ospf_params); $area_port_count_enabled = dbFetchCell("SELECT COUNT(*) FROM `ospf_ports` " . generate_where_clause($where_area, "`ospfIfAdminStat` = 'enabled'"), $ospf_params); $area_id = $ospf_version === 'version3' ? long2ip($area['ospfAreaId']) : $area['ospfAreaId']; $area_row_class = $area['ospfAreaStatus'] === 'active' ? 'up' : 'disabled'; $enabled = $area['ospfAreaStatus'] === 'active' ? '' . $area['ospfAreaStatus'] . '' : '' . $area['ospfAreaStatus'] . ''; echo(''); echo(' '); echo(' '); echo(' '); echo ' '; echo ' '; echo ' '; echo ' '; echo(' '); echo(''); echo(''); echo('
Area IdStatusAuth TypeAS ExternalArea LSAsArea SummaryPorts
' . $area_id . '' . $enabled . '' . get_type_class_label($area['ospfAuthType'], 'ospfAuthType') . '' . get_type_class_label($area['ospfImportAsExtern'], 'ospfImportAsExtern') . '' . $area['ospfAreaLsaCount'] . '' . get_type_class_label($area['ospfAreaSummary'], 'ospfAreaSummary') . '' . $area_port_count . '(' . $area_port_count_enabled . ')
'); /// Per-Area Ports Table /// FIXME -- humanize_ospf_port() echo generate_box_open(); echo(''); $cols = [ [NULL, 'class="state-marker"'], ['Port', 'style="width: 250px;"'], ['Status', 'style="width: 125px;"'], ['Port Type', 'style="width: 125px;"'], 'Port State' ]; echo get_table_header($cols, $vars); //echo(''); // Loop Ports $p_sql = 'SELECT * FROM `ospf_ports` LEFT JOIN `ports` USING (`device_id`, `port_id`)' . generate_where_clause($where_area, "`ospfIfAdminStat` = 'enabled'"); foreach (dbFetchRows($p_sql, $ospf_params) as $ospfport) { if ($ospfport['ospfIfAdminStat'] === "enabled") { $port_enabled = 'enabled'; $port_row_class = 'up'; } else { $port_enabled = '' . $ospfport['ospfIfAdminStat'] . ''; $port_row_class = 'disabled'; } echo(''); echo(' '); echo(' '); echo(' '); echo(' '); echo(' '); echo(''); } // End loop Ports echo('
PortStatusPort TypePort State
' . generate_port_link($ospfport) . '' . $port_enabled . '' . get_type_class_label($ospfport['ospfIfType'], 'ospfIfType') . '' . get_type_Class_label($ospfport['ospfIfState'], 'ospfIfState') . '
'); echo generate_box_close(); } // End loop areas echo '
'; echo generate_box_close(); echo '
'; // End Areas box echo '
'; /// Global Neighbour Table /// FIXME -- humanize_ospf_neighbour() echo generate_box_open(['title' => 'Neighbours']); echo ''; $cols = [ [NULL, 'class="state-marker"'], ['Router Id', 'style="width: 160px;"'], ['Device', 'style="width: 160px;"'], 'IP Address', 'Status' ]; echo get_table_header($cols, $vars); //echo ''; // Loop Neighbours foreach (dbFetchRows("SELECT * FROM `ospf_nbrs` WHERE `device_id` = ? AND `ospfVersionNumber` = ?", $ospf_params) as $nbr) { if ($ospf_version !== 'version3') { $nbr_router_id = $nbr['ospfNbrRtrId']; } else { $nbr_router_id = long2ip($nbr['ospfNbrRtrId']); } $host = dbFetchRow("SELECT `device_id`, `port_id` FROM `ipv4_addresses` WHERE `ipv4_address` = ?", [$nbr_router_id]); if (is_array($host)) { $rtr_id = generate_device_link($host); } else { $rtr_id = 'unknown'; } echo(''); echo(' '); echo(' '); echo(' '); echo(' '); echo(' '); echo(''); } echo('
Router IdDeviceIP AddressStatus
' . $nbr_router_id . '' . $rtr_id . '' . ip_compress($nbr['ospfNbrIpAddr']) . '' . get_type_class_label($nbr['ospfNbrState'], 'ospfNbrState') . '
'); echo generate_box_close(); echo '
'; } // End loop instances // EOF