<?php

$scale_min = 0;
include_once $config['html_dir'] . '/includes/graphs/common.inc.php';
$rrd = get_port_rrdfilename($device, $port, 'fdbcount');
if (is_file($rrd)) {
    $rrd_filename = $rrd;
}
$ds = 'value';
$colour_area = 'EEEEEE';
$colour_line = '36393D';
$colour_area_max = 'FFEE99';
$unit_text = 'MACs';
$unit_integer = TRUE;
$line_text = 'Count';
include_once $config['html_dir'] . '/includes/graphs/generic_simplex.inc.php';
// EOF
<?php

// Generate a list of ports and then call the multi_bits grapher to generate from the list
$i = 0;
foreach (dbFetchRows("SELECT * FROM `ports` WHERE `device_id` = ? AND `pagpGroupIfIndex` = ?", array($port['device_id'], $port['ifIndex'])) as $int) {
    $rrdfile = get_port_rrdfilename($device, $int);
    if (is_file($rrdfile)) {
        $rrd_list[$i]['filename'] = $rrdfile;
        $rrd_list[$i]['descr'] = $int['ifDescr'];
        $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";
Beispiel #3
0
    $ignore = 0;
    if (is_array($config['device_traffic_iftype'])) {
        foreach ($config['device_traffic_iftype'] as $iftype) {
            if (preg_match($iftype . "i", $port['ifType'])) {
                $ignore = 1;
            }
        }
    }
    if (is_array($config['device_traffic_descr'])) {
        foreach ($config['device_traffic_descr'] as $ifdescr) {
            if (preg_match($ifdescr . "i", $port['ifDescr']) || preg_match($ifdescr . "i", $port['ifName']) || preg_match($ifdescr . "i", $port['portName'])) {
                $ignore = 1;
            }
        }
    }
    $rrd_filename = get_port_rrdfilename($port, $port);
    if (!$ignore && $i < 1100 && is_file($rrd_filename)) {
        $rrd_filenames[] = $rrd_filename;
        $rrd_list[$i]['filename'] = $rrd_filename;
        #    $rrd_list[$i]['descr'] = $port['device_id'] . " " . $port['ifDescr'];
        $rrd_list[$i]['descr'] = "dev" . $port['device_id'] . "if" . $port['ifIndex'];
        $rrd_list[$i]['rra_in'] = $rra_in;
        $rrd_list[$i]['rra_out'] = $rra_out;
        $i++;
    }
    unset($ignore);
}
$units = 'bps';
$total_units = 'B';
$colours_in = 'greens';
$multiplier = "8";
Beispiel #4
0
<?php

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage graphs
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
// Generate a list of ports and then call the multi_bits grapher to generate from the list
$i = 0;
foreach (dbFetchRows("SELECT * FROM `ports` WHERE `device_id` = ? AND `pagpGroupIfIndex` = ?", array($port['device_id'], $port['ifIndex'])) as $int) {
    $rrdfile = get_port_rrdfilename($int, NULL, TRUE);
    if (is_file($rrdfile)) {
        $rrd_list[$i]['filename'] = $rrdfile;
        $rrd_list[$i]['descr'] = $int['ifDescr'];
        $i++;
    }
}
$units = 'bps';
$total_units = 'B';
$colours_in = 'greens';
$multiplier = "8";
$colours_out = 'blues';
$nototal = 1;
$ds_in = "INOCTETS";
$ds_out = "OUTOCTETS";
include $config['html_dir'] . "/includes/graphs/generic_multi_bits_separated.inc.php";
<?php

$rrd_filename = get_port_rrdfilename($device, $port, "adsl");
$rrd_list[0]['filename'] = $rrd_filename;
$rrd_list[0]['descr'] = "Downstream";
$rrd_list[0]['ds'] = "AturCurrSnrMgn";
$rrd_list[1]['filename'] = $rrd_filename;
$rrd_list[1]['descr'] = "Upstream";
$rrd_list[1]['ds'] = "AtucCurrSnrMgn";
$unit_text = "dB";
$units = '';
$total_units = '';
$colours = 'mixed';
$scale_min = "0";
$nototal = 1;
if ($rrd_list) {
    include "includes/graphs/generic_multi_line.inc.php";
}
Beispiel #6
0
 }
 $port['state']['ifInOctets_perc'] = $port['stats']['ifInBits_perc'];
 $port['state']['ifOutOctets_perc'] = $port['stats']['ifOutBits_perc'];
 $port['alert_array']['ifInOctets_perc'] = $port['stats']['ifInBits_perc'];
 $port['alert_array']['ifOutOctets_perc'] = $port['stats']['ifOutBits_perc'];
 $port['alert_array']['rx_ave_pktsize'] = $port['state']['ifInOctets_delta'] / ($port['state']['ifInUcastPkts_delta'] + $port['state']['ifInNUcastPkts_delta']);
 $port['alert_array']['tx_ave_pktsize'] = $port['state']['ifOutOctets_delta'] / ($port['state']['ifOutUcastPkts_delta'] + $port['state']['ifOutNUcastPkts_delta']);
 echo 'bps(' . formatRates($port['stats']['ifInBits_rate']) . '/' . formatRates($port['stats']['ifOutBits_rate']) . ')';
 echo 'bytes(' . formatStorage($port['stats']['ifInOctets_diff']) . '/' . formatStorage($port['stats']['ifOutOctets_diff']) . ')';
 echo 'pkts(' . format_si($port['stats']['ifInUcastPkts_rate']) . 'pps/' . format_si($port['stats']['ifOutUcastPkts_rate']) . 'pps)';
 // Store aggregate in/out state
 $port['state']['ifOctets_rate'] = $port['stats']['ifOutOctets_rate'] + $port['stats']['ifInOctets_rate'];
 $port['state']['ifUcastPkts_rate'] = $port['stats']['ifOutUcastPkts_rate'] + $port['stats']['ifInUcastPkts_rate'];
 $port['state']['ifErrors_rate'] = $port['stats']['ifOutErrors_rate'] + $port['stats']['ifInErrors_rate'];
 // Update RRDs
 $rrdfile = get_port_rrdfilename($port);
 rrdtool_create($device, $rrdfile, "\\\n      DS:INOCTETS:DERIVE:600:0:" . $config['max_port_speed'] . " \\\n      DS:OUTOCTETS:DERIVE:600:0:" . $config['max_port_speed'] . " \\\n      DS:INERRORS:DERIVE:600:0:" . $config['max_port_speed'] . " \\\n      DS:OUTERRORS:DERIVE:600:0:" . $config['max_port_speed'] . " \\\n      DS:INUCASTPKTS:DERIVE:600:0:" . $config['max_port_speed'] . " \\\n      DS:OUTUCASTPKTS:DERIVE:600:0:" . $config['max_port_speed'] . " \\\n      DS:INNUCASTPKTS:DERIVE:600:0:" . $config['max_port_speed'] . " \\\n      DS:OUTNUCASTPKTS:DERIVE:600:0:" . $config['max_port_speed'] . " \\\n      DS:INDISCARDS:DERIVE:600:0:" . $config['max_port_speed'] . " \\\n      DS:OUTDISCARDS:DERIVE:600:0:" . $config['max_port_speed'] . " \\\n      DS:INUNKNOWNPROTOS:DERIVE:600:0:" . $config['max_port_speed'] . " \\\n      DS:INBROADCASTPKTS:DERIVE:600:0:" . $config['max_port_speed'] . " \\\n      DS:OUTBROADCASTPKTS:DERIVE:600:0:" . $config['max_port_speed'] . " \\\n      DS:INMULTICASTPKTS:DERIVE:600:0:" . $config['max_port_speed'] . " \\\n      DS:OUTMULTICASTPKTS:DERIVE:600:0:" . $config['max_port_speed']);
 $this_port['rrd_update'] = array($this_port['ifInOctets'], $this_port['ifOutOctets'], $this_port['ifInErrors'], $this_port['ifOutErrors'], $this_port['ifInUcastPkts'], $this_port['ifOutUcastPkts'], $this_port['ifInNUcastPkts'], $this_port['ifOutNUcastPkts'], $this_port['ifInDiscards'], $this_port['ifOutDiscards'], $this_port['ifInUnknownProtos'], $this_port['ifInBroadcastPkts'], $this_port['ifOutBroadcastPkts'], $this_port['ifInMulticastPkts'], $this_port['ifOutMulticastPkts']);
 rrdtool_update($device, $rrdfile, $this_port['rrd_update']);
 // End Update IF-MIB
 // Update PAgP
 if ($this_port['pagpOperationMode'] || $port['pagpOperationMode']) {
     $log_event = array();
     foreach ($pagp_oids as $oid) {
         // Loop the OIDs
         if ($this_port[$oid] != $port[$oid]) {
             // If data has changed, build a query
             $port['update'][$oid] = $this_port[$oid];
             $log_event[] = "[{$oid}] " . $port[$oid] . " -> " . $this_port[$oid];
         }
     }
<?php

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage graphs
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
$rrd_filename = get_port_rrdfilename($port, "adsl", TRUE);
$rrd_list[0]['filename'] = $rrd_filename;
$rrd_list[0]['descr'] = "Downstream";
$rrd_list[0]['ds'] = "AturCurrAtn";
$rrd_list[1]['filename'] = $rrd_filename;
$rrd_list[1]['descr'] = "Upstream";
$rrd_list[1]['ds'] = "AtucCurrAtn";
$unit_text = "dB";
$units = '';
$total_units = '';
$colours = 'mixed';
$scale_min = "0";
$nototal = 1;
if ($rrd_list) {
    include "includes/graphs/generic_multi_line.inc.php";
}
    $rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/fdb_count.rrd";
    if (!is_file($rrd_file)) {
        rrdtool_create($rrd_file, "DS:value:GAUGE:600:0:U ");
    }
    rrdtool_update($rrd_file, "N:" . $fdb_count);
    $graphs['fdb_count'] = TRUE;
}
$fdbcount_module = 'enable_ports_fdbcount';
if ($attribs[$fdbcount_module] || $config[$fdbcount_module] && !isset($attribs[$fdbcount_module])) {
    foreach ($fdb_portcount as $port => $count) {
        $port_info = $port_table[$port];
        if (!$port_info) {
            echo "No entry in port table for {$port}\n";
            continue;
        }
        $rrd_file = get_port_rrdfilename($device, $port_info, "fdbcount");
        if (!is_file($rrd_file)) {
            rrdtool_create($rrd_file, "DS:value:GAUGE:600:0:U ");
        }
        rrdtool_update($rrd_file, "N:" . $count);
        $graphs['port_fdb_count'] = TRUE;
    }
}
// Loop the existing list and delete anything remaining
foreach ($fdbs_db as $vlan => $fdb_macs) {
    foreach ($fdb_macs as $mac => $data) {
        echo str_pad($vlan, 8) . " | " . str_pad($mac, 12) . " | " . str_pad($data['port_id'], 25) . " | " . str_pad($data['fdb_status'], 16);
        echo "-\n";
        dbDelete('vlans_fdb', '`device_id` = ? AND `vlan_id` = ? AND `mac_address` = ?', array($device['device_id'], $vlan, $mac));
    }
}
Beispiel #9
0
<?php

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage graphs
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
// Cycle through dot3stats OIDs and build list of RRAs to pass to multi simplex grapher
$oids = array('dot3StatsAlignmentErrors', 'dot3StatsFCSErrors', 'dot3StatsSingleCollisionFrames', 'dot3StatsMultipleCollisionFrames', 'dot3StatsSQETestErrors', 'dot3StatsDeferredTransmissions', 'dot3StatsLateCollisions', 'dot3StatsExcessiveCollisions', 'dot3StatsInternalMacTransmitErrors', 'dot3StatsCarrierSenseErrors', 'dot3StatsFrameTooLongs', 'dot3StatsInternalMacReceiveErrors', 'dot3StatsSymbolErrors');
$i = 0;
$rrd_filename = get_port_rrdfilename($port, "dot3", TRUE);
if (is_file($rrd_filename)) {
    foreach ($oids as $oid) {
        $oid = str_replace("dot3Stats", "", $oid);
        $oid_ds = truncate($oid, 19, '');
        $rrd_list[$i]['filename'] = $rrd_filename;
        $rrd_list[$i]['descr'] = $oid;
        $rrd_list[$i]['ds'] = $oid_ds;
        $i++;
    }
}
#} else { echo("file missing: $file");  }
$colours = "mixed";
$nototal = 1;
$unit_text = "Errors/sec";
$simple_rrd = 1;
if (1) {
    #  $rrd_list[1]['filename'] = get_port_rrdfilename($device, $port);
    #  $rrd_list[1]['descr'] = $int['ifDescr'];
    #  $rrd_list[1]['ds_in'] = "INNUCASTPKTS";
    #  $rrd_list[1]['ds_out'] = "OUTNUCASTPKTS";
    #  $rrd_list[1]['descr']   = "NonUnicast";
    #  $rrd_list[1]['colour_area_in'] = "BB77BB";
    #  $rrd_list[1]['colour_area_out'] = "FFDD88";
    $rrd_list[2]['filename'] = get_port_rrdfilename($device, $port);
    $rrd_list[2]['descr'] = $int['ifDescr'];
    $rrd_list[2]['ds_in'] = "INBROADCASTPKTS";
    $rrd_list[2]['ds_out'] = "OUTBROADCASTPKTS";
    $rrd_list[2]['descr'] = "Broadcast";
    $rrd_list[2]['colour_area_in'] = "905090";
    $rrd_list[2]['colour_area_out'] = "CCA514";
    $rrd_list[4]['filename'] = get_port_rrdfilename($device, $port);
    $rrd_list[4]['descr'] = $int['ifDescr'];
    $rrd_list[4]['ds_in'] = "INMULTICASTPKTS";
    $rrd_list[4]['ds_out'] = "OUTMULTICASTPKTS";
    $rrd_list[4]['descr'] = "Multicast";
    $rrd_list[4]['colour_area_in'] = "DC91DC";
    $rrd_list[4]['colour_area_out'] = "FFE940";
    $units = '';
    $units_descr = 'Packets/sec';
    $colours_in = 'purples';
    $multiplier = "1";
    $colours_out = 'oranges';
    $args['nototal'] = 1;
    $print_total = 0;
    $nototal = 1;
    include "includes/graphs/generic_multi_separated.inc.php";
Beispiel #11
0
function delete_port($int_id, $delete_rrd = TRUE)
{
    global $config;
    $port = dbFetchRow("SELECT * FROM `ports`\n                      LEFT JOIN `devices` USING (`device_id`)\n                      WHERE `port_id` = ?", array($int_id));
    $ret = "> Deleted interface from " . $port['hostname'] . ": id={$int_id} (" . $port['ifDescr'] . ")\n";
    // Remove entities from common tables
    $deleted_entities = array();
    foreach ($config['entity_tables'] as $table) {
        $where = '`entity_type` = ?' . generate_query_values($int_id, 'entity_id');
        $table_status = dbDelete($table, $where, array('port'));
        if ($table_status) {
            $deleted_entities['port'] = 1;
        }
    }
    if (count($deleted_entities)) {
        $ret .= ' * Deleted common entity entries linked to port.' . PHP_EOL;
    }
    // FIXME, move to definitions
    $port_tables = array('eigrp_ports', 'ipv4_addresses', 'ipv6_addresses', 'ip_mac', 'juniAtmVp', 'mac_accounting', 'ospf_nbrs', 'ospf_ports', 'ports_adsl', 'ports_cbqos', 'ports_vlans', 'pseudowires', 'vlans_fdb', 'neighbours', 'ports');
    foreach ($port_tables as $table) {
        $table_status = dbDelete($table, "`port_id` = ?", array($int_id));
        if ($table_status) {
            $deleted_tables[] = $table;
        }
    }
    $table_status = dbDelete('ports_stack', "`port_id_high` = ?  OR `port_id_low` = ?", array($int_id, $int_id));
    if ($table_status) {
        $deleted_tables[] = 'ports_stack';
    }
    $table_status = dbDelete('entity_permissions', "`entity_type` = 'port' AND `entity_id` = ?", array($int_id));
    if ($table_status) {
        $deleted_tables[] = 'entity_permissions';
    }
    $table_status = dbDelete('alert_table', "`entity_type` = 'port' AND `entity_id` = ?", array($int_id));
    if ($table_status) {
        $deleted_tables[] = 'alert_table';
    }
    $table_status = dbDelete('group_table', "`entity_type` = 'port' AND `entity_id` = ?", array($int_id));
    if ($table_status) {
        $deleted_tables[] = 'group_table';
    }
    $ret .= ' * Deleted interface entries from tables: ' . implode(', ', $deleted_tables) . PHP_EOL;
    if ($delete_rrd) {
        $rrd_types = array('adsl', 'dot3', 'fdbcount', 'poe', NULL);
        foreach ($rrd_types as $type) {
            $rrdfile = get_port_rrdfilename($port, $type, TRUE);
            if (is_file($rrdfile)) {
                unlink($rrdfile);
                $deleted_rrds[] = $rrdfile;
            }
        }
        $ret .= ' * Deleted interface RRD files: ' . implode(', ', $deleted_rrds) . PHP_EOL;
    }
    return $ret;
}
Beispiel #12
0
function generate_port_row($port, $vars = array())
{
    global $config, $cache;
    $device = device_by_id_cache($port['device_id']);
    humanize_port($port);
    if (!isset($vars['view'])) {
        $vars['view'] = "basic";
    }
    // Populate $port_adsl if the port has ADSL-MIB data
    if (!isset($cache['ports_option']['ports_adsl']) || in_array($port['port_id'], $cache['ports_option']['ports_adsl'])) {
        $port_adsl = dbFetchRow("SELECT * FROM `ports_adsl` WHERE `port_id` = ?", array($port['port_id']));
    }
    // Populate $port['tags'] with various tags to identify port statuses and features
    // Port Errors
    if ($port['ifInErrors_delta'] > 0 || $port['ifOutErrors_delta'] > 0) {
        $port['tags'] .= generate_port_link($port, '<span class="label label-important">Errors</span>', 'port_errors');
    }
    // Port Deleted
    if ($port['deleted'] == '1') {
        $port['tags'] .= '<a href="' . generate_url(array('page' => 'deleted-ports')) . '"><span class="label label-important">Deleted</span></a>';
    }
    // Port CBQoS
    if (isset($cache['ports_option']['ports_cbqos'])) {
        if (in_array($port['port_id'], $cache['ports_option']['ports_cbqos'])) {
            $port['tags'] .= '<a href="' . generate_port_url($port, array('view' => 'cbqos')) . '"><span class="label label-info">CBQoS</span></a>';
        }
    } else {
        if (dbFetchCell("SELECT COUNT(*) FROM `ports_cbqos` WHERE `port_id` = ?", array($port['port_id']))) {
            $port['tags'] .= '<a href="' . generate_port_url($port, array('view' => 'cbqos')) . '"><span class="label label-info">CBQoS</span></a>';
        }
    }
    // Port MAC Accounting
    if (isset($cache['ports_option']['mac_accounting'])) {
        if (in_array($port['port_id'], $cache['ports_option']['mac_accounting'])) {
            $port['tags'] .= '<a href="' . generate_port_url($port, array('view' => 'macaccounting')) . '"><span class="label label-info">MAC</span></a>';
        }
    } else {
        if (dbFetchCell("SELECT COUNT(*) FROM `mac_accounting` WHERE `port_id` = ?", array($port['port_id']))) {
            $port['tags'] .= '<a href="' . generate_port_url($port, array('view' => 'macaccounting')) . '"><span class="label label-info">MAC</span></a>';
        }
    }
    // Populated formatted versions of port rates.
    $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";
    $string = '';
    if ($vars['view'] == "basic" || $vars['view'] == "graphs") {
        $table_cols = '8';
        $string .= '<tr class="' . $port['row_class'] . '">
            <td class="state-marker"></td>
            <td style="width: 1px;"></td>';
        if ($vars['page'] != "device" && $vars['popup'] != TRUE) {
            $table_cols++;
            // Increment table columns by one to make sure graph line draws correctly
            $string .= '    <td style="width: 200px;"><span class="entity">' . generate_device_link($device, short_hostname($device['hostname'], "20")) . '</span><br />
                <span class="em">' . escape_html(truncate($port['location'], 32, "")) . '</span></td>';
        }
        $string .= '    <td><span class="entity">' . generate_port_link($port, rewrite_ifname($port['port_label'])) . ' ' . $port['tags'] . '</span><br />
                <span class="em">' . escape_html(truncate($port['ifAlias'], 50, '')) . '</span></td>' . '<td style="width: 110px;"> <i class="icon-circle-arrow-down" style="' . $port['bps_in_style'] . '"></i>  <span class="small" style="' . $port['bps_in_style'] . '">' . formatRates($port['in_rate']) . '</span><br />' . '<i class="icon-circle-arrow-up" style="' . $port['bps_out_style'] . '"></i> <span class="small" style="' . $port['bps_out_style'] . '">' . formatRates($port['out_rate']) . '</span><br /></td>' . '<td style="width: 90px;"> <i class="icon-circle-arrow-down" style="' . $port['bps_in_style'] . '"></i>  <span class="small" style="' . $port['bps_in_style'] . '">' . $port['ifInOctets_perc'] . '%</span><br />' . '<i class="icon-circle-arrow-up" style="' . $port['bps_out_style'] . '"></i> <span class="small" style="' . $port['bps_out_style'] . '">' . $port['ifOutOctets_perc'] . '%</span><br /></td>' . '<td style="width: 110px;"><i class="icon-circle-arrow-down" style="' . $port['pps_in_style'] . '"></i>  <span class="small" style="' . $port['pps_in_style'] . '">' . format_bi($port['ifInUcastPkts_rate']) . 'pps</span><br />' . '<i class="icon-circle-arrow-up" style="' . $port['pps_out_style'] . '"></i> <span class="small" style="' . $port['pps_out_style'] . '">' . format_bi($port['ifOutUcastPkts_rate']) . 'pps</span></td>' . '<td style="width: 110px;"><small>' . $port['human_speed'] . '<br />' . $port['ifMtu'] . '</small></td>
            <td ><small>' . $port['human_type'] . '<br />' . $port['human_mac'] . '</small></td>
          </tr>';
    } else {
        if ($vars['view'] == "details" || $vars['view'] == "detail") {
            $table_cols = '9';
            $string .= '<tr class="' . $port['row_class'] . '"';
            if ($vars['tab'] != "port") {
                $string .= ' onclick="openLink(\'' . generate_port_url($port) . '\')" style="cursor: pointer;"';
            }
            $string .= '>';
            $string .= '         <td class="state-marker"></td>
         <td style="width: 1px;"></td>';
            if ($vars['page'] != "device" && $vars['popup'] != TRUE) {
                $table_cols++;
                // Increment table columns by one to make sure graph line draws correctly
                $string .= '    <td width="200"><span class="entity">' . generate_device_link($device, short_hostname($device['hostname'], "20")) . '</span><br />
                <span class="em">' . escape_html(truncate($port['location'], 32, "")) . '</span></td>';
            }
            $string .= '
         <td style="min-width: 250px;">';
            $string .= '        <span class="entity-title">
              ' . generate_port_link($port) . ' ' . $port['tags'] . '
           </span><br /><span class="small">' . escape_html($port['ifAlias']) . '</span>';
            if ($port['ifAlias']) {
                $string .= '<br />';
            }
            unset($break);
            if (!isset($cache['ports_option']['ipv4_addresses']) || in_array($port['port_id'], $cache['ports_option']['ipv4_addresses'])) {
                foreach (dbFetchRows("SELECT * FROM `ipv4_addresses` WHERE `port_id` = ?", array($port['port_id'])) as $ip) {
                    $string .= $break . generate_popup_link('ip', $ip['ipv4_address'] . '/' . $ip['ipv4_prefixlen'], NULL, 'small');
                    $break = "<br />";
                }
            }
            if (!isset($cache['ports_option']['ipv6_addresses']) || in_array($port['port_id'], $cache['ports_option']['ipv6_addresses'])) {
                foreach (dbFetchRows("SELECT * FROM `ipv6_addresses` WHERE `port_id` = ?", array($port['port_id'])) as $ip6) {
                    $string .= $break . generate_popup_link('ip', $ip6['ipv6_address'] . '/' . $ip6['ipv6_prefixlen'], NULL, 'small');
                    $break = "<br />";
                }
            }
            //$string .= '</span>';
            $string .= '</td>';
            // Print port graph thumbnails
            $string .= '<td style="width: 147px;">';
            $port['graph_type'] = "port_bits";
            $graph_array = array();
            $graph_array['to'] = $config['time']['now'];
            $graph_array['id'] = $port['port_id'];
            $graph_array['type'] = $port['graph_type'];
            $graph_array['width'] = 100;
            $graph_array['height'] = 20;
            $graph_array['bg'] = 'ffffff00';
            $graph_array['from'] = $config['time']['day'];
            $string .= generate_port_link($port, generate_graph_tag($graph_array));
            $port['graph_type'] = "port_upkts";
            $graph_array['type'] = $port['graph_type'];
            $string .= generate_port_link($port, generate_graph_tag($graph_array));
            $port['graph_type'] = "port_errors";
            $graph_array['type'] = $port['graph_type'];
            $string .= generate_port_link($port, generate_graph_tag($graph_array));
            $string .= '</td>';
            $string .= '<td style="width: 100px; white-space: nowrap;">';
            if ($port['ifOperStatus'] == "up" || $port['ifOperStatus'] == "monitoring") {
                // Colours generated by humanize_port
                $string .= '<i class="icon-circle-arrow-down" style="' . $port['bps_in_style'] . '"></i> <span class="small" style="' . $port['bps_in_style'] . '">' . formatRates($port['in_rate']) . '</span><br />
      <i class="icon-circle-arrow-up"   style="' . $port['bps_out_style'] . '"></i> <span class="small" style="' . $port['bps_out_style'] . '">' . formatRates($port['out_rate']) . '</span><br />
      <i class="icon-circle-arrow-down" style="' . $port['pps_in_style'] . '"></i> <span class="small" style="' . $port['pps_in_style'] . '">' . format_bi($port['ifInUcastPkts_rate']) . 'pps</span><br />
      <i class="icon-circle-arrow-up"   style="' . $port['pps_out_style'] . '"></i> <span class="small" style="' . $port['pps_out_style'] . '">' . format_bi($port['ifOutUcastPkts_rate']) . 'pps</span>';
            }
            $string .= '</td><td style="width: 110px;">';
            if ($port['ifType'] && $port['ifType'] != "") {
                $string .= '<span class="small">' . $port['human_type'] . '</span>';
            } else {
                $string .= '-';
            }
            $string .= '<br />';
            if ($port['ifSpeed']) {
                $string .= '<span class="small">' . humanspeed($port['ifSpeed']) . '</span>';
            }
            if ($port['ifDuplex'] && $port['ifDuplex'] != "unknown") {
                $string .= '<span class="small"> (' . str_replace("Duplex", "", $port['ifDuplex']) . ')</span>';
            }
            $string .= '<br />';
            if ($port['ifMtu'] && $port['ifMtu'] != "") {
                $string .= '<span class="small">MTU ' . $port['ifMtu'] . '</span>';
            } else {
                $string .= '<span class="small">Unknown MTU</span>';
            }
            // if ($ifHardType && $ifHardType != "") { $string .= '<span class="small">" . $ifHardType . "</span>"); } else { $string .= '-'; }
            //$string .= '<br />';
            // Set VLAN data if the port has ifTrunk populated
            if ($port['ifTrunk']) {
                if ($port['ifVlan']) {
                    // Native VLAN
                    if (!isset($cache['ports_vlan'])) {
                        $native_state = dbFetchCell('SELECT `state` FROM `ports_vlans` WHERE `device_id` = ? AND `port_id` = ?', array($device['device_id'], $port['port_id']));
                        $native_name = dbFetchCell('SELECT `vlan_name` FROM vlans     WHERE `device_id` = ? AND `vlan_vlan` = ?;', array($device['device_id'], $port['ifVlan']));
                    } else {
                        $native_state = $cache['ports_vlan'][$port['port_id']][$port['ifVlan']]['state'];
                        $native_name = $cache['ports_vlan'][$port['port_id']][$port['ifVlan']]['vlan_name'];
                    }
                    switch ($native_state) {
                        case 'blocking':
                            $class = 'text-danger';
                            break;
                        case 'forwarding':
                            $class = 'text-success';
                            break;
                        default:
                            $class = 'muted';
                    }
                    if (empty($native_name)) {
                        $native_name = 'VLAN' . str_pad($port['ifVlan'], 4, '0', STR_PAD_LEFT);
                    }
                    $native_tooltip = 'NATIVE: <strong class=' . $class . '>' . $port['ifVlan'] . ' [' . $native_name . ']</strong><br />';
                }
                if (!isset($cache['ports_vlan'])) {
                    $vlans = dbFetchRows('SELECT * FROM `ports_vlans` AS PV
                         LEFT JOIN vlans AS V ON PV.`vlan` = V.`vlan_vlan` AND PV.`device_id` = V.`device_id`
                         WHERE PV.`port_id` = ? AND PV.`device_id` = ? ORDER BY PV.`vlan`;', array($port['port_id'], $device['device_id']));
                } else {
                    $vlans = $cache['ports_vlan'][$port['port_id']];
                }
                $vlans_count = count($vlans);
                $rel = $vlans_count || $native_tooltip ? 'tooltip' : '';
                // Hide tooltip for empty
                $string .= '<p class="small"><a class="label label-info" data-rel="' . $rel . '" data-tooltip="<div class=\'small\' style=\'max-width: 320px; text-align: justify;\'>' . $native_tooltip;
                if ($vlans_count) {
                    $string .= 'ALLOWED: ';
                    $vlans_aggr = array();
                    foreach ($vlans as $vlan) {
                        if ($vlans_count > 20) {
                            // Aggregate VLANs
                            $vlans_aggr[] = $vlan['vlan'];
                        } else {
                            // List VLANs
                            switch ($vlan['state']) {
                                case 'blocking':
                                    $class = 'text-danger';
                                    break;
                                case 'forwarding':
                                    $class = 'text-success';
                                    break;
                                default:
                                    $class = 'muted';
                            }
                            if (empty($vlan['vlan_name'])) {
                                'VLAN' . str_pad($vlan['vlan'], 4, '0', STR_PAD_LEFT);
                            }
                            $string .= '<strong class=' . $class . '>' . $vlan['vlan'] . ' [' . $vlan['vlan_name'] . ']</strong><br />';
                        }
                    }
                    if ($vlans_count > 20) {
                        // End aggregate VLANs
                        $string .= '<strong>' . range_to_list($vlans_aggr, ', ') . '</strong>';
                    }
                }
                $string .= '</div>">' . $port['ifTrunk'] . '</a></p>';
            } else {
                if ($port['ifVlan']) {
                    if (!isset($cache['ports_vlan'])) {
                        $native_state = dbFetchCell('SELECT `state` FROM `ports_vlans` WHERE `device_id` = ? AND `port_id` = ?', array($device['device_id'], $port['port_id']));
                        $native_name = dbFetchCell('SELECT `vlan_name` FROM vlans     WHERE `device_id` = ? AND `vlan_vlan` = ?;', array($device['device_id'], $port['ifVlan']));
                    } else {
                        $native_state = $cache['ports_vlan'][$port['port_id']][$port['ifVlan']]['state'];
                        $native_name = $cache['ports_vlan'][$port['port_id']][$port['ifVlan']]['vlan_name'];
                    }
                    switch ($native_state) {
                        case 'blocking':
                            $class = 'label-error';
                            break;
                        case 'forwarding':
                            $class = 'label-success';
                            break;
                        default:
                            $class = '';
                    }
                    $rel = $native_name ? 'tooltip' : '';
                    // Hide tooltip for empty
                    $string .= '<br /><span data-rel="' . $rel . '" class="label ' . $class . '"  data-tooltip="<strong class=\'small\'>' . $port['ifVlan'] . ' [' . $native_name . ']</strong>">VLAN ' . $port['ifVlan'] . '</span>';
                } else {
                    if ($port['ifVrf']) {
                        $vrf_name = dbFetchCell("SELECT `vrf_name` FROM `vrfs` WHERE `vrf_id` = ?", array($port['ifVrf']));
                        $string .= '<br /><span class="label label-success" data-rel="tooltip" data-tooltip="VRF">' . $vrf_name . '</span>';
                    }
                }
            }
            $string .= '</td>';
            // If the port is ADSL, print ADSL port data.
            if ($port_adsl['adslLineCoding']) {
                $string .= '<td style="width: 200px;"><span class="small">';
                $string .= '<span class="label">' . $port_adsl['adslLineCoding'] . '</span> <span class="label">' . rewrite_adslLineType($port_adsl['adslLineType']) . '</span>';
                $string .= '<br />';
                $string .= 'SYN <i class="icon-circle-arrow-down green"></i> ' . formatRates($port_adsl['adslAtucChanCurrTxRate']) . ' <i class="icon-circle-arrow-up blue"></i> ' . formatRates($port_adsl['adslAturChanCurrTxRate']);
                $string .= '<br />';
                //$string .= 'Max:'.formatRates($port_adsl['adslAtucCurrAttainableRate']) . '/'. formatRates($port_adsl['adslAturCurrAttainableRate']);
                //$string .= '<br />';
                $string .= 'ATN <i class="icon-circle-arrow-down green"></i> ' . $port_adsl['adslAtucCurrAtn'] . 'dBm <i class="icon-circle-arrow-up blue"></i> ' . $port_adsl['adslAturCurrAtn'] . 'dBm';
                $string .= '<br />';
                $string .= 'SNR <i class="icon-circle-arrow-down green"></i> ' . $port_adsl['adslAtucCurrSnrMgn'] . 'dB <i class="icon-circle-arrow-up blue"></i> ' . $port_adsl['adslAturCurrSnrMgn'] . 'dB';
                $string .= '</span>';
            } else {
                // Otherwise print normal port data
                $string .= '<td style="width: 150px;"><span class="small">';
                if ($port['ifPhysAddress'] && $port['ifPhysAddress'] != "") {
                    $string .= $port['human_mac'];
                } else {
                    $string .= '-';
                }
                $string .= '<br />' . $port['ifLastChange'] . '</span>';
            }
            $string .= '</td>';
            $string .= '<td style="min-width: 200px" class="small">';
            if (strpos($port['port_label'], "oopback") === FALSE && !$graph_type) {
                unset($br);
                // Populate links array for ports with direct links
                if (!isset($cache['ports_option']['neighbours']) || in_array($port['port_id'], $cache['ports_option']['neighbours'])) {
                    foreach (dbFetchRows('SELECT * FROM `neighbours` WHERE `port_id` = ?', array($port['port_id'])) as $neighbour) {
                        // print_r($link);
                        if ($neighbour['remote_port_id']) {
                            $int_links[$neighbour['remote_port_id']] = $neighbour['remote_port_id'];
                            $int_links_phys[$neighbour['remote_port_id']] = 1;
                        } else {
                            $int_links_unknown[] = $neighbour;
                        }
                    }
                } else {
                }
                // Populate links array for devices which share an IPv4 subnet
                if (!isset($cache['ports_option']['ipv4_addresses']) || in_array($port['port_id'], $cache['ports_option']['ipv4_addresses'])) {
                    foreach (dbFetchColumn('SELECT DISTINCT(`ipv4_network_id`) FROM `ipv4_addresses`
                                 LEFT JOIN `ipv4_networks` USING(`ipv4_network_id`)
                                 WHERE `port_id` = ? AND `ipv4_network` NOT IN (?);', array($port['port_id'], $config['ignore_common_subnet'])) as $network_id) {
                        $sql = 'SELECT N.*, P.`port_id`, P.`device_id` FROM `ipv4_addresses` AS A, `ipv4_networks` AS N, `ports` AS P
                   WHERE A.`port_id` = P.`port_id` AND P.`device_id` != ?
                   AND A.`ipv4_network_id` = ? AND N.`ipv4_network_id` = A.`ipv4_network_id`
                   AND P.`ifAdminStatus` = "up"';
                        $params = array($device['device_id'], $network_id);
                        foreach (dbFetchRows($sql, $params) as $new) {
                            if ($cache['devices']['id'][$new['device_id']]['disabled'] && !$config['web_show_disabled']) {
                                continue;
                            }
                            $int_links[$new['port_id']] = $new['port_id'];
                            $int_links_v4[$new['port_id']][] = $new['ipv4_network'];
                        }
                    }
                }
                // Populate links array for devices which share an IPv6 subnet
                if (!isset($cache['ports_option']['ipv6_addresses']) || in_array($port['port_id'], $cache['ports_option']['ipv6_addresses'])) {
                    foreach (dbFetchColumn("SELECT DISTINCT(`ipv6_network_id`) FROM `ipv6_addresses`\n                                 LEFT JOIN `ipv6_networks` USING(`ipv6_network_id`)\n                                 WHERE `port_id` = ? AND `ipv6_network` NOT IN (?);", array($port['port_id'], $config['ignore_common_subnet'])) as $network_id) {
                        $sql = "SELECT N.*, P.`port_id`, P.`device_id` FROM `ipv6_addresses` AS A, `ipv6_networks` AS N, `ports` AS P\n                   WHERE A.`port_id` = P.`port_id` AND P.device_id != ?\n                   AND A.`ipv6_network_id` = ? AND N.`ipv6_network_id` = A.`ipv6_network_id`\n                   AND P.`ifAdminStatus` = 'up' AND A.`ipv6_origin` != 'linklayer' AND A.`ipv6_origin` != 'wellknown'";
                        $params = array($device['device_id'], $network_id);
                        foreach (dbFetchRows($sql, $params) as $new) {
                            if ($cache['devices']['id'][$new['device_id']]['disabled'] && !$config['web_show_disabled']) {
                                continue;
                            }
                            $int_links[$new['port_id']] = $new['port_id'];
                            $int_links_v6[$new['port_id']][] = $new['ipv6_network'];
                        }
                    }
                }
                // Output contents of links array
                foreach ($int_links as $int_link) {
                    $link_if = get_port_by_id_cache($int_link);
                    if (!device_permitted($link_if['device_id'])) {
                        continue;
                    }
                    // Skip not permitted links
                    $link_dev = device_by_id_cache($link_if['device_id']);
                    $string .= $br;
                    if ($int_links_phys[$int_link]) {
                        $string .= '<a data-alt="Directly connected" class="oicon-connect"></a> ';
                    } else {
                        $string .= '<a data-alt="Same subnet" class="oicon-network-hub"></a> ';
                    }
                    $string .= '<b>' . generate_port_link($link_if, $link_if['port_label_short']) . ' on ' . generate_device_link($link_dev, short_hostname($link_dev['hostname'])) . '</b>';
                    ## FIXME -- do something fancy here.
                    if ($int_links_v6[$int_link]) {
                        $string .= '&nbsp;' . overlib_link('', '<span class="label label-success">IPv6</span>', implode("<br />", $int_links_v6[$int_link]), NULL);
                    }
                    if ($int_links_v4[$int_link]) {
                        $string .= '&nbsp;' . overlib_link('', '<span class="label label-info">IPv4</span>', implode("<br />", $int_links_v4[$int_link]), NULL);
                    }
                    $br = "<br />";
                }
                // Output content of unknown links array (where ports don't exist in our database, or they weren't matched)
                foreach ($int_links_unknown as $int_link) {
                    // FIXME -- Expose platform and version here.
                    $string .= '<a data-alt="Directly connected" class="oicon-plug-connect"></a> ';
                    $string .= '<b><i>' . short_ifname($int_link['remote_port']) . '</i></b> on ';
                    $string .= '<i><b>' . generate_tooltip_link(NULL, $int_link['remote_hostname'], '<div class="small" style="max-width: 500px;"><b>' . $int_link['remote_platform'] . '</b><br />' . $int_link['remote_version'] . '</div>') . '</b></i>';
                    $string .= '<br />';
                }
            }
            if (!isset($cache['ports_option']['pseudowires']) || in_array($port['port_id'], $cache['ports_option']['pseudowires'])) {
                foreach (dbFetchRows("SELECT * FROM `pseudowires` WHERE `port_id` = ?", array($port['port_id'])) as $pseudowire) {
                    //`port_id`,`peer_device_id`,`peer_ldp_id`,`pwID`,`pwIndex`
                    #    $pw_peer_dev = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($pseudowire['peer_device_id']));
                    $pw_peer_int = dbFetchRow("SELECT * FROM `ports` AS I, `pseudowires` AS P WHERE I.`device_id` = ? AND P.`pwID` = ? AND P.`port_id` = I.`port_id`", array($pseudowire['peer_device_id'], $pseudowire['pwID']));
                    #    $pw_peer_int = get_port_by_id_cache($pseudowire['peer_device_id']);
                    $pw_peer_dev = device_by_id_cache($pseudowire['peer_device_id']);
                    if (is_array($pw_peer_int)) {
                        humanize_port($pw_peer_int);
                        $string .= $br . '<i class="oicon-arrow-switch"></i> <strong>' . generate_port_link($pw_peer_int, $pw_peer_int['port_label_short']) . ' on ' . generate_device_link($pw_peer_dev, short_hostname($pw_peer_dev['hostname'])) . '</strong>';
                    } else {
                        $string .= $br . '<i class="oicon-arrow-switch"></i> <strong> VC ' . $pseudowire['pwID'] . ' on ' . $pseudowire['peer_addr'] . '</strong>';
                    }
                    $string .= ' <span class="label">' . $pseudowire['pwPsnType'] . '</span>';
                    $string .= ' <span class="label">' . $pseudowire['pwType'] . '</span>';
                    $br = "<br />";
                }
            }
            if (!isset($cache['ports_option']['ports_pagp']) || in_array($port['ifIndex'], $cache['ports_option']['ports_pagp'])) {
                foreach (dbFetchRows("SELECT * FROM `ports` WHERE `pagpGroupIfIndex` = ? AND `device_id` = ?", array($port['ifIndex'], $device['device_id'])) as $member) {
                    humanize_port($member);
                    $pagp[$device['device_id']][$port['ifIndex']][$member['ifIndex']] = TRUE;
                    $string .= $br . '<i class="oicon-arrow-join"></i> <strong>' . generate_port_link($member) . ' [PAgP]</strong>';
                    $br = "<br />";
                }
            }
            if ($port['pagpGroupIfIndex'] && $port['pagpGroupIfIndex'] != $port['ifIndex']) {
                $pagp[$device['device_id']][$port['pagpGroupIfIndex']][$port['ifIndex']] = TRUE;
                $parent = dbFetchRow("SELECT * FROM `ports` WHERE `ifIndex` = ? and `device_id` = ?", array($port['pagpGroupIfIndex'], $device['device_id']));
                humanize_port($parent);
                $string .= $br . '<i class="oicon-arrow-split"></i> <strong>' . generate_port_link($parent) . ' [PAgP]</strong>';
                $br = "<br />";
            }
            if (!isset($cache['ports_option']['ports_stack_low']) || in_array($port['ifIndex'], $cache['ports_option']['ports_stack_low'])) {
                foreach (dbFetchRows("SELECT * FROM `ports_stack` WHERE `port_id_low` = ? and `device_id` = ?", array($port['ifIndex'], $device['device_id'])) as $higher_if) {
                    if ($higher_if['port_id_high']) {
                        if ($pagp[$device['device_id']][$higher_if['port_id_high']][$port['ifIndex']]) {
                            continue;
                        }
                        // Skip if same PAgP port
                        $this_port = get_port_by_index_cache($device['device_id'], $higher_if['port_id_high']);
                        if (is_array($this_port)) {
                            $string .= $br . '<i class="oicon-arrow-split"></i> <strong>' . generate_port_link($this_port) . '</strong>';
                            $br = "<br />";
                        }
                    }
                }
            }
            if (!isset($cache['ports_option']['ports_stack_high']) || in_array($port['ifIndex'], $cache['ports_option']['ports_stack_high'])) {
                foreach (dbFetchRows("SELECT * FROM `ports_stack` WHERE `port_id_high` = ? and `device_id` = ?", array($port['ifIndex'], $device['device_id'])) as $lower_if) {
                    if ($lower_if['port_id_low']) {
                        if ($pagp[$device['device_id']][$port['ifIndex']][$lower_if['port_id_low']]) {
                            continue;
                        }
                        // Skip if same PAgP ports
                        $this_port = get_port_by_index_cache($device['device_id'], $lower_if['port_id_low']);
                        if (is_array($this_port)) {
                            $string .= $br . '<i class="oicon-arrow-join"></i> <strong>' . generate_port_link($this_port) . '</strong>';
                            $br = "<br />";
                        }
                    }
                }
            }
            unset($int_links, $int_links_v6, $int_links_v4, $int_links_phys, $br);
            $string .= '</td></tr>';
        }
    }
    // End Detailed View
    // If we're showing graphs, generate the graph and print the img tags
    if ($vars['graph'] == "etherlike") {
        $graph_file = get_port_rrdfilename($port, "dot3", TRUE);
    } else {
        $graph_file = get_port_rrdfilename($port, NULL, TRUE);
    }
    if ($vars['graph'] && is_file($graph_file)) {
        $string .= '<tr><td colspan="' . $table_cols . '">';
        $graph_array['to'] = $config['time']['now'];
        $graph_array['id'] = $port['port_id'];
        $graph_array['type'] = 'port_' . $vars['graph'];
        $string .= generate_graph_row($graph_array);
        $string .= '</td></tr>';
    }
    return $string;
}
Beispiel #13
0
# adslAtucPerfLofs.1 = 0
# adslAtucPerfLoss.1 = 0
# adslAtucPerfLols.1 = 0
# adslAtucPerfLprs.1 = 0
# adslAtucPerfESs.1 = 0
# adslAtucPerfInits.1 = 1
# adslAtucPerfValidIntervals.1 = 0
# adslAtucPerfInvalidIntervals.1 = 0
# adslAturPerfLoss.1 = 0 seconds
# adslAturPerfESs.1 = 0 seconds
# adslAturPerfValidIntervals.1 = 0
# adslAturPerfInvalidIntervals.1 = 0
if (isset($port_stats[$port['ifIndex']]['adslLineCoding'])) {
    // Check to make sure Port data is cached.
    $this_port =& $port_stats[$port['ifIndex']];
    $rrdfile = get_port_rrdfilename($port, "adsl");
    $rrd_create = " DS:AtucCurrSnrMgn:GAUGE:600:0:635";
    $rrd_create .= " DS:AtucCurrAtn:GAUGE:600:0:635";
    $rrd_create .= " DS:AtucCurrOutputPwr:GAUGE:600:0:635";
    $rrd_create .= " DS:AtucCurrAttainableR:GAUGE:600:0:U";
    $rrd_create .= " DS:AtucChanCurrTxRate:GAUGE:600:0:U";
    $rrd_create .= " DS:AturCurrSnrMgn:GAUGE:600:0:635";
    $rrd_create .= " DS:AturCurrAtn:GAUGE:600:0:635";
    $rrd_create .= " DS:AturCurrOutputPwr:GAUGE:600:0:635";
    $rrd_create .= " DS:AturCurrAttainableR:GAUGE:600:0:U";
    $rrd_create .= " DS:AturChanCurrTxRate:GAUGE:600:0:U";
    $rrd_create .= " DS:AtucPerfLofs:COUNTER:600:U:100000000000";
    $rrd_create .= " DS:AtucPerfLoss:COUNTER:600:U:100000000000";
    $rrd_create .= " DS:AtucPerfLprs:COUNTER:600:U:100000000000";
    $rrd_create .= " DS:AtucPerfESs:COUNTER:600:U:100000000000";
    $rrd_create .= " DS:AtucPerfInits:COUNTER:600:U:100000000000";
Beispiel #14
0
<?php

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage graphs
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
$scale_min = 0;
include_once $config['html_dir'] . '/includes/graphs/common.inc.php';
$rrd = get_port_rrdfilename($port, 'fdbcount', TRUE);
if (is_file($rrd)) {
    $rrd_filename = $rrd;
}
$ds = 'value';
$colour_area = 'EEEEEE';
$colour_line = '36393D';
$colour_area_max = 'FFEE99';
$unit_text = 'MACs';
$unit_integer = TRUE;
$line_text = 'Count';
include_once $config['html_dir'] . '/includes/graphs/generic_simplex.inc.php';
// EOF
        if ($lower_if['port_id_low']) {
            if ($pagp[$device['device_id']][$port['ifIndex']][$lower_if['port_id_low']]) {
                continue;
            }
            // Skip if same PAgP ports
            $this_port = get_port_by_index_cache($device['device_id'], $lower_if['port_id_low']);
            if (is_array($this_port)) {
                echo $br . '<i class="oicon-arrow-join"></i> <strong>' . generate_port_link($this_port) . "</strong>";
                $br = "<br />";
            }
        }
    }
}
unset($int_links, $int_links_v6, $int_links_v4, $int_links_phys, $br);
echo "</td></tr>";
// If we're showing graphs, generate the graph and print the img tags
if ($graph_type == "etherlike") {
    $graph_file = get_port_rrdfilename($device, $port, "dot3");
} else {
    $graph_file = get_port_rrdfilename($device, $port);
}
if ($graph_type && is_file($graph_file)) {
    $type = $graph_type;
    echo "<tr><td colspan=9>";
    $graph_array['to'] = $config['time']['now'];
    $graph_array['id'] = $port['port_id'];
    $graph_array['type'] = $graph_type;
    print_graph_row($graph_array);
    echo "</td></tr>";
}
// EOF
        }
        $rrd_options .= " DEF:inoctetsb" . $i . "=" . $rrdfile . ":" . $in . "OCTETS:AVERAGE";
        $rrd_options .= " DEF:outoctetsb" . $i . "=" . $rrdfile . ":" . $out . "OCTETS:AVERAGE";
        $in_thingb .= $seperator . "inoctetsb" . $i . ",UN,0," . "inoctetsb" . $i . ",IF";
        $out_thingb .= $seperator . "outoctetsb" . $i . ",UN,0," . "outoctetsb" . $i . ",IF";
        $plusesb .= $plus;
        $seperator = ",";
        $plus = ",+";
        $i++;
    }
}
unset($seperator);
unset($plus);
foreach (explode(",", $_GET['idc']) as $ifid) {
    $int = dbFetchRow("SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id", array($ifid));
    $rrdfile = get_port_rrdfilename($int, $int);
    if (is_file($rrdfile)) {
        if (strstr($inverse, "c")) {
            $in = "OUT";
            $out = "IN";
        } else {
            $in = "IN";
            $out = "OUT";
        }
        $rrd_options .= " DEF:inoctetsc" . $i . "=" . $rrdfile . ":" . $in . "OCTETS:AVERAGE";
        $rrd_options .= " DEF:outoctetsc" . $i . "=" . $rrdfile . ":" . $out . "OCTETS:AVERAGE";
        $in_thingc .= $seperator . "inoctetsc" . $i . ",UN,0," . "inoctetsc" . $i . ",IF";
        $out_thingc .= $seperator . "outoctetsc" . $i . ",UN,0," . "outoctetsc" . $i . ",IF";
        $plusesc .= $plus;
        $seperator = ",";
        $plus = ",+";
Beispiel #17
0
/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage poller
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
if ($port_stats[$port['ifIndex']] && $port['ifType'] == "ethernetCsmacd" && isset($port_stats[$port['ifIndex']]['dot3StatsIndex'])) {
    // Check to make sure Port data is cached.
    $this_port =& $port_stats[$port['ifIndex']];
    // CLEANME remove rename after r6000
    $old_rrdfile = get_rrd_path($device, "etherlike-" . $port['ifIndex'] . ".rrd");
    $rrdfile = get_port_rrdfilename($port, "dot3");
    if (!is_file($rrdfile) && is_file(get_rrd_path($device, $old_rrdfile))) {
        rename($old_rrdfile, $rrdfile);
    }
    foreach ($etherlike_oids as $oid) {
        $oid = truncate(str_replace("dot3Stats", "", $oid), 19, '');
        $rrd_create .= " DS:{$oid}:COUNTER:600:U:100000000000";
    }
    rrdtool_create($device, $rrdfile, $rrd_create);
    if ($config['statsd']['enable'] == TRUE) {
        foreach ($etherlike_oids as $oid) {
            // Update StatsD/Carbon
            StatsD::gauge(str_replace(".", "_", $device['hostname']) . '.' . 'port' . '.' . $port['ifIndex'] . '.' . $oid, $this_port[$oid]);
        }
    }
    $rrdupdate = "N";
function delete_port($int_id)
{
    global $config;
    $interface = dbFetchRow("SELECT * FROM `ports` AS P, `devices` AS D WHERE P.port_id = ? AND D.device_id = P.device_id", array($int_id));
    $interface_tables = array('adjacencies', 'ipaddr', 'ip6adjacencies', 'ip6addr', 'mac_accounting', 'bill_ports', 'pseudowires', 'ports');
    foreach ($interface_tables as $table) {
        dbDelete($table, "`port_id` =  ?", array($int_id));
    }
    dbDelete('links', "`local_port_id` =  ?", array($int_id));
    dbDelete('links', "`remote_port_id` =  ?", array($int_id));
    dbDelete('bill_ports', "`port_id` =  ?", array($int_id));
    $rrdfile = get_port_rrdfilename($interface, $interface);
    unlink($rrdfile);
}
Beispiel #19
0
<?php

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage graphs
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
// Generate a list of ports and then call the multi_bits grapher to generate from the list
$i = 0;
foreach (dbFetchRows("SELECT * FROM `ports` AS I, `devices` AS D WHERE `port_descr_type` = 'cust' AND `port_descr_descr` = ? AND D.device_id = I.device_id", array($vars['id'])) as $port) {
    $rrd_filename = get_port_rrdfilename($port, NULL, TRUE);
    if (is_file($rrd_filename)) {
        $rrd_list[$i]['filename'] = $rrd_filename;
        $rrd_list[$i]['descr'] = $port['hostname'] . "-" . $port['ifDescr'];
        $rrd_list[$i]['descr_in'] = short_hostname($port['hostname']);
        $rrd_list[$i]['descr_out'] = short_ifname($port['ifDescr'], NULL, FALSE);
        // Options sets for skip htmlentities
        $i++;
    }
}
$units = 'b';
$total_units = 'B';
$colours_in = 'greens';
$multiplier = "8";
$colours_out = 'blues';
$nototal = 1;
Beispiel #20
0
 */
#  $rrd_list[1]['filename'] = get_port_rrdfilename($port, NULL, TRUE);
#  $rrd_list[1]['descr'] = $int['ifDescr'];
#  $rrd_list[1]['ds_in'] = "INNUCASTPKTS";
#  $rrd_list[1]['ds_out'] = "OUTNUCASTPKTS";
#  $rrd_list[1]['descr']   = "NonUnicast";
#  $rrd_list[1]['colour_area_in'] = "BB77BB";
#  $rrd_list[1]['colour_area_out'] = "FFDD88";
$rrd_list[2]['filename'] = get_port_rrdfilename($port, NULL, TRUE);
$rrd_list[2]['descr'] = $int['ifDescr'];
$rrd_list[2]['ds_in'] = "INBROADCASTPKTS";
$rrd_list[2]['ds_out'] = "OUTBROADCASTPKTS";
$rrd_list[2]['descr'] = "Broadcast";
$rrd_list[2]['colour_area_in'] = "905090";
$rrd_list[2]['colour_area_out'] = "CCA514";
$rrd_list[4]['filename'] = get_port_rrdfilename($port, NULL, TRUE);
$rrd_list[4]['descr'] = $int['ifDescr'];
$rrd_list[4]['ds_in'] = "INMULTICASTPKTS";
$rrd_list[4]['ds_out'] = "OUTMULTICASTPKTS";
$rrd_list[4]['descr'] = "Multicast";
$rrd_list[4]['colour_area_in'] = "DC91DC";
$rrd_list[4]['colour_area_out'] = "FFE940";
$units = '';
$unit_text = 'Packets/sec';
$colours_in = 'purples';
$multiplier = "1";
$colours_out = 'oranges';
$args['nototal'] = 1;
$print_total = 0;
$nototal = 1;
include "includes/graphs/generic_multi_separated.inc.php";
<?php

if ($port_stats[$port['ifIndex']] && $port['ifType'] == "ethernetCsmacd" && isset($port_stats[$port['ifIndex']]['dot3StatsIndex'])) {
    // Check to make sure Port data is cached.
    $this_port =& $port_stats[$port['ifIndex']];
    // TODO: remove $old_rrdfile?
    $old_rrdfile = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("etherlike-" . $port['ifIndex'] . ".rrd");
    $rrdfile = get_port_rrdfilename($device, $port, "dot3");
    if (!file_exists($rrdfile)) {
        if (file_exists($old_rrdfile)) {
            rename($old_rrdfile, $rrd_file);
        } else {
            foreach ($etherlike_oids as $oid) {
                $oid = truncate(str_replace("dot3Stats", "", $oid), 19, '');
                $rrd_create .= " DS:{$oid}:COUNTER:600:U:100000000000";
            }
            rrdtool_create($rrdfile, $rrd_create);
        }
    }
    if ($config['statsd']['enable'] == TRUE) {
        foreach ($etherlike_oids as $oid) {
            // Update StatsD/Carbon
            StatsD::gauge(str_replace(".", "_", $device['hostname']) . '.' . 'port' . '.' . $port['ifIndex'] . '.' . $oid, $this_port[$oid]);
        }
    }
    $rrdupdate = "N";
    foreach ($etherlike_oids as $oid) {
        $data = $this_port[$oid] + 0;
        $rrdupdate .= ":{$data}";
    }
    rrdtool_update($rrdfile, $rrdupdate);
    echo '</td></tr>';
    echo '<tr><td>';
    echo "<h4>利用率比例</h4>";
    $graph_array['type'] = "port_percent";
    print_graph_row_port($graph_array, $port);
    echo '</td></tr>';
    echo '<tr><td>';
    echo "<h4>错误</h4>";
    $graph_array['type'] = "port_errors";
    print_graph_row_port($graph_array, $port);
    echo '</td></tr>';
    if (is_file(get_port_rrdfilename($device, $port, "dot3"))) {
        echo '<tr><td>';
        echo "<h4>以太网错误</h4>";
        $graph_array['type'] = "port_etherlike";
        print_graph_row_port($graph_array, $port);
        echo '</td></tr>';
    }
    if (is_file(get_port_rrdfilename($device, $port, "fdbcount"))) {
        echo '<tr><td>';
        echo "<h4>FDB计数</h4>";
        $graph_array['type'] = "port_fdb_count";
        print_graph_row_port($graph_array, $port);
        echo '</td></tr>';
    }
}
?>

</table>
<?php 
// EOF
Beispiel #23
0
    echo '</td></tr>';
    echo '<tr><td>';
    echo "<h4>Percent Utilisation</h4>";
    $graph_array['type'] = "port_percent";
    print_graph_row_port($graph_array, $port);
    echo '</td></tr>';
    echo '<tr><td>';
    echo "<h4>Errors</h4>";
    $graph_array['type'] = "port_errors";
    print_graph_row_port($graph_array, $port);
    echo '</td></tr>';
    if (is_file($device, get_port_rrdfilename($port, "dot3", TRUE))) {
        echo '<tr><td>';
        echo "<h4>Ethernet Errors</h4>";
        $graph_array['type'] = "port_etherlike";
        print_graph_row_port($graph_array, $port);
        echo '</td></tr>';
    }
    if (is_file(get_port_rrdfilename($port, "fdbcount", TRUE))) {
        echo '<tr><td>';
        echo "<h4>FDB Count</h4>";
        $graph_array['type'] = "port_fdb_count";
        print_graph_row_port($graph_array, $port);
        echo '</td></tr>';
    }
}
?>

</table>
<?php 
// EOF
Beispiel #24
0
                }
                $ignore = 1;
            } elseif (preg_match($ifdescr . "i", $port['ifName'])) {
                if ($debug) {
                    echo "[" . $port['ifIndex'] . ":ifName ignored(" . $ifdescr . "||" . $port['ifName'] . ")]";
                }
                $ignore = 1;
            } elseif (preg_match($ifdescr . "i", $port['portName'])) {
                if ($debug) {
                    echo "[" . $port['ifIndex'] . ":portName ignored]";
                }
                $ignore = 1;
            }
        }
    }
    $rrd_filename = get_port_rrdfilename($device, $port);
    if ($ignore != 1 && is_file($rrd_filename)) {
        humanize_port($port);
        // Fix Labels! ARGH. This needs to be in the bloody database!
        $rrd_filenames[] = $rrd_filename;
        $rrd_list[$i]['filename'] = $rrd_filename;
        $rrd_list[$i]['descr'] = $port['label'];
        $rrd_list[$i]['descr_in'] = $port['label'];
        $rrd_list[$i]['descr_out'] = $port['ifAlias'];
        $rrd_list[$i]['ds_in'] = $ds_in;
        $rrd_list[$i]['ds_out'] = $ds_out;
        $i++;
    }
    unset($ignore);
}
$units = 'b';
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage scripts
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
chdir(dirname($argv[0]) . '/..');
$scriptname = basename($argv[0]);
$options = getopt("dh:");
include_once "includes/sql-config.inc.php";
if (empty($options['h'])) {
    print "Usage: scripts/rename-port-rrdfile.php -h <device_id|hostname>\n\n";
    exit(1);
}
if (is_numeric($options['h'])) {
    $where = "`device_id` = ?";
} else {
    $where = "`hostname` = ?";
}
$device = dbFetchRow("SELECT * FROM devices WHERE " . $where, array($options['h']));
$ports = dbFetchRows("SELECT * FROM ports WHERE `device_id` = ?", array($device['device_id']));
foreach ($ports as $port) {
    $old_rrdfile = trim($config['rrd_dir']) . "/" . trim($device['hostname']) . "/port-" . $port['ifIndex'] . ".rrd";
    $new_rrdfile = get_port_rrdfilename($device, $port);
    printf("%s -> %s\n", $old_rrdfile, $new_rrdfile);
    rename($old_rrdfile, $new_rrdfile);
}
// EOF
<?php

