コード例 #1
0
ファイル: bill.inc.php プロジェクト: greggcz/librenms
    function print_port_list()
    {
        global $ports;
        ?>
      <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title">Billed Ports</h3>
            </div>
            <div class="list-group">
            <?php 
        // Collected Earlier
        foreach ($ports as $port) {
            $portalias = empty($port['ifAlias']) ? '' : ' - ' . $port['ifAlias'] . '';
            ?>
                <div class="list-group-item">
                    <?php 
            echo generate_port_link($port, $port['ifName'] . $portalias);
            ?>
 on <?php 
            echo generate_device_link($port);
            ?>
                </div>
<?php 
        }
        ?>
        
            </div>
        </div>
<?php 
    }
コード例 #2
0
ファイル: rows.inc.php プロジェクト: skive/observium
function print_vm_row($vm, $device = NULL)
{
    echo '<tr>';
    echo '<td>';
    if (getidbyname($vm['vmwVmDisplayName'])) {
        echo generate_device_link(device_by_name($vm['vmwVmDisplayName']));
    } else {
        echo $vm['vmwVmDisplayName'];
    }
    echo "</td>";
    echo '<td>' . $vm['vmwVmState'] . "</td>";
    if ($vm['vmwVmGuestOS'] == "E: tools not installed") {
        echo '<td class="small">Unknown (VMware Tools not installed)</td>';
    } else {
        if ($vm['vmwVmGuestOS'] == "E: tools not running") {
            echo '<td class="small">Unknown (VMware Tools not running)</td>';
        } else {
            if ($vm['vmwVmGuestOS'] == "") {
                echo '<td class="small"><i>(Unknown)</i></td>';
            } elseif (isset($config['vmware_guestid'][$vm['vmwVmGuestOS']])) {
                echo '<td>' . $config['vmware_guestid'][$vm['vmwVmGuestOS']] . "</td>";
            } else {
                echo '<td>' . $vm['vmwVmGuestOS'] . "</td>";
            }
        }
    }
    if ($vm['vmwVmMemSize'] >= 1024) {
        echo "<td class=list>" . sprintf("%.2f", $vm['vmwVmMemSize'] / 1024) . " GB</td>";
    } else {
        echo "<td class=list>" . sprintf("%.2f", $vm['vmwVmMemSize']) . " MB</td>";
    }
    echo '<td>' . $vm['vmwVmCpus'] . " CPU</td>";
}
コード例 #3
0
/**
 * Display neighbours.
 *
 * Display pages with device neighbours in some formats.
 * Examples:
 * print_neighbours() - display all neighbours from all devices
 * print_neighbours(array('pagesize' => 99)) - display 99 neighbours from all device
 * print_neighbours(array('pagesize' => 10, 'pageno' => 3, 'pagination' => TRUE)) - display 10 neighbours from page 3 with pagination header
 * print_neighbours(array('pagesize' => 10, 'device' = 4)) - display 10 neighbours for device_id 4
 *
 * @param array $vars
 * @return none
 *
 */
