Exemple #1
0
         print_message("Adding host {$hostname} communit" . (count($config['snmp']['community']) == 1 ? 'y' : 'ies') . ' ' . implode(', ', $config['snmp']['community']) . " port {$port} using {$transport}");
     } elseif ($_POST['snmpver'] === 'v3') {
         $v3 = array('authlevel' => mres($_POST['authlevel']), 'authname' => mres($_POST['authname']), 'authpass' => mres($_POST['authpass']), 'authalgo' => mres($_POST['authalgo']), 'cryptopass' => mres($_POST['cryptopass']), 'cryptoalgo' => mres($_POST['cryptoalgo']));
         array_push($config['snmp']['v3'], $v3);
         $snmpver = 'v3';
         print_message("Adding SNMPv3 host {$hostname} port {$port}");
     } else {
         print_error('Unsupported SNMP Version. There was a dropdown menu, how did you reach this error ?');
     }
     //end if
     $poller_group = $_POST['poller_group'];
     $force_add = $_POST['force_add'] == 'on';
     $port_assoc_mode = $_POST['port_assoc_mode'];
     try {
         $device_id = addHost($hostname, $snmpver, $port, $transport, $poller_group, $force_add, $port_assoc_mode);
         $link = generate_device_url(array('device_id' => $device_id));
         print_message("Device added <a href='{$link}'>{$hostname} ({$device_id})</a>");
     } catch (HostUnreachableException $e) {
         print_error($e->getMessage());
         foreach ($e->getReasons() as $reason) {
             print_error($reason);
         }
     } catch (Exception $e) {
         print_error($e->getMessage());
     }
 } else {
     print_error("You don't have the necessary privileges to add hosts.");
 }
 //end if
 echo '    </div>
         <div class="col-sm-3">
function generate_device_link($device, $text = NULL, $vars = array(), $escape = TRUE)
{
    if (is_array($device) && !$device['hostname']) {
        $device = device_by_id_cache($device['device_id']);
    }
    if (!device_permitted($device['device_id'])) {
        $text = $escape ? escape_html($device['hostname']) : $device['hostname'];
        return $text;
    }
    $class = devclass($device);
    if (!$text) {
        $text = $device['hostname'];
    }
    $url = generate_device_url($device, $vars);
    //$link = overlib_link($url, $text, $contents, $class, $escape);
    if ($escape) {
        $text = escape_html($text);
    }
    return '<a href="' . $url . '" class="entity-popup ' . $class . '" data-eid="' . $device['device_id'] . '" data-etype="device">' . $text . '</a>';
}
 * 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.
 */