if (isset($port_stats[$port['ifIndex']]) && $port['ifType'] == "ethernetCsmacd") {
    // Check to make sure Port data is cached.
    $this_port =& $port_stats[$port['ifIndex']];
    $rrdfile = get_port_rrdfilename($device, $port, "poe");
    if (!file_exists($rrdfile)) {
        // FIXME CISCOSPECIFIC
        $rrd_create .= " DS:PortPwrAllocated:GAUGE:600:0:U";
        $rrd_create .= " DS:PortPwrAvailable:GAUGE:600:0:U";
        $rrd_create .= " DS:PortConsumption:DERIVE:600:0:U";
        $rrd_create .= " DS:PortMaxPwrDrawn:GAUGE:600:0:U ";
        rrdtool_create($rrdfile, $rrd_create);
    }
    if ($config['statsd']['enable'] == TRUE) {
        foreach (array('cpeExtPsePortPwrAllocated', 'cpeExtPsePortPwrAvailable', 'cpeExtPsePortPwrConsumption', 'cpeExtPsePortMaxPwrDrawn') as $oid) {
            // Update StatsD/Carbon
            StatsD::gauge(str_replace(".", "_", $device['hostname']) . '.' . 'port' . '.' . $port['ifIndex'] . '.' . $oid, $this_port[$oid]);
        }
    }
    $upd = "{$polled}:" . $port['cpeExtPsePortPwrAllocated'] . ":" . $port['cpeExtPsePortPwrAvailable'] . ":" . $port['cpeExtPsePortPwrConsumption'] . ":" . $port['cpeExtPsePortMaxPwrDrawn'];
    $ret = rrdtool_update("{$rrdfile}", $upd);
    echo "PoE ";
}
function delete_port($int_id, $delete_rrd = TRUE)
{
    global $config;
    $port = dbFetchRow("SELECT * FROM `ports` AS P, `devices` AS D WHERE P.`port_id` = ? AND D.`device_id` = P.`device_id`", array($int_id));
    $ret = "> 删除接口自 " . $port['hostname'] . ": id={$int_id} (" . $port['ifDescr'] . ")\n";
    $port_tables = array('bill_ports', 'eigrp_ports', 'ipv4_addresses', 'ipv6_addresses', 'ip_mac', 'juniAtmVp', 'mac_accounting', 'ospf_nb', 'ospf_ports', 'ports_adsl', 'ports_cbqos', 'ports_vlans', 'pseudowires', 'vlans_fdb', 'ports');
    foreach ($port_tables as $table) {
        $table_status = dbDelete($table, "`port_id` = ?", array($int_id));
        if ($table_status) {
            $deleted_tables[] = $table;
        }
    }
    $table_status = dbDelete('ports_stack', "`port_id_high` = ?  OR `port_id_low` = ?", array($int_id, $int_id));
    if ($table_status) {
        $deleted_tables[] = 'ports_stack';
    }
    $table_status = dbDelete('links', "`local_port_id` = ? OR `remote_port_id` = ?", array($int_id, $int_id));
    if ($table_status) {
        $deleted_tables[] = 'links';
    }
    $table_status = dbDelete('entity_permissions', "`entity_type` = 'port' AND `entity_id` = ?", array($int_id));
    if ($table_status) {
        $deleted_tables[] = 'entity_permissions';
    }
    $table_status = dbDelete('alert_table', "`entity_type` = 'port' AND `entity_id` = ?", array($int_id));
    if ($table_status) {
        $deleted_tables[] = 'alert_table';
    }
    $table_status = dbDelete('group_table', "`entity_type` = 'port' AND `entity_id` = ?", array($int_id));
    if ($table_status) {
        $deleted_tables[] = 'group_table';
    }
    $ret .= '> 从表中删除接口内容: ' . implode(', ', $deleted_tables) . PHP_EOL;
    if ($delete_rrd) {
        $rrd_types = array('adsl', 'dot3', 'fdbcount', 'poe', NULL);
        foreach ($rrd_types as $type) {
            $rrdfile = get_port_rrdfilename($port, $type, TRUE);
            if (is_file($rrdfile)) {
                unlink($rrdfile);
                $deleted_rrds[] = $rrdfile;
            }
        }
        $ret .= '> 删除接口RDD文件: ' . implode(', ', $deleted_rrds) . PHP_EOL;
    }
    return $ret;
}
Beispiel #28
0
<?php

