mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-28 08:02:41 +02:00
Rebasing
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2015 Mark Schouten <mark@tuxis.nl>
|
||||
*
|
||||
* 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; version 2 dated June,
|
||||
* 1991.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* See http://www.gnu.org/licenses/gpl.txt for the full license
|
||||
*/
|
||||
|
||||
/**
|
||||
* Fetch all VM's in a Proxmox Cluster
|
||||
* @param string $c Clustername
|
||||
* @return array An array with all the VM's on this cluster
|
||||
*/
|
||||
function proxmox_cluster_vms($c) {
|
||||
return dbFetchRows("SELECT * FROM proxmox WHERE cluster = ? ORDER BY vmid", array($c));
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch all VM's on a Proxmox node
|
||||
* @param integer $n device_id
|
||||
* @return array An array with all the VM's on this node
|
||||
*/
|
||||
function proxmox_node_vms($n) {
|
||||
return dbFetchRows("SELECT * FROM proxmox WHERE device_id = ? ORDER BY vmid", array($n));
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch all info about a Proxmox VM
|
||||
* @param integer $vmid Proxmox VM ID
|
||||
* @param string $c Clustername
|
||||
* @return array An array with all info of this VM on this cluster, including ports
|
||||
*/
|
||||
function proxmox_vm_info($vmid, $c) {
|
||||
$vm = dbFetchRow("SELECT pm.*, d.hostname AS host, d.device_id FROM proxmox pm, devices d WHERE pm.device_id = d.device_id AND pm.vmid = ? AND pm.cluster = ?", array($vmid, $c));
|
||||
$appid = dbFetchRow("SELECT app_id FROM applications WHERE device_id = ? AND app_type = ?", array($vm['device_id'], 'proxmox'));
|
||||
|
||||
$vm['ports'] = dbFetchRows("SELECT * FROM proxmox_ports WHERE vm_id = ?", array($vm['id']));
|
||||
$vm['app_id'] = $appid['app_id'];
|
||||
return $vm;
|
||||
}
|
||||
@@ -42,7 +42,7 @@ foreach(dbFetchRows($sql, $param) as $device) {
|
||||
$temp_output[] = '<a href="' . generate_url(array(
|
||||
'page' => 'device',
|
||||
'device' => $device['device_id']
|
||||
)) . '" role="button" class="btn ' . $btn_type . ' btn-xs" title="' . $device['hostname'] . '" style="min-height:25px; min-width:25px; border-radius:0px; margin:0; padding:0;"></a>';
|
||||
)) . '" role="button" class="btn ' . $btn_type . ' btn-xs" title="' . $device['hostname'] . " - " . formatUptime($device['uptime']) . '" style="min-height:25px; min-width:25px; border-radius:0px; margin:0; padding:0;"></a>';
|
||||
}
|
||||
|
||||
$temp_rows = count($temp_output);
|
||||
|
||||
@@ -12,6 +12,7 @@ $temp_output = '
|
||||
<th>Down</th>
|
||||
<th>Ignored</th>
|
||||
<th>Disabled</th>
|
||||
'.($config['summary_errors'] ? '<th>Errored</th>' : '').'
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -22,6 +23,7 @@ $temp_output = '
|
||||
<td><a href="devices/state=down/format=list_detail/"><span class="red"> '.$devices['down'].'</span></a></td>
|
||||
<td><a href="devices/ignore=1/format=list_detail/"><span class="grey"> '.$devices['ignored'].'</span></a></td>
|
||||
<td><a href="devices/disabled=1/format=list_detail/"><span class="black"> '.$devices['disabled'].'</span></a></td>
|
||||
'.($config['summary_errors'] ? '<td>-</td>' : '').'
|
||||
</tr>
|
||||
<tr class="active">
|
||||
<td><a href="ports/">Ports</a></td>
|
||||
@@ -30,6 +32,7 @@ $temp_output = '
|
||||
<td><a href="ports/format=list_detail/state=down/"><span class="red"> '.$ports['down'].'</span></a></td>
|
||||
<td><a href="ports/format=list_detail/ignore=1/"><span class="grey"> '.$ports['ignored'].'</span></a></td>
|
||||
<td><a href="ports/format=list_detail/state=admindown/"><span class="black"> '.$ports['shutdown'].'</span></a></td>
|
||||
'.($config['summary_errors'] ? '<td><a href="ports/format=list_detail/errors=1/"><span class="black"> '.$ports['errored'].'</span></a></td>' : '').'
|
||||
</tr>';
|
||||
if ($config['show_services']) {
|
||||
|
||||
@@ -41,6 +44,7 @@ $temp_output .= '
|
||||
<td><a href="services/state=down/view=details/"><span class="red"> '.$services['down'].'</span></a></td>
|
||||
<td><a href="services/ignore=1/view=details/"><span class="grey"> '.$services['ignored'].'</span></a></td>
|
||||
<td><a href="services/disabled=1/view=details/"><span class="black"> '.$services['disabled'].'</span></a></td>
|
||||
'.($config['summary_errors'] ? '<td>-</td>' : '').'
|
||||
</tr>';
|
||||
}
|
||||
$temp_output .= '
|
||||
|
||||
@@ -83,6 +83,21 @@ if ($config['show_services']) {
|
||||
|
||||
}
|
||||
|
||||
if ($config['summary_errors']) {
|
||||
$temp_output .= '
|
||||
</tr>
|
||||
<tr class="active">
|
||||
<th><span class="black">Errored</span></th>
|
||||
<td>-</td>
|
||||
<td><a href="ports/format=list_detail/errors=1/"><span class="black"> '.$ports['errored'].'</span></a></td>
|
||||
';
|
||||
if ($config['show_services']) {
|
||||
$temp_output .= '
|
||||
<td>-</td>
|
||||
';
|
||||
}
|
||||
}
|
||||
|
||||
$temp_output .= '
|
||||
</tr>
|
||||
<tr class="active">
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
<?php
|
||||
|
||||
$common_output[] = '
|
||||
<table id="eventlog" class="table table-hover table-condensed table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-column-id="datetime" data-order="desc">Datetime</th>
|
||||
<th data-column-id="hostname">Hostname</th>
|
||||
<th data-column-id="type">Type</th>
|
||||
<th data-column-id="message">Message</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table id="eventlog" class="table table-hover table-condensed table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-column-id="datetime" data-order="desc">Datetime</th>
|
||||
<th data-column-id="hostname">Hostname</th>
|
||||
<th data-column-id="type">Type</th>
|
||||
<th data-column-id="message">Message</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
<script>
|
||||
|
||||
var eventlog_grid = $("#eventlog").bootgrid({
|
||||
|
||||
@@ -0,0 +1,328 @@
|
||||
<?php
|
||||
/* Copyright (C) 2015 Daniel Preussker, QuxLabs UG <preussker@quxlabs.com>
|
||||
* 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.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/**
|
||||
* Generic Graph Widget
|
||||
* @author Daniel Preussker
|
||||
* @copyright 2015 Daniel Preussker, QuxLabs UG
|
||||
* @license GPL
|
||||
* @package LibreNMS
|
||||
* @subpackage Widgets
|
||||
*/
|
||||
|
||||
if( defined('show_settings') || empty($widget_settings) ) {
|
||||
$common_output[] = '
|
||||
<form class="form" onsubmit="widget_settings(this); return false;">
|
||||
<div class="form-group">
|
||||
<div class="col-sm-2">
|
||||
<label for="graph_type" class="control-label">Graph: </label>
|
||||
</div>
|
||||
<div class="col-sm-8">
|
||||
<select class="form-control" name="graph_type" id="select_'.$unique_id.'" onchange="switch_'.$unique_id.'($(this).val());">';
|
||||
if (empty($widget_settings['graph_type'])) {
|
||||
$common_output[] = '<option disabled selected>Select a Graph</option>';
|
||||
}
|
||||
$sub = '';
|
||||
$old = '';
|
||||
foreach (array('device','port','application','munin') as $type) {
|
||||
$common_output[] = '<option disabled>'.nicecase($type).':</option>';
|
||||
foreach (get_graph_subtypes($type) as $avail_type) {
|
||||
$display_type = is_mib_graph($type, $avail_type) ? $avail_type : nicecase($avail_type);
|
||||
if( strstr($display_type,'_') ) {
|
||||
$sub = explode('_',$display_type,2);
|
||||
$sub = array_shift($sub);
|
||||
if( $sub != $old ) {
|
||||
$old = $sub;
|
||||
$common_output[] = '<option disabled> '.nicecase($sub).':</option>';
|
||||
}
|
||||
$display_type = str_replace($sub.'_','',$display_type);
|
||||
$space = ' ';
|
||||
} else {
|
||||
$space = ' ';
|
||||
}
|
||||
$common_output[] = '<option value="'.$type.'_'.$avail_type.'"';
|
||||
if ($type.'_'.$avail_type == $widget_settings['graph_type']) {
|
||||
$common_output[] = " selected";
|
||||
}
|
||||
$common_output[] = '>'.$space.nicecase($display_type).'</option>';
|
||||
}
|
||||
$common_output[] = '<option disabled></option>';
|
||||
}
|
||||
$common_output[] = '
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-sm-offset-10 col-sm-2">
|
||||
<div class="checkbox input-sm">
|
||||
<label class="control-label">
|
||||
<input type="checkbox" name="graph_legend" class="widget_setting" value="1" '.($widget_settings['graph_legend'] ? 'checked' : '').'> Legend
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-2">
|
||||
<label for="graph_range" class="control-label">Range: </label>
|
||||
</div>
|
||||
<div class="col-sm-10">
|
||||
<select class="form-control" name="graph_range">';
|
||||
$checked = '';
|
||||
foreach( array_diff_key($config['time'],array('now'=>'')) as $k=>$v ) {
|
||||
if ($widget_settings['graph_range'] == $k) {
|
||||
$checked = ' selected';
|
||||
} else {
|
||||
$checked = '';
|
||||
}
|
||||
$common_output[] = '<option value="'.$k.'"'.$checked.'>'.nicecase($k).'</option>';
|
||||
}
|
||||
$common_output[] = '
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group input_'.$unique_id.'" id="input_'.$unique_id.'_device">
|
||||
<div class="col-sm-2">
|
||||
<label for="graph_device" class="control-label">Device: </label>
|
||||
</div>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control input_'.$unique_id.'_device" name="graph_device" placeholder="Device Name" value="'.htmlspecialchars($widget_settings['graph_device']).'">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group input_'.$unique_id.'" id="input_'.$unique_id.'_port">
|
||||
<div class="col-sm-2">
|
||||
<label for="graph_port" class="control-label">Port: </label>
|
||||
</div>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control input_'.$unique_id.'_port" name="graph_port" placeholder="Port" value="'.htmlspecialchars($widget_settings['graph_port']).'">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group input_'.$unique_id.'" id="input_'.$unique_id.'_application">
|
||||
<div class="col-sm-2">
|
||||
<label for="graph_application" class="control-label">Application: </label>
|
||||
</div>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control input_'.$unique_id.'_application" name="graph_application" placeholder="Application" value="'.htmlspecialchars($widget_settings['graph_application']).'">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group input_'.$unique_id.'" id="input_'.$unique_id.'_munin">
|
||||
<div class="col-sm-2">
|
||||
<label for="graph_munin" class="control-label">Munin Plugin: </label>
|
||||
</div>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control input_'.$unique_id.'_munin" name="graph_munin" placeholder="Munin Plugin" value="'.htmlspecialchars($widget_settings['graph_munin']).'">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-2">
|
||||
<button type="submit" class="btn btn-default">Set</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<style>
|
||||
.twitter-typeahead {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
function '.$unique_id.'() {
|
||||
var '.$unique_id.'_device = new Bloodhound({
|
||||
datumTokenizer: Bloodhound.tokenizers.obj.whitespace("name"),
|
||||
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||||
remote: {
|
||||
url: "ajax_search.php?search=%QUERY&type=device",
|
||||
filter: function (output) {
|
||||
return $.map(output, function (item) {
|
||||
return {
|
||||
device_id: item.device_id,
|
||||
device_image: item.device_image,
|
||||
name: item.name,
|
||||
device_os: item.device_os,
|
||||
version: item.version,
|
||||
device_hardware: item.device_hardware,
|
||||
device_ports: item.device_ports,
|
||||
location: item.location
|
||||
};
|
||||
});
|
||||
},
|
||||
wildcard: "%QUERY"
|
||||
}
|
||||
});
|
||||
'.$unique_id.'_device.initialize();
|
||||
$(".input_'.$unique_id.'_device").typeahead({
|
||||
hint: true,
|
||||
highlight: true,
|
||||
minLength: 1,
|
||||
classNames: {
|
||||
menu: "typeahead-left"
|
||||
}
|
||||
},
|
||||
{
|
||||
source: '.$unique_id.'_device.ttAdapter(),
|
||||
async: false,
|
||||
templates: {
|
||||
header: "<h5><strong> Devices</strong></h5>",
|
||||
suggestion: Handlebars.compile(\'<p><img src="{{device_image}}" border="0"> <small><strong>{{name}}</strong> | {{device_os}} | {{version}} | {{device_hardware}} with {{device_ports}} port(s) | {{location}}</small></p>\')
|
||||
}
|
||||
});
|
||||
|
||||
var '.$unique_id.'_port = new Bloodhound({
|
||||
datumTokenizer: Bloodhound.tokenizers.obj.whitespace("port_id"),
|
||||
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||||
remote: {
|
||||
url: "ajax_search.php?search=%QUERY&type=ports",
|
||||
filter: function (output) {
|
||||
return $.map(output, function (item) {
|
||||
return {
|
||||
name: item.name,
|
||||
description: item.description,
|
||||
hostname: item.hostname,
|
||||
port_id: item.port_id
|
||||
};
|
||||
});
|
||||
},
|
||||
wildcard: "%QUERY"
|
||||
}
|
||||
});
|
||||
'.$unique_id.'_port.initialize();
|
||||
$(".input_'.$unique_id.'_port").typeahead({
|
||||
hint: true,
|
||||
highlight: true,
|
||||
minLength: 1,
|
||||
classNames: {
|
||||
menu: "typeahead-left"
|
||||
}
|
||||
},
|
||||
{
|
||||
source: '.$unique_id.'_port.ttAdapter(),
|
||||
async: false,
|
||||
templates: {
|
||||
header: "<h5><strong> Ports</strong></h5>",
|
||||
suggestion: Handlebars.compile(\'<p><small><img src="images/icons/port.png" /> <strong>{{name}}</strong> – {{hostname}} - <i>{{description}}</i></small></p>\')
|
||||
}
|
||||
});
|
||||
|
||||
var '.$unique_id.'_application = new Bloodhound({
|
||||
datumTokenizer: Bloodhound.tokenizers.obj.whitespace("app_id"),
|
||||
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||||
remote: {
|
||||
url: "ajax_search.php?search=%QUERY&type=applications",
|
||||
filter: function (output) {
|
||||
return $.map(output, function (item) {
|
||||
return {
|
||||
name: item.name,
|
||||
hostname: item.hostname,
|
||||
app_id: item.app_id
|
||||
};
|
||||
});
|
||||
},
|
||||
wildcard: "%QUERY"
|
||||
}
|
||||
});
|
||||
'.$unique_id.'_application.initialize();
|
||||
$(".input_'.$unique_id.'_application").typeahead({
|
||||
hint: true,
|
||||
highlight: true,
|
||||
minLength: 1,
|
||||
classNames: {
|
||||
menu: "typeahead-left"
|
||||
}
|
||||
},
|
||||
{
|
||||
source: '.$unique_id.'_application.ttAdapter(),
|
||||
async: false,
|
||||
templates: {
|
||||
header: "<h5><strong> Applications</strong></h5>",
|
||||
suggestion: Handlebars.compile(\'<p><small><img src="images/icons/port.png" /> <strong>{{name}}</strong> – {{hostname}}</small></p>\')
|
||||
}
|
||||
});
|
||||
|
||||
var '.$unique_id.'_munin = new Bloodhound({
|
||||
datumTokenizer: Bloodhound.tokenizers.obj.whitespace("munin"),
|
||||
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||||
remote: {
|
||||
url: "ajax_search.php?search=%QUERY&type=munin",
|
||||
filter: function (output) {
|
||||
return $.map(output, function (item) {
|
||||
return {
|
||||
desc: item.name,
|
||||
name: item.plugin,
|
||||
hostname: item.hostname,
|
||||
plugin: item.plugin,
|
||||
device_id: item.device_id,
|
||||
};
|
||||
});
|
||||
},
|
||||
wildcard: "%QUERY"
|
||||
}
|
||||
});
|
||||
'.$unique_id.'_munin.initialize();
|
||||
$(".input_'.$unique_id.'_munin").typeahead({
|
||||
hint: true,
|
||||
highlight: true,
|
||||
minLength: 1,
|
||||
classNames: {
|
||||
menu: "typeahead-left"
|
||||
}
|
||||
},
|
||||
{
|
||||
source: '.$unique_id.'_munin.ttAdapter(),
|
||||
async: false,
|
||||
templates: {
|
||||
header: "<h5><strong> Munin</strong></h5>",
|
||||
suggestion: Handlebars.compile(\'<p><small><img src="images/icons/port.png" /> <strong>{{plugin}}</strong> – {{hostname}}</small></p>\')
|
||||
}
|
||||
});
|
||||
|
||||
switch_'.$unique_id.'($("#select_'.$unique_id.'").val());
|
||||
}
|
||||
function switch_'.$unique_id.'(data) {
|
||||
$(".input_'.$unique_id.'").fadeOut();
|
||||
if (data != undefined && data != "") {
|
||||
data = data.split("_");
|
||||
type = data.shift();
|
||||
data = data.join("_");
|
||||
$("#input_'.$unique_id.'_"+type).fadeIn();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<script id="js_'.$unique_id.'">
|
||||
$(function() {
|
||||
$("#js_'.$unique_id.'").parent().parent().data("settings","1");
|
||||
'.$unique_id.'();
|
||||
});
|
||||
</script>';
|
||||
}
|
||||
else {
|
||||
$widget_settings['title'] = "";
|
||||
$type = explode('_',$widget_settings['graph_type'],2);
|
||||
$type = array_shift($type);
|
||||
$widget_settings['graph_'.$type] = json_decode($widget_settings['graph_'.$type],true);
|
||||
if ($type == 'device') {
|
||||
$widget_settings['title'] = $widget_settings['graph_device']['name']." / ".$widget_settings['graph_type'];
|
||||
$param = 'device='.$widget_settings['graph_device']['device_id'];
|
||||
}
|
||||
elseif ($type == 'application') {
|
||||
$param = 'id='.$widget_settings['graph_'.$type]['app_id'];
|
||||
}
|
||||
elseif ($type == 'munin') {
|
||||
$param = 'device='.$widget_settings['graph_'.$type]['device_id'].'&plugin='.$widget_settings['graph_'.$type]['name'];
|
||||
}
|
||||
else {
|
||||
$param = 'id='.$widget_settings['graph_'.$type][$type.'_id'];
|
||||
}
|
||||
if (empty($widget_settings['title'])) {
|
||||
$widget_settings['title'] = $widget_settings['graph_'.$type]['hostname']." / ".$widget_settings['graph_'.$type]['name']." / ".$widget_settings['graph_type'];
|
||||
}
|
||||
$common_output[] = '<img class="minigraph-image" src="graph.php?'.$param.'&from='.$config['time'][$widget_settings['graph_range']].'&to='.$config['time']['now'].'&width='.$widget_dimensions['x'].'&height='.$widget_dimensions['y'].'&type='.$widget_settings['graph_type'].'&legend='.($widget_settings['graph_legend'] == 1 ? 'yes' : 'no').'&absolute=1"/>';
|
||||
}
|
||||
@@ -1,17 +1,18 @@
|
||||
<?php
|
||||
|
||||
$common_output[] = '
|
||||
<table id="syslog" class="table table-hover table-condensed table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-column-id="timestamp" data-order="desc">Datetime</th>
|
||||
<th data-column-id="device_id">Hostname</th>
|
||||
<th data-column-id="program">Program</th>
|
||||
<th data-column-id="msg">Message</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table id="syslog" class="table table-hover table-condensed table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-column-id="timestamp" data-order="desc">Datetime</th>
|
||||
<th data-column-id="device_id">Hostname</th>
|
||||
<th data-column-id="program">Program</th>
|
||||
<th data-column-id="msg">Message</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
<script>
|
||||
|
||||
var syslog_grid = $("#syslog").bootgrid({
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
/* Copyright (C) 2015 Sergiusz Paprzycki <serek@walcz.net>
|
||||
*
|
||||
* This widget is based on legacy frontpage module created by Paul Gear.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/**
|
||||
* Top devices by traffic
|
||||
* @author Sergiusz Paprzycki
|
||||
* @copyright 2015 Sergiusz Paprzycki <serek@walcz.net>
|
||||
* @license GPL
|
||||
* @package LibreNMS
|
||||
* @subpackage Widgets
|
||||
*/
|
||||
|
||||
if( defined('show_settings') || empty($widget_settings) ) {
|
||||
$common_output[] = '
|
||||
<form class="form" onsubmit="widget_settings(this); return false;">
|
||||
<div class="form-group">
|
||||
<div class="col-sm-6">
|
||||
<label for="graph_type" class="control-label">Number of Devices: </label>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<input class="form-control" name="device_count" id="input_count_'.$unique_id.'" placeholder="ie. 5" value="'.$widget_settings['device_count'].'">
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-6">
|
||||
<label for="graph_type" class="control-label">Time interval (minutes): </label>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<input class="form-control" name="time_interval" id="input_time_'.$unique_id.'" placeholder="ie. 15" value="'.$widget_settings['time_interval'].'">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-2">
|
||||
<button type="submit" class="btn btn-default">Set</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
';
|
||||
}
|
||||
else {
|
||||
$interval = $widget_settings['time_interval'];
|
||||
(integer) $interval_seconds = ($interval * 60);
|
||||
(integer) $device_count = $widget_settings['device_count'];
|
||||
$common_output[] = '
|
||||
<h4>Top '.$device_count.' devices (last '.$interval.' minutes)</h4>
|
||||
';
|
||||
$params = array('user' => $_SESSION['user_id'], 'interval' => array($interval_seconds), 'count' => array($device_count));
|
||||
if (is_admin() || is_read()) {
|
||||
$query = '
|
||||
SELECT *, sum(p.ifInOctets_rate + p.ifOutOctets_rate) as total
|
||||
FROM ports as p, devices as d
|
||||
WHERE d.device_id = p.device_id
|
||||
AND unix_timestamp() - p.poll_time < :interval
|
||||
AND ( p.ifInOctets_rate > 0
|
||||
OR p.ifOutOctets_rate > 0 )
|
||||
GROUP BY d.device_id
|
||||
ORDER BY total desc
|
||||
LIMIT :count
|
||||
';
|
||||
}
|
||||
else {
|
||||
$query = '
|
||||
SELECT *, sum(p.ifInOctets_rate + p.ifOutOctets_rate) as total
|
||||
FROM ports as p, devices as d, `devices_perms` AS `P`
|
||||
WHERE `P`.`user_id` = :user AND `P`.`device_id` = `d`.`device_id` AND
|
||||
d.device_id = p.device_id
|
||||
AND unix_timestamp() - p.poll_time < :interval
|
||||
AND ( p.ifInOctets_rate > 0
|
||||
OR p.ifOutOctets_rate > 0 )
|
||||
GROUP BY d.device_id
|
||||
ORDER BY total desc
|
||||
LIMIT :count
|
||||
';
|
||||
}
|
||||
$common_output[] = '
|
||||
<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">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_device_link(
|
||||
$result,
|
||||
generate_minigraph_image(
|
||||
$result, $config['time']['day'],
|
||||
$config['time']['now'],
|
||||
'device_bits',
|
||||
'no', 150, 21),
|
||||
array(), 0, 0, 0).'
|
||||
</td>
|
||||
</tr>
|
||||
';
|
||||
}
|
||||
$common_output[] = '
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
';
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
<?php
|
||||
/* Copyright (C) 2015 Sergiusz Paprzycki <serek@walcz.net>
|
||||
*
|
||||
* This widget is based on legacy frontpage module created by Paul Gear.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/**
|
||||
* Top interfaces by traffic
|
||||
* @author Sergiusz Paprzycki
|
||||
* @copyright 2015 Sergiusz Paprzycki <serek@walcz.net>
|
||||
* @license GPL
|
||||
* @package LibreNMS
|
||||
* @subpackage Widgets
|
||||
*/
|
||||
|
||||
if( defined('show_settings') || empty($widget_settings) ) {
|
||||
$common_output[] = '
|
||||
<form class="form-horizontal" onsubmit="widget_settings(this); return false;">
|
||||
<div class="form-group">
|
||||
<label for="interface_count" class="col-sm-5 control-label">Number of Interfaces: </label>
|
||||
<div class="col-sm-7">
|
||||
<input class="form-control" type="number" min="0" step="1" name="interface_count" id="input_count_'.$unique_id.'" placeholder="ie. 5" value="'.$widget_settings['interface_count'].'">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="time_interval" class="col-sm-5 control-label">Last Polled within (minutes): </label>
|
||||
<div class="col-sm-7">
|
||||
<input class="form-control" type="number" min="5" step="1" name="time_interval" id="input_time_'.$unique_id.'" placeholder="ie. 15" value="'.$widget_settings['time_interval'].'">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="interface_filter" class="col-sm-5 control-label">Interface Type: </label>
|
||||
<div class="col-sm-7">
|
||||
<input class="form-control" name="interface_filter" id="input_filter_'.$unique_id.'" placeholder="Any" value="'.$widget_settings['interface_filter'].'">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-5 col-sm-7">
|
||||
<button type="submit" class="btn btn-default">Set</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<script>
|
||||
$(function() {
|
||||
var '.$unique_id.'_filter = new Bloodhound({
|
||||
datumTokenizer: Bloodhound.tokenizers.obj.whitespace("name"),
|
||||
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||||
remote: {
|
||||
url: "ajax_search.php?search=%QUERY&type=iftype",
|
||||
filter: function (output) {
|
||||
return $.map(output, function (item) {
|
||||
return {
|
||||
filter: item.filter
|
||||
};
|
||||
});
|
||||
},
|
||||
wildcard: "%QUERY"
|
||||
}
|
||||
});
|
||||
'.$unique_id.'_filter.initialize();
|
||||
$("#input_filter_'.$unique_id.'").typeahead({
|
||||
hint: true,
|
||||
highlight: true,
|
||||
minLength: 1,
|
||||
classNames: {
|
||||
menu: "typeahead-left"
|
||||
}
|
||||
},
|
||||
{
|
||||
source: '.$unique_id.'_filter.ttAdapter(),
|
||||
async: false,
|
||||
display: "filter",
|
||||
templates: {
|
||||
header: "<h5><strong> Interface Types</strong></h5>",
|
||||
suggestion: Handlebars.compile("<p>{{filter}}</p>")
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
.twitter-typeahead {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
';
|
||||
}
|
||||
else {
|
||||
$interval = $widget_settings['time_interval'];
|
||||
(integer) $lastpoll_seconds = ($interval * 60);
|
||||
(integer) $interface_count = $widget_settings['interface_count'];
|
||||
$params = array('user' => $_SESSION['user_id'], 'lastpoll' => array($lastpoll_seconds), 'count' => array($interface_count), 'filter' => ($widget_settings['interface_filter']?:(int)1));
|
||||
if (is_admin() || is_read()) {
|
||||
$query = '
|
||||
SELECT *, p.ifInOctets_rate + p.ifOutOctets_rate as total
|
||||
FROM ports as p
|
||||
INNER JOIN devices ON p.device_id = devices.device_id
|
||||
AND unix_timestamp() - p.poll_time <= :lastpoll
|
||||
AND ( p.ifType = :filter || 1 = :filter )
|
||||
AND ( p.ifInOctets_rate > 0 || p.ifOutOctets_rate > 0 )
|
||||
ORDER BY total DESC
|
||||
LIMIT :count
|
||||
';
|
||||
}
|
||||
else {
|
||||
$query = '
|
||||
SELECT ports.*, devices.hostname, ports.ifInOctets_rate + ports.ifOutOctets_rate as total
|
||||
FROM ports
|
||||
INNER JOIN devices ON ports.device_id = devices.device_id
|
||||
LEFT JOIN ports_perms ON ports.port_id = ports_perms.port_id
|
||||
LEFT JOIN devices_perms ON devices.device_id = devices_perms.device_id
|
||||
WHERE ( ports_perms.user_id = :user || devices_perms.user_id = :user )
|
||||
AND unix_timestamp() - ports.poll_time <= :lastpoll
|
||||
AND ( ports.ifType = :filter || 1 = :filter )
|
||||
AND ( ports.ifInOctets_rate > 0 || ports.ifOutOctets_rate > 0 )
|
||||
GROUP BY ports.port_id
|
||||
ORDER BY total DESC
|
||||
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).'</td>
|
||||
<td class="text-left">'.generate_port_link($result, generate_port_thumbnail($result)).'</td>
|
||||
</tr>
|
||||
';
|
||||
}
|
||||
$common_output[] = '
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
';
|
||||
}
|
||||
@@ -23,19 +23,72 @@
|
||||
*/
|
||||
|
||||
if ($config['map']['engine'] == 'leaflet') {
|
||||
|
||||
$temp_output = '
|
||||
if ((defined('show_settings') || empty($widget_settings)) && $config['front_page'] == "pages/front/tiles.php") {
|
||||
$temp_output = '
|
||||
<form class="form" onsubmit="widget_settings(this); return false;">
|
||||
<div class="form-group">
|
||||
<div class="col-sm-4">
|
||||
<label for="init_lat" class="control-label">Initial Latitude: </label>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<input class="form-control" name="init_lat" id="input_lat_'.$unique_id.'" value="'.$widget_settings['init_lat'].'" placeholder="ie. 51.4800 for Greenwich">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-4">
|
||||
<label for="init_lng" class="control-label">Initial Longitude: </label>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<input class="form-control" name="init_lng" id="input_lng_'.$unique_id.'" value="'.$widget_settings['init_lng'].'" placeholder="ie. 0 for Greenwich">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-4">
|
||||
<label for="init_zoom" class="control-label">Initial Zoom: </label>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<select class="form-control" name="init_zoom" id="select_zoom'.$unique_id.'">
|
||||
';
|
||||
for ($i=0; $i<19; $i++) {
|
||||
if ($i == $widget_settings['init_zoom']) {
|
||||
$temp_output .= '<option selected value="'.$i.'">'.$i.'</option>';
|
||||
}
|
||||
else {
|
||||
$temp_output .= '<option value="'.$i.'">'.$i.'</option>';
|
||||
}
|
||||
}
|
||||
$temp_output .= '
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-2">
|
||||
<button type="submit" class="btn btn-default">Set</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
';
|
||||
}
|
||||
else {
|
||||
$temp_output = '
|
||||
<script src="js/leaflet.js"></script>
|
||||
<script src="js/leaflet.markercluster-src.js"></script>
|
||||
<script src="js/leaflet.awesome-markers.min.js"></script>
|
||||
<div id="leaflet-map"></div>
|
||||
<script>
|
||||
';
|
||||
|
||||
$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.');
|
||||
|
||||
';
|
||||
if (!empty($widget_settings)) {
|
||||
$init_lat = $widget_settings['init_lat'];
|
||||
$init_lng = $widget_settings['init_lng'];
|
||||
$init_zoom = $widget_settings['init_zoom'];
|
||||
}
|
||||
elseif (isset($config['leaflet'])) {
|
||||
$init_lat = $config['leaflet']['default_lat'];
|
||||
$init_lng = $config['leaflet']['default_lng'];
|
||||
$init_zoom = $config['leaflet']['default_zoom'];
|
||||
}
|
||||
$map_init = "[" . $init_lat . ", " . $init_lng . "], " . sprintf("%01.0f", $init_zoom);
|
||||
$temp_output .= 'var map = L.map(\'leaflet-map\').setView('.$map_init.');
|
||||
L.tileLayer(\'//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png\', {
|
||||
attribution: \'© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors\'
|
||||
}).addTo(map);
|
||||
@@ -49,24 +102,49 @@ 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>';
|
||||
var marker = L.marker(new L.LatLng(".$map_devices['lat'].", ".$map_devices['lng']."), {title: title, icon: $icon});
|
||||
marker.bindPopup(title);
|
||||
markers.addLayer(marker);\n";
|
||||
}
|
||||
|
||||
$temp_output .= 'map.addLayer(markers);
|
||||
';
|
||||
// Checking user permissions
|
||||
if (is_admin() || is_read()) {
|
||||
// Admin or global read-only - show all devices
|
||||
$sql = "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`";
|
||||
}
|
||||
else {
|
||||
// Normal user - grab devices that user has permissions to
|
||||
$sql = "SELECT `devices`.`device_id` as `device_id`,`hostname`,`os`,`status`,`lat`,`lng`
|
||||
FROM `devices_perms`, `devices`
|
||||
LEFT JOIN `locations` ON `devices`.`location`=`locations`.`location`
|
||||
WHERE `disabled`=0 AND `ignore`=0 AND `lat` != '' AND `lng` != ''
|
||||
AND `devices`.`device_id` = `devices_perms`.`device_id`
|
||||
AND `devices_perms`.`user_id` = ?
|
||||
ORDER BY `status` ASC, `hostname`";
|
||||
}
|
||||
foreach (dbFetchRows($sql, array($_SESSION['user_id'])) 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>';
|
||||
var marker = L.marker(new L.LatLng(".$map_devices['lat'].", ".$map_devices['lng']."), {title: title, icon: $icon});
|
||||
marker.bindPopup(title);
|
||||
markers.addLayer(marker);\n";
|
||||
}
|
||||
$temp_output .= 'map.addLayer(markers);
|
||||
map.scrollWheelZoom.disable();
|
||||
$(document).ready(function(){
|
||||
$("#leaflet-map").on("click", function(event) {
|
||||
map.scrollWheelZoom.enable();
|
||||
});
|
||||
$("#leaflet-map").mouseleave(function(event) {
|
||||
map.scrollWheelZoom.disable();
|
||||
});
|
||||
});
|
||||
</script>';
|
||||
|
||||
} else {
|
||||
}
|
||||
}
|
||||
else {
|
||||
$temp_output = 'Mapael engine not supported here';
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/* Copyright (C) 2015 Daniel Preussker, QuxLabs UG <preussker@quxlabs.com>
|
||||
* 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.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/**
|
||||
* Create Dashboards
|
||||
* @author Daniel Preussker
|
||||
* @copyright 2015 Daniel Preussker, QuxLabs UG
|
||||
* @license GPL
|
||||
* @package LibreNMS
|
||||
* @subpackage Dashboards
|
||||
*/
|
||||
|
||||
$status = 'error';
|
||||
$message = 'unknown error';
|
||||
if (isset($_REQUEST['dashboard_name']) && ($dash_id = dbInsert(array('dashboard_name'=>$_REQUEST['dashboard_name'],'user_id'=>$_SESSION['user_id']),'dashboards'))) {
|
||||
$status = 'ok';
|
||||
$message = 'Created';
|
||||
}
|
||||
else {
|
||||
$status = 'error';
|
||||
$message = 'ERROR: Could not create';
|
||||
}
|
||||
|
||||
die(json_encode(array(
|
||||
'status' => $status,
|
||||
'message' => $message,
|
||||
'dashboard_id' => $dash_id
|
||||
)));
|
||||
|
||||
@@ -52,7 +52,7 @@ if(!empty($name)) {
|
||||
elseif( $_REQUEST['template'] && is_numeric($_REQUEST['template_id']) ) {
|
||||
//Update template-text
|
||||
|
||||
if($ret = dbUpdate(array('template' => $_REQUEST['template'], 'name' => $name), "alert_templates", "id = ?", array($_REQUEST['template_id']))) {
|
||||
if($ret = dbUpdate(array('template' => $_REQUEST['template'], 'name' => $name, 'title' => $_REQUEST['title'], 'title_rec' => $_REQUEST['title_rec']), "alert_templates", "id = ?", array($_REQUEST['template_id']))) {
|
||||
$ok = "Updated template";
|
||||
}
|
||||
else {
|
||||
@@ -62,7 +62,7 @@ if(!empty($name)) {
|
||||
elseif( $_REQUEST['template'] ) {
|
||||
//Create new template
|
||||
|
||||
if(dbInsert(array('template' => $_REQUEST['template'], 'name' => $name), "alert_templates")) {
|
||||
if(dbInsert(array('template' => $_REQUEST['template'], 'name' => $name, 'title' => $_REQUEST['title'], 'title_rec' => $_REQUEST['title_rec']), "alert_templates")) {
|
||||
$ok = "Alert template has been created.";
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/* Copyright (C) 2015 Daniel Preussker, QuxLabs UG <preussker@quxlabs.com>
|
||||
* 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.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/**
|
||||
* Delete Dashboards
|
||||
* @author Daniel Preussker
|
||||
* @copyright 2015 Daniel Preussker, QuxLabs UG
|
||||
* @license GPL
|
||||
* @package LibreNMS
|
||||
* @subpackage Dashboards
|
||||
*/
|
||||
|
||||
$status = 'error';
|
||||
$message = 'unknown error';
|
||||
if (isset($_REQUEST['dashboard_id'])) {
|
||||
dbDelete('users_widgets','user_id = ? && dashboard_id = ?',array($_SESSION['user_id'],$_REQUEST['dashboard_id']));
|
||||
if (dbDelete('dashboards','user_id = ? && dashboard_id = ?',array($_SESSION['user_id'],$_REQUEST['dashboard_id']))) {
|
||||
$status = 'ok';
|
||||
$message = 'Deleted dashboard';
|
||||
}
|
||||
else {
|
||||
$message = 'ERROR: Could not delete dashboard '.$_REQUEST['dashboard_id'];
|
||||
}
|
||||
}
|
||||
else {
|
||||
$message = 'ERROR: Not enough params';
|
||||
}
|
||||
|
||||
die(json_encode(array(
|
||||
'status' => $status,
|
||||
'message' => $message,
|
||||
)));
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/* Copyright (C) 2015 Daniel Preussker, QuxLabs UG <preussker@quxlabs.com>
|
||||
* 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.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/**
|
||||
* Edit Dashboards
|
||||
* @author Daniel Preussker
|
||||
* @copyright 2015 Daniel Preussker, QuxLabs UG
|
||||
* @license GPL
|
||||
* @package LibreNMS
|
||||
* @subpackage Dashboards
|
||||
*/
|
||||
|
||||
$status = 'error';
|
||||
$message = 'unknown error';
|
||||
if (isset($_REQUEST['dashboard_id']) && isset($_REQUEST['dashboard_name']) && isset($_REQUEST['access'])) {
|
||||
if(dbUpdate(array('dashboard_name'=>$_REQUEST['dashboard_name'],'access'=>$_REQUEST['access']),'dashboards','(user_id = ? || access = 2) && dashboard_id = ?',array($_SESSION['user_id'],$_REQUEST['dashboard_id']))) {
|
||||
$status = 'ok';
|
||||
$message = 'Updated dashboard';
|
||||
}
|
||||
else {
|
||||
$message = 'ERROR: Could not update dashboard '.$_REQUEST['dashboard_id'];
|
||||
}
|
||||
}
|
||||
else {
|
||||
$message = 'ERROR: Not enough params';
|
||||
}
|
||||
|
||||
die(json_encode(array(
|
||||
'status' => $status,
|
||||
'message' => $message,
|
||||
)));
|
||||
|
||||
@@ -21,8 +21,10 @@ $template_id = ($_POST['template_id']);
|
||||
if (is_numeric($template_id) && $template_id > 0) {
|
||||
$template = dbFetchRow('SELECT * FROM `alert_templates` WHERE `id` = ? LIMIT 1', array($template_id));
|
||||
$output = array(
|
||||
'template' => $template['template'],
|
||||
'name' => $template['name'],
|
||||
'template' => $template['template'],
|
||||
'name' => $template['name'],
|
||||
'title' => $template['title'],
|
||||
'title_rec' => $template['title_rec'],
|
||||
);
|
||||
echo _json_encode($output);
|
||||
}
|
||||
|
||||
@@ -18,31 +18,32 @@ if (is_admin() === false) {
|
||||
|
||||
$transport = mres($_POST['transport']);
|
||||
|
||||
require_once $config['install_dir'].'/includes/alerts.inc.php';
|
||||
$tmp = array(dbFetchRow('select device_id,hostname from devices order by device_id asc limit 1'));
|
||||
$tmp['contacts'] = GetContacts($tmp);
|
||||
$obj = array(
|
||||
'contacts' => $config['alert']['default_mail'],
|
||||
'title' => 'Testing transport from ' . $config['project_name'],
|
||||
'msg' => 'This is a test alert',
|
||||
'severity' => 'critical',
|
||||
'state' => 'critical',
|
||||
'hostname' => 'testing',
|
||||
'name' => 'Testing rule',
|
||||
"hostname" => $tmp[0]['hostname'],
|
||||
"device_id" => $tmp[0]['device_id'],
|
||||
"title" => "Testing transport from ".$config['project_name'],
|
||||
"elapsed" => "11s",
|
||||
"id" => "000",
|
||||
"faults" => false,
|
||||
"uid" => "000",
|
||||
"severity" => "critical",
|
||||
"rule" => "%macros.device = 1",
|
||||
"name" => "Test-Rule",
|
||||
"timestamp" => date("Y-m-d H:i:s"),
|
||||
"contacts" => $tmp['contacts'],
|
||||
"state" => "1",
|
||||
"msg" => "This is a test alert",
|
||||
);
|
||||
|
||||
unset($obj);
|
||||
$obj['contacts'] = 'test';
|
||||
$obj['title'] = 'test';
|
||||
$obj['msg'] = 'test';
|
||||
$obj['severity'] = 'test';
|
||||
$obj['state'] = 'test';
|
||||
$obj['hostname'] = 'test';
|
||||
$obj['name'] = 'test';
|
||||
|
||||
$status = 'error';
|
||||
|
||||
if (file_exists($config['install_dir']."/includes/alerts/transport.$transport.php")) {
|
||||
if (file_exists($config['install_dir']."/includes/alerts/transport.".$transport.".php")) {
|
||||
$opts = $config['alert']['transports'][$transport];
|
||||
if ($opts) {
|
||||
eval('$tmp = function($obj,$opts) { global $config; '.file_get_contents($config['install_dir'].'/includes/alerts/transport.'.$transport.'.php').' };');
|
||||
eval('$tmp = function($obj,$opts) { global $config; '.file_get_contents($config['install_dir'].'/includes/alerts/transport.'.$transport.'.php').' return false; };');
|
||||
$tmp = $tmp($obj,$opts);
|
||||
if ($tmp) {
|
||||
$status = 'ok';
|
||||
|
||||
@@ -6,49 +6,65 @@ $message = 'Error updating user dashboard config';
|
||||
$data = json_decode($_POST['data'],true);
|
||||
$sub_type = mres($_POST['sub_type']);
|
||||
$widget_id = mres($_POST['widget_id']);
|
||||
$dasboard_id = mres($_POST['dashboard_id']);
|
||||
|
||||
if ($sub_type == 'remove' && is_numeric($widget_id)) {
|
||||
if ($widget_id == 0 || dbDelete('users_widgets','`user_id`=? AND `user_widget_id`=?', array($_SESSION['user_id'],$widget_id))) {
|
||||
$status = 'ok';
|
||||
$message = '';
|
||||
if (dbFetchCell('select 1 from dashboards where (user_id = ? || access = 2) && dashboard_id = ?',array($_SESSION['user_id'],$dasboard_id)) == 1) {
|
||||
if ($widget_id == 0 || dbDelete('users_widgets','`user_widget_id`=? AND `dashboard_id`=?', array($widget_id,$dasboard_id))) {
|
||||
$status = 'ok';
|
||||
$message = '';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$status = 'error';
|
||||
$message = 'ERROR: You have no write access.';
|
||||
}
|
||||
}
|
||||
elseif ($sub_type == 'remove-all') {
|
||||
if (dbDelete('users_widgets','`user_id`=?', array($_SESSION['user_id']))) {
|
||||
$status = 'ok';
|
||||
$message = '';
|
||||
if (dbFetchCell('select 1 from dashboards where (user_id = ? || access = 2) && dashboard_id = ?',array($_SESSION['user_id'],$dasboard_id)) == 1) {
|
||||
if (dbDelete('users_widgets','`dashboard_id`=?', array($dasboard_id))) {
|
||||
$status = 'ok';
|
||||
$message = '';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$status = 'error';
|
||||
$message = 'ERROR: You have no write access.';
|
||||
}
|
||||
}
|
||||
elseif ($sub_type == 'add' && is_numeric($widget_id)) {
|
||||
$dupe_check = dbFetchCEll('SELECT `user_widget_id` FROM `users_widgets` WHERE `user_id`=? AND `widget_id`=?',array($_SESSION['user_id'],$widget_id));
|
||||
|
||||
if (is_numeric($dupe_check)) {
|
||||
$message = 'This widget has already been added';
|
||||
}
|
||||
else {
|
||||
|
||||
if (dbFetchCell('select 1 from dashboards where (user_id = ? || access = 2) && dashboard_id = ?',array($_SESSION['user_id'],$dasboard_id)) == 1) {
|
||||
$widget = dbFetchRow('SELECT * FROM `widgets` WHERE `widget_id`=?', array($widget_id));
|
||||
if (is_array($widget)) {
|
||||
list($x,$y) = explode(',',$widget['base_dimensions']);
|
||||
$item_id = dbInsert(array('user_id'=>$_SESSION['user_id'],'widget_id'=>$widget_id, 'col'=>1,'row'=>1,'refresh'=>60,'title'=>$widget['widget_title'],'size_x'=>$x,'size_y'=>$y),'users_widgets');
|
||||
$item_id = dbInsert(array('user_id'=>$_SESSION['user_id'],'widget_id'=>$widget_id, 'col'=>1,'row'=>1,'refresh'=>60,'title'=>$widget['widget_title'],'size_x'=>$x,'size_y'=>$y,'settings'=>'','dashboard_id'=>$dasboard_id),'users_widgets');
|
||||
if (is_numeric($item_id)) {
|
||||
$extra = array('widget_id'=>$item_id,'title'=>$widget['widget_title'],'widget'=>$widget['widget'],'size_x'=>$x,'size_y'=>$y);
|
||||
$extra = array('user_widget_id'=>$item_id,'widget_id'=>$item_id,'title'=>$widget['widget_title'],'widget'=>$widget['widget'],'refresh'=>60,'size_x'=>$x,'size_y'=>$y);
|
||||
$status = 'ok';
|
||||
$message = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$status = 'error';
|
||||
$message = 'ERROR: You have no write access.';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$status = 'ok';
|
||||
$message = '';
|
||||
|
||||
foreach ($data as $line) {
|
||||
if (is_array($line)) {
|
||||
$update = array('col'=>$line['col'],'row'=>$line['row'],'size_x'=>$line['size_x'],'size_y'=>$line['size_y']);
|
||||
dbUpdate($update, 'users_widgets', '`user_widget_id`=?', array($line['id']));
|
||||
if (dbFetchCell('select 1 from dashboards where (user_id = ? || access = 2) && dashboard_id = ?',array($_SESSION['user_id'],$dasboard_id)) == 1) {
|
||||
$status = 'ok';
|
||||
$message = '';
|
||||
foreach ($data as $line) {
|
||||
if (is_array($line)) {
|
||||
$update = array('col'=>$line['col'],'row'=>$line['row'],'size_x'=>$line['size_x'],'size_y'=>$line['size_y']);
|
||||
dbUpdate($update, 'users_widgets', '`user_widget_id`=? AND `dashboard_id`=?', array($line['id'],$dasboard_id));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$status = 'error';
|
||||
$message = 'ERROR: You have no write access.';
|
||||
}
|
||||
}
|
||||
|
||||
$response = array(
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* LibreNMS
|
||||
*
|
||||
* Copyright (c) 2014 Neil Lathwood <https://github.com/laf/ http://www.lathwood.co.uk/fa>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
$status = 'error';
|
||||
|
||||
$descr = mres($_POST['descr']);
|
||||
$device_id = mres($_POST['device_id']);
|
||||
$ifName = mres($_POST['ifName']);
|
||||
$port_id = mres($_POST['port_id']);
|
||||
|
||||
logfile($descr . ','. $device_id . ','. $ifName. ','. $port_id);
|
||||
|
||||
if (!empty($ifName) && is_numeric($port_id)) {
|
||||
// We have ifName and port id so update ifAlias
|
||||
if (empty($descr)) {
|
||||
$descr = 'repoll';
|
||||
// Set to repoll so we avoid using ifDescr on port poll
|
||||
}
|
||||
if (dbUpdate(array('ifAlias'=>$descr), 'ports', '`port_id`=?', array($port_id)) > 0) {
|
||||
$device = device_by_id_cache($device_id);
|
||||
if ($descr === 'repoll') {
|
||||
del_dev_attrib($device, 'ifName');
|
||||
}
|
||||
else {
|
||||
set_dev_attrib($device, 'ifName', $ifName);
|
||||
}
|
||||
$status = 'ok';
|
||||
}
|
||||
else {
|
||||
$status = 'na';
|
||||
}
|
||||
}
|
||||
|
||||
$response = array(
|
||||
'status' => $status,
|
||||
);
|
||||
echo _json_encode($response);
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/*
|
||||
* LibreNMS
|
||||
*
|
||||
* Copyright (c) 2015 Søren Friis Rosiak <sorenrosiak@gmail.com>
|
||||
* 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.
|
||||
*/
|
||||
|
||||
$status = 'error';
|
||||
$message = 'unknown error';
|
||||
|
||||
$device_id = mres($_POST['device_id']);
|
||||
$notes = mres($_POST['notes']);
|
||||
|
||||
if (isset($notes) && (dbUpdate(array('notes' => $notes), 'devices', 'device_id = ?', array($device_id)))) {
|
||||
$status = 'ok';
|
||||
$message = 'Updated';
|
||||
}
|
||||
else {
|
||||
$status = 'error';
|
||||
$message = 'ERROR: Could not update';
|
||||
}
|
||||
die(json_encode(array(
|
||||
'status' => $status,
|
||||
'message' => $message,
|
||||
'notes' => $notes,
|
||||
'device_id' => $device_id
|
||||
)));
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/* Copyright (C) 2015 Daniel Preussker, QuxLabs UG <preussker@quxlabs.com>
|
||||
* 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.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/**
|
||||
* Store per-widget settings
|
||||
* @author Daniel Preussker
|
||||
* @copyright 2015 Daniel Preussker, QuxLabs UG
|
||||
* @license GPL
|
||||
* @package LibreNMS
|
||||
* @subpackage Widgets
|
||||
*/
|
||||
|
||||
$status = 'error';
|
||||
$message = 'unknown error';
|
||||
$widget_id = (int) $_REQUEST['id'];
|
||||
|
||||
if ($widget_id < 1) {
|
||||
$status = 'error';
|
||||
$message = 'ERROR: malformed widget ID.';
|
||||
}
|
||||
else {
|
||||
$widget_settings = $_REQUEST['settings'];
|
||||
if (!is_array($widget_settings)) {
|
||||
$widget_settings = array();
|
||||
}
|
||||
if (dbFetchCell('select 1 from users_widgets inner join dashboards on users_widgets.dashboard_id = dashboards.dashboard_id where user_widget_id = ? && (users_widgets.user_id = ? || dashboards.access = 2)',array($widget_id,$_SESSION['user_id'])) == 1) {
|
||||
if (dbUpdate(array('settings'=>json_encode($widget_settings)),'users_widgets','user_widget_id=?',array($widget_id))) {
|
||||
$status = 'ok';
|
||||
$message = 'Updated';
|
||||
}
|
||||
else {
|
||||
$status = 'error';
|
||||
$message = 'ERROR: Could not update';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$status = 'error';
|
||||
$message = 'ERROR: You have no write-access to this dashboard';
|
||||
}
|
||||
}
|
||||
|
||||
die(json_encode(array(
|
||||
'status' => $status,
|
||||
'message' => $message
|
||||
)));
|
||||
@@ -12,6 +12,35 @@
|
||||
* @copyright (C) 2013 LibreNMS Group
|
||||
*/
|
||||
|
||||
/**
|
||||
* Compare $t with the value of $vars[$v], if that exists
|
||||
* @param string $v Name of the var to test
|
||||
* @param string $t Value to compare $vars[$v] to
|
||||
* @return boolean true, if values are the same, false if $vars[$v] is unset or values differ
|
||||
*/
|
||||
function var_eq($v, $t) {
|
||||
global $vars;
|
||||
if (isset($vars[$v]) && $vars[$v] == $t) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of $vars[$v], if it exists
|
||||
* @param string $v Name of the var to get
|
||||
* @return string|boolean The value of $vars[$v] if it exists, false if it does not exist
|
||||
*/
|
||||
function var_get($v) {
|
||||
global $vars;
|
||||
if (isset($vars[$v])) {
|
||||
return $vars[$v];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function data_uri($file, $mime) {
|
||||
$contents = file_get_contents($file);
|
||||
@@ -152,8 +181,8 @@ function get_percentage_colours($percentage) {
|
||||
}//end get_percentage_colours()
|
||||
|
||||
|
||||
function generate_minigraph_image($device, $start, $end, $type, $legend='no', $width=275, $height=100, $sep='&', $class='minigraph-image') {
|
||||
return '<img class="'.$class.'" src="graph.php?'.implode($sep, array('device='.$device['device_id'], "from=$start", "to=$end", "width=$width", "height=$height", "type=$type", "legend=$legend")).'">';
|
||||
function generate_minigraph_image($device, $start, $end, $type, $legend='no', $width=275, $height=100, $sep='&', $class='minigraph-image',$absolute_size=0) {
|
||||
return '<img class="'.$class.'" src="graph.php?'.implode($sep, array('device='.$device['device_id'], "from=$start", "to=$end", "width=$width", "height=$height", "type=$type", "legend=$legend", "absolute=$absolute_size")).'">';
|
||||
|
||||
}//end generate_minigraph_image()
|
||||
|
||||
|
||||
@@ -3,7 +3,12 @@
|
||||
if (is_numeric($vars['id']) && ($auth || application_permitted($vars['id']))) {
|
||||
$app = get_application_by_id($vars['id']);
|
||||
$device = device_by_id_cache($app['device_id']);
|
||||
$title = generate_device_link($device);
|
||||
$title .= $graph_subtype;
|
||||
if ($app['app_type'] != 'proxmox') {
|
||||
$title = generate_device_link($device);
|
||||
$title .= $graph_subtype;
|
||||
}
|
||||
else {
|
||||
$title = $vars['port'].'@'.$vars['hostname'].' on '.generate_device_link($device);
|
||||
}
|
||||
$auth = true;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2015 Mark Schouten <mark@tuxis.nl>
|
||||
*
|
||||
* 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; version 2 dated June,
|
||||
* 1991.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* See http://www.gnu.org/licenses/gpl.txt for the full license
|
||||
*/
|
||||
|
||||
require 'includes/graphs/common.inc.php';
|
||||
|
||||
$proxmox_rrd = $config['rrd_dir'].'/proxmox/'.$vars['cluster'].'/'.$vars['vmid'].'_netif_'.$vars['port'].'.rrd';
|
||||
|
||||
if (is_file($proxmox_rrd)) {
|
||||
$rrd_filename = $proxmox_rrd;
|
||||
}
|
||||
|
||||
$ds_in = 'INOCTETS';
|
||||
$ds_out = 'OUTOCTETS';
|
||||
|
||||
require 'includes/graphs/generic_data.inc.php';
|
||||
@@ -103,3 +103,7 @@ else {
|
||||
}
|
||||
|
||||
$rrd_options .= ' --font-render-mode normal';
|
||||
|
||||
if (isset($_GET['absolute']) && $_GET['absolute'] == "1") {
|
||||
$rrd_options .= ' --full-size-mode';
|
||||
}
|
||||
|
||||
@@ -51,6 +51,8 @@ if(is_admin() === false) {
|
||||
<textarea class="form-control" id="template" name="template" rows="15"></textarea><br /><br />
|
||||
<strong><em>Give your template a name: </em></strong><br />
|
||||
<input type="text" class="form-control input-sm" id="name" name="name"><br />
|
||||
<em>Optionally, add custom titles: </em><br />
|
||||
<input type="text" class="form-control input-sm" id="title" name="title" placeholder="Alert Title"><input type="text" class="form-control input-sm" id="title_rec" name="title_rec" placeholder="Recovery Title"><br />
|
||||
<span id="error"></span><br />
|
||||
<button type="button" class="btn btn-primary btn-sm" name="create-template" id="create-template">Create template</button>
|
||||
</div>
|
||||
@@ -113,6 +115,8 @@ $('#alert-template').on('show.bs.modal', function (event) {
|
||||
success: function(output) {
|
||||
$('#template').val(output['template']);
|
||||
$('#name').val(output['name']);
|
||||
$('#title').val(output['title']);
|
||||
$('#title_rec').val(output['title_rec']);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -123,10 +127,12 @@ $('#create-template').click('', function(e) {
|
||||
var template = $("#template").val();
|
||||
var template_id = $("#template_id").val();
|
||||
var name = $("#name").val();
|
||||
var title = $("#title").val();
|
||||
var title_rec = $("#title_rec").val();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "ajax_form.php",
|
||||
data: { type: "alert-templates", template: template , name: name, template_id: template_id},
|
||||
data: { type: "alert-templates", template: template , name: name, template_id: template_id, title: title, title_rec: title_rec},
|
||||
dataType: "html",
|
||||
success: function(msg){
|
||||
if(msg.indexOf("ERROR:") <= -1) {
|
||||
|
||||
@@ -107,7 +107,7 @@ echo '<div class="table-responsive">
|
||||
|
||||
echo '<td colspan="7">';
|
||||
if ($_SESSION['userlevel'] >= '10') {
|
||||
echo '<button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#create-alert" data-device_id="'.$device['device_id'].'">Create new alert rule</button>';
|
||||
echo '<button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#create-alert" data-device_id="'.$device['device_id'].'"><i class="fa fa-plus"></i> Create new alert rule</button>';
|
||||
}
|
||||
|
||||
echo '</td>
|
||||
|
||||
@@ -233,7 +233,7 @@ if (strpos($port['label'], 'oopback') === false && !$graph_type) {
|
||||
}//end foreach
|
||||
}//end if
|
||||
|
||||
if ($port_details && $config['enable_port_relationship'] === true) {
|
||||
if ($port_details && $config['enable_port_relationship'] === true && port_permitted($int_link,$device['device_id'])) {
|
||||
foreach ($int_links as $int_link) {
|
||||
$link_if = dbFetchRow('SELECT * from ports AS I, devices AS D WHERE I.device_id = D.device_id and I.port_id = ?', array($int_link));
|
||||
|
||||
@@ -263,7 +263,7 @@ if (strpos($port['label'], 'oopback') === false && !$graph_type) {
|
||||
// unset($int_links, $int_links_v6, $int_links_v4, $int_links_phys, $br);
|
||||
}//end if
|
||||
|
||||
if ($port_details && $config['enable_port_relationship'] === true) {
|
||||
if ($port_details && $config['enable_port_relationship'] === true && port_permitted($port['port_id'], $device['device_id'])) {
|
||||
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']));
|
||||
|
||||
@@ -89,6 +89,15 @@ if (isset($config['graylog']['server']) && isset($config['graylog']['port'])) {
|
||||
|
||||
?>
|
||||
<li><a href="<?php echo(generate_url(array('page'=>'inventory'))); ?>"><i class="fa fa-cube fa-fw fa-lg"></i> Inventory</a></li>
|
||||
<?php
|
||||
if ( dbFetchCell("SELECT 1 from `packages` LIMIT 1") ) {
|
||||
?>
|
||||
<li>
|
||||
<a href="<?php echo(generate_url(array('page'=>'search','search'=>'packages'))); ?>"><i class="fa fa-archive fa-fw fa-lg fa-nav-icons"></i> Packages</a>
|
||||
</li>
|
||||
<?php
|
||||
} # if ($packages)
|
||||
?>
|
||||
<li role="presentation" class="divider"></li>
|
||||
<li role="presentation" class="dropdown-header"> Search</li>
|
||||
<li><a href="<?php echo(generate_url(array('page'=>'search','search'=>'ipv4'))); ?>"><i class="fa fa-search fa-fw fa-lg"></i> IPv4 Search</a></li>
|
||||
@@ -351,21 +360,32 @@ foreach (array_keys($menu_sensors) as $item) {
|
||||
</li>
|
||||
<?php
|
||||
|
||||
$app_count = dbFetchCell("SELECT COUNT(`app_id`) FROM `applications`");
|
||||
$app_list = dbFetchRows("SELECT DISTINCT(`app_type`) AS `app_type` FROM `applications` ORDER BY `app_type`");
|
||||
|
||||
if ($_SESSION['userlevel'] >= '5' && ($app_count) > "0") {
|
||||
if ($_SESSION['userlevel'] >= '5' && count($app_list) > "0") {
|
||||
?>
|
||||
<li class="dropdown">
|
||||
<a href="apps/" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown"><i class="fa fa-tasks fa-fw fa-lg fa-nav-icons"></i> Apps</a>
|
||||
<ul class="dropdown-menu">
|
||||
<?php
|
||||
|
||||
$app_list = dbFetchRows("SELECT `app_type` FROM `applications` GROUP BY `app_type` ORDER BY `app_type`");
|
||||
foreach ($app_list as $app) {
|
||||
if (isset($app['app_type'])) {
|
||||
$app_i_list = dbFetchRows("SELECT DISTINCT(`app_instance`) FROM `applications` WHERE `app_type` = ? ORDER BY `app_instance`", array($app['app_type']));
|
||||
$image = $config['html_dir']."/images/icons/".$app['app_type'].".png";
|
||||
$icon = (file_exists($image) ? $app['app_type'] : "apps");
|
||||
echo('<li><a href="apps/app='.$app['app_type'].'/"><i class="fa fa-angle-double-right fa-fw fa-lg"></i> '.nicecase($app['app_type']).' </a></li>');
|
||||
if (count($app_i_list) > 1) {
|
||||
echo '<li class="dropdown-submenu">';
|
||||
echo '<a href="apps/app='.$app['app_type'].'/"><i class="fa fa-server fa-fw fa-lg"></i> '.nicecase($app['app_type']).' </a>';
|
||||
echo '<ul class="dropdown-menu scrollable-menu">';
|
||||
foreach ($app_i_list as $instance) {
|
||||
echo ' <li><a href="apps/app='.$app['app_type'].'/instance='.$instance['app_instance'].'/"><i class="fa fa-angle-double-right fa-fw fa-lg"></i> ' . nicecase($instance['app_instance']) . '</a></li>';
|
||||
}
|
||||
echo '</ul></li>';
|
||||
}
|
||||
else {
|
||||
echo('<li><a href="apps/app='.$app['app_type'].'/"><i class="fa fa-angle-double-right fa-fw fa-lg"></i> '.nicecase($app['app_type']).' </a></li>');
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -427,14 +447,6 @@ if ($_SESSION['userlevel'] >= '5' && ($routing_count['bgp']+$routing_count['ospf
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
if ( dbFetchCell("SELECT 1 from `packages` LIMIT 1") ) {
|
||||
?>
|
||||
<li>
|
||||
<a href="<?php echo(generate_url(array('page'=>'search','search'=>'packages'))); ?>"><i class="fa fa-archive fa-fw fa-lg fa-nav-icons"></i> Packages</a>
|
||||
</li>
|
||||
<?php
|
||||
} # if ($packages)
|
||||
?>
|
||||
|
||||
<li class="dropdown">
|
||||
@@ -497,7 +509,7 @@ if ($_SESSION['userlevel'] >= '10') {
|
||||
<li class="dropdown-submenu">
|
||||
<a href="#"><i class="fa fa-clock-o fa-fw fa-lg"></i> Pollers</a>
|
||||
<ul class="dropdown-menu scrollable-menu">
|
||||
<li><a href="poll-log/"><i class="fa fa-exclamation fa-fw fa-lg"></i> Poll-log</a></li>');
|
||||
<li><a href="poll-log/"><i class="fa fa-list-alt fa-fw fa-lg"></i> Poll-log</a></li>');
|
||||
|
||||
if($config['distributed_poller'] === TRUE) {
|
||||
echo ('
|
||||
|
||||
@@ -64,7 +64,7 @@ foreach (dbFetchRows($sql, $param) as $port) {
|
||||
<input type="hidden" name="olddis_'.$port['port_id'].'" value="'.($port['disabled'] ? 1 : 0).'"">',
|
||||
'ignore' => '<input type="checkbox" class="ignore-check" name="ignore_'.$port['port_id'].'"'.($port['ignore'] ? 'checked' : '').'>
|
||||
<input type="hidden" name="oldign_'.$port['port_id'].'" value="'.($port['ignore'] ? 1 : 0).'"">',
|
||||
'ifAlias' => $port['ifAlias']
|
||||
'ifAlias' => '<div class="form-group"><input class="form-control input-sm" id="if-alias" name="if-alias" data-device_id="'.$port['device_id'].'" data-port_id="'.$port['port_id'].'" data-ifName="'.$port['ifName'].'" value="'.$port['ifAlias'].'"><span class="glyphicon form-control-feedback" aria-hidden="true"></span></div>'
|
||||
);
|
||||
|
||||
}//end foreach
|
||||
@@ -75,4 +75,4 @@ $output = array(
|
||||
'rows' => $response,
|
||||
'total' => $total,
|
||||
);
|
||||
echo _json_encode($output);
|
||||
echo _json_encode($output);
|
||||
|
||||
Reference in New Issue
Block a user