case 'errors': $ports = array_sort($ports, 'ifErrors_rate', SORT_DESC); break; case 'speed': $ports = array_sort($ports, 'ifSpeed', SORT_DESC); break; case 'port': $ports = array_sort($ports, 'ifDescr', SORT_ASC); break; case 'media': $ports = array_sort($ports, 'ifType', SORT_ASC); break; case 'descr': $ports = array_sort($ports, 'ifAlias', SORT_ASC); break; case 'device': default: $ports = array_sort($ports, 'hostname', SORT_ASC); } //end switch $csv[] = array('Device', 'Port', 'Speed', 'Down', 'Up', 'Media', 'Description'); foreach ($ports as $port) { if (port_permitted($port['port_id'], $port['device_id'])) { $speed = humanspeed($port['ifSpeed']); $type = humanmedia($port['ifType']); $port['in_rate'] = formatRates($port['ifInOctets_rate'] * 8); $port['out_rate'] = formatRates($port['ifOutOctets_rate'] * 8); $port = ifLabel($port, $device); $csv[] = array($port['hostname'], fixIfName($port['label']), $speed, $port['in_rate'], $port['out_rate'], $type, $port['ifAlias']); } }
function generate_ap_link($args, $text = null, $type = null) { global $config; $args = ifNameDescr($args); if (!$text) { $text = fixIfName($args['label']); } if ($type) { $args['graph_type'] = $type; } if (!isset($args['graph_type'])) { $args['graph_type'] = 'port_bits'; } if (!isset($args['hostname'])) { $args = array_merge($args, device_by_id_cache($args['device_id'])); } $content = '<div class=list-large>' . $args['text'] . ' - ' . fixifName($args['label']) . '</div>'; if ($args['ifAlias']) { $content .= $args['ifAlias'] . '<br />'; } $content .= "<div style=\\'width: 850px\\'>"; $graph_array = array(); $graph_array['type'] = $args['graph_type']; $graph_array['legend'] = 'yes'; $graph_array['height'] = '100'; $graph_array['width'] = '340'; $graph_array['to'] = $config['time']['now']; $graph_array['from'] = $config['time']['day']; $graph_array['id'] = $args['accesspoint_id']; $content .= generate_graph_tag($graph_array); $graph_array['from'] = $config['time']['week']; $content .= generate_graph_tag($graph_array); $graph_array['from'] = $config['time']['month']; $content .= generate_graph_tag($graph_array); $graph_array['from'] = $config['time']['year']; $content .= generate_graph_tag($graph_array); $content .= '</div>'; $url = generate_ap_url($args); if (port_permitted($args['interface_id'], $args['device_id'])) { return overlib_link($url, $text, $content, null); } else { return fixifName($text); } }
$ports_disabled = 0; $ports_down = 0; $ports_up = 0; $ports_total = 0; foreach ($ports as $port) { if (port_permitted($port['port_id'], $port['device_id'])) { if ($port['ifAdminStatus'] == "down") { $ports_disabled++; } elseif ($port['ifAdminStatus'] == "up" && $port['ifOperStatus'] == "down") { $ports_down++; } elseif ($port['ifAdminStatus'] == "up" && $port['ifOperStatus'] == "up") { $ports_up++; } $ports_total++; $speed = humanspeed($port['ifSpeed']); $type = humanmedia($port['ifType']); $ifclass = ifclass($port['ifOperStatus'], $port['ifAdminStatus']); if (isset($port['in_errors']) && $port['in_errors'] > 0 || isset($ports['out_errors']) && $port['out_errors'] > 0) { $error_img = generate_port_link($port, "<img src='images/16/chart_curve_error.png' alt='Interface Errors' border=0>", errors); } else { $error_img = ""; } $port['in_rate'] = formatRates($port['ifInOctets_rate'] * 8); $port['out_rate'] = formatRates($port['ifOutOctets_rate'] * 8); $port = ifLabel($port, $device); echo "<tr class='ports'>\n <td width=200 class=list-bold>" . generate_device_link($port, shorthost($port['hostname'], "20")) . "</td>\n <td width=150 class=list-bold><a class='" . $ifclass . "'href='" . generate_port_url($port) . "'>" . fixIfName($port['label']) . " {$error_img}</td>\n <td width=110 >{$speed}</td>\n <td width=100 class=green>" . $port['in_rate'] . "</td>\n <td width=100 class=blue>" . $port['out_rate'] . "</td>\n <td width=150>{$type}</td>\n <td>" . $port['ifAlias'] . "</td>\n </tr>\n"; } } echo '<tr><td colspan="7">'; echo "<strong>Matched Ports: {$ports_total} ( <span class=green>Up {$ports_up}</span> | <span class=red>Down {$ports_down}</span> | Disabled {$ports_disabled} )</strong>"; echo '</td></tr></table>';
function generateiflink($interface, $text = 0, $type = NULL) { global $twoday; global $now; global $config; global $day; global $month; $interface = ifNameDescr($interface); if (!$text) { $text = fixIfName($interface['label']); } if (isset($type)) { $interface['graph_type'] = $type; } else { $interface['graph_type'] = 'port_bits'; } if (!isset($interface['hostname'])) { $interface = array_merge($interface, device_by_id_cache($interface['device_id'])); } $class = ifclass($interface['ifOperStatus'], $interface['ifAdminStatus']); $graph_url = $config['base_url'] . "/graph.php?port=" . $interface['interface_id'] . "&from={$day}&to={$now}&width=400&height=100&type=" . $interface['graph_type']; $graph_url_month = $config['base_url'] . "/graph.php?port=" . $interface['interface_id'] . "&from={$month}&to={$now}&width=400&height=100&type=" . $interface['graph_type']; $device_id = getifhost($interface['interface_id']); $url = $config['base_url'] . "/device/{$device_id}/interface/" . $interface['interface_id'] . "/"; $contents = "<div class=list-large>" . $interface['hostname'] . " - " . fixifName($interface['label']) . "</div>"; if ($interface['ifAlias']) { $contents .= htmlentities($interface['ifAlias'] . "<br />"); } $contents .= "<img src=\\'{$graph_url}\\'><br /><img src=\\'{$graph_url_month}\\'>"; $link = overlib_link($url, $text, $contents, $class); return $link; }
function generate_ap_link($args, $text = NULL, $type = NULL) { global $config; if (isset($args['humanized']) == false) { humanize_port($args); } if (!$text) { $text = fixIfName($args['label']); } if ($type) { $args['graph_type'] = $type; } if (!isset($args['graph_type'])) { $args['graph_type'] = 'port_bits'; } if (!isset($args['hostname'])) { $args = array_merge($args, device_by_id_cache($args['device_id'])); } $content = "<div class=entity-title>" . $args['text'] . " - " . fixifName($args['label']) . "</div>"; if ($args['ifAlias']) { $content .= $args['ifAlias'] . "<br />"; } $content .= "<div style=\\'width: 850px\\'>"; $graph_array['type'] = $args['graph_type']; $graph_array['legend'] = "yes"; $graph_array['height'] = "100"; $graph_array['width'] = "340"; $graph_array['to'] = $config['time']['now']; $graph_array['from'] = $config['time']['day']; $graph_array['id'] = $args['accesspoint_id']; $content .= generate_graph_tag($graph_array); $graph_array['from'] = $config['time']['week']; $content .= generate_graph_tag($graph_array); $graph_array['from'] = $config['time']['month']; $content .= generate_graph_tag($graph_array); $graph_array['from'] = $config['time']['year']; $content .= generate_graph_tag($graph_array); $content .= "</div>"; $url = generate_ap_url($args); if (port_permitted($args['interface_id'], $args['device_id'])) { return overlib_link($url, $text, $content, $class); } else { return fixifName($text); } }
# if (port_permitted($port['port_id'], $port['device_id'])) # { if ($port['ifAdminStatus'] == "down") { $ports_disabled++; $table_tab_colour = "#aaaaaa"; } elseif ($port['ifAdminStatus'] == "up" && $port['ifOperStatus'] == "down") { $ports_down++; $table_tab_colour = "#cc0000"; } elseif ($port['ifAdminStatus'] == "up" && $port['ifOperStatus'] == "lowerLayerDown") { $ports_down++; $table_tab_colour = "#ff6600"; } elseif ($port['ifAdminStatus'] == "up" && $port['ifOperStatus'] == "up") { $ports_up++; $table_tab_colour = "#194B7F"; } $ports_total++; humanize_port($port); if ($port['in_errors'] > 0 || $port['out_errors'] > 0) { $error_img = generate_port_link($port, "<img src='images/16/chart_curve_error.png' alt='Interface Errors' border=0>", errors); } else { $error_img = ""; } $port['bps_in'] = formatRates($port['ifInOctets_rate'] * 8); $port['bps_out'] = formatRates($port['ifOutOctets_rate'] * 8); $port['pps_in'] = format_si($port['ifInUcastPkts_rate']) . "pps"; $port['pps_out'] = format_si($port['ifOutUcastPkts_rate']) . "pps"; echo "<tr class='ports'>\n <td style='background-color: " . $table_tab_colour . ";'></td>\n <td></td>\n <td><span class=entity>" . generate_device_link($port, shorthost($port['hostname'], "20")) . "</span><br />\n <span class=em>" . truncate($port['location'], 32, "") . "</span></td>\n\n <td><span class=entity>" . generate_port_link($port, fixIfName($port['label'])) . " " . $error_img . "</span><br />\n <span class=em>" . truncate($port['ifAlias'], 50, '') . "</span></td>\n <td><span class=green>↓ " . $port['bps_in'] . "<br />\n <span class=blue>↑ " . $port['bps_out'] . "<br />\n\n <td><span class=green>" . $port['ifInOctets_perc'] . "%<br />\n <span class=blue>" . $port['ifOutOctets_perc'] . "%<br />\n\n <td><span class=purple>↓ " . $port['pps_in'] . "<br />\n <span class=orange>↑ " . $port['pps_out'] . "<br />\n <td>" . $port['human_speed'] . "<br />" . $port['ifMtu'] . "</td>\n <td >" . $port['human_type'] . "<br />" . $port['human_mac'] . "</td>\n </tr>\n"; # } } echo '</td></tr></table>'; echo pagination($vars, count($ports));