echo '<td>';
if (device_permitted($device['device_id'])) {
    echo '<div class="row">
                   <div class="col-xs-1">';
    echo '<a href="' . generate_device_url($device) . '"> <img src="images/16/server.png" border="0" align="absmiddle" alt="View device" title="View device" /></a> ';
    echo '</div>
               <div class="col-xs-1">';
    echo '<a href="' . generate_device_url($device, array('tab' => 'alerts')) . '"> <img src="images/16/bell.png" border="0" align="absmiddle" alt="View alerts" title="View alerts"  /></a> ';
    echo '</div>';
    if ($_SESSION['userlevel'] >= "7") {
        echo '<div class="col-xs-1">
                       <a href="' . generate_device_url($device, array('tab' => 'edit')) . '"> <img src="images/16/wrench.png" border="0" align="absmiddle" alt="Edit device" title="Edit device" /></a>
                   </div>';
    }
    echo '</div>
               <div class="row">
                   <div class="col-xs-1">
                       <a href="telnet://' . $device['hostname'] . '"><img src="images/16/telnet.png" alt="telnet" title="Telnet to ' . $device['hostname'] . '" border="0" width="16" height="16"></a>
                   </div>
                   <div class="col-xs-1">
                       <a href="ssh://' . $device['hostname'] . '"><img src="images/16/ssh.png" alt="ssh" title="SSH to ' . $device['hostname'] . '" border="0" width="16" height="16"></a>
                   </div>
                   <div class="col-xs-1">
                       <a href="https://' . $device['hostname'] . '"><img src="images/16/http.png" alt="https" title="Launch browser https://' . $device['hostname'] . '" border="0" width="16" height="16" target="_blank"></a>
                   </div>
               </div>';
}
Exemple #4
0
<?php

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage search
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
/// SEARCH DEVICES
$results = dbFetchRows("SELECT * FROM `devices`\n                        WHERE (`hostname` LIKE ? OR `location` LIKE ?) {$query_permitted_device}\n                        ORDER BY `hostname` LIMIT {$query_limit}", array($query_param, $query_param));
if (count($results)) {
    foreach ($results as $result) {
        humanize_device($result);
        $name = $result['hostname'];
        if (strlen($name) > 35) {
            $name = substr($name, 0, 35) . "...";
        }
        $num_ports = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE device_id = ?", array($result['device_id']));
        $device_search_results[] = array('url' => generate_device_url($result), 'name' => $name, 'colour' => $result['html_tab_colour'], 'icon' => get_device_icon($result), 'data' => array(escape_html($result['hardware'] . ' | ' . $config['os'][$result['os']]['text'] . ' ' . $result['version']), highlight_search(escape_html($result['location'])) . ' | ' . $num_ports . ' ports'));
    }
    $search_results['devices'] = array('descr' => 'Devices found', 'results' => $device_search_results);
}
// EOF
Exemple #5
0
 $type = strtolower($device['os']);
 $image = getImage($device);
 if ($device['os'] == 'ios') {
     formatCiscoHardware($device, true);
 }
 $device['os_text'] = $config['os'][$device['os']]['text'];
 $port_count = dbFetchCell('SELECT COUNT(*) FROM `ports` WHERE `device_id` = ?', array($device['device_id']));
 $sensor_count = dbFetchCell('SELECT COUNT(*) FROM `sensors` WHERE `device_id` = ?', array($device['device_id']));
 $actions = '
     <div class="container-fluid">
         <div class="row">
             <div class="col-xs-1"><a href="' . generate_device_url($device) . '"> <img src="images/16/server.png" border="0" align="absmiddle" alt="View device" title="View device"></a></div>
             <div class="col-xs-1"><a href="' . generate_device_url($device, array('tab' => 'alerts')) . '"> <img src="images/16/bell.png" border="0" align="absmiddle" alt="View alerts" title="View alerts"></a></div>
 ';
 if ($_SESSION['userlevel'] >= '7') {
     $actions .= '<div class="col-xs-1"><a href="' . generate_device_url($device, array('tab' => 'edit')) . '"> <img src="images/16/wrench.png" border="0" align="absmiddle" alt="Edit device" title="Edit device"></a></div>';
 }
 if ($subformat == 'detail') {
     $actions .= '</div><div class="row">';
 }
 $actions .= '
             <div class="col-xs-1"><a href="telnet://' . $device['hostname'] . '"><img src="images/16/telnet.png" alt="telnet" title="Telnet to ' . $device['hostname'] . '" border="0" width="16" height="16"></a></div>
             <div class="col-xs-1"><a href="ssh://' . $device['hostname'] . '"><img src="images/16/ssh.png" alt="ssh" title="SSH to ' . $device['hostname'] . '" border="0" width="16" height="16"></a></div>
             <div class="col-xs-1"><a href="https://' . $device['hostname'] . '"><img src="images/16/http.png" alt="https" title="Launch browser https://' . $device['hostname'] . '" border="0" width="16" height="16" target="_blank"></a></div>
         </div>
     </div>
 ';
 $hostname = generate_device_link($device);
 if (extension_loaded('mbstring')) {
     $location = mb_substr($device['location'], 0, 32, 'utf8');
 } else {
Exemple #6
0
include $config['html_dir'] . "/includes/cache-data.inc.php";
// Is there a POST/GET query string?
if (isset($_REQUEST['queryString'])) {
    $queryString = mres($_REQUEST['queryString']);
    // Is the string length greater than 0?
    if (strlen($queryString) > 0) {
        $found = 0;
        /// SEARCH DEVICES
        $query_permitted_device = generate_query_permitted(array('device'), array('device_table' => 'devices'));
        $results = dbFetchRows("SELECT * FROM `devices`\n                            WHERE (`hostname` LIKE '%{$queryString}%' OR `location` LIKE '%{$queryString}%') {$query_permitted_device}\n                            ORDER BY `hostname` LIMIT 8");
        if (count($results)) {
            $found = 1;
            echo '<li class="nav-header">Devices found: ' . count($results) . '</li>' . PHP_EOL;
            foreach ($results as $result) {
                echo '<li class="divider" style="margin: 0px;"></li>' . PHP_EOL;
                echo '<li style="margin: 0px;">' . PHP_EOL . '  <a href="' . generate_device_url($result) . '">' . PHP_EOL;
                humanize_device($result);
                $name = $result['hostname'];
                if (strlen($name) > 35) {
                    $name = substr($name, 0, 35) . "...";
                }
                $num_ports = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE device_id = ?", array($result['device_id']));
                echo '    <dl style="border-left: 10px solid ' . $result['html_tab_colour'] . '; " class="dl-horizontal dl-search">
      <dt style="padding-left: 10px; text-align: center;">' . getImage($result) . '</dt>
        <dd>
          <strong>' . highlight_search(htmlentities($name)) . '
            <small>' . htmlentities($result['hardware']) . ' | ' . htmlentities($config['os'][$result['os']]['text']) . ' ' . htmlentities($result['version']) . '
            <br /> ' . highlight_search(htmlentities($result['location'], 0, 'UTF-8')) . ' | ' . $num_ports . ' ports</small>
          </strong>
        </dd>
    </dl>
Exemple #7
0
    $map_init = "[" . $config['leaflet']['default_lat'] . ", " . $config['leaflet']['default_lng'] . "], " . sprintf("%01.0f", $config['leaflet']['default_zoom']);
    $temp_output .= 'var map = L.map(\'leaflet-map\').setView(' . $map_init . ');

L.tileLayer(\'//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png\', {
    attribution: \'&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors\'
}).addTo(map);

var markers = L.markerClusterGroup();
var redMarker = L.AwesomeMarkers.icon({
    icon: \'server\',
    markerColor: \'red\', prefix: \'fa\', iconColor: \'white\'
  });
var greenMarker = L.AwesomeMarkers.icon({
    icon: \'server\',
    markerColor: \'green\', prefix: \'fa\', iconColor: \'white\'
  });
';
    foreach (dbFetchRows("SELECT `device_id`,`hostname`,`os`,`status`,`lat`,`lng` FROM `devices` LEFT JOIN `locations` ON `devices`.`location`=`locations`.`location` WHERE `disabled`=0 AND `ignore`=0 AND `lat` != '' AND `lng` != '' ORDER BY `status` ASC, `hostname`") as $map_devices) {
        $icon = 'greenMarker';
        if ($map_devices['status'] == 0) {
            $icon = 'redMarker';
        }
        $temp_output .= "var title = '<a href=\"" . generate_device_url($map_devices) . "\"><img src=\"" . getImageSrc($map_devices) . "\" width=\"32\" height=\"32\" alt=\"\">" . $map_devices['hostname'] . "</a>';\n         var marker = L.marker(new L.LatLng(" . $map_devices['lat'] . ", " . $map_devices['lng'] . "), {title: title, icon: {$icon}});\n         marker.bindPopup(title);\n         markers.addLayer(marker);\n";
    }
    $temp_output .= 'map.addLayer(markers);
</script>';
} else {
    $temp_output = 'Mapael engine not supported here';
}
unset($common_output);
$common_output[] = $temp_output;
Exemple #8
0
if (isset($searchPhrase) && !empty($searchPhrase)) {
    $sql .= " AND (hostname LIKE '%{$searchPhrase}%' OR last_polled LIKE '%{$searchPhrase}%' OR last_polled_timetaken LIKE '%{$searchPhrase}%')";
}
if ($_POST['type'] == "unpolled") {
    $sql .= " AND `last_polled` <= DATE_ADD(NOW(), INTERVAL - 15 minute)";
}
if (!isset($sort) || empty($sort)) {
    $sort = 'last_polled_timetaken DESC';
}
$sql .= " AND D.status ='1' AND D.ignore='0' AND D.disabled='0' ORDER BY {$sort}";
$count_sql = "SELECT COUNT(`D`.`device_id`) {$sql}";
$total = dbFetchCell($count_sql);
if (empty($total)) {
    $total = 0;
}
if (isset($current)) {
    $limit_low = $current * $rowCount - $rowCount;
    $limit_high = $rowCount;
}
if ($rowCount != -1) {
    $sql .= " LIMIT {$limit_low},{$limit_high}";
}
$sql = "SELECT D.device_id,D.hostname AS `hostname`, D.last_polled AS `last_polled`, `group_name`, D.last_polled_timetaken AS `last_polled_timetaken` {$sql}";
foreach (dbFetchRows($sql, array(), true) as $device) {
    if (empty($device['group_name'])) {
        $device['group_name'] = 'General';
    }
    $response[] = array('hostname' => "<a class='list-device' href='" . generate_device_url($device, array('tab' => 'graphs', 'group' => 'poller')) . "'>" . $device['hostname'] . '</a>', 'last_polled' => $device['last_polled'], 'poller_group' => $device['group_name'], 'last_polled_timetaken' => $device['last_polled_timetaken']);
}
$output = array('current' => $current, 'rowCount' => $rowCount, 'rows' => $response, 'total' => $total);
echo _json_encode($output);
Exemple #9
0
     }
     echo '<div class="dropdown pull-right">
           <button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown"><i class="fa fa-cog"></i>
           <span class="caret"></span></button>
           <ul class="dropdown-menu">
             <li><a href="https://' . $device['hostname'] . '" target="_blank"><img src="images/16/http.png" alt="https" title="Launch browser to https://' . $device['hostname'] . '" border="0" width="16" height="16" target="_blank"> Web</a></li>
             <li><a href="ssh://' . $device['hostname'] . '" target="_blank"><img src="images/16/ssh.png" alt="ssh" title="SSH to ' . $device['hostname'] . '" border="0" width="16" height="16"> SSH</a></li>
              <li><a href="telnet://' . $device['hostname'] . '" target="_blank"><img src="images/16/telnet.png" alt="telnet" title="Telnet to ' . $device['hostname'] . '" border="0" width="16" height="16"> Telnet</a></li>';
     if (is_admin()) {
         echo '<li>
             <a href="' . generate_device_url($device, array('tab' => 'edit')) . '">
             <img src="images/16/wrench.png" align="absmiddle" border="0" />
              Edit
             </a>
             </li>';
         echo '<li><a href="' . generate_device_url($device, array('tab' => 'capture')) . '">
             <img src="images/16/brick_error.png" align="absmiddle" border="0" /> Capture
             </a></li>';
     }
     echo '</ul>
         </div>';
     echo '</ul>';
 }
 //end if
 if (device_permitted($device['device_id']) || $check_device == $vars['device']) {
     echo '<div class="tabcontent">';
     require 'pages/device/' . mres(basename($tab)) . '.inc.php';
     echo '</div>';
 } else {
     require 'includes/error-no-perm.inc.php';
 }
if (isset($_POST['queryString']) || isset($_GET['queryString'])) {
    if (isset($_POST['queryString'])) {
        $queryString = mres($_POST['queryString']);
    } elseif (isset($_GET['queryString'])) {
        $queryString = mres($_GET['queryString']);
    }
    // Is the string length greater than 0?
    if (strlen($queryString) > 0) {
        /// SEARCH DEVICES
        $results = dbFetchRows("SELECT * FROM `devices` WHERE `hostname` LIKE '%" . $queryString . "%' OR `location` LIKE '%" . $queryString . "%' ORDER BY hostname LIMIT 8");
        if (count($results)) {
            echo '<li class="nav-header">Devices found: ' . count($results) . '</li>';
            foreach ($results as $result) {
                echo '<li class="divider" style="margin: 0px;"></li>';
                echo "<li>";
                echo '<a href="' . generate_device_url($result) . '">';
                humanize_device($result);
                $name = $result['hostname'];
                if (strlen($name) > 35) {
                    $name = substr($name, 0, 35) . "...";
                }
                // $description = $result->desc;
                // if (strlen($description) > 80) { $description = substr($description, 0, 80) . "..."; }
                $num_ports = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE device_id = ?", array($result['device_id']));
                echo '<dl style="border-left: 10px solid ' . $result['html_tab_colour'] . '; " class="dl-horizontal dl-search">
                <dt style="padding-left: 10px; text-align: center;">' . $result['icon'] . '</dt>
                  <dd><h5>' . highlight_search($name) . '</h5>
                    <small>' . $result['hardware'] . ' | ' . $config['os'][$result['os']]['text'] . ' ' . $result['version'] . '
                    <br /> ' . highlight_search($result['location']) . ' | ' . $num_ports . 'ports</small></dd>
                </dl>';
            }
     $xml->addChild('icon', $base_url . '/' . $GLOBALS['config']['favicon']);
     $xml->addChild('link');
     $xml->link->addAttribute('href', $feed_link);
     $self_link = $xml->addChild('link', '', $atom_ns);
     $self_link->addAttribute('href', $base_url . $_SERVER['REQUEST_URI']);
     $self_link->addAttribute('rel', 'self');
     $self_link->addAttribute('type', 'application/atom+xml');
     $xml->addChild('generator', $feed_generator);
     $xml->addChild('updated', date(DATE_ATOM, strtotime($events['updated'])));
 }
 foreach ($events['entries'] as $entry) {
     $entry_device = device_by_id_cache($entry['device_id']);
     $entry_vars = array('page' => 'device', 'device' => $entry['device_id'], 'tab' => 'logs', 'section' => 'eventlog', 'type' => $entry['type'], 'timestamp_from' => $entry['timestamp'], 'timestamp_to' => $entry['timestamp']);
     $entry_title = htmlentities('[' . $entry_device['hostname'] . '] ' . $entry['message']);
     $entry_description = htmlentities('[' . $entry_device['hostname'] . "]\n" . strtoupper($entry['type']) . ': ' . $entry['message']);
     $entry_link = $base_url . '/' . generate_device_url($entry_device, $entry_vars);
     $entry_id = $entry_link . 'guid=' . md5($entry['event_id']);
     if ($use_rss) {
         // add item element for each article
         $item = $xml->channel->addChild('item');
         $item->addChild('title', $entry_title);
         $item->addChild('description', $entry_description);
         $item->addChild('guid', $entry_id);
         $item->addChild('link', $entry_link);
         $item->addChild('h:dc:creator', $entry['type']);
         $item->addChild('pubDate', date(DATE_RSS, strtotime($entry['timestamp'])));
     } else {
         // add entry element for each article
         $item = $xml->addChild('entry');
         $item->addChild('title', $entry_title);
         $item->addChild('summary', $entry_description);
Exemple #12
0
<?php 
        $navbar['class'] = 'navbar-narrow subnav';
        foreach ($navbar['options'] as $option => $array) {
            if (!isset($vars['tab'])) {
                $vars['tab'] = $option;
            }
            if ($vars['tab'] == $option) {
                $navbar['options'][$option]['class'] .= " active";
            }
            if (!isset($navbar['options'][$option]['url'])) {
                $navbar['options'][$option]['url'] = generate_device_url($device, array('tab' => $option));
            }
            if (isset($navbar['options'][$option]['suboptions'])) {
                foreach ($navbar['options'][$option]['suboptions'] as $sub_option => $sub_array) {
                    if (!isset($navbar['options'][$option]['suboptions'][$sub_option]['url'])) {
                        $navbar['options'][$option]['suboptions'][$sub_option]['url'] = generate_device_url($device, array('tab' => $sub_option));
                    }
                }
            }
        }
        if ($vars['tab'] == 'port') {
            $navbar['options']['ports']['class'] .= " active";
        }
        if ($vars['tab'] == 'alert') {
            $navbar['options']['alerts']['class'] .= " active";
        }
        if ($vars['tab'] == 'accesspoint') {
            $navbar['options']['accesspoints']['class'] .= " active";
        }
        print_navbar($navbar);
        unset($navbar);
function generate_device_link($device, $text = NULL, $vars = array(), $start = 0, $end = 0)
{
    $class = devclass($device);
    if (!$text) {
        $text = $device['hostname'];
    }
    #  $contents = generate_device_link_contents($device, $vars, $start, $end);
    $text = htmlentities($text);
    $url = generate_device_url($device, $vars);
    $link = overlib_link($url, $text, $contents, $class);
    if (!device_permitted($device['device_id'])) {
        return $device['hostname'];
    }
    return '<a href="' . $url . '" class="entity-popup ' . $class . '" data-eid="' . $device['device_id'] . '" data-etype="device">' . $text . '</a>';
}
    echo "</th>";
}
echo "      </tr></thead>";
$ports_disabled = 0;
$ports_down = 0;
$ports_up = 0;
$ports_total = 0;
foreach ($ports as $port) {
    $device = device_by_id_cache($port['device_id']);
    #&$GLOBALS['cache']['devices']['id'][$port['device_id']];
    $ports_total++;
    humanize_port($port);
    $error_img = '';
    if ($port['in_errors'] > 0 || $port['out_errors'] > 0) {
        $error_img = generate_port_link($port, "<img src='images/16/chart_curve_error.png' alt='接口错误' border=0>", 'errors');
    }
    if (in_array($port['port_id'], $cache['ports']['cbqos'])) {
        $error_img .= '<a href="' . generate_port_url($port, array('view' => 'cbqos')) . '"><span class="label label-info">CBQoS</span></a>';
    }
    if (in_array($port['port_id'], $cache['ports']['pseudowires'])) {
        $error_img .= '<a href="' . generate_device_url($port, array('tab' => 'pseudowires')) . '"><span class="label label-info">伪流量</span></a>';
    }
    $port['bps_in'] = formatRates($port['ifInOctets_rate'] * 8);
    $port['bps_out'] = formatRates($port['ifOutOctets_rate'] * 8);
    $port['pps_in'] = format_si($port['ifInUcastPkts_rate']) . "pps";
    $port['pps_out'] = format_si($port['ifOutUcastPkts_rate']) . "pps";
    echo "<tr class='ports " . $port['row_class'] . "'>\n          <td class='state-marker'></td>\n          <td></td>\n          <td><span class=entity>" . generate_device_link($device, short_hostname($device['hostname'], "20")) . "</span><br />\n              <span class=em>" . escape_html(truncate($port['location'], 32, "")) . "</span></td>\n\n          <td><span class=entity>" . generate_port_link($port, rewrite_ifname($port['label'])) . " " . $error_img . "</span><br />\n              <span class=em>" . escape_html(truncate($port['ifAlias'], 50, '')) . "</span></td>" . '<td> <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> <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><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>" . $port['human_speed'] . "<br />" . $port['ifMtu'] . "</td>\n          <td >" . $port['human_type'] . "<br />" . $port['human_mac'] . "</td>\n        </tr>\n";
}
echo '</table>';
echo pagination($vars, $ports_count);
// EOF
Exemple #15
0
                 } else {
                     if ($result['status'] == 0 && $result['ignore'] == 0 && $result['disabled'] == 0) {
                         $highlight_colour = '#ff0000';
                     } else {
                         if ($result['status'] == 1 && $result['ignore'] == 0 && $result['disabled'] == 0) {
                             $highlight_colour = '#008000';
                         }
                     }
                 }
             }
             if (is_admin() === true || is_read() === true) {
                 $num_ports = dbFetchCell('SELECT COUNT(*) FROM `ports` WHERE device_id = ?', array($result['device_id']));
             } else {
                 $num_ports = dbFetchCell('SELECT COUNT(*) FROM `ports` AS `I`, `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` AND `I`.`device_id` = `D`.`device_id` AND device_id = ?', array($_SESSION['user_id'], $result['device_id']));
             }
             $device[] = array('name' => $name, 'device_id' => $result['device_id'], 'url' => generate_device_url($result), 'colours' => $highlight_colour, 'device_ports' => $num_ports, 'device_image' => getImageSrc($result), 'device_hardware' => $result['hardware'], 'device_os' => $config['os'][$result['os']]['text'], 'version' => $result['version'], 'location' => $result['location']);
         }
         //end foreach
     }
     //end if
     $json = json_encode($device);
     die($json);
 } else {
     if ($_REQUEST['type'] == 'ports') {
         // Search ports
         if (is_admin() === true || is_read() === true) {
             $results = dbFetchRows("SELECT `ports`.*,`devices`.* FROM `ports` LEFT JOIN `devices` ON  `ports`.`device_id` =  `devices`.`device_id` WHERE `ifAlias` LIKE '%" . $search . "%' OR `ifDescr` LIKE '%" . $search . "%' OR `ifName` LIKE '%" . $search . "%' ORDER BY ifDescr LIMIT " . $limit);
         } else {
             $results = dbFetchRows("SELECT DISTINCT(`I`.`port_id`), `I`.*, `D`.`hostname` FROM `ports` AS `I`, `devices` AS `D`, `devices_perms` AS `P`, `ports_perms` AS `PP` 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 `D`.`device_id` = `I`.`device_id` AND (`ifAlias` LIKE '%" . $search . "%' OR `ifDescr` LIKE '%" . $search . "%' OR `ifName` LIKE '%" . $search . "%') ORDER BY ifDescr LIMIT " . $limit, array($_SESSION['user_id'], $_SESSION['user_id']));
         }
         if (count($results)) {
Exemple #16
0
}
echo "</td><td width=75 onclick=\"location.href='" . generate_port_url($port) . "'\" >";
if ($port['ifSpeed']) {
    echo '<span class=box-desc>' . humanspeed($port['ifSpeed']) . '</span>';
}
echo '<br />';
if ($port[ifDuplex] != 'unknown') {
    echo '<span class=box-desc>' . $port['ifDuplex'] . '</span>';
} else {
    echo '-';
}
$vlans = dbFetchColumn('SELECT vlan FROM `ports_vlans` AS PV, vlans AS V ' . 'WHERE PV.`port_id`=? AND PV.`device_id`=? AND V.`vlan_vlan`=PV.vlan AND V.device_id = PV.device_id', array($port['port_id'], $device['device_id']));
$vlan_count = count($vlans);
if ($vlan_count > 1) {
    echo '<p class=box-desc><span class=purple><a href="';
    echo generate_device_url($device, array('tab' => 'vlans'));
    echo '" title="';
    echo implode(', ', $vlans);
    echo '">VLANs: ';
    echo $vlan_count;
    echo '</a></span></p>';
} elseif ($vlan_count == 1 || $port['ifVlan']) {
    echo '<p class=box-desc><span class=blue>VLAN: ';
    echo $vlans[0] ?: $port['ifVlan'];
    echo '</span></p>';
} elseif ($port['ifVrf']) {
    $vrf = dbFetchRow('SELECT * FROM vrfs WHERE vrf_id = ?', array($port['ifVrf']));
    echo "<p style='color: green;'>" . $vrf['vrf_name'] . '</p>';
}
//end if
if ($port_adsl['adslLineCoding']) {
Exemple #17
0
         echo '<li class="' . $select['mib'] . '">
             <a href="' . generate_device_url($device, array('tab' => 'mib')) . '">
             <i class="fa fa-file-text-o"></i> MIB
             </a>
             </li>';
     }
     echo '<div class="dropdown pull-right">
           <button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown"><i class="fa fa-cog"></i>
           <span class="caret"></span></button>
           <ul class="dropdown-menu">
             <li><a href="https://' . $device['hostname'] . '"><img src="images/16/http.png" alt="https" title="Launch browser to https://' . $device['hostname'] . '" border="0" width="16" height="16" target="_blank"> Launch</a></li>
             <li><a href="ssh://' . $device['hostname'] . '"><img src="images/16/ssh.png" alt="ssh" title="SSH to ' . $device['hostname'] . '" border="0" width="16" height="16"> SSH</a></li>
              <li><a href="telnet://' . $device['hostname'] . '"><img src="images/16/telnet.png" alt="telnet" title="Telnet to ' . $device['hostname'] . '" border="0" width="16" height="16"> Telnet</a></li>';
     if (is_admin()) {
         echo '<li>
             <a href="' . generate_device_url($device, array('tab' => 'edit')) . '">
             <img src="images/16/wrench.png" align="absmiddle" border="0" />
              Edit
             </a>
             </li>';
     }
     echo '</ul>
         </div>';
     echo '</ul>';
 }
 //end if
 if (device_permitted($device['device_id']) || $check_device == $vars['device']) {
     echo '<div class="tabcontent">';
     require 'pages/device/' . mres(basename($tab)) . '.inc.php';
     echo '</div>';
 } else {
                     <span class="device-icon">' . $deviceIcon . '</span><br>
                     <span class="small">' . shorthost(ip_to_sysname($device, $device['hostname'])) . '</span>
                 </div>
                 </a>';
             } else {
                 if ($widget_settings['color_only_select'] == 1) {
                     $deviceState = ' ';
                     $deviceLabel .= ' widget-availability-fixed';
                 }
                 $temp_output[] = '
                 <a href="' . generate_device_url($device) . '" title="' . $device['hostname'] . " - " . formatUptime($device['uptime']) . '">
                     <span class="label ' . $deviceLabel . ' widget-availability label-font-border">' . $deviceState . '</span>
                 </a>';
             }
         } else {
             $temp_output[] = "<a href='" . generate_device_url($device) . "' title='" . $device['hostname'] . ' - ' . formatUptime($device['uptime']) . "'><div class='" . $deviceLabelOld . "' style='width:{$compact_tile}px;height:{$compact_tile}px;'></div></a>";
         }
     }
 }
 if (($mode == 1 || $mode == 2) && $config['show_services'] != 0) {
     $service_query = 'select `S`.`service_type`, `S`.`service_id`, `S`.`service_desc`, `S`.`service_status`, `D`.`hostname`, `D`.`sysName`, `D`.`device_id`, `D`.`os`, `D`.`icon` from services S, devices D where `S`.`device_id` = `D`.`device_id` ORDER BY ' . $serviceOrderBy . ';';
     $services = dbFetchRows($service_query);
     if (count($services) > 0) {
         foreach ($services as $service) {
             if ($service['service_status'] == '0') {
                 $serviceLabel = "label-success";
                 $serviceLabelOld = 'availability-map-oldview-box-up';
                 $serviceState = "up";
                 $service_up_count++;
             } elseif ($service['service_status'] == '1') {
                 $serviceLabel = "label-warning";
Exemple #19
0
        $sql .= " ORDER BY `{$sort_column}` {$sort_order}";
    }
}
if (isset($current)) {
    $limit_low = $current * $rowCount - $rowCount;
    $limit_high = $rowCount;
}
if ($rowCount != -1) {
    $sql .= " LIMIT {$limit_low},{$limit_high}";
}
$query = 'SELECT DISTINCT(`ports`.`port_id`),`ports`.*';
// calculate ifLastChange as seconds ago
$query .= ',`D`.`uptime` - `ports`.`ifLastChange` / 100 as secondsIfLastChange ';
$query .= $sql;
foreach (dbFetchRows($query, $param) as $port) {
    $device = device_by_id_cache($port['device_id']);
    // FIXME what actions should we have?
    $actions = '<div class="container-fluid"><div class="row">';
    $actions .= '<div class="col-xs-1"><a href="';
    $actions .= generate_device_url($device, array('tab' => 'alerts'));
    $actions .= '"><img src="images/16/bell.png" border="0" align="absmiddle" alt="View alerts" title="View alerts" /></a></div>';
    if ($_SESSION['userlevel'] >= '7') {
        $actions .= '<div class="col-xs-1"><a href="';
        $actions .= generate_device_url($device, array('tab' => 'edit', 'section' => 'ports'));
        $actions .= '"><img src="images/16/wrench.png" border="0" align="absmiddle" alt="Edit ports" title="Edit ports" /></a></div>';
    }
    $actions .= '</div></div>';
    $response[] = array('device' => generate_device_link($device), 'port' => generate_port_link($port), 'ifLastChange' => ceil($port['secondsIfLastChange']), 'ifConnectorPresent' => $port['ifConnectorPresent'] == 'true' ? 'yes' : 'no', 'ifSpeed' => $port['ifSpeed'], 'ifMtu' => $port['ifMtu'], 'ifInOctets_rate' => $port['ifInOctets_rate'] * 8, 'ifOutOctets_rate' => $port['ifOutOctets_rate'] * 8, 'ifInUcastPkts_rate' => $port['ifInUcastPkts_rate'], 'ifOutUcastPkts_rate' => $port['ifOutUcastPkts_rate'], 'ifInErrors' => $port['ifInErrors'], 'ifOutErrors' => $port['ifOutErrors'], 'ifType' => humanmedia($port['ifType']), 'description' => display($port['ifAlias']), 'actions' => $actions);
}
$output = array('current' => $current, 'rowCount' => $rowCount, 'rows' => $response, 'total' => $total);
echo _json_encode($output);
function generate_device_link($device, $text = NULL, $vars = array(), $start = 0, $end = 0)
{
    global $config;
    $class = devclass($device);
    if (!$text) {
        $text = $device['hostname'];
    }
    $contents = generate_device_link_contents($device, $vars, $start, $end);
    $text = htmlentities($text);
    $url = generate_device_url($device, $vars);
    $link = overlib_link($url, $text, $contents, $class);
    if (!device_permitted($device['device_id'])) {
        return $device['hostname'];
    }
    return $link;
}
Exemple #21
0
function generate_device_link($device, $text = null, $vars = array(), $start = 0, $end = 0, $escape_text = 1, $overlib = 1)
{
    global $config;
    if (!$start) {
        $start = $config['time']['day'];
    }
    if (!$end) {
        $end = $config['time']['now'];
    }
    $class = devclass($device);
    if (!$text) {
        $text = $device['hostname'];
    }
    if (isset($config['os'][$device['os']]['over'])) {
        $graphs = $config['os'][$device['os']]['over'];
    } else {
        if (isset($device['os_group']) && isset($config['os'][$device['os_group']]['over'])) {
            $graphs = $config['os'][$device['os_group']]['over'];
        } else {
            $graphs = $config['os']['default']['over'];
        }
    }
    $url = generate_device_url($device, $vars);
    // beginning of overlib box contains large hostname followed by hardware & OS details
    $contents = '<div><span class="list-large">' . $device['hostname'] . '</span>';
    if ($device['hardware']) {
        $contents .= ' - ' . $device['hardware'];
    }
    if ($device['os']) {
        $contents .= ' - ' . mres($config['os'][$device['os']]['text']);
    }
    if ($device['version']) {
        $contents .= ' ' . mres($device['version']);
    }
    if ($device['features']) {
        $contents .= ' (' . mres($device['features']) . ')';
    }
    if (isset($device['location'])) {
        $contents .= ' - ' . htmlentities($device['location']);
    }
    $contents .= '</div>';
    foreach ($graphs as $entry) {
        $graph = $entry['graph'];
        $graphhead = $entry['text'];
        $contents .= '<div class="overlib-box">';
        $contents .= '<span class="overlib-title">' . $graphhead . '</span><br />';
        $contents .= generate_minigraph_image($device, $start, $end, $graph);
        $contents .= generate_minigraph_image($device, $config['time']['week'], $end, $graph);
        $contents .= '</div>';
    }
    if ($escape_text) {
        $text = htmlentities($text);
    }
    if ($overlib == 0) {
        $link = $contents;
    } else {
        $link = overlib_link($url, $text, escape_quotes($contents), $class);
    }
    if (device_permitted($device['device_id'])) {
        return $link;
    } else {
        return $device['hostname'];
    }
}
Exemple #22
0
            $graph_array['height'] = 100;
            $graph_array['width'] = 212;
            if (is_numeric($vars['to'])) {
                $graph_array['to'] = $vars['to'];
            } else {
                $graph_array['to'] = $config['time']['now'];
            }
            if (is_numeric($vars['from'])) {
                $graph_array['from'] = $vars['from'];
            } else {
                $graph_array['from'] = $config['time']['day'];
            }
            $graph_array['device'] = $device['device_id'];
            $graph_array['type'] = $graph_type;
            $graph_array['legend'] = "no";
            $link_array = $graph_array;
            $link_array['page'] = "graphs";
            unset($link_array['height'], $link_array['width'], $link_array['legend']);
            $link = generate_url($link_array);
            $overlib_content = generate_overlib_content($graph_array, $device['hostname']);
            //$graph_array['title']  = "yes";
            $graph_array['width'] = $width;
            $graph_array['height'] = $height;
            $graph = generate_graph_tag($graph_array);
            echo generate_box_open(array('title' => $device['hostname'], 'url' => generate_device_url($device), 'header-border' => TRUE, 'box-style' => 'float: left; margin-right: 10px; margin-bottom: 10px;  width:' . $width_div . 'px; min-width: ' . $width_div . 'px; max-width:' . $width_div . 'px; min-height:' . $height_div . 'px; max-height:' . $height_div . ';'));
            echo overlib_link($link, $graph, $overlib_content);
            echo generate_box_close();
        }
    }
}
// EOF