$rrdfile = get_port_rrdfilename($device, $port);
if (file_exists($rrdfile)) {
    $iid = $id;
    echo "<h4>Interface Traffic</h4>";
    $graph_array['type'] = "port_bits";
    print_graph_row_port($graph_array, $port);
    echo "<h4>Interface Packets</h4>";
    $graph_array['type'] = "port_upkts";
    print_graph_row_port($graph_array, $port);
    echo "<h4>Interface Non Unicast</h4>";
    $graph_array['type'] = "port_nupkts";
    print_graph_row_port($graph_array, $port);
    echo "<h4>Interface Errors</h4>";
    $graph_array['type'] = "port_errors";
    print_graph_row_port($graph_array, $port);
    if (is_file(get_port_rrdfilename($device, $port, "dot3"))) {
        echo "<h4>Ethernet Errors</h4>";
        $graph_array['type'] = "port_etherlike";
        print_graph_row_port($graph_array, $port);
    }
}
Beispiel #29
0
                if ($pagp[$device['device_id']][$port['ifIndex']][$lower_if['port_id_low']]) {
                    continue;
                }
                // Skip if same PAgP ports
                $this_port = get_port_by_index_cache($device['device_id'], $lower_if['port_id_low']);
                if (is_array($this_port)) {
                    echo $br . '<i class="oicon-arrow-join"></i> <strong>' . generate_port_link($this_port) . "</strong>";
                    $br = "<br />";
                }
            }
        }
    }
}
unset($int_links, $int_links_v6, $int_links_v4, $int_links_phys, $br);
echo "</td></tr>";
// If we're showing graphs, generate the graph and print the img tags
if ($graph_type == "etherlike") {
    $graph_file = get_port_rrdfilename($port, "dot3", TRUE);
} else {
    $graph_file = get_port_rrdfilename($port, NULL, TRUE);
}
if ($graph_type && is_file($graph_file)) {
    $type = $graph_type;
    echo "<tr><td colspan=9>";
    $graph_array['to'] = $config['time']['now'];
    $graph_array['id'] = $port['port_id'];
    $graph_array['type'] = $graph_type;
    print_graph_row($graph_array);
    echo "</td></tr>";
}
// EOF
Beispiel #30
0
/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage poller
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
// This code is currently not used.
if (isset($port_stats[$port['ifIndex']]) && $port['ifType'] == "ethernetCsmacd") {
    // Check to make sure Port data is cached.
    $this_port =& $port_stats[$port['ifIndex']];
    $rrdfile = get_port_rrdfilename($port, "poe");
    // FIXME CISCOSPECIFIC
    $rrd_create .= " DS:PortPwrAllocated:GAUGE:600:0:U";
    $rrd_create .= " DS:PortPwrAvailable:GAUGE:600:0:U";
    $rrd_create .= " DS:PortConsumption:DERIVE:600:0:U";
    $rrd_create .= " DS:PortMaxPwrDrawn:GAUGE:600:0:U ";
    rrdtool_create($device, $rrdfile, $rrd_create);
    if ($config['statsd']['enable'] == TRUE) {
        foreach (array('cpeExtPsePortPwrAllocated', 'cpeExtPsePortPwrAvailable', 'cpeExtPsePortPwrConsumption', 'cpeExtPsePortMaxPwrDrawn') as $oid) {
            // Update StatsD/Carbon
            StatsD::gauge(str_replace(".", "_", $device['hostname']) . '.' . 'port' . '.' . $port['ifIndex'] . '.' . $oid, $this_port[$oid]);
        }
    }
    $upd = "{$polled}:" . $port['cpeExtPsePortPwrAllocated'] . ":" . $port['cpeExtPsePortPwrAvailable'] . ":" . $port['cpeExtPsePortPwrConsumption'] . ":" . $port['cpeExtPsePortMaxPwrDrawn'];
    $ret = rrdtool_update($device, "{$rrdfile}", $upd);
    echo "PoE ";