Example #1
0
<?php

if (device_permitted($entry['device_id'])) {
    echo '<tr>';
    // Stop shortening hostname. Issue #61
    // $entry['hostname'] = shorthost($entry['hostname'], 20);
    if ($vars['page'] != 'device') {
        echo '<td>' . $entry['date'] . '</td>';
        echo '<td><strong>' . generate_device_link($entry) . '</strong></td>';
        echo '<td><strong>' . $entry['program'] . ' : </strong> ' . htmlspecialchars($entry['msg']) . '</td>';
    } else {
        echo '<td><i>' . $entry['date'] . '</i>&nbsp;&nbsp;&nbsp;<strong>' . $entry['program'] . '</strong>&nbsp;&nbsp;&nbsp;' . htmlspecialchars($entry['msg']) . '</td>';
    }
    echo '</tr>';
}
Example #2
0
print_optionbar_start();
?>


<div id="{{ctx.id}}" class="{{css.header}}">
    <div class="row">
        <div class="col-sm-9 actionBar">
            <div class="pull-left">
                <form method="post" action="" class="form-inline" role="form" id="result_form">
                    <div class="form-group">
                        <select name="device" id="device" class="form-control input-sm">
                            <option value="">All Devices</option>
                                <?php 
foreach (get_all_devices() as $hostname) {
    $device_id = getidbyname($hostname);
    if (device_permitted($device_id)) {
        echo '"<option value="' . $device_id . '"';
        if ($device_id == $vars['device']) {
            echo ' selected';
        }
        echo '>' . $hostname . '</option>';
    }
}
?>
                        </select>
                    </div>
                    <div class="form-group">
                        <select name="program" id="program" class="form-control input-sm">
                            <option value="">All Programs</option>
                                <?php 
