function ifNameDescr($interface, $device = null) { return ifLabel($interface, $device); }
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']); } }
<?php $hostname = gethostbyid($entry['host']); unset($icon); $icon = geteventicon($entry['message']); if ($icon) { $icon = '<img src="images/16/' . $icon . '" />'; } echo '<tr> <td> ' . $entry['datetime'] . ' </td>'; if (!isset($vars['device'])) { $dev = device_by_id_cache($entry['host']); echo '<td> ' . generate_device_link($dev, shorthost($dev['hostname'])) . ' </td>'; } if ($entry['type'] == 'interface') { $this_if = ifLabel(getifbyid($entry['reference'])); $entry['link'] = '<b>' . generate_port_link($this_if, makeshortif(strtolower($this_if['label']))) . '</b>'; } else { $entry['link'] = 'System'; } echo '<td>' . $entry['link'] . '</td>'; echo '<td>' . $entry['message'] . '</td> </tr>';
<?php $i = 0; foreach (explode(",", $vars['id']) as $ifid) { $port = dbFetchRow("SELECT * FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id", array($ifid)); if (is_file($config['rrd_dir'] . "/" . $port['hostname'] . "/port-" . safename($port['ifIndex'] . ".rrd"))) { $port = ifLabel($port); $rrd_list[$i]['filename'] = $config['rrd_dir'] . "/" . $port['hostname'] . "/port-" . safename($port['ifIndex'] . ".rrd"); $rrd_list[$i]['descr'] = $port['hostname'] . " " . $port['ifDescr']; $rrd_list[$i]['descr_in'] = $port['hostname']; $rrd_list[$i]['descr_out'] = makeshortif($port['label']); $i++; } } $units = 'bps'; $total_units = 'B'; $colours_in = 'greens'; $multiplier = "8"; $colours_out = 'blues'; $nototal = 1; $ds_in = "INOCTETS"; $ds_out = "OUTOCTETS"; include "includes/graphs/generic_multi_bits_separated.inc.php";
$sql .= " AND (`D`.`hostname` LIKE '%{$searchPhrase}%' OR `E`.`datetime` LIKE '%{$searchPhrase}%' OR `E`.`message` LIKE '%{$searchPhrase}%' OR `E`.`type` LIKE '%{$searchPhrase}%')"; } $count_sql = "SELECT COUNT(datetime) {$sql}"; $total = dbFetchCell($count_sql, $param); if (empty($total)) { $total = 0; } if (!isset($sort) || empty($sort)) { $sort = 'datetime DESC'; } $sql .= " ORDER BY {$sort}"; if (isset($current)) { $limit_low = $current * $rowCount - $rowCount; $limit_high = $rowCount; } if ($rowCount != -1) { $sql .= " LIMIT {$limit_low},{$limit_high}"; } $sql = "SELECT `E`.*,DATE_FORMAT(datetime, '" . $config['dateformat']['mysql']['compact'] . "') as humandate {$sql}"; foreach (dbFetchRows($sql, $param) as $eventlog) { $dev = device_by_id_cache($eventlog['host']); if ($eventlog['type'] == 'interface') { $this_if = ifLabel(getifbyid($eventlog['reference'])); $type = '<b>' . generate_port_link($this_if, makeshortif(strtolower($this_if['label']))) . '</b>'; } else { $type = $eventlog['type']; } $response[] = array('datetime' => $eventlog['humandate'], 'hostname' => generate_device_link($dev, shorthost($dev['hostname'])), 'type' => $type, 'message' => htmlspecialchars($eventlog['message'])); } $output = array('current' => $current, 'rowCount' => $rowCount, 'rows' => $response, 'total' => $total); echo _json_encode($output);
if (!$ignore) { if ($entry['ifInErrors'] > 0 || $entry['ifOutErrors'] > 0) { $error_img = generate_port_link($entry, "<img src='images/16/chart_curve_error.png' alt='Interface Errors' border=0>", port_errors); } else { $error_img = ''; } $arp_host = dbFetchRow('SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND D.device_id = I.device_id', array($entry['ipv4_address'])); if ($arp_host) { $arp_name = generate_device_link($arp_host); } else { unset($arp_name); } if ($arp_host) { $arp_if = generate_port_link($arp_host); } else { unset($arp_if); } if ($arp_host['device_id'] == $entry['device_id']) { $arp_name = 'Localhost'; } if ($arp_host['port_id'] == $entry['port_id']) { $arp_if = 'Local port'; } $response[] = array('mac_address' => formatMac($entry['mac_address']), 'ipv4_address' => $entry['ipv4_address'], 'hostname' => generate_device_link($entry), 'interface' => generate_port_link($entry, makeshortif(fixifname(ifLabel($entry['label'])))) . ' ' . $error_img, 'remote_device' => $arp_name, 'remote_interface' => $arp_if); } //end if unset($ignore); } //end foreach $output = array('current' => $current, 'rowCount' => $rowCount, 'rows' => $response, 'total' => $total); echo _json_encode($output);
<?php #echo("<pre>"); #print_r($interface); #echo("</pre>"); # This file prints a table row for each interface $interface['device_id'] = $device['device_id']; $interface['hostname'] = $device['hostname']; $if_id = $interface['interface_id']; $interface = ifLabel($interface); if (!is_integer($i / 2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } if ($interface['ifInErrors_delta'] > 0 || $interface['ifOutErrors_delta'] > 0) { $error_img = generateiflink($interface, "<img src='images/16/chart_curve_error.png' alt='Interface Errors' border=0>", "port_errors"); } else { $error_img = ""; } if (mysql_result(mysql_query("SELECT count(*) FROM mac_accounting WHERE interface_id = '" . $interface['interface_id'] . "'"), 0)) { $mac = "<a href='device/" . $interface['device_id'] . "/interface/" . $interface['interface_id'] . "/macaccounting/'><img src='/images/16/chart_curve.png' align='absmiddle'></a>"; } else { $mac = ""; } echo "<tr style=\"background-color: {$row_colour}; padding: 5px;\" valign=top onmouseover=\"this.style.backgroundColor='{$list_highlight}';\" onmouseout=\"this.style.backgroundColor='{$row_colour}';\" onclick=\"location.href='/device/" . $device['device_id'] . "/interface/" . $interface['interface_id'] . "/'\" style='cursor: hand;'>\n <td valign=top width=350>"; echo " <span class=list-large>\n " . generateiflink($interface, $interface['ifIndex'] . ". " . $interface['label']) . " {$error_img} {$mac}\n\n </span><br /><span class=interface-desc>" . $interface['ifAlias'] . "</span>"; if ($interface['ifAlias']) { echo "<br />"; } unset($break);
AND NOT EXISTS ( SELECT * FROM ipv4_addresses a WHERE a.ipv4_address = m.ipv4_address ) GROUP BY ipv4_address ORDER BY ipv4_address '; // FIXME: Observium now uses ip_mac.ip_address in place of ipv4_mac.ipv4_address - why? $names = array(); $ips = array(); foreach (dbFetchRows($sql, array($deviceid)) as $entry) { global $config; $ip = $entry['ipv4_address']; $mac = $entry['mac_address']; $if = $entry['port_id']; $int = ifLabel($if); $label = $int['label']; // Even though match_network is done inside discover_new_device, we do it here // as well in order to skip unnecessary reverse DNS lookups on discovered IPs. if (match_network($config['autodiscovery']['nets-exclude'], $ip)) { echo 'x'; continue; } if (!match_network($config['nets'], $ip)) { echo 'i'; log_event("Ignored {$ip}", $deviceid, 'interface', $if); continue; } // Attempt discovery of each IP only once per run. if (arp_discovery_is_cached($ip)) { echo '.';
require_once '../includes/snmp.inc.php'; if (is_numeric($_GET['id']) && ($config['allow_unauth_graphs'] || port_permitted($_GET['id']))) { $port = get_port_by_id($_GET['id']); $device = device_by_id_cache($port['device_id']); $title = generate_device_link($device); $title .= " :: Port " . generate_port_link($port); $auth = TRUE; } else { echo "Unauthenticad"; die; } header("Content-type: image/svg+xml"); /********** HTTP GET Based Conf ***********/ $ifnum = @$port['ifIndex']; // BSD / SNMP interface name / number $ifname = ifLabel($port); $ifname = $ifname['label']; //Interface name that will be showed on top right of graph $hostname = shorthost($device['hostname']); if ($_GET['title']) { $ifname = $_GET['title']; } /********* Other conf *******/ $scale_type = "follow"; //Autoscale default setup : "up" = only increase scale; "follow" = increase and decrease scale according to current graphed datas $nb_plot = 240; //NB plot in graph if (is_numeric($_GET['interval'])) { $time_interval = $_GET['interval']; } else { $time_interval = 1;