function print_neighbours($vars)
{
    // Get neighbours array
    $neighbours = get_neighbours_array($vars);
    if (!$neighbours['count']) {
        // There have been no entries returned. Print the warning.
        print_warning('<h4>No neighbours found!</h4>');
    } else {
        // Entries have been returned. Print the table.
        $list = array('device' => FALSE);
        if ($vars['page'] != 'device') {
            $list['device'] = TRUE;
        }
        if (in_array($vars['graph'], array('bits', 'upkts', 'nupkts', 'pktsize', 'percent', 'errors', 'etherlike', 'fdb_count'))) {
            $graph_types = array($vars['graph']);
        } else {
            $graph_types = array('bits', 'upkts', 'errors');
        }
        $string = generate_box_open($vars['header']);
        $string .= '<table class="table  table-striped table-hover table-condensed">' . PHP_EOL;
        $cols = array(array(NULL, 'class="state-marker"'), 'device_a' => 'Local Device', 'port_a' => 'Local Port', 'NONE' => NULL, 'device_b' => 'Remote Device', 'port_b' => 'Remote Port', 'protocol' => 'Protocol');
        if (!$list['device']) {
            unset($cols[0], $cols['device_a']);
        }
        $string .= get_table_header($cols, $vars);
        $string .= '  <tbody>' . PHP_EOL;
        foreach ($neighbours['entries'] as $entry) {
            $string .= '  <tr class="' . $entry['row_class'] . '">' . PHP_EOL;
            if ($list['device']) {
                $string .= '   <td class="state-marker"></td>';
                $string .= '    <td class="entity">' . generate_device_link($entry, NULL, array('tab' => 'ports', 'view' => 'neighbours')) . '</td>' . PHP_EOL;
            }
            $string .= '    <td><span class="entity">' . generate_port_link($entry) . '</span><br />' . $entry['ifAlias'] . '</td>' . PHP_EOL;
            $string .= '    <td><i class="icon-resize-horizontal text-success"></i></td>' . PHP_EOL;
            if (is_numeric($entry['remote_port_id']) && $entry['remote_port_id']) {
                $remote_port = get_port_by_id_cache($entry['remote_port_id']);
                $remote_device = device_by_id_cache($remote_port['device_id']);
                $string .= '    <td><span class="entity">' . generate_device_link($remote_device) . '</span><br />' . $remote_device['hardware'] . '</td>' . PHP_EOL;
                $string .= '    <td><span class="entity">' . generate_port_link($remote_port) . '</span><br />' . $remote_port['ifAlias'] . '</td>' . PHP_EOL;
            } else {
                $string .= '    <td><span class="entity">' . $entry['remote_hostname'] . '</span><br />' . $entry['remote_platform'] . '</td>' . PHP_EOL;
                $string .= '    <td><span class="entity">' . $entry['remote_port'] . '</span></td>' . PHP_EOL;
            }
            $string .= '    <td>' . strtoupper($entry['protocol']) . '</td>' . PHP_EOL;
            $string .= '  </tr>' . PHP_EOL;
        }
        $string .= '  </tbody>' . PHP_EOL;
        $string .= '</table>';
        $string .= generate_box_close();
        // Print pagination header
        if ($neighbours['pagination_html']) {
            $string = $neighbours['pagination_html'] . $string . $neighbours['pagination_html'];
        }
        // Print
        echo $string;
    }
}
コード例 #4
0
ファイル: auth.inc.php プロジェクト: Natolumin/observium
<?php

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage graphs
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
if (is_numeric($vars['id'])) {
    $sensor = dbFetchRow("SELECT * FROM `sensors` WHERE `sensor_id` = ?", array($vars['id']));
    if (is_numeric($sensor['device_id']) && ($auth || is_entity_permitted($sensor['sensor_id'], 'sensor') || device_permitted($sensor['device_id']))) {
        $device = device_by_id_cache($sensor['device_id']);
        $rrd_filename = get_rrd_path($device, get_sensor_rrd($device, $sensor));
        $title = generate_device_link($device);
        $title .= " :: Sensors :: ";
        $auth = TRUE;
    }
}
// EOF
コード例 #5
0
ファイル: jt.php プロジェクト: CumulusNetworks/cldemo-archive
foreach (dbFetchRows($sql) as $service) {
    if (device_permitted($service['device_id'])) {
        echo "<div style='text-align: center; margin: 2px; border: solid 2px #D0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ffddaa;'>\n      <strong>" . generate_device_link($service, shorthost($service['hostname'])) . "</strong><br />\n      <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Service Down</span><br />\n      <strong>" . $service['service_type'] . "</strong><br />\n      <span class=body-date-1>" . truncate($interface['ifAlias'], 15) . "</span>\n      </center></div>";
    }
}
$sql = "SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id";
foreach (dbFetchRows($sql) as $peer) {
    if (device_permitted($peer['device_id'])) {
        echo "<div style='text-align: center; margin: 2px; border: solid 2px #D0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ffddaa;'>\n      <strong>" . generate_device_link($peer, shorthost($peer['hostname'])) . "</strong><br />\n      <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>BGP Down</span><br />\n      <strong>" . $peer['bgpPeerIdentifier'] . "</strong><br />\n      <span class=body-date-1>AS" . $peer['bgpPeerRemoteAs'] . " " . truncate($peer['astext'], 10) . "</span>\n      </div>";
    }
}
if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) {
    $sql = "SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < '" . $config['uptime_warning'] . "' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'";
    foreach (dbFetchRows($sql) as $device) {
        if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == "uptime") {
            echo "<div style='text-align: center; margin: 2px; border: solid 2px #D0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ddffdd;'>\n        <strong>" . generate_device_link($device, shorthost($device['hostname'])) . "</strong><br />\n        <span style='font-size: 14px; font-weight: bold; margin: 5px; color: #090;'>Device<br />Rebooted</span><br />\n        <span class=body-date-1>" . formatUptime($device['attrib_value']) . "</span>\n        </div>";
        }
    }
}
echo "\n\n        <div style='clear: both;'>{$errorboxes}</div> <div style='margin: 0px; clear: both;'>\n\n<h3>Recent Syslog Messages</h3>\n\n";
$sql = "SELECT *, DATE_FORMAT(timestamp, '%D %b %T') AS date from syslog,devices WHERE syslog.device_id = devices.device_id ORDER BY seq DESC LIMIT 20";
echo "<table cellspacing=0 cellpadding=2 width=100%>";
foreach (dbFetchRows($sql) as $entry) {
    include "includes/print-syslog.inc.php";
}
echo "</table>";
echo "</div>\n\n   </td>\n   <td bgcolor=#e5e5e5 width=470 valign=top>";
// this stuff can be customised to show whatever you want....
if ($_SESSION['userlevel'] >= '5') {
    $sql = "SELECT * FROM ports AS I, devices AS D WHERE `ifAlias` like 'Transit: %' AND I.device_id = D.device_id ORDER BY I.ifAlias";
    unset($seperator);
コード例 #6
0
ファイル: default.php プロジェクト: greggcz/librenms
    }
    foreach (dbFetchRows($sql) as $peer) {
        generate_front_box('bgp-down', generate_device_link($peer, shorthost($peer['hostname'])) . "<br />\n    <span class=bgp-down>BGP Down</span>\n    <span class='" . (strstr($peer['bgpPeerIdentifier'], ':') ? 'front-page-bgp-small' : 'front-page-bgp-normal') . "'>" . $peer['bgpPeerIdentifier'] . '</span><br />
    <span class=body-date-1>AS' . truncate($peer['bgpPeerRemoteAs'] . ' ' . $peer['astext'], 14, '') . '</span>');
        ++$count_boxes;
    }
}
// Device rebooted boxes
if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== false && $config['uptime_warning'] > 0) {
    if (is_admin() === true || is_read() === true) {
        $sql = "SELECT * FROM `devices` AS D WHERE D.status = '1' AND D.uptime > 0 AND D.uptime < '" . $config['uptime_warning'] . "' AND D.ignore = 0 LIMIT " . $config['front_page_down_box_limit'];
    } else {
        $sql = "SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND D.status = '1' AND D.uptime > 0 AND D.uptime < '" . $config['uptime_warning'] . "' AND D.ignore = 0 LIMIT " . $config['front_page_down_box_limit'];
    }
    foreach (dbFetchRows($sql) as $device) {
        generate_front_box('device-rebooted', generate_device_link($device, shorthost($device['hostname'])) . '<br />
      <span class=device-rebooted>Device Rebooted</span><br />
      <span class=body-date-1>' . formatUptime($device['uptime'], 'short') . '</span>');
        ++$count_boxes;
    }
}
if ($count_boxes == 0) {
    echo "<h5>Nothing here yet</h5><p class=welcome>This is where status notifications about devices and services would normally go. You might have none\n  because you run such a great network, or perhaps you've just started using " . $config['project_name'] . ". If you're new to " . $config['project_name'] . ', you might
  want to start by adding one or more devices in the Devices menu.</p>';
}
echo '</div>';
echo '</div>';
echo '</div>';
echo '
  </div>
  </div>
コード例 #7
0
function get_status_array($status)
{
    // Mike: I know that there are duplicated variables, but later will remove global
    global $config, $cache;
    $max_interval = filter_var($status['max']['interval'], FILTER_VALIDATE_INT, array('options' => array('default' => 24, 'min_range' => 1)));
    $max_count = filter_var($status['max']['count'], FILTER_VALIDATE_INT, array('options' => array('default' => 200, 'min_range' => 1)));
    $query_device_permitted = generate_query_permitted(array('device'), array('device_table' => 'D'));
    $query_port_permitted = generate_query_permitted(array('port'), array('port_table' => 'I'));
    // Show Device Status
    if ($status['devices']) {
        $query = 'SELECT * FROM `devices` AS D ';
        $query .= 'WHERE D.`status` = 0' . $query_device_permitted;
        $query .= 'ORDER BY D.`hostname` ASC';
        $entries = dbFetchRows($query);
        foreach ($entries as $device) {
            $boxes[] = array('sev' => 100, 'class' => 'Device', 'event' => 'Down', 'device_link' => generate_device_link($device, short_hostname($device['hostname'])), 'time' => deviceUptime($device, 'short-3'));
        }
    }
    // Uptime
    if ($status['uptime']) {
        if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0) {
            $query = 'SELECT * FROM `devices` AS D ';
            $query .= 'WHERE D.`status` = 1 AND D.`uptime` > 0 AND D.`uptime` < ' . $config['uptime_warning'];
            $query .= $query_device_permitted;
            $query .= 'ORDER BY D.`hostname` ASC';
            $entries = dbFetchRows($query);
            foreach ($entries as $device) {
                $boxes[] = array('sev' => 10, 'class' => 'Device', 'event' => 'Rebooted', 'device_link' => generate_device_link($device, short_hostname($device['hostname'])), 'time' => deviceUptime($device, 'short-3'), 'location' => $device['location']);
            }
        }
    }
    // Ports Down
    if ($status['ports'] || $status['links']) {
        // warning about deprecated option: $config['warn']['ifdown']
        if (isset($config['warn']['ifdown']) && !$config['warn']['ifdown']) {
            print_warning("<strong>Config option obsolete</strong>\n                    Please note that config option <strong>\$config['warn']['ifdown']</strong> is now obsolete.\n                    Use options: <strong>\$config['frontpage']['device_status']['ports']</strong> and <strong>\$config['frontpage']['device_status']['errors']</strong>\n                    To remove this message, delete <strong>\$config['warn']['ifdown']</strong> from configuration file.");
        }
        $query = 'SELECT * FROM `ports` AS I ';
        if ($status['links'] && !$status['ports']) {
            $query .= 'INNER JOIN `links` as L ON I.`port_id` = L.`local_port_id` ';
        }
        $query .= 'LEFT JOIN `devices` AS D ON I.`device_id` = D.`device_id` ';
        $query .= "WHERE I.`ifOperStatus` = 'down' AND I.`ifAdminStatus` = 'up' ";
        if ($status['links'] && !$status['ports']) {
            $query .= ' AND L.`active` = 1 ';
        }
        $query .= $query_port_permitted;
        $query .= ' AND I.`ifLastChange` >= DATE_SUB(NOW(), INTERVAL ' . $max_interval . ' HOUR) ';
        $query .= 'ORDER BY I.`ifLastChange` DESC, D.`hostname` ASC, I.`ifDescr` * 1 ASC ';
        $entries = dbFetchRows($query);
        $i = 1;
        foreach ($entries as $port) {
            if ($i > $max_count) {
                // Limit to 200 ports on overview page
                break;
            }
            humanize_port($port);
            $boxes[] = array('sev' => 50, 'class' => 'Port', 'event' => 'Down', 'device_link' => generate_device_link($port, short_hostname($port['hostname'])), 'entity_link' => generate_port_link($port, short_ifname($port['label'], 13)), 'time' => formatUptime($config['time']['now'] - strtotime($port['ifLastChange'])), 'location' => $device['location']);
        }
    }
    // Ports Errors (only deltas)
    if ($status['errors']) {
        foreach ($cache['ports']['errored'] as $port_id) {
            $port = get_port_by_id($port_id);
            $device = device_by_id_cache($port['device_id']);
            humanize_port($port);
            if ($port['ifInErrors_delta']) {
                $port['string'] .= 'Rx: ' . format_number($port['ifInErrors_delta']);
            }
            if ($port['ifInErrors_delta'] && $port['ifOutErrors_delta']) {
                $port['string'] .= ', ';
            }
            if ($port['ifOutErrors_delta']) {
                $port['string'] .= 'Tx: ' . format_number($port['ifOutErrors_delta']);
            }
            $boxes[] = array('sev' => 75, 'class' => 'Port', 'event' => 'Errors', 'device_link' => generate_device_link($device, short_hostname($device['hostname'])), 'entity_link' => generate_port_link($port, short_ifname($port['label'], 13)), 'time' => $port['string'], 'location' => $device['location']);
        }
    }
    // Services
    if ($status['services']) {
        $query = 'SELECT * FROM `services` AS S ';
        $query .= 'LEFT JOIN `devices` AS D ON S.device_id = D.device_id ';
        $query .= "WHERE S.`service_status` = 'down' AND S.`service_ignore` = 0";
        $query .= $query_device_permitted;
        $query .= 'ORDER BY D.`hostname` ASC';
        $entries = dbFetchRows($query);
        foreach ($entries as $service) {
            $boxes[] = array('sev' => 50, 'class' => 'Service', 'event' => 'Down', 'device_link' => generate_device_link($service, short_hostname($service['hostname'])), 'entity_link' => $service['service_type'], 'time' => formatUptime($config['time']['now'] - strtotime($service['service_changed']), 'short'), 'location' => $device['location']);
        }
    }
    // BGP
    if ($status['bgp']) {
        if (isset($config['enable_bgp']) && $config['enable_bgp']) {
            $query = 'SELECT * FROM `devices` AS D ';
            $query .= 'LEFT JOIN `bgpPeers` AS B ON B.`device_id` = D.`device_id` ';
            $query .= 'LEFT JOIN `bgpPeers-state` AS BS ON B.`bgpPeer_id` = BS.`bgpPeer_id` ';
            $query .= "WHERE (`bgpPeerAdminStatus` = 'start' OR `bgpPeerAdminStatus` = 'running') AND `bgpPeerState` != 'established' ";
            $query .= $query_device_permitted;
            $query .= 'ORDER BY D.`hostname` ASC';
            $entries = dbFetchRows($query);
            foreach ($entries as $peer) {
                $peer_ip = strstr($peer['bgpPeerRemoteAddr'], ':') ? Net_IPv6::compress($peer['bgpPeerRemoteAddr']) : $peer['bgpPeerRemoteAddr'];
                $peer['wide'] = strstr($peer['bgpPeerRemoteAddr'], ':') ? TRUE : FALSE;
                $boxes[] = array('sev' => 75, 'class' => 'BGP Peer', 'event' => 'Down', 'device_link' => generate_device_link($peer, short_hostname($peer['hostname'])), 'entity_link' => $peer_ip, 'wide' => $peer['wide'], 'time' => formatUptime($peer['bgpPeerFsmEstablishedTime'], 'short-3'), 'location' => $device['location']);
            }
        }
    }
    // Return boxes array
    return $boxes;
}
コード例 #8
0
ファイル: vrf.inc.php プロジェクト: samyscoub/librenms
 $x = 1;
 foreach ($vrf_devices[$vrf['mplsVpnVrfRouteDistinguisher']] as $device) {
     if ($i % 2) {
         if ($x % 2) {
             $dev_colour = $list_colour_a_a;
         } else {
             $dev_colour = $list_colour_a_b;
         }
     } else {
         if ($x % 2) {
             $dev_colour = $list_colour_b_b;
         } else {
             $dev_colour = $list_colour_b_a;
         }
     }
     echo "<tr bgcolor='{$dev_colour}'><td width=150>" . generate_device_link($device, shorthost($device['hostname']));
     if ($device['vrf_name'] != $vrf['vrf_name']) {
         echo "<a href='#' onmouseover=\" return overlib('Expected Name : " . $vrf['vrf_name'] . '<br />Configured : ' . $device['vrf_name'] . "', CAPTION, '<span class=list-large>VRF Inconsistency</span>' ,FGCOLOR,'#e5e5e5', BGCOLOR, '#c0c0c0', BORDER, 5, CELLPAD, 4, CAPCOLOR, '#050505');\" onmouseout=\"return nd();\"> <img align=absmiddle src=images/16/exclamation.png></a>";
     }
     echo '</td><td>';
     unset($seperator);
     foreach ($ports[$device['vrf_id']][$device['device_id']] as $port) {
         $port = array_merge($device, $port);
         switch ($_GET['optc']) {
             case 'bits':
             case 'upkts':
             case 'nupkts':
             case 'errors':
                 $port['width'] = '130';
                 $port['height'] = '30';
                 $port['from'] = $config['time']['day'];
コード例 #9
0
ファイル: iftype.inc.php プロジェクト: skive/observium
        unset($class);
        $port['ifAlias'] = str_ireplace($type . ": ", "", $port['ifAlias']);
        $port['ifAlias'] = str_ireplace("[PNI]", "Private", $port['ifAlias']);
        $ifclass = ifclass($port['ifOperStatus'], $port['ifAdminStatus']);
        if ($bg == "#ffffff") {
            $bg = "#e5e5e5";
        } else {
            $bg = "#ffffff";
        }
        echo "<tr class='iftype'>\n             <td><span class=entity-title>" . generate_port_link($port, $port['port_descr_descr']) . "</span>";
        #            <span class=small style='float: left;'>".generate_device_link($port)." ".generate_port_link($port)." </span>");
        if (dbFetchCell("SELECT count(*) FROM mac_accounting WHERE port_id = ?", array($port['port_id']))) {
            echo "<span style='float: right;'><a href='device/device=" . $port['device_id'] . "/tab=port/port=" . $port['port_id'] . "/view=macaccounting/'><img src='images/16/chart_curve.png' align='absmiddle'> MAC Accounting</a></span>";
        }
        echo "</td>";
        echo '   <td style="width: 150px;" class="strong">' . generate_device_link($port) . '</td>
             <td style="width: 150px;" class="strong">' . generate_port_link($port, short_ifname($port['ifDescr'])) . '</td>
             <td style="width: 75px;">' . $port['port_descr_speed'] . '</td>
             <td style="width: 150px;">' . $port['port_descr_circuit'] . '</td>
             <td>' . $port['port_descr_notes'] . '</td>';
        echo '</tr><tr><td colspan="6">';
        $rrdfile = get_port_rrdfilename($port, NULL, TRUE);
        if (file_exists($rrdfile)) {
            $graph_type = "port_bits";
            include "includes/print-interface-graphs.inc.php";
        }
        echo "</td></tr>";
    }
} else {
    echo "None found.</td></tr>";
}
コード例 #10
0
ファイル: top_ports.inc.php プロジェクト: samyscoub/librenms
<?php

/*
 * LibreNMS front page top ports graph
 * - Find most utilised ports that have been polled in the last N minutes
 *
 * Author: Paul Gear
 * Copyright (c) 2013 Gear Consulting Pty Ltd <http://libertysys.com.au/>
 *
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or (at your
 * option) any later version.  Please see LICENSE.txt at the top level of
 * the source code distribution for details.
 */
$minutes = 15;
$seconds = $minutes * 60;
$top = $config['front_page_settings']['top']['ports'];
if (is_admin() === true || is_read() === true) {
    $query = "\n        SELECT *, p.ifInOctets_rate + p.ifOutOctets_rate as total\n        FROM ports as p, devices as d\n        WHERE d.device_id = p.device_id\n        AND unix_timestamp() - p.poll_time < {$seconds}\n        AND ( p.ifInOctets_rate > 0\n        OR p.ifOutOctets_rate > 0 )\n        ORDER BY total desc\n        LIMIT {$top}\n        ";
} else {
    $query = "\n        SELECT *, I.ifInOctets_rate + I.ifOutOctets_rate as total\n        FROM ports as I, devices as d,\n        `devices_perms` AS `P`, `ports_perms` AS `PP`\n        WHERE ((`P`.`user_id` = ? AND `P`.`device_id` = `d`.`device_id`) OR (`PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` AND `I`.`device_id` = `d`.`device_id`)) AND\n        d.device_id = I.device_id\n        AND unix_timestamp() - I.poll_time < {$seconds}\n        AND ( I.ifInOctets_rate > 0\n        OR I.ifOutOctets_rate > 0 )\n        ORDER BY total desc\n        LIMIT {$top}\n        ";
    $param[] = array($_SESSION['user_id'], $_SESSION['user_id']);
}
//end if
echo "<strong>Top {$top} ports (last {$minutes} minutes)</strong>\n";
echo "<table class='simple'>\n";
foreach (dbFetchRows($query, $param) as $result) {
    echo '<tr class=top10>' . '<td class=top10>' . generate_device_link($result, shorthost($result['hostname'])) . '</td>' . '<td class=top10>' . generate_port_link($result) . '</td>' . '<td class=top10>' . generate_port_link($result, generate_port_thumbnail($result)) . '</td>' . "</tr>\n";
}
echo "</table>\n";
コード例 #11
0
foreach ($cache['devices']['hostname'] as $hostname => $id) {
    // Reference the cache.
    $device =& $cache['devices']['id'][$id];
    if ($device['disabled'] == 1 && !$config['web_show_disabled']) {
        continue;
    }
    // Find max poller/discovery times
    if ($device['last_polled_timetaken'] > $proc['max']['poller']) {
        $proc['max']['poller'] = $device['last_polled_timetaken'];
    }
    if ($device['last_discovered_timetaken'] > $proc['max']['discovery']) {
        $proc['max']['discovery'] = $device['last_discovered_timetaken'];
    }
    $proc['avg2']['poller'] += pow($device['last_polled_timetaken'], 2);
    $proc['avg2']['discovery'] += pow($device['last_discovered_timetaken'], 2);
    $poller_table[] = array('html_row_class' => $device['html_row_class'], 'html_tab_colour' => $device['html_tab_colour'], 'device_hostname' => $device['hostname'], 'device_link' => generate_device_link($device), 'last_polled_timetaken' => $device['last_polled_timetaken'], 'last_polled' => $device['last_polled'], 'last_discovered_timetaken' => $device['last_discovered_timetaken'], 'last_discovered' => $device['last_discovered']);
}
// Sort poller table
// sort order: $polled > $discovered > $hostname
$poller_table = array_sort_by($poller_table, 'last_polled_timetaken', SORT_DESC, SORT_NUMERIC, 'last_discovered_timetaken', SORT_DESC, SORT_NUMERIC, 'device_hostname', SORT_ASC, SORT_STRING);
// Print poller table
foreach ($poller_table as $row) {
    $proc['time']['poller'] = round($row['last_polled_timetaken'] * 100 / $proc['max']['poller']);
    $proc['color']['poller'] = "success";
    if ($row['last_polled_timetaken'] > $proc['max']['poller'] * 0.75) {
        $proc['color']['poller'] = "danger";
    } elseif ($row['last_polled_timetaken'] > $proc['max']['poller'] * 0.5) {
        $proc['color']['poller'] = "warning";
    } elseif ($row['last_polled_timetaken'] >= $proc['max']['poller'] * 0.25) {
        $proc['color']['poller'] = "info";
    }
コード例 #12
0
ファイル: bgp.inc.php プロジェクト: skive/observium
$sql = 'SELECT * FROM `bgpPeers` AS B
        LEFT JOIN `bgpPeers-state` AS S ON B.bgpPeer_id = S.bgpPeer_id
        WHERE `device_id` = ? ' . $where . '
        ORDER BY `bgpPeerRemoteAs`, `bgpPeerRemoteAddr`';
foreach (dbFetchRows($sql, array($device['device_id'])) as $peer) {
    $peer['bgpLocalAs'] = $device['bgpLocalAs'];
    humanize_bgp($peer);
    $has_macaccounting = dbFetchCell("SELECT COUNT(*) FROM mac_accounting AS M\n                                   LEFT JOIN `ip_mac` AS I ON M.mac = I.mac_address\n                                   WHERE I.ip_address = ?", array($peer['bgpPeerRemoteAddr']));
    unset($peerhost, $peername);
    $ip_version = strstr($peer['bgpPeerRemoteAddr'], ':') ? 'ipv6' : 'ipv4';
    $peerhost = dbFetchRow('SELECT * FROM ' . $ip_version . '_addresses AS A
                         LEFT JOIN ports AS I ON A.port_id = I.port_id
                         LEFT JOIN devices AS D ON I.device_id = D.device_id
                         WHERE A.' . $ip_version . '_address = ?', array($peer['bgpPeerRemoteAddr']));
    if ($peerhost['device_id']) {
        $peername = generate_device_link($peerhost, short_hostname($peerhost['hostname']), array('tab' => 'routing', 'proto' => 'bgp'));
        $peer['remote_id'] = $peerhost['device_id'];
    } else {
        $peername = $peer['reverse_dns'];
    }
    unset($sep);
    foreach (dbFetchRows("SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ? AND bgpPeerRemoteAddr = ?", array($device['device_id'], $peer['bgpPeerRemoteAddr'])) as $afisafi) {
        $afi = $afisafi['afi'];
        $safi = $afisafi['safi'];
        $this_afisafi = $afi . $safi;
        $peer['afi'] .= $sep . $afi . "." . $safi;
        $sep = "<br />";
        $peer['afisafi'][$this_afisafi] = 1;
        // Build a list of valid AFI/SAFI for this peer
    }
    $graph_type = "bgp_updates";
コード例 #13
0
ファイル: alertlog.inc.php プロジェクト: awlx/librenms
foreach (dbFetchRows($sql, $param) as $alertlog) {
    $dev = device_by_id_cache($alertlog['device_id']);
    $fault_detail = alert_details($alertlog['details']);
    $alert_state = $alertlog['state'];
    if ($alert_state == '0') {
        $fa_icon = 'check';
        $fa_color = 'success';
        $text = 'Ok';
    } elseif ($alert_state == '1') {
        $fa_icon = 'times';
        $fa_color = 'danger';
        $text = 'Alert';
    } elseif ($alert_state == '2') {
        $fa_icon = 'info-circle';
        $fa_color = 'muted';
        $text = 'Ack';
    } elseif ($alert_state == '3') {
        $fa_icon = 'arrow-down';
        $fa_color = 'warning';
        $text = 'Worse';
    } elseif ($alert_state == '4') {
        $fa_icon = 'arrow-up';
        $fa_color = 'info';
        $text = 'Better';
    }
    //end if
    $response[] = array('id' => $rulei++, 'time_logged' => $alertlog['humandate'], 'details' => '<a class="fa fa-plus incident-toggle" style="display:none" data-toggle="collapse" data-target="#incident' . $rulei . '" data-parent="#alerts"></a>', 'hostname' => '<div class="incident">' . generate_device_link($dev, shorthost($dev['hostname'])) . '<div id="incident' . $rulei . '" class="collapse">' . $fault_detail . '</div></div>', 'alert' => htmlspecialchars($alertlog['alert']), 'status' => "<b><i class='fa fa-" . $fa_icon . " text-" . $fa_color . "'></i> {$text}</b>");
}
//end foreach
$output = array('current' => $current, 'rowCount' => $rowCount, 'rows' => $response, 'total' => $total);
echo _json_encode($output);
コード例 #14
0
ファイル: top-interfaces.inc.php プロジェクト: awlx/librenms
            LIMIT :count
            ';
    }
    $common_output[] = '
<h4>Top ' . $interface_count . ' interfaces polled within ' . $interval . ' minutes</h4>
<div class="table-responsive">
<table class="table table-hover table-condensed table-striped bootgrid-table">
  <thead>
    <tr>
      <th class="text-left">Device</th>
      <th class="text-left">Interface</th>
      <th class="text-left">Total traffic</a></th>
   </tr>
  </thead>
  <tbody>
    ';
    foreach (dbFetchRows($query, $params) as $result) {
        $common_output[] = '
    <tr>
      <td class="text-left">' . generate_device_link($result, shorthost($result['hostname'])) . '</td>
      <td class="text-left">' . generate_port_link($result, shorten_interface_type($result['ifName'])) . '</td>
      <td class="text-left">' . generate_port_link($result, generate_port_thumbnail($result)) . '</td>
    </tr>
        ';
    }
    $common_output[] = '
  </tbody>
</table>
</div>
    ';
}
コード例 #15
0
function generate_printersupplies_row($supply, $vars)
{
    $graph_type = "printersupply_usage";
    $table_cols = 5;
    $total = $supply['supply_capacity'];
    $perc = $supply['supply_value'];
    $graph_array['type'] = $graph_type;
    $graph_array['id'] = $supply['supply_id'];
    $graph_array['from'] = $GLOBALS['config']['time']['day'];
    $graph_array['to'] = $GLOBALS['config']['time']['now'];
    $graph_array['height'] = "20";
    $graph_array['width'] = "80";
    if ($supply['supply_colour'] != '') {
        $background = toner_to_colour($supply['supply_colour'], $perc);
    } else {
        $background = toner_to_colour($supply['supply_descr'], $perc);
    }
    /// FIXME - popup for printersupply entity.
    $output .= '<tr class="' . $supply['html_row_class'] . '">';
    $output .= '<td class="state-marker"></td>';
    if ($vars['popup'] == TRUE) {
        $output .= '<td style="width: 40px; text-align: center;"><i class="' . $GLOBALS['config']['entities']['printersupply']['icon'] . '"></i></td>';
    } else {
        $output .= '<td style="width: 1px;"></td>';
    }
    if ($vars['page'] != "device" && $vars['popup'] != TRUE) {
        $output .= '<td class="entity">' . generate_device_link($supply) . '</td>';
        $table_cols++;
    }
    $output .= '<td class="entity">' . generate_entity_link('printersupply', $supply) . '</td>';
    if (!isset($vars['supply'])) {
        $output .= '<td>' . nicecase($supply['supply_type']) . '</td>';
    }
    $output .= '<td style="width: 70px;">' . generate_graph_popup($graph_array) . '</td>';
    $output .= '<td style="width: 200px;"><a href="' . $link . '">' . print_percentage_bar(400, 20, $perc, $perc . '%', 'ffffff', $background['right'], NULL, "ffffff", $background['left']) . '</a></td>';
    $output .= '<td style="width: 50px; text-align: right;"><span class="label">' . $perc . '%</span></td>';
    $output .= '</tr>';
    if ($vars['view'] == "graphs") {
        $output .= '<tr class="' . $supply['html_row_class'] . '">';
        $output .= '<td class="state-marker"></td>';
        $output .= '<td colspan=' . $table_cols . '>';
        unset($graph_array['height'], $graph_array['width'], $graph_array['legend']);
        $graph_array['to'] = $config['time']['now'];
        $graph_array['id'] = $supply['supply_id'];
        $graph_array['type'] = $graph_type;
        $output .= generate_graph_row($graph_array, TRUE);
        $output .= "</td></tr>";
    }
    # endif graphs
    return $output;
}
コード例 #16
0
ファイル: latency.inc.php プロジェクト: skive/observium
        echo '<tr><td>';
        echo '<h3>Aggregate</h3>';
        print_graph_row($graph_array);
        echo '</td></tr>';
        unset($graph_array['legend']);
        asort($smokeping_files['outgoing'][$device['hostname']]);
        foreach ($smokeping_files['outgoing'][$device['hostname']] as $host) {
            $hostname = basename($host, ".rrd");
            list($hostname) = explode("~", $hostname);
            if ($config['smokeping']['suffix']) {
                $hostname = $hostname . $config['smokeping']['suffix'];
            }
            if ($config['smokeping']['split_char']) {
                $hostname = str_replace($config['smokeping']['split_char'], ".", $hostname);
            }
            $host = device_by_name($hostname);
            if (is_numeric($host['device_id'])) {
                echo '<tr><td>';
                echo '<h3>' . generate_device_link($host) . '</h3>';
                $graph_array['type'] = "smokeping_out";
                $graph_array['device'] = $device['device_id'];
                $graph_array['dest'] = $host['device_id'];
                print_graph_row($graph_array);
                echo '</td></tr>';
            }
        }
    }
}
echo '</table>';
$pagetitle[] = "Latency";
// EOF
コード例 #17
0
ファイル: add.inc.php プロジェクト: RomanBogachev/observium
              <input class="span4" type="text" name="bill_notes" value="<?php 
    echo $port['port_descr_speed'];
    ?>