foreach (dbFetchRows('SELECT DISTINCT `program` FROM `syslog` ORDER BY `program`') as $data) {
Example #3
0
<?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
<?php

$graph_type = "processor_usage";
echo "<div style='margin-top: 5px; padding: 0px;'>";
echo "  <table class='table table-condensed'>";
echo "<tr>\n        <th>Device</th>\n        <th>Processor</th>\n        <th></th>\n        <th>Usage</th>\n      </tr>";
foreach (dbFetchRows("SELECT * FROM `processors` AS P, `devices` AS D WHERE D.device_id = P.device_id ORDER BY D.hostname") as $proc) {
    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";
<?php

$i = 0;
$query = "SELECT * FROM `devices`";
$devices = dbFetchRows($query, $sql_param);
foreach ($devices as $device) {
    $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/perf-poller.rrd";
    if (device_permitted($device) && is_file($rrd_filename)) {
        $rrd_list[$i]['filename'] = $rrd_filename;
        $rrd_list[$i]['descr'] = str_pad($device['hostname'], 25) . " (" . $device['os'] . ")";
        $rrd_list[$i]['ds'] = "val";
        $i++;
    }
}
$unit_text = "负载 %";
$units = '秒';
$total_units = 'Sec';
$colours = 'mixed-q12';
#$scale_min = "0";
#$scale_max = "100";
#$divider = $i;
#$text_orig = 1;
$nototal = 1;
include "includes/graphs/generic_multi_simplex_separated.inc.php";
Example #6
0
<?php

if (is_numeric($vars['id'])) {
    $storage = dbFetchRow('SELECT * FROM `storage` WHERE `storage_id` = ?', array($vars['id']));
    if (is_numeric($storage['device_id']) && ($auth || device_permitted($storage['device_id']))) {
        $device = device_by_id_cache($storage['device_id']);
        $rrd_filename = $config['rrd_dir'] . '/' . $device['hostname'] . '/' . safename('storage-' . $storage['storage_mib'] . '-' . $storage['storage_descr'] . '.rrd');
        $title = generate_device_link($device);
        $title .= ' :: Storage :: ' . htmlentities($storage['storage_descr']);
        $auth = true;
    }
}
Example #7
0
<?php

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage graphs
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
// $cbqos = dbFetchRows("SELECT * FROM `ports_cbqos` WHERE `port_id` = ?", array($port['port_id']));
if (is_numeric($vars['id'])) {
    $cbqos = dbFetchRow("SELECT * FROM `ports_cbqos` WHERE `cbqos_id` = ?", array($vars['id']));
    if (is_numeric($cbqos['device_id']) && ($auth || device_permitted($cbqos['device_id']))) {
        $device = device_by_id_cache($cbqos['device_id']);
        $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("cbqos-" . $cbqos['policy_index'] . "-" . $cbqos['object_index'] . ".rrd");
        $title = generate_device_link($device);
        $title .= " :: CBQoS :: " . $cbqos['policy_index'] . "-" . $cbqos['object_index'];
        $auth = TRUE;
        $graph_return['rrds'][] = $rrd_filename;
    }
}
Example #8
0
<?php

$graph_type = "toner_usage";
echo "<div style='padding: 5px;'>\n        <table width=100% cellspacing=0 cellpadding=6 class='sortable'>";
echo "<tr class=tablehead>\n        <th width=280>Device</th>\n        <th>Toner</th>\n        <th width=100></th>\n        <th width=280>Usage</th>\n        <th width=50>Used</th>\n      </tr>";
foreach (dbFetchRows("SELECT * FROM `toner` AS S, `devices` AS D WHERE S.device_id = D.device_id ORDER BY D.hostname, S.toner_descr") as $toner) {
    if (device_permitted($toner['device_id'])) {
        $total = $toner['toner_capacity'];
        $perc = $toner['toner_current'];
        $graph_array['type'] = $graph_type;
        $graph_array['id'] = $toner['toner_id'];
        $graph_array['from'] = $config['time']['day'];
        $graph_array['to'] = $config['time']['now'];
        $graph_array['height'] = "20";
        $graph_array['width'] = "80";
        $graph_array_zoom = $graph_array;
        $graph_array_zoom['height'] = "150";
        $graph_array_zoom['width'] = "400";
        $link = "graphs/id=" . $graph_array['id'] . "/type=" . $graph_array['type'] . "/from=" . $graph_array['from'] . "/to=" . $graph_array['to'] . "/";
        $mini_graph = overlib_link($link, generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL);
        $background = get_percentage_colours(100 - $perc);
        echo "<tr class='health'><td>" . generate_device_link($toner) . "</td><td class=tablehead>" . $toner['toner_descr'] . "</td>\n         <td>{$mini_graph}</td>\n         <td>\n          <a href='#' {$store_popup}>" . print_percentage_bar(400, 20, $perc, "{$perc}%", "ffffff", $background['left'], $free, "ffffff", $background['right']) . "</a>\n          </td><td>{$perc}" . "%</td></tr>";
        if ($vars['view'] == "graphs") {
            echo "<tr></tr><tr class='health'><td colspan=5>";
            $graph_array['height'] = "100";
            $graph_array['width'] = "216";
            $graph_array['to'] = $config['time']['now'];
            $graph_array['id'] = $toner['toner_id'];
            $graph_array['type'] = $graph_type;
            include "includes/print-graphrow.inc.php";
            echo "</td></tr>";
Example #9
0
?>
                 "</select>"+
                 "</div>"+
                 "<div class=\"form-group\">"+
                 "<input type=\"text\" name=\"serial\" id=\"serial\" value=\"<?php 
echo $_POST['serial'];
?>
\" placeholder=\"Serial\" class=\"form-control input-sm\"/>"+
                 "</div>"+
                 "<div class=\"form-group\">"+
                 "<strong>&nbsp;Device&nbsp;</strong>"+
                 "<select name=\"device\" id=\"device\" class=\"form-control input-sm\">"+
                 "<option value=\"\">All Devices</option>"+
<?php 
foreach (dbFetchRows("SELECT * FROM `devices` ORDER BY `hostname`") as $data) {
    if (device_permitted($data['device_id'])) {
        echo '"<option value=\\"' . $data['device_id'] . '\\""+';
        if ($data['device_id'] == $_POST['device']) {
            echo '" selected"+';
        }
        echo '">' . $data['hostname'] . '</option>"+';
    }
}
?>
                 "</select>"+
                 "</div>"+
                 "<div class=\"form-group\">"+
                 "<input type=\"text\" size=24 name=\"device_string\" id=\"device_string\" value=\"<?php 
if ($_POST['device_string']) {
    echo $_POST['device_string'];
}
Example #10
0
    exit;
}
$vars = get_vars();
$vars['page'] = "popup";
switch ($vars['entity_type']) {
    case "port":
        if (is_numeric($vars['entity_id']) && port_permitted($vars['entity_id'])) {
            $port = get_port_by_id($vars['entity_id']);
            echo generate_port_popup($port);
        } else {
            print_warning("You are not permitted to view this port.");
        }
        exit;
        break;
    case "device":
        if (is_numeric($vars['entity_id']) && device_permitted($vars['entity_id'])) {
            $device = device_by_id_cache($vars['entity_id']);
            echo generate_device_popup($device, $vars, $start, $end);
        } else {
            print_warning("You are not permitted to view this device.");
        }
        exit;
        break;
    case "group":
        if (is_numeric($vars['entity_id']) && $_SESSION['userlevel'] >= 5) {
            $group = get_group_by_id($vars['entity_id']);
            generate_group_popup_header($group, array());
        } else {
            print_warning("You are not permitted to view this device.");
        }
        exit;
Example #11
0
<?php

if (is_numeric($vars['plugin'])) {
    $mplug = dbFetchRow("SELECT * FROM `munin_plugins` AS M, `devices` AS D WHERE `mplug_id` = ? AND D.device_id = M.device_id ", array($vars['plugin']));
} else {
    $mplug = dbFetchRow("SELECT * FROM `munin_plugins` AS M, `devices` AS D WHERE M.`device_id` = ? AND `mplug_type` = ?  AND D.device_id = M.device_id", array($device['device_id'], $vars['plugin']));
}
if (is_numeric($mplug['device_id']) && ($auth || device_permitted($mplug['device_id']))) {
    $device =& $mplug;
    $title = generate_device_link($device);
    $plugfile = $config['rrd_dir'] . "/" . $device['hostname'] . "/munin/" . $mplug['mplug_type'];
    $title .= " :: Plugin :: " . $mplug['mplug_type'] . " - " . $mplug['mplug_title'];
    $auth = TRUE;
}
Example #12
0
<?php

if (is_numeric($vars['id']) && ($auth || device_permitted($vars['id']))) {
    $device = device_by_id_cache($vars['id']);
    $title = generate_device_link($device);
    $graph_title = $device['hostname'];
    $auth = true;
}
Example #13
0
                $cache['bgp']['external'][] = (int) $bgp['bgpPeer_id'];
                // Collect eBGP peers
            }
        }
    }
}
// OSPF
if (isset($config['enable_ospf']) && $config['enable_ospf']) {
    $routing['ospf']['last_seen'] = $config['time']['now'];
    foreach (dbFetchRows("SELECT `device_id`, `ospfAdminStat` FROM `ospf_instances`") as $ospf) {
        if (!$config['web_show_disabled']) {
            if ($cache['devices']['id'][$ospf['device_id']]['disabled']) {
                continue;
            }
        }
        if (device_permitted($ospf)) {
            if ($ospf['ospfAdminStat'] == 'enabled') {
                $routing['ospf']['up']++;
            } else {
                if ($ospf['ospfAdminStat'] == 'disabled') {
                    $routing['ospf']['down']++;
                } else {
                    continue;
                }
            }
            $routing['ospf']['count']++;
        }
    }
}
// Common permission sql query
//r(range_to_list($cache['devices']['permitted']));
Example #14
0
    $sql = ' WHERE `devices`.`hostname`=?';
    $sql_array = array($device['hostname']);
} else {
    $sql = ' WHERE 1';
}
$sql .= ' AND `local_device_id` != 0 AND `remote_device_id` != 0 ';
$sql .= ' AND `local_device_id` IS NOT NULL AND `remote_device_id` IS NOT NULL ';
$tmp_ids = array();
foreach (dbFetchRows("SELECT DISTINCT least(`devices`.`device_id`, `remote_device_id`) AS `remote_device_id`, GREATEST(`remote_device_id`,`devices`.`device_id`) AS `local_device_id` FROM `links` LEFT JOIN `ports` ON `local_port_id`=`ports`.`port_id` LEFT JOIN `devices` ON `ports`.`device_id`=`devices`.`device_id` {$sql}", $sql_array) as $link_devices) {
    if (!in_array($link_devices['local_device_id'], $tmp_ids) && device_permitted($link_devices['local_device_id'])) {
        $link_dev = dbFetchRow("SELECT * FROM `devices` WHERE `device_id`=?", array($link_devices['local_device_id']));
        if (!empty($link_dev)) {
            $tmp_devices[] = array('id' => $link_devices['local_device_id'], 'label' => $link_dev['hostname'], 'title' => generate_device_link($link_dev, '', array(), '', '', '', 0), 'group' => $link_dev['location'], 'shape' => 'box');
        }
    }
    if (!in_array($link_devices['remote_device_id'], $tmp_ids) && device_permitted($link_devices['remote_device_id'])) {
        $link_dev = dbFetchRow("SELECT * FROM `devices` WHERE `device_id`=?", array($link_devices['remote_device_id']));
        if (!empty($link_dev)) {
            $tmp_devices[] = array('id' => $link_devices['remote_device_id'], 'label' => $link_dev['hostname'], 'title' => generate_device_link($link_dev, '', array(), '', '', '', 0), 'group' => $link_dev['location'], 'shape' => 'box');
        }
    }
    array_push($tmp_ids, $link_devices['local_device_id']);
    array_push($tmp_ids, $link_devices['remote_device_id']);
}
$tmp_ids = implode(',', $tmp_ids);
$nodes = json_encode($tmp_devices);
if (is_array($tmp_devices[0])) {
    $tmp_links = array();
    foreach (dbFetchRows("SELECT local_device_id, remote_device_id, `remote_hostname`,`ports`.*, `remote_port` FROM `links` LEFT JOIN `ports` ON `local_port_id`=`ports`.`port_id` LEFT JOIN `devices` ON `ports`.`device_id`=`devices`.`device_id` WHERE (`local_device_id` IN ({$tmp_ids}) AND `remote_device_id` IN ({$tmp_ids}))") as $link_devices) {
        $port = '';
        foreach ($tmp_devices as $k => $v) {
Example #15
0
<?php

if (is_numeric($vars['id'])) {
    $sensor = dbFetchRow('SELECT * FROM sensors WHERE sensor_id = ?', array($vars['id']));
    if (is_numeric($sensor['device_id']) && ($auth || device_permitted($sensor['device_id']))) {
        $device = device_by_id_cache($sensor['device_id']);
        $rrd_filename = get_sensor_rrd($device, $sensor);
        $title = generate_device_link($device);
        $title .= ' :: Sensor :: ' . htmlentities($sensor['sensor_descr']);
        $auth = true;
    }
}
Example #16
0
<?php

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage graphs
 * @copyright  (C) 2006-2014 Adam Armstrong
 *
 */
if (is_numeric($vars['id'])) {
    $radio = dbFetchRow("SELECT * FROM `wifi_accesspoints`, `wifi_radios` WHERE  `wifi_accesspoints`.`wifi_accesspoint_id` = `wifi_radios`.`accesspoint_id` AND `wifi_radios`.`wifi_radio_id` = ? ", array($vars['id']));
    if (is_numeric($radio['device_id']) && ($auth || device_permitted($radio['device_id']))) {
        $device = device_by_id_cache($radio['device_id']);
        $title = generate_device_link($device);
        $title .= " :: WIFI - Accesspoint :: " . htmlentities($radio['name']);
        $auth = TRUE;
    }
}
Example #17
0
function application_permitted($app_id, $device_id = NULL)
{
    global $permissions;
    if (is_numeric($app_id)) {
        if (!$device_id) {
            $device_id = get_device_id_by_app_id($app_id);
        }
        if ($_SESSION['userlevel'] >= "5") {
            $allowed = TRUE;
        } elseif (device_permitted($device_id)) {
            $allowed = TRUE;
        } elseif ($permissions['application'][$app_id]) {
            $allowed = TRUE;
        } else {
            $allowed = FALSE;
        }
    } else {
        $allowed = FALSE;
    }
    return $allowed;
}
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>';
}
<?php

if (is_numeric($vars['id'])) {
    $mempool = dbFetchRow("SELECT * FROM `mempools` AS C, `devices` AS D where C.`mempool_id` = ? AND C.device_id = D.device_id", array($vars['id']));
    if (is_numeric($mempool['device_id']) && ($auth || device_permitted($mempool['device_id']))) {
        $device = device_by_id_cache($mempool['device_id']);
        if (isset($mempool['mempool_type'])) {
            $mempool['mempool_mib'] = $mempool['mempool_type'];
        }
        $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("mempool-" . $mempool['mempool_mib'] . "-" . $mempool['mempool_index'] . ".rrd");
        $title = generate_device_link($device);
        $title .= " :: Memory Pool :: " . htmlentities($mempool['mempool_descr']);
        $auth = TRUE;
    }
}
// EOF
Example #20
0
<?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'])) {
    $tunnel = dbFetchRow("SELECT * FROM `ipsec_tunnels`WHERE `tunnel_id` = ?", array($vars['id']));
    if (is_numeric($tunnel['device_id']) && ($auth || device_permitted($tunnel['device_id']))) {
        $device = device_by_id_cache($tunnel['device_id']);
        if ($tunnel['tunnel_endhash']) {
            // New index
            $rrd_index = $tunnel['local_addr'] . '-' . $tunnel['peer_addr'] . '-' . $tunnel['tunnel_endhash'];
        } else {
            $rrd_index = $tunnel['peer_addr'];
        }
        $rrd_filename = get_rrd_path($device, "ipsectunnel-" . $rrd_index . ".rrd");
        $title = generate_device_link($device);
        $title .= " :: IPSEC Tunnel :: " . escape_html($tunnel['peer_addr']);
        $auth = TRUE;
    }
}
// EOF
Example #21
0
<?php

if (is_numeric($vars['id'])) {
    // $auth= TRUE;
    $rserver = dbFetchRow('SELECT * FROM `loadbalancer_rservers` AS I, `devices` AS D WHERE I.rserver_id = ? AND I.device_id = D.device_id', array($vars['id']));
    if (is_numeric($rserver['device_id']) && ($auth || device_permitted($rserver['device_id']))) {
        $device = device_by_id_cache($rserver['device_id']);
        $rrd_filename = $config['rrd_dir'] . '/' . $device['hostname'] . '/' . safename('rserver-' . $rserver['rserver_id'] . '.rrd');
        $title = generate_device_link($device);
        $title .= ' :: Rserver :: ' . htmlentities($rserver['farm_id']);
        $auth = true;
    }
}
Example #22
0
<?php

if ($auth || device_permitted($device['device_id'])) {
    $title = generate_device_link($device);
    $graph_title = $device['hostname'];
    $auth = TRUE;
}
Example #23
0
<?php

/**
 * Observium
 *
 *   This file is part of Observium.
 *
 * @package    observium
 * @subpackage webui
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
echo '
  <table class="table table-hover table-striped  table-condensed ">';
foreach ($devices as $device) {
    if (device_permitted($device['device_id'])) {
        if (!$location_filter || $device['location'] == $location_filter) {
            print_device_row($device, 'basic');
        }
    }
}
echo "  </table>";
// EOF
Example #24
0
                </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 {
        require 'includes/error-no-perm.inc.php';
    }
}
//end if
Example #25
0
function application_permitted($app_id, $device_id = null)
{
    global $permissions;
    if (is_numeric($app_id)) {
        if (!$device_id) {
            $device_id = get_device_id_by_app_id($app_id);
        }
        if ($_SESSION['userlevel'] >= '5') {
            $allowed = true;
        } else {
            if (device_permitted($device_id)) {
                $allowed = true;
            } else {
                if ($permissions['application'][$app_id]) {
                    $allowed = true;
                } else {
                    $allowed = false;
                }
            }
        }
    } else {
        $allowed = false;
    }
    return $allowed;
}
Example #26
0
<?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'])) {
    $supply = dbFetchRow("SELECT * FROM `printersupplies` WHERE `supply_id` = ?", array($vars['id']));
    if (is_numeric($supply['device_id']) && ($auth || device_permitted($supply['device_id']))) {
        $device = device_by_id_cache($supply['device_id']);
        $rrd_filename = get_rrd_path($device, "toner-" . $supply['supply_index'] . ".rrd");
        $title = generate_device_link($device);
        $title .= " :: Toner :: " . escape_html($supply['supply_descr']);
        $auth = TRUE;
    }
}
// EOF
Example #27
0
$sql = "SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'";
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";
Example #28
0
<?php

if (is_numeric($vars['id'])) {
    $disk = dbFetchRow("SELECT * FROM `ucd_diskio` AS U, `devices` AS D WHERE U.diskio_id = ? AND U.device_id = D.device_id", array($vars['id']));
    if (is_numeric($disk['device_id']) && ($auth || device_permitted($disk['device_id']))) {
        $device = device_by_id_cache($disk['device_id']);
        $rrd_filename = $config['rrd_dir'] . "/" . $disk['hostname'] . "/ucd_diskio-" . safename($disk['diskio_descr'] . ".rrd");
        $title = generate_device_link($device);
        $title .= " :: Disk :: " . htmlentities($disk['diskio_descr']);
        $auth = TRUE;
    }
}
Example #29
0
/**
 * 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;
}
Example #30
0
<?php

/**
 * Observium Network Management and Monitoring System
 * Copyright (C) 2006-2015, Adam Armstrong - http://www.observium.org
 *
 * @package    observium
 * @subpackage webui
 * @author     Adam Armstrong <*****@*****.**>
 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
 *
 */
if (device_permitted($device)) {
    // Only show aggregate graph if we have access to the entire device.
    $graph_title = nicecase($vars['metric']);
    $graph_array['type'] = "device_" . $vars['metric'];
    $graph_array['device'] = $device['device_id'];
    $graph_array['legend'] = no;
    $box_args = array('title' => $graph_title, 'header-border' => TRUE);
    echo generate_box_open($box_args);
    print_graph_row($graph_array);
    echo generate_box_close();
}
echo generate_box_open();
echo '<table class="table table-striped table-condensed ">';
//echo("<thead><tr>
//        <th>Device</th>
//      </tr></thead>");
foreach (dbFetchRows("SELECT * FROM `ucd_diskio` WHERE device_id = ? ORDER BY diskio_descr", array($device['device_id'])) as $drive) {
    $fs_url = "device/device=" . $device['device_id'] . "/tab=health/metric=diskio/";
    $graph_array_zoom['id'] = $drive['diskio_id'];