">
            </div>
          </div>
        </fieldset>
        <div class="form-actions">
          <!-- <button class="btn btn-info" style="float: right;"><i class="icon-circle-arrow-left icon-white"></i> <strong>Back to bills</strong></button> //-->
          <button type="submit" class="btn btn-primary"><i class="icon-ok-sign icon-white"></i> <strong>Add Bill</strong></button>
        </div>
    </div>
    <div class="tab-pane fade in" id="ports">
<?php 
    if (is_array($port)) {
        $devicebtn = str_replace("list-device", "btn", generate_device_link($port));
        $portbtn = str_replace("interface-upup", "btn", generate_port_link($port));
        $portalias = empty($port['ifAlias']) ? "" : " - " . $port['ifAlias'] . "";
        $devicebtn = str_replace("\">" . $port['hostname'], "\" style=\"color: #000;\"><i class=\"icon-asterisk\"></i> " . $port['hostname'], $devicebtn);
        $devicebtn = str_replace("overlib('", "overlib('<div style=\\'border: 5px solid #e5e5e5; background: #fff; padding: 10px;\\'>", $devicebtn);
        $devicebtn = str_replace("<div>',;", "</div></div>',", $devicebtn);
        $portbtn = str_replace("\">" . strtolower($port['ifName']), "\" style=\"color: #000;\"><i class=\"icon-random\"></i> " . $port['ifName'] . "" . $portalias, $portbtn);
        $portbtn = str_replace("overlib('", "overlib('<div style=\\'border: 5px solid #e5e5e5; background: #fff; padding: 10px;\\'>", $portbtn);
        $portbtn = str_replace("<div>',;", "</div></div>',", $portbtn);
        echo "      <fieldset>\n";
        echo "        <legend>Bill Ports</legend>\n";
        echo "        <input type=\"hidden\" name=\"port\" value=\"" . $port['port_id'] . "\">\n";
        echo "        <div class=\"control-group\">\n";
        echo "          <div class=\"btn-toolbar\">\n";
        echo "            <div class=\"btn-group\">\n";
        echo "              " . $devicebtn . "\n";
コード例 #18
0
ファイル: check-errors.php プロジェクト: skive/observium
include "includes/defaults.inc.php";
include "config.php";
include "includes/definitions.inc.php";
include "includes/functions.inc.php";
include "html/includes/functions.inc.php";
// Check all of our interface RRD files for errors
if ($argv[1]) {
    $where = "AND `port_id` = ?";
    $params = array($argv[1]);
}
$i = 0;
$errored = 0;
foreach (dbFetchRows("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id {$where}", $params) as $interface) {
    $errors = $interface['ifInErrors_delta'] + $interface['ifOutErrors_delta'];
    if ($errors > '1') {
        $errored[] = generate_device_link($interface, $interface['hostname'] . " - " . $interface['ifDescr'] . " - " . $interface['ifAlias'] . " - " . $interface['ifInErrors_delta'] . " - " . $interface['ifOutErrors_delta']);
        $errored++;
    }
    $i++;
}
echo "Checked {$i} interfaces\n";
if (is_array($errored)) {
    // If there are errored ports
    $i = 0;
    $msg = "Interfaces with errors : \n\n";
    foreach ($errored as $int) {
        $msg .= "{$int}\n";
        // Add a line to the report email warning about them
        $i++;
    }
    // Send the alert email
コード例 #19
0
 if (device_permitted($proc['device_id'])) {
     $device = $proc;
     // FIXME should that really be done here? :-)
     $text_descr = $proc['processor_descr'];
     $text_descr = str_replace("Routing Processor", "RP", $text_descr);
     $text_descr = str_replace("Switching Processor", "SP", $text_descr);
     $text_descr = str_replace("Sub-Module", "Module ", $text_descr);
     $text_descr = str_replace("DFC Card", "DFC", $text_descr);
     $proc_url = "device/" . $device['device_id'] . "/health/processor/";
     $mini_url = "graph.php?id=" . $proc['processor_id'] . "&amp;type=" . $graph_type . "&amp;from=" . $config['time']['day'] . "&amp;to=" . $config['time']['now'] . "&amp;width=80&amp;height=20&amp;bg=f4f4f400";
     $proc_popup = "onmouseover=\"return overlib('<div class=list-large>" . $device['hostname'] . " - " . $text_descr;
     $proc_popup .= "</div><img src=\\'graph.php?id=" . $proc['processor_id'] . "&amp;type=" . $graph_type . "&amp;from=" . $config['month'] . "&amp;to=" . $config['time']['now'] . "&amp;width=400&amp;height=125\\'>";
     $proc_popup .= "', RIGHT" . $config['overlib_defaults'] . ");\" onmouseout=\"return nd();\"";
     $perc = round($proc['processor_usage']);
     $background = get_percentage_colours($perc);
     echo "    <tr class=\"health\">\n               <td>" . generate_device_link($proc) . "</td>\n               <td class=\"tablehead\"><a href='" . $proc_url . "' {$proc_popup}>" . $text_descr . "</a></td>\n               <td width=\"90\"><a href=\"" . $proc_url . "\"  {$proc_popup}><img src=\"{$mini_url}\" /></a></td>\n               <td width=\"200\"><a href=\"" . $proc_url . "\" {$proc_popup}>\n           " . print_percentage_bar(400, 20, $perc, $perc . "%", "ffffff", $background['left'], 100 - $perc . "%", "ffffff", $background['right']);
     echo '</a></td>
          </tr>';
     if ($vars['view'] == "graphs") {
         echo '    <tr></tr><tr class="health"><td colspan="5">';
         $daily_graph = "graph.php?id=" . $proc['processor_id'] . "&amp;type=" . $graph_type . "&amp;from=" . $config['time']['day'] . "&amp;to=" . $config['time']['now'] . "&amp;width=211&amp;height=100";
         $daily_url = "graph.php?id=" . $proc['processor_id'] . "&amp;type=" . $graph_type . "&amp;from=" . $config['time']['day'] . "&amp;to=" . $config['time']['now'] . "&amp;width=400&amp;height=150";
         $weekly_graph = "graph.php?id=" . $proc['processor_id'] . "&amp;type=" . $graph_type . "&amp;from=" . $config['time']['week'] . "&amp;to=" . $config['time']['now'] . "&amp;width=211&amp;height=100";
         $weekly_url = "graph.php?id=" . $proc['processor_id'] . "&amp;type=" . $graph_type . "&amp;from=" . $config['time']['week'] . "&amp;to=" . $config['time']['now'] . "&amp;width=400&amp;height=150";
         $monthly_graph = "graph.php?id=" . $proc['processor_id'] . "&amp;type=" . $graph_type . "&amp;from=" . $config['time']['month'] . "&amp;to=" . $config['time']['now'] . "&amp;width=211&amp;height=100";
         $monthly_url = "graph.php?id=" . $proc['processor_id'] . "&amp;type=" . $graph_type . "&amp;from=" . $config['time']['month'] . "&amp;to=" . $config['time']['now'] . "&amp;width=400&amp;height=150";
         $yearly_graph = "graph.php?id=" . $proc['processor_id'] . "&amp;type=" . $graph_type . "&amp;from=" . $config['time']['year'] . "&amp;to=" . $config['time']['now'] . "&amp;width=211&amp;height=100";
         $yearly_url = "graph.php?id=" . $proc['processor_id'] . "&amp;type=" . $graph_type . "&amp;from=" . $config['time']['year'] . "&amp;to=" . $config['time']['now'] . "&amp;width=400&amp;height=150";
         echo "      <a onmouseover=\"return overlib('<img src=\\'{$daily_url}\\'>', LEFT);\" onmouseout=\"return nd();\">\n        <img src=\"{$daily_graph}\" border=\"0\"></a> ";
         echo "      <a onmouseover=\"return overlib('<img src=\\'{$weekly_url}\\'>', LEFT);\" onmouseout=\"return nd();\">\n        <img src=\"{$weekly_graph}\" border=\"0\"></a> ";
         echo "      <a onmouseover=\"return overlib('<img src=\\'{$monthly_url}\\'>', LEFT);\" onmouseout=\"return nd();\">\n        <img src=\"{$monthly_graph}\" border=\"0\"></a> ";
コード例 #20
0
          <button class="btn pull-right" type="submit" name="提交" value="添加"><i class="oicon-plus-circle"></i> 添加</button>
        </form>
      </div>
    </div>
    <div class="col-md-4">
      <div class="well">
        <h2>端口权限</h2>

<?php 
            if (count($user_permissions['port'])) {
                foreach (array_keys($user_permissions['port']) as $entity_id) {
                    $port = get_port_by_id($entity_id);
                    $device = device_by_id_cache($port['device_id']);
                    $emptyCheck = true;
                    $count++;
                    $devicebtn = '<button class="btn"><i class="oicon-servers"></i> ' . generate_device_link($device) . '</button>';
                    if (empty($port['ifAlias'])) {
                        $portalias = "";
                    } else {
                        $portalias = " - " . $port['ifAlias'] . "";
                    }
                    $portbtn = '<button class="btn">' . generate_port_link($port, '<i class="oicon-network-ethernet"></i> ' . rewrite_ifname($port['label']) . $portalias) . '</button>';
                    $del_url = generate_url(array('page' => 'edituser', 'action' => 'perm_del', 'user_id' => $vars['user_id'], 'entity_type' => 'port', 'entity_id' => $entity_id));
                    echo '            <div class="btn-group" style="margin: 5px;">';
                    echo '              <button class="btn btn-danger" style="color: #fff;" onclick="location.href=\'' . $del_url . '\';"><i class="icon-minus-sign icon-white"></i> 删除</button>';
                    echo '              ' . $devicebtn;
                    echo '              ' . $portbtn;
                    echo '            </div>';
                }
            } else {
                echo '<div class="alert alert-danger">无权限</div>';
コード例 #21
0
ファイル: print-vm.inc.php プロジェクト: samyscoub/librenms
<?php

echo '<tr class="list">';
echo '<td class="list">';
if (getidbyname($vm['vmwVmDisplayName'])) {
    echo generate_device_link(device_by_name($vm['vmwVmDisplayName']));
} else {
    echo $vm['vmwVmDisplayName'];
}
echo '</td>';
echo '<td class="list">' . $vm['vmwVmState'] . '</td>';
if ($vm['vmwVmGuestOS'] == 'E: tools not installed') {
    echo '<td class="box-desc">Unknown (VMware Tools not installed)</td>';
} else {
    if ($vm['vmwVmGuestOS'] == '') {
        echo '<td class="box-desc"><i>(Unknown)</i></td>';
    } else {
        if (isset($config['vmware_guestid'][$vm['vmwVmGuestOS']])) {
            echo '<td class="list">' . $config['vmware_guestid'][$vm['vmwVmGuestOS']] . '</td>';
        } else {
            echo '<td class="list">' . $vm['vmwVmGuestOS'] . '</td>';
        }
    }
}
if ($vm['vmwVmMemSize'] >= 1024) {
    echo '<td class=list>' . sprintf('%.2f', $vm['vmwVmMemSize'] / 1024) . ' GB</td>';
} else {
    echo '<td class=list>' . sprintf('%.2f', $vm['vmwVmMemSize']) . ' MB</td>';
}
echo '<td class="list">' . $vm['vmwVmCpus'] . ' CPU</td>';
コード例 #22
0
<?php

echo '<table class="table table-striped table-condensed">';
$i = "1";
echo '<thead><th>Local Port</th>
          <th>Remote Port</th>
          <th>Remote Device</th>
          <th>Protocol</th>
      </thead>';
foreach (dbFetchRows("SELECT * FROM links AS L, ports AS I WHERE I.device_id = ? AND I.port_id = L.local_port_id", array($device['device_id'])) as $neighbour) {
    if ($bg_colour == $list_colour_b) {
        $bg_colour = $list_colour_a;
    } else {
        $bg_colour = $list_colour_b;
    }
    echo '<tr bgcolor="' . $bg_colour . '">';
    echo '<td><span style="font-weight: bold;">' . generate_port_link($neighbour) . '</span><br />' . $neighbour['ifAlias'] . '</td>';
    if (is_numeric($neighbour['remote_port_id']) && $neighbour['remote_port_id']) {
        $remote_port = get_port_by_id($neighbour['remote_port_id']);
        $remote_device = device_by_id_cache($remote_port['device_id']);
        echo "<td>" . generate_port_link($remote_port) . "<br />" . $remote_port['ifAlias'] . "</td>";
        echo "<td>" . generate_device_link($remote_device) . "<br />" . $remote_device['hardware'] . "</td>";
    } else {
        echo "<td>" . $neighbour['remote_port'] . "</td>";
        echo "<td>" . $neighbour['remote_hostname'] . "\n          <br />" . $neighbour['remote_platform'] . "</td>";
    }
    echo "<td>" . strtoupper($neighbour['protocol']) . "</td>";
    echo "</tr>";
    $i++;
}
echo "</table>";
コード例 #23
0
         if ($int_links_v4[$int_link]) {
             echo ' ', overlib_link('', '<span class="label label-info">IPv4</span>', implode("<br />", $int_links_v4[$int_link]), NULL);
         }
         $br = "<br />";
     }
 }
 if (!isset($ports_has_ext['pseudowires']) || in_array($port['port_id'], $ports_has_ext['pseudowires'])) {
     foreach (dbFetchRows("SELECT * FROM `pseudowires` WHERE `port_id` = ?", array($port['port_id'])) as $pseudowire) {
         //`port_id`,`peer_device_id`,`peer_ldp_id`,`cpwVcID`,`cpwOid`
         #    $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.`cpwVcID` = ? AND P.`port_id` = I.`port_id`", array($pseudowire['peer_device_id'], $pseudowire['cpwVcID']));
         #    $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);
             echo $br . '<i class="oicon-arrow-switch"></i> <strong>' . generate_port_link($pw_peer_int, short_ifname($pw_peer_int['label'])) . ' on ' . generate_device_link($pw_peer_dev, short_hostname($pw_peer_dev['hostname'])) . '</strong>';
         } else {
             echo $br . '<i class="oicon-arrow-switch"></i> <strong> VC ' . $pseudowire['cpwVcID'] . ' on ' . $pseudowire['peer_addr'] . '</strong>';
         }
         echo ' <span class="label">' . $pseudowire['pw_psntype'] . '</span>';
         echo ' <span class="label">' . $pseudowire['pw_type'] . '</span>';
         $br = "<br />";
     }
 }
 if (!isset($ports_has_ext['ports_pagp']) || in_array($port['ifIndex'], $ports_has_ext['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;
         echo $br . '<i class="oicon-arrow-join"></i> <strong>' . generate_port_link($member) . ' [PAgP]</strong>';
         $br = "<br />";
     }
コード例 #24
0
ファイル: print-event.inc.php プロジェクト: jmacul2/librenms
<?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>';
コード例 #25
0
ファイル: bgp.inc.php プロジェクト: n-st/librenms
 }
 $peeraddresslink = "<span class=list-large><a href='device/device=" . $peer['device_id'] . "/tab=routing/proto=bgp/' onmouseover=\"return overlib('<img src=\\'{$peer_daily_url}\\'>', LEFT" . $config['overlib_defaults'] . ');" onmouseout="return nd();">' . $peer_ident . '</a></span>';
 echo '<tr class="bgp"' . ($peer['alert'] ? ' bordercolor="#cc0000"' : '') . ($peer['disabled'] ? ' bordercolor="#cccccc"' : '') . '>';
 unset($sep);
 foreach (dbFetchRows('SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ? AND bgpPeerIdentifier = ?', array($peer['device_id'], $peer['bgpPeerIdentifier'])) as $afisafi) {
     $afi = $afisafi['afi'];
     $safi = $afisafi['safi'];
     $this_afisafi = $afi . $safi;
     $peer['afi'] .= $sep . $afi . '.' . $safi;
     $sep = '<br />';
     $peer['afisafi'][$this_afisafi] = 1;
     // Build a list of valid AFI/SAFI for this peer
 }
 unset($sep);
 echo '  <td></td>
     <td width=150>' . $localaddresslink . '<br />' . generate_device_link($peer, shorthost($peer['hostname']), array('tab' => 'routing', 'proto' => 'bgp')) . '</td>
     <td width=30><b>&#187;</b></td>
     <td width=150>' . $peeraddresslink . "</td>\n            <td width=50><b>{$peer_type}</b></td>\n            <td width=50>" . $peer['afi'] . '</td>
     <td><strong>AS' . $peer['bgpPeerRemoteAs'] . '</strong><br />' . $peer['astext'] . "</td>\n            <td><strong><span style='color: {$admin_col};'>" . $peer['bgpPeerAdminStatus'] . "</span><br /><span style='color: {$col};'>" . $peer['bgpPeerState'] . '</span></strong></td>
     <td>' . formatUptime($peer['bgpPeerFsmEstablishedTime']) . "<br />\n            Updates <img src='images/16/arrow_down.png' align=absmiddle /> " . format_si($peer['bgpPeerInUpdates']) . "\n            <img src='images/16/arrow_up.png' align=absmiddle /> " . format_si($peer['bgpPeerOutUpdates']) . '</td></tr>';
 unset($invalid);
 switch ($vars['graph']) {
     case 'prefixes_ipv4unicast':
     case 'prefixes_ipv4multicast':
     case 'prefixes_ipv4vpn':
     case 'prefixes_ipv6unicast':
     case 'prefixes_ipv6multicast':
         list(, $afisafi) = explode('_', $vars['graph']);
         if (isset($peer['afisafi'][$afisafi])) {
             $peer['graph'] = 1;
         }
コード例 #26
0
         break;
     case 'pkts_out':
         $ma_array = array_sort($ma_array, 'bytes_output_rate', 'SORT_DESC');
         break;
 }
 foreach ($ma_array as $acc) {
     $ips = array();
     foreach (dbFetchRows("SELECT `ip_address` FROM `ip_mac` WHERE `mac_address` = ? AND `port_id` = ?", array($acc['mac'], $acc['port_id'])) as $ip) {
         $ips[] = $ip['ip_address'];
     }
     unset($name);
     ///FIXME. Need rewrite, because $addy is array with multiple items.
     #$name = gethostbyaddr($addy['ipv4_address']); FIXME - Maybe some caching for this?
     $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($addy['ip_address']));
     if ($arp_host) {
         $arp_name = generate_device_link($arp_host);
         $arp_name .= " " . generate_port_link($arp_host);
     } else {
         unset($arp_if);
     }
     if ($name == $addy['ip_address']) {
         unset($name);
     }
     if (dbFetchCell("SELECT COUNT(*) FROM bgpPeers WHERE device_id = ? AND bgpPeerIdentifier = ?", array($acc['device_id'], $addy['ip_address']))) {
         $peer_info = dbFetchRow("SELECT * FROM bgpPeers WHERE device_id = ? AND bgpPeerIdentifier = ?", array($acc['device_id'], $addy['ip_address']));
     } else {
         unset($peer_info);
     }
     if ($peer_info) {
         $asn = "AS" . $peer_info['bgpPeerRemoteAs'];
         $astext = $peer_info['astext'];
コード例 #27
0
if ($device['ignore'] == '1') {
    $class = 'bg-warning';
    if ($device['status'] == '1') {
        $class = 'bg-success';
    }
}
if ($device['disabled'] == '1') {
    $class = 'bg-info';
}
$type = strtolower($device['os']);
if ($device['os'] == 'ios') {
    formatCiscoHardware($device, true);
}
$device['os_text'] = $config['os'][$device['os']]['text'];
echo '  <tr>
          <td class="' . $class . ' "></td>
          <td>' . $image . '</td>
          <td><span style="font-size: 15px;">' . generate_device_link($device) . '</span></td>';
echo '<td>';
if ($port_count) {
    echo ' <img src="images/icons/port.png" align=absmiddle /> ' . $port_count;
}
echo '<br />';
if ($sensor_count) {
    echo ' <img src="images/icons/sensors.png" align=absmiddle /> ' . $sensor_count;
}
echo '</td>';
echo '    <td>' . $device['hardware'] . ' ' . $device['features'] . '</td>';
echo '    <td>' . formatUptime($device['uptime'], 'short') . ' <br />';
echo '    ' . truncate($device['location'], 32, '') . '</td>';
echo ' </tr>';
コード例 #28
0
ファイル: bgp.inc.php プロジェクト: greggcz/librenms
 $query = 'SELECT * FROM ipv6_addresses AS A, ports AS I, devices AS D WHERE ';
 $query .= '(A.ipv6_address = ? AND I.port_id = A.port_id)';
 $query .= ' AND D.device_id = I.device_id';
 $ipv6_host = dbFetchRow($query, array($peer['bgpPeerIdentifier']));
 if ($ipv4_host) {
     $peerhost = $ipv4_host;
 } else {
     if ($ipv6_host) {
         $peerhost = $ipv6_host;
     } else {
         unset($peerhost);
     }
 }
 if (is_array($peerhost)) {
     // $peername = generate_device_link($peerhost);
     $peername = generate_device_link($peerhost) . ' ' . generate_port_link($peerhost);
     $peer_url = 'device/device=' . $peer['device_id'] . '/tab=routing/proto=bgp/view=updates/';
 } else {
     // FIXME
     // $peername = gethostbyaddr($peer['bgpPeerIdentifier']); // FFffuuu DNS // Cache this in discovery?
     // if ($peername == $peer['bgpPeerIdentifier'])
     // {
     // unset($peername);
     // } else {
     // $peername = "<i>".$peername."<i>";
     // }
 }
 unset($peer_af);
 unset($sep);
 foreach (dbFetchRows('SELECT * FROM `bgpPeers_cbgp` WHERE `device_id` = ? AND bgpPeerIdentifier = ?', array($device['device_id'], $peer['bgpPeerIdentifier'])) as $afisafi) {
     $afi = $afisafi['afi'];
コード例 #29
0
ファイル: inventory.inc.php プロジェクト: skive/observium
/**
 * Display Devices Inventory.
 *
 * @param array $vars
 * @return none
 *
 */
function print_inventory($vars)
{
    // On "Inventory" device tab display hierarchical list
    if ($vars['page'] == 'device' && is_numeric($vars['device']) && device_permitted($vars['device'])) {
        echo '<table class="table table-striped table-bordered table-condensed table-rounded"><tr><td>';
        echo '<div class="btn-group pull-right" style="margin-top:5px; margin-right: 5px;">
      <button class="btn btn-small" onClick="expandTree(\'enttree\');return false;"><i class="icon-plus muted small"></i> Expand</button>
      <button class="btn btn-small" onClick="collapseTree(\'enttree\');return false;"><i class="icon-minus muted small"></i> Collapse</button>
    </div>';
        echo '<div style="clear: left; margin: 5px;"><ul class="mktree" id="enttree" style="margin-left: -10px;">';
        $level = 0;
        $ent['entPhysicalIndex'] = 0;
        print_ent_physical($ent['entPhysicalIndex'], $level, "liOpen");
        echo '</ul></div>';
        echo '</td></tr></table>';
        return TRUE;
    }
    // With pagination? (display page numbers in header)
    $pagination = isset($vars['pagination']) && $vars['pagination'];
    pagination($vars, 0, TRUE);
    // Get default pagesize/pageno
    $pageno = $vars['pageno'];
    $pagesize = $vars['pagesize'];
    $start = $pagesize * $pageno - $pagesize;
    $param = array();
    $where = ' WHERE 1 ';
    foreach ($vars as $var => $value) {
        if ($value != '') {
            switch ($var) {
                case 'device':
                case 'device_id':
                    $where .= generate_query_values($value, 'E.device_id');
                    break;
                case 'parts':
                    $where .= generate_query_values($value, 'E.entPhysicalModelName', 'LIKE');
                    break;
                case 'serial':
                    $where .= ' AND E.`entPhysicalSerialNum` LIKE ?';
                    $param[] = '%' . $value . '%';
                    break;
                case 'description':
                    $where .= ' AND E.`entPhysicalDescr` LIKE ?';
                    $param[] = '%' . $value . '%';
                    break;
            }
        }
    }
    // Show inventory only for permitted devices
    $query_permitted = generate_query_permitted(array('device'), array('device_table' => 'D'));
    $query = 'FROM `entPhysical` AS E ';
    $query .= 'LEFT JOIN `devices` AS D ON D.`device_id` = E.`device_id` ';
    $query .= $where . $query_permitted;
    $query_count = 'SELECT COUNT(*) ' . $query;
    $query = 'SELECT * ' . $query;
    $query .= ' ORDER BY D.`hostname`';
    $query .= " LIMIT {$start},{$pagesize}";
    // Query inventories
    $entries = dbFetchRows($query, $param);
    // Query inventory count
    if ($pagination) {
        $count = dbFetchCell($query_count, $param);
    }
    $list = array('device' => FALSE);
    if (!isset($vars['device']) || empty($vars['device']) || $vars['page'] == 'inventory') {
        $list['device'] = TRUE;
    }
    $string = '<table class="table table-bordered table-striped table-hover table-condensed">' . PHP_EOL;
    if (!$short) {
        $string .= '  <thead>' . PHP_EOL;
        $string .= '    <tr>' . PHP_EOL;
        if ($list['device']) {
            $string .= '      <th>Device</th>' . PHP_EOL;
        }
        $string .= '      <th>Name</th>' . PHP_EOL;
        $string .= '      <th>Description</th>' . PHP_EOL;
        $string .= '      <th>Part #</th>' . PHP_EOL;
        $string .= '      <th>Serial #</th>' . PHP_EOL;
        $string .= '    </tr>' . PHP_EOL;
        $string .= '  </thead>' . PHP_EOL;
    }
    $string .= '  <tbody>' . PHP_EOL;
    foreach ($entries as $entry) {
        $string .= '  <tr>' . PHP_EOL;
        if ($list['device']) {
            $string .= '    <td class="entity" style="white-space: nowrap">' . generate_device_link($entry, NULL, array('page' => 'device', 'tab' => 'entphysical')) . '</td>' . PHP_EOL;
        }
        if ($entry['ifIndex']) {
            $interface = get_port_by_ifIndex($entry['device_id'], $entry['ifIndex']);
            $entry['entPhysicalName'] = generate_port_link($interface);
        } elseif ($entry['entPhysicalClass'] == "sensor") {
            $sensor = dbFetchRow("SELECT * FROM `sensors` AS S\n                            LEFT JOIN `sensors-state` AS ST ON S.`sensor_id` = ST.`sensor_id`\n                            WHERE `device_id` = ? AND (`entPhysicalIndex` = ? OR `sensor_index` = ?)", array($entry['device_id'], $entry['entPhysicalIndex'], $entry['entPhysicalIndex']));
            //$ent_text .= ' ('.$sensor['sensor_value'] .' '. $sensor['sensor_class'].')';
            $entry['entPhysicalName'] = generate_entity_link('sensor', $sensor);
        }
        $string .= '    <td style="width: 160px;">' . $entry['entPhysicalName'] . '</td>' . PHP_EOL;
        $string .= '    <td>' . $entry['entPhysicalDescr'] . '</td>' . PHP_EOL;
        $string .= '    <td>' . $entry['entPhysicalModelName'] . '</td>' . PHP_EOL;
        $string .= '    <td>' . $entry['entPhysicalSerialNum'] . '</td>' . PHP_EOL;
        $string .= '  </tr>' . PHP_EOL;
    }
    $string .= '  </tbody>' . PHP_EOL;
    $string .= '</table>';
    // Print pagination header
    if ($pagination) {
        $string = pagination($vars, $count) . $string . pagination($vars, $count);
    }
    // Print Inventories
    echo $string;
}
コード例 #30
0
ファイル: logalert.inc.php プロジェクト: Natolumin/observium
/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage web
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
function print_logalert_log($vars)
{
    global $config;
    foreach (dbFetchRows("SELECT * FROM `syslog_rules` ORDER BY `la_name`") as $la) {
        $syslog_rules[$la['la_id']] = $la;
    }
    $entries = get_logalert_log($vars);
    if (!$entries['count']) {
        // There have been no entries returned. Print the warning.
        print_warning('<h4>No logging alert entries found!</h4>');
    } else {
        // Entries have been returned. Print the table.
        $list = array('device' => FALSE);
        if (!isset($vars['device']) || empty($vars['device']) || $vars['page'] == 'alert_log') {
            $list['device'] = TRUE;
        }
        if (!isset($vars['la_id']) || empty($vars['la_id'])) {
            $list['la_id'] = TRUE;
        }
        $string = generate_box_open($vars['header']);
        $string .= '<table class="table table-striped table-hover table-condensed-more">' . PHP_EOL;
        if (!$entries['short']) {
            $cols = array();
            $cols[] = array(NULL, 'class="state-marker"');
            $cols['date'] = array('Date', 'style="width: 140px"');
            if ($list['device']) {
                $cols['device'] = array('Device', 'style="width: 150px;"');
            }
            if ($list['la_id']) {
                $cols['la_id'] = array('Alert Rule', 'style="width: 150px;"');
            }
            $cols[] = array('Program', 'style="width: 80px"');
            $cols[] = 'Message';
            $cols[] = array('Notified', 'style="width: 40px"');
            $string .= get_table_header($cols);
            // , $vars); // Actually sorting is disabled now
        }
        $string .= '  <tbody>' . PHP_EOL;
        foreach ($entries['entries'] as $entry) {
            $string .= '  <tr class="' . $entry['html_row_class'] . '">' . PHP_EOL;
            $string .= '<td class="state-marker"></td>' . PHP_EOL;
            if ($entries['short']) {
                $string .= '    <td class="syslog" style="white-space: nowrap">';
                $timediff = $GLOBALS['config']['time']['now'] - strtotime($entry['timestamp']);
                $string .= generate_tooltip_link('', formatUptime($timediff, "short-3"), format_timestamp($entry['timestamp']), NULL) . '</td>' . PHP_EOL;
            } else {
                $string .= '    <td>';
                $string .= format_timestamp($entry['timestamp']) . '</td>' . PHP_EOL;
            }
            if ($list['device']) {
                $dev = device_by_id_cache($entry['device_id']);
                $device_vars = array('page' => 'device', 'device' => $entry['device_id'], 'tab' => 'logs', 'section' => 'alertlog');
                $string .= '    <td class="entity">' . generate_device_link($dev, short_hostname($dev['hostname']), $device_vars) . '</td>' . PHP_EOL;
            }
            if ($list['la_id']) {
                $string .= '<td><strong><a href="' . generate_url(array('page' => 'syslog_rules', 'la_id' => $entry['la_id'])) . '">' . (is_array($syslog_rules[$entry['la_id']]) ? $syslog_rules[$entry['la_id']]['la_name'] : 'Rule Deleted') . '</td>' . PHP_EOL;
            }
            $string .= '<td>' . (strlen($entry['program']) ? '<span class="label">' . $entry['program'] . '</span> ' : '') . '</td>' . PHP_EOL;
            $string .= '<td>' . escape_html($entry['message']) . '</td>' . PHP_EOL;
            if (!$vars['short']) {
                //$string .= '<td>' . escape_html($entry['log_type']) . '</td>' . PHP_EOL;
                $string .= '<td style="text-align: right">' . ($entry['notified'] == '1' ? '<span class="label label-success">YES</span>' : ($entry['notified'] == '-1' ? '<span class="label label-suppressed">NO</span>' : '<span class="label">NO</span>')) . '</td>' . PHP_EOL;
            }
            $string .= '  </tr>' . PHP_EOL;
        }
        $string .= '  </tbody>' . PHP_EOL;
        $string .= '</table>';
        $string .= generate_box_close();
    }
    // Print pagination header
    if ($entries['pagination_html']) {
        $string = $entries['pagination_html'] . $string . $entries['pagination_html'];
    }
    // Print events
    echo $string;
}