mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Fix coding style part 2
This commit is contained in:
@@ -13,32 +13,28 @@
|
||||
*/
|
||||
|
||||
// FUA
|
||||
|
||||
if (isset($_REQUEST['debug']))
|
||||
{
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 0);
|
||||
ini_set('log_errors', 0);
|
||||
ini_set('allow_url_fopen', 0);
|
||||
ini_set('error_reporting', E_ALL);
|
||||
if (isset($_REQUEST['debug'])) {
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 0);
|
||||
ini_set('log_errors', 0);
|
||||
ini_set('allow_url_fopen', 0);
|
||||
ini_set('error_reporting', E_ALL);
|
||||
}
|
||||
|
||||
include_once("../includes/defaults.inc.php");
|
||||
include_once("../config.php");
|
||||
include_once("../includes/definitions.inc.php");
|
||||
include_once("includes/functions.inc.php");
|
||||
include_once("../includes/functions.php");
|
||||
include_once("includes/authenticate.inc.php");
|
||||
|
||||
if (!$_SESSION['authenticated']) { echo("unauthenticated"); exit; }
|
||||
|
||||
if(preg_match("/^[a-zA-Z0-9\-]+$/", $_POST['type']) == 1) {
|
||||
|
||||
if(file_exists('forms/'.$_POST['type'].'.inc.php'))
|
||||
{
|
||||
include_once('forms/'.$_POST['type'].'.inc.php');
|
||||
}
|
||||
require_once '../includes/defaults.inc.php';
|
||||
require_once '../config.php';
|
||||
require_once '../includes/definitions.inc.php';
|
||||
require_once 'includes/functions.inc.php';
|
||||
require_once '../includes/functions.php';
|
||||
require_once 'includes/authenticate.inc.php';
|
||||
|
||||
if (!$_SESSION['authenticated']) {
|
||||
echo 'unauthenticated';
|
||||
exit;
|
||||
}
|
||||
|
||||
?>
|
||||
if (preg_match('/^[a-zA-Z0-9\-]+$/', $_POST['type']) == 1) {
|
||||
if (file_exists('forms/'.$_POST['type'].'.inc.php')) {
|
||||
include_once 'forms/'.$_POST['type'].'.inc.php';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,39 +9,36 @@
|
||||
* @subpackage ajax
|
||||
* @author Adam Armstrong <adama@memetic.org>
|
||||
* @copyright (C) 2006 - 2012 Adam Armstrong
|
||||
*
|
||||
*/
|
||||
|
||||
if (isset($_GET['debug']))
|
||||
{
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 0);
|
||||
ini_set('log_errors', 0);
|
||||
ini_set('allow_url_fopen', 0);
|
||||
ini_set('error_reporting', E_ALL);
|
||||
if (isset($_GET['debug'])) {
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 0);
|
||||
ini_set('log_errors', 0);
|
||||
ini_set('allow_url_fopen', 0);
|
||||
ini_set('error_reporting', E_ALL);
|
||||
}
|
||||
|
||||
include_once("../includes/defaults.inc.php");
|
||||
include_once("../config.php");
|
||||
include_once("../includes/definitions.inc.php");
|
||||
include_once("includes/functions.inc.php");
|
||||
include_once("../includes/dbFacile.php");
|
||||
include_once("../includes/common.php");
|
||||
require_once '../includes/defaults.inc.php';
|
||||
require_once '../config.php';
|
||||
require_once '../includes/definitions.inc.php';
|
||||
require_once 'includes/functions.inc.php';
|
||||
require_once '../includes/dbFacile.php';
|
||||
require_once '../includes/common.php';
|
||||
|
||||
include_once("../includes/rewrites.php");
|
||||
include_once("includes/authenticate.inc.php");
|
||||
require_once '../includes/rewrites.php';
|
||||
require_once 'includes/authenticate.inc.php';
|
||||
|
||||
if (!$_SESSION['authenticated']) { echo("unauthenticated"); exit; }
|
||||
|
||||
if (is_numeric($_GET['device_id']))
|
||||
{
|
||||
foreach (dbFetch("SELECT * FROM ports WHERE device_id = ?", array($_GET['device_id'])) as $interface)
|
||||
{
|
||||
$interface = ifNameDescr($interface);
|
||||
$string = mres($interface['label']." - ".$interface['ifAlias']);
|
||||
echo("obj.options[obj.options.length] = new Option('".$string."','".$interface['port_id']."');\n");
|
||||
#echo("obj.options[obj.options.length] = new Option('".$interface['ifDescr']." - ".$interface['ifAlias']."','".$interface['port_id']."');\n");
|
||||
}
|
||||
if (!$_SESSION['authenticated']) {
|
||||
echo 'unauthenticated';
|
||||
exit;
|
||||
}
|
||||
|
||||
?>
|
||||
if (is_numeric($_GET['device_id'])) {
|
||||
foreach (dbFetch('SELECT * FROM ports WHERE device_id = ?', array($_GET['device_id'])) as $interface) {
|
||||
$interface = ifNameDescr($interface);
|
||||
$string = mres($interface['label'].' - '.$interface['ifAlias']);
|
||||
echo "obj.options[obj.options.length] = new Option('".$string."','".$interface['port_id']."');\n";
|
||||
// echo("obj.options[obj.options.length] = new Option('".$interface['ifDescr']." - ".$interface['ifAlias']."','".$interface['port_id']."');\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
<?php
|
||||
/* Copyright (C) 2014 Daniel Preussker <f0o@devilcode.org>
|
||||
/*
|
||||
* Copyright (C) 2014 Daniel Preussker <f0o@devilcode.org>
|
||||
* 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/>. */
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* Rule Suggestion-AJAX
|
||||
* @author Daniel Preussker <f0o@devilcode.org>
|
||||
* @copyright 2014 f0o, LibreNMS
|
||||
@@ -22,103 +24,123 @@
|
||||
*/
|
||||
|
||||
session_start();
|
||||
if( !isset($_SESSION['authenticated']) ) {
|
||||
die("Unauthorized.");
|
||||
if (!isset($_SESSION['authenticated'])) {
|
||||
die('Unauthorized.');
|
||||
}
|
||||
|
||||
require_once("../includes/defaults.inc.php");
|
||||
require_once("../config.php");
|
||||
require_once("../includes/definitions.inc.php");
|
||||
require_once("../includes/functions.php");
|
||||
require_once '../includes/defaults.inc.php';
|
||||
require_once '../config.php';
|
||||
require_once '../includes/definitions.inc.php';
|
||||
require_once '../includes/functions.php';
|
||||
|
||||
|
||||
/**
|
||||
* Levenshtein Sort
|
||||
* @param string $base Comparisson basis
|
||||
* @param array $obj Object to sort
|
||||
* @param array $obj Object to sort
|
||||
* @return array
|
||||
*/
|
||||
function levsort($base, $obj) {
|
||||
$ret = array();
|
||||
foreach( $obj as $elem ) {
|
||||
$lev = levenshtein($base, $elem, 1, 10, 10);
|
||||
if( $lev == 0 ) {
|
||||
return array(array('name'=>$elem));
|
||||
} else {
|
||||
while( isset($ret["$lev"]) ) {
|
||||
$lev += 0.1;
|
||||
}
|
||||
$ret["$lev"] = array('name'=>$elem);
|
||||
}
|
||||
}
|
||||
ksort($ret);
|
||||
return $ret;
|
||||
$ret = array();
|
||||
foreach ($obj as $elem) {
|
||||
$lev = levenshtein($base, $elem, 1, 10, 10);
|
||||
if ($lev == 0) {
|
||||
return array(array('name' => $elem));
|
||||
}
|
||||
else {
|
||||
while (isset($ret["$lev"])) {
|
||||
$lev += 0.1;
|
||||
}
|
||||
|
||||
$ret["$lev"] = array('name' => $elem);
|
||||
}
|
||||
}
|
||||
|
||||
ksort($ret);
|
||||
return $ret;
|
||||
|
||||
}
|
||||
|
||||
$obj = array(array('name'=>'Error: No suggestions found.'));
|
||||
$term = array();
|
||||
|
||||
$obj = array(array('name' => 'Error: No suggestions found.'));
|
||||
$term = array();
|
||||
$current = false;
|
||||
if( isset($_GET['term'],$_GET['device_id']) ) {
|
||||
$chk = array();
|
||||
$_GET['term'] = mres($_GET['term']);
|
||||
$_GET['device_id'] = mres($_GET['device_id']);
|
||||
if( strstr($_GET['term'],".") ) {
|
||||
$term = explode(".",$_GET['term']);
|
||||
if( $config['memcached']['enable'] ) {
|
||||
$chk = $memcache->get('rule-suggest_'.$term[0]);
|
||||
}
|
||||
if( !(sizeof($chk) > 0) || $chk === false ) {
|
||||
if( $term[0] == "macros" ) {
|
||||
foreach( $config['alert']['macros']['rule'] as $macro=>$v ) {
|
||||
$chk[] = "macros.".$macro;
|
||||
}
|
||||
} else {
|
||||
$tmp = dbFetchRows('SHOW COLUMNS FROM '.$term[0]);
|
||||
foreach( $tmp as $tst ) {
|
||||
if( isset($tst['Field']) ) {
|
||||
$chk[] = $term[0].'.'.$tst['Field'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$current = true;
|
||||
} else {
|
||||
if( $config['memcached']['enable'] ) {
|
||||
$chk = $memcache->get('rule-suggest-toplvl');
|
||||
}
|
||||
if( !(sizeof($chk) > 0) || $chk === false ) {
|
||||
$tmp = dbFetchRows("SELECT TABLE_NAME FROM information_schema.COLUMNS WHERE COLUMN_NAME = 'device_id'");
|
||||
foreach( $tmp as $tst ) {
|
||||
$chk[] = $tst['TABLE_NAME'].'.';
|
||||
}
|
||||
$chk[] = 'macros.';
|
||||
$chk[] = 'bills.';
|
||||
}
|
||||
}
|
||||
if( sizeof($chk) > 0 ) {
|
||||
if( $config['memcached']['enable'] ) {
|
||||
$memcache->set('rule-suggest-'.$oterm,$chk,86400); //Cache for 24h
|
||||
}
|
||||
$obj = levsort($_GET['term'],$chk);
|
||||
$obj = array_chunk($obj,20,true);
|
||||
$obj = $obj[0];
|
||||
$flds = array();
|
||||
if( $current == true ) {
|
||||
foreach( $obj as $fld ) {
|
||||
$flds[] = $fld['name'];
|
||||
}
|
||||
$qry = dbFetchRows("SELECT ".implode(", ",$flds)." FROM ".$term[0]." WHERE device_id = ?", array($_GET['device_id']));
|
||||
$ret = array();
|
||||
foreach( $obj as $lev=>$fld ) {
|
||||
list($tbl, $chk) = explode(".",$fld['name']);
|
||||
$val = array();
|
||||
foreach( $qry as $row ) {
|
||||
$val[] = $row[$chk];
|
||||
}
|
||||
$ret[$lev] = array('name'=>$fld['name'],'current'=>$val);
|
||||
}
|
||||
$obj = $ret;
|
||||
}
|
||||
}
|
||||
if (isset($_GET['term'],$_GET['device_id'])) {
|
||||
$chk = array();
|
||||
$_GET['term'] = mres($_GET['term']);
|
||||
$_GET['device_id'] = mres($_GET['device_id']);
|
||||
if (strstr($_GET['term'], '.')) {
|
||||
$term = explode('.', $_GET['term']);
|
||||
if ($config['memcached']['enable']) {
|
||||
$chk = $memcache->get('rule-suggest_'.$term[0]);
|
||||
}
|
||||
|
||||
if (!(sizeof($chk) > 0) || $chk === false) {
|
||||
if ($term[0] == 'macros') {
|
||||
foreach ($config['alert']['macros']['rule'] as $macro => $v) {
|
||||
$chk[] = 'macros.'.$macro;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$tmp = dbFetchRows('SHOW COLUMNS FROM '.$term[0]);
|
||||
foreach ($tmp as $tst) {
|
||||
if (isset($tst['Field'])) {
|
||||
$chk[] = $term[0].'.'.$tst['Field'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$current = true;
|
||||
}
|
||||
else {
|
||||
if ($config['memcached']['enable']) {
|
||||
$chk = $memcache->get('rule-suggest-toplvl');
|
||||
}
|
||||
|
||||
if (!(sizeof($chk) > 0) || $chk === false) {
|
||||
$tmp = dbFetchRows("SELECT TABLE_NAME FROM information_schema.COLUMNS WHERE COLUMN_NAME = 'device_id'");
|
||||
foreach ($tmp as $tst) {
|
||||
$chk[] = $tst['TABLE_NAME'].'.';
|
||||
}
|
||||
|
||||
$chk[] = 'macros.';
|
||||
$chk[] = 'bills.';
|
||||
}
|
||||
}
|
||||
if (sizeof($chk) > 0) {
|
||||
if ($config['memcached']['enable']) {
|
||||
$memcache->set('rule-suggest-'.$oterm, $chk, 86400);
|
||||
// Cache for 24h
|
||||
}
|
||||
|
||||
$obj = levsort($_GET['term'], $chk);
|
||||
$obj = array_chunk($obj, 20, true);
|
||||
$obj = $obj[0];
|
||||
$flds = array();
|
||||
if ($current == true) {
|
||||
foreach ($obj as $fld) {
|
||||
$flds[] = $fld['name'];
|
||||
}
|
||||
|
||||
$qry = dbFetchRows('SELECT '.implode(', ', $flds).' FROM '.$term[0].' WHERE device_id = ?', array($_GET['device_id']));
|
||||
$ret = array();
|
||||
foreach ($obj as $lev => $fld) {
|
||||
list($tbl, $chk) = explode('.', $fld['name']);
|
||||
$val = array();
|
||||
foreach ($qry as $row) {
|
||||
$val[] = $row[$chk];
|
||||
}
|
||||
|
||||
$ret[$lev] = array(
|
||||
'name' => $fld['name'],
|
||||
'current' => $val,
|
||||
);
|
||||
}
|
||||
|
||||
$obj = $ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
die(json_encode($obj));
|
||||
?>
|
||||
|
||||
@@ -1,212 +1,218 @@
|
||||
<?php
|
||||
|
||||
if (isset($_REQUEST['debug']))
|
||||
{
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 0);
|
||||
ini_set('log_errors', 0);
|
||||
ini_set('allow_url_fopen', 0);
|
||||
ini_set('error_reporting', E_ALL);
|
||||
if (isset($_REQUEST['debug'])) {
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 0);
|
||||
ini_set('log_errors', 0);
|
||||
ini_set('allow_url_fopen', 0);
|
||||
ini_set('error_reporting', E_ALL);
|
||||
}
|
||||
|
||||
include_once("../includes/defaults.inc.php");
|
||||
include_once("../config.php");
|
||||
include_once("../includes/definitions.inc.php");
|
||||
include_once("includes/functions.inc.php");
|
||||
include_once("../includes/functions.php");
|
||||
include_once("includes/authenticate.inc.php");
|
||||
require_once '../includes/defaults.inc.php';
|
||||
require_once '../config.php';
|
||||
require_once '../includes/definitions.inc.php';
|
||||
require_once 'includes/functions.inc.php';
|
||||
require_once '../includes/functions.php';
|
||||
require_once 'includes/authenticate.inc.php';
|
||||
|
||||
if (!$_SESSION['authenticated']) { echo("unauthenticated"); exit; }
|
||||
|
||||
$device = Array();
|
||||
$ports = Array();
|
||||
|
||||
if (isset($_REQUEST['search']))
|
||||
{
|
||||
$search = mres($_REQUEST['search']);
|
||||
|
||||
if (strlen($search) >0)
|
||||
{
|
||||
$found = 0;
|
||||
|
||||
if( $_REQUEST['type'] == 'group' ) {
|
||||
include_once('../includes/device-groups.inc.php');
|
||||
foreach( dbFetchRows("SELECT id,name FROM device_groups WHERE name LIKE '%".$search."%'") as $group ) {
|
||||
if( $_REQUEST['map'] ) {
|
||||
$results[] = array('name'=>'g:'.$group['name'],'group_id'=>$group['id']);
|
||||
} else {
|
||||
$results[] = array('name'=>$group['name']);
|
||||
}
|
||||
}
|
||||
die(json_encode($results));
|
||||
} elseif( $_REQUEST['type'] == 'alert-rules' ) {
|
||||
foreach( dbFetchRows("SELECT name FROM alert_rules WHERE name LIKE '%".$search."%'") as $rules ) {
|
||||
$results[] = array('name'=>$rules['name']);
|
||||
}
|
||||
die(json_encode($results));
|
||||
} elseif($_REQUEST['type'] == 'device') {
|
||||
|
||||
// Device search
|
||||
if (is_admin() === TRUE || is_read() === TRUE) {
|
||||
$results = dbFetchRows("SELECT * FROM `devices` WHERE `hostname` LIKE '%" . $search . "%' OR `location` LIKE '%" . $search . "%' ORDER BY hostname LIMIT 8");
|
||||
} else {
|
||||
$results = dbFetchRows("SELECT * FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` AND (`hostname` LIKE '%" . $search . "%' OR `location` LIKE '%" . $search . "%') ORDER BY hostname LIMIT 8", array($_SESSION['user_id']));
|
||||
}
|
||||
if (count($results))
|
||||
{
|
||||
$found = 1;
|
||||
$devices = count($results);
|
||||
|
||||
foreach ($results as $result)
|
||||
{
|
||||
$name = $result['hostname'];
|
||||
if($result['disabled'] == 1)
|
||||
{
|
||||
$highlight_colour = '#808080';
|
||||
}
|
||||
elseif($result['ignored'] == 1 && $result['disabled'] == 0)
|
||||
{
|
||||
$highlight_colour = '#000000';
|
||||
}
|
||||
elseif($result['status'] == 0 && $result['ignore'] == 0 && $result['disabled'] == 0)
|
||||
{
|
||||
$highlight_colour = '#ff0000';
|
||||
}
|
||||
elseif($result['status'] == 1 && $result['ignore'] == 0 && $result['disabled'] == 0)
|
||||
{
|
||||
$highlight_colour = '#008000';
|
||||
}
|
||||
if (is_admin() === TRUE || is_read() === TRUE) {
|
||||
$num_ports = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE device_id = ?", array($result['device_id']));
|
||||
} else {
|
||||
$num_ports = dbFetchCell("SELECT COUNT(*) FROM `ports` AS `I`, `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` AND `I`.`device_id` = `D`.`device_id` AND device_id = ?", array($_SESSION['user_id'],$result['device_id']));
|
||||
}
|
||||
$device[]=array('name'=>$name,
|
||||
'device_id'=>$result['device_id'],
|
||||
'url'=> generate_device_url($result),
|
||||
'colours'=>$highlight_colour,
|
||||
'device_ports'=>$num_ports,
|
||||
'device_image'=>getImageSrc($result),
|
||||
'device_hardware'=>$result['hardware'],
|
||||
'device_os'=>$config['os'][$result['os']]['text'],
|
||||
'version'=>$result['version'],
|
||||
'location'=>$result['location']);
|
||||
}
|
||||
}
|
||||
$json = json_encode($device);
|
||||
print_r($json);
|
||||
exit;
|
||||
|
||||
} elseif($_REQUEST['type'] == 'ports') {
|
||||
// Search ports
|
||||
if (is_admin() === TRUE || is_read() === TRUE) {
|
||||
$results = dbFetchRows("SELECT `ports`.*,`devices`.* FROM `ports` LEFT JOIN `devices` ON `ports`.`device_id` = `devices`.`device_id` WHERE `ifAlias` LIKE '%" . $search . "%' OR `ifDescr` LIKE '%" . $search . "%' ORDER BY ifDescr LIMIT 8");
|
||||
} else {
|
||||
$results = dbFetchRows("SELECT DISTINCT(`I`.`port_id`), `I`.*, `D`.`hostname` FROM `ports` AS `I`, `devices` AS `D`, `devices_perms` AS `P`, `ports_perms` AS `PP` WHERE ((`P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id`) OR (`PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` AND `I`.`device_id` = `D`.`device_id`)) AND `D`.`device_id` = `I`.`device_id` AND (`ifAlias` LIKE '%" . $search . "%' OR `ifDescr` LIKE '%" . $search . "%') ORDER BY ifDescr LIMIT 8", array($_SESSION['user_id'],$_SESSION['user_id']));
|
||||
}
|
||||
|
||||
if (count($results))
|
||||
{
|
||||
$found = 1;
|
||||
|
||||
foreach ($results as $result)
|
||||
{
|
||||
$name = $result['ifDescr'];
|
||||
$description = $result['ifAlias'];
|
||||
|
||||
if($result['deleted'] == 0 && ($result['ignore'] == 0 || $result['ignore'] == 0) && ($result['ifInErrors_delta'] > 0 || $result['ifOutErrors_delta'] > 0))
|
||||
{
|
||||
// Errored ports
|
||||
$port_colour = '#ffa500';
|
||||
}
|
||||
elseif($result['deleted'] == 0 && ($result['ignore'] == 1 || $result['ignore'] == 1))
|
||||
{
|
||||
// Ignored ports
|
||||
$port_colour = '#000000';
|
||||
|
||||
}
|
||||
elseif($result['deleted'] == 0 && $result['ifAdminStatus'] == 'down' && $result['ignore'] == 0 && $result['ignore'] == 0)
|
||||
{
|
||||
// Shutdown ports
|
||||
$port_colour = '#808080';
|
||||
}
|
||||
elseif($result['deleted'] == 0 && $result['ifOperStatus'] == 'down' && $result['ifAdminStatus'] == 'up' && $result['ignore'] == 0 && $result['ignore'] == 0)
|
||||
{
|
||||
// Down ports
|
||||
$port_colour = '#ff0000';
|
||||
}
|
||||
elseif($result['deleted'] == 0 && $result['ifOperStatus'] == 'up' && $result['ignore'] == 0 && $result['ignore'] == 0)
|
||||
{
|
||||
// Up ports
|
||||
$port_colour = '#008000';
|
||||
}
|
||||
|
||||
$ports[]=array('count'=>count($results),
|
||||
'url'=>generate_port_url($result),
|
||||
'name'=>$name,
|
||||
'description'=>$description,
|
||||
'colours'=>$highlight_colour,
|
||||
'hostname'=>$result['hostname']);
|
||||
|
||||
}
|
||||
}
|
||||
$json = json_encode($ports);
|
||||
print_r($json);
|
||||
exit;
|
||||
|
||||
} elseif($_REQUEST['type'] == 'bgp') {
|
||||
// Search bgp peers
|
||||
if (is_admin() === TRUE || is_read() === TRUE) {
|
||||
$results = dbFetchRows("SELECT `bgpPeers`.*,`devices`.* FROM `bgpPeers` LEFT JOIN `devices` ON `bgpPeers`.`device_id` = `devices`.`device_id` WHERE `astext` LIKE '%" . $search . "%' OR `bgpPeerIdentifier` LIKE '%" . $search . "%' OR `bgpPeerRemoteAs` LIKE '%" . $search . "%' ORDER BY `astext` LIMIT 8");
|
||||
} else {
|
||||
$results = dbFetchRows("SELECT `bgpPeers`.*,`D`.* FROM `bgpPeers`, `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` AND `bgpPeers`.`device_id`=`D`.`device_id` AND (`astext` LIKE '%" . $search . "%' OR `bgpPeerIdentifier` LIKE '%" . $search . "%' OR `bgpPeerRemoteAs` LIKE '%" . $search . "%') ORDER BY `astext` LIMIT 8", array($_SESSION['user_id']));
|
||||
}
|
||||
if (count($results))
|
||||
{
|
||||
$found = 1;
|
||||
|
||||
foreach ($results as $result)
|
||||
{
|
||||
$name = $result['bgpPeerIdentifier'];
|
||||
$description = $result['astext'];
|
||||
$remoteas = $result['bgpPeerRemoteAs'];
|
||||
$localas = $result['bgpLocalAs'];
|
||||
|
||||
if($result['bgpPeerAdminStatus'] == 'start' && $result['bgpPeerState'] != 'established')
|
||||
{
|
||||
// Session active but errored
|
||||
$port_colour = '#ffa500';
|
||||
}
|
||||
elseif($result['bgpPeerAdminStatus'] != 'start')
|
||||
{
|
||||
// Session inactive
|
||||
$port_colour = '#000000';
|
||||
|
||||
}
|
||||
elseif($result['bgpPeerAdminStatus'] == 'start' && $result['bgpPeerState'] == 'established')
|
||||
{
|
||||
// Session Up
|
||||
$port_colour = '#008000';
|
||||
}
|
||||
|
||||
if ($result['bgpPeerRemoteAs'] == $result['bgpLocalAs']) { $bgp_image = "images/16/brick_link.png"; } else { $bgp_image = "images/16/world_link.png"; }
|
||||
|
||||
$bgp[]=array('count'=>count($results),
|
||||
'url'=>generate_peer_url($result),
|
||||
'name'=>$name,
|
||||
'description'=>$description,
|
||||
'localas'=>$localas,
|
||||
'bgp_image'=>$bgp_image,
|
||||
'remoteas'=>$remoteas,
|
||||
'colours'=>$port_colour,
|
||||
'hostname'=>$result['hostname']);
|
||||
|
||||
}
|
||||
}
|
||||
$json = json_encode($bgp);
|
||||
print_r($json);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
if (!$_SESSION['authenticated']) {
|
||||
echo 'unauthenticated';
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
||||
$device = array();
|
||||
$ports = array();
|
||||
|
||||
if (isset($_REQUEST['search'])) {
|
||||
$search = mres($_REQUEST['search']);
|
||||
|
||||
if (strlen($search) > 0) {
|
||||
$found = 0;
|
||||
|
||||
if ($_REQUEST['type'] == 'group') {
|
||||
include_once '../includes/device-groups.inc.php';
|
||||
foreach (dbFetchRows("SELECT id,name FROM device_groups WHERE name LIKE '%".$search."%'") as $group) {
|
||||
if ($_REQUEST['map']) {
|
||||
$results[] = array(
|
||||
'name' => 'g:'.$group['name'],
|
||||
'group_id' => $group['id'],
|
||||
);
|
||||
}
|
||||
else {
|
||||
$results[] = array('name' => $group['name']);
|
||||
}
|
||||
}
|
||||
|
||||
die(json_encode($results));
|
||||
}
|
||||
else if ($_REQUEST['type'] == 'alert-rules') {
|
||||
foreach (dbFetchRows("SELECT name FROM alert_rules WHERE name LIKE '%".$search."%'") as $rules) {
|
||||
$results[] = array('name' => $rules['name']);
|
||||
}
|
||||
|
||||
die(json_encode($results));
|
||||
}
|
||||
else if ($_REQUEST['type'] == 'device') {
|
||||
// Device search
|
||||
if (is_admin() === true || is_read() === true) {
|
||||
$results = dbFetchRows("SELECT * FROM `devices` WHERE `hostname` LIKE '%".$search."%' OR `location` LIKE '%".$search."%' ORDER BY hostname LIMIT 8");
|
||||
}
|
||||
else {
|
||||
$results = dbFetchRows("SELECT * FROM `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` AND (`hostname` LIKE '%".$search."%' OR `location` LIKE '%".$search."%') ORDER BY hostname LIMIT 8", array($_SESSION['user_id']));
|
||||
}
|
||||
|
||||
if (count($results)) {
|
||||
$found = 1;
|
||||
$devices = count($results);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$name = $result['hostname'];
|
||||
if ($result['disabled'] == 1) {
|
||||
$highlight_colour = '#808080';
|
||||
}
|
||||
else if ($result['ignored'] == 1 && $result['disabled'] == 0) {
|
||||
$highlight_colour = '#000000';
|
||||
}
|
||||
else if ($result['status'] == 0 && $result['ignore'] == 0 && $result['disabled'] == 0) {
|
||||
$highlight_colour = '#ff0000';
|
||||
}
|
||||
else if ($result['status'] == 1 && $result['ignore'] == 0 && $result['disabled'] == 0) {
|
||||
$highlight_colour = '#008000';
|
||||
}
|
||||
|
||||
if (is_admin() === true || is_read() === true) {
|
||||
$num_ports = dbFetchCell('SELECT COUNT(*) FROM `ports` WHERE device_id = ?', array($result['device_id']));
|
||||
}
|
||||
else {
|
||||
$num_ports = dbFetchCell('SELECT COUNT(*) FROM `ports` AS `I`, `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` AND `I`.`device_id` = `D`.`device_id` AND device_id = ?', array($_SESSION['user_id'], $result['device_id']));
|
||||
}
|
||||
|
||||
$device[] = array(
|
||||
'name' => $name,
|
||||
'device_id' => $result['device_id'],
|
||||
'url' => generate_device_url($result),
|
||||
'colours' => $highlight_colour,
|
||||
'device_ports' => $num_ports,
|
||||
'device_image' => getImageSrc($result),
|
||||
'device_hardware' => $result['hardware'],
|
||||
'device_os' => $config['os'][$result['os']]['text'],
|
||||
'version' => $result['version'],
|
||||
'location' => $result['location'],
|
||||
);
|
||||
}//end foreach
|
||||
}//end if
|
||||
|
||||
$json = json_encode($device);
|
||||
print_r($json);
|
||||
exit;
|
||||
}
|
||||
else if ($_REQUEST['type'] == 'ports') {
|
||||
// Search ports
|
||||
if (is_admin() === true || is_read() === true) {
|
||||
$results = dbFetchRows("SELECT `ports`.*,`devices`.* FROM `ports` LEFT JOIN `devices` ON `ports`.`device_id` = `devices`.`device_id` WHERE `ifAlias` LIKE '%".$search."%' OR `ifDescr` LIKE '%".$search."%' ORDER BY ifDescr LIMIT 8");
|
||||
}
|
||||
else {
|
||||
$results = dbFetchRows("SELECT DISTINCT(`I`.`port_id`), `I`.*, `D`.`hostname` FROM `ports` AS `I`, `devices` AS `D`, `devices_perms` AS `P`, `ports_perms` AS `PP` WHERE ((`P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id`) OR (`PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` AND `I`.`device_id` = `D`.`device_id`)) AND `D`.`device_id` = `I`.`device_id` AND (`ifAlias` LIKE '%".$search."%' OR `ifDescr` LIKE '%".$search."%') ORDER BY ifDescr LIMIT 8", array($_SESSION['user_id'], $_SESSION['user_id']));
|
||||
}
|
||||
|
||||
if (count($results)) {
|
||||
$found = 1;
|
||||
|
||||
foreach ($results as $result) {
|
||||
$name = $result['ifDescr'];
|
||||
$description = $result['ifAlias'];
|
||||
|
||||
if ($result['deleted'] == 0 && ($result['ignore'] == 0 || $result['ignore'] == 0) && ($result['ifInErrors_delta'] > 0 || $result['ifOutErrors_delta'] > 0)) {
|
||||
// Errored ports
|
||||
$port_colour = '#ffa500';
|
||||
}
|
||||
else if ($result['deleted'] == 0 && ($result['ignore'] == 1 || $result['ignore'] == 1)) {
|
||||
// Ignored ports
|
||||
$port_colour = '#000000';
|
||||
}
|
||||
else if ($result['deleted'] == 0 && $result['ifAdminStatus'] == 'down' && $result['ignore'] == 0 && $result['ignore'] == 0) {
|
||||
// Shutdown ports
|
||||
$port_colour = '#808080';
|
||||
}
|
||||
else if ($result['deleted'] == 0 && $result['ifOperStatus'] == 'down' && $result['ifAdminStatus'] == 'up' && $result['ignore'] == 0 && $result['ignore'] == 0) {
|
||||
// Down ports
|
||||
$port_colour = '#ff0000';
|
||||
}
|
||||
else if ($result['deleted'] == 0 && $result['ifOperStatus'] == 'up' && $result['ignore'] == 0 && $result['ignore'] == 0) {
|
||||
// Up ports
|
||||
$port_colour = '#008000';
|
||||
}//end if
|
||||
|
||||
$ports[] = array(
|
||||
'count' => count($results),
|
||||
'url' => generate_port_url($result),
|
||||
'name' => $name,
|
||||
'description' => $description,
|
||||
'colours' => $highlight_colour,
|
||||
'hostname' => $result['hostname'],
|
||||
);
|
||||
}//end foreach
|
||||
}//end if
|
||||
|
||||
$json = json_encode($ports);
|
||||
print_r($json);
|
||||
exit;
|
||||
}
|
||||
else if ($_REQUEST['type'] == 'bgp') {
|
||||
// Search bgp peers
|
||||
if (is_admin() === true || is_read() === true) {
|
||||
$results = dbFetchRows("SELECT `bgpPeers`.*,`devices`.* FROM `bgpPeers` LEFT JOIN `devices` ON `bgpPeers`.`device_id` = `devices`.`device_id` WHERE `astext` LIKE '%".$search."%' OR `bgpPeerIdentifier` LIKE '%".$search."%' OR `bgpPeerRemoteAs` LIKE '%".$search."%' ORDER BY `astext` LIMIT 8");
|
||||
}
|
||||
else {
|
||||
$results = dbFetchRows("SELECT `bgpPeers`.*,`D`.* FROM `bgpPeers`, `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` AND `bgpPeers`.`device_id`=`D`.`device_id` AND (`astext` LIKE '%".$search."%' OR `bgpPeerIdentifier` LIKE '%".$search."%' OR `bgpPeerRemoteAs` LIKE '%".$search."%') ORDER BY `astext` LIMIT 8", array($_SESSION['user_id']));
|
||||
}
|
||||
|
||||
if (count($results)) {
|
||||
$found = 1;
|
||||
|
||||
foreach ($results as $result) {
|
||||
$name = $result['bgpPeerIdentifier'];
|
||||
$description = $result['astext'];
|
||||
$remoteas = $result['bgpPeerRemoteAs'];
|
||||
$localas = $result['bgpLocalAs'];
|
||||
|
||||
if ($result['bgpPeerAdminStatus'] == 'start' && $result['bgpPeerState'] != 'established') {
|
||||
// Session active but errored
|
||||
$port_colour = '#ffa500';
|
||||
}
|
||||
else if ($result['bgpPeerAdminStatus'] != 'start') {
|
||||
// Session inactive
|
||||
$port_colour = '#000000';
|
||||
}
|
||||
else if ($result['bgpPeerAdminStatus'] == 'start' && $result['bgpPeerState'] == 'established') {
|
||||
// Session Up
|
||||
$port_colour = '#008000';
|
||||
}
|
||||
|
||||
if ($result['bgpPeerRemoteAs'] == $result['bgpLocalAs']) {
|
||||
$bgp_image = 'images/16/brick_link.png';
|
||||
}
|
||||
else {
|
||||
$bgp_image = 'images/16/world_link.png';
|
||||
}
|
||||
|
||||
$bgp[] = array(
|
||||
'count' => count($results),
|
||||
'url' => generate_peer_url($result),
|
||||
'name' => $name,
|
||||
'description' => $description,
|
||||
'localas' => $localas,
|
||||
'bgp_image' => $bgp_image,
|
||||
'remoteas' => $remoteas,
|
||||
'colours' => $port_colour,
|
||||
'hostname' => $result['hostname'],
|
||||
);
|
||||
}//end foreach
|
||||
}//end if
|
||||
|
||||
$json = json_encode($bgp);
|
||||
print_r($json);
|
||||
exit;
|
||||
}//end if
|
||||
}//end if
|
||||
}//end if
|
||||
|
||||
@@ -12,39 +12,37 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
if (isset($_REQUEST['debug']))
|
||||
{
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 0);
|
||||
ini_set('log_errors', 0);
|
||||
ini_set('allow_url_fopen', 0);
|
||||
ini_set('error_reporting', E_ALL);
|
||||
if (isset($_REQUEST['debug'])) {
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 0);
|
||||
ini_set('log_errors', 0);
|
||||
ini_set('allow_url_fopen', 0);
|
||||
ini_set('error_reporting', E_ALL);
|
||||
}
|
||||
|
||||
include_once("../includes/defaults.inc.php");
|
||||
include_once("../config.php");
|
||||
include_once("../includes/definitions.inc.php");
|
||||
include_once("includes/functions.inc.php");
|
||||
include_once("../includes/functions.php");
|
||||
include_once("includes/authenticate.inc.php");
|
||||
require_once '../includes/defaults.inc.php';
|
||||
require_once '../config.php';
|
||||
require_once '../includes/definitions.inc.php';
|
||||
require_once 'includes/functions.inc.php';
|
||||
require_once '../includes/functions.php';
|
||||
require_once 'includes/authenticate.inc.php';
|
||||
|
||||
$current = $_POST['current'];
|
||||
settype($current,"integer");
|
||||
settype($current, 'integer');
|
||||
$rowCount = $_POST['rowCount'];
|
||||
settype($rowCount,"integer");
|
||||
settype($rowCount, 'integer');
|
||||
if (isset($_POST['sort']) && is_array($_POST['sort'])) {
|
||||
foreach ($_POST['sort'] as $k=>$v) {
|
||||
foreach ($_POST['sort'] as $k => $v) {
|
||||
$sort .= " $k $v";
|
||||
}
|
||||
}
|
||||
|
||||
$searchPhrase = mres($_POST['searchPhrase']);
|
||||
$id = mres($_POST['id']);
|
||||
$response = array();
|
||||
$id = mres($_POST['id']);
|
||||
$response = array();
|
||||
|
||||
if (isset($id)) {
|
||||
if (file_exists("includes/table/$id.inc.php")) {
|
||||
require_once "includes/table/$id.inc.php";
|
||||
include_once "includes/table/$id.inc.php";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
158
html/api_v0.php
158
html/api_v0.php
@@ -12,67 +12,111 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
include_once("../includes/defaults.inc.php");
|
||||
include_once("../config.php");
|
||||
include_once("../includes/definitions.inc.php");
|
||||
include_once("../includes/common.php");
|
||||
include_once("../includes/dbFacile.php");
|
||||
include_once("../includes/rewrites.php");
|
||||
include_once("includes/functions.inc.php");
|
||||
include_once("../includes/rrdtool.inc.php");
|
||||
require_once '../includes/defaults.inc.php';
|
||||
require_once '../config.php';
|
||||
require_once '../includes/definitions.inc.php';
|
||||
require_once '../includes/common.php';
|
||||
require_once '../includes/dbFacile.php';
|
||||
require_once '../includes/rewrites.php';
|
||||
require_once 'includes/functions.inc.php';
|
||||
require_once '../includes/rrdtool.inc.php';
|
||||
require 'includes/Slim/Slim.php';
|
||||
\Slim\Slim::registerAutoloader();
|
||||
$app = new \Slim\Slim();
|
||||
require_once("includes/api_functions.inc.php");
|
||||
require_once 'includes/api_functions.inc.php';
|
||||
$app->setName('api');
|
||||
|
||||
$app->group('/api', function() use ($app) {
|
||||
$app->group('/v0', function() use ($app) {
|
||||
$app->get('/bgp', 'authToken', 'list_bgp')->name('list_bgp');//api/v0/bgp
|
||||
$app->get('/oxidized', 'authToken', 'list_oxidized')->name('list_oxidized');
|
||||
$app->group('/devices', function() use ($app) {
|
||||
$app->delete('/:hostname', 'authToken', 'del_device')->name('del_device');//api/v0/devices/$hostname
|
||||
$app->get('/:hostname', 'authToken', 'get_device')->name('get_device');//api/v0/devices/$hostname
|
||||
$app->get('/:hostname/vlans', 'authToken', 'get_vlans')->name('get_vlans');//api/v0/devices/$hostname/vlans
|
||||
$app->get('/:hostname/graphs', 'authToken', 'get_graphs')->name('get_graphs');//api/v0/devices/$hostname/graphs
|
||||
$app->get('/:hostname/ports', 'authToken', 'get_port_graphs')->name('get_port_graphs');//api/v0/devices/$hostname/ports
|
||||
$app->get('/:hostname/:type', 'authToken', 'get_graph_generic_by_hostname')->name('get_graph_generic_by_hostname');//api/v0/devices/$hostname/$type
|
||||
$app->get('/:hostname/ports/:ifname', 'authToken', 'get_port_stats_by_port_hostname')->name('get_port_stats_by_port_hostname');//api/v0/devices/$hostname/ports/$ifName
|
||||
$app->get('/:hostname/ports/:ifname/:type', 'authToken', 'get_graph_by_port_hostname')->name('get_graph_by_port_hostname');//api/v0/devices/$hostname/ports/$ifName/$type
|
||||
});
|
||||
$app->get('/devices', 'authToken', 'list_devices')->name('list_devices');//api/v0/devices
|
||||
$app->post('/devices', 'authToken', 'add_device')->name('add_device');//api/v0/devices (json data needs to be passed)
|
||||
$app->group('/portgroups', function() use ($app) {
|
||||
$app->get('/:group', 'authToken', 'get_graph_by_portgroup')->name('get_graph_by_portgroup');//api/v0/portgroups/$group
|
||||
});
|
||||
$app->group('/bills', function() use ($app) {
|
||||
$app->get('/:bill_id', 'authToken', 'list_bills')->name('get_bill');//api/v0/bills/$bill_id
|
||||
});
|
||||
$app->get('/bills', 'authToken', 'list_bills')->name('list_bills');//api/v0/bills
|
||||
|
||||
// /api/v0/alerts
|
||||
$app->group('/alerts', function() use ($app) {
|
||||
$app->get('/:id', 'authToken', 'list_alerts')->name('get_alert');//api/v0/alerts
|
||||
$app->put('/:id', 'authToken', 'ack_alert')->name('ack_alert');//api/v0/alerts/$id (PUT)
|
||||
});
|
||||
$app->get('/alerts', 'authToken', 'list_alerts')->name('list_alerts');//api/v0/alerts
|
||||
|
||||
// /api/v0/rules
|
||||
$app->group('/rules', function() use ($app) {
|
||||
$app->get('/:id', 'authToken', 'list_alert_rules')->name('get_alert_rule');//api/v0/rules/$id
|
||||
$app->delete('/:id', 'authToken', 'delete_rule')->name('delete_rule');//api/v0/rules/$id (DELETE)
|
||||
});
|
||||
$app->get('/rules', 'authToken', 'list_alert_rules')->name('list_alert_rules');//api/v0/rules
|
||||
$app->post('/rules', 'authToken', 'add_edit_rule')->name('add_rule');//api/v0/rules (json data needs to be passed)
|
||||
$app->put('/rules', 'authToken', 'add_edit_rule')->name('edit_rule');//api/v0/rules (json data needs to be passed)
|
||||
// Inventory section
|
||||
$app->group('/inventory', function() use ($app) {
|
||||
$app->get('/:hostname', 'authToken', 'get_inventory')->name('get_inventory');
|
||||
});// End Inventory
|
||||
});
|
||||
$app->get('/v0', 'authToken', 'show_endpoints');//api/v0
|
||||
});
|
||||
$app->group(
|
||||
'/api',
|
||||
function () use ($app) {
|
||||
$app->group(
|
||||
'/v0',
|
||||
function () use ($app) {
|
||||
$app->get('/bgp', 'authToken', 'list_bgp')->name('list_bgp');
|
||||
// api/v0/bgp
|
||||
$app->get('/oxidized', 'authToken', 'list_oxidized')->name('list_oxidized');
|
||||
$app->group(
|
||||
'/devices',
|
||||
function () use ($app) {
|
||||
$app->delete('/:hostname', 'authToken', 'del_device')->name('del_device');
|
||||
// api/v0/devices/$hostname
|
||||
$app->get('/:hostname', 'authToken', 'get_device')->name('get_device');
|
||||
// api/v0/devices/$hostname
|
||||
$app->get('/:hostname/vlans', 'authToken', 'get_vlans')->name('get_vlans');
|
||||
// api/v0/devices/$hostname/vlans
|
||||
$app->get('/:hostname/graphs', 'authToken', 'get_graphs')->name('get_graphs');
|
||||
// api/v0/devices/$hostname/graphs
|
||||
$app->get('/:hostname/ports', 'authToken', 'get_port_graphs')->name('get_port_graphs');
|
||||
// api/v0/devices/$hostname/ports
|
||||
$app->get('/:hostname/:type', 'authToken', 'get_graph_generic_by_hostname')->name('get_graph_generic_by_hostname');
|
||||
// api/v0/devices/$hostname/$type
|
||||
$app->get('/:hostname/ports/:ifname', 'authToken', 'get_port_stats_by_port_hostname')->name('get_port_stats_by_port_hostname');
|
||||
// api/v0/devices/$hostname/ports/$ifName
|
||||
$app->get('/:hostname/ports/:ifname/:type', 'authToken', 'get_graph_by_port_hostname')->name('get_graph_by_port_hostname');
|
||||
// api/v0/devices/$hostname/ports/$ifName/$type
|
||||
}
|
||||
);
|
||||
$app->get('/devices', 'authToken', 'list_devices')->name('list_devices');
|
||||
// api/v0/devices
|
||||
$app->post('/devices', 'authToken', 'add_device')->name('add_device');
|
||||
// api/v0/devices (json data needs to be passed)
|
||||
$app->group(
|
||||
'/portgroups',
|
||||
function () use ($app) {
|
||||
$app->get('/:group', 'authToken', 'get_graph_by_portgroup')->name('get_graph_by_portgroup');
|
||||
// api/v0/portgroups/$group
|
||||
}
|
||||
);
|
||||
$app->group(
|
||||
'/bills',
|
||||
function () use ($app) {
|
||||
$app->get('/:bill_id', 'authToken', 'list_bills')->name('get_bill');
|
||||
// api/v0/bills/$bill_id
|
||||
}
|
||||
);
|
||||
$app->get('/bills', 'authToken', 'list_bills')->name('list_bills');
|
||||
// api/v0/bills
|
||||
// /api/v0/alerts
|
||||
$app->group(
|
||||
'/alerts',
|
||||
function () use ($app) {
|
||||
$app->get('/:id', 'authToken', 'list_alerts')->name('get_alert');
|
||||
// api/v0/alerts
|
||||
$app->put('/:id', 'authToken', 'ack_alert')->name('ack_alert');
|
||||
// api/v0/alerts/$id (PUT)
|
||||
}
|
||||
);
|
||||
$app->get('/alerts', 'authToken', 'list_alerts')->name('list_alerts');
|
||||
// api/v0/alerts
|
||||
// /api/v0/rules
|
||||
$app->group(
|
||||
'/rules',
|
||||
function () use ($app) {
|
||||
$app->get('/:id', 'authToken', 'list_alert_rules')->name('get_alert_rule');
|
||||
// api/v0/rules/$id
|
||||
$app->delete('/:id', 'authToken', 'delete_rule')->name('delete_rule');
|
||||
// api/v0/rules/$id (DELETE)
|
||||
}
|
||||
);
|
||||
$app->get('/rules', 'authToken', 'list_alert_rules')->name('list_alert_rules');
|
||||
// api/v0/rules
|
||||
$app->post('/rules', 'authToken', 'add_edit_rule')->name('add_rule');
|
||||
// api/v0/rules (json data needs to be passed)
|
||||
$app->put('/rules', 'authToken', 'add_edit_rule')->name('edit_rule');
|
||||
// api/v0/rules (json data needs to be passed)
|
||||
// Inventory section
|
||||
$app->group(
|
||||
'/inventory',
|
||||
function () use ($app) {
|
||||
$app->get('/:hostname', 'authToken', 'get_inventory')->name('get_inventory');
|
||||
}
|
||||
);
|
||||
// End Inventory
|
||||
}
|
||||
);
|
||||
$app->get('/v0', 'authToken', 'show_endpoints');
|
||||
// api/v0
|
||||
}
|
||||
);
|
||||
|
||||
$app->run();
|
||||
|
||||
?>
|
||||
|
||||
@@ -9,72 +9,77 @@
|
||||
* @subpackage webinterface
|
||||
* @author Adam Armstrong <adama@memetic.org>
|
||||
* @copyright (C) 2006 - 2012 Adam Armstrong
|
||||
*
|
||||
*/
|
||||
|
||||
ini_set('allow_url_fopen', 0);
|
||||
ini_set('display_errors', 0);
|
||||
|
||||
if (strpos($_SERVER['REQUEST_URI'], "debug"))
|
||||
{
|
||||
$debug = "1";
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
ini_set('log_errors', 1);
|
||||
ini_set('error_reporting', E_ALL);
|
||||
} else {
|
||||
$debug = FALSE;
|
||||
ini_set('display_errors', 0);
|
||||
ini_set('display_startup_errors', 0);
|
||||
ini_set('log_errors', 0);
|
||||
ini_set('error_reporting', 0);
|
||||
if (strpos($_SERVER['REQUEST_URI'], 'debug')) {
|
||||
$debug = '1';
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
ini_set('log_errors', 1);
|
||||
ini_set('error_reporting', E_ALL);
|
||||
}
|
||||
else {
|
||||
$debug = false;
|
||||
ini_set('display_errors', 0);
|
||||
ini_set('display_startup_errors', 0);
|
||||
ini_set('log_errors', 0);
|
||||
ini_set('error_reporting', 0);
|
||||
}
|
||||
|
||||
include("../includes/defaults.inc.php");
|
||||
include("../config.php");
|
||||
include("../includes/definitions.inc.php");
|
||||
include("../includes/functions.php");
|
||||
include("includes/functions.inc.php");
|
||||
include("includes/authenticate.inc.php");
|
||||
require '../includes/defaults.inc.php';
|
||||
require '../config.php';
|
||||
require '../includes/definitions.inc.php';
|
||||
require '../includes/functions.php';
|
||||
require 'includes/functions.inc.php';
|
||||
require 'includes/authenticate.inc.php';
|
||||
|
||||
if (get_client_ip() != $_SERVER['SERVER_ADDR']) { if (!$_SESSION['authenticated']) { echo("unauthenticated"); exit; } }
|
||||
require_once("includes/jpgraph/src/jpgraph.php");
|
||||
require_once("includes/jpgraph/src/jpgraph_line.php");
|
||||
require_once("includes/jpgraph/src/jpgraph_bar.php");
|
||||
require_once("includes/jpgraph/src/jpgraph_utils.inc.php");
|
||||
require_once("includes/jpgraph/src/jpgraph_date.php");
|
||||
|
||||
if (is_numeric($_GET['bill_id']))
|
||||
{
|
||||
if (get_client_ip() != $_SERVER['SERVER_ADDR'])
|
||||
{
|
||||
if (bill_permitted($_GET['bill_id']))
|
||||
{
|
||||
$bill_id = $_GET['bill_id'];
|
||||
} else {
|
||||
echo("Unauthorised Access Prohibited.");
|
||||
exit;
|
||||
if (get_client_ip() != $_SERVER['SERVER_ADDR']) {
|
||||
if (!$_SESSION['authenticated']) {
|
||||
echo 'unauthenticated';
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$bill_id = $_GET['bill_id'];
|
||||
}
|
||||
} else {
|
||||
echo("Unauthorised Access Prohibited.");
|
||||
exit;
|
||||
}
|
||||
|
||||
$start = $_GET['from'];
|
||||
$end = $_GET['to'];
|
||||
$xsize = (is_numeric($_GET['x']) ? $_GET['x'] : "800" );
|
||||
$ysize = (is_numeric($_GET['y']) ? $_GET['y'] : "250" );
|
||||
//$count = (is_numeric($_GET['count']) ? $_GET['count'] : "0" );
|
||||
//$type = (isset($_GET['type']) ? $_GET['type'] : "date" );
|
||||
//$dur = $end - $start;
|
||||
//$datefrom = date('Ymthis', $start);
|
||||
//$dateto = date('Ymthis', $end);
|
||||
$imgtype = (isset($_GET['type']) ? $_GET['type'] : "historical" );
|
||||
$imgbill = (isset($_GET['imgbill']) ? $_GET['imgbill'] : false);
|
||||
$yaxistitle = "Bytes";
|
||||
require_once 'includes/jpgraph/src/jpgraph.php';
|
||||
require_once 'includes/jpgraph/src/jpgraph_line.php';
|
||||
require_once 'includes/jpgraph/src/jpgraph_bar.php';
|
||||
require_once 'includes/jpgraph/src/jpgraph_utils.inc.php';
|
||||
require_once 'includes/jpgraph/src/jpgraph_date.php';
|
||||
|
||||
if (is_numeric($_GET['bill_id'])) {
|
||||
if (get_client_ip() != $_SERVER['SERVER_ADDR']) {
|
||||
if (bill_permitted($_GET['bill_id'])) {
|
||||
$bill_id = $_GET['bill_id'];
|
||||
}
|
||||
else {
|
||||
echo 'Unauthorised Access Prohibited.';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$bill_id = $_GET['bill_id'];
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo 'Unauthorised Access Prohibited.';
|
||||
exit;
|
||||
}
|
||||
|
||||
$start = $_GET['from'];
|
||||
$end = $_GET['to'];
|
||||
$xsize = (is_numeric($_GET['x']) ? $_GET['x'] : '800' );
|
||||
$ysize = (is_numeric($_GET['y']) ? $_GET['y'] : '250' );
|
||||
// $count = (is_numeric($_GET['count']) ? $_GET['count'] : "0" );
|
||||
// $type = (isset($_GET['type']) ? $_GET['type'] : "date" );
|
||||
// $dur = $end - $start;
|
||||
// $datefrom = date('Ymthis', $start);
|
||||
// $dateto = date('Ymthis', $end);
|
||||
$imgtype = (isset($_GET['type']) ? $_GET['type'] : 'historical' );
|
||||
$imgbill = (isset($_GET['imgbill']) ? $_GET['imgbill'] : false);
|
||||
$yaxistitle = 'Bytes';
|
||||
|
||||
$in_data = array();
|
||||
$out_data = array();
|
||||
@@ -84,187 +89,179 @@ $ave_data = array();
|
||||
$overuse_data = array();
|
||||
$ticklabels = array();
|
||||
|
||||
if ($imgtype == "historical")
|
||||
{
|
||||
$i = "0";
|
||||
if ($imgtype == 'historical') {
|
||||
$i = '0';
|
||||
|
||||
foreach (dbFetchRows("SELECT * FROM `bill_history` WHERE `bill_id` = ? ORDER BY `bill_datefrom` DESC LIMIT 12", array($bill_id)) as $data)
|
||||
{
|
||||
$datefrom = strftime("%e %b %Y", strtotime($data['bill_datefrom']));
|
||||
$dateto = strftime("%e %b %Y", strtotime($data['bill_dateto']));
|
||||
$datelabel = $datefrom."\n".$dateto;
|
||||
$traf['in'] = $data['traf_in'];
|
||||
$traf['out'] = $data['traf_out'];
|
||||
$traf['total'] = $data['traf_total'];
|
||||
foreach (dbFetchRows('SELECT * FROM `bill_history` WHERE `bill_id` = ? ORDER BY `bill_datefrom` DESC LIMIT 12', array($bill_id)) as $data) {
|
||||
$datefrom = strftime('%e %b %Y', strtotime($data['bill_datefrom']));
|
||||
$dateto = strftime('%e %b %Y', strtotime($data['bill_dateto']));
|
||||
$datelabel = $datefrom."\n".$dateto;
|
||||
$traf['in'] = $data['traf_in'];
|
||||
$traf['out'] = $data['traf_out'];
|
||||
$traf['total'] = $data['traf_total'];
|
||||
|
||||
if ($data['bill_type'] == "Quota")
|
||||
{
|
||||
$traf['allowed'] = $data['bill_allowed'];
|
||||
$traf['overuse'] = $data['bill_overuse'];
|
||||
} else {
|
||||
$traf['allowed'] = "0";
|
||||
$traf['overuse'] = "0";
|
||||
if ($data['bill_type'] == 'Quota') {
|
||||
$traf['allowed'] = $data['bill_allowed'];
|
||||
$traf['overuse'] = $data['bill_overuse'];
|
||||
}
|
||||
else {
|
||||
$traf['allowed'] = '0';
|
||||
$traf['overuse'] = '0';
|
||||
}
|
||||
|
||||
array_push($ticklabels, $datelabel);
|
||||
array_push($in_data, $traf['in']);
|
||||
array_push($out_data, $traf['out']);
|
||||
array_push($tot_data, $traf['total']);
|
||||
array_push($allow_data, $traf['allowed']);
|
||||
array_push($overuse_data, $traf['overuse']);
|
||||
$i++;
|
||||
// print_r($data);
|
||||
}//end foreach
|
||||
|
||||
if ($i < 12) {
|
||||
$y = (12 - $i);
|
||||
for ($x = 0; $x < $y; $x++) {
|
||||
$allowed = (($x == '0') ? $traf['allowed'] : '0' );
|
||||
array_push($in_data, '0');
|
||||
array_push($out_data, '0');
|
||||
array_push($tot_data, '0');
|
||||
array_push($allow_data, $allowed);
|
||||
array_push($overuse_data, '0');
|
||||
array_push($ticklabels, '');
|
||||
}
|
||||
}
|
||||
|
||||
array_push($ticklabels, $datelabel);
|
||||
array_push($in_data, $traf['in']);
|
||||
array_push($out_data, $traf['out']);
|
||||
array_push($tot_data, $traf['total']);
|
||||
array_push($allow_data, $traf['allowed']);
|
||||
array_push($overuse_data, $traf['overuse']);
|
||||
$i++;
|
||||
//print_r($data);
|
||||
}
|
||||
|
||||
if ($i < 12)
|
||||
{
|
||||
$y = 12 - $i;
|
||||
for ($x=0;$x<$y;$x++)
|
||||
{
|
||||
$allowed = (($x == "0") ? $traf['allowed'] : "0" );
|
||||
array_push($in_data, "0");
|
||||
array_push($out_data, "0");
|
||||
array_push($tot_data, "0");
|
||||
array_push($allow_data, $allowed);
|
||||
array_push($overuse_data, "0");
|
||||
array_push($ticklabels, "");
|
||||
}
|
||||
}
|
||||
$yaxistitle = "Gigabytes";
|
||||
$graph_name = "Historical bandwidth over the last 12 billing periods";
|
||||
} else {
|
||||
$data = array();
|
||||
$average = 0;
|
||||
if ($imgtype == "day")
|
||||
{
|
||||
foreach (dbFetch("SELECT DISTINCT UNIX_TIMESTAMP(timestamp) as timestamp, SUM(delta) as traf_total, SUM(in_delta) as traf_in, SUM(out_delta) as traf_out FROM bill_data WHERE `bill_id` = ? AND `timestamp` >= FROM_UNIXTIME(?) AND `timestamp` <= FROM_UNIXTIME(?) GROUP BY DATE(timestamp) ORDER BY timestamp ASC", array($bill_id, $start, $end)) as $data)
|
||||
{
|
||||
$traf['in'] = (isset($data['traf_in']) ? $data['traf_in'] : 0);
|
||||
$traf['out'] = (isset($data['traf_out']) ? $data['traf_out'] : 0);
|
||||
$traf['total'] = (isset($data['traf_total']) ? $data['traf_total'] : 0);
|
||||
$datelabel = strftime("%e\n%b", $data['timestamp']);
|
||||
array_push($ticklabels, $datelabel);
|
||||
array_push($in_data, $traf['in']);
|
||||
array_push($out_data, $traf['out']);
|
||||
array_push($tot_data, $traf['total']);
|
||||
$average += $data['traf_total'];
|
||||
}
|
||||
$ave_count = count($tot_data);
|
||||
if ($imgbill != false)
|
||||
{
|
||||
$days = strftime("%e", date($end - $start)) - $ave_count - 1;
|
||||
for ($x=0;$x<$days;$x++)
|
||||
{
|
||||
array_push($ticklabels, "");
|
||||
array_push($in_data, 0);
|
||||
array_push($out_data, 0);
|
||||
array_push($tot_data, 0);
|
||||
}
|
||||
}
|
||||
} elseif ($imgtype == "hour")
|
||||
{
|
||||
foreach (dbFetch("SELECT DISTINCT UNIX_TIMESTAMP(timestamp) as timestamp, SUM(delta) as traf_total, SUM(in_delta) as traf_in, SUM(out_delta) as traf_out FROM bill_data WHERE `bill_id` = ? AND `timestamp` >= FROM_UNIXTIME(?) AND `timestamp` <= FROM_UNIXTIME(?) GROUP BY HOUR(timestamp) ORDER BY timestamp ASC", array($bill_id, $start, $end)) as $data)
|
||||
{
|
||||
$traf['in'] = (isset($data['traf_in']) ? $data['traf_in'] : 0);
|
||||
$traf['out'] = (isset($data['traf_out']) ? $data['traf_out'] : 0);
|
||||
$traf['total'] = (isset($data['traf_total']) ? $data['traf_total'] : 0);
|
||||
$datelabel = strftime("%H:%M", $data['timestamp']);
|
||||
array_push($ticklabels, $datelabel);
|
||||
array_push($in_data, $traf['in']);
|
||||
array_push($out_data, $traf['out']);
|
||||
array_push($tot_data, $traf['total']);
|
||||
$average += $data['traf_total'];
|
||||
}
|
||||
$ave_count = count($tot_data);
|
||||
}
|
||||
|
||||
$decimal = 0;
|
||||
$average = $average / $ave_count;
|
||||
for ($x=0;$x<=count($tot_data);$x++)
|
||||
{
|
||||
array_push($ave_data, $average);
|
||||
}
|
||||
$graph_name = date('M j g:ia', $start)." - ".date('M j g:ia', $end);
|
||||
$yaxistitle = 'Gigabytes';
|
||||
$graph_name = 'Historical bandwidth over the last 12 billing periods';
|
||||
}
|
||||
else {
|
||||
$data = array();
|
||||
$average = 0;
|
||||
if ($imgtype == 'day') {
|
||||
foreach (dbFetch('SELECT DISTINCT UNIX_TIMESTAMP(timestamp) as timestamp, SUM(delta) as traf_total, SUM(in_delta) as traf_in, SUM(out_delta) as traf_out FROM bill_data WHERE `bill_id` = ? AND `timestamp` >= FROM_UNIXTIME(?) AND `timestamp` <= FROM_UNIXTIME(?) GROUP BY DATE(timestamp) ORDER BY timestamp ASC', array($bill_id, $start, $end)) as $data) {
|
||||
$traf['in'] = (isset($data['traf_in']) ? $data['traf_in'] : 0);
|
||||
$traf['out'] = (isset($data['traf_out']) ? $data['traf_out'] : 0);
|
||||
$traf['total'] = (isset($data['traf_total']) ? $data['traf_total'] : 0);
|
||||
$datelabel = strftime("%e\n%b", $data['timestamp']);
|
||||
array_push($ticklabels, $datelabel);
|
||||
array_push($in_data, $traf['in']);
|
||||
array_push($out_data, $traf['out']);
|
||||
array_push($tot_data, $traf['total']);
|
||||
$average += $data['traf_total'];
|
||||
}
|
||||
|
||||
$ave_count = count($tot_data);
|
||||
if ($imgbill != false) {
|
||||
$days = (strftime('%e', date($end - $start)) - $ave_count - 1);
|
||||
for ($x = 0; $x < $days; $x++) {
|
||||
array_push($ticklabels, '');
|
||||
array_push($in_data, 0);
|
||||
array_push($out_data, 0);
|
||||
array_push($tot_data, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ($imgtype == 'hour') {
|
||||
foreach (dbFetch('SELECT DISTINCT UNIX_TIMESTAMP(timestamp) as timestamp, SUM(delta) as traf_total, SUM(in_delta) as traf_in, SUM(out_delta) as traf_out FROM bill_data WHERE `bill_id` = ? AND `timestamp` >= FROM_UNIXTIME(?) AND `timestamp` <= FROM_UNIXTIME(?) GROUP BY HOUR(timestamp) ORDER BY timestamp ASC', array($bill_id, $start, $end)) as $data) {
|
||||
$traf['in'] = (isset($data['traf_in']) ? $data['traf_in'] : 0);
|
||||
$traf['out'] = (isset($data['traf_out']) ? $data['traf_out'] : 0);
|
||||
$traf['total'] = (isset($data['traf_total']) ? $data['traf_total'] : 0);
|
||||
$datelabel = strftime('%H:%M', $data['timestamp']);
|
||||
array_push($ticklabels, $datelabel);
|
||||
array_push($in_data, $traf['in']);
|
||||
array_push($out_data, $traf['out']);
|
||||
array_push($tot_data, $traf['total']);
|
||||
$average += $data['traf_total'];
|
||||
}
|
||||
|
||||
$ave_count = count($tot_data);
|
||||
}//end if
|
||||
|
||||
$decimal = 0;
|
||||
$average = ($average / $ave_count);
|
||||
for ($x = 0; $x <= count($tot_data); $x++) {
|
||||
array_push($ave_data, $average);
|
||||
}
|
||||
|
||||
$graph_name = date('M j g:ia', $start).' - '.date('M j g:ia', $end);
|
||||
}//end if
|
||||
|
||||
// Create the graph. These two calls are always required
|
||||
$graph = new Graph($xsize, $ysize, $graph_name);
|
||||
$graph->img->SetImgFormat("png");
|
||||
$graph->img->SetImgFormat('png');
|
||||
|
||||
#$graph->SetScale("textlin",0,0,$start,$end);
|
||||
|
||||
$graph->SetScale("textlin");
|
||||
#$graph->title->Set("$graph_name");
|
||||
// $graph->SetScale("textlin",0,0,$start,$end);
|
||||
$graph->SetScale('textlin');
|
||||
// $graph->title->Set("$graph_name");
|
||||
$graph->title->SetFont(FF_FONT2, FS_BOLD, 10);
|
||||
$graph->SetMarginColor("white");
|
||||
$graph->SetMarginColor('white');
|
||||
$graph->SetFrame(false);
|
||||
$graph->SetMargin("75", "30", "30", "65");
|
||||
$graph->SetMargin('75', '30', '30', '65');
|
||||
$graph->legend->SetFont(FF_FONT1, FS_NORMAL);
|
||||
$graph->legend->SetLayout(LEGEND_HOR);
|
||||
$graph->legend->Pos("0.52", "0.91", "center");
|
||||
$graph->legend->Pos('0.52', '0.91', 'center');
|
||||
|
||||
$graph->xaxis->SetFont(FF_FONT1, FS_BOLD);
|
||||
$graph->xaxis->SetPos('min');
|
||||
$graph->xaxis->SetTitleMargin(30);
|
||||
$graph->xaxis->SetTickLabels($ticklabels);
|
||||
$graph->xgrid->Show(true,true);
|
||||
$graph->xgrid->SetColor('#e0e0e0','#efefef');
|
||||
$graph->xgrid->Show(true, true);
|
||||
$graph->xgrid->SetColor('#e0e0e0', '#efefef');
|
||||
|
||||
$graph->yaxis->SetFont(FF_FONT1);
|
||||
$graph->yaxis->SetTitleMargin(50);
|
||||
$graph->yaxis->title->SetFont(FF_FONT1, FS_NORMAL, 10);
|
||||
$graph->yaxis->title->Set("Bytes Transferred");
|
||||
$graph->yaxis->title->Set('Bytes Transferred');
|
||||
$graph->yaxis->SetLabelFormatCallback('format_bytes_billing');
|
||||
$graph->ygrid->SetFill(true,'#EFEFEF@0.5','#FFFFFF@0.5');
|
||||
$graph->ygrid->SetFill(true, '#EFEFEF@0.5', '#FFFFFF@0.5');
|
||||
|
||||
// Create the bar plots
|
||||
$barplot_tot = new BarPlot($tot_data);
|
||||
$barplot_tot->SetLegend("Traffic total");
|
||||
$barplot_tot->SetLegend('Traffic total');
|
||||
$barplot_tot->SetColor('darkgray');
|
||||
$barplot_tot->SetFillColor('lightgray@0.4');
|
||||
$barplot_tot->value->Show();
|
||||
$barplot_tot->value->SetFormatCallback('format_bytes_billing_short');
|
||||
|
||||
$barplot_in = new BarPlot($in_data);
|
||||
$barplot_in->SetLegend("Traffic In");
|
||||
$barplot_in->SetLegend('Traffic In');
|
||||
$barplot_in->SetColor('darkgreen');
|
||||
$barplot_in->SetFillColor('lightgreen@0.4');
|
||||
$barplot_in->SetWeight(1);
|
||||
|
||||
$barplot_out = new BarPlot($out_data);
|
||||
$barplot_out->SetLegend("Traffic Out");
|
||||
$barplot_out->SetLegend('Traffic Out');
|
||||
$barplot_out->SetColor('darkblue');
|
||||
$barplot_out->SetFillColor('lightblue@0.4');
|
||||
$barplot_out->SetWeight(1);
|
||||
|
||||
if ($imgtype == "historical")
|
||||
{
|
||||
$barplot_over = new BarPlot($overuse_data);
|
||||
$barplot_over->SetLegend("Traffic Overusage");
|
||||
$barplot_over->SetColor('darkred');
|
||||
$barplot_over->SetFillColor('lightred@0.4');
|
||||
$barplot_over->SetWeight(1);
|
||||
if ($imgtype == 'historical') {
|
||||
$barplot_over = new BarPlot($overuse_data);
|
||||
$barplot_over->SetLegend('Traffic Overusage');
|
||||
$barplot_over->SetColor('darkred');
|
||||
$barplot_over->SetFillColor('lightred@0.4');
|
||||
$barplot_over->SetWeight(1);
|
||||
|
||||
$lineplot_allow = new LinePlot($allow_data);
|
||||
$lineplot_allow->SetLegend("Traffic Allowed");
|
||||
$lineplot_allow->SetColor('black');
|
||||
$lineplot_allow->SetWeight(1);
|
||||
$lineplot_allow = new LinePlot($allow_data);
|
||||
$lineplot_allow->SetLegend('Traffic Allowed');
|
||||
$lineplot_allow->SetColor('black');
|
||||
$lineplot_allow->SetWeight(1);
|
||||
|
||||
$gbplot = new GroupBarPlot(array($barplot_in, $barplot_tot, $barplot_out, $barplot_over));
|
||||
} else {
|
||||
$lineplot_allow = new LinePlot($ave_data);
|
||||
//$lineplot_allow->SetLegend("Average per ".$imgtype);
|
||||
$lineplot_allow->SetLegend("Average");
|
||||
$lineplot_allow->SetColor('black');
|
||||
$lineplot_allow->SetWeight(1);
|
||||
|
||||
$gbplot = new GroupBarPlot(array($barplot_in, $barplot_tot, $barplot_out));
|
||||
$gbplot = new GroupBarPlot(array($barplot_in, $barplot_tot, $barplot_out, $barplot_over));
|
||||
}
|
||||
else {
|
||||
$lineplot_allow = new LinePlot($ave_data);
|
||||
// $lineplot_allow->SetLegend("Average per ".$imgtype);
|
||||
$lineplot_allow->SetLegend('Average');
|
||||
$lineplot_allow->SetColor('black');
|
||||
$lineplot_allow->SetWeight(1);
|
||||
|
||||
$gbplot = new GroupBarPlot(array($barplot_in, $barplot_tot, $barplot_out));
|
||||
}//end if
|
||||
|
||||
$graph->Add($gbplot);
|
||||
$graph->Add($lineplot_allow);
|
||||
|
||||
// Display the graph
|
||||
$graph->Stroke();
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
/*
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
@@ -9,247 +9,256 @@
|
||||
* @subpackage billing
|
||||
* @author Adam Armstrong <adama@memetic.org>
|
||||
* @copyright (C) 2006 - 2012 Adam Armstrong
|
||||
*
|
||||
*/
|
||||
|
||||
ini_set('allow_url_fopen', 0);
|
||||
ini_set('display_errors', 0);
|
||||
|
||||
if (strpos($_SERVER['REQUEST_URI'], "debug"))
|
||||
{
|
||||
$debug = "1";
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
ini_set('log_errors', 1);
|
||||
ini_set('error_reporting', E_ALL);
|
||||
} else {
|
||||
$debug = FALSE;
|
||||
ini_set('display_errors', 0);
|
||||
ini_set('display_startup_errors', 0);
|
||||
ini_set('log_errors', 0);
|
||||
ini_set('error_reporting', 0);
|
||||
if (strpos($_SERVER['REQUEST_URI'], 'debug')) {
|
||||
$debug = '1';
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
ini_set('log_errors', 1);
|
||||
ini_set('error_reporting', E_ALL);
|
||||
}
|
||||
else {
|
||||
$debug = false;
|
||||
ini_set('display_errors', 0);
|
||||
ini_set('display_startup_errors', 0);
|
||||
ini_set('log_errors', 0);
|
||||
ini_set('error_reporting', 0);
|
||||
}
|
||||
|
||||
include("../includes/defaults.inc.php");
|
||||
include("../config.php");
|
||||
include("../includes/definitions.inc.php");
|
||||
include("../includes/functions.php");
|
||||
include("includes/functions.inc.php");
|
||||
include("includes/authenticate.inc.php");
|
||||
require '../includes/defaults.inc.php';
|
||||
require '../config.php';
|
||||
require '../includes/definitions.inc.php';
|
||||
require '../includes/functions.php';
|
||||
require 'includes/functions.inc.php';
|
||||
require 'includes/authenticate.inc.php';
|
||||
|
||||
if (get_client_ip() != $_SERVER['SERVER_ADDR']) { if (!$_SESSION['authenticated']) { echo("unauthenticated"); exit; } }
|
||||
require("includes/jpgraph/src/jpgraph.php");
|
||||
include("includes/jpgraph/src/jpgraph_line.php");
|
||||
include("includes/jpgraph/src/jpgraph_utils.inc.php");
|
||||
include("includes/jpgraph/src/jpgraph_date.php");
|
||||
|
||||
if (is_numeric($_GET['bill_id']))
|
||||
{
|
||||
if (get_client_ip() != $_SERVER['SERVER_ADDR'])
|
||||
{
|
||||
if (bill_permitted($_GET['bill_id']))
|
||||
{
|
||||
$bill_id = $_GET['bill_id'];
|
||||
} else {
|
||||
echo("Unauthorised Access Prohibited.");
|
||||
exit;
|
||||
if (get_client_ip() != $_SERVER['SERVER_ADDR']) {
|
||||
if (!$_SESSION['authenticated']) {
|
||||
echo 'unauthenticated';
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$bill_id = $_GET['bill_id'];
|
||||
}
|
||||
} else {
|
||||
echo("Unauthorised Access Prohibited.");
|
||||
exit;
|
||||
}
|
||||
|
||||
require 'includes/jpgraph/src/jpgraph.php';
|
||||
require 'includes/jpgraph/src/jpgraph_line.php';
|
||||
require 'includes/jpgraph/src/jpgraph_utils.inc.php';
|
||||
require 'includes/jpgraph/src/jpgraph_date.php';
|
||||
|
||||
if (is_numeric($_GET['bill_id'])) {
|
||||
if (get_client_ip() != $_SERVER['SERVER_ADDR']) {
|
||||
if (bill_permitted($_GET['bill_id'])) {
|
||||
$bill_id = $_GET['bill_id'];
|
||||
}
|
||||
else {
|
||||
echo 'Unauthorised Access Prohibited.';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$bill_id = $_GET['bill_id'];
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo 'Unauthorised Access Prohibited.';
|
||||
exit;
|
||||
}
|
||||
|
||||
$start = $_GET[from];
|
||||
$end = $_GET[to];
|
||||
$end = $_GET[to];
|
||||
$xsize = $_GET[x];
|
||||
$ysize = $_GET[y];
|
||||
$count = $_GET[count];
|
||||
$count = $count + 0;
|
||||
$iter = 1;
|
||||
$count = ($count + 0);
|
||||
$iter = 1;
|
||||
|
||||
if ($_GET[type]) { $type = $_GET[type]; } else { $type = "date"; }
|
||||
|
||||
$dur = $end - $start;
|
||||
|
||||
$datefrom = date('Ymthis', $start);
|
||||
$dateto = date('Ymthis', $end);
|
||||
|
||||
#$rate_data = getRates($bill_id,$datefrom,$dateto);
|
||||
$rate_data = dbFetchRow("SELECT * from `bills` WHERE `bill_id`= ? LIMIT 1", array($bill_id));
|
||||
$rate_95th = $rate_data['rate_95th'];
|
||||
$rate_average = $rate_data['rate_average'];
|
||||
|
||||
#$bi_a = dbFetchRow("SELECT * FROM bills WHERE bill_id = ?", array($bill_id));
|
||||
#$bill_name = $bi_a['bill_name'];
|
||||
$bill_name = $rate_data['bill_name'];
|
||||
|
||||
$dur = $end - $start;
|
||||
|
||||
$counttot = dbFetchCell("SELECT count(`delta`) FROM `bill_data` WHERE `bill_id` = ? AND `timestamp` >= FROM_UNIXTIME( ? ) AND `timestamp` <= FROM_UNIXTIME( ? )", array($bill_id, $start, $end));
|
||||
|
||||
$count = round($dur / 300 / (($ysize - 100) * 3), 0);
|
||||
if ($count <= 1) { $count = 2; }
|
||||
|
||||
#$count = round($counttot / 260, 0);
|
||||
#if ($count <= 1) { $count = 2; }
|
||||
|
||||
#$max = dbFetchCell("SELECT delta FROM bill_data WHERE bill_id = ? AND `timestamp` >= FROM_UNIXTIME( ? ) AND `timestamp` <= FROM_UNIXTIME( ? ) ORDER BY delta DESC LIMIT 0,1", array($bill_id, $start, $end));
|
||||
#if ($max > 1000000) { $div = "1000000"; $yaxis = "Mbit/sec"; } else { $div = "1000"; $yaxis = "Kbit/sec"; }
|
||||
|
||||
$i = '0';
|
||||
|
||||
foreach (dbFetch("SELECT *, UNIX_TIMESTAMP(timestamp) AS formatted_date FROM bill_data WHERE bill_id = ? AND `timestamp` >= FROM_UNIXTIME( ? ) AND `timestamp` <= FROM_UNIXTIME( ? ) ORDER BY timestamp ASC", array($bill_id, $start, $end)) as $row)
|
||||
{
|
||||
@$timestamp = $row['formatted_date'];
|
||||
if (!$first) { $first = $timestamp; }
|
||||
$delta = $row['delta'];
|
||||
$period = $row['period'];
|
||||
$in_delta = $row['in_delta'];
|
||||
$out_delta = $row['out_delta'];
|
||||
$in_value = round($in_delta * 8 / $period, 2);
|
||||
$out_value = round($out_delta * 8 / $period, 2);
|
||||
|
||||
$last = $timestamp;
|
||||
|
||||
$iter_in += $in_delta;
|
||||
$iter_out += $out_delta;
|
||||
$iter_period += $period;
|
||||
|
||||
if ($iter == $count)
|
||||
{
|
||||
$out_data[$i] = round($iter_out * 8 / $iter_period, 2);
|
||||
$out_data_inv[$i] = $out_data[$i] * -1;
|
||||
$in_data[$i] = round($iter_in * 8 / $iter_period, 2);
|
||||
$tot_data[$i] = $out_data[$i] + $in_data[$i];
|
||||
$tot_data_inv[$i] = $tot_data[$i] * -1;
|
||||
|
||||
if ($tot_data[$i] > $max_value) { $max_value = $tot_data[$i]; }
|
||||
|
||||
$ticks[$i] = $timestamp;
|
||||
$per_data[$i] = $rate_95th;
|
||||
$ave_data[$i] = $rate_average;
|
||||
$iter = "1";
|
||||
$i++;
|
||||
unset($iter_out, $iter_in, $iter_period);
|
||||
}
|
||||
|
||||
$iter++;
|
||||
if ($_GET[type]) {
|
||||
$type = $_GET[type];
|
||||
}
|
||||
else {
|
||||
$type = 'date';
|
||||
}
|
||||
|
||||
$graph_name = date('M j g:ia', $start) . " - " . date('M j g:ia', $last);
|
||||
$dur = ($end - $start);
|
||||
|
||||
$n = count($ticks);
|
||||
$datefrom = date('Ymthis', $start);
|
||||
$dateto = date('Ymthis', $end);
|
||||
|
||||
// $rate_data = getRates($bill_id,$datefrom,$dateto);
|
||||
$rate_data = dbFetchRow('SELECT * from `bills` WHERE `bill_id`= ? LIMIT 1', array($bill_id));
|
||||
$rate_95th = $rate_data['rate_95th'];
|
||||
$rate_average = $rate_data['rate_average'];
|
||||
|
||||
// $bi_a = dbFetchRow("SELECT * FROM bills WHERE bill_id = ?", array($bill_id));
|
||||
// $bill_name = $bi_a['bill_name'];
|
||||
$bill_name = $rate_data['bill_name'];
|
||||
|
||||
$dur = ($end - $start);
|
||||
|
||||
$counttot = dbFetchCell('SELECT count(`delta`) FROM `bill_data` WHERE `bill_id` = ? AND `timestamp` >= FROM_UNIXTIME( ? ) AND `timestamp` <= FROM_UNIXTIME( ? )', array($bill_id, $start, $end));
|
||||
|
||||
$count = round(($dur / 300 / (($ysize - 100) * 3)), 0);
|
||||
if ($count <= 1) {
|
||||
$count = 2;
|
||||
}
|
||||
|
||||
// $count = round($counttot / 260, 0);
|
||||
// if ($count <= 1) { $count = 2; }
|
||||
// $max = dbFetchCell("SELECT delta FROM bill_data WHERE bill_id = ? AND `timestamp` >= FROM_UNIXTIME( ? ) AND `timestamp` <= FROM_UNIXTIME( ? ) ORDER BY delta DESC LIMIT 0,1", array($bill_id, $start, $end));
|
||||
// if ($max > 1000000) { $div = "1000000"; $yaxis = "Mbit/sec"; } else { $div = "1000"; $yaxis = "Kbit/sec"; }
|
||||
$i = '0';
|
||||
|
||||
foreach (dbFetch('SELECT *, UNIX_TIMESTAMP(timestamp) AS formatted_date FROM bill_data WHERE bill_id = ? AND `timestamp` >= FROM_UNIXTIME( ? ) AND `timestamp` <= FROM_UNIXTIME( ? ) ORDER BY timestamp ASC', array($bill_id, $start, $end)) as $row) {
|
||||
@$timestamp = $row['formatted_date'];
|
||||
if (!$first) {
|
||||
$first = $timestamp;
|
||||
}
|
||||
|
||||
$delta = $row['delta'];
|
||||
$period = $row['period'];
|
||||
$in_delta = $row['in_delta'];
|
||||
$out_delta = $row['out_delta'];
|
||||
$in_value = round(($in_delta * 8 / $period), 2);
|
||||
$out_value = round(($out_delta * 8 / $period), 2);
|
||||
|
||||
$last = $timestamp;
|
||||
|
||||
$iter_in += $in_delta;
|
||||
$iter_out += $out_delta;
|
||||
$iter_period += $period;
|
||||
|
||||
if ($iter == $count) {
|
||||
$out_data[$i] = round(($iter_out * 8 / $iter_period), 2);
|
||||
$out_data_inv[$i] = ($out_data[$i] * -1);
|
||||
$in_data[$i] = round(($iter_in * 8 / $iter_period), 2);
|
||||
$tot_data[$i] = ($out_data[$i] + $in_data[$i]);
|
||||
$tot_data_inv[$i] = ($tot_data[$i] * -1);
|
||||
|
||||
if ($tot_data[$i] > $max_value) {
|
||||
$max_value = $tot_data[$i];
|
||||
}
|
||||
|
||||
$ticks[$i] = $timestamp;
|
||||
$per_data[$i] = $rate_95th;
|
||||
$ave_data[$i] = $rate_average;
|
||||
$iter = '1';
|
||||
$i++;
|
||||
unset($iter_out, $iter_in, $iter_period);
|
||||
}
|
||||
|
||||
$iter++;
|
||||
}//end foreach
|
||||
|
||||
$graph_name = date('M j g:ia', $start).' - '.date('M j g:ia', $last);
|
||||
|
||||
$n = count($ticks);
|
||||
$xmin = $ticks[0];
|
||||
$xmax = $ticks[$n-1];
|
||||
$xmax = $ticks[($n - 1)];
|
||||
|
||||
$graph_name = date('M j g:ia', $xmin) . " - " . date('M j g:ia', $xmax);
|
||||
$graph_name = date('M j g:ia', $xmin).' - '.date('M j g:ia', $xmax);
|
||||
|
||||
$graph = new Graph($xsize, $ysize, $graph_name);
|
||||
$graph->img->SetImgFormat("png");
|
||||
$graph->img->SetImgFormat('png');
|
||||
|
||||
$graph->SetScale('datlin',0,0,$start,$end);
|
||||
$graph->SetScale('datlin', 0, 0, $start, $end);
|
||||
|
||||
#$graph->title->Set("$graph_name");
|
||||
$graph->title->SetFont(FF_FONT2,FS_BOLD,10);
|
||||
$graph->xaxis->SetFont(FF_FONT1,FS_BOLD);
|
||||
// $graph->title->Set("$graph_name");
|
||||
$graph->title->SetFont(FF_FONT2, FS_BOLD, 10);
|
||||
$graph->xaxis->SetFont(FF_FONT1, FS_BOLD);
|
||||
|
||||
$graph->xaxis->SetTextLabelInterval(2);
|
||||
|
||||
$graph->xaxis->SetPos('min');
|
||||
#$graph->xaxis->SetLabelAngle(15);
|
||||
// $graph->xaxis->SetLabelAngle(15);
|
||||
$graph->yaxis->HideZeroLabel(1);
|
||||
$graph->yaxis->SetFont(FF_FONT1);
|
||||
$graph->yaxis->SetLabelAngle(0);
|
||||
$graph->xaxis->title->SetFont(FF_FONT1,FS_NORMAL,10);
|
||||
$graph->yaxis->title->SetFont(FF_FONT1,FS_NORMAL,10);
|
||||
$graph->xaxis->title->SetFont(FF_FONT1, FS_NORMAL, 10);
|
||||
$graph->yaxis->title->SetFont(FF_FONT1, FS_NORMAL, 10);
|
||||
$graph->yaxis->SetTitleMargin(50);
|
||||
$graph->xaxis->SetTitleMargin(30);
|
||||
#$graph->xaxis->HideLastTickLabel();
|
||||
#$graph->xaxis->HideFirstTickLabel();
|
||||
#$graph->yaxis->scale->SetAutoMin(1);
|
||||
// $graph->xaxis->HideLastTickLabel();
|
||||
// $graph->xaxis->HideFirstTickLabel();
|
||||
// $graph->yaxis->scale->SetAutoMin(1);
|
||||
$graph->xaxis->title->Set($type);
|
||||
$graph->yaxis->title->Set("Bits per second");
|
||||
$graph->yaxis->SetLabelFormatCallback("format_si");
|
||||
$graph->yaxis->title->Set('Bits per second');
|
||||
$graph->yaxis->SetLabelFormatCallback('format_si');
|
||||
|
||||
|
||||
function TimeCallback($aVal) {
|
||||
global $dur;
|
||||
|
||||
if ($dur < 172800)
|
||||
{
|
||||
return Date('H:i',$aVal);
|
||||
} elseif ($dur < 604800) {
|
||||
return Date('D',$aVal);
|
||||
} else {
|
||||
return Date('j M',$aVal);
|
||||
if ($dur < 172800) {
|
||||
return date('H:i', $aVal);
|
||||
}
|
||||
}
|
||||
else if ($dur < 604800) {
|
||||
return date('D', $aVal);
|
||||
}
|
||||
else {
|
||||
return date('j M', $aVal);
|
||||
}
|
||||
|
||||
}//end TimeCallback()
|
||||
|
||||
|
||||
$graph->xaxis->SetLabelFormatCallback('TimeCallBack');
|
||||
|
||||
$graph->ygrid->SetFill(true,'#EFEFEF@0.5','#FFFFFF@0.5');
|
||||
$graph->xgrid->Show(true,true);
|
||||
$graph->xgrid->SetColor('#e0e0e0','#efefef');
|
||||
$graph->ygrid->SetFill(true, '#EFEFEF@0.5', '#FFFFFF@0.5');
|
||||
$graph->xgrid->Show(true, true);
|
||||
$graph->xgrid->SetColor('#e0e0e0', '#efefef');
|
||||
$graph->SetMarginColor('white');
|
||||
$graph->SetFrame(false);
|
||||
$graph->SetMargin(75,30,30,45);
|
||||
$graph->legend->SetFont(FF_FONT1,FS_NORMAL);
|
||||
$graph->SetMargin(75, 30, 30, 45);
|
||||
$graph->legend->SetFont(FF_FONT1, FS_NORMAL);
|
||||
|
||||
$lineplot = new LinePlot($tot_data, $ticks);
|
||||
$lineplot->SetLegend("Traffic total");
|
||||
$lineplot->SetColor("#d5d5d5");
|
||||
$lineplot->SetFillColor("#d5d5d5@0.5");
|
||||
|
||||
#$lineplot2 = new LinePlot($tot_data_inv, $ticks);
|
||||
#$lineplot2->SetColor("#d5d5d5");
|
||||
#$lineplot2->SetFillColor("#d5d5d5@0.5");
|
||||
$lineplot->SetLegend('Traffic total');
|
||||
$lineplot->SetColor('#d5d5d5');
|
||||
$lineplot->SetFillColor('#d5d5d5@0.5');
|
||||
|
||||
// $lineplot2 = new LinePlot($tot_data_inv, $ticks);
|
||||
// $lineplot2->SetColor("#d5d5d5");
|
||||
// $lineplot2->SetFillColor("#d5d5d5@0.5");
|
||||
$lineplot_in = new LinePlot($in_data, $ticks);
|
||||
|
||||
$lineplot_in->SetLegend("Traffic In");
|
||||
$lineplot_in->SetLegend('Traffic In');
|
||||
$lineplot_in->SetColor('darkgreen');
|
||||
$lineplot_in->SetFillColor('lightgreen@0.4');
|
||||
$lineplot_in->SetWeight(1);
|
||||
|
||||
$lineplot_out = new LinePlot($out_data_inv, $ticks);
|
||||
$lineplot_out->SetLegend("Traffic Out");
|
||||
$lineplot_out->SetLegend('Traffic Out');
|
||||
$lineplot_out->SetColor('darkblue');
|
||||
$lineplot_out->SetFillColor('lightblue@0.4');
|
||||
$lineplot_out->SetWeight(1);
|
||||
|
||||
if ($_GET['95th'])
|
||||
{
|
||||
$lineplot_95th = new LinePlot($per_data, $ticks);
|
||||
$lineplot_95th ->SetColor("red");
|
||||
if ($_GET['95th']) {
|
||||
$lineplot_95th = new LinePlot($per_data, $ticks);
|
||||
$lineplot_95th->SetColor('red');
|
||||
}
|
||||
|
||||
if ($_GET['ave'])
|
||||
{
|
||||
$lineplot_ave = new LinePlot($ave_data, $ticks);
|
||||
$lineplot_ave ->SetColor("red");
|
||||
if ($_GET['ave']) {
|
||||
$lineplot_ave = new LinePlot($ave_data, $ticks);
|
||||
$lineplot_ave->SetColor('red');
|
||||
}
|
||||
|
||||
$graph->legend->SetLayout(LEGEND_HOR);
|
||||
$graph->legend->Pos(0.52, 0.90, 'center');
|
||||
|
||||
$graph->Add($lineplot);
|
||||
#$graph->Add($lineplot2);
|
||||
|
||||
// $graph->Add($lineplot2);
|
||||
$graph->Add($lineplot_in);
|
||||
$graph->Add($lineplot_out);
|
||||
|
||||
if ($_GET['95th'])
|
||||
{
|
||||
$graph->Add($lineplot_95th);
|
||||
if ($_GET['95th']) {
|
||||
$graph->Add($lineplot_95th);
|
||||
}
|
||||
|
||||
if ($_GET['ave'])
|
||||
{
|
||||
$graph->Add($lineplot_ave);
|
||||
if ($_GET['ave']) {
|
||||
$graph->Add($lineplot_ave);
|
||||
}
|
||||
|
||||
$graph->stroke();
|
||||
|
||||
?>
|
||||
|
||||
67
html/csv.php
67
html/csv.php
@@ -12,41 +12,42 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
if (strpos($_SERVER['PATH_INFO'], "debug"))
|
||||
{
|
||||
$debug = "1";
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
ini_set('log_errors', 1);
|
||||
ini_set('error_reporting', E_ALL);
|
||||
} else {
|
||||
$debug = FALSE;
|
||||
ini_set('display_errors', 0);
|
||||
ini_set('display_startup_errors', 0);
|
||||
ini_set('log_errors', 0);
|
||||
ini_set('error_reporting', 0);
|
||||
if (strpos($_SERVER['PATH_INFO'], 'debug')) {
|
||||
$debug = '1';
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
ini_set('log_errors', 1);
|
||||
ini_set('error_reporting', E_ALL);
|
||||
}
|
||||
else {
|
||||
$debug = false;
|
||||
ini_set('display_errors', 0);
|
||||
ini_set('display_startup_errors', 0);
|
||||
ini_set('log_errors', 0);
|
||||
ini_set('error_reporting', 0);
|
||||
}
|
||||
|
||||
include "../includes/defaults.inc.php";
|
||||
include "../config.php";
|
||||
include_once "../includes/definitions.inc.php";
|
||||
include "../includes/functions.php";
|
||||
include "includes/functions.inc.php";
|
||||
include "includes/vars.inc.php";
|
||||
include "includes/authenticate.inc.php";
|
||||
require '../includes/defaults.inc.php';
|
||||
require '../config.php';
|
||||
require_once '../includes/definitions.inc.php';
|
||||
require '../includes/functions.php';
|
||||
require 'includes/functions.inc.php';
|
||||
require 'includes/vars.inc.php';
|
||||
require 'includes/authenticate.inc.php';
|
||||
|
||||
$report = mres($vars['report']);
|
||||
if( !empty($report) && file_exists("includes/reports/$report.csv.inc.php")) {
|
||||
if( $debug == false ) {
|
||||
header("Content-Type: text/csv");
|
||||
header('Content-Disposition: attachment; filename="'.$report.'-'.date('Ymd').'.csv"');
|
||||
}
|
||||
$csv = array();
|
||||
include_once "includes/reports/$report.csv.inc.php";
|
||||
foreach( $csv as $line ) {
|
||||
echo implode(',',$line)."\n";
|
||||
}
|
||||
} else {
|
||||
echo "Report not found.\n";
|
||||
if (!empty($report) && file_exists("includes/reports/$report.csv.inc.php")) {
|
||||
if ($debug == false) {
|
||||
header('Content-Type: text/csv');
|
||||
header('Content-Disposition: attachment; filename="'.$report.'-'.date('Ymd').'.csv"');
|
||||
}
|
||||
|
||||
$csv = array();
|
||||
include_once "includes/reports/$report.csv.inc.php";
|
||||
foreach ($csv as $line) {
|
||||
echo implode(',', $line)."\n";
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo "Report not found.\n";
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -9,44 +9,38 @@
|
||||
* @subpackage webinterface
|
||||
* @author Adam Armstrong <adama@memetic.org>
|
||||
* @copyright (C) 2006 - 2012 Adam Armstrong
|
||||
*
|
||||
*/
|
||||
|
||||
// FIXME - fewer includes!
|
||||
require_once '../includes/defaults.inc.php';
|
||||
require_once '../config.php';
|
||||
require_once '../includes/definitions.inc.php';
|
||||
require_once '../includes/common.php';
|
||||
require_once '../includes/dbFacile.php';
|
||||
require_once '../includes/rewrites.php';
|
||||
require_once 'includes/functions.inc.php';
|
||||
require_once 'includes/authenticate.inc.php';
|
||||
|
||||
include_once("../includes/defaults.inc.php");
|
||||
include_once("../config.php");
|
||||
include_once("../includes/definitions.inc.php");
|
||||
include_once("../includes/common.php");
|
||||
include_once("../includes/dbFacile.php");
|
||||
include_once("../includes/rewrites.php");
|
||||
include_once("includes/functions.inc.php");
|
||||
include_once("includes/authenticate.inc.php");
|
||||
require_once '../includes/snmp.inc.php';
|
||||
|
||||
include_once("../includes/snmp.inc.php");
|
||||
|
||||
if (is_numeric($_GET['id']) && ($config['allow_unauth_graphs'] || port_permitted($_GET['id'])))
|
||||
{
|
||||
$port = get_port_by_id($_GET['id']);
|
||||
$device = device_by_id_cache($port['device_id']);
|
||||
$title = generate_device_link($device);
|
||||
$title .= " :: Port ".generate_port_link($port);
|
||||
$auth = TRUE;
|
||||
if (is_numeric($_GET['id']) && ($config['allow_unauth_graphs'] || port_permitted($_GET['id']))) {
|
||||
$port = get_port_by_id($_GET['id']);
|
||||
$device = device_by_id_cache($port['device_id']);
|
||||
$title = generate_device_link($device);
|
||||
$title .= ' :: Port '.generate_port_link($port);
|
||||
$auth = true;
|
||||
}
|
||||
|
||||
$in = snmp_get($device, "ifInOctets.".$port['ifIndex'], "-OUqnv", "IF-MIB");
|
||||
$out = snmp_get($device, "ifOutOctets.".$port['ifIndex'], "-OUqnv", "IF-MIB");
|
||||
if(empty($in))
|
||||
{
|
||||
$in = snmp_get($device, "ifHCInOctets.".$port['ifIndex'], "-OUqnv", "IF-MIB");
|
||||
$in = snmp_get($device, 'ifInOctets.'.$port['ifIndex'], '-OUqnv', 'IF-MIB');
|
||||
$out = snmp_get($device, 'ifOutOctets.'.$port['ifIndex'], '-OUqnv', 'IF-MIB');
|
||||
if (empty($in)) {
|
||||
$in = snmp_get($device, 'ifHCInOctets.'.$port['ifIndex'], '-OUqnv', 'IF-MIB');
|
||||
}
|
||||
if(empty($out))
|
||||
{
|
||||
$out = snmp_get($device, "ifHCOutOctets.".$port['ifIndex'], "-OUqnv", "IF-MIB");
|
||||
|
||||
if (empty($out)) {
|
||||
$out = snmp_get($device, 'ifHCOutOctets.'.$port['ifIndex'], '-OUqnv', 'IF-MIB');
|
||||
}
|
||||
|
||||
$time = time();
|
||||
|
||||
printf("%lf|%s|%s\n", time(), $in, $out);
|
||||
|
||||
?>
|
||||
|
||||
@@ -14,86 +14,75 @@
|
||||
|
||||
enable_debug();
|
||||
|
||||
include_once("../includes/defaults.inc.php");
|
||||
include_once("../config.php");
|
||||
include_once("../includes/definitions.inc.php");
|
||||
include_once("includes/functions.inc.php");
|
||||
include_once("../includes/functions.php");
|
||||
include_once("includes/authenticate.inc.php");
|
||||
require_once '../includes/defaults.inc.php';
|
||||
require_once '../config.php';
|
||||
require_once '../includes/definitions.inc.php';
|
||||
require_once 'includes/functions.inc.php';
|
||||
require_once '../includes/functions.php';
|
||||
require_once 'includes/authenticate.inc.php';
|
||||
|
||||
if (!$_SESSION['authenticated']) { echo("unauthenticated"); exit; }
|
||||
if (!$_SESSION['authenticated']) {
|
||||
echo 'unauthenticated';
|
||||
exit;
|
||||
}
|
||||
|
||||
$new_conf_type = $_POST['new_conf_type'];
|
||||
$new_conf_name = $_POST['new_conf_name'];
|
||||
$new_conf_desc = $_POST['new_conf_desc'];
|
||||
|
||||
if(empty($new_conf_name))
|
||||
{
|
||||
echo("You haven't specified a config name");
|
||||
exit;
|
||||
if (empty($new_conf_name)) {
|
||||
echo "You haven't specified a config name";
|
||||
exit;
|
||||
}
|
||||
elseif(empty($new_conf_desc))
|
||||
{
|
||||
echo("You haven't specified a config description");
|
||||
exit;
|
||||
else if (empty($new_conf_desc)) {
|
||||
echo "You haven't specified a config description";
|
||||
exit;
|
||||
}
|
||||
elseif(empty($_POST['new_conf_single_value']) && empty($_POST['new_conf_multi_value']))
|
||||
{
|
||||
echo("You haven't specified a config value");
|
||||
exit;
|
||||
else if (empty($_POST['new_conf_single_value']) && empty($_POST['new_conf_multi_value'])) {
|
||||
echo "You haven't specified a config value";
|
||||
exit;
|
||||
}
|
||||
|
||||
$db_inserted = '0';
|
||||
|
||||
if($new_conf_type == 'Single')
|
||||
{
|
||||
$new_conf_type = 'single';
|
||||
$new_conf_value = $_POST['new_conf_single_value'];
|
||||
$db_inserted = add_config_item($new_conf_name,$new_conf_value,$new_conf_type,$new_conf_desc);
|
||||
if ($new_conf_type == 'Single') {
|
||||
$new_conf_type = 'single';
|
||||
$new_conf_value = $_POST['new_conf_single_value'];
|
||||
$db_inserted = add_config_item($new_conf_name, $new_conf_value, $new_conf_type, $new_conf_desc);
|
||||
}
|
||||
elseif($new_conf_type == 'Single Array')
|
||||
{
|
||||
$new_conf_type = 'single-array';
|
||||
$new_conf_value = $_POST['new_conf_single_value'];
|
||||
$db_inserted = add_config_item($new_conf_name,$new_conf_value,$new_conf_type,$new_conf_desc);
|
||||
}
|
||||
elseif($new_conf_type == 'Standard Array' || $new_conf_type == 'Multi Array')
|
||||
{
|
||||
if($new_conf_type == 'Standard Array')
|
||||
{
|
||||
$new_conf_type = 'array';
|
||||
}
|
||||
elseif($new_conf_type == 'Multi Array')
|
||||
{
|
||||
$new_conf_type = 'multi-array';
|
||||
}
|
||||
else
|
||||
{
|
||||
# $new_conf_type is invalid so clear values so we don't create any config
|
||||
$new_conf_value = '';
|
||||
}
|
||||
$new_conf_value = nl2br($_POST['new_conf_multi_value']);
|
||||
$values = explode('<br />',$new_conf_value);
|
||||
foreach ($values as $item)
|
||||
{
|
||||
$new_conf_value = trim($item);
|
||||
$db_inserted = add_config_item($new_conf_name,$new_conf_value,$new_conf_type,$new_conf_desc);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo('Bad config type!');
|
||||
$db_inserted = 0;
|
||||
exit;
|
||||
else if ($new_conf_type == 'Single Array') {
|
||||
$new_conf_type = 'single-array';
|
||||
$new_conf_value = $_POST['new_conf_single_value'];
|
||||
$db_inserted = add_config_item($new_conf_name, $new_conf_value, $new_conf_type, $new_conf_desc);
|
||||
}
|
||||
else if ($new_conf_type == 'Standard Array' || $new_conf_type == 'Multi Array') {
|
||||
if ($new_conf_type == 'Standard Array') {
|
||||
$new_conf_type = 'array';
|
||||
}
|
||||
else if ($new_conf_type == 'Multi Array') {
|
||||
$new_conf_type = 'multi-array';
|
||||
}
|
||||
else {
|
||||
// $new_conf_type is invalid so clear values so we don't create any config
|
||||
$new_conf_value = '';
|
||||
}
|
||||
|
||||
if($db_inserted == 1)
|
||||
{
|
||||
echo('Your new config item has been added');
|
||||
}
|
||||
else
|
||||
{
|
||||
echo('An error occurred adding your config item to the database');
|
||||
$new_conf_value = nl2br($_POST['new_conf_multi_value']);
|
||||
$values = explode('<br />', $new_conf_value);
|
||||
foreach ($values as $item) {
|
||||
$new_conf_value = trim($item);
|
||||
$db_inserted = add_config_item($new_conf_name, $new_conf_value, $new_conf_type, $new_conf_desc);
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo 'Bad config type!';
|
||||
$db_inserted = 0;
|
||||
exit;
|
||||
}//end if
|
||||
|
||||
?>
|
||||
if ($db_inserted == 1) {
|
||||
echo 'Your new config item has been added';
|
||||
}
|
||||
else {
|
||||
echo 'An error occurred adding your config item to the database';
|
||||
}
|
||||
|
||||
@@ -13,25 +13,29 @@
|
||||
*/
|
||||
|
||||
$alert_id = mres($_POST['alert_id']);
|
||||
$state = mres($_POST['state']);
|
||||
if(!is_numeric($alert_id)) {
|
||||
echo('ERROR: No alert selected');
|
||||
$state = mres($_POST['state']);
|
||||
if (!is_numeric($alert_id)) {
|
||||
echo 'ERROR: No alert selected';
|
||||
exit;
|
||||
} elseif(!is_numeric($state)) {
|
||||
echo('ERROR: No state passed');
|
||||
}
|
||||
else if (!is_numeric($state)) {
|
||||
echo 'ERROR: No state passed';
|
||||
exit;
|
||||
} else {
|
||||
if($state == 2) {
|
||||
$state = dbFetchCell('SELECT alerted FROM alerts WHERE id = ?',array($alert_id));
|
||||
} elseif($state >= 1) {
|
||||
}
|
||||
else {
|
||||
if ($state == 2) {
|
||||
$state = dbFetchCell('SELECT alerted FROM alerts WHERE id = ?', array($alert_id));
|
||||
}
|
||||
else if ($state >= 1) {
|
||||
$state = 2;
|
||||
}
|
||||
if(dbUpdate(array('state' => $state), 'alerts', 'id=?',array($alert_id)) >= 0) {
|
||||
echo('Alert acknowledged status changed.');
|
||||
exit;
|
||||
} else {
|
||||
echo('ERROR: Alert has not been acknowledged.');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
if (dbUpdate(array('state' => $state), 'alerts', 'id=?', array($alert_id)) >= 0) {
|
||||
echo 'Alert acknowledged status changed.';
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
echo 'ERROR: Alert has not been acknowledged.';
|
||||
exit;
|
||||
}
|
||||
}//end if
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
* 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/>. */
|
||||
|
||||
@@ -44,35 +44,43 @@ if(!empty($name)) {
|
||||
}
|
||||
if(dbUpdate(array('rule_id' => mres($_REQUEST['rule_id']), 'name' => $name), "alert_templates", "id = ?", array($_REQUEST['template_id']))) {
|
||||
$ok = "Updated template and rule id mapping";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$error ="Failed to update the template and rule id mapping";
|
||||
}
|
||||
} elseif( $_REQUEST['template'] && is_numeric($_REQUEST['template_id']) ) {
|
||||
}
|
||||
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']))) {
|
||||
$ok = "Updated template";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$error = "Failed to update the template";
|
||||
}
|
||||
} elseif( $_REQUEST['template'] ) {
|
||||
}
|
||||
elseif( $_REQUEST['template'] ) {
|
||||
//Create new template
|
||||
|
||||
if(dbInsert(array('template' => $_REQUEST['template'], 'name' => $name), "alert_templates")) {
|
||||
$ok = "Alert template has been created.";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$error = "Could not create alert template";
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$error = "We could not work out what you wanted to do!";
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$error = "You haven't given your template a name, it feels sad :( - $name";
|
||||
}
|
||||
|
||||
if(!empty( $ok )) {
|
||||
die("$ok");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
die("ERROR: $error");
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -12,30 +12,32 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
if(is_admin() === false) {
|
||||
if (is_admin() === false) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
if(!is_numeric($_POST['template_id'])) {
|
||||
echo('ERROR: No template selected');
|
||||
if (!is_numeric($_POST['template_id'])) {
|
||||
echo 'ERROR: No template selected';
|
||||
exit;
|
||||
} else {
|
||||
$rules = preg_split("/,/",mres($_POST['rule_id']));
|
||||
$success = FALSE;
|
||||
}
|
||||
else {
|
||||
$rules = preg_split('/,/', mres($_POST['rule_id']));
|
||||
$success = false;
|
||||
foreach ($rules as $rule_id) {
|
||||
$db_id = dbInsert(array('alert_rule_id' => $rule_id, 'alert_templates_id' => mres($_POST['template_id'])), 'alert_template_map');
|
||||
if ($db_id > 0) {
|
||||
$success = TRUE;
|
||||
$ids[] = $db_id;
|
||||
} else {
|
||||
echo('ERROR: Alert rules have not been attached to this template.');
|
||||
$success = true;
|
||||
$ids[] = $db_id;
|
||||
}
|
||||
else {
|
||||
echo 'ERROR: Alert rules have not been attached to this template.';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
if ($success === TRUE) {
|
||||
dbDelete('alert_template_map',"id NOT IN (".implode(',',$ids).")");
|
||||
|
||||
if ($success === true) {
|
||||
dbDelete('alert_template_map', 'id NOT IN ('.implode(',', $ids).')');
|
||||
echo "Alert rules have been attached to this template. $template_map_ids";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
}//end if
|
||||
|
||||
@@ -14,9 +14,11 @@
|
||||
|
||||
if ($_POST['state'] == 'true') {
|
||||
$state = 1;
|
||||
} elseif ($_POST['state'] == 'false') {
|
||||
}
|
||||
elseif ($_POST['state'] == 'false') {
|
||||
$state = 0;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$state = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,36 +13,28 @@
|
||||
*/
|
||||
|
||||
// FUA
|
||||
|
||||
if(!is_numeric($_POST['config_id']))
|
||||
{
|
||||
echo('error with data');
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
if($_POST['state'] == 'true')
|
||||
{
|
||||
$state = 1;
|
||||
}
|
||||
elseif($_POST['state'] == 'false')
|
||||
{
|
||||
$state = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$state = 0;
|
||||
}
|
||||
$update = dbUpdate(array('config_disabled' => $state), 'config', '`config_id` = ?', array($_POST['config_id']));
|
||||
if(!empty($update) || $update == '0')
|
||||
{
|
||||
echo('success');
|
||||
if (!is_numeric($_POST['config_id'])) {
|
||||
echo 'error with data';
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
echo('error');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($_POST['state'] == 'true') {
|
||||
$state = 1;
|
||||
}
|
||||
else if ($_POST['state'] == 'false') {
|
||||
$state = 0;
|
||||
}
|
||||
else {
|
||||
$state = 0;
|
||||
}
|
||||
|
||||
$update = dbUpdate(array('config_disabled' => $state), 'config', '`config_id` = ?', array($_POST['config_id']));
|
||||
if (!empty($update) || $update == '0') {
|
||||
echo 'success';
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
echo 'error';
|
||||
exit;
|
||||
}
|
||||
}//end if
|
||||
|
||||
@@ -13,25 +13,19 @@
|
||||
*/
|
||||
|
||||
// FUA
|
||||
|
||||
if(!is_numeric($_POST['config_id']) || empty($_POST['data']))
|
||||
{
|
||||
echo('error with data');
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$data = mres($_POST['data']);
|
||||
$update = dbUpdate(array('config_value' => "$data"), 'config', '`config_id` = ?', array($_POST['config_id']));
|
||||
if(!empty($update) || $update == '0')
|
||||
{
|
||||
echo('success');
|
||||
if (!is_numeric($_POST['config_id']) || empty($_POST['data'])) {
|
||||
echo 'error with data';
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
echo('error');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
$data = mres($_POST['data']);
|
||||
$update = dbUpdate(array('config_value' => "$data"), 'config', '`config_id` = ?', array($_POST['config_id']));
|
||||
if (!empty($update) || $update == '0') {
|
||||
echo 'success';
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
echo 'error';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,121 +12,145 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
if(is_admin() === false) {
|
||||
$response = array('status'=>'error','message'=>'Need to be admin');
|
||||
if (is_admin() === false) {
|
||||
$response = array(
|
||||
'status' => 'error',
|
||||
'message' => 'Need to be admin',
|
||||
);
|
||||
echo _json_encode($response);
|
||||
exit;
|
||||
}
|
||||
|
||||
$action = mres($_POST['action']);
|
||||
$config_group = mres($_POST['config_group']);
|
||||
$action = mres($_POST['action']);
|
||||
$config_group = mres($_POST['config_group']);
|
||||
$config_sub_group = mres($_POST['config_sub_group']);
|
||||
$config_name = mres($_POST['config_name']);
|
||||
$config_value = mres($_POST['config_value']);
|
||||
$config_extra = mres($_POST['config_extra']);
|
||||
$config_room_id = mres($_POST['config_room_id']);
|
||||
$config_from = mres($_POST['config_from']);
|
||||
$config_userkey = mres($_POST['config_userkey']);
|
||||
$status = 'error';
|
||||
$message = 'Error with config';
|
||||
$config_name = mres($_POST['config_name']);
|
||||
$config_value = mres($_POST['config_value']);
|
||||
$config_extra = mres($_POST['config_extra']);
|
||||
$config_room_id = mres($_POST['config_room_id']);
|
||||
$config_from = mres($_POST['config_from']);
|
||||
$config_userkey = mres($_POST['config_userkey']);
|
||||
$status = 'error';
|
||||
$message = 'Error with config';
|
||||
|
||||
if ($action == 'remove' || $action == 'remove-slack' || $action == 'remove-hipchat' || $action == 'remove-pushover') {
|
||||
$config_id = mres($_POST['config_id']);
|
||||
if (empty($config_id)) {
|
||||
$message = 'No config id passed';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (dbDelete('config', '`config_id`=?', array($config_id))) {
|
||||
if ($action == 'remove-slack') {
|
||||
dbDelete('config', "`config_name` LIKE 'alert.transports.slack.$config_id.%'");
|
||||
} elseif ($action == 'remove-hipchat') {
|
||||
}
|
||||
else if ($action == 'remove-hipchat') {
|
||||
dbDelete('config', "`config_name` LIKE 'alert.transports.hipchat.$config_id.%'");
|
||||
} elseif ($action == 'remove-pushover') {
|
||||
}
|
||||
else if ($action == 'remove-pushover') {
|
||||
dbDelete('config', "`config_name` LIKE 'alert.transports.pushover.$config_id.%'");
|
||||
}
|
||||
$status = 'ok';
|
||||
|
||||
$status = 'ok';
|
||||
$message = 'Config item removed';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$message = 'General error, could not remove config';
|
||||
}
|
||||
}
|
||||
} elseif ($action == 'add-slack') {
|
||||
}
|
||||
else if ($action == 'add-slack') {
|
||||
if (empty($config_value)) {
|
||||
$message = 'No Slack url provided';
|
||||
} else {
|
||||
$config_id = dbInsert(array('config_name' => 'alert.transports.slack.', 'config_value' => $config_value, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default'=>$config_value, 'config_descr'=>'Slack Transport'), 'config');
|
||||
}
|
||||
else {
|
||||
$config_id = dbInsert(array('config_name' => 'alert.transports.slack.', 'config_value' => $config_value, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default' => $config_value, 'config_descr' => 'Slack Transport'), 'config');
|
||||
if ($config_id > 0) {
|
||||
dbUpdate(array('config_name' => 'alert.transports.slack.'.$config_id.'.url'), 'config', 'config_id=?', array($config_id));
|
||||
$status = 'ok';
|
||||
$status = 'ok';
|
||||
$message = 'Config item created';
|
||||
$extras = explode('\n',$config_extra);
|
||||
$extras = explode('\n', $config_extra);
|
||||
foreach ($extras as $option) {
|
||||
list($k,$v) = explode("=", $option,2);
|
||||
list($k,$v) = explode('=', $option, 2);
|
||||
if (!empty($k) || !empty($v)) {
|
||||
dbInsert(array('config_name' => 'alert.transports.slack.'.$config_id.'.'.$k, 'config_value' => $v, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default'=>$v, 'config_descr'=>'Slack Transport'), 'config');
|
||||
dbInsert(array('config_name' => 'alert.transports.slack.'.$config_id.'.'.$k, 'config_value' => $v, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default' => $v, 'config_descr' => 'Slack Transport'), 'config');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$message = 'Could not create config item';
|
||||
}
|
||||
}
|
||||
} elseif ($action == 'add-hipchat') {
|
||||
if (empty($config_value) || empty($config_room_id) || empty($config_from)) {
|
||||
$message = 'No hipchat url, room id or from provided';
|
||||
} else {
|
||||
$config_id = dbInsert(array('config_name' => 'alert.transports.hipchat.', 'config_value' => $config_value, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default'=>$config_value, 'config_descr'=>'Hipchat Transport'), 'config');
|
||||
if ($config_id > 0) {
|
||||
dbUpdate(array('config_name' => 'alert.transports.hipchat.'.$config_id.'.url'), 'config', 'config_id=?', array($config_id));
|
||||
$additional_id['room_id'] = dbInsert(array('config_name' => 'alert.transports.hipchat.'.$config_id.'.room_id', 'config_value' => $config_room_id, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default'=>$config_room_id, 'config_descr'=>'Hipchat URL'), 'config');
|
||||
$additional_id['from'] = dbInsert(array('config_name' => 'alert.transports.hipchat.'.$config_id.'.from', 'config_value' => $config_from, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default'=>$config_from, 'config_descr'=>'Hipchat From'), 'config');
|
||||
$status = 'ok';
|
||||
$message = 'Config item created';
|
||||
$extras = explode('\n',$config_extra);
|
||||
foreach ($extras as $option) {
|
||||
list($k,$v) = explode("=", $option,2);
|
||||
if (!empty($k) || !empty($v)) {
|
||||
dbInsert(array('config_name' => 'alert.transports.hipchat.'.$config_id.'.'.$k, 'config_value' => $v, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default'=>$v, 'config_descr'=>'Hipchat '.$v), 'config');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$message = 'Could not create config item';
|
||||
}
|
||||
}
|
||||
} elseif ($action == 'add-pushover') {
|
||||
if (empty($config_value) || empty($config_userkey)) {
|
||||
$message = 'No pushover appkey or userkey provided';
|
||||
} else {
|
||||
$config_id = dbInsert(array('config_name' => 'alert.transports.pushover.', 'config_value' => $config_value, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default'=>$config_value, 'config_descr'=>'Pushover Transport'), 'config');
|
||||
if ($config_id > 0) {
|
||||
dbUpdate(array('config_name' => 'alert.transports.pushover.'.$config_id.'.appkey'), 'config', 'config_id=?', array($config_id));
|
||||
$additional_id['userkey'] = dbInsert(array('config_name' => 'alert.transports.pushover.'.$config_id.'.userkey', 'config_value' => $config_userkey, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default'=>$config_userkey, 'config_descr'=>'Pushver Userkey'), 'config');
|
||||
$status = 'ok';
|
||||
$message = 'Config item created';
|
||||
$extras = explode('\n',$config_extra);
|
||||
foreach ($extras as $option) {
|
||||
list($k,$v) = explode("=", $option,2);
|
||||
if (!empty($k) || !empty($v)) {
|
||||
dbInsert(array('config_name' => 'alert.transports.pushover.'.$config_id.'.'.$k, 'config_value' => $v, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default'=>$v, 'config_descr'=>'Pushover '.$v), 'config');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$message = 'Could not create config item';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
if (empty($config_group) || empty($config_sub_group) || empty($config_name) || empty($config_value)) {
|
||||
$message = 'Missing config name or value';
|
||||
} else {
|
||||
$config_id = dbInsert(array('config_name' => $config_name, 'config_value' => $config_value, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default'=>$config_value, 'config_descr'=>'API Transport'), 'config');
|
||||
if ($config_id > 0) {
|
||||
dbUpdate(array('config_name'=>$config_name.$config_id),'config','config_id=?',array($config_id));
|
||||
$status = 'ok';
|
||||
$message = 'Config item created';
|
||||
} else {
|
||||
else {
|
||||
$message = 'Could not create config item';
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ($action == 'add-hipchat') {
|
||||
if (empty($config_value) || empty($config_room_id) || empty($config_from)) {
|
||||
$message = 'No hipchat url, room id or from provided';
|
||||
}
|
||||
else {
|
||||
$config_id = dbInsert(array('config_name' => 'alert.transports.hipchat.', 'config_value' => $config_value, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default' => $config_value, 'config_descr' => 'Hipchat Transport'), 'config');
|
||||
if ($config_id > 0) {
|
||||
dbUpdate(array('config_name' => 'alert.transports.hipchat.'.$config_id.'.url'), 'config', 'config_id=?', array($config_id));
|
||||
$additional_id['room_id'] = dbInsert(array('config_name' => 'alert.transports.hipchat.'.$config_id.'.room_id', 'config_value' => $config_room_id, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default' => $config_room_id, 'config_descr' => 'Hipchat URL'), 'config');
|
||||
$additional_id['from'] = dbInsert(array('config_name' => 'alert.transports.hipchat.'.$config_id.'.from', 'config_value' => $config_from, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default' => $config_from, 'config_descr' => 'Hipchat From'), 'config');
|
||||
$status = 'ok';
|
||||
$message = 'Config item created';
|
||||
$extras = explode('\n', $config_extra);
|
||||
foreach ($extras as $option) {
|
||||
list($k,$v) = explode('=', $option, 2);
|
||||
if (!empty($k) || !empty($v)) {
|
||||
dbInsert(array('config_name' => 'alert.transports.hipchat.'.$config_id.'.'.$k, 'config_value' => $v, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default' => $v, 'config_descr' => 'Hipchat '.$v), 'config');
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$message = 'Could not create config item';
|
||||
}
|
||||
}//end if
|
||||
}
|
||||
else if ($action == 'add-pushover') {
|
||||
if (empty($config_value) || empty($config_userkey)) {
|
||||
$message = 'No pushover appkey or userkey provided';
|
||||
}
|
||||
else {
|
||||
$config_id = dbInsert(array('config_name' => 'alert.transports.pushover.', 'config_value' => $config_value, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default' => $config_value, 'config_descr' => 'Pushover Transport'), 'config');
|
||||
if ($config_id > 0) {
|
||||
dbUpdate(array('config_name' => 'alert.transports.pushover.'.$config_id.'.appkey'), 'config', 'config_id=?', array($config_id));
|
||||
$additional_id['userkey'] = dbInsert(array('config_name' => 'alert.transports.pushover.'.$config_id.'.userkey', 'config_value' => $config_userkey, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default' => $config_userkey, 'config_descr' => 'Pushver Userkey'), 'config');
|
||||
$status = 'ok';
|
||||
$message = 'Config item created';
|
||||
$extras = explode('\n', $config_extra);
|
||||
foreach ($extras as $option) {
|
||||
list($k,$v) = explode('=', $option, 2);
|
||||
if (!empty($k) || !empty($v)) {
|
||||
dbInsert(array('config_name' => 'alert.transports.pushover.'.$config_id.'.'.$k, 'config_value' => $v, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default' => $v, 'config_descr' => 'Pushover '.$v), 'config');
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$message = 'Could not create config item';
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (empty($config_group) || empty($config_sub_group) || empty($config_name) || empty($config_value)) {
|
||||
$message = 'Missing config name or value';
|
||||
}
|
||||
else {
|
||||
$config_id = dbInsert(array('config_name' => $config_name, 'config_value' => $config_value, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default' => $config_value, 'config_descr' => 'API Transport'), 'config');
|
||||
if ($config_id > 0) {
|
||||
dbUpdate(array('config_name' => $config_name.$config_id), 'config', 'config_id=?', array($config_id));
|
||||
$status = 'ok';
|
||||
$message = 'Config item created';
|
||||
}
|
||||
else {
|
||||
$message = 'Could not create config item';
|
||||
}
|
||||
}
|
||||
}//end if
|
||||
|
||||
$response = array('status'=>$status,'message'=>$message, 'config_id'=>$config_id, 'additional_id'=>$additional_id);
|
||||
$response = array(
|
||||
'status' => $status,
|
||||
'message' => $message,
|
||||
'config_id' => $config_id,
|
||||
'additional_id' => $additional_id,
|
||||
);
|
||||
echo _json_encode($response);
|
||||
|
||||
@@ -12,68 +12,85 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
if(is_admin() === false) {
|
||||
if (is_admin() === false) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
$rule = implode(" ", $_POST['rules']);
|
||||
$rule = rtrim($rule,'&&');
|
||||
$rule = rtrim($rule,'||');
|
||||
$rule = implode(' ', $_POST['rules']);
|
||||
$rule = rtrim($rule, '&&');
|
||||
$rule = rtrim($rule, '||');
|
||||
$alert_id = $_POST['alert_id'];
|
||||
$count = mres($_POST['count']);
|
||||
$delay = mres($_POST['delay']);
|
||||
$count = mres($_POST['count']);
|
||||
$delay = mres($_POST['delay']);
|
||||
$interval = mres($_POST['interval']);
|
||||
$mute = mres($_POST['mute']);
|
||||
$invert = mres($_POST['invert']);
|
||||
$name = mres($_POST['name']);
|
||||
$mute = mres($_POST['mute']);
|
||||
$invert = mres($_POST['invert']);
|
||||
$name = mres($_POST['name']);
|
||||
|
||||
if(empty($rule)) {
|
||||
$update_message = "ERROR: No rule was generated - did you forget to click and / or?";
|
||||
} elseif(validate_device_id($_POST['device_id']) || $_POST['device_id'] == '-1' || $_POST['device_id'][0] == ':') {
|
||||
if (empty($rule)) {
|
||||
$update_message = 'ERROR: No rule was generated - did you forget to click and / or?';
|
||||
}
|
||||
else if (validate_device_id($_POST['device_id']) || $_POST['device_id'] == '-1' || $_POST['device_id'][0] == ':') {
|
||||
$device_id = $_POST['device_id'];
|
||||
if(!is_numeric($count)) {
|
||||
$count='-1';
|
||||
if (!is_numeric($count)) {
|
||||
$count = '-1';
|
||||
}
|
||||
$delay_sec = convert_delay($delay);
|
||||
|
||||
$delay_sec = convert_delay($delay);
|
||||
$interval_sec = convert_delay($interval);
|
||||
if($mute == 'on') {
|
||||
if ($mute == 'on') {
|
||||
$mute = true;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$mute = false;
|
||||
}
|
||||
if($invert == 'on') {
|
||||
|
||||
if ($invert == 'on') {
|
||||
$invert = true;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$invert = false;
|
||||
}
|
||||
$extra = array('mute'=>$mute,'count'=>$count,'delay'=>$delay_sec,'invert'=>$invert,'interval'=>$interval_sec);
|
||||
|
||||
$extra = array(
|
||||
'mute' => $mute,
|
||||
'count' => $count,
|
||||
'delay' => $delay_sec,
|
||||
'invert' => $invert,
|
||||
'interval' => $interval_sec,
|
||||
);
|
||||
$extra_json = json_encode($extra);
|
||||
if(is_numeric($alert_id) && $alert_id > 0) {
|
||||
if(dbUpdate(array('rule' => $rule,'severity'=>mres($_POST['severity']),'extra'=>$extra_json,'name'=>$name), 'alert_rules', 'id=?',array($alert_id)) >= 0) {
|
||||
if (is_numeric($alert_id) && $alert_id > 0) {
|
||||
if (dbUpdate(array('rule' => $rule, 'severity' => mres($_POST['severity']), 'extra' => $extra_json, 'name' => $name), 'alert_rules', 'id=?', array($alert_id)) >= 0) {
|
||||
$update_message = "Edited Rule: <i>$name: $rule</i>";
|
||||
} else {
|
||||
$update_message = "ERROR: Failed to edit Rule: <i>".$rule."</i>";
|
||||
}
|
||||
} else {
|
||||
if( is_array($_POST['maps']) ) {
|
||||
else {
|
||||
$update_message = 'ERROR: Failed to edit Rule: <i>'.$rule.'</i>';
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (is_array($_POST['maps'])) {
|
||||
$device_id = ':'.$device_id;
|
||||
}
|
||||
if( dbInsert(array('device_id'=>$device_id,'rule'=>$rule,'severity'=>mres($_POST['severity']),'extra'=>$extra_json,'name'=>$name),'alert_rules') ) {
|
||||
|
||||
if (dbInsert(array('device_id' => $device_id, 'rule' => $rule, 'severity' => mres($_POST['severity']), 'extra' => $extra_json, 'name' => $name), 'alert_rules')) {
|
||||
$update_message = "Added Rule: <i>$name: $rule</i>";
|
||||
if( is_array($_POST['maps']) ) {
|
||||
foreach( $_POST['maps'] as $target ) {
|
||||
$_POST['rule'] = $name;
|
||||
if (is_array($_POST['maps'])) {
|
||||
foreach ($_POST['maps'] as $target) {
|
||||
$_POST['rule'] = $name;
|
||||
$_POST['target'] = $target;
|
||||
$_POST['map_id'] = '';
|
||||
include('forms/create-map-item.inc.php');
|
||||
include 'forms/create-map-item.inc.php';
|
||||
unset($ret,$target,$raw,$rule,$msg,$map_id);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$update_message = "ERROR: Failed to add Rule: <i>".$rule."</i>";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$update_message = "ERROR: invalid device ID or not a global alert";
|
||||
else {
|
||||
$update_message = 'ERROR: Failed to add Rule: <i>'.$rule.'</i>';
|
||||
}
|
||||
}//end if
|
||||
}
|
||||
else {
|
||||
$update_message = 'ERROR: invalid device ID or not a global alert';
|
||||
}//end if
|
||||
echo $update_message;
|
||||
|
||||
@@ -12,39 +12,46 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
if(is_admin() === false) {
|
||||
if (is_admin() === false) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
$pattern = $_POST['patterns'];
|
||||
$pattern = $_POST['patterns'];
|
||||
$group_id = $_POST['group_id'];
|
||||
$name = mres($_POST['name']);
|
||||
$desc = mres($_POST['desc']);
|
||||
$name = mres($_POST['name']);
|
||||
$desc = mres($_POST['desc']);
|
||||
|
||||
if( is_array($pattern) ) {
|
||||
$pattern = implode(" ", $pattern);
|
||||
} elseif( !empty($_POST['pattern']) && !empty($_POST['condition']) && !empty($_POST['value']) ) {
|
||||
$pattern = '%'.$_POST['pattern'].' '.$_POST['condition'].' ';
|
||||
if( is_numeric($_POST['value']) ) {
|
||||
$pattern .= $_POST['value'];
|
||||
} else {
|
||||
$pattern .= '"'.$_POST['value'].'"';
|
||||
}
|
||||
if (is_array($pattern)) {
|
||||
$pattern = implode(' ', $pattern);
|
||||
}
|
||||
else if (!empty($_POST['pattern']) && !empty($_POST['condition']) && !empty($_POST['value'])) {
|
||||
$pattern = '%'.$_POST['pattern'].' '.$_POST['condition'].' ';
|
||||
if (is_numeric($_POST['value'])) {
|
||||
$pattern .= $_POST['value'];
|
||||
}
|
||||
else {
|
||||
$pattern .= '"'.$_POST['value'].'"';
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($pattern)) {
|
||||
$update_message = "ERROR: No group was generated";
|
||||
} elseif(is_numeric($group_id) && $group_id > 0) {
|
||||
if(dbUpdate(array('pattern' => $pattern,'name'=>$name,'desc'=>$desc), 'device_groups', 'id=?',array($group_id)) >= 0) {
|
||||
$update_message = "Edited Group: <i>$name: $pattern</i>";
|
||||
} else {
|
||||
$update_message = "ERROR: Failed to edit Group: <i>".$pattern."</i>";
|
||||
if (empty($pattern)) {
|
||||
$update_message = 'ERROR: No group was generated';
|
||||
}
|
||||
else if (is_numeric($group_id) && $group_id > 0) {
|
||||
if (dbUpdate(array('pattern' => $pattern, 'name' => $name, 'desc' => $desc), 'device_groups', 'id=?', array($group_id)) >= 0) {
|
||||
$update_message = "Edited Group: <i>$name: $pattern</i>";
|
||||
}
|
||||
} else {
|
||||
if( dbInsert(array('pattern'=>$pattern,'name'=>$name,'desc'=>$desc),'device_groups') ) {
|
||||
else {
|
||||
$update_message = 'ERROR: Failed to edit Group: <i>'.$pattern.'</i>';
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (dbInsert(array('pattern' => $pattern, 'name' => $name, 'desc' => $desc), 'device_groups')) {
|
||||
$update_message = "Added Group: <i>$name: $pattern</i>";
|
||||
} else {
|
||||
$update_message = "ERROR: Failed to add Group: <i>".$pattern."</i>";
|
||||
}
|
||||
else {
|
||||
$update_message = 'ERROR: Failed to add Group: <i>'.$pattern.'</i>';
|
||||
}
|
||||
}
|
||||
|
||||
echo $update_message;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
if(is_admin() === false) {
|
||||
if (is_admin() === false) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
@@ -21,46 +21,56 @@ $target = mres($_POST['target']);
|
||||
$map_id = mres($_POST['map_id']);
|
||||
$ret = array();
|
||||
|
||||
if( empty($rule) || empty($target) ) {
|
||||
$ret[] = "ERROR: No map was generated";
|
||||
} else {
|
||||
$raw = $rule;
|
||||
$rule = dbFetchCell('SELECT id FROM alert_rules WHERE name = ?',array($rule));
|
||||
if( !is_numeric($rule) ) {
|
||||
array_unshift($ret, "ERROR: Could not find rule for '".$raw."'");
|
||||
} else {
|
||||
$raw = $target;
|
||||
if( $target[0].$target[1] == "g:" ) {
|
||||
$target = "g".dbFetchCell('SELECT id FROM device_groups WHERE name = ?',array(substr($target,2)));
|
||||
} else {
|
||||
$target = dbFetchCell('SELECT device_id FROM devices WHERE hostname = ?',array($target));
|
||||
}
|
||||
if( !is_numeric(str_replace('g','',$target)) ) {
|
||||
array_unshift($ret, "ERROR: Could not find entry for '".$raw."'");
|
||||
} else {
|
||||
if(is_numeric($map_id) && $map_id > 0) {
|
||||
if(dbUpdate(array('rule' => $rule,'target'=>$target), 'alert_map', 'id=?',array($map_id)) >= 0) {
|
||||
$ret[] = "Edited Map: <i>".$map_id.": ".$rule." = ".$target."</i>";
|
||||
} else {
|
||||
array_unshift($ret,"ERROR: Failed to edit Map: <i>".$map_id.": ".$rule." = ".$target."</i>");
|
||||
}
|
||||
} else {
|
||||
if( dbInsert(array('rule'=>$rule,'target'=>$target),'alert_map') ) {
|
||||
$ret[] = "Added Map: <i>".$rule." = ".$target."</i>";
|
||||
} else {
|
||||
array_unshift($ret,"ERROR: Failed to add Map: <i>".$rule." = ".$target."</i>");
|
||||
}
|
||||
}
|
||||
if( ($tmp=dbFetchCell('SELECT device_id FROM alert_rules WHERE id = ?',array($rule))) && $tmp[0] != ":" ) {
|
||||
if(dbUpdate(array('device_id' => ':'.$tmp), 'alert_rules', 'id=?',array($rule)) >= 0) {
|
||||
$ret[] = "Edited Rule: <i>".$rule." device_id = ':".$tmp."'</i>";
|
||||
} else {
|
||||
array_unshift($ret,"ERROR: Failed to edit Rule: <i>".$rule.": device_id = ':".$tmp."'</i>");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (empty($rule) || empty($target)) {
|
||||
$ret[] = 'ERROR: No map was generated';
|
||||
}
|
||||
foreach( $ret as $msg ) {
|
||||
echo $msg."<br/>";
|
||||
else {
|
||||
$raw = $rule;
|
||||
$rule = dbFetchCell('SELECT id FROM alert_rules WHERE name = ?', array($rule));
|
||||
if (!is_numeric($rule)) {
|
||||
array_unshift($ret, "ERROR: Could not find rule for '".$raw."'");
|
||||
}
|
||||
else {
|
||||
$raw = $target;
|
||||
if ($target[0].$target[1] == 'g:') {
|
||||
$target = 'g'.dbFetchCell('SELECT id FROM device_groups WHERE name = ?', array(substr($target, 2)));
|
||||
}
|
||||
else {
|
||||
$target = dbFetchCell('SELECT device_id FROM devices WHERE hostname = ?', array($target));
|
||||
}
|
||||
|
||||
if (!is_numeric(str_replace('g', '', $target))) {
|
||||
array_unshift($ret, "ERROR: Could not find entry for '".$raw."'");
|
||||
}
|
||||
else {
|
||||
if (is_numeric($map_id) && $map_id > 0) {
|
||||
if (dbUpdate(array('rule' => $rule, 'target' => $target), 'alert_map', 'id=?', array($map_id)) >= 0) {
|
||||
$ret[] = 'Edited Map: <i>'.$map_id.': '.$rule.' = '.$target.'</i>';
|
||||
}
|
||||
else {
|
||||
array_unshift($ret, 'ERROR: Failed to edit Map: <i>'.$map_id.': '.$rule.' = '.$target.'</i>');
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (dbInsert(array('rule' => $rule, 'target' => $target), 'alert_map')) {
|
||||
$ret[] = 'Added Map: <i>'.$rule.' = '.$target.'</i>';
|
||||
}
|
||||
else {
|
||||
array_unshift($ret, 'ERROR: Failed to add Map: <i>'.$rule.' = '.$target.'</i>');
|
||||
}
|
||||
}
|
||||
|
||||
if (($tmp = dbFetchCell('SELECT device_id FROM alert_rules WHERE id = ?', array($rule))) && $tmp[0] != ':') {
|
||||
if (dbUpdate(array('device_id' => ':'.$tmp), 'alert_rules', 'id=?', array($rule)) >= 0) {
|
||||
$ret[] = 'Edited Rule: <i>'.$rule." device_id = ':".$tmp."'</i>";
|
||||
}
|
||||
else {
|
||||
array_unshift($ret, 'ERROR: Failed to edit Rule: <i>'.$rule.": device_id = ':".$tmp."'</i>");
|
||||
}
|
||||
}
|
||||
}//end if
|
||||
}//end if
|
||||
}//end if
|
||||
foreach ($ret as $msg) {
|
||||
echo $msg.'<br/>';
|
||||
}
|
||||
|
||||
@@ -12,30 +12,36 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
if(is_admin() === false) {
|
||||
if (is_admin() === false) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
$ret = array();
|
||||
$brk = false;
|
||||
if( !is_numeric($_POST['map_id']) ) {
|
||||
array_unshift($ret,'ERROR: No map selected');
|
||||
} else {
|
||||
if( dbFetchCell('SELECT COUNT(B.id) FROM alert_map,alert_map AS B WHERE alert_map.rule=B.rule && alert_map.id = ?',array($_POST['map_id'])) <= 1 ) {
|
||||
$rule = dbFetchRow('SELECT alert_rules.id,alert_rules.device_id FROM alert_map,alert_rules WHERE alert_map.rule=alert_rules.id && alert_map.id = ?',array($_POST['map_id']));
|
||||
$rule['device_id'] = str_replace(":",'',$rule['device_id']);
|
||||
if( dbUpdate(array('device_id'=>$rule['device_id']),'alert_rules','id = ?',array($rule['id'])) >= 0 ) {
|
||||
$ret[] = "Restored Rule: <i>".$rule['id'].": device_id = '".$rule['device_id']."'</i>";
|
||||
} else {
|
||||
array_unshift($ret, 'ERROR: Rule '.$rule['id'].' has not been restored.');
|
||||
$brk = true;
|
||||
}
|
||||
}
|
||||
if( $brk === false && dbDelete('alert_map', "`id` = ?", array($_POST['map_id'])) ) {
|
||||
$ret[] = 'Map has been deleted.';
|
||||
} else {
|
||||
array_unshift($ret, 'ERROR: Map has not been deleted.');
|
||||
}
|
||||
if (!is_numeric($_POST['map_id'])) {
|
||||
array_unshift($ret, 'ERROR: No map selected');
|
||||
}
|
||||
foreach( $ret as $msg ) {
|
||||
echo $msg."<br/>";
|
||||
else {
|
||||
if (dbFetchCell('SELECT COUNT(B.id) FROM alert_map,alert_map AS B WHERE alert_map.rule=B.rule && alert_map.id = ?', array($_POST['map_id'])) <= 1) {
|
||||
$rule = dbFetchRow('SELECT alert_rules.id,alert_rules.device_id FROM alert_map,alert_rules WHERE alert_map.rule=alert_rules.id && alert_map.id = ?', array($_POST['map_id']));
|
||||
$rule['device_id'] = str_replace(':', '', $rule['device_id']);
|
||||
if (dbUpdate(array('device_id' => $rule['device_id']), 'alert_rules', 'id = ?', array($rule['id'])) >= 0) {
|
||||
$ret[] = 'Restored Rule: <i>'.$rule['id'].": device_id = '".$rule['device_id']."'</i>";
|
||||
}
|
||||
else {
|
||||
array_unshift($ret, 'ERROR: Rule '.$rule['id'].' has not been restored.');
|
||||
$brk = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($brk === false && dbDelete('alert_map', '`id` = ?', array($_POST['map_id']))) {
|
||||
$ret[] = 'Map has been deleted.';
|
||||
}
|
||||
else {
|
||||
array_unshift($ret, 'ERROR: Map has not been deleted.');
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($ret as $msg) {
|
||||
echo $msg.'<br/>';
|
||||
}
|
||||
|
||||
@@ -12,25 +12,28 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
if(is_admin() === false) {
|
||||
if (is_admin() === false) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
if(!is_numeric($_POST['alert_id'])) {
|
||||
echo('ERROR: No alert selected');
|
||||
if (!is_numeric($_POST['alert_id'])) {
|
||||
echo 'ERROR: No alert selected';
|
||||
exit;
|
||||
} else {
|
||||
if(dbDelete('alert_rules', "`id` = ?", array($_POST['alert_id']))) {
|
||||
if(dbDelete('alert_map', "rule = ?", array($_POST['alert_id'])) || dbFetchCell('COUNT(id) FROM alert_map WHERE rule = ?',array($_POST['alert_id'])) == 0) {
|
||||
echo('Maps has been deleted.');
|
||||
} else {
|
||||
echo('WARNING: Maps could not be deleted.');
|
||||
}
|
||||
echo('Alert rule has been deleted.');
|
||||
exit;
|
||||
} else {
|
||||
echo('ERROR: Alert rule has not been deleted.');
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
if (dbDelete('alert_rules', '`id` = ?', array($_POST['alert_id']))) {
|
||||
if (dbDelete('alert_map', 'rule = ?', array($_POST['alert_id'])) || dbFetchCell('COUNT(id) FROM alert_map WHERE rule = ?', array($_POST['alert_id'])) == 0) {
|
||||
echo 'Maps has been deleted.';
|
||||
}
|
||||
else {
|
||||
echo 'WARNING: Maps could not be deleted.';
|
||||
}
|
||||
|
||||
echo 'Alert rule has been deleted.';
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
echo 'ERROR: Alert rule has not been deleted.';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,20 +12,21 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
if(is_admin() === false) {
|
||||
if (is_admin() === false) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
if(!is_numeric($_POST['template_id'])) {
|
||||
echo('ERROR: No template selected');
|
||||
if (!is_numeric($_POST['template_id'])) {
|
||||
echo 'ERROR: No template selected';
|
||||
exit;
|
||||
} else {
|
||||
if(dbDelete('alert_templates', "`id` = ?", array($_POST['template_id']))) {
|
||||
echo('Alert template has been deleted.');
|
||||
exit;
|
||||
} else {
|
||||
echo('ERROR: Alert template has not been deleted.');
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
if (dbDelete('alert_templates', '`id` = ?', array($_POST['template_id']))) {
|
||||
echo 'Alert template has been deleted.';
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
echo 'ERROR: Alert template has not been deleted.';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,26 +12,28 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
if(is_admin() === false) {
|
||||
if (is_admin() === false) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
if(!is_numeric($_POST['group_id'])) {
|
||||
echo('ERROR: No group selected');
|
||||
if (!is_numeric($_POST['group_id'])) {
|
||||
echo 'ERROR: No group selected';
|
||||
exit;
|
||||
} else {
|
||||
if(dbDelete('device_groups', "`id` = ?", array($_POST['group_id']))) {
|
||||
if( dbFetchCell('SELECT COUNT(id) FROM alert_map WHERE target = ?',array('g'.$_POST['group_id'])) >= 1 ) {
|
||||
foreach( dbFetchRows('SELECT id FROM alert_map WHERE target = ?',array('g'.$_POST['group_id'])) as $map ) {
|
||||
$_POST['map_id'] = $map['id'];
|
||||
include('forms/delete-alert-map.inc.php');
|
||||
}
|
||||
else {
|
||||
if (dbDelete('device_groups', '`id` = ?', array($_POST['group_id']))) {
|
||||
if (dbFetchCell('SELECT COUNT(id) FROM alert_map WHERE target = ?', array('g'.$_POST['group_id'])) >= 1) {
|
||||
foreach (dbFetchRows('SELECT id FROM alert_map WHERE target = ?', array('g'.$_POST['group_id'])) as $map) {
|
||||
$_POST['map_id'] = $map['id'];
|
||||
include 'forms/delete-alert-map.inc.php';
|
||||
}
|
||||
}
|
||||
}
|
||||
echo('Group has been deleted.');
|
||||
exit;
|
||||
} else {
|
||||
echo('ERROR: Group has not been deleted.');
|
||||
exit;
|
||||
|
||||
echo 'Group has been deleted.';
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
echo 'ERROR: Group has not been deleted.';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,37 +1,28 @@
|
||||
<?php
|
||||
|
||||
// FUA
|
||||
|
||||
$device['device_id'] = $_POST['device_id'];
|
||||
$module = 'discover_'.$_POST['discovery_module'];
|
||||
$module = 'discover_'.$_POST['discovery_module'];
|
||||
|
||||
if(!isset($module) && validate_device_id($device['device_id']) === false)
|
||||
{
|
||||
echo('error with data');
|
||||
exit;
|
||||
if (!isset($module) && validate_device_id($device['device_id']) === false) {
|
||||
echo 'error with data';
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
if($_POST['state'] == 'true')
|
||||
{
|
||||
$state = 1;
|
||||
}
|
||||
elseif($_POST['state'] == 'false')
|
||||
{
|
||||
$state = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$state = 0;
|
||||
}
|
||||
else {
|
||||
if ($_POST['state'] == 'true') {
|
||||
$state = 1;
|
||||
}
|
||||
else if ($_POST['state'] == 'false') {
|
||||
$state = 0;
|
||||
}
|
||||
else {
|
||||
$state = 0;
|
||||
}
|
||||
|
||||
if(isset($attribs['discover_'.$module]) && $attribs['discover_'.$module] != $config['discover_modules'][$module])
|
||||
{
|
||||
del_dev_attrib($device, $module);
|
||||
}
|
||||
else
|
||||
{
|
||||
set_dev_attrib($device, $module, $state);
|
||||
}
|
||||
if (isset($attribs['discover_'.$module]) && $attribs['discover_'.$module] != $config['discover_modules'][$module]) {
|
||||
del_dev_attrib($device, $module);
|
||||
}
|
||||
else {
|
||||
set_dev_attrib($device, $module, $state);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,24 +13,18 @@
|
||||
*/
|
||||
|
||||
// FUA
|
||||
|
||||
if(!is_numeric($_POST['device_id']) || !is_numeric($_POST['sensor_id']) || (empty($_POST['data']) || !isset($_POST['data'])))
|
||||
{
|
||||
echo('error with data');
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$update = dbUpdate(array($_POST['value_type'] => $_POST['data'], 'sensor_custom' => 'Yes'), 'sensors', '`sensor_id` = ? AND `device_id` = ?', array($_POST['sensor_id'],$_POST['device_id']));
|
||||
if(!empty($update) || $update == '0')
|
||||
{
|
||||
echo('success');
|
||||
if (!is_numeric($_POST['device_id']) || !is_numeric($_POST['sensor_id']) || (empty($_POST['data']) || !isset($_POST['data']))) {
|
||||
echo 'error with data';
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
echo('error');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
$update = dbUpdate(array($_POST['value_type'] => $_POST['data'], 'sensor_custom' => 'Yes'), 'sensors', '`sensor_id` = ? AND `device_id` = ?', array($_POST['sensor_id'], $_POST['device_id']));
|
||||
if (!empty($update) || $update == '0') {
|
||||
echo 'success';
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
echo 'error';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,19 +12,24 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
if(is_admin() === false) {
|
||||
if (is_admin() === false) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
$map_id = $_POST['map_id'];
|
||||
|
||||
if(is_numeric($map_id) && $map_id > 0) {
|
||||
$map = dbFetchRow("SELECT alert_rules.name,alert_map.target FROM alert_map,alert_rules WHERE alert_map.rule=alert_rules.id && alert_map.id = ?",array($map_id));
|
||||
if( $map['target'][0] == "g" ) {
|
||||
$map['target'] = 'g:'.dbFetchCell("SELECT name FROM device_groups WHERE id = ?",array(substr($map['target'],1)));
|
||||
} else {
|
||||
$map['target'] = dbFetchCell("SELECT hostname FROM devices WHERE device_id = ?",array($map['target']));
|
||||
if (is_numeric($map_id) && $map_id > 0) {
|
||||
$map = dbFetchRow('SELECT alert_rules.name,alert_map.target FROM alert_map,alert_rules WHERE alert_map.rule=alert_rules.id && alert_map.id = ?', array($map_id));
|
||||
if ($map['target'][0] == 'g') {
|
||||
$map['target'] = 'g:'.dbFetchCell('SELECT name FROM device_groups WHERE id = ?', array(substr($map['target'], 1)));
|
||||
}
|
||||
$output = array('rule'=>$map['name'],'target'=>$map['target']);
|
||||
else {
|
||||
$map['target'] = dbFetchCell('SELECT hostname FROM devices WHERE device_id = ?', array($map['target']));
|
||||
}
|
||||
|
||||
$output = array(
|
||||
'rule' => $map['name'],
|
||||
'target' => $map['target'],
|
||||
);
|
||||
echo _json_encode($output);
|
||||
}
|
||||
|
||||
@@ -12,17 +12,22 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
if(is_admin() === false) {
|
||||
if (is_admin() === false) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
$alert_id = $_POST['alert_id'];
|
||||
|
||||
if(is_numeric($alert_id) && $alert_id > 0) {
|
||||
$rule = dbFetchRow("SELECT * FROM `alert_rules` WHERE `id` = ? LIMIT 1",array($alert_id));
|
||||
$rule_split = preg_split('/([a-zA-Z0-9_\-\.\=\%\<\>\ \"\'\!\~\(\)\*\/\@]+[&&\|\|]+)/',$rule['rule'], -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
|
||||
$count = count($rule_split) - 1;
|
||||
if (is_numeric($alert_id) && $alert_id > 0) {
|
||||
$rule = dbFetchRow('SELECT * FROM `alert_rules` WHERE `id` = ? LIMIT 1', array($alert_id));
|
||||
$rule_split = preg_split('/([a-zA-Z0-9_\-\.\=\%\<\>\ \"\'\!\~\(\)\*\/\@]+[&&\|\|]+)/', $rule['rule'], -1, (PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY));
|
||||
$count = (count($rule_split) - 1);
|
||||
$rule_split[$count] = $rule_split[$count].' &&';
|
||||
$output = array('severity'=>$rule['severity'],'extra'=>$rule['extra'],'name'=>$rule['name'],'rules'=>$rule_split);
|
||||
$output = array(
|
||||
'severity' => $rule['severity'],
|
||||
'extra' => $rule['extra'],
|
||||
'name' => $rule['name'],
|
||||
'rules' => $rule_split,
|
||||
);
|
||||
echo _json_encode($output);
|
||||
}
|
||||
|
||||
@@ -12,14 +12,17 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
if(is_admin() === false) {
|
||||
if (is_admin() === false) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
$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']);
|
||||
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'],
|
||||
);
|
||||
echo _json_encode($output);
|
||||
}
|
||||
|
||||
@@ -12,21 +12,27 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
if(is_admin() === false) {
|
||||
if (is_admin() === false) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
$group_id = $_POST['group_id'];
|
||||
|
||||
if(is_numeric($group_id) && $group_id > 0) {
|
||||
$group = dbFetchRow("SELECT * FROM `device_groups` WHERE `id` = ? LIMIT 1",array($group_id));
|
||||
$group_split = preg_split('/([a-zA-Z0-9_\-\.\=\%\<\>\ \"\'\!\~\(\)\*\/\@\[\]]+[&&\|\|]+)/',$group['pattern'], -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
|
||||
$count = count($group_split) - 1;
|
||||
if (preg_match("/\&\&$/",$group_split[$count]) == 1 || preg_match("/\|\|$/", $group_split[$count]) == 1) {
|
||||
if (is_numeric($group_id) && $group_id > 0) {
|
||||
$group = dbFetchRow('SELECT * FROM `device_groups` WHERE `id` = ? LIMIT 1', array($group_id));
|
||||
$group_split = preg_split('/([a-zA-Z0-9_\-\.\=\%\<\>\ \"\'\!\~\(\)\*\/\@\[\]]+[&&\|\|]+)/', $group['pattern'], -1, (PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY));
|
||||
$count = (count($group_split) - 1);
|
||||
if (preg_match('/\&\&$/', $group_split[$count]) == 1 || preg_match('/\|\|$/', $group_split[$count]) == 1) {
|
||||
$group_split[$count] = $group_split[$count];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$group_split[$count] = $group_split[$count].' &&';
|
||||
}
|
||||
$output = array('name'=>$group['name'],'desc'=>$group['desc'],'pattern'=>$group_split);
|
||||
|
||||
$output = array(
|
||||
'name' => $group['name'],
|
||||
'desc' => $group['desc'],
|
||||
'pattern' => $group_split,
|
||||
);
|
||||
echo _json_encode($output);
|
||||
}
|
||||
|
||||
@@ -12,14 +12,17 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
if(is_admin() === false) {
|
||||
if (is_admin() === false) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
$group_id = ($_POST['group_id']);
|
||||
|
||||
if(is_numeric($group_id) && $group_id > 0) {
|
||||
$group = dbFetchRow("SELECT * FROM `poller_groups` WHERE `id` = ? LIMIT 1",array($group_id));
|
||||
$output = array('group_name'=>$group['group_name'],'descr'=>$group['descr']);
|
||||
if (is_numeric($group_id) && $group_id > 0) {
|
||||
$group = dbFetchRow('SELECT * FROM `poller_groups` WHERE `id` = ? LIMIT 1', array($group_id));
|
||||
$output = array(
|
||||
'group_name' => $group['group_name'],
|
||||
'descr' => $group['descr'],
|
||||
);
|
||||
echo _json_encode($output);
|
||||
}
|
||||
|
||||
@@ -12,16 +12,17 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
if(is_admin() === false) {
|
||||
if (is_admin() === false) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
$template_id = ($_POST['template_id']);
|
||||
|
||||
if(is_numeric($template_id) && $template_id > 0) {
|
||||
foreach (dbFetchRows("SELECT `alert_rule_id` FROM `alert_template_map` WHERE `alert_templates_id` = ?",array($template_id)) as $rule) {
|
||||
if (is_numeric($template_id) && $template_id > 0) {
|
||||
foreach (dbFetchRows('SELECT `alert_rule_id` FROM `alert_template_map` WHERE `alert_templates_id` = ?', array($template_id)) as $rule) {
|
||||
$rules[] = $rule['alert_rule_id'];
|
||||
}
|
||||
$output = array('rule_id'=>$rules);
|
||||
|
||||
$output = array('rule_id' => $rules);
|
||||
echo _json_encode($output);
|
||||
}
|
||||
|
||||
@@ -13,18 +13,19 @@
|
||||
*/
|
||||
|
||||
if (!is_numeric($_POST['group_id'])) {
|
||||
echo('error with data');
|
||||
exit;
|
||||
} else {
|
||||
if($_POST['confirm'] == 'yes')
|
||||
{
|
||||
$delete = dbDelete('poller_groups', '`id` = ?', array($_POST['group_id']));
|
||||
if ($delete > '0') {
|
||||
echo('Poller group has been removed');
|
||||
exit;
|
||||
} else {
|
||||
echo('An error occurred removing the Poller group');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
echo 'error with data';
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
if ($_POST['confirm'] == 'yes') {
|
||||
$delete = dbDelete('poller_groups', '`id` = ?', array($_POST['group_id']));
|
||||
if ($delete > '0') {
|
||||
echo 'Poller group has been removed';
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
echo 'An error occurred removing the Poller group';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,36 +12,40 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
if(is_admin() === false) {
|
||||
if (is_admin() === false) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
$ok = '';
|
||||
$error = '';
|
||||
$group_id = $_POST['group_id'];
|
||||
$ok = '';
|
||||
$error = '';
|
||||
$group_id = $_POST['group_id'];
|
||||
$group_name = mres($_POST['group_name']);
|
||||
$descr = mres($_POST['descr']);
|
||||
if(!empty($group_name)) {
|
||||
if( is_numeric($group_id)) {
|
||||
if (dbUpdate(array('group_name' => $group_name, 'descr' => $descr), "poller_groups", "id = ?", array($group_id))) {
|
||||
$ok = "Updated poller group";
|
||||
} else {
|
||||
$error = "Failed to update the poller group";
|
||||
$descr = mres($_POST['descr']);
|
||||
if (!empty($group_name)) {
|
||||
if (is_numeric($group_id)) {
|
||||
if (dbUpdate(array('group_name' => $group_name, 'descr' => $descr), 'poller_groups', 'id = ?', array($group_id))) {
|
||||
$ok = 'Updated poller group';
|
||||
}
|
||||
} else {
|
||||
if (dbInsert(array('group_name' => $group_name, 'descr' => $descr), 'poller_groups') >= 0) {
|
||||
$ok = "Added new poller group";
|
||||
} else {
|
||||
$error = "Failed to create new poller group";
|
||||
else {
|
||||
$error = 'Failed to update the poller group';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
else {
|
||||
if (dbInsert(array('group_name' => $group_name, 'descr' => $descr), 'poller_groups') >= 0) {
|
||||
$ok = 'Added new poller group';
|
||||
}
|
||||
else {
|
||||
$error = 'Failed to create new poller group';
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$error = "You haven't given your poller group a name, it feels sad :( - $group_name";
|
||||
}
|
||||
|
||||
if(!empty( $ok )) {
|
||||
if (!empty($ok)) {
|
||||
die("$ok");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
die("ERROR: $error");
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -1,37 +1,28 @@
|
||||
<?php
|
||||
|
||||
// FUA
|
||||
|
||||
$device['device_id'] = $_POST['device_id'];
|
||||
$module = 'poll_'.$_POST['poller_module'];
|
||||
$module = 'poll_'.$_POST['poller_module'];
|
||||
|
||||
if(!isset($module) && validate_device_id($device['device_id']) === false)
|
||||
{
|
||||
echo('error with data');
|
||||
exit;
|
||||
if (!isset($module) && validate_device_id($device['device_id']) === false) {
|
||||
echo 'error with data';
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
if($_POST['state'] == 'true')
|
||||
{
|
||||
$state = 1;
|
||||
}
|
||||
elseif($_POST['state'] == 'false')
|
||||
{
|
||||
$state = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$state = 0;
|
||||
}
|
||||
else {
|
||||
if ($_POST['state'] == 'true') {
|
||||
$state = 1;
|
||||
}
|
||||
else if ($_POST['state'] == 'false') {
|
||||
$state = 0;
|
||||
}
|
||||
else {
|
||||
$state = 0;
|
||||
}
|
||||
|
||||
if(isset($attribs['poll_'.$module]) && $attribs['poll_'.$module] != $config['poller_modules'][$module])
|
||||
{
|
||||
del_dev_attrib($device, $module);
|
||||
}
|
||||
else
|
||||
{
|
||||
set_dev_attrib($device, $module, $state);
|
||||
}
|
||||
if (isset($attribs['poll_'.$module]) && $attribs['poll_'.$module] != $config['poller_modules'][$module]) {
|
||||
del_dev_attrib($device, $module);
|
||||
}
|
||||
else {
|
||||
set_dev_attrib($device, $module, $state);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,20 +13,26 @@
|
||||
*/
|
||||
|
||||
// FIXME: Make this part of the API instead of a standalone function
|
||||
|
||||
if(!is_numeric($_POST['device_id'])) {
|
||||
$status = "error";
|
||||
$message = "Invalid device id";
|
||||
} else {
|
||||
if (!is_numeric($_POST['device_id'])) {
|
||||
$status = 'error';
|
||||
$message = 'Invalid device id';
|
||||
}
|
||||
else {
|
||||
$update = dbUpdate(array('last_discovered' => array('NULL')), 'devices', '`device_id` = ?', array($_POST['device_id']));
|
||||
if(!empty($update) || $update == '0') {
|
||||
$status = "ok";
|
||||
$message = "Device will be rediscovered";
|
||||
} else {
|
||||
$status = "error";
|
||||
$message = "Error rediscovering device";
|
||||
if (!empty($update) || $update == '0') {
|
||||
$status = 'ok';
|
||||
$message = 'Device will be rediscovered';
|
||||
}
|
||||
else {
|
||||
$status = 'error';
|
||||
$message = 'Error rediscovering device';
|
||||
}
|
||||
}
|
||||
$output = array("status" => $status, "message" => $message);
|
||||
header("Content-type: application/json");
|
||||
|
||||
$output = array(
|
||||
'status' => $status,
|
||||
'message' => $message,
|
||||
);
|
||||
|
||||
header('Content-type: application/json');
|
||||
echo _json_encode($output);
|
||||
|
||||
@@ -12,14 +12,13 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
if(is_admin() === false) {
|
||||
if (is_admin() === false) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
$sub_type = $_POST['sub_type'];
|
||||
|
||||
if ($sub_type == 'new-maintenance') {
|
||||
|
||||
// Defaults
|
||||
$status = 'error';
|
||||
$update = 0;
|
||||
@@ -28,6 +27,7 @@ if ($sub_type == 'new-maintenance') {
|
||||
if ($schedule_id > 0) {
|
||||
$update = 1;
|
||||
}
|
||||
|
||||
$title = mres($_POST['title']);
|
||||
$notes = mres($_POST['notes']);
|
||||
$start = mres($_POST['start']);
|
||||
@@ -35,75 +35,98 @@ if ($sub_type == 'new-maintenance') {
|
||||
$maps = mres($_POST['maps']);
|
||||
|
||||
if (empty($title)) {
|
||||
$message = "Missing title<br />";
|
||||
$message = 'Missing title<br />';
|
||||
}
|
||||
|
||||
if (empty($start)) {
|
||||
$message .= "Missing start date<br />";
|
||||
$message .= 'Missing start date<br />';
|
||||
}
|
||||
|
||||
if (empty($end)) {
|
||||
$message .= "Missing end date<br />";
|
||||
$message .= 'Missing end date<br />';
|
||||
}
|
||||
if( !is_array($_POST['maps']) ) {
|
||||
$message .= "Not mapped to any groups or devices<br />";
|
||||
|
||||
if (!is_array($_POST['maps'])) {
|
||||
$message .= 'Not mapped to any groups or devices<br />';
|
||||
}
|
||||
|
||||
if (empty($message)) {
|
||||
if (empty($schedule_id)) {
|
||||
$schedule_id = dbInsert(array('start'=>$start,'end'=>$end,'title'=>$title,'notes'=>$notes),'alert_schedule');
|
||||
} else {
|
||||
dbUpdate(array('start'=>$start,'end'=>$end,'title'=>$title,'notes'=>$notes),'alert_schedule','`schedule_id`=?',array($schedule_id));
|
||||
$schedule_id = dbInsert(array('start' => $start, 'end' => $end, 'title' => $title, 'notes' => $notes), 'alert_schedule');
|
||||
}
|
||||
else {
|
||||
dbUpdate(array('start' => $start, 'end' => $end, 'title' => $title, 'notes' => $notes), 'alert_schedule', '`schedule_id`=?', array($schedule_id));
|
||||
}
|
||||
|
||||
if ($schedule_id > 0) {
|
||||
$items = array();
|
||||
$fail = 0;
|
||||
|
||||
$fail = 0;
|
||||
|
||||
if ($update == 1) {
|
||||
dbDelete('alert_schedule_items', '`schedule_id`=?', array($schedule_id));
|
||||
}
|
||||
|
||||
foreach( $_POST['maps'] as $target ) {
|
||||
foreach ($_POST['maps'] as $target) {
|
||||
$target = target_to_id($target);
|
||||
$item = dbInsert(array('schedule_id'=>$schedule_id,'target'=>$target),'alert_schedule_items');
|
||||
$item = dbInsert(array('schedule_id' => $schedule_id, 'target' => $target), 'alert_schedule_items');
|
||||
if ($item > 0) {
|
||||
array_push($items,$item);
|
||||
} else {
|
||||
array_push($items, $item);
|
||||
}
|
||||
else {
|
||||
$fail = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ($fail == 1 && $update == 0) {
|
||||
foreach ($items as $item) {
|
||||
dbDelete('alert_schedule_items', '`item_id`=?', array($item));
|
||||
}
|
||||
|
||||
dbDelete('alert_schedule', '`schedule_id`=?', array($schedule_id));
|
||||
$message = 'Issue scheduling maintenance';
|
||||
} else {
|
||||
$status = 'ok';
|
||||
}
|
||||
else {
|
||||
$status = 'ok';
|
||||
$message = 'Scheduling maintenance ok';
|
||||
}
|
||||
} else {
|
||||
$message = "Issue scheduling maintenance";
|
||||
}
|
||||
}
|
||||
else {
|
||||
$message = 'Issue scheduling maintenance';
|
||||
}//end if
|
||||
}//end if
|
||||
|
||||
$response = array('status'=>$status,'message'=>$message);
|
||||
|
||||
} elseif ($sub_type == 'parse-maintenance') {
|
||||
|
||||
$schedule_id = mres($_POST['schedule_id']);
|
||||
$schedule = dbFetchRow("SELECT * FROM `alert_schedule` WHERE `schedule_id`=?",array($schedule_id));
|
||||
$items = array();
|
||||
foreach (dbFetchRows("SELECT `target` FROM `alert_schedule_items` WHERE `schedule_id`=?",array($schedule_id)) as $targets) {
|
||||
$targets = id_to_target($targets['target']);
|
||||
array_push($items,$targets);
|
||||
}
|
||||
$response = array('start'=>$schedule['start'],'end'=>$schedule['end'],'title'=>$schedule['title'],'notes'=>$schedule['notes'],'targets'=>$items);
|
||||
} elseif ($sub_type == 'del-maintenance') {
|
||||
$schedule_id = mres($_POST['del_schedule_id']);
|
||||
dbDelete('alert_schedule_items','`schedule_id`=?',array($schedule_id));
|
||||
dbDelete('alert_schedule','`schedule_id`=?', array($schedule_id));
|
||||
$status = 'ok';
|
||||
$message = 'Maintenance schedule has been removed';
|
||||
$response = array('status'=>$status,'message'=>$message);
|
||||
$response = array(
|
||||
'status' => $status,
|
||||
'message' => $message,
|
||||
);
|
||||
}
|
||||
else if ($sub_type == 'parse-maintenance') {
|
||||
$schedule_id = mres($_POST['schedule_id']);
|
||||
$schedule = dbFetchRow('SELECT * FROM `alert_schedule` WHERE `schedule_id`=?', array($schedule_id));
|
||||
$items = array();
|
||||
foreach (dbFetchRows('SELECT `target` FROM `alert_schedule_items` WHERE `schedule_id`=?', array($schedule_id)) as $targets) {
|
||||
$targets = id_to_target($targets['target']);
|
||||
array_push($items, $targets);
|
||||
}
|
||||
|
||||
$response = array(
|
||||
'start' => $schedule['start'],
|
||||
'end' => $schedule['end'],
|
||||
'title' => $schedule['title'],
|
||||
'notes' => $schedule['notes'],
|
||||
'targets' => $items,
|
||||
);
|
||||
}
|
||||
else if ($sub_type == 'del-maintenance') {
|
||||
$schedule_id = mres($_POST['del_schedule_id']);
|
||||
dbDelete('alert_schedule_items', '`schedule_id`=?', array($schedule_id));
|
||||
dbDelete('alert_schedule', '`schedule_id`=?', array($schedule_id));
|
||||
$status = 'ok';
|
||||
$message = 'Maintenance schedule has been removed';
|
||||
$response = array(
|
||||
'status' => $status,
|
||||
'message' => $message,
|
||||
);
|
||||
}//end if
|
||||
|
||||
echo _json_encode($response);
|
||||
|
||||
@@ -13,9 +13,6 @@
|
||||
*/
|
||||
|
||||
// FUA
|
||||
|
||||
for($x=0;$x<count($_POST['sensor_id']);$x++)
|
||||
{
|
||||
dbUpdate(array('sensor_limit' => $_POST['sensor_limit'][$x], 'sensor_limit_low' => $_POST['sensor_limit_low'][$x], 'sensor_alert' => $_POST['sensor_alert'][$x]), 'sensors', '`sensor_id` = ?', array($_POST['sensor_id'][$x]));
|
||||
for ($x = 0; $x < count($_POST['sensor_id']); $x++) {
|
||||
dbUpdate(array('sensor_limit' => $_POST['sensor_limit'][$x], 'sensor_limit_low' => $_POST['sensor_limit_low'][$x], 'sensor_alert' => $_POST['sensor_alert'][$x]), 'sensors', '`sensor_id` = ?', array($_POST['sensor_id'][$x]));
|
||||
}
|
||||
|
||||
|
||||
@@ -13,41 +13,33 @@
|
||||
*/
|
||||
|
||||
// FUA
|
||||
|
||||
if (isset($_POST['sub_type']) && !empty($_POST['sub_type'])) {
|
||||
dbUpdate(array('sensor_custom' => 'No'), 'sensors', '`sensor_id` = ?', array($_POST['sensor_id']));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (!is_numeric($_POST['device_id']) || !is_numeric($_POST['sensor_id'])) {
|
||||
echo 'error with data';
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
if ($_POST['state'] == 'true') {
|
||||
$state = 1;
|
||||
}
|
||||
else if ($_POST['state'] == 'false') {
|
||||
$state = 0;
|
||||
}
|
||||
else {
|
||||
$state = 0;
|
||||
}
|
||||
|
||||
if(!is_numeric($_POST['device_id']) || !is_numeric($_POST['sensor_id']))
|
||||
{
|
||||
echo('error with data');
|
||||
exit;
|
||||
$update = dbUpdate(array('sensor_alert' => $state), 'sensors', '`sensor_id` = ? AND `device_id` = ?', array($_POST['sensor_id'], $_POST['device_id']));
|
||||
if (!empty($update) || $update == '0') {
|
||||
echo 'success';
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
echo 'error';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($_POST['state'] == 'true')
|
||||
{
|
||||
$state = 1;
|
||||
}
|
||||
elseif($_POST['state'] == 'false')
|
||||
{
|
||||
$state = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$state = 0;
|
||||
}
|
||||
$update = dbUpdate(array('sensor_alert' => $state), 'sensors', '`sensor_id` = ? AND `device_id` = ?', array($_POST['sensor_id'],$_POST['device_id']));
|
||||
if(!empty($update) || $update == '0')
|
||||
{
|
||||
echo('success');
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
echo('error');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,33 +12,27 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
if(!is_numeric($_POST['user_id']) || !isset($_POST['token']))
|
||||
{
|
||||
echo('ERROR: error with data, please ensure a valid user and token have been specified.');
|
||||
exit;
|
||||
}
|
||||
elseif(strlen($_POST['token']) > 32)
|
||||
{
|
||||
echo('ERROR: The token is more than 32 characters');
|
||||
exit;
|
||||
}
|
||||
elseif(strlen($_POST['token']) < 16)
|
||||
{
|
||||
echo('ERROR: The token is less than 16 characters');
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$create = dbInsert(array('user_id' => $_POST['user_id'], 'token_hash' => $_POST['token'], 'description' => $_POST['description']), 'api_tokens');
|
||||
if($create > '0')
|
||||
{
|
||||
echo('API token has been created');
|
||||
$_SESSION['api_token'] = TRUE;
|
||||
if (!is_numeric($_POST['user_id']) || !isset($_POST['token'])) {
|
||||
echo 'ERROR: error with data, please ensure a valid user and token have been specified.';
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
echo('ERROR: An error occurred creating the API token');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else if (strlen($_POST['token']) > 32) {
|
||||
echo 'ERROR: The token is more than 32 characters';
|
||||
exit;
|
||||
}
|
||||
else if (strlen($_POST['token']) < 16) {
|
||||
echo 'ERROR: The token is less than 16 characters';
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
$create = dbInsert(array('user_id' => $_POST['user_id'], 'token_hash' => $_POST['token'], 'description' => $_POST['description']), 'api_tokens');
|
||||
if ($create > '0') {
|
||||
echo 'API token has been created';
|
||||
$_SESSION['api_token'] = true;
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
echo 'ERROR: An error occurred creating the API token';
|
||||
exit;
|
||||
}
|
||||
}//end if
|
||||
|
||||
@@ -12,34 +12,28 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
if(!is_numeric($_POST['token_id']))
|
||||
{
|
||||
echo('error with data');
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
if($_POST['state'] == 'true')
|
||||
{
|
||||
$state = 1;
|
||||
}
|
||||
elseif($_POST['state'] == 'false')
|
||||
{
|
||||
$state = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$state = 0;
|
||||
}
|
||||
$update = dbUpdate(array('disabled' => $state), 'api_tokens', '`id` = ?', array($_POST['token_id']));
|
||||
if(!empty($update) || $update == '0')
|
||||
{
|
||||
echo('success');
|
||||
if (!is_numeric($_POST['token_id'])) {
|
||||
echo 'error with data';
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
echo('error');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($_POST['state'] == 'true') {
|
||||
$state = 1;
|
||||
}
|
||||
else if ($_POST['state'] == 'false') {
|
||||
$state = 0;
|
||||
}
|
||||
else {
|
||||
$state = 0;
|
||||
}
|
||||
|
||||
$update = dbUpdate(array('disabled' => $state), 'api_tokens', '`id` = ?', array($_POST['token_id']));
|
||||
if (!empty($update) || $update == '0') {
|
||||
echo 'success';
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
echo 'error';
|
||||
exit;
|
||||
}
|
||||
}//end if
|
||||
|
||||
@@ -12,25 +12,20 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
if(!is_numeric($_POST['token_id']))
|
||||
{
|
||||
echo('error with data');
|
||||
exit;
|
||||
if (!is_numeric($_POST['token_id'])) {
|
||||
echo 'error with data';
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
if($_POST['confirm'] == 'yes')
|
||||
{
|
||||
$delete = dbDelete('api_tokens', '`id` = ?', array($_POST['token_id']));
|
||||
if($delete > '0')
|
||||
{
|
||||
echo('API token has been removed');
|
||||
exit;
|
||||
else {
|
||||
if ($_POST['confirm'] == 'yes') {
|
||||
$delete = dbDelete('api_tokens', '`id` = ?', array($_POST['token_id']));
|
||||
if ($delete > '0') {
|
||||
echo 'API token has been removed';
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
echo 'An error occurred removing the API token';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo('An error occurred removing the API token');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}//end if
|
||||
|
||||
@@ -12,39 +12,32 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
if(is_admin() === false) {
|
||||
if (is_admin() === false) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
if(!is_numeric($_POST['alert_id']))
|
||||
{
|
||||
echo('ERROR: No alert selected');
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
if($_POST['state'] == 'true')
|
||||
{
|
||||
$state = 0;
|
||||
}
|
||||
elseif($_POST['state'] == 'false')
|
||||
{
|
||||
$state = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$state = 1;
|
||||
}
|
||||
$update = dbUpdate(array('disabled' => $state), 'alert_rules', '`id`=?', array($_POST['alert_id']));
|
||||
if(!empty($update) || $update == '0')
|
||||
{
|
||||
echo('Alert rule has been updated.');
|
||||
if (!is_numeric($_POST['alert_id'])) {
|
||||
echo 'ERROR: No alert selected';
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
echo('ERROR: Alert rule has not been updated.');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($_POST['state'] == 'true') {
|
||||
$state = 0;
|
||||
}
|
||||
else if ($_POST['state'] == 'false') {
|
||||
$state = 1;
|
||||
}
|
||||
else {
|
||||
$state = 1;
|
||||
}
|
||||
|
||||
$update = dbUpdate(array('disabled' => $state), 'alert_rules', '`id`=?', array($_POST['alert_id']));
|
||||
if (!empty($update) || $update == '0') {
|
||||
echo 'Alert rule has been updated.';
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
echo 'ERROR: Alert rule has not been updated.';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,58 +12,70 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
if(is_admin() === false) {
|
||||
if (is_admin() === false) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
$config_id = mres($_POST['config_id']);
|
||||
$action = mres($_POST['action']);
|
||||
$config_id = mres($_POST['config_id']);
|
||||
$action = mres($_POST['action']);
|
||||
$config_type = mres($_POST['config_type']);
|
||||
|
||||
$status = 'error';
|
||||
|
||||
if (!is_numeric($config_id)) {
|
||||
$message = 'ERROR: No alert selected';
|
||||
} elseif ($action == 'update-textarea') {
|
||||
$extras = explode(PHP_EOL,$_POST['config_value']);
|
||||
}
|
||||
else if ($action == 'update-textarea') {
|
||||
$extras = explode(PHP_EOL, $_POST['config_value']);
|
||||
foreach ($extras as $option) {
|
||||
list($k,$v) = explode("=", $option,2);
|
||||
list($k,$v) = explode('=', $option, 2);
|
||||
if (!empty($k) || !empty($v)) {
|
||||
if ($config_type == 'slack') {
|
||||
$db_id[] = dbInsert(array('config_name' => 'alert.transports.slack.'.$config_id.'.'.$k, 'config_value' => $v, 'config_group' => 'alerting', 'config_sub_group' => 'transports', 'config_default'=>$v, 'config_descr'=>'Slack Transport'), 'config');
|
||||
} elseif ($config_type == 'hipchat') {
|
||||
$db_id[] = dbInsert(array('config_name' => 'alert.transports.hipchat.'.$config_id.'.'.$k, 'config_value' => $v, 'config_group' => 'alerting', 'config_sub_group' => 'transports', 'config_default'=>$v, 'config_descr'=>'Hipchat Transport'), 'config');
|
||||
} elseif ($config_type == 'pushover') {
|
||||
$db_id[] = dbInsert(array('config_name' => 'alert.transports.pushover.'.$config_id.'.'.$k, 'config_value' => $v, 'config_group' => 'alerting', 'config_sub_group' => 'transports', 'config_default'=>$v, 'config_descr'=>'Pushover Transport'), 'config');
|
||||
$db_id[] = dbInsert(array('config_name' => 'alert.transports.slack.'.$config_id.'.'.$k, 'config_value' => $v, 'config_group' => 'alerting', 'config_sub_group' => 'transports', 'config_default' => $v, 'config_descr' => 'Slack Transport'), 'config');
|
||||
}
|
||||
else if ($config_type == 'hipchat') {
|
||||
$db_id[] = dbInsert(array('config_name' => 'alert.transports.hipchat.'.$config_id.'.'.$k, 'config_value' => $v, 'config_group' => 'alerting', 'config_sub_group' => 'transports', 'config_default' => $v, 'config_descr' => 'Hipchat Transport'), 'config');
|
||||
}
|
||||
else if ($config_type == 'pushover') {
|
||||
$db_id[] = dbInsert(array('config_name' => 'alert.transports.pushover.'.$config_id.'.'.$k, 'config_value' => $v, 'config_group' => 'alerting', 'config_sub_group' => 'transports', 'config_default' => $v, 'config_descr' => 'Pushover Transport'), 'config');
|
||||
}
|
||||
}
|
||||
}
|
||||
$db_inserts = implode(",",$db_id);
|
||||
|
||||
$db_inserts = implode(',', $db_id);
|
||||
if (!empty($db_inserts) || empty($_POST['config_value'])) {
|
||||
if (empty($_POST['config_value'])) {
|
||||
$db_inserts = 0;
|
||||
}
|
||||
|
||||
if ($config_type == 'slack') {
|
||||
dbDelete('config',"(`config_name` LIKE 'alert.transports.slack.$config_id.%' AND `config_name` != 'alert.transports.slack.$config_id.url' AND `config_id` NOT IN ($db_inserts))");
|
||||
} elseif ($config_type == 'hipchat') {
|
||||
dbDelete('config',"(`config_name` LIKE 'alert.transports.hipchat.$config_id.%' AND (`config_name` != 'alert.transports.hipchat.$config_id.url' AND `config_name` != 'alert.transports.hipchat.$config_id.room_id' AND `config_name` != 'alert.transports.hipchat.$config_id.from') AND `config_id` NOT IN ($db_inserts))");
|
||||
} elseif ($config_type == 'pushover') {
|
||||
dbDelete('config',"(`config_name` LIKE 'alert.transports.pushover.$config_id.%' AND (`config_name` != 'alert.transports.pushover.$config_id.appkey' AND `config_name` != 'alert.transports.pushover.$config_id.userkey') AND `config_id` NOT IN ($db_inserts))");
|
||||
dbDelete('config', "(`config_name` LIKE 'alert.transports.slack.$config_id.%' AND `config_name` != 'alert.transports.slack.$config_id.url' AND `config_id` NOT IN ($db_inserts))");
|
||||
}
|
||||
else if ($config_type == 'hipchat') {
|
||||
dbDelete('config', "(`config_name` LIKE 'alert.transports.hipchat.$config_id.%' AND (`config_name` != 'alert.transports.hipchat.$config_id.url' AND `config_name` != 'alert.transports.hipchat.$config_id.room_id' AND `config_name` != 'alert.transports.hipchat.$config_id.from') AND `config_id` NOT IN ($db_inserts))");
|
||||
}
|
||||
else if ($config_type == 'pushover') {
|
||||
dbDelete('config', "(`config_name` LIKE 'alert.transports.pushover.$config_id.%' AND (`config_name` != 'alert.transports.pushover.$config_id.appkey' AND `config_name` != 'alert.transports.pushover.$config_id.userkey') AND `config_id` NOT IN ($db_inserts))");
|
||||
}
|
||||
}
|
||||
|
||||
$message = 'Config item has been updated:';
|
||||
$status = 'ok';
|
||||
} else {
|
||||
$state = mres($_POST['config_value']);
|
||||
$status = 'ok';
|
||||
}
|
||||
else {
|
||||
$state = mres($_POST['config_value']);
|
||||
$update = dbUpdate(array('config_value' => $state), 'config', '`config_id`=?', array($config_id));
|
||||
if(!empty($update) || $update == '0')
|
||||
{
|
||||
if (!empty($update) || $update == '0') {
|
||||
$message = 'Alert rule has been updated.';
|
||||
$status = 'ok';
|
||||
} else {
|
||||
$status = 'ok';
|
||||
}
|
||||
else {
|
||||
$message = 'ERROR: Alert rule has not been updated.';
|
||||
}
|
||||
}
|
||||
}//end if
|
||||
|
||||
$response = array('status'=>$status,'message'=>$message);
|
||||
$response = array(
|
||||
'status' => $status,
|
||||
'message' => $message,
|
||||
);
|
||||
echo _json_encode($response);
|
||||
|
||||
@@ -13,30 +13,28 @@
|
||||
*
|
||||
*/
|
||||
|
||||
include_once("../includes/defaults.inc.php");
|
||||
include_once("../config.php");
|
||||
include_once("../includes/definitions.inc.php");
|
||||
require_once '../includes/defaults.inc.php';
|
||||
require_once '../config.php';
|
||||
require_once '../includes/definitions.inc.php';
|
||||
|
||||
include_once("../includes/common.php");
|
||||
include_once("../includes/dbFacile.php");
|
||||
include_once("../includes/rewrites.php");
|
||||
include_once("includes/functions.inc.php");
|
||||
include_once("includes/authenticate.inc.php");
|
||||
require_once '../includes/common.php';
|
||||
require_once '../includes/dbFacile.php';
|
||||
require_once '../includes/rewrites.php';
|
||||
require_once 'includes/functions.inc.php';
|
||||
require_once 'includes/authenticate.inc.php';
|
||||
|
||||
include_once("../includes/snmp.inc.php");
|
||||
|
||||
if (is_numeric($_GET['id']) && ($config['allow_unauth_graphs'] || port_permitted($_GET['id'])))
|
||||
{
|
||||
$port = get_port_by_id($_GET['id']);
|
||||
$device = device_by_id_cache($port['device_id']);
|
||||
$title = generate_device_link($device);
|
||||
$title .= " :: Port ".generate_port_link($port);
|
||||
$auth = TRUE;
|
||||
} else {
|
||||
|
||||
echo("Unauthenticad");
|
||||
die;
|
||||
require_once '../includes/snmp.inc.php';
|
||||
|
||||
if (is_numeric($_GET['id']) && ($config['allow_unauth_graphs'] || port_permitted($_GET['id']))) {
|
||||
$port = get_port_by_id($_GET['id']);
|
||||
$device = device_by_id_cache($port['device_id']);
|
||||
$title = generate_device_link($device);
|
||||
$title .= " :: Port ".generate_port_link($port);
|
||||
$auth = TRUE;
|
||||
}
|
||||
else {
|
||||
echo("Unauthenticad");
|
||||
die;
|
||||
}
|
||||
|
||||
header("Content-type: image/svg+xml");
|
||||
@@ -47,16 +45,19 @@ $ifname=ifLabel($port);
|
||||
$ifname=$ifname['label']; //Interface name that will be showed on top right of graph
|
||||
$hostname=shorthost($device['hostname']);
|
||||
|
||||
if($_GET['title']) { $ifname = $_GET['title']; }
|
||||
if($_GET['title']) {
|
||||
$ifname = $_GET['title'];
|
||||
}
|
||||
|
||||
/********* Other conf *******/
|
||||
$scale_type="follow"; //Autoscale default setup : "up" = only increase scale; "follow" = increase and decrease scale according to current graphed datas
|
||||
$nb_plot=240; //NB plot in graph
|
||||
|
||||
if(is_numeric($_GET['interval'])) {
|
||||
$time_interval=$_GET['interval'];
|
||||
} else {
|
||||
$time_interval=1; //Refresh time Interval
|
||||
$time_interval=$_GET['interval'];
|
||||
}
|
||||
else {
|
||||
$time_interval=1; //Refresh time Interval
|
||||
}
|
||||
|
||||
$fetch_link = "data.php?id=".$_GET[id];
|
||||
@@ -225,24 +226,24 @@ function plot_data(obj) {
|
||||
last_ifout = ifout;
|
||||
|
||||
switch (plot_in.length) {
|
||||
case 0:
|
||||
SVGDoc.getElementById("collect_initial").setAttributeNS(null, 'visibility', 'visible');
|
||||
plot_in[0] = diff_ifin / diff_ugmt;
|
||||
plot_out[0] = diff_ifout / diff_ugmt;
|
||||
setTimeout('fetch_data()',<?php echo(1000*$time_interval) ?>);
|
||||
return;
|
||||
case 1:
|
||||
SVGDoc.getElementById("collect_initial").setAttributeNS(null, 'visibility', 'hidden');
|
||||
break;
|
||||
case 0:
|
||||
SVGDoc.getElementById("collect_initial").setAttributeNS(null, 'visibility', 'visible');
|
||||
plot_in[0] = diff_ifin / diff_ugmt;
|
||||
plot_out[0] = diff_ifout / diff_ugmt;
|
||||
setTimeout('fetch_data()',<?php echo(1000*$time_interval) ?>);
|
||||
return;
|
||||
case 1:
|
||||
SVGDoc.getElementById("collect_initial").setAttributeNS(null, 'visibility', 'hidden');
|
||||
break;
|
||||
case max_num_points:
|
||||
// shift plot to left if the maximum number of plot points has been reached
|
||||
var i = 0;
|
||||
while (i < max_num_points) {
|
||||
plot_in[i] = plot_in[i+1];
|
||||
plot_out[i] = plot_out[++i];
|
||||
}
|
||||
plot_in.length--;
|
||||
plot_out.length--;
|
||||
// shift plot to left if the maximum number of plot points has been reached
|
||||
var i = 0;
|
||||
while (i < max_num_points) {
|
||||
plot_in[i] = plot_in[i+1];
|
||||
plot_out[i] = plot_out[++i];
|
||||
}
|
||||
plot_in.length--;
|
||||
plot_out.length--;
|
||||
}
|
||||
|
||||
plot_in[plot_in.length] = diff_ifin / diff_ugmt;
|
||||
|
||||
@@ -9,62 +9,57 @@
|
||||
* @subpackage graphing
|
||||
* @author Adam Armstrong <adama@memetic.org>
|
||||
* @copyright (C) 2006 - 2012 Adam Armstrong
|
||||
*
|
||||
*/
|
||||
|
||||
function utime()
|
||||
{
|
||||
$time = explode(" ", microtime());
|
||||
$usec = (double)$time[0];
|
||||
$sec = (double)$time[1];
|
||||
return $sec + $usec;
|
||||
|
||||
function utime() {
|
||||
$time = explode(' ', microtime());
|
||||
$usec = (double) $time[0];
|
||||
$sec = (double) $time[1];
|
||||
return ($sec + $usec);
|
||||
|
||||
}
|
||||
|
||||
$start = utime();
|
||||
|
||||
include_once("Net/IPv4.php");
|
||||
require_once 'Net/IPv4.php';
|
||||
|
||||
if (isset($_GET['debug']))
|
||||
{
|
||||
$debug = TRUE;
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 0);
|
||||
ini_set('log_errors', 0);
|
||||
ini_set('error_reporting', E_ALL);
|
||||
if (isset($_GET['debug'])) {
|
||||
$debug = true;
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 0);
|
||||
ini_set('log_errors', 0);
|
||||
ini_set('error_reporting', E_ALL);
|
||||
}
|
||||
else
|
||||
{
|
||||
$debug = FALSE;
|
||||
ini_set('display_errors', 0);
|
||||
ini_set('display_startup_errors', 0);
|
||||
ini_set('log_errors', 0);
|
||||
ini_set('error_reporting', 0);
|
||||
else {
|
||||
$debug = false;
|
||||
ini_set('display_errors', 0);
|
||||
ini_set('display_startup_errors', 0);
|
||||
ini_set('log_errors', 0);
|
||||
ini_set('error_reporting', 0);
|
||||
}
|
||||
|
||||
include_once("../includes/defaults.inc.php");
|
||||
include_once("../config.php");
|
||||
include_once("../includes/definitions.inc.php");
|
||||
include_once("../includes/common.php");
|
||||
include_once("../includes/console_colour.php");
|
||||
include_once("../includes/dbFacile.php");
|
||||
include_once("../includes/rewrites.php");
|
||||
include_once("includes/functions.inc.php");
|
||||
include_once("../includes/rrdtool.inc.php");
|
||||
include_once("includes/authenticate.inc.php");
|
||||
require_once '../includes/defaults.inc.php';
|
||||
require_once '../config.php';
|
||||
require_once '../includes/definitions.inc.php';
|
||||
require_once '../includes/common.php';
|
||||
require_once '../includes/console_colour.php';
|
||||
require_once '../includes/dbFacile.php';
|
||||
require_once '../includes/rewrites.php';
|
||||
require_once 'includes/functions.inc.php';
|
||||
require_once '../includes/rrdtool.inc.php';
|
||||
require_once 'includes/authenticate.inc.php';
|
||||
|
||||
include("includes/graphs/graph.inc.php");
|
||||
require 'includes/graphs/graph.inc.php';
|
||||
|
||||
$console_color = new Console_Color2();
|
||||
|
||||
$end = utime(); $run = $end - $start;;
|
||||
$end = utime();
|
||||
$run = ($end - $start);
|
||||
|
||||
if($debug) { echo("<br />Runtime ".$run." secs");
|
||||
|
||||
echo('<br />MySQL: Cell '.($db_stats['fetchcell']+0).'/'.round($db_stats['fetchcell_sec']+0,3).'s'.
|
||||
' Row '.($db_stats['fetchrow']+0). '/'.round($db_stats['fetchrow_sec']+0,3).'s'.
|
||||
' Rows '.($db_stats['fetchrows']+0).'/'.round($db_stats['fetchrows_sec']+0,3).'s'.
|
||||
' Column '.($db_stats['fetchcol']+0). '/'.round($db_stats['fetchcol_sec']+0,3).'s');
|
||||
if ($debug) {
|
||||
echo '<br />Runtime '.$run.' secs';
|
||||
|
||||
echo ('<br />MySQL: Cell '.($db_stats['fetchcell'] + 0).'/'.round(($db_stats['fetchcell_sec'] + 0), 3).'s'.' Row '.($db_stats['fetchrow'] + 0).'/'.round(($db_stats['fetchrow_sec'] + 0), 3).'s'.' Rows '.($db_stats['fetchrows'] + 0).'/'.round(($db_stats['fetchrows_sec'] + 0), 3).'s'.' Column '.($db_stats['fetchcol'] + 0).'/'.round(($db_stats['fetchcol_sec'] + 0), 3).'s');
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,123 +1,114 @@
|
||||
<?php
|
||||
|
||||
@ini_set("session.gc_maxlifetime","0");
|
||||
@ini_set('session.gc_maxlifetime', '0');
|
||||
@ini_set('session.use_only_cookies', 1);
|
||||
@ini_set('session.cookie_httponly', 1);
|
||||
require('includes/PasswordHash.php');
|
||||
require 'includes/PasswordHash.php';
|
||||
|
||||
session_start();
|
||||
|
||||
// Preflight checks
|
||||
if (!is_dir($config['rrd_dir']))
|
||||
{
|
||||
echo("<div class='errorbox'>RRD Log Directory is missing ({$config['rrd_dir']}). Graphing may fail.</div>");
|
||||
if (!is_dir($config['rrd_dir'])) {
|
||||
echo "<div class='errorbox'>RRD Log Directory is missing ({$config['rrd_dir']}). Graphing may fail.</div>";
|
||||
}
|
||||
|
||||
if (!is_dir($config['temp_dir']))
|
||||
{
|
||||
echo("<div class='errorbox'>Temp Directory is missing ({$config['temp_dir']}). Graphing may fail.</div>");
|
||||
if (!is_dir($config['temp_dir'])) {
|
||||
echo "<div class='errorbox'>Temp Directory is missing ({$config['temp_dir']}). Graphing may fail.</div>";
|
||||
}
|
||||
|
||||
if (!is_writable($config['temp_dir']))
|
||||
{
|
||||
echo("<div class='errorbox'>Temp Directory is not writable ({$config['tmp_dir']}). Graphing may fail.</div>");
|
||||
if (!is_writable($config['temp_dir'])) {
|
||||
echo "<div class='errorbox'>Temp Directory is not writable ({$config['tmp_dir']}). Graphing may fail.</div>";
|
||||
}
|
||||
|
||||
// Clear up any old sessions
|
||||
dbDelete('session', "`session_expiry` < ?", array(time()));
|
||||
dbDelete('session', '`session_expiry` < ?', array(time()));
|
||||
|
||||
if ($vars['page'] == "logout" && $_SESSION['authenticated'])
|
||||
{
|
||||
dbInsert(array('user' => $_SESSION['username'], 'address' => get_client_ip(), 'result' => 'Logged Out'), 'authlog');
|
||||
dbDelete('session', "`session_username` = ? AND session_value = ?", array($_SESSION['username'],$_COOKIE['sess_id']));
|
||||
unset($_SESSION);
|
||||
unset($_COOKIE);
|
||||
setcookie ("sess_id", "", time() - 60*60*24*$config['auth_remember'], "/");
|
||||
setcookie ("token", "", time() - 60*60*24*$config['auth_remember'], "/");
|
||||
setcookie ("auth", "", time() - 60*60*24*$config['auth_remember'], "/");
|
||||
session_destroy();
|
||||
$auth_message = "Logged Out";
|
||||
header('Location: /');
|
||||
exit;
|
||||
if ($vars['page'] == 'logout' && $_SESSION['authenticated']) {
|
||||
dbInsert(array('user' => $_SESSION['username'], 'address' => get_client_ip(), 'result' => 'Logged Out'), 'authlog');
|
||||
dbDelete('session', '`session_username` = ? AND session_value = ?', array($_SESSION['username'], $_COOKIE['sess_id']));
|
||||
unset($_SESSION);
|
||||
unset($_COOKIE);
|
||||
setcookie('sess_id', '', (time() - 60 * 60 * 24 * $config['auth_remember']), '/');
|
||||
setcookie('token', '', (time() - 60 * 60 * 24 * $config['auth_remember']), '/');
|
||||
setcookie('auth', '', (time() - 60 * 60 * 24 * $config['auth_remember']), '/');
|
||||
session_destroy();
|
||||
$auth_message = 'Logged Out';
|
||||
header('Location: /');
|
||||
exit;
|
||||
}
|
||||
|
||||
// We are only interested in login details passed via POST.
|
||||
if (isset($_POST['username']) && isset($_POST['password'])) {
|
||||
$_SESSION['username'] = mres($_POST['username']);
|
||||
$_SESSION['password'] = $_POST['password'];
|
||||
} elseif(isset($_GET['username']) && isset($_GET['password'])) {
|
||||
$_SESSION['username'] = mres($_GET['username']);
|
||||
$_SESSION['password'] = $_GET['password'];
|
||||
$_SESSION['username'] = mres($_POST['username']);
|
||||
$_SESSION['password'] = $_POST['password'];
|
||||
}
|
||||
else if (isset($_GET['username']) && isset($_GET['password'])) {
|
||||
$_SESSION['username'] = mres($_GET['username']);
|
||||
$_SESSION['password'] = $_GET['password'];
|
||||
}
|
||||
|
||||
if (!isset($config['auth_mechanism']))
|
||||
{
|
||||
$config['auth_mechanism'] = "mysql";
|
||||
if (!isset($config['auth_mechanism'])) {
|
||||
$config['auth_mechanism'] = 'mysql';
|
||||
}
|
||||
|
||||
if (file_exists('includes/authentication/' . $config['auth_mechanism'] . '.inc.php'))
|
||||
{
|
||||
include_once('includes/authentication/' . $config['auth_mechanism'] . '.inc.php');
|
||||
if (file_exists('includes/authentication/'.$config['auth_mechanism'].'.inc.php')) {
|
||||
include_once 'includes/authentication/'.$config['auth_mechanism'].'.inc.php';
|
||||
}
|
||||
else
|
||||
{
|
||||
print_error('ERROR: no valid auth_mechanism defined!');
|
||||
exit();
|
||||
else {
|
||||
print_error('ERROR: no valid auth_mechanism defined!');
|
||||
exit();
|
||||
}
|
||||
|
||||
$auth_success = 0;
|
||||
|
||||
if ((isset($_SESSION['username'])) || (isset($_COOKIE['sess_id'],$_COOKIE['token'])))
|
||||
{
|
||||
if ((authenticate($_SESSION['username'],$_SESSION['password'])) || (reauthenticate($_COOKIE['sess_id'],$_COOKIE['token'])))
|
||||
{
|
||||
$_SESSION['userlevel'] = get_userlevel($_SESSION['username']);
|
||||
$_SESSION['user_id'] = get_userid($_SESSION['username']);
|
||||
if (!$_SESSION['authenticated'])
|
||||
{
|
||||
if( $config['twofactor'] === true && !isset($_SESSION['twofactor']) ) {
|
||||
require_once($config['install_dir'].'/html/includes/authentication/twofactor.lib.php');
|
||||
twofactor_auth();
|
||||
}
|
||||
if( !$config['twofactor'] || $_SESSION['twofactor'] ) {
|
||||
$_SESSION['authenticated'] = true;
|
||||
dbInsert(array('user' => $_SESSION['username'], 'address' => get_client_ip(), 'result' => 'Logged In'), 'authlog');
|
||||
}
|
||||
if ((isset($_SESSION['username'])) || (isset($_COOKIE['sess_id'],$_COOKIE['token']))) {
|
||||
if ((authenticate($_SESSION['username'], $_SESSION['password'])) || (reauthenticate($_COOKIE['sess_id'], $_COOKIE['token']))) {
|
||||
$_SESSION['userlevel'] = get_userlevel($_SESSION['username']);
|
||||
$_SESSION['user_id'] = get_userid($_SESSION['username']);
|
||||
if (!$_SESSION['authenticated']) {
|
||||
if ($config['twofactor'] === true && !isset($_SESSION['twofactor'])) {
|
||||
include_once $config['install_dir'].'/html/includes/authentication/twofactor.lib.php';
|
||||
twofactor_auth();
|
||||
}
|
||||
|
||||
if (!$config['twofactor'] || $_SESSION['twofactor']) {
|
||||
$_SESSION['authenticated'] = true;
|
||||
dbInsert(array('user' => $_SESSION['username'], 'address' => get_client_ip(), 'result' => 'Logged In'), 'authlog');
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_POST['remember'])) {
|
||||
$sess_id = session_id();
|
||||
$hasher = new PasswordHash(8, false);
|
||||
$token = strgen();
|
||||
$auth = strgen();
|
||||
$hasher = new PasswordHash(8, false);
|
||||
$token_id = $_SESSION['username'].'|'.$hasher->HashPassword($_SESSION['username'].$token);
|
||||
// If we have been asked to remember the user then set the relevant cookies and create a session in the DB.
|
||||
setcookie('sess_id', $sess_id, (time() + 60 * 60 * 24 * $config['auth_remember']), '/', null, false, true);
|
||||
setcookie('token', $token_id, (time() + 60 * 60 * 24 * $config['auth_remember']), '/', null, false, true);
|
||||
setcookie('auth', $auth, (time() + 60 * 60 * 24 * $config['auth_remember']), '/', null, false, true);
|
||||
dbInsert(array('session_username' => $_SESSION['username'], 'session_value' => $sess_id, 'session_token' => $token, 'session_auth' => $auth, 'session_expiry' => time() + 60 * 60 * 24 * $config['auth_remember']), 'session');
|
||||
}
|
||||
|
||||
if (isset($_COOKIE['sess_id'],$_COOKIE['token'],$_COOKIE['auth'])) {
|
||||
// If we have the remember me cookies set then update session expiry times to keep us logged in.
|
||||
$sess_id = session_id();
|
||||
dbUpdate(array('session_value' => $sess_id, 'session_expiry' => time() + 60 * 60 * 24 * $config['auth_remember']), 'session', 'session_auth=?', array($_COOKIE['auth']));
|
||||
setcookie('sess_id', $sess_id, (time() + 60 * 60 * 24 * $config['auth_remember']), '/', null, false, true);
|
||||
setcookie('token', $_COOKIE['token'], (time() + 60 * 60 * 24 * $config['auth_remember']), '/', null, false, true);
|
||||
setcookie('auth', $_COOKIE['auth'], (time() + 60 * 60 * 24 * $config['auth_remember']), '/', null, false, true);
|
||||
}
|
||||
|
||||
$permissions = permissions_cache($_SESSION['user_id']);
|
||||
if (isset($_POST['username'])) {
|
||||
header('Location: '.$_SERVER['REQUEST_URI'], true, 303);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
if (isset($_POST['remember']))
|
||||
{
|
||||
$sess_id = session_id();
|
||||
$hasher = new PasswordHash(8, FALSE);
|
||||
$token = strgen();
|
||||
$auth = strgen();
|
||||
$hasher = new PasswordHash(8, FALSE);
|
||||
$token_id = $_SESSION['username'].'|'.$hasher->HashPassword($_SESSION['username'].$token);
|
||||
// If we have been asked to remember the user then set the relevant cookies and create a session in the DB.
|
||||
setcookie("sess_id", $sess_id, time()+60*60*24*$config['auth_remember'], "/", null, false, true);
|
||||
setcookie("token", $token_id, time()+60*60*24*$config['auth_remember'], "/", null, false, true);
|
||||
setcookie("auth", $auth, time()+60*60*24*$config['auth_remember'], "/", null, false, true);
|
||||
dbInsert(array('session_username' => $_SESSION['username'], 'session_value' => $sess_id, 'session_token' => $token, 'session_auth' => $auth, 'session_expiry' => time()+60*60*24*$config['auth_remember']), 'session');
|
||||
else if (isset($_SESSION['username'])) {
|
||||
$auth_message = 'Authentication Failed';
|
||||
unset($_SESSION['authenticated']);
|
||||
dbInsert(array('user' => $_SESSION['username'], 'address' => get_client_ip(), 'result' => 'Authentication Failure'), 'authlog');
|
||||
}
|
||||
if (isset($_COOKIE['sess_id'],$_COOKIE['token'],$_COOKIE['auth']))
|
||||
{
|
||||
// If we have the remember me cookies set then update session expiry times to keep us logged in.
|
||||
$sess_id = session_id();
|
||||
dbUpdate(array('session_value' => $sess_id, 'session_expiry' => time()+60*60*24*$config['auth_remember']), 'session', 'session_auth=?', array($_COOKIE['auth']));
|
||||
setcookie("sess_id", $sess_id, time()+60*60*24*$config['auth_remember'], "/", null, false, true);
|
||||
setcookie("token", $_COOKIE['token'], time()+60*60*24*$config['auth_remember'], "/", null, false, true);
|
||||
setcookie("auth", $_COOKIE['auth'], time()+60*60*24*$config['auth_remember'], "/", null, false, true);
|
||||
}
|
||||
$permissions = permissions_cache($_SESSION['user_id']);
|
||||
if (isset($_POST['username'])) {
|
||||
header('Location: '.$_SERVER['REQUEST_URI'],TRUE,303);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
elseif (isset($_SESSION['username']))
|
||||
{
|
||||
$auth_message = "Authentication Failed";
|
||||
unset ($_SESSION['authenticated']);
|
||||
dbInsert(array('user' => $_SESSION['username'], 'address' => get_client_ip(), 'result' => 'Authentication Failure'), 'authlog');
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -1,104 +1,99 @@
|
||||
<?php
|
||||
|
||||
if (!isset($_SESSION['username']))
|
||||
{
|
||||
$_SESSION['username'] = '';
|
||||
if (!isset($_SESSION['username'])) {
|
||||
$_SESSION['username'] = '';
|
||||
}
|
||||
|
||||
function authenticate($username,$password)
|
||||
{
|
||||
global $config;
|
||||
|
||||
if (isset($_SERVER['REMOTE_USER']))
|
||||
{
|
||||
$_SESSION['username'] = mres($_SERVER['REMOTE_USER']);
|
||||
function authenticate($username, $password) {
|
||||
global $config;
|
||||
|
||||
$row = @dbFetchRow("SELECT username FROM `users` WHERE `username`=?", array($_SESSION['username']));
|
||||
if (isset($row['username']) && $row['username'] == $_SESSION['username'])
|
||||
{
|
||||
return 1;
|
||||
if (isset($_SERVER['REMOTE_USER'])) {
|
||||
$_SESSION['username'] = mres($_SERVER['REMOTE_USER']);
|
||||
|
||||
$row = @dbFetchRow('SELECT username FROM `users` WHERE `username`=?', array($_SESSION['username']));
|
||||
if (isset($row['username']) && $row['username'] == $_SESSION['username']) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
$_SESSION['username'] = $config['http_auth_guest'];
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$_SESSION['username'] = $config['http_auth_guest'];
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
function reauthenticate($sess_id = "",$token = "")
|
||||
{
|
||||
return 0;
|
||||
|
||||
function reauthenticate($sess_id='', $token='') {
|
||||
return 0;
|
||||
}
|
||||
|
||||
function passwordscanchange($username = "")
|
||||
{
|
||||
return 0;
|
||||
|
||||
function passwordscanchange($username='') {
|
||||
return 0;
|
||||
}
|
||||
|
||||
function changepassword($username,$newpassword)
|
||||
{
|
||||
# Not supported
|
||||
|
||||
function changepassword($username, $newpassword) {
|
||||
// Not supported
|
||||
}
|
||||
|
||||
function auth_usermanagement()
|
||||
{
|
||||
return 1;
|
||||
|
||||
function auth_usermanagement() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
function adduser($username, $password, $level, $email = "", $realname = "", $can_modify_passwd = '1')
|
||||
{
|
||||
|
||||
function adduser($username, $password, $level, $email='', $realname='', $can_modify_passwd='1') {
|
||||
if (!user_exists($username)) {
|
||||
$hasher = new PasswordHash(8, FALSE);
|
||||
$hasher = new PasswordHash(8, false);
|
||||
$encrypted = $hasher->HashPassword($password);
|
||||
return dbInsert(array('username' => $username, 'password' => $encrypted, 'level' => $level, 'email' => $email, 'realname' => $realname), 'users');
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function user_exists($username)
|
||||
{
|
||||
// FIXME this doesn't seem right? (adama)
|
||||
return dbFetchCell("SELECT * FROM `users` WHERE `username` = ?", array($username));
|
||||
|
||||
function user_exists($username) {
|
||||
// FIXME this doesn't seem right? (adama)
|
||||
return dbFetchCell('SELECT * FROM `users` WHERE `username` = ?', array($username));
|
||||
}
|
||||
|
||||
function get_userlevel($username)
|
||||
{
|
||||
return dbFetchCell("SELECT `level` FROM `users` WHERE `username`= ?", array($username));
|
||||
|
||||
function get_userlevel($username) {
|
||||
return dbFetchCell('SELECT `level` FROM `users` WHERE `username`= ?', array($username));
|
||||
}
|
||||
|
||||
function get_userid($username)
|
||||
{
|
||||
return dbFetchCell("SELECT `user_id` FROM `users` WHERE `username`= ?", array($username));
|
||||
|
||||
function get_userid($username) {
|
||||
return dbFetchCell('SELECT `user_id` FROM `users` WHERE `username`= ?', array($username));
|
||||
}
|
||||
|
||||
function deluser($username)
|
||||
{
|
||||
# Not supported
|
||||
return 0;
|
||||
|
||||
function deluser($username) {
|
||||
// Not supported
|
||||
return 0;
|
||||
}
|
||||
|
||||
function get_userlist()
|
||||
{
|
||||
return dbFetchRows("SELECT * FROM `users`");
|
||||
|
||||
function get_userlist() {
|
||||
return dbFetchRows('SELECT * FROM `users`');
|
||||
}
|
||||
|
||||
function can_update_users()
|
||||
{
|
||||
# supported so return 1
|
||||
return 1;
|
||||
|
||||
function can_update_users() {
|
||||
// supported so return 1
|
||||
return 1;
|
||||
}
|
||||
|
||||
function get_user($user_id)
|
||||
{
|
||||
return dbFetchRow("SELECT * FROM `users` WHERE `user_id` = ?", array($user_id));
|
||||
|
||||
function get_user($user_id) {
|
||||
return dbFetchRow('SELECT * FROM `users` WHERE `user_id` = ?', array($user_id));
|
||||
}
|
||||
|
||||
function update_user($user_id,$realname,$level,$can_modify_passwd,$email)
|
||||
{
|
||||
dbUpdate(array('realname' => $realname, 'level' => $level, 'can_modify_passwd' => $can_modify_passwd, 'email' => $email), 'users', '`user_id` = ?', array($user_id));
|
||||
}
|
||||
|
||||
?>
|
||||
function update_user($user_id, $realname, $level, $can_modify_passwd, $email) {
|
||||
dbUpdate(array('realname' => $realname, 'level' => $level, 'can_modify_passwd' => $can_modify_passwd, 'email' => $email), 'users', '`user_id` = ?', array($user_id));
|
||||
}
|
||||
|
||||
@@ -1,228 +1,237 @@
|
||||
<?php
|
||||
|
||||
$ds = @ldap_connect($config['auth_ldap_server'],$config['auth_ldap_port']);
|
||||
$ds = @ldap_connect($config['auth_ldap_server'], $config['auth_ldap_port']);
|
||||
|
||||
if ($config['auth_ldap_starttls'] && ($config['auth_ldap_starttls'] == 'optional' || $config['auth_ldap_starttls'] == 'require'))
|
||||
{
|
||||
$tls = ldap_start_tls($ds);
|
||||
if ($config['auth_ldap_starttls'] == 'require' && $tls == FALSE)
|
||||
{
|
||||
echo("<h2>Fatal error: LDAP TLS required but not successfully negotiated:" . ldap_error($ds) . "</h2>");
|
||||
exit;
|
||||
}
|
||||
if ($config['auth_ldap_starttls'] && ($config['auth_ldap_starttls'] == 'optional' || $config['auth_ldap_starttls'] == 'require')) {
|
||||
$tls = ldap_start_tls($ds);
|
||||
if ($config['auth_ldap_starttls'] == 'require' && $tls == false) {
|
||||
echo '<h2>Fatal error: LDAP TLS required but not successfully negotiated:'.ldap_error($ds).'</h2>';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function authenticate($username,$password)
|
||||
{
|
||||
global $config, $ds;
|
||||
|
||||
if ($username && $ds)
|
||||
{
|
||||
if ($config['auth_ldap_version'])
|
||||
{
|
||||
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, $config['auth_ldap_version']);
|
||||
|
||||
function authenticate($username, $password) {
|
||||
global $config, $ds;
|
||||
|
||||
if ($username && $ds) {
|
||||
if ($config['auth_ldap_version']) {
|
||||
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, $config['auth_ldap_version']);
|
||||
}
|
||||
|
||||
if (ldap_bind($ds, $config['auth_ldap_prefix'].$username.$config['auth_ldap_suffix'], $password)) {
|
||||
if (!$config['auth_ldap_group']) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
$ldap_groups = get_group_list();
|
||||
foreach ($ldap_groups as $ldap_group) {
|
||||
$ldap_comparison = ldap_compare(
|
||||
$ds,
|
||||
$ldap_group,
|
||||
$config['auth_ldap_groupmemberattr'],
|
||||
get_membername($username)
|
||||
);
|
||||
if ($ldap_comparison === true) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo ldap_error($ds);
|
||||
}
|
||||
}
|
||||
if (ldap_bind($ds, $config['auth_ldap_prefix'] . $username . $config['auth_ldap_suffix'], $password))
|
||||
{
|
||||
if (!$config['auth_ldap_group'])
|
||||
{
|
||||
else {
|
||||
// FIXME return a warning that LDAP couldn't connect?
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function reauthenticate($sess_id, $token) {
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function passwordscanchange($username='') {
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function changepassword($username, $newpassword) {
|
||||
// Not supported (for now)
|
||||
|
||||
}
|
||||
|
||||
|
||||
function auth_usermanagement() {
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function adduser($username, $password, $level, $email='', $realname='', $can_modify_passwd='1') {
|
||||
// Not supported
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function user_exists($username) {
|
||||
global $config, $ds;
|
||||
|
||||
$filter = '('.$config['auth_ldap_prefix'].$username.')';
|
||||
$search = ldap_search($ds, trim($config['auth_ldap_suffix'], ','), $filter);
|
||||
$entries = ldap_get_entries($ds, $search);
|
||||
if ($entries['count']) {
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$ldap_groups = get_group_list();
|
||||
foreach($ldap_groups as $ldap_group) {
|
||||
$ldap_comparison = ldap_compare($ds,
|
||||
$ldap_group,
|
||||
$config['auth_ldap_groupmemberattr'],
|
||||
get_membername($username));
|
||||
if($ldap_comparison === true) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function get_userlevel($username) {
|
||||
global $config, $ds;
|
||||
|
||||
$userlevel = 0;
|
||||
|
||||
// Find all defined groups $username is in
|
||||
$filter = '(&(|(cn='.join(')(cn=', array_keys($config['auth_ldap_groups'])).'))('.$config['auth_ldap_groupmemberattr'].'='.get_membername($username).'))';
|
||||
$search = ldap_search($ds, $config['auth_ldap_groupbase'], $filter);
|
||||
$entries = ldap_get_entries($ds, $search);
|
||||
|
||||
// Loop the list and find the highest level
|
||||
foreach ($entries as $entry) {
|
||||
$groupname = $entry['cn'][0];
|
||||
if ($config['auth_ldap_groups'][$groupname]['level'] > $userlevel) {
|
||||
$userlevel = $config['auth_ldap_groups'][$groupname]['level'];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo(ldap_error($ds));
|
||||
|
||||
return $userlevel;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function get_userid($username) {
|
||||
global $config, $ds;
|
||||
|
||||
$filter = '('.$config['auth_ldap_prefix'].$username.')';
|
||||
$search = ldap_search($ds, trim($config['auth_ldap_suffix'], ','), $filter);
|
||||
$entries = ldap_get_entries($ds, $search);
|
||||
|
||||
if ($entries['count']) {
|
||||
return $entries[0]['uidnumber'][0];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIXME return a warning that LDAP couldn't connect?
|
||||
}
|
||||
|
||||
return 0;
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
function reauthenticate($sess_id,$token)
|
||||
{
|
||||
return 0;
|
||||
|
||||
function deluser($username) {
|
||||
// Not supported
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
function passwordscanchange($username = "")
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
function changepassword($username,$newpassword)
|
||||
{
|
||||
# Not supported (for now)
|
||||
}
|
||||
function get_userlist() {
|
||||
global $config, $ds;
|
||||
$userlist = array();
|
||||
|
||||
function auth_usermanagement()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
$filter = '('.$config['auth_ldap_prefix'].'*)';
|
||||
|
||||
function adduser($username, $password, $level, $email = "", $realname = "", $can_modify_passwd = '1')
|
||||
{
|
||||
# Not supported
|
||||
return 0;
|
||||
}
|
||||
$search = ldap_search($ds, trim($config['auth_ldap_suffix'], ','), $filter);
|
||||
$entries = ldap_get_entries($ds, $search);
|
||||
|
||||
function user_exists($username)
|
||||
{
|
||||
global $config, $ds;
|
||||
|
||||
$filter = "(" . $config['auth_ldap_prefix'] . $username . ")";
|
||||
$search = ldap_search($ds, trim($config['auth_ldap_suffix'],','), $filter);
|
||||
$entries = ldap_get_entries($ds, $search);
|
||||
if ($entries['count'])
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
function get_userlevel($username)
|
||||
{
|
||||
global $config, $ds;
|
||||
|
||||
$userlevel = 0;
|
||||
|
||||
# Find all defined groups $username is in
|
||||
$filter = "(&(|(cn=" . join(")(cn=", array_keys($config['auth_ldap_groups'])) . "))(". $config['auth_ldap_groupmemberattr']. "=" . get_membername($username) . "))";
|
||||
$search = ldap_search($ds, $config['auth_ldap_groupbase'], $filter);
|
||||
$entries = ldap_get_entries($ds, $search);
|
||||
|
||||
# Loop the list and find the highest level
|
||||
foreach ($entries as $entry)
|
||||
{
|
||||
$groupname = $entry['cn'][0];
|
||||
if ($config['auth_ldap_groups'][$groupname]['level'] > $userlevel)
|
||||
{
|
||||
$userlevel = $config['auth_ldap_groups'][$groupname]['level'];
|
||||
}
|
||||
}
|
||||
|
||||
return $userlevel;
|
||||
}
|
||||
|
||||
function get_userid($username)
|
||||
{
|
||||
global $config, $ds;
|
||||
|
||||
$filter = "(" . $config['auth_ldap_prefix'] . $username . ")";
|
||||
$search = ldap_search($ds, trim($config['auth_ldap_suffix'],','), $filter);
|
||||
$entries = ldap_get_entries($ds, $search);
|
||||
|
||||
if ($entries['count'])
|
||||
{
|
||||
return $entries[0]['uidnumber'][0];
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
function deluser($username)
|
||||
{
|
||||
# Not supported
|
||||
return 0;
|
||||
}
|
||||
|
||||
function get_userlist()
|
||||
{
|
||||
global $config, $ds;
|
||||
$userlist = array();
|
||||
|
||||
$filter = '(' . $config['auth_ldap_prefix'] . '*)';
|
||||
|
||||
$search = ldap_search($ds, trim($config['auth_ldap_suffix'],','), $filter);
|
||||
$entries = ldap_get_entries($ds, $search);
|
||||
|
||||
if ($entries['count'])
|
||||
{
|
||||
foreach ($entries as $entry)
|
||||
{
|
||||
$username = $entry['uid'][0];
|
||||
$realname = $entry['cn'][0];
|
||||
$user_id = $entry['uidnumber'][0];
|
||||
$email = $entry[$config['auth_ldap_emailattr']][0];
|
||||
$ldap_groups = get_group_list();
|
||||
foreach($ldap_groups as $ldap_group) {
|
||||
$ldap_comparison = ldap_compare($ds,
|
||||
$ldap_group,
|
||||
$config['auth_ldap_groupmemberattr'],
|
||||
get_membername($username));
|
||||
if (!isset($config['auth_ldap_group']) || $ldap_comparison === true) {
|
||||
$userlist[] = array('username' => $username, 'realname' => $realname, 'user_id' => $user_id, 'email' => $email);
|
||||
if ($entries['count']) {
|
||||
foreach ($entries as $entry) {
|
||||
$username = $entry['uid'][0];
|
||||
$realname = $entry['cn'][0];
|
||||
$user_id = $entry['uidnumber'][0];
|
||||
$email = $entry[$config['auth_ldap_emailattr']][0];
|
||||
$ldap_groups = get_group_list();
|
||||
foreach ($ldap_groups as $ldap_group) {
|
||||
$ldap_comparison = ldap_compare(
|
||||
$ds,
|
||||
$ldap_group,
|
||||
$config['auth_ldap_groupmemberattr'],
|
||||
get_membername($username)
|
||||
);
|
||||
if (!isset($config['auth_ldap_group']) || $ldap_comparison === true) {
|
||||
$userlist[] = array(
|
||||
'username' => $username,
|
||||
'realname' => $realname,
|
||||
'user_id' => $user_id,
|
||||
'email' => $email,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $userlist;
|
||||
return $userlist;
|
||||
}
|
||||
|
||||
function can_update_users()
|
||||
{
|
||||
# not supported so return 0
|
||||
return 0;
|
||||
|
||||
function can_update_users() {
|
||||
// not supported so return 0
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
function get_user($user_id)
|
||||
{
|
||||
# not supported
|
||||
return 0;
|
||||
|
||||
function get_user($user_id) {
|
||||
// not supported
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
function update_user($user_id,$realname,$level,$can_modify_passwd,$email)
|
||||
{
|
||||
# not supported
|
||||
return 0;
|
||||
|
||||
function update_user($user_id, $realname, $level, $can_modify_passwd, $email) {
|
||||
// not supported
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
function get_membername ($username)
|
||||
{
|
||||
global $config;
|
||||
if ($config['auth_ldap_groupmembertype'] == "fulldn")
|
||||
{
|
||||
$membername = $config['auth_ldap_prefix'] . $username . $config['auth_ldap_suffix'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$membername = $username;
|
||||
}
|
||||
return $membername;
|
||||
|
||||
function get_membername($username) {
|
||||
global $config;
|
||||
if ($config['auth_ldap_groupmembertype'] == 'fulldn') {
|
||||
$membername = $config['auth_ldap_prefix'].$username.$config['auth_ldap_suffix'];
|
||||
}
|
||||
else {
|
||||
$membername = $username;
|
||||
}
|
||||
|
||||
return $membername;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function get_group_list() {
|
||||
global $config;
|
||||
global $config;
|
||||
|
||||
$ldap_groups = array();
|
||||
$default_group = 'cn=groupname,ou=groups,dc=example,dc=com';
|
||||
if(isset($config['auth_ldap_group'])) {
|
||||
if($config['auth_ldap_group'] !== $default_group) {
|
||||
$ldap_groups[] = $config['auth_ldap_group'];
|
||||
$ldap_groups = array();
|
||||
$default_group = 'cn=groupname,ou=groups,dc=example,dc=com';
|
||||
if (isset($config['auth_ldap_group'])) {
|
||||
if ($config['auth_ldap_group'] !== $default_group) {
|
||||
$ldap_groups[] = $config['auth_ldap_group'];
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach($config['auth_ldap_groups'] as $key => $value) {
|
||||
$dn = "cn=$key," . $config['auth_ldap_groupbase'];
|
||||
$ldap_groups[] = $dn;
|
||||
}
|
||||
return $ldap_groups;
|
||||
}
|
||||
|
||||
?>
|
||||
foreach ($config['auth_ldap_groups'] as $key => $value) {
|
||||
$dn = "cn=$key,".$config['auth_ldap_groupbase'];
|
||||
$ldap_groups[] = $dn;
|
||||
}
|
||||
|
||||
return $ldap_groups;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,71 +1,69 @@
|
||||
<?php
|
||||
|
||||
function authenticate($username,$password)
|
||||
{
|
||||
$encrypted_old = md5($password);
|
||||
$row = dbFetchRow("SELECT username,password FROM `users` WHERE `username`= ?", array($username));
|
||||
if ($row['username'] && $row['username'] == $username)
|
||||
{
|
||||
// Migrate from old, unhashed password
|
||||
if ($row['password'] == $encrypted_old)
|
||||
{
|
||||
$row_type = dbFetchRow("DESCRIBE users password");
|
||||
if ($row_type['Type'] == 'varchar(34)')
|
||||
{
|
||||
changepassword($username,$password);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
elseif(substr($row['password'],0,3) == '$1$')
|
||||
{
|
||||
$row_type = dbFetchRow("DESCRIBE users password");
|
||||
if ($row_type['Type'] == 'varchar(60)')
|
||||
{
|
||||
if ($row['password'] == crypt($password,$row['password']))
|
||||
{
|
||||
changepassword($username,$password);
|
||||
|
||||
function authenticate($username, $password) {
|
||||
$encrypted_old = md5($password);
|
||||
$row = dbFetchRow('SELECT username,password FROM `users` WHERE `username`= ?', array($username));
|
||||
if ($row['username'] && $row['username'] == $username) {
|
||||
// Migrate from old, unhashed password
|
||||
if ($row['password'] == $encrypted_old) {
|
||||
$row_type = dbFetchRow('DESCRIBE users password');
|
||||
if ($row_type['Type'] == 'varchar(34)') {
|
||||
changepassword($username, $password);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
else if (substr($row['password'], 0, 3) == '$1$') {
|
||||
$row_type = dbFetchRow('DESCRIBE users password');
|
||||
if ($row_type['Type'] == 'varchar(60)') {
|
||||
if ($row['password'] == crypt($password, $row['password'])) {
|
||||
changepassword($username, $password);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$hasher = new PasswordHash(8, FALSE);
|
||||
if($hasher->CheckPassword($password, $row['password']))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
function reauthenticate($sess_id,$token)
|
||||
{
|
||||
list($uname,$hash) = explode("|",$token);
|
||||
$session = dbFetchRow("SELECT * FROM `session` WHERE `session_username` = '$uname' AND session_value='$sess_id'");
|
||||
$hasher = new PasswordHash(8, FALSE);
|
||||
if($hasher->CheckPassword($uname.$session['session_token'],$hash))
|
||||
{
|
||||
$_SESSION['username'] = $uname;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$hasher = new PasswordHash(8, false);
|
||||
if ($hasher->CheckPassword($password, $row['password'])) {
|
||||
return 1;
|
||||
}
|
||||
}//end if
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
function passwordscanchange($username = "")
|
||||
{
|
||||
/*
|
||||
* By default allow the password to be modified, unless the existing
|
||||
* user is explicitly prohibited to do so.
|
||||
*/
|
||||
}//end authenticate()
|
||||
|
||||
|
||||
function reauthenticate($sess_id, $token) {
|
||||
list($uname,$hash) = explode('|', $token);
|
||||
$session = dbFetchRow("SELECT * FROM `session` WHERE `session_username` = '$uname' AND session_value='$sess_id'");
|
||||
$hasher = new PasswordHash(8, false);
|
||||
if ($hasher->CheckPassword($uname.$session['session_token'], $hash)) {
|
||||
$_SESSION['username'] = $uname;
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}//end reauthenticate()
|
||||
|
||||
|
||||
function passwordscanchange($username='') {
|
||||
/*
|
||||
* By default allow the password to be modified, unless the existing
|
||||
* user is explicitly prohibited to do so.
|
||||
*/
|
||||
|
||||
if (empty($username) || !user_exists($username)) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return dbFetchCell('SELECT can_modify_passwd FROM users WHERE username = ?', array($username));
|
||||
}
|
||||
|
||||
}//end passwordscanchange()
|
||||
|
||||
if (empty($username) || !user_exists($username))
|
||||
{
|
||||
return 1;
|
||||
} else {
|
||||
return dbFetchCell("SELECT can_modify_passwd FROM users WHERE username = ?", array($username));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* From: http://code.activestate.com/recipes/576894-generate-a-salt/
|
||||
@@ -74,92 +72,98 @@ function passwordscanchange($username = "")
|
||||
* @param $max integer The number of characters in the string
|
||||
* @author AfroSoft <scripts@afrosoft.co.cc>
|
||||
*/
|
||||
function generateSalt($max = 15)
|
||||
{
|
||||
$characterList = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
$i = 0;
|
||||
$salt = "";
|
||||
do
|
||||
{
|
||||
$salt .= $characterList{mt_rand(0,strlen($characterList))};
|
||||
$i++;
|
||||
} while ($i <= $max);
|
||||
function generateSalt($max=15) {
|
||||
$characterList = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
||||
$i = 0;
|
||||
$salt = '';
|
||||
do {
|
||||
$salt .= $characterList{mt_rand(0, strlen($characterList))};
|
||||
$i++;
|
||||
} while ($i <= $max);
|
||||
|
||||
return $salt;
|
||||
}
|
||||
return $salt;
|
||||
|
||||
function changepassword($username,$password)
|
||||
{
|
||||
$hasher = new PasswordHash(8, FALSE);
|
||||
$encrypted = $hasher->HashPassword($password);
|
||||
return dbUpdate(array('password' => $encrypted), 'users', '`username` = ?', array($username));
|
||||
}
|
||||
}//end generateSalt()
|
||||
|
||||
function auth_usermanagement()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
function adduser($username, $password, $level, $email = "", $realname = "", $can_modify_passwd=1, $description ="", $twofactor=0)
|
||||
{
|
||||
if (!user_exists($username))
|
||||
{
|
||||
$hasher = new PasswordHash(8, FALSE);
|
||||
function changepassword($username, $password) {
|
||||
$hasher = new PasswordHash(8, false);
|
||||
$encrypted = $hasher->HashPassword($password);
|
||||
return dbInsert(array('username' => $username, 'password' => $encrypted, 'level' => $level, 'email' => $email, 'realname' => $realname, 'can_modify_passwd' => $can_modify_passwd, 'descr' => $description, 'twofactor' => $twofactor), 'users');
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return dbUpdate(array('password' => $encrypted), 'users', '`username` = ?', array($username));
|
||||
|
||||
function user_exists($username)
|
||||
{
|
||||
$return = @dbFetchCell("SELECT COUNT(*) FROM users WHERE username = ?", array($username));
|
||||
return $return;
|
||||
}
|
||||
}//end changepassword()
|
||||
|
||||
function get_userlevel($username)
|
||||
{
|
||||
return dbFetchCell("SELECT `level` FROM `users` WHERE `username` = ?", array($username));
|
||||
}
|
||||
|
||||
function get_userid($username)
|
||||
{
|
||||
return dbFetchCell("SELECT `user_id` FROM `users` WHERE `username` = ?", array($username));
|
||||
}
|
||||
function auth_usermanagement() {
|
||||
return 1;
|
||||
|
||||
function deluser($username)
|
||||
{
|
||||
}//end auth_usermanagement()
|
||||
|
||||
dbDelete('bill_perms', "`user_name` = ?", array($username));
|
||||
dbDelete('devices_perms', "`user_name` = ?", array($username));
|
||||
dbDelete('ports_perms', "`user_name` = ?", array($username));
|
||||
dbDelete('users_prefs', "`user_name` = ?", array($username));
|
||||
dbDelete('users', "`user_name` = ?", array($username));
|
||||
|
||||
return dbDelete('users', "`username` = ?", array($username));
|
||||
function adduser($username, $password, $level, $email='', $realname='', $can_modify_passwd=1, $description='', $twofactor=0) {
|
||||
if (!user_exists($username)) {
|
||||
$hasher = new PasswordHash(8, false);
|
||||
$encrypted = $hasher->HashPassword($password);
|
||||
return dbInsert(array('username' => $username, 'password' => $encrypted, 'level' => $level, 'email' => $email, 'realname' => $realname, 'can_modify_passwd' => $can_modify_passwd, 'descr' => $description, 'twofactor' => $twofactor), 'users');
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}//end adduser()
|
||||
|
||||
function get_userlist()
|
||||
{
|
||||
return dbFetchRows("SELECT * FROM `users`");
|
||||
}
|
||||
|
||||
function can_update_users()
|
||||
{
|
||||
# supported so return 1
|
||||
return 1;
|
||||
}
|
||||
function user_exists($username) {
|
||||
$return = @dbFetchCell('SELECT COUNT(*) FROM users WHERE username = ?', array($username));
|
||||
return $return;
|
||||
|
||||
function get_user($user_id)
|
||||
{
|
||||
return dbFetchRow("SELECT * FROM `users` WHERE `user_id` = ?", array($user_id));
|
||||
}
|
||||
}//end user_exists()
|
||||
|
||||
function update_user($user_id,$realname,$level,$can_modify_passwd,$email)
|
||||
{
|
||||
dbUpdate(array('realname' => $realname, 'level' => $level, 'can_modify_passwd' => $can_modify_passwd, 'email' => $email), 'users', '`user_id` = ?', array($user_id));
|
||||
}
|
||||
|
||||
?>
|
||||
function get_userlevel($username) {
|
||||
return dbFetchCell('SELECT `level` FROM `users` WHERE `username` = ?', array($username));
|
||||
|
||||
}//end get_userlevel()
|
||||
|
||||
|
||||
function get_userid($username) {
|
||||
return dbFetchCell('SELECT `user_id` FROM `users` WHERE `username` = ?', array($username));
|
||||
|
||||
}//end get_userid()
|
||||
|
||||
|
||||
function deluser($username) {
|
||||
dbDelete('bill_perms', '`user_name` = ?', array($username));
|
||||
dbDelete('devices_perms', '`user_name` = ?', array($username));
|
||||
dbDelete('ports_perms', '`user_name` = ?', array($username));
|
||||
dbDelete('users_prefs', '`user_name` = ?', array($username));
|
||||
dbDelete('users', '`user_name` = ?', array($username));
|
||||
|
||||
return dbDelete('users', '`username` = ?', array($username));
|
||||
|
||||
}//end deluser()
|
||||
|
||||
|
||||
function get_userlist() {
|
||||
return dbFetchRows('SELECT * FROM `users`');
|
||||
|
||||
}//end get_userlist()
|
||||
|
||||
|
||||
function can_update_users() {
|
||||
// supported so return 1
|
||||
return 1;
|
||||
|
||||
}//end can_update_users()
|
||||
|
||||
|
||||
function get_user($user_id) {
|
||||
return dbFetchRow('SELECT * FROM `users` WHERE `user_id` = ?', array($user_id));
|
||||
|
||||
}//end get_user()
|
||||
|
||||
|
||||
function update_user($user_id, $realname, $level, $can_modify_passwd, $email) {
|
||||
dbUpdate(array('realname' => $realname, 'level' => $level, 'can_modify_passwd' => $can_modify_passwd, 'email' => $email), 'users', '`user_id` = ?', array($user_id));
|
||||
|
||||
}//end update_user()
|
||||
|
||||
@@ -4,14 +4,15 @@
|
||||
* 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/>. */
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Two-Factor Authentication Library
|
||||
@@ -44,14 +45,14 @@ const otpWindow = 4;
|
||||
* Base32 Decoding dictionary
|
||||
*/
|
||||
$base32 = array(
|
||||
"A" => 0, "B" => 1, "C" => 2, "D" => 3,
|
||||
"E" => 4, "F" => 5, "G" => 6, "H" => 7,
|
||||
"I" => 8, "J" => 9, "K" => 10, "L" => 11,
|
||||
"M" => 12, "N" => 13, "O" => 14, "P" => 15,
|
||||
"Q" => 16, "R" => 17, "S" => 18, "T" => 19,
|
||||
"U" => 20, "V" => 21, "W" => 22, "X" => 23,
|
||||
"Y" => 24, "Z" => 25, "2" => 26, "3" => 27,
|
||||
"4" => 28, "5" => 29, "6" => 30, "7" => 31
|
||||
"A" => 0, "B" => 1, "C" => 2, "D" => 3,
|
||||
"E" => 4, "F" => 5, "G" => 6, "H" => 7,
|
||||
"I" => 8, "J" => 9, "K" => 10, "L" => 11,
|
||||
"M" => 12, "N" => 13, "O" => 14, "P" => 15,
|
||||
"Q" => 16, "R" => 17, "S" => 18, "T" => 19,
|
||||
"U" => 20, "V" => 21, "W" => 22, "X" => 23,
|
||||
"Y" => 24, "Z" => 25, "2" => 26, "3" => 27,
|
||||
"4" => 28, "5" => 29, "6" => 30, "7" => 31
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -128,14 +129,16 @@ function oath_hotp($key, $counter=false) {
|
||||
function verify_hotp($key,$otp,$counter=false) {
|
||||
if( oath_hotp($key,$counter) == $otp ) {
|
||||
return true;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if( $counter === false ) {
|
||||
//TimeBased HOTP requires lookbehind and lookahead.
|
||||
$counter = floor(microtime(true)/keyInterval);
|
||||
$initcount = $counter-((otpWindow+1)*keyInterval);
|
||||
$endcount = $counter+(otpWindow*keyInterval);
|
||||
$totp = true;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
//Counter based HOTP only has lookahead, not lookbehind.
|
||||
$initcount = $counter-1;
|
||||
$endcount = $counter+otpWindow;
|
||||
@@ -145,7 +148,8 @@ function verify_hotp($key,$otp,$counter=false) {
|
||||
if( oath_hotp($key,$initcount) == $otp ) {
|
||||
if( !$totp ) {
|
||||
return $initcount;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -200,23 +204,28 @@ function twofactor_auth() {
|
||||
$twofactor = dbFetchRow('SELECT twofactor FROM users WHERE username = ?', array($_SESSION['username']));
|
||||
if( empty($twofactor['twofactor']) ) {
|
||||
$_SESSION['twofactor'] = true;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$twofactor = json_decode($twofactor['twofactor'],true);
|
||||
if( $twofactor['fails'] >= 3 && (!$config['twofactor_lock'] || (time()-$twofactor['last']) < $config['twofactor_lock']) ) {
|
||||
$auth_message = "Too many failures, please ".($config['twofactor_lock'] ? "wait ".$config['twofactor_lock']." seconds" : "contact administrator").".";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if( !$_POST['twofactor'] ) {
|
||||
$twofactorform = true;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if( ($server_c = verify_hotp($twofactor['key'],$_POST['twofactor'],$twofactor['counter'])) === false ) {
|
||||
$twofactor['fails']++;
|
||||
$twofactor['last'] = time();
|
||||
$auth_message = "Wrong Two-Factor Token.";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if( $twofactor['counter'] !== false ) {
|
||||
if( $server_c !== true && $server_c !== $twofactor['counter'] ) {
|
||||
$twofactor['counter'] = $server_c+1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$twofactor['counter']++;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,89 +1,87 @@
|
||||
<?php
|
||||
|
||||
echo('<div class="container-fluid">');
|
||||
echo("<div class='row'>
|
||||
echo '<div class="container-fluid">';
|
||||
echo "<div class='row'>
|
||||
<div class='col-md-12'>
|
||||
<div class='panel panel-default panel-condensed'>
|
||||
<div class='panel-heading'>");
|
||||
<div class='panel-heading'>";
|
||||
|
||||
if ($config['overview_show_sysDescr'])
|
||||
{
|
||||
echo('<strong>' . $device['sysDescr'] . "</strong>");
|
||||
if ($config['overview_show_sysDescr']) {
|
||||
echo '<strong>'.$device['sysDescr'].'</strong>';
|
||||
}
|
||||
|
||||
echo('</div>
|
||||
<table class="table table-hover table-condensed table-striped">');
|
||||
echo '</div>
|
||||
<table class="table table-hover table-condensed table-striped">';
|
||||
|
||||
$uptime = $device['uptime'];
|
||||
|
||||
if ($device['os'] == "ios") { formatCiscoHardware($device); }
|
||||
if ($device['features']) { $device['features'] = "(".$device['features'].")"; }
|
||||
if ($device['os'] == 'ios') {
|
||||
formatCiscoHardware($device);
|
||||
}
|
||||
|
||||
if ($device['features']) {
|
||||
$device['features'] = '('.$device['features'].')';
|
||||
}
|
||||
|
||||
$device['os_text'] = $config['os'][$device['os']]['text'];
|
||||
|
||||
if ($device['hardware'])
|
||||
{
|
||||
echo('<tr>
|
||||
if ($device['hardware']) {
|
||||
echo '<tr>
|
||||
<td>Hardware</td>
|
||||
<td>' . $device['hardware']. '</td>
|
||||
</tr>');
|
||||
<td>'.$device['hardware'].'</td>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
echo('<tr>
|
||||
echo '<tr>
|
||||
<td>Operating System</td>
|
||||
<td>' . $device['os_text'] . ' ' . $device['version'] . ' ' . $device['features'] . ' </td>
|
||||
</tr>');
|
||||
<td>'.$device['os_text'].' '.$device['version'].' '.$device['features'].' </td>
|
||||
</tr>';
|
||||
|
||||
if ($device['serial'])
|
||||
{
|
||||
echo('<tr>
|
||||
if ($device['serial']) {
|
||||
echo '<tr>
|
||||
<td>Serial</td>
|
||||
<td>' . $device['serial']. '</td>
|
||||
</tr>');
|
||||
<td>'.$device['serial'].'</td>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
if ($device['sysContact'])
|
||||
{
|
||||
echo('<tr>
|
||||
<td>Contact</td>');
|
||||
if (get_dev_attrib($device,'override_sysContact_bool'))
|
||||
{
|
||||
echo('
|
||||
<td>' . htmlspecialchars(get_dev_attrib($device,'override_sysContact_string')) . '</td>
|
||||
if ($device['sysContact']) {
|
||||
echo '<tr>
|
||||
<td>Contact</td>';
|
||||
if (get_dev_attrib($device, 'override_sysContact_bool')) {
|
||||
echo '
|
||||
<td>'.htmlspecialchars(get_dev_attrib($device, 'override_sysContact_string')).'</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>SNMP Contact</td>');
|
||||
}
|
||||
echo('
|
||||
<td>' . htmlspecialchars($device['sysContact']). '</td>
|
||||
</tr>');
|
||||
<td>SNMP Contact</td>';
|
||||
}
|
||||
|
||||
echo '
|
||||
<td>'.htmlspecialchars($device['sysContact']).'</td>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
if ($device['location'])
|
||||
{
|
||||
echo('<tr>
|
||||
if ($device['location']) {
|
||||
echo '<tr>
|
||||
<td>Location</td>
|
||||
<td>' . $device['location']. '</td>
|
||||
</tr>');
|
||||
if (get_dev_attrib($device,'override_sysLocation_bool') && !empty($device['real_location']))
|
||||
{
|
||||
echo('<tr>
|
||||
<td>'.$device['location'].'</td>
|
||||
</tr>';
|
||||
if (get_dev_attrib($device, 'override_sysLocation_bool') && !empty($device['real_location'])) {
|
||||
echo '<tr>
|
||||
<td>SNMP Location</td>
|
||||
<td>' . $device['real_location']. '</td>
|
||||
</tr>');
|
||||
}
|
||||
<td>'.$device['real_location'].'</td>
|
||||
</tr>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($uptime)
|
||||
{
|
||||
echo('<tr>
|
||||
if ($uptime) {
|
||||
echo '<tr>
|
||||
<td>Uptime</td>
|
||||
<td>' . formatUptime($uptime) . '</td>
|
||||
</tr>');
|
||||
<td>'.formatUptime($uptime).'</td>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
echo('</table>
|
||||
echo '</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>');
|
||||
?>
|
||||
</div>';
|
||||
|
||||
@@ -1,73 +1,70 @@
|
||||
<?php
|
||||
|
||||
if ($device['status'] == '0') { $class = "alert-danger"; } else { $class = ""; }
|
||||
if ($device['ignore'] == '1')
|
||||
{
|
||||
$class = "div-ignore-alert";
|
||||
if ($device['status'] == '1')
|
||||
{
|
||||
$class = "alert-warning";
|
||||
}
|
||||
if ($device['status'] == '0') {
|
||||
$class = 'alert-danger';
|
||||
}
|
||||
if ($device['disabled'] == '1')
|
||||
{
|
||||
$class = "alert-info";
|
||||
else {
|
||||
$class = '';
|
||||
}
|
||||
|
||||
if ($device['ignore'] == '1') {
|
||||
$class = 'div-ignore-alert';
|
||||
if ($device['status'] == '1') {
|
||||
$class = 'alert-warning';
|
||||
}
|
||||
}
|
||||
|
||||
if ($device['disabled'] == '1') {
|
||||
$class = 'alert-info';
|
||||
}
|
||||
|
||||
$type = strtolower($device['os']);
|
||||
|
||||
$image = getImage($device);
|
||||
|
||||
echo('
|
||||
echo '
|
||||
<tr bgcolor="'.$device_colour.'" class="alert '.$class.'">
|
||||
<td width="40" align=center valign=middle style="padding: 21px;">'.$image.'</td>
|
||||
<td valign=middle style="padding: 0 15px;"><span style="font-size: 20px;">' . generate_device_link($device) . '</span>
|
||||
<br />' . $device['location'] . '</td>
|
||||
<td>');
|
||||
<td valign=middle style="padding: 0 15px;"><span style="font-size: 20px;">'.generate_device_link($device).'</span>
|
||||
<br />'.$device['location'].'</td>
|
||||
<td>';
|
||||
|
||||
if (isset($config['os'][$device['os']]['over']))
|
||||
{
|
||||
$graphs = $config['os'][$device['os']]['over'];
|
||||
if (isset($config['os'][$device['os']]['over'])) {
|
||||
$graphs = $config['os'][$device['os']]['over'];
|
||||
}
|
||||
elseif (isset($device['os_group']) && isset($config['os'][$device['os_group']]['over']))
|
||||
{
|
||||
$graphs = $config['os'][$device['os_group']]['over'];
|
||||
else if (isset($device['os_group']) && isset($config['os'][$device['os_group']]['over'])) {
|
||||
$graphs = $config['os'][$device['os_group']]['over'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$graphs = $config['os']['default']['over'];
|
||||
else {
|
||||
$graphs = $config['os']['default']['over'];
|
||||
}
|
||||
|
||||
$graph_array = array();
|
||||
$graph_array['height'] = "100";
|
||||
$graph_array['width'] = "310";
|
||||
$graph_array['to'] = $config['time']['now'];
|
||||
$graph_array['device'] = $device['device_id'];
|
||||
$graph_array['type'] = "device_bits";
|
||||
$graph_array['from'] = $config['time']['day'];
|
||||
$graph_array['legend'] = "no";
|
||||
$graph_array = array();
|
||||
$graph_array['height'] = '100';
|
||||
$graph_array['width'] = '310';
|
||||
$graph_array['to'] = $config['time']['now'];
|
||||
$graph_array['device'] = $device['device_id'];
|
||||
$graph_array['type'] = 'device_bits';
|
||||
$graph_array['from'] = $config['time']['day'];
|
||||
$graph_array['legend'] = 'no';
|
||||
$graph_array['popup_title'] = $descr;
|
||||
|
||||
$graph_array['height'] = "45";
|
||||
$graph_array['width'] = "150";
|
||||
$graph_array['bg'] = "FFFFFF00";
|
||||
$graph_array['height'] = '45';
|
||||
$graph_array['width'] = '150';
|
||||
$graph_array['bg'] = 'FFFFFF00';
|
||||
|
||||
foreach ($graphs as $entry)
|
||||
{
|
||||
if ($entry['graph'])
|
||||
{
|
||||
$graph_array['type'] = $entry['graph'];
|
||||
foreach ($graphs as $entry) {
|
||||
if ($entry['graph']) {
|
||||
$graph_array['type'] = $entry['graph'];
|
||||
|
||||
echo("<div style='float: right; text-align: center; padding: 1px 5px; margin: 0 1px; ' class='rounded-5px'>");
|
||||
print_graph_popup($graph_array);
|
||||
echo("<div style='font-weight: bold; font-size: 7pt; margin: -3px;'>".$entry['text']."</div>");
|
||||
echo("</div>");
|
||||
}
|
||||
echo "<div style='float: right; text-align: center; padding: 1px 5px; margin: 0 1px; ' class='rounded-5px'>";
|
||||
print_graph_popup($graph_array);
|
||||
echo "<div style='font-weight: bold; font-size: 7pt; margin: -3px;'>".$entry['text'].'</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
unset($graph_array);
|
||||
|
||||
echo('</td>
|
||||
</tr>');
|
||||
|
||||
?>
|
||||
echo '</td>
|
||||
</tr>';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
include_once("includes/object-cache.inc.php");
|
||||
require_once 'includes/object-cache.inc.php';
|
||||
?>
|
||||
<div class="panel panel-default panel-condensed table-responsive">
|
||||
<table class="table table-hover table-condensed table-striped">
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
include_once("includes/object-cache.inc.php");
|
||||
require_once 'includes/object-cache.inc.php';
|
||||
?>
|
||||
<div class="panel panel-default panel-condensed table-responsive">
|
||||
<table class="table table-hover table-condensed table-striped">
|
||||
|
||||
@@ -16,5 +16,3 @@ echo("
|
||||
</tr></table>");
|
||||
print_optionbar_end();
|
||||
echo("</div>");
|
||||
|
||||
?>
|
||||
|
||||
@@ -11,31 +11,23 @@
|
||||
* option) any later version. Please see LICENSE.txt at the top level of
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
|
||||
echo('
|
||||
echo '
|
||||
<div class="cycle-slideshow"
|
||||
data-cycle-fx="fade"
|
||||
data-cycle-timeout="10000"
|
||||
data-cycle-slides="> div"
|
||||
style="clear: both">
|
||||
');
|
||||
data-cycle-fx="fade"
|
||||
data-cycle-timeout="10000"
|
||||
data-cycle-slides="> div"
|
||||
style="clear: both">
|
||||
';
|
||||
|
||||
foreach (get_matching_files($config['html_dir']."/includes/front/", "/^top_.*\.php$/") as $file)
|
||||
{
|
||||
if(($file == 'top_ports.inc.php' && $config['top_ports'] == 0) || ($file == 'top_device_bits.inc.php' && $config['top_devices'] == 0))
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
echo("<div class=box>\n");
|
||||
include_once($file);
|
||||
echo("</div>\n");
|
||||
}
|
||||
foreach (get_matching_files($config['html_dir'].'/includes/front/', '/^top_.*\.php$/') as $file) {
|
||||
if (($file == 'top_ports.inc.php' && $config['top_ports'] == 0) || ($file == 'top_device_bits.inc.php' && $config['top_devices'] == 0)) {
|
||||
}
|
||||
else {
|
||||
echo "<div class=box>\n";
|
||||
include_once $file;
|
||||
echo "</div>\n";
|
||||
}
|
||||
}
|
||||
|
||||
echo("</div>\n");
|
||||
|
||||
?>
|
||||
|
||||
echo "</div>\n";
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
*/
|
||||
|
||||
$minutes = 15;
|
||||
$seconds = $minutes * 60;
|
||||
$top = $config['front_page_settings']['top']['devices'];
|
||||
if (is_admin() === TRUE || is_read() === TRUE) {
|
||||
$seconds = ($minutes * 60);
|
||||
$top = $config['front_page_settings']['top']['devices'];
|
||||
if (is_admin() === true || is_read() === true) {
|
||||
$query = "
|
||||
SELECT *, sum(p.ifInOctets_rate + p.ifOutOctets_rate) as total
|
||||
FROM ports as p, devices as d
|
||||
@@ -27,9 +27,10 @@ if (is_admin() === TRUE || is_read() === TRUE) {
|
||||
GROUP BY d.device_id
|
||||
ORDER BY total desc
|
||||
LIMIT $top
|
||||
";
|
||||
} else {
|
||||
$query = "
|
||||
";
|
||||
}
|
||||
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` = ? AND `P`.`device_id` = `d`.`device_id` AND
|
||||
@@ -40,19 +41,21 @@ if (is_admin() === TRUE || is_read() === TRUE) {
|
||||
GROUP BY d.device_id
|
||||
ORDER BY total desc
|
||||
LIMIT $top
|
||||
";
|
||||
";
|
||||
$param[] = array($_SESSION['user_id']);
|
||||
}//end if
|
||||
|
||||
echo "<strong>Top $top devices (last $minutes minutes)</strong>\n";
|
||||
echo "<table class='simple'>\n";
|
||||
foreach (dbFetchRows($query, $param) as $result) {
|
||||
echo '<tr class=top10>'.'<td class=top10>'.generate_device_link($result, shorthost($result['hostname'])).'</td>'.'<td class=top10>'.generate_device_link(
|
||||
$result,
|
||||
generate_minigraph_image($result, $config['time']['day'], $config['time']['now'], 'device_bits', 'no', 150, 21, '&', 'top10'),
|
||||
array(),
|
||||
0,
|
||||
0,
|
||||
0
|
||||
).'</td>'."</tr>\n";
|
||||
}
|
||||
|
||||
echo("<strong>Top $top devices (last $minutes minutes)</strong>\n");
|
||||
echo("<table class='simple'>\n");
|
||||
foreach (dbFetchRows($query,$param) as $result) {
|
||||
echo("<tr class=top10>".
|
||||
"<td class=top10>".generate_device_link($result, shorthost($result['hostname']))."</td>".
|
||||
"<td class=top10>".generate_device_link($result,
|
||||
generate_minigraph_image($result, $config['time']['day'], $config['time']['now'], "device_bits", "no", 150, 21, '&', "top10"), array(), 0, 0, 0)."</td>".
|
||||
"</tr>\n");
|
||||
}
|
||||
echo("</table>\n");
|
||||
|
||||
?>
|
||||
echo "</table>\n";
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
*/
|
||||
|
||||
$minutes = 15;
|
||||
$seconds = $minutes * 60;
|
||||
$top = $config['front_page_settings']['top']['ports'];
|
||||
if (is_admin() === TRUE || is_read() === TRUE) {
|
||||
$seconds = ($minutes * 60);
|
||||
$top = $config['front_page_settings']['top']['ports'];
|
||||
if (is_admin() === true || is_read() === true) {
|
||||
$query = "
|
||||
SELECT *, p.ifInOctets_rate + p.ifOutOctets_rate as total
|
||||
FROM ports as p, devices as d
|
||||
@@ -26,9 +26,10 @@ if (is_admin() === TRUE || is_read() === TRUE) {
|
||||
OR p.ifOutOctets_rate > 0 )
|
||||
ORDER BY total desc
|
||||
LIMIT $top
|
||||
";
|
||||
} else {
|
||||
$query = "
|
||||
";
|
||||
}
|
||||
else {
|
||||
$query = "
|
||||
SELECT *, I.ifInOctets_rate + I.ifOutOctets_rate as total
|
||||
FROM ports as I, devices as d,
|
||||
`devices_perms` AS `P`, `ports_perms` AS `PP`
|
||||
@@ -39,19 +40,17 @@ if (is_admin() === TRUE || is_read() === TRUE) {
|
||||
OR I.ifOutOctets_rate > 0 )
|
||||
ORDER BY total desc
|
||||
LIMIT $top
|
||||
";
|
||||
$param[] = array($_SESSION['user_id'],$_SESSION['user_id']);
|
||||
";
|
||||
$param[] = array(
|
||||
$_SESSION['user_id'],
|
||||
$_SESSION['user_id'],
|
||||
);
|
||||
}//end if
|
||||
|
||||
echo "<strong>Top $top ports (last $minutes minutes)</strong>\n";
|
||||
echo "<table class='simple'>\n";
|
||||
foreach (dbFetchRows($query, $param) as $result) {
|
||||
echo '<tr class=top10>'.'<td class=top10>'.generate_device_link($result, shorthost($result['hostname'])).'</td>'.'<td class=top10>'.generate_port_link($result).'</td>'.'<td class=top10>'.generate_port_link($result, generate_port_thumbnail($result)).'</td>'."</tr>\n";
|
||||
}
|
||||
|
||||
echo("<strong>Top $top ports (last $minutes minutes)</strong>\n");
|
||||
echo("<table class='simple'>\n");
|
||||
foreach (dbFetchRows($query,$param) as $result) {
|
||||
echo("<tr class=top10>".
|
||||
"<td class=top10>".generate_device_link($result, shorthost($result['hostname']))."</td>".
|
||||
"<td class=top10>".generate_port_link($result)."</td>".
|
||||
"<td class=top10>".generate_port_link($result, generate_port_thumbnail($result))."</td>".
|
||||
"</tr>\n");
|
||||
}
|
||||
echo("</table>\n");
|
||||
|
||||
?>
|
||||
echo "</table>\n";
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,172 +1,170 @@
|
||||
<?php
|
||||
|
||||
|
||||
$language_data = array (
|
||||
|
||||
'LANG_NAME' => 'IOS',
|
||||
'COMMENT_SINGLE' => array(1 => '!'),
|
||||
'CASE_KEYWORDS' => GESHI_CAPS_LOWER,
|
||||
'OOLANG' => false,
|
||||
'NUMBERS' => GESHI_NUMBER_OCT_PREFIX | GESHI_NUMBER_HEX_PREFIX,
|
||||
'KEYWORDS' => array(
|
||||
1 => array(
|
||||
'no', 'shutdown'
|
||||
),
|
||||
# 2 => array(
|
||||
# 'router', 'interface', 'service', 'config-register', 'upgrade', 'version', 'hostname', 'boot-start-marker', 'boot', 'boot-end-marker', 'enable', 'aaa', 'clock', 'ip',
|
||||
# 'logging', 'access-list', 'route-map', 'snmp-server', 'mpls', 'speed', 'media-type', 'negotiation', 'timestamps', 'prefix-list', 'network', 'mask', 'unsuppress-map',
|
||||
# 'neighbor', 'remote-as', 'ebgp-multihop', 'update-source', 'description', 'peer-group', 'policy-map', 'class-map', 'class', 'match', 'access-group', 'bandwidth', 'username',
|
||||
# 'password', 'send-community', 'next-hop-self', 'route-reflector-client', 'ldp', 'discovery', 'advertise-labels', 'label', 'protocol', 'login', 'debug', 'log', 'duplex', 'router-id',
|
||||
# 'authentication', 'mode', 'maximum-paths', 'address-family', 'set', 'local-preference', 'community', 'trap-source', 'location', 'host', 'tacacs-server', 'session-id',
|
||||
# 'flow-export', 'destination', 'source', 'in', 'out', 'permit', 'deny', 'control-plane', 'line', 'con' ,'aux', 'vty', 'access-class', 'ntp', 'server', 'end', 'source-interface',
|
||||
# 'key', 'chain', 'key-string', 'redundancy', 'match-any', 'queue-limit', 'encapsulation', 'pvc', 'vbr-nrt', 'address', 'bundle-enable', 'atm', 'sonet', 'clns', 'route-cache',
|
||||
# 'default-information', 'redistribute', 'log-adjacency-changes', 'metric', 'spf-interval', 'prc-interval', 'lsp-refresh-interval', 'max-lsp-lifetime', 'set-overload-bit',
|
||||
# 'on-startup', 'wait-for-bgp', 'system', 'flash', 'timezone', 'subnet-zero', 'cef', 'flow-cache', 'timeout', 'active', 'domain', 'lookup', 'dhcp', 'use', 'vrf', 'hello', 'interval',
|
||||
# 'priority', 'ilmi-keepalive', 'buffered', 'debugging', 'fpd', 'secret', 'accounting', 'exec', 'group', 'local', 'recurring', 'source-route', 'call', 'rsvp-sync', 'scripting',
|
||||
# 'mtu', 'passive-interface', 'area' , 'distribute-list', 'metric-style', 'is-type', 'originate', 'activate', 'both', 'auto-summary', 'synchronization', 'aggregate-address', 'le', 'ge',
|
||||
# 'bgp-community', 'route', 'exit-address-family', 'standard', 'file', 'verify', 'domain-name', 'domain-lookup', 'route-target', 'export', 'import', 'map', 'rd', 'mfib', 'vtp', 'mls',
|
||||
# 'hardware-switching', 'replication-mode', 'ingress', 'flow', 'error', 'action', 'slb', 'purge', 'share-global', 'routing', 'traffic-eng', 'tunnels', 'propagate-ttl', 'switchport', 'vlan',
|
||||
# 'portfast', 'counters', 'max', 'age', 'ethernet', 'evc', 'uni', 'count', 'oam', 'lmi', 'gmt', 'netflow', 'pseudowire-class', 'spanning-tree', 'name', 'circuit-type'
|
||||
# ),
|
||||
# 3 => array(
|
||||
# 'isis', 'ospf', 'eigrp', 'rip', 'igrp', 'bgp', 'ipv4', 'unicast', 'multicast', 'ipv6', 'connected', 'static', 'subnets', 'tcl'
|
||||
# ),
|
||||
# 4 => array(
|
||||
# 'point-to-point', 'aal5snap', 'rj45', 'auto', 'full', 'half', 'precedence', 'percent', 'datetime', 'msec', 'locatime', 'summer-time', 'md5', 'wait-for-bgp', 'wide',
|
||||
# 'level-1', 'level-2', 'log-neighbor-changes', 'directed-request', 'password-encryption', 'common', 'origin-as', 'bgp-nexthop', 'random-detect', 'localtime', 'sso', 'stm-1',
|
||||
# 'dot1q', 'isl', 'new-model', 'always', 'summary-only', 'freeze', 'global', 'forwarded', 'access', 'trunk', 'edge', 'transparent'
|
||||
# ),
|
||||
),
|
||||
|
||||
'REGEXPS' => array (
|
||||
1 => array(
|
||||
GESHI_SEARCH => '(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})',
|
||||
GESHI_REPLACE => '\\1',
|
||||
GESHI_BEFORE => '',
|
||||
),
|
||||
2 => array(
|
||||
GESHI_SEARCH => '(255\.\d{1,3}\.\d{1,3}\.\d{1,3})',
|
||||
GESHI_REPLACE => '\\1',
|
||||
GESHI_BEFORE => '',
|
||||
),
|
||||
3 => array(
|
||||
GESHI_SEARCH => '(source|interface|update-source|router-id) ([A-Za-z0-9\/\:\-\.]+)',
|
||||
GESHI_REPLACE => '\\2',
|
||||
GESHI_BEFORE => '\\1 ',
|
||||
),
|
||||
4 => array(
|
||||
GESHI_SEARCH => '(neighbor) ([\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}]+|[a-zA-Z0-9\-\_]+)',
|
||||
GESHI_REPLACE => '\\2',
|
||||
GESHI_BEFORE => '\\1 ',
|
||||
),
|
||||
5 => array(
|
||||
GESHI_SEARCH => '(distribute-map|access-group|policy-map|class-map\ match-any|ip\ access-list\ extended|match\ community|community-list\ standard|community-list\ expanded|ip\ access-list\ standard|router\ bgp|remote-as|key\ chain|service-policy\ input|service-policy\ output|class|login\ authentication|authentication\ key-chain|username|import\ map|export\ map|domain-name|hostname|route-map|access-class|ip\ vrf\ forwarding|ip\ vrf|vtp\ domain|name|pseudowire-class|pw-class|prefix-list|vrf) ([A-Za-z0-9\-\_\.]+)',
|
||||
GESHI_REPLACE => '\\2',
|
||||
GESHI_BEFORE => '\\1 ',
|
||||
),
|
||||
6 => array(
|
||||
GESHI_SEARCH => '(password|key-string|key) ([0-9]) (.+)',
|
||||
GESHI_REPLACE => '\\2 \\3',
|
||||
GESHI_BEFORE => '\\1 ',
|
||||
),
|
||||
7 => array(
|
||||
GESHI_SEARCH => '(enable) ([a-z]+) ([0-9]) (.+)',
|
||||
GESHI_REPLACE => '\\3 \\4',
|
||||
GESHI_BEFORE => '\\1 \\2 ',
|
||||
),
|
||||
8 => array(
|
||||
GESHI_SEARCH => '(description|location|contact|remark) (.+)',
|
||||
GESHI_REPLACE => '\\2',
|
||||
GESHI_BEFORE => '\\1 ',
|
||||
),
|
||||
9 => array(
|
||||
GESHI_SEARCH => '([0-9\.\_\*]+\:[0-9\.\_\*]+)',
|
||||
GESHI_REPLACE => '\\1',
|
||||
),
|
||||
10 => array(
|
||||
GESHI_SEARCH => '(boot) ([a-z]+) (.+)',
|
||||
GESHI_REPLACE => '\\3',
|
||||
GESHI_BEFORE => '\\1 \\2 '
|
||||
),
|
||||
11 => array(
|
||||
GESHI_SEARCH => '(net) ([0-9a-z\.]+)',
|
||||
GESHI_REPLACE => '\\2',
|
||||
GESHI_BEFORE => '\\1 '
|
||||
),
|
||||
12 => array(
|
||||
GESHI_SEARCH => '(access-list|RO|RW) ([0-9]+)',
|
||||
GESHI_REPLACE => '\\2',
|
||||
GESHI_BEFORE => '\\1 '
|
||||
),
|
||||
13 => array(
|
||||
GESHI_SEARCH => '(vlan) ([0-9]+)',
|
||||
GESHI_REPLACE => '\\2',
|
||||
GESHI_BEFORE => '\\1 '
|
||||
),
|
||||
14 => array(
|
||||
GESHI_SEARCH => '(encapsulation|speed|duplex|mtu|metric|media-type|negotiation|transport\ input|bgp-community|set\ as-path\ prepend|maximum-prefix|version|local-preference|continue|redistribute|cluster-id|vtp\ mode|label\ protocol|spanning-tree\ mode) (.+)',
|
||||
GESHI_REPLACE => '\\2',
|
||||
GESHI_BEFORE => '\\1 '
|
||||
$language_data = array(
|
||||
'LANG_NAME' => 'IOS',
|
||||
'COMMENT_SINGLE' => array(1 => '!'),
|
||||
'CASE_KEYWORDS' => GESHI_CAPS_LOWER,
|
||||
'OOLANG' => false,
|
||||
'NUMBERS' => GESHI_NUMBER_OCT_PREFIX | GESHI_NUMBER_HEX_PREFIX,
|
||||
'KEYWORDS' => array(
|
||||
1 => array(
|
||||
'no',
|
||||
'shutdown',
|
||||
),
|
||||
// 2 => array(
|
||||
// 'router', 'interface', 'service', 'config-register', 'upgrade', 'version', 'hostname', 'boot-start-marker', 'boot', 'boot-end-marker', 'enable', 'aaa', 'clock', 'ip',
|
||||
// 'logging', 'access-list', 'route-map', 'snmp-server', 'mpls', 'speed', 'media-type', 'negotiation', 'timestamps', 'prefix-list', 'network', 'mask', 'unsuppress-map',
|
||||
// 'neighbor', 'remote-as', 'ebgp-multihop', 'update-source', 'description', 'peer-group', 'policy-map', 'class-map', 'class', 'match', 'access-group', 'bandwidth', 'username',
|
||||
// 'password', 'send-community', 'next-hop-self', 'route-reflector-client', 'ldp', 'discovery', 'advertise-labels', 'label', 'protocol', 'login', 'debug', 'log', 'duplex', 'router-id',
|
||||
// 'authentication', 'mode', 'maximum-paths', 'address-family', 'set', 'local-preference', 'community', 'trap-source', 'location', 'host', 'tacacs-server', 'session-id',
|
||||
// 'flow-export', 'destination', 'source', 'in', 'out', 'permit', 'deny', 'control-plane', 'line', 'con' ,'aux', 'vty', 'access-class', 'ntp', 'server', 'end', 'source-interface',
|
||||
// 'key', 'chain', 'key-string', 'redundancy', 'match-any', 'queue-limit', 'encapsulation', 'pvc', 'vbr-nrt', 'address', 'bundle-enable', 'atm', 'sonet', 'clns', 'route-cache',
|
||||
// 'default-information', 'redistribute', 'log-adjacency-changes', 'metric', 'spf-interval', 'prc-interval', 'lsp-refresh-interval', 'max-lsp-lifetime', 'set-overload-bit',
|
||||
// 'on-startup', 'wait-for-bgp', 'system', 'flash', 'timezone', 'subnet-zero', 'cef', 'flow-cache', 'timeout', 'active', 'domain', 'lookup', 'dhcp', 'use', 'vrf', 'hello', 'interval',
|
||||
// 'priority', 'ilmi-keepalive', 'buffered', 'debugging', 'fpd', 'secret', 'accounting', 'exec', 'group', 'local', 'recurring', 'source-route', 'call', 'rsvp-sync', 'scripting',
|
||||
// 'mtu', 'passive-interface', 'area' , 'distribute-list', 'metric-style', 'is-type', 'originate', 'activate', 'both', 'auto-summary', 'synchronization', 'aggregate-address', 'le', 'ge',
|
||||
// 'bgp-community', 'route', 'exit-address-family', 'standard', 'file', 'verify', 'domain-name', 'domain-lookup', 'route-target', 'export', 'import', 'map', 'rd', 'mfib', 'vtp', 'mls',
|
||||
// 'hardware-switching', 'replication-mode', 'ingress', 'flow', 'error', 'action', 'slb', 'purge', 'share-global', 'routing', 'traffic-eng', 'tunnels', 'propagate-ttl', 'switchport', 'vlan',
|
||||
// 'portfast', 'counters', 'max', 'age', 'ethernet', 'evc', 'uni', 'count', 'oam', 'lmi', 'gmt', 'netflow', 'pseudowire-class', 'spanning-tree', 'name', 'circuit-type'
|
||||
// ),
|
||||
// 3 => array(
|
||||
// 'isis', 'ospf', 'eigrp', 'rip', 'igrp', 'bgp', 'ipv4', 'unicast', 'multicast', 'ipv6', 'connected', 'static', 'subnets', 'tcl'
|
||||
// ),
|
||||
// 4 => array(
|
||||
// 'point-to-point', 'aal5snap', 'rj45', 'auto', 'full', 'half', 'precedence', 'percent', 'datetime', 'msec', 'locatime', 'summer-time', 'md5', 'wait-for-bgp', 'wide',
|
||||
// 'level-1', 'level-2', 'log-neighbor-changes', 'directed-request', 'password-encryption', 'common', 'origin-as', 'bgp-nexthop', 'random-detect', 'localtime', 'sso', 'stm-1',
|
||||
// 'dot1q', 'isl', 'new-model', 'always', 'summary-only', 'freeze', 'global', 'forwarded', 'access', 'trunk', 'edge', 'transparent'
|
||||
// ),
|
||||
),
|
||||
|
||||
),
|
||||
|
||||
'STYLES' => array(
|
||||
'REGEXPS' => array(
|
||||
0 => 'color: #ff0000;',
|
||||
1 => 'color: #0000cc;', # x.x.x.x
|
||||
2 => 'color: #000099; font-style: italic', # 255.x.x.x
|
||||
3 => 'color: #000000; font-weight: bold; font-style: italic;', # interface xxx
|
||||
4 => 'color: #ff0000;', # neighbor x.x.x.x
|
||||
5 => 'color: #000099;', # variable names
|
||||
6 => 'color: #cc0000;',
|
||||
7 => 'color: #cc0000;', # passwords
|
||||
8 => 'color: #555555;', # description
|
||||
9 => 'color: #990099;', # communities
|
||||
10 => 'color: #cc0000; font-style: italic;', # no/shut
|
||||
11 => 'color: #000099;', # net numbers
|
||||
12 => 'color: #000099;', # acls
|
||||
13 => 'color: #000099;', # acls
|
||||
14 => 'color: #990099;', # warnings
|
||||
),
|
||||
'KEYWORDS' => array(
|
||||
1 => 'color: #cc0000; font-weight: bold;', # no/shut
|
||||
2 => 'color: #000000;', # commands
|
||||
3 => 'color: #000000; font-weight: bold;', # proto/service
|
||||
4 => 'color: #000000;', # options
|
||||
5 => 'color: #ff0000;'
|
||||
),
|
||||
'COMMENTS' => array(
|
||||
1 => 'color: #808080; font-style: italic;'
|
||||
),
|
||||
'ESCAPE_CHAR' => array(
|
||||
0 => 'color: #000099; font-weight: bold;'
|
||||
),
|
||||
'BRACKETS' => array(
|
||||
0 => 'color: #66cc66;'
|
||||
),
|
||||
'STRINGS' => array(
|
||||
0 => 'color: #ff0000;'
|
||||
),
|
||||
'NUMBERS' => array(
|
||||
0 => 'color: #cc0000;'
|
||||
),
|
||||
'METHODS' => array(
|
||||
0 => 'color: #006600;'
|
||||
),
|
||||
'SYMBOLS' => array(
|
||||
0 => 'color: #66cc66;'
|
||||
),
|
||||
'SCRIPT' => array(
|
||||
0 => '',
|
||||
1 => '',
|
||||
2 => '',
|
||||
3 => ''
|
||||
)
|
||||
|
||||
)
|
||||
'REGEXPS' => array(
|
||||
1 => array(
|
||||
GESHI_SEARCH => '(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})',
|
||||
GESHI_REPLACE => '\\1',
|
||||
GESHI_BEFORE => '',
|
||||
),
|
||||
2 => array(
|
||||
GESHI_SEARCH => '(255\.\d{1,3}\.\d{1,3}\.\d{1,3})',
|
||||
GESHI_REPLACE => '\\1',
|
||||
GESHI_BEFORE => '',
|
||||
),
|
||||
3 => array(
|
||||
GESHI_SEARCH => '(source|interface|update-source|router-id) ([A-Za-z0-9\/\:\-\.]+)',
|
||||
GESHI_REPLACE => '\\2',
|
||||
GESHI_BEFORE => '\\1 ',
|
||||
),
|
||||
4 => array(
|
||||
GESHI_SEARCH => '(neighbor) ([\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}]+|[a-zA-Z0-9\-\_]+)',
|
||||
GESHI_REPLACE => '\\2',
|
||||
GESHI_BEFORE => '\\1 ',
|
||||
),
|
||||
5 => array(
|
||||
GESHI_SEARCH => '(distribute-map|access-group|policy-map|class-map\ match-any|ip\ access-list\ extended|match\ community|community-list\ standard|community-list\ expanded|ip\ access-list\ standard|router\ bgp|remote-as|key\ chain|service-policy\ input|service-policy\ output|class|login\ authentication|authentication\ key-chain|username|import\ map|export\ map|domain-name|hostname|route-map|access-class|ip\ vrf\ forwarding|ip\ vrf|vtp\ domain|name|pseudowire-class|pw-class|prefix-list|vrf) ([A-Za-z0-9\-\_\.]+)',
|
||||
GESHI_REPLACE => '\\2',
|
||||
GESHI_BEFORE => '\\1 ',
|
||||
),
|
||||
6 => array(
|
||||
GESHI_SEARCH => '(password|key-string|key) ([0-9]) (.+)',
|
||||
GESHI_REPLACE => '\\2 \\3',
|
||||
GESHI_BEFORE => '\\1 ',
|
||||
),
|
||||
7 => array(
|
||||
GESHI_SEARCH => '(enable) ([a-z]+) ([0-9]) (.+)',
|
||||
GESHI_REPLACE => '\\3 \\4',
|
||||
GESHI_BEFORE => '\\1 \\2 ',
|
||||
),
|
||||
8 => array(
|
||||
GESHI_SEARCH => '(description|location|contact|remark) (.+)',
|
||||
GESHI_REPLACE => '\\2',
|
||||
GESHI_BEFORE => '\\1 ',
|
||||
),
|
||||
9 => array(
|
||||
GESHI_SEARCH => '([0-9\.\_\*]+\:[0-9\.\_\*]+)',
|
||||
GESHI_REPLACE => '\\1',
|
||||
),
|
||||
10 => array(
|
||||
GESHI_SEARCH => '(boot) ([a-z]+) (.+)',
|
||||
GESHI_REPLACE => '\\3',
|
||||
GESHI_BEFORE => '\\1 \\2 ',
|
||||
),
|
||||
11 => array(
|
||||
GESHI_SEARCH => '(net) ([0-9a-z\.]+)',
|
||||
GESHI_REPLACE => '\\2',
|
||||
GESHI_BEFORE => '\\1 ',
|
||||
),
|
||||
12 => array(
|
||||
GESHI_SEARCH => '(access-list|RO|RW) ([0-9]+)',
|
||||
GESHI_REPLACE => '\\2',
|
||||
GESHI_BEFORE => '\\1 ',
|
||||
),
|
||||
13 => array(
|
||||
GESHI_SEARCH => '(vlan) ([0-9]+)',
|
||||
GESHI_REPLACE => '\\2',
|
||||
GESHI_BEFORE => '\\1 ',
|
||||
),
|
||||
14 => array(
|
||||
GESHI_SEARCH => '(encapsulation|speed|duplex|mtu|metric|media-type|negotiation|transport\ input|bgp-community|set\ as-path\ prepend|maximum-prefix|version|local-preference|continue|redistribute|cluster-id|vtp\ mode|label\ protocol|spanning-tree\ mode) (.+)',
|
||||
GESHI_REPLACE => '\\2',
|
||||
GESHI_BEFORE => '\\1 ',
|
||||
),
|
||||
|
||||
),
|
||||
|
||||
'STYLES' => array(
|
||||
'REGEXPS' => array(
|
||||
0 => 'color: #ff0000;',
|
||||
1 => 'color: #0000cc;',
|
||||
// x.x.x.x
|
||||
2 => 'color: #000099; font-style: italic',
|
||||
// 255.x.x.x
|
||||
3 => 'color: #000000; font-weight: bold; font-style: italic;',
|
||||
// interface xxx
|
||||
4 => 'color: #ff0000;',
|
||||
// neighbor x.x.x.x
|
||||
5 => 'color: #000099;',
|
||||
// variable names
|
||||
6 => 'color: #cc0000;',
|
||||
7 => 'color: #cc0000;',
|
||||
// passwords
|
||||
8 => 'color: #555555;',
|
||||
// description
|
||||
9 => 'color: #990099;',
|
||||
// communities
|
||||
10 => 'color: #cc0000; font-style: italic;',
|
||||
// no/shut
|
||||
11 => 'color: #000099;',
|
||||
// net numbers
|
||||
12 => 'color: #000099;',
|
||||
// acls
|
||||
13 => 'color: #000099;',
|
||||
// acls
|
||||
14 => 'color: #990099;',
|
||||
// warnings
|
||||
),
|
||||
'KEYWORDS' => array(
|
||||
1 => 'color: #cc0000; font-weight: bold;',
|
||||
// no/shut
|
||||
2 => 'color: #000000;',
|
||||
// commands
|
||||
3 => 'color: #000000; font-weight: bold;',
|
||||
// proto/service
|
||||
4 => 'color: #000000;',
|
||||
// options
|
||||
5 => 'color: #ff0000;',
|
||||
),
|
||||
'COMMENTS' => array(1 => 'color: #808080; font-style: italic;'),
|
||||
'ESCAPE_CHAR' => array(0 => 'color: #000099; font-weight: bold;'),
|
||||
'BRACKETS' => array(0 => 'color: #66cc66;'),
|
||||
'STRINGS' => array(0 => 'color: #ff0000;'),
|
||||
'NUMBERS' => array(0 => 'color: #cc0000;'),
|
||||
'METHODS' => array(0 => 'color: #006600;'),
|
||||
'SYMBOLS' => array(0 => 'color: #66cc66;'),
|
||||
'SCRIPT' => array(
|
||||
0 => '',
|
||||
1 => '',
|
||||
2 => '',
|
||||
3 => '',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,25 +1,21 @@
|
||||
<?php
|
||||
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] ."/".
|
||||
safename("arubaap-$ap[name].$ap[radio_number].rrd");
|
||||
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename("arubaap-$ap[name].$ap[radio_number].rrd");
|
||||
|
||||
$rrd_list[0]['filename'] = $rrd_filename;
|
||||
$rrd_list[0]['descr'] = "Channel";
|
||||
$rrd_list[0]['ds'] = "channel";
|
||||
$rrd_list[0]['descr'] = 'Channel';
|
||||
$rrd_list[0]['ds'] = 'channel';
|
||||
|
||||
$unit_text = "Channel";
|
||||
$unit_text = 'Channel';
|
||||
|
||||
$units='';
|
||||
$total_units='';
|
||||
$colours='mixed';
|
||||
$units = '';
|
||||
$total_units = '';
|
||||
$colours = 'mixed';
|
||||
|
||||
$scale_min = "0";
|
||||
$scale_min = '0';
|
||||
|
||||
$nototal = 1;
|
||||
|
||||
if ($rrd_list)
|
||||
{
|
||||
include("includes/graphs/generic_multi_line.inc.php");
|
||||
if ($rrd_list) {
|
||||
include 'includes/graphs/generic_multi_line.inc.php';
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -2,27 +2,24 @@
|
||||
|
||||
$scale_min = 0;
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
require 'includes/graphs/common.inc.php';
|
||||
|
||||
$apache_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-apache-".$app['app_id'].".rrd";
|
||||
$apache_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/app-apache-'.$app['app_id'].'.rrd';
|
||||
|
||||
if (is_file($apache_rrd))
|
||||
{
|
||||
$rrd_filename = $apache_rrd;
|
||||
if (is_file($apache_rrd)) {
|
||||
$rrd_filename = $apache_rrd;
|
||||
}
|
||||
|
||||
$ds = "kbyte";
|
||||
$ds = 'kbyte';
|
||||
|
||||
$colour_area = "CDEB8B";
|
||||
$colour_line = "006600";
|
||||
$colour_area = 'CDEB8B';
|
||||
$colour_line = '006600';
|
||||
|
||||
$colour_area_max = "FFEE99";
|
||||
$colour_area_max = 'FFEE99';
|
||||
|
||||
$graph_max = 1;
|
||||
$graph_max = 1;
|
||||
$multiplier = 8;
|
||||
|
||||
$unit_text = "Kbps";
|
||||
$unit_text = 'Kbps';
|
||||
|
||||
include("includes/graphs/generic_simplex.inc.php");
|
||||
|
||||
?>
|
||||
require 'includes/graphs/generic_simplex.inc.php';
|
||||
|
||||
@@ -2,26 +2,23 @@
|
||||
|
||||
$scale_min = 0;
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
require 'includes/graphs/common.inc.php';
|
||||
|
||||
$apache_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-apache-".$app['app_id'].".rrd";
|
||||
$apache_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/app-apache-'.$app['app_id'].'.rrd';
|
||||
|
||||
if (is_file($apache_rrd))
|
||||
{
|
||||
$rrd_filename = $apache_rrd;
|
||||
if (is_file($apache_rrd)) {
|
||||
$rrd_filename = $apache_rrd;
|
||||
}
|
||||
|
||||
$ds = "cpu";
|
||||
$ds = 'cpu';
|
||||
|
||||
$colour_area = "F0E68C";
|
||||
$colour_line = "FF4500";
|
||||
$colour_area = 'F0E68C';
|
||||
$colour_line = 'FF4500';
|
||||
|
||||
$colour_area_max = "FFEE99";
|
||||
$colour_area_max = 'FFEE99';
|
||||
|
||||
$graph_max = 1;
|
||||
|
||||
$unit_text = "% Used";
|
||||
$unit_text = '% Used';
|
||||
|
||||
include("includes/graphs/generic_simplex.inc.php");
|
||||
|
||||
?>
|
||||
require 'includes/graphs/generic_simplex.inc.php';
|
||||
|
||||
@@ -2,26 +2,23 @@
|
||||
|
||||
$scale_min = 0;
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
require 'includes/graphs/common.inc.php';
|
||||
|
||||
$apache_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-apache-".$app['app_id'].".rrd";
|
||||
$apache_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/app-apache-'.$app['app_id'].'.rrd';
|
||||
|
||||
if (is_file($apache_rrd))
|
||||
{
|
||||
$rrd_filename = $apache_rrd;
|
||||
if (is_file($apache_rrd)) {
|
||||
$rrd_filename = $apache_rrd;
|
||||
}
|
||||
|
||||
$ds = "access";
|
||||
$ds = 'access';
|
||||
|
||||
$colour_area = "B0C4DE";
|
||||
$colour_line = "191970";
|
||||
$colour_area = 'B0C4DE';
|
||||
$colour_line = '191970';
|
||||
|
||||
$colour_area_max = "FFEE99";
|
||||
$colour_area_max = 'FFEE99';
|
||||
|
||||
$graph_max = 1;
|
||||
|
||||
$unit_text = "Hits/sec";
|
||||
$unit_text = 'Hits/sec';
|
||||
|
||||
include("includes/graphs/generic_simplex.inc.php");
|
||||
|
||||
?>
|
||||
require 'includes/graphs/generic_simplex.inc.php';
|
||||
|
||||
@@ -2,39 +2,69 @@
|
||||
|
||||
$scale_min = 0;
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
require 'includes/graphs/common.inc.php';
|
||||
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-apache-".$app['app_id'].".rrd";
|
||||
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-apache-'.$app['app_id'].'.rrd';
|
||||
|
||||
$array = array('sb_reading' => array('descr' => 'Reading', 'colour' => '750F7DFF'),
|
||||
'sb_writing' => array('descr' => 'Writing', 'colour' => '00FF00FF'),
|
||||
'sb_wait' => array('descr' => 'Waiting', 'colour' => '4444FFFF'),
|
||||
'sb_start' => array('descr' => 'Starting', 'colour' => '157419FF'),
|
||||
'sb_keepalive' => array('descr' => 'Keepalive', 'colour' => 'FF0000FF'),
|
||||
'sb_dns' => array('descr' => 'DNS', 'colour' => '6DC8FEFF'),
|
||||
'sb_closing' => array('descr' => 'Closing', 'colour' => 'FFAB00FF'),
|
||||
'sb_logging' => array('descr' => 'Logging', 'colour' => 'FFFF00FF'),
|
||||
'sb_graceful' => array('descr' => 'Graceful', 'colour' => 'FF5576FF'),
|
||||
'sb_idle' => array('descr' => 'Idle', 'colour' => 'FF4105FF'),
|
||||
$array = array(
|
||||
'sb_reading' => array(
|
||||
'descr' => 'Reading',
|
||||
'colour' => '750F7DFF',
|
||||
),
|
||||
'sb_writing' => array(
|
||||
'descr' => 'Writing',
|
||||
'colour' => '00FF00FF',
|
||||
),
|
||||
'sb_wait' => array(
|
||||
'descr' => 'Waiting',
|
||||
'colour' => '4444FFFF',
|
||||
),
|
||||
'sb_start' => array(
|
||||
'descr' => 'Starting',
|
||||
'colour' => '157419FF',
|
||||
),
|
||||
'sb_keepalive' => array(
|
||||
'descr' => 'Keepalive',
|
||||
'colour' => 'FF0000FF',
|
||||
),
|
||||
'sb_dns' => array(
|
||||
'descr' => 'DNS',
|
||||
'colour' => '6DC8FEFF',
|
||||
),
|
||||
'sb_closing' => array(
|
||||
'descr' => 'Closing',
|
||||
'colour' => 'FFAB00FF',
|
||||
),
|
||||
'sb_logging' => array(
|
||||
'descr' => 'Logging',
|
||||
'colour' => 'FFFF00FF',
|
||||
),
|
||||
'sb_graceful' => array(
|
||||
'descr' => 'Graceful',
|
||||
'colour' => 'FF5576FF',
|
||||
),
|
||||
'sb_idle' => array(
|
||||
'descr' => 'Idle',
|
||||
'colour' => 'FF4105FF',
|
||||
),
|
||||
);
|
||||
|
||||
$i = 0;
|
||||
if (is_file($rrd_filename))
|
||||
{
|
||||
foreach ($array as $ds => $vars)
|
||||
{
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = $vars['descr'];
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$rrd_list[$i]['colour'] = $vars['colour'];
|
||||
$i++;
|
||||
}
|
||||
} else { echo("file missing: $file"); }
|
||||
if (is_file($rrd_filename)) {
|
||||
foreach ($array as $ds => $vars) {
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = $vars['descr'];
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$rrd_list[$i]['colour'] = $vars['colour'];
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo "file missing: $file";
|
||||
}
|
||||
|
||||
$colours = "mixed";
|
||||
$colours = 'mixed';
|
||||
$nototal = 1;
|
||||
$unit_text = "Workers";
|
||||
$unit_text = 'Workers';
|
||||
|
||||
include("includes/graphs/generic_multi_simplex_seperated.inc.php");
|
||||
|
||||
?>
|
||||
require 'includes/graphs/generic_multi_simplex_seperated.inc.php';
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
<?php
|
||||
/* Copyright (C) 2015 Daniel Preussker <f0o@devilcode.org>
|
||||
/*
|
||||
* Copyright (C) 2015 Daniel Preussker <f0o@devilcode.org>
|
||||
* 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/>. */
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* Bind9 Query Graph
|
||||
* @author Daniel Preussker <f0o@devilcode.org>
|
||||
* @copyright 2015 f0o, LibreNMS
|
||||
@@ -22,29 +24,40 @@
|
||||
* @subpackage Graphs
|
||||
*/
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
require 'includes/graphs/common.inc.php';
|
||||
|
||||
$i = 0;
|
||||
$scale_min = 0;
|
||||
$nototal = 1;
|
||||
$unit_text = "Query/sec";
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-bind-".$app['app_id'].".rrd";
|
||||
$array = array( 'any', 'a', 'aaaa', 'cname', 'mx', 'ns', 'ptr', 'soa', 'srv', 'spf' );
|
||||
$colours = "merged";
|
||||
$unit_text = 'Query/sec';
|
||||
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-bind-'.$app['app_id'].'.rrd';
|
||||
$array = array(
|
||||
'any',
|
||||
'a',
|
||||
'aaaa',
|
||||
'cname',
|
||||
'mx',
|
||||
'ns',
|
||||
'ptr',
|
||||
'soa',
|
||||
'srv',
|
||||
'spf',
|
||||
);
|
||||
$colours = 'merged';
|
||||
$rrd_list = array();
|
||||
|
||||
$config['graph_colours']['merged'] = array_merge($config['graph_colours']['greens'], $config['graph_colours']['blues']);
|
||||
|
||||
if( is_file($rrd_filename) ) {
|
||||
foreach( $array as $ds ) {
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = strtoupper($ds);
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
echo "file missing: $file";
|
||||
if (is_file($rrd_filename)) {
|
||||
foreach ($array as $ds) {
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = strtoupper($ds);
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo "file missing: $file";
|
||||
}
|
||||
|
||||
include("includes/graphs/generic_multi_simplex_seperated.inc.php");
|
||||
?>
|
||||
require 'includes/graphs/generic_multi_simplex_seperated.inc.php';
|
||||
|
||||
@@ -2,21 +2,18 @@
|
||||
|
||||
$scale_min = 0;
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
require 'includes/graphs/common.inc.php';
|
||||
|
||||
$drbd_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-drbd-".$app['app_instance'].".rrd";
|
||||
$drbd_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/app-drbd-'.$app['app_instance'].'.rrd';
|
||||
|
||||
if (is_file($drbd_rrd))
|
||||
{
|
||||
$rrd_filename = $drbd_rrd;
|
||||
if (is_file($drbd_rrd)) {
|
||||
$rrd_filename = $drbd_rrd;
|
||||
}
|
||||
|
||||
$ds_in = "dr";
|
||||
$ds_out = "dw";
|
||||
$ds_in = 'dr';
|
||||
$ds_out = 'dw';
|
||||
|
||||
$multiplier = "8";
|
||||
$format = "bytes";
|
||||
$multiplier = '8';
|
||||
$format = 'bytes';
|
||||
|
||||
include("includes/graphs/generic_data.inc.php");
|
||||
|
||||
?>
|
||||
require 'includes/graphs/generic_data.inc.php';
|
||||
|
||||
@@ -2,20 +2,17 @@
|
||||
|
||||
$scale_min = 0;
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
require 'includes/graphs/common.inc.php';
|
||||
|
||||
$drbd_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-drbd-".$app['app_instance'].".rrd";
|
||||
$drbd_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/app-drbd-'.$app['app_instance'].'.rrd';
|
||||
|
||||
if (is_file($drbd_rrd))
|
||||
{
|
||||
$rrd_filename = $drbd_rrd;
|
||||
if (is_file($drbd_rrd)) {
|
||||
$rrd_filename = $drbd_rrd;
|
||||
}
|
||||
|
||||
$ds_in = "nr";
|
||||
$ds_out = "ns";
|
||||
$ds_in = 'nr';
|
||||
$ds_out = 'ns';
|
||||
|
||||
$multiplier = "8";
|
||||
$multiplier = '8';
|
||||
|
||||
include("includes/graphs/generic_data.inc.php");
|
||||
|
||||
?>
|
||||
require 'includes/graphs/generic_data.inc.php';
|
||||
|
||||
@@ -2,27 +2,24 @@
|
||||
|
||||
$scale_min = 0;
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
require 'includes/graphs/common.inc.php';
|
||||
|
||||
$drbd_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-drbd-".$app['app_instance'].".rrd";
|
||||
$drbd_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/app-drbd-'.$app['app_instance'].'.rrd';
|
||||
|
||||
if (is_file($drbd_rrd))
|
||||
{
|
||||
$rrd_filename = $drbd_rrd;
|
||||
if (is_file($drbd_rrd)) {
|
||||
$rrd_filename = $drbd_rrd;
|
||||
}
|
||||
|
||||
$ds = "oos";
|
||||
$ds = 'oos';
|
||||
|
||||
$colour_area = "CDEB8B";
|
||||
$colour_line = "006600";
|
||||
$colour_area = 'CDEB8B';
|
||||
$colour_line = '006600';
|
||||
|
||||
$colour_area_max = "FFEE99";
|
||||
$colour_area_max = 'FFEE99';
|
||||
|
||||
$graph_max = 1;
|
||||
$graph_max = 1;
|
||||
$multiplier = 8;
|
||||
|
||||
$unit_text = "Bytes";
|
||||
$unit_text = 'Bytes';
|
||||
|
||||
include("includes/graphs/generic_simplex.inc.php");
|
||||
|
||||
?>
|
||||
require 'includes/graphs/generic_simplex.inc.php';
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
<?php
|
||||
|
||||
include("memcached.inc.php");
|
||||
include("includes/graphs/common.inc.php");
|
||||
require 'memcached.inc.php';
|
||||
require 'includes/graphs/common.inc.php';
|
||||
|
||||
$multiplier = 8;
|
||||
|
||||
$ds_in = "bytes_read";
|
||||
$ds_out = "bytes_written";
|
||||
$ds_in = 'bytes_read';
|
||||
$ds_out = 'bytes_written';
|
||||
|
||||
include("includes/graphs/generic_data.inc.php");
|
||||
|
||||
?>
|
||||
require 'includes/graphs/generic_data.inc.php';
|
||||
|
||||
@@ -5,43 +5,43 @@ require 'includes/graphs/common.inc.php';
|
||||
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-mysql-'.$app['app_id'].'.rrd';
|
||||
|
||||
$array = array(
|
||||
'CDe' => array(
|
||||
'descr' => 'Delete',
|
||||
'colour' => '22FF22',
|
||||
),
|
||||
'CIt' => array(
|
||||
'descr' => 'Insert',
|
||||
'colour' => '0022FF',
|
||||
),
|
||||
'CISt' => array(
|
||||
'descr' => 'Insert Select',
|
||||
'colour' => 'FF0000',
|
||||
),
|
||||
'CLd' => array(
|
||||
'descr' => 'Load Data',
|
||||
'colour' => '00AAAA',
|
||||
),
|
||||
'CRe' => array(
|
||||
'descr' => 'Replace',
|
||||
'colour' => 'FF00FF',
|
||||
),
|
||||
'CRSt' => array(
|
||||
'descr' => 'Replace Select',
|
||||
'colour' => 'FFA500',
|
||||
),
|
||||
'CSt' => array(
|
||||
'descr' => 'Select',
|
||||
'colour' => 'CC0000',
|
||||
),
|
||||
'CUe' => array(
|
||||
'descr' => 'Update',
|
||||
'colour' => '0000CC',
|
||||
),
|
||||
'CUMi' => array(
|
||||
'descr' => 'Update Multiple',
|
||||
'colour' => '0080C0',
|
||||
),
|
||||
);
|
||||
'CDe' => array(
|
||||
'descr' => 'Delete',
|
||||
'colour' => '22FF22',
|
||||
),
|
||||
'CIt' => array(
|
||||
'descr' => 'Insert',
|
||||
'colour' => '0022FF',
|
||||
),
|
||||
'CISt' => array(
|
||||
'descr' => 'Insert Select',
|
||||
'colour' => 'FF0000',
|
||||
),
|
||||
'CLd' => array(
|
||||
'descr' => 'Load Data',
|
||||
'colour' => '00AAAA',
|
||||
),
|
||||
'CRe' => array(
|
||||
'descr' => 'Replace',
|
||||
'colour' => 'FF00FF',
|
||||
),
|
||||
'CRSt' => array(
|
||||
'descr' => 'Replace Select',
|
||||
'colour' => 'FFA500',
|
||||
),
|
||||
'CSt' => array(
|
||||
'descr' => 'Select',
|
||||
'colour' => 'CC0000',
|
||||
),
|
||||
'CUe' => array(
|
||||
'descr' => 'Update',
|
||||
'colour' => '0000CC',
|
||||
),
|
||||
'CUMi' => array(
|
||||
'descr' => 'Update Multiple',
|
||||
'colour' => '0080C0',
|
||||
),
|
||||
);
|
||||
|
||||
$i = 0;
|
||||
if (is_file($rrd_filename)) {
|
||||
@@ -52,7 +52,8 @@ if (is_file($rrd_filename)) {
|
||||
// $rrd_list[$i]['colour'] = $vars['colour'];
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
echo "file missing: $file";
|
||||
}
|
||||
|
||||
|
||||
@@ -7,15 +7,15 @@ $nototal = (($width < 224) ? 1 : 0);
|
||||
$unit_text = 'Packets';
|
||||
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-ntpdserver-'.$app['app_id'].'.rrd';
|
||||
$array = array(
|
||||
'packets_drop' => array(
|
||||
'descr' => 'Dropped',
|
||||
'colour' => '880000FF',
|
||||
),
|
||||
'packets_ignore' => array(
|
||||
'descr' => 'Ignored',
|
||||
'colour' => 'FF8800FF',
|
||||
),
|
||||
);
|
||||
'packets_drop' => array(
|
||||
'descr' => 'Dropped',
|
||||
'colour' => '880000FF',
|
||||
),
|
||||
'packets_ignore' => array(
|
||||
'descr' => 'Ignored',
|
||||
'colour' => 'FF8800FF',
|
||||
),
|
||||
);
|
||||
|
||||
$i = 0;
|
||||
|
||||
|
||||
@@ -25,8 +25,7 @@ $files = array();
|
||||
$i = 0;
|
||||
|
||||
if ($handle = opendir($rrddir)) {
|
||||
while (false !== ($file = readdir($handle)))
|
||||
{
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if ($file != '.' && $file != '..') {
|
||||
if (eregi('app-shoutcast-'.$app['app_id'], $file)) {
|
||||
array_push($files, $file);
|
||||
|
||||
@@ -13,8 +13,7 @@ $i = 0;
|
||||
$x = 0;
|
||||
|
||||
if ($handle = opendir($rrddir)) {
|
||||
while (false !== ($file = readdir($handle)))
|
||||
{
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if ($file != '.' && $file != '..') {
|
||||
if (eregi('app-shoutcast-'.$app['app_id'], $file)) {
|
||||
array_push($files, $file);
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
<?php
|
||||
/* Copyright (C) 2015 Daniel Preussker <f0o@devilcode.org>
|
||||
/*
|
||||
* Copyright (C) 2015 Daniel Preussker <f0o@devilcode.org>
|
||||
* 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/>. */
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* TinyDNS DNSSec Graph
|
||||
* @author Daniel Preussker <f0o@devilcode.org>
|
||||
* @copyright 2015 f0o, LibreNMS
|
||||
@@ -22,28 +24,31 @@
|
||||
* @subpackage Graphs
|
||||
*/
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
require 'includes/graphs/common.inc.php';
|
||||
|
||||
$i = 0;
|
||||
$scale_min = 0;
|
||||
$nototal = 1;
|
||||
$unit_text = "Query/sec";
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-tinydns-".$app['app_id'].".rrd";
|
||||
//$array = explode(":","hinfo:rp:sig:key:axfr:total");
|
||||
$array = array( "key", "sig" );
|
||||
$colours = "mixed";
|
||||
$rrd_list = array();
|
||||
$unit_text = 'Query/sec';
|
||||
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-tinydns-'.$app['app_id'].'.rrd';
|
||||
// $array = explode(":","hinfo:rp:sig:key:axfr:total");
|
||||
$array = array(
|
||||
'key',
|
||||
'sig',
|
||||
);
|
||||
$colours = 'mixed';
|
||||
$rrd_list = array();
|
||||
|
||||
if( is_file($rrd_filename) ) {
|
||||
foreach( $array as $ds ) {
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = strtoupper($ds);
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
echo "file missing: $file";
|
||||
if (is_file($rrd_filename)) {
|
||||
foreach ($array as $ds) {
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = strtoupper($ds);
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo "file missing: $file";
|
||||
}
|
||||
|
||||
include("includes/graphs/generic_multi_simplex_seperated.inc.php");
|
||||
?>
|
||||
require 'includes/graphs/generic_multi_simplex_seperated.inc.php';
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
<?php
|
||||
/* Copyright (C) 2015 Daniel Preussker <f0o@devilcode.org>
|
||||
/*
|
||||
Copyright (C) 2015 Daniel Preussker <f0o@devilcode.org>
|
||||
* 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/>. */
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* TinyDNS Error Graph
|
||||
* @author Daniel Preussker <f0o@devilcode.org>
|
||||
* @copyright 2015 f0o, LibreNMS
|
||||
@@ -22,27 +24,32 @@
|
||||
* @subpackage Graphs
|
||||
*/
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
require 'includes/graphs/common.inc.php';
|
||||
|
||||
$i = 0;
|
||||
$scale_min = 0;
|
||||
$nototal = 1;
|
||||
$unit_text = "Query/sec";
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-tinydns-".$app['app_id'].".rrd";
|
||||
$array = array( "notauth", "notimpl", "badclass", "noquery" );
|
||||
$colours = "oranges";
|
||||
$unit_text = 'Query/sec';
|
||||
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-tinydns-'.$app['app_id'].'.rrd';
|
||||
$array = array(
|
||||
'notauth',
|
||||
'notimpl',
|
||||
'badclass',
|
||||
'noquery',
|
||||
);
|
||||
$colours = 'oranges';
|
||||
$rrd_list = array();
|
||||
|
||||
if( is_file($rrd_filename) ) {
|
||||
foreach( $array as $ds ) {
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = strtoupper($ds);
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
echo "file missing: $file";
|
||||
if (is_file($rrd_filename)) {
|
||||
foreach ($array as $ds) {
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = strtoupper($ds);
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo "file missing: $file";
|
||||
}
|
||||
|
||||
include("includes/graphs/generic_multi_simplex_seperated.inc.php");
|
||||
?>
|
||||
require 'includes/graphs/generic_multi_simplex_seperated.inc.php';
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
<?php
|
||||
/* Copyright (C) 2015 Daniel Preussker <f0o@devilcode.org>
|
||||
/*
|
||||
Copyright (C) 2015 Daniel Preussker <f0o@devilcode.org>
|
||||
* 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/>. */
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* TinyDNS Other Graph
|
||||
* @author Daniel Preussker <f0o@devilcode.org>
|
||||
* @copyright 2015 f0o, LibreNMS
|
||||
@@ -22,27 +24,32 @@
|
||||
* @subpackage Graphs
|
||||
*/
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
require 'includes/graphs/common.inc.php';
|
||||
|
||||
$i = 0;
|
||||
$scale_min = 0;
|
||||
$nototal = 1;
|
||||
$unit_text = "Query/sec";
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-tinydns-".$app['app_id'].".rrd";
|
||||
$array = array( "other", "hinfo", "rp", "axfr" );
|
||||
$colours = "mixed";
|
||||
$unit_text = 'Query/sec';
|
||||
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-tinydns-'.$app['app_id'].'.rrd';
|
||||
$array = array(
|
||||
'other',
|
||||
'hinfo',
|
||||
'rp',
|
||||
'axfr',
|
||||
);
|
||||
$colours = 'mixed';
|
||||
$rrd_list = array();
|
||||
|
||||
if( is_file($rrd_filename) ) {
|
||||
foreach( $array as $ds ) {
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = strtoupper($ds);
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
echo "file missing: $file";
|
||||
if (is_file($rrd_filename)) {
|
||||
foreach ($array as $ds) {
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = strtoupper($ds);
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo "file missing: $file";
|
||||
}
|
||||
|
||||
include("includes/graphs/generic_multi_simplex_seperated.inc.php");
|
||||
?>
|
||||
require 'includes/graphs/generic_multi_simplex_seperated.inc.php';
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
<?php
|
||||
/* Copyright (C) 2015 Daniel Preussker <f0o@devilcode.org>
|
||||
/*
|
||||
* Copyright (C) 2015 Daniel Preussker <f0o@devilcode.org>
|
||||
* 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/>. */
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* TinyDNS Query Graph
|
||||
* @author Daniel Preussker <f0o@devilcode.org>
|
||||
* @copyright 2015 f0o, LibreNMS
|
||||
@@ -22,30 +24,40 @@
|
||||
* @subpackage Graphs
|
||||
*/
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
require 'includes/graphs/common.inc.php';
|
||||
|
||||
$i = 0;
|
||||
$scale_min = 0;
|
||||
$nototal = 1;
|
||||
$unit_text = "Query/sec";
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-tinydns-".$app['app_id'].".rrd";
|
||||
//$array = explode(":","hinfo:rp:sig:key:axfr:total");
|
||||
$array = array( "any", "a", "aaaa", "cname", "mx", "ns", "ptr", "soa", "txt" );
|
||||
$colours = "merged";
|
||||
$rrd_list = array();
|
||||
$unit_text = 'Query/sec';
|
||||
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/app-tinydns-'.$app['app_id'].'.rrd';
|
||||
// $array = explode(":","hinfo:rp:sig:key:axfr:total");
|
||||
$array = array(
|
||||
'any',
|
||||
'a',
|
||||
'aaaa',
|
||||
'cname',
|
||||
'mx',
|
||||
'ns',
|
||||
'ptr',
|
||||
'soa',
|
||||
'txt',
|
||||
);
|
||||
$colours = 'merged';
|
||||
$rrd_list = array();
|
||||
|
||||
$config['graph_colours']['merged'] = array_merge($config['graph_colours']['greens'], $config['graph_colours']['blues']);
|
||||
|
||||
if( is_file($rrd_filename) ) {
|
||||
foreach( $array as $ds ) {
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = strtoupper($ds);
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
echo "file missing: $file";
|
||||
if (is_file($rrd_filename)) {
|
||||
foreach ($array as $ds) {
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = strtoupper($ds);
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo "file missing: $file";
|
||||
}
|
||||
|
||||
include("includes/graphs/generic_multi_simplex_seperated.inc.php");
|
||||
?>
|
||||
require 'includes/graphs/generic_multi_simplex_seperated.inc.php';
|
||||
|
||||
@@ -1,34 +1,105 @@
|
||||
<?php
|
||||
|
||||
if ($_GET['from']) { $from = mres($_GET['from']); }
|
||||
if ($_GET['to']) { $to = mres($_GET['to']); }
|
||||
if ($_GET['width']) { $width = mres($_GET['width']); }
|
||||
if ($config['trim_tobias']) { $width+=12; }
|
||||
if ($_GET['height']) { $height = mres($_GET['height']); }
|
||||
if ($_GET['inverse']) { $in = 'out'; $out = 'in'; $inverse=TRUE; } else { $in = 'in'; $out = 'out'; }
|
||||
if ($_GET['legend'] == "no") { $rrd_options .= " -g"; }
|
||||
if (isset($_GET['nototal'])) { $nototal = ((bool) $_GET['nototal']); } else { $nototal=true; }
|
||||
if (isset($_GET['nodetails'])) { $nodetails = ((bool) $_GET['nodetails']); } else { $nodetails=false; }
|
||||
if (isset($_GET['noagg'])) { $noagg = ((bool) $_GET['noagg']); } else { $noagg=true; }
|
||||
if ($_GET['title'] == "yes") { $rrd_options .= " --title='".$graph_title."' "; }
|
||||
if (isset($_GET['graph_title'])) { $rrd_options .= " --title='".$_GET['graph_title']."' "; }
|
||||
if ($_GET['from']) {
|
||||
$from = mres($_GET['from']);
|
||||
}
|
||||
|
||||
if (!isset($scale_min) && !isset($scale_max)) { $rrd_options .= " --alt-autoscale-max"; }
|
||||
if (!isset($scale_min) && !isset($scale_max) && !isset($norigid)) { $rrd_options .= " --rigid"; }
|
||||
if (isset($scale_min)) { $rrd_options .= " -l $scale_min"; }
|
||||
if (isset($scale_max)) { $rrd_options .= " -u $scale_max"; }
|
||||
if (isset($scale_rigid)) { $rrd_options .= " -r"; }
|
||||
if ($_GET['to']) {
|
||||
$to = mres($_GET['to']);
|
||||
}
|
||||
|
||||
$rrd_options .= " -E --start ".$from." --end " . $to . " --width ".$width." --height ".$height." ";
|
||||
if ($_GET['width']) {
|
||||
$width = mres($_GET['width']);
|
||||
}
|
||||
|
||||
if ($config['trim_tobias']) {
|
||||
$width += 12;
|
||||
}
|
||||
|
||||
if ($_GET['height']) {
|
||||
$height = mres($_GET['height']);
|
||||
}
|
||||
|
||||
if ($_GET['inverse']) {
|
||||
$in = 'out';
|
||||
$out = 'in';
|
||||
$inverse = true;
|
||||
}
|
||||
else {
|
||||
$in = 'in';
|
||||
$out = 'out';
|
||||
}
|
||||
|
||||
if ($_GET['legend'] == 'no') {
|
||||
$rrd_options .= ' -g';
|
||||
}
|
||||
|
||||
if (isset($_GET['nototal'])) {
|
||||
$nototal = ((bool) $_GET['nototal']);
|
||||
}
|
||||
else {
|
||||
$nototal = true;
|
||||
}
|
||||
|
||||
if (isset($_GET['nodetails'])) {
|
||||
$nodetails = ((bool) $_GET['nodetails']);
|
||||
}
|
||||
else {
|
||||
$nodetails = false;
|
||||
}
|
||||
|
||||
if (isset($_GET['noagg'])) {
|
||||
$noagg = ((bool) $_GET['noagg']);
|
||||
}
|
||||
else {
|
||||
$noagg = true;
|
||||
}
|
||||
|
||||
if ($_GET['title'] == 'yes') {
|
||||
$rrd_options .= " --title='".$graph_title."' ";
|
||||
}
|
||||
|
||||
if (isset($_GET['graph_title'])) {
|
||||
$rrd_options .= " --title='".$_GET['graph_title']."' ";
|
||||
}
|
||||
|
||||
if (!isset($scale_min) && !isset($scale_max)) {
|
||||
$rrd_options .= ' --alt-autoscale-max';
|
||||
}
|
||||
|
||||
if (!isset($scale_min) && !isset($scale_max) && !isset($norigid)) {
|
||||
$rrd_options .= ' --rigid';
|
||||
}
|
||||
|
||||
if (isset($scale_min)) {
|
||||
$rrd_options .= " -l $scale_min";
|
||||
}
|
||||
|
||||
if (isset($scale_max)) {
|
||||
$rrd_options .= " -u $scale_max";
|
||||
}
|
||||
|
||||
if (isset($scale_rigid)) {
|
||||
$rrd_options .= ' -r';
|
||||
}
|
||||
|
||||
$rrd_options .= ' -E --start '.$from.' --end '.$to.' --width '.$width.' --height '.$height.' ';
|
||||
$rrd_options .= $config['rrdgraph_def_text'];
|
||||
|
||||
if ($_GET['bg']) { $rrd_options .= " -c CANVAS#" . mres($_GET['bg']) . " "; }
|
||||
if ($_GET['bg']) {
|
||||
$rrd_options .= ' -c CANVAS#'.mres($_GET['bg']).' ';
|
||||
}
|
||||
|
||||
#$rrd_options .= " -c BACK#FFFFFF";
|
||||
// $rrd_options .= " -c BACK#FFFFFF";
|
||||
if ($height < '99') {
|
||||
$rrd_options .= ' --only-graph';
|
||||
}
|
||||
|
||||
if ($height < "99") { $rrd_options .= " --only-graph"; }
|
||||
if ($width <= '300') {
|
||||
$rrd_options .= ' --font LEGEND:7:'.$config['mono_font'].' --font AXIS:6:'.$config['mono_font'];
|
||||
}
|
||||
else {
|
||||
$rrd_options .= ' --font LEGEND:8:'.$config['mono_font'].' --font AXIS:7:'.$config['mono_font'];
|
||||
}
|
||||
|
||||
if ($width <= "300") { $rrd_options .= " --font LEGEND:7:" . $config['mono_font'] . " --font AXIS:6:" . $config['mono_font']; }
|
||||
else { $rrd_options .= " --font LEGEND:8:" . $config['mono_font'] . " --font AXIS:7:" . $config['mono_font']; }
|
||||
|
||||
$rrd_options .= " --font-render-mode normal";
|
||||
$rrd_options .= ' --font-render-mode normal';
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
<?php
|
||||
|
||||
// FIXME - wtfbbq
|
||||
|
||||
if ($_SESSION['userlevel'] >= "5" || $auth)
|
||||
{
|
||||
$id = mres($vars['id']);
|
||||
$title = generate_device_link($device);
|
||||
$auth = TRUE;
|
||||
if ($_SESSION['userlevel'] >= '5' || $auth) {
|
||||
$id = mres($vars['id']);
|
||||
$title = generate_device_link($device);
|
||||
$auth = true;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,39 +1,35 @@
|
||||
<?php
|
||||
|
||||
// Generate a list of ports and then call the multi_bits grapher to generate from the list
|
||||
$i=0;
|
||||
$i = 0;
|
||||
|
||||
if (!is_array($config['customers_descr'])) {
|
||||
$config['customers_descr'] = array($config['customers_descr']);
|
||||
}
|
||||
$descr_type = "'". implode("', '", $config['customers_descr']) ."'";
|
||||
|
||||
foreach (dbFetchRows("SELECT * FROM `ports` AS I, `devices` AS D WHERE `port_descr_type` IN (?) AND `port_descr_descr` = ? AND D.device_id = I.device_id", array(array($descr_type),$vars['id'])) as $port)
|
||||
{
|
||||
if (is_file($config['rrd_dir'] . "/" . $port['hostname'] . "/port-" . safename($port['ifIndex'] . ".rrd")))
|
||||
{
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $port['hostname'] . "/port-" . safename($port['ifIndex'] . ".rrd");
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = $port['hostname'] ."-". $port['ifDescr'];
|
||||
$rrd_list[$i]['descr_in'] = shorthost($port['hostname']);
|
||||
$rrd_list[$i]['descr_out'] = makeshortif($port['ifDescr']);
|
||||
$i++;
|
||||
}
|
||||
$descr_type = "'".implode("', '", $config['customers_descr'])."'";
|
||||
|
||||
foreach (dbFetchRows('SELECT * FROM `ports` AS I, `devices` AS D WHERE `port_descr_type` IN (?) AND `port_descr_descr` = ? AND D.device_id = I.device_id', array(array($descr_type), $vars['id'])) as $port) {
|
||||
if (is_file($config['rrd_dir'].'/'.$port['hostname'].'/port-'.safename($port['ifIndex'].'.rrd'))) {
|
||||
$rrd_filename = $config['rrd_dir'].'/'.$port['hostname'].'/port-'.safename($port['ifIndex'].'.rrd');
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = $port['hostname'].'-'.$port['ifDescr'];
|
||||
$rrd_list[$i]['descr_in'] = shorthost($port['hostname']);
|
||||
$rrd_list[$i]['descr_out'] = makeshortif($port['ifDescr']);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
#echo($config['rrd_dir'] . "/" . $port['hostname'] . "/port-" . safename($port['ifIndex'] . ".rrd"));
|
||||
|
||||
$units ='bps';
|
||||
$total_units ='B';
|
||||
$colours_in ='greens';
|
||||
$multiplier = "8";
|
||||
// echo($config['rrd_dir'] . "/" . $port['hostname'] . "/port-" . safename($port['ifIndex'] . ".rrd"));
|
||||
$units = 'bps';
|
||||
$total_units = 'B';
|
||||
$colours_in = 'greens';
|
||||
$multiplier = '8';
|
||||
$colours_out = 'blues';
|
||||
|
||||
$nototal = 1;
|
||||
|
||||
$ds_in = "INOCTETS";
|
||||
$ds_out = "OUTOCTETS";
|
||||
$ds_in = 'INOCTETS';
|
||||
$ds_out = 'OUTOCTETS';
|
||||
|
||||
include("includes/graphs/generic_multi_bits_separated.inc.php");
|
||||
|
||||
?>
|
||||
require 'includes/graphs/generic_multi_bits_separated.inc.php';
|
||||
|
||||
@@ -10,23 +10,20 @@
|
||||
* 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.
|
||||
*/
|
||||
*/
|
||||
|
||||
$scale_min = "0";
|
||||
$scale_min = '0';
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
require 'includes/graphs/common.inc.php';
|
||||
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/asa_conns.rrd";
|
||||
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/asa_conns.rrd';
|
||||
|
||||
$rrd_options .= " DEF:connections=$rrd_filename:connections:AVERAGE";
|
||||
$rrd_options .= " DEF:connections_max=$rrd_filename:connections:MAX";
|
||||
$rrd_options .= " DEF:connections_min=$rrd_filename:connections:MIN";
|
||||
$rrd_options .= " AREA:connections_min";
|
||||
$rrd_options .= ' AREA:connections_min';
|
||||
|
||||
$rrd_options .= " LINE1.5:connections#cc0000:'" . rrdtool_escape('Current connections')."'";
|
||||
$rrd_options .= " GPRINT:connections_min:MIN:%4.0lf";
|
||||
$rrd_options .= " GPRINT:connections:LAST:%4.0lf";
|
||||
$rrd_options .= " GPRINT:connections_max:MAX:%4.0lf\\\\l";
|
||||
|
||||
|
||||
?>
|
||||
$rrd_options .= " LINE1.5:connections#cc0000:'".rrdtool_escape('Current connections')."'";
|
||||
$rrd_options .= ' GPRINT:connections_min:MIN:%4.0lf';
|
||||
$rrd_options .= ' GPRINT:connections:LAST:%4.0lf';
|
||||
$rrd_options .= ' GPRINT:connections_max:MAX:%4.0lf\\\\l';
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
<?php
|
||||
|
||||
if ($auth || device_permitted($device['device_id']))
|
||||
{
|
||||
$title = generate_device_link($device);
|
||||
if ($auth || device_permitted($device['device_id'])) {
|
||||
$title = generate_device_link($device);
|
||||
$graph_title = $device['hostname'];
|
||||
$auth = true;
|
||||
$auth = true;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,73 +1,62 @@
|
||||
<?php
|
||||
|
||||
// Generate a list of ports and then call the multi_bits grapher to generate from the list
|
||||
$ds_in = 'INOCTETS';
|
||||
$ds_out = 'OUTOCTETS';
|
||||
|
||||
$ds_in = "INOCTETS";
|
||||
$ds_out = "OUTOCTETS";
|
||||
|
||||
foreach (dbFetchRows("SELECT * FROM `ports` WHERE `device_id` = ?", array($device['device_id'])) as $port)
|
||||
{
|
||||
$ignore = 0;
|
||||
if (is_array($config['device_traffic_iftype']))
|
||||
{
|
||||
foreach ($config['device_traffic_iftype'] as $iftype)
|
||||
{
|
||||
if (preg_match($iftype ."i", $port['ifType']))
|
||||
{
|
||||
$ignore = 1;
|
||||
}
|
||||
foreach (dbFetchRows('SELECT * FROM `ports` WHERE `device_id` = ?', array($device['device_id'])) as $port) {
|
||||
$ignore = 0;
|
||||
if (is_array($config['device_traffic_iftype'])) {
|
||||
foreach ($config['device_traffic_iftype'] as $iftype) {
|
||||
if (preg_match($iftype.'i', $port['ifType'])) {
|
||||
$ignore = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (is_array($config['device_traffic_descr']))
|
||||
{
|
||||
foreach ($config['device_traffic_descr'] as $ifdescr)
|
||||
{
|
||||
if (preg_match($ifdescr."i", $port['ifDescr']) || preg_match($ifdescr."i", $port['ifName']) || preg_match($ifdescr."i", $port['portName']))
|
||||
{
|
||||
$ignore = 1;
|
||||
}
|
||||
|
||||
if (is_array($config['device_traffic_descr'])) {
|
||||
foreach ($config['device_traffic_descr'] as $ifdescr) {
|
||||
if (preg_match($ifdescr.'i', $port['ifDescr']) || preg_match($ifdescr.'i', $port['ifName']) || preg_match($ifdescr.'i', $port['portName'])) {
|
||||
$ignore = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/port-" . safename($port['ifIndex'] . ".rrd");
|
||||
if ($ignore != 1 && is_file($rrd_filename))
|
||||
{
|
||||
$port = ifLabel($port); // Fix Labels! ARGH. This needs to be in the bloody database!
|
||||
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/port-'.safename($port['ifIndex'].'.rrd');
|
||||
if ($ignore != 1 && is_file($rrd_filename)) {
|
||||
$port = ifLabel($port);
|
||||
// Fix Labels! ARGH. This needs to be in the bloody database!
|
||||
$rrd_filenames[] = $rrd_filename;
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = shorten_interface_type($port['label']);
|
||||
$rrd_list[$i]['descr_in'] = $port['label'];
|
||||
$rrd_list[$i]['descr_out'] = $port['ifAlias'];
|
||||
$rrd_list[$i]['ds_in'] = $ds_in;
|
||||
$rrd_list[$i]['ds_out'] = $ds_out;
|
||||
$i++;
|
||||
}
|
||||
|
||||
$rrd_filenames[] = $rrd_filename;
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = shorten_interface_type($port['label']);
|
||||
$rrd_list[$i]['descr_in'] = $port['label'];
|
||||
$rrd_list[$i]['descr_out'] = $port['ifAlias'];
|
||||
$rrd_list[$i]['ds_in'] = $ds_in;
|
||||
$rrd_list[$i]['ds_out'] = $ds_out;
|
||||
$i++;
|
||||
}
|
||||
unset($ignore);
|
||||
}//end foreach
|
||||
|
||||
unset($ignore);
|
||||
}
|
||||
|
||||
$units ='b';
|
||||
$total_units ='B';
|
||||
$colours_in ='greens';
|
||||
$multiplier = "8";
|
||||
$units = 'b';
|
||||
$total_units = 'B';
|
||||
$colours_in = 'greens';
|
||||
$multiplier = '8';
|
||||
$colours_out = 'blues';
|
||||
|
||||
#$nototal = 1;
|
||||
// $nototal = 1;
|
||||
$ds_in = 'INOCTETS';
|
||||
$ds_out = 'OUTOCTETS';
|
||||
|
||||
$ds_in = "INOCTETS";
|
||||
$ds_out = "OUTOCTETS";
|
||||
$graph_title .= '::bits';
|
||||
|
||||
$graph_title .= "::bits";
|
||||
$colour_line_in = '006600';
|
||||
$colour_line_out = '000099';
|
||||
$colour_area_in = '91B13C';
|
||||
$colour_area_out = '8080BD';
|
||||
|
||||
$colour_line_in = "006600";
|
||||
$colour_line_out = "000099";
|
||||
$colour_area_in = "91B13C";
|
||||
$colour_area_out = "8080BD";
|
||||
require 'includes/graphs/generic_multi_seperated.inc.php';
|
||||
|
||||
include("includes/graphs/generic_multi_seperated.inc.php");
|
||||
|
||||
#include("includes/graphs/generic_multi_bits_separated.inc.php");
|
||||
#include("includes/graphs/generic_multi_data_separated.inc.php");
|
||||
|
||||
?>
|
||||
// include("includes/graphs/generic_multi_bits_separated.inc.php");
|
||||
// include("includes/graphs/generic_multi_data_separated.inc.php");
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
<?php
|
||||
|
||||
$class = "charge";
|
||||
$unit = "%%";
|
||||
$unit_long = "Percent";
|
||||
$class = 'charge';
|
||||
$unit = '%%';
|
||||
$unit_long = 'Percent';
|
||||
|
||||
include("includes/graphs/device/sensor.inc.php");
|
||||
|
||||
?>
|
||||
require 'includes/graphs/device/sensor.inc.php';
|
||||
|
||||
@@ -1,85 +1,82 @@
|
||||
<?php
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
require 'includes/graphs/common.inc.php';
|
||||
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/cipsec_flow.rrd";
|
||||
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/cipsec_flow.rrd';
|
||||
|
||||
$i=0;
|
||||
$i = 0;
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = "InAuths";
|
||||
$rrd_list[$i]['ds'] = "InAuths";
|
||||
$rrd_list[$i]['descr'] = 'InAuths';
|
||||
$rrd_list[$i]['ds'] = 'InAuths';
|
||||
$i++;
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = "OutAuths";
|
||||
$rrd_list[$i]['ds'] = "OutAuths";
|
||||
$ds_list[$i]['invert'] = "1";
|
||||
$rrd_list[$i]['descr'] = 'OutAuths';
|
||||
$rrd_list[$i]['ds'] = 'OutAuths';
|
||||
$ds_list[$i]['invert'] = '1';
|
||||
|
||||
$i++;
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = "InDecrypts";
|
||||
$rrd_list[$i]['ds'] = "InDencrypts";
|
||||
$rrd_list[$i]['descr'] = 'InDecrypts';
|
||||
$rrd_list[$i]['ds'] = 'InDencrypts';
|
||||
$i++;
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = "OutEncrypts";
|
||||
$rrd_list[$i]['ds'] = "OutEncrypts";
|
||||
$ds_list[$i]['invert'] = "1";
|
||||
$rrd_list[$i]['descr'] = 'OutEncrypts';
|
||||
$rrd_list[$i]['ds'] = 'OutEncrypts';
|
||||
$ds_list[$i]['invert'] = '1';
|
||||
|
||||
$i++;
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = "InDrops";
|
||||
$rrd_list[$i]['ds'] = "InDrops";
|
||||
$rrd_list[$i]['descr'] = 'InDrops';
|
||||
$rrd_list[$i]['ds'] = 'InDrops';
|
||||
$i++;
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = "InReplayDrops";
|
||||
$rrd_list[$i]['ds'] = "InReplayDrops";
|
||||
$rrd_list[$i]['descr'] = 'InReplayDrops';
|
||||
$rrd_list[$i]['ds'] = 'InReplayDrops';
|
||||
$i++;
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = "OutDrops";
|
||||
$rrd_list[$i]['ds'] = "OutDrops";
|
||||
$ds_list[$i]['invert'] = "1";
|
||||
$rrd_list[$i]['descr'] = 'OutDrops';
|
||||
$rrd_list[$i]['ds'] = 'OutDrops';
|
||||
$ds_list[$i]['invert'] = '1';
|
||||
|
||||
$i++;
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = "InAuthFail";
|
||||
$rrd_list[$i]['ds'] = "InAuthFails";
|
||||
$rrd_list[$i]['descr'] = 'InAuthFail';
|
||||
$rrd_list[$i]['ds'] = 'InAuthFails';
|
||||
$i++;
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = "OutAuthFail";
|
||||
$rrd_list[$i]['ds'] = "OutAuthFails";
|
||||
$ds_list[$i]['invert'] = "1";
|
||||
$rrd_list[$i]['descr'] = 'OutAuthFail';
|
||||
$rrd_list[$i]['ds'] = 'OutAuthFails';
|
||||
$ds_list[$i]['invert'] = '1';
|
||||
|
||||
$i++;
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = "InDecryptFails";
|
||||
$rrd_list[$i]['ds'] = "InDecryptFails";
|
||||
$rrd_list[$i]['descr'] = 'InDecryptFails';
|
||||
$rrd_list[$i]['ds'] = 'InDecryptFails';
|
||||
$i++;
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = "OutEncryptFails";
|
||||
$rrd_list[$i]['ds'] = "OutEncryptFails";
|
||||
$ds_list[$i]['invert'] = "1";
|
||||
$rrd_list[$i]['descr'] = 'OutEncryptFails';
|
||||
$rrd_list[$i]['ds'] = 'OutEncryptFails';
|
||||
$ds_list[$i]['invert'] = '1';
|
||||
|
||||
$i++;
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = "ProtocolUseFails";
|
||||
$rrd_list[$i]['ds'] = "ProtocolUseFails";
|
||||
$rrd_list[$i]['descr'] = 'ProtocolUseFails';
|
||||
$rrd_list[$i]['ds'] = 'ProtocolUseFails';
|
||||
$i++;
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = "NoSaFails";
|
||||
$rrd_list[$i]['ds'] = "NoSaFails";
|
||||
$rrd_list[$i]['descr'] = 'NoSaFails';
|
||||
$rrd_list[$i]['ds'] = 'NoSaFails';
|
||||
$i++;
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = "SysCapFails";
|
||||
$rrd_list[$i]['ds'] = "SysCapFails";
|
||||
$rrd_list[$i]['descr'] = 'SysCapFails';
|
||||
$rrd_list[$i]['ds'] = 'SysCapFails';
|
||||
|
||||
#$units='%';
|
||||
#$total_units='%';
|
||||
$colours='mixed';
|
||||
|
||||
$scale_min = "0";
|
||||
#$scale_max = "100";
|
||||
// $units='%';
|
||||
// $total_units='%';
|
||||
$colours = 'mixed';
|
||||
|
||||
$scale_min = '0';
|
||||
// $scale_max = "100";
|
||||
$nototal = 1;
|
||||
|
||||
include("includes/graphs/generic_multi_line.inc.php");
|
||||
|
||||
?>
|
||||
require 'includes/graphs/generic_multi_line.inc.php';
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php // vim:fenc=utf-8:filetype=php:ts=4
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2009 Bruno Prémont <bonbons AT linux-vserver.org>
|
||||
*
|
||||
@@ -16,27 +17,32 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
require('includes/collectd/config.php');
|
||||
require('includes/collectd/functions.php');
|
||||
require('includes/collectd/definitions.php');
|
||||
require 'includes/collectd/config.php';
|
||||
require 'includes/collectd/functions.php';
|
||||
require 'includes/collectd/definitions.php';
|
||||
|
||||
|
||||
function makeTextBlock($text, $fontfile, $fontsize, $width) {
|
||||
// TODO: handle explicit line-break!
|
||||
$words = explode(' ', $text);
|
||||
$lines = array($words[0]);
|
||||
$currentLine = 0;
|
||||
foreach ($words as $word) {
|
||||
$lineSize = imagettfbbox($fontsize, 0, $fontfile, $lines[$currentLine] . ' ' . $word);
|
||||
if ($lineSize[2] - $lineSize[0] < $width) {
|
||||
$lines[$currentLine] .= ' ' . $word;
|
||||
} else {
|
||||
$currentLine++;
|
||||
$lines[$currentLine] = $word;
|
||||
// TODO: handle explicit line-break!
|
||||
$words = explode(' ', $text);
|
||||
$lines = array($words[0]);
|
||||
$currentLine = 0;
|
||||
foreach ($words as $word) {
|
||||
$lineSize = imagettfbbox($fontsize, 0, $fontfile, $lines[$currentLine].' '.$word);
|
||||
if (($lineSize[2] - $lineSize[0]) < $width) {
|
||||
$lines[$currentLine] .= ' '.$word;
|
||||
}
|
||||
else {
|
||||
$currentLine++;
|
||||
$lines[$currentLine] = $word;
|
||||
}
|
||||
}
|
||||
}
|
||||
error_log(sprintf('Handles message "%s", %d words => %d/%d lines', $text, count($words), $currentLine, count($lines)));
|
||||
return implode("\n", $lines);
|
||||
}
|
||||
|
||||
error_log(sprintf('Handles message "%s", %d words => %d/%d lines', $text, count($words), $currentLine, count($lines)));
|
||||
return implode("\n", $lines);
|
||||
|
||||
}//end makeTextBlock()
|
||||
|
||||
|
||||
/**
|
||||
* No RRD files found that could match request
|
||||
@@ -46,124 +52,150 @@ function makeTextBlock($text, $fontfile, $fontsize, $width) {
|
||||
* @msg Complete error message to display in place of graph content
|
||||
*/
|
||||
function error($code, $code_msg, $title, $msg) {
|
||||
global $config;
|
||||
global $config;
|
||||
|
||||
header(sprintf("HTTP/1.0 %d %s", $code, $code_msg));
|
||||
header("Pragma: no-cache");
|
||||
header("Expires: Mon, 01 Jan 2008 00:00:00 CET");
|
||||
header("Content-Type: image/png");
|
||||
$w = $config['rrd_width']+81;
|
||||
$h = $config['rrd_height']+79;
|
||||
header(sprintf('HTTP/1.0 %d %s', $code, $code_msg));
|
||||
header('Pragma: no-cache');
|
||||
header('Expires: Mon, 01 Jan 2008 00:00:00 CET');
|
||||
header('Content-Type: image/png');
|
||||
$w = ($config['rrd_width'] + 81);
|
||||
$h = ($config['rrd_height'] + 79);
|
||||
|
||||
$png = imagecreate($w, $h);
|
||||
$c_bkgnd = imagecolorallocate($png, 240, 240, 240);
|
||||
$c_fgnd = imagecolorallocate($png, 255, 255, 255);
|
||||
$c_blt = imagecolorallocate($png, 208, 208, 208);
|
||||
$c_brb = imagecolorallocate($png, 160, 160, 160);
|
||||
$c_grln = imagecolorallocate($png, 114, 114, 114);
|
||||
$c_grarr = imagecolorallocate($png, 128, 32, 32);
|
||||
$c_txt = imagecolorallocate($png, 0, 0, 0);
|
||||
$c_etxt = imagecolorallocate($png, 64, 0, 0);
|
||||
$png = imagecreate($w, $h);
|
||||
$c_bkgnd = imagecolorallocate($png, 240, 240, 240);
|
||||
$c_fgnd = imagecolorallocate($png, 255, 255, 255);
|
||||
$c_blt = imagecolorallocate($png, 208, 208, 208);
|
||||
$c_brb = imagecolorallocate($png, 160, 160, 160);
|
||||
$c_grln = imagecolorallocate($png, 114, 114, 114);
|
||||
$c_grarr = imagecolorallocate($png, 128, 32, 32);
|
||||
$c_txt = imagecolorallocate($png, 0, 0, 0);
|
||||
$c_etxt = imagecolorallocate($png, 64, 0, 0);
|
||||
|
||||
if (function_exists('imageantialias'))
|
||||
imageantialias($png, true);
|
||||
imagefilledrectangle($png, 0, 0, $w, $h, $c_bkgnd);
|
||||
imagefilledrectangle($png, 51, 33, $w-31, $h-47, $c_fgnd);
|
||||
imageline($png, 51, 30, 51, $h-43, $c_grln);
|
||||
imageline($png, 48, $h-46, $w-28, $h-46, $c_grln);
|
||||
imagefilledpolygon($png, array(49, 30, 51, 26, 53, 30), 3, $c_grarr);
|
||||
imagefilledpolygon($png, array($w-28, $h-48, $w-24, $h-46, $w-28, $h-44), 3, $c_grarr);
|
||||
imageline($png, 0, 0, $w, 0, $c_blt);
|
||||
imageline($png, 0, 1, $w, 1, $c_blt);
|
||||
imageline($png, 0, 0, 0, $h, $c_blt);
|
||||
imageline($png, 1, 0, 1, $h, $c_blt);
|
||||
imageline($png, $w-1, 0, $w-1, $h, $c_brb);
|
||||
imageline($png, $w-2, 1, $w-2, $h, $c_brb);
|
||||
imageline($png, 1, $h-2, $w, $h-2, $c_brb);
|
||||
imageline($png, 0, $h-1, $w, $h-1, $c_brb);
|
||||
if (function_exists('imageantialias')) {
|
||||
imageantialias($png, true);
|
||||
}
|
||||
|
||||
imagestring($png, 4, ceil(($w-strlen($title)*imagefontwidth(4)) / 2), 10, $title, $c_txt);
|
||||
imagestring($png, 5, 60, 35, sprintf('%s [%d]', $code_msg, $code), $c_etxt);
|
||||
if (function_exists('imagettfbbox') && is_file($config['error_font'])) {
|
||||
// Detailled error message
|
||||
$fmt_msg = makeTextBlock($msg, $errorfont, 10, $w-86);
|
||||
$fmtbox = imagettfbbox(12, 0, $errorfont, $fmt_msg);
|
||||
imagettftext($png, 10, 0, 55, 35+3+imagefontwidth(5)-$fmtbox[7]+$fmtbox[1], $c_txt, $errorfont, $fmt_msg);
|
||||
} else {
|
||||
imagestring($png, 4, 53, 35+6+imagefontwidth(5), $msg, $c_txt);
|
||||
}
|
||||
imagefilledrectangle($png, 0, 0, $w, $h, $c_bkgnd);
|
||||
imagefilledrectangle($png, 51, 33, ($w - 31), ($h - 47), $c_fgnd);
|
||||
imageline($png, 51, 30, 51, ($h - 43), $c_grln);
|
||||
imageline($png, 48, ($h - 46), ($w - 28), ($h - 46), $c_grln);
|
||||
imagefilledpolygon($png, array(49, 30, 51, 26, 53, 30), 3, $c_grarr);
|
||||
imagefilledpolygon($png, array($w - 28, $h - 48, $w - 24, $h - 46, $w - 28, $h - 44), 3, $c_grarr);
|
||||
imageline($png, 0, 0, $w, 0, $c_blt);
|
||||
imageline($png, 0, 1, $w, 1, $c_blt);
|
||||
imageline($png, 0, 0, 0, $h, $c_blt);
|
||||
imageline($png, 1, 0, 1, $h, $c_blt);
|
||||
imageline($png, ($w - 1), 0, ($w - 1), $h, $c_brb);
|
||||
imageline($png, ($w - 2), 1, ($w - 2), $h, $c_brb);
|
||||
imageline($png, 1, ($h - 2), $w, ($h - 2), $c_brb);
|
||||
imageline($png, 0, ($h - 1), $w, ($h - 1), $c_brb);
|
||||
|
||||
imagestring($png, 4, ceil(($w - strlen($title) * imagefontwidth(4)) / 2), 10, $title, $c_txt);
|
||||
imagestring($png, 5, 60, 35, sprintf('%s [%d]', $code_msg, $code), $c_etxt);
|
||||
if (function_exists('imagettfbbox') && is_file($config['error_font'])) {
|
||||
// Detailled error message
|
||||
$fmt_msg = makeTextBlock($msg, $errorfont, 10, ($w - 86));
|
||||
$fmtbox = imagettfbbox(12, 0, $errorfont, $fmt_msg);
|
||||
imagettftext($png, 10, 0, 55, (35 + 3 + imagefontwidth(5) - $fmtbox[7] + $fmtbox[1]), $c_txt, $errorfont, $fmt_msg);
|
||||
}
|
||||
else {
|
||||
imagestring($png, 4, 53, (35 + 6 + imagefontwidth(5)), $msg, $c_txt);
|
||||
}
|
||||
|
||||
imagepng($png);
|
||||
imagedestroy($png);
|
||||
|
||||
}//end error()
|
||||
|
||||
imagepng($png);
|
||||
imagedestroy($png);
|
||||
}
|
||||
|
||||
/**
|
||||
* No RRD files found that could match request
|
||||
*/
|
||||
function error404($title, $msg) {
|
||||
return error(404, "Not found", $title, $msg);
|
||||
}
|
||||
return error(404, 'Not found', $title, $msg);
|
||||
|
||||
}//end error404()
|
||||
|
||||
|
||||
function error500($title, $msg) {
|
||||
return error(500, "Not found", $title, $msg);
|
||||
}
|
||||
return error(500, 'Not found', $title, $msg);
|
||||
|
||||
}//end error500()
|
||||
|
||||
|
||||
/**
|
||||
* Incomplete / invalid request
|
||||
*/
|
||||
function error400($title, $msg) {
|
||||
return error(400, "Bad request", $title, $msg);
|
||||
}
|
||||
return error(400, 'Bad request', $title, $msg);
|
||||
|
||||
}//end error400()
|
||||
|
||||
|
||||
// Process input arguments
|
||||
#$host = read_var('host', $_GET, null);
|
||||
$host = $device['hostname'];
|
||||
if (is_null($host))
|
||||
return error400("?/?-?/?", "Missing host name");
|
||||
else if (!is_string($host))
|
||||
return error400("?/?-?/?", "Expecting exactly 1 host name");
|
||||
else if (strlen($host) == 0)
|
||||
return error400("?/?-?/?", "Host name may not be blank");
|
||||
// $host = read_var('host', $_GET, null);
|
||||
$host = $device['hostname'];
|
||||
if (is_null($host)) {
|
||||
return error400('?/?-?/?', 'Missing host name');
|
||||
}
|
||||
else if (!is_string($host)) {
|
||||
return error400('?/?-?/?', 'Expecting exactly 1 host name');
|
||||
}
|
||||
else if (strlen($host) == 0) {
|
||||
return error400('?/?-?/?', 'Host name may not be blank');
|
||||
}
|
||||
|
||||
$plugin = read_var('c_plugin', $_GET, null);
|
||||
if (is_null($plugin))
|
||||
return error400($host.'/?-?/?', "Missing plugin name");
|
||||
else if (!is_string($plugin))
|
||||
return error400($host.'/?-?/?', "Plugin name must be a string");
|
||||
else if (strlen($plugin) == 0)
|
||||
return error400($host.'/?-?/?', "Plugin name may not be blank");
|
||||
$plugin = read_var('c_plugin', $_GET, null);
|
||||
if (is_null($plugin)) {
|
||||
return error400($host.'/?-?/?', 'Missing plugin name');
|
||||
}
|
||||
else if (!is_string($plugin)) {
|
||||
return error400($host.'/?-?/?', 'Plugin name must be a string');
|
||||
}
|
||||
else if (strlen($plugin) == 0) {
|
||||
return error400($host.'/?-?/?', 'Plugin name may not be blank');
|
||||
}
|
||||
|
||||
$pinst = read_var('c_plugin_instance', $_GET, '');
|
||||
if (!is_string($pinst))
|
||||
return error400($host.'/'.$plugin.'-?/?', "Plugin instance name must be a string");
|
||||
$pinst = read_var('c_plugin_instance', $_GET, '');
|
||||
if (!is_string($pinst)) {
|
||||
return error400($host.'/'.$plugin.'-?/?', 'Plugin instance name must be a string');
|
||||
}
|
||||
|
||||
$type = read_var('c_type', $_GET, '');
|
||||
if (is_null($type))
|
||||
return error400($host.'/'.$plugin.(strlen($pinst) ? '-'.$pinst : '').'/?', "Missing type name");
|
||||
else if (!is_string($type))
|
||||
return error400($host.'/'.$plugin.(strlen($pinst) ? '-'.$pinst : '').'/?', "Type name must be a string");
|
||||
else if (strlen($type) == 0)
|
||||
return error400($host.'/'.$plugin.(strlen($pinst) ? '-'.$pinst : '').'/?', "Type name may not be blank");
|
||||
$type = read_var('c_type', $_GET, '');
|
||||
if (is_null($type)) {
|
||||
return error400($host.'/'.$plugin.(strlen($pinst) ? '-'.$pinst : '').'/?', 'Missing type name');
|
||||
}
|
||||
else if (!is_string($type)) {
|
||||
return error400($host.'/'.$plugin.(strlen($pinst) ? '-'.$pinst : '').'/?', 'Type name must be a string');
|
||||
}
|
||||
else if (strlen($type) == 0) {
|
||||
return error400($host.'/'.$plugin.(strlen($pinst) ? '-'.$pinst : '').'/?', 'Type name may not be blank');
|
||||
}
|
||||
|
||||
$tinst = read_var('c_type_instance', $_GET, '');
|
||||
$tinst = read_var('c_type_instance', $_GET, '');
|
||||
|
||||
$graph_identifier = $host.'/'.$plugin.(strlen($pinst) ? '-'.$pinst : '').'/'.$type.(strlen($tinst) ? '-'.$tinst : '-*');
|
||||
|
||||
$timespan = read_var('timespan', $_GET, $config['timespan'][0]['name']);
|
||||
$timespan = read_var('timespan', $_GET, $config['timespan'][0]['name']);
|
||||
$timespan_ok = false;
|
||||
foreach ($config['timespan'] as &$ts)
|
||||
if ($ts['name'] == $timespan)
|
||||
$timespan_ok = true;
|
||||
if (!$timespan_ok)
|
||||
return error400($graph_identifier, "Unknown timespan requested");
|
||||
foreach ($config['timespan'] as &$ts) {
|
||||
if ($ts['name'] == $timespan) {
|
||||
$timespan_ok = true;
|
||||
}
|
||||
}
|
||||
|
||||
$logscale = (boolean)read_var('logarithmic', $_GET, false);
|
||||
$tinylegend = (boolean)read_var('tinylegend', $_GET, false);
|
||||
if (!$timespan_ok) {
|
||||
return error400($graph_identifier, 'Unknown timespan requested');
|
||||
}
|
||||
|
||||
$logscale = (boolean) read_var('logarithmic', $_GET, false);
|
||||
$tinylegend = (boolean) read_var('tinylegend', $_GET, false);
|
||||
|
||||
// Check that at least 1 RRD exists for the specified request
|
||||
$all_tinst = collectd_list_tinsts($host, $plugin, $pinst, $type);
|
||||
if (count($all_tinst) == 0)
|
||||
return error404($graph_identifier, "No rrd file found for graphing");
|
||||
if (count($all_tinst) == 0) {
|
||||
return error404($graph_identifier, 'No rrd file found for graphing');
|
||||
}
|
||||
|
||||
// Now that we are read, do the bulk work
|
||||
load_graph_definitions($logscale, $tinylegend);
|
||||
@@ -171,57 +203,83 @@ load_graph_definitions($logscale, $tinylegend);
|
||||
$pinst = strlen($pinst) == 0 ? null : $pinst;
|
||||
$tinst = strlen($tinst) == 0 ? null : $tinst;
|
||||
|
||||
$opts = array();
|
||||
$opts = array();
|
||||
$opts['timespan'] = $timespan;
|
||||
if ($logscale)
|
||||
$opts['logarithmic'] = 1;
|
||||
if ($tinylegend)
|
||||
$opts['tinylegend'] = 1;
|
||||
if ($logscale) {
|
||||
$opts['logarithmic'] = 1;
|
||||
}
|
||||
|
||||
if ($tinylegend) {
|
||||
$opts['tinylegend'] = 1;
|
||||
}
|
||||
|
||||
$rrd_cmd = false;
|
||||
if (isset($MetaGraphDefs[$type])) {
|
||||
$identifiers = array();
|
||||
foreach ($all_tinst as &$atinst)
|
||||
$identifiers[] = collectd_identifier($host, $plugin, is_null($pinst) ? '' : $pinst, $type, $atinst);
|
||||
collectd_flush($identifiers);
|
||||
$rrd_cmd = $MetaGraphDefs[$type]($host, $plugin, $pinst, $type, $all_tinst, $opts);
|
||||
} else {
|
||||
if (!in_array(is_null($tinst) ? '' : $tinst, $all_tinst))
|
||||
return error404($host.'/'.$plugin.(!is_null($pinst) ? '-'.$pinst : '').'/'.$type.(!is_null($tinst) ? '-'.$tinst : ''), "No rrd file found for graphing");
|
||||
collectd_flush(collectd_identifier($host, $plugin, is_null($pinst) ? '' : $pinst, $type, is_null($tinst) ? '' : $tinst));
|
||||
if (isset($GraphDefs[$type]))
|
||||
$rrd_cmd = collectd_draw_generic($timespan, $host, $plugin, $pinst, $type, $tinst);
|
||||
else
|
||||
$rrd_cmd = collectd_draw_rrd($host, $plugin, $pinst, $type, $tinst);
|
||||
$identifiers = array();
|
||||
foreach ($all_tinst as &$atinst) {
|
||||
$identifiers[] = collectd_identifier($host, $plugin, is_null($pinst) ? '' : $pinst, $type, $atinst);
|
||||
}
|
||||
|
||||
collectd_flush($identifiers);
|
||||
$rrd_cmd = $MetaGraphDefs[$type]($host, $plugin, $pinst, $type, $all_tinst, $opts);
|
||||
}
|
||||
else {
|
||||
if (!in_array(is_null($tinst) ? '' : $tinst, $all_tinst)) {
|
||||
return error404($host.'/'.$plugin.(!is_null($pinst) ? '-'.$pinst : '').'/'.$type.(!is_null($tinst) ? '-'.$tinst : ''), 'No rrd file found for graphing');
|
||||
}
|
||||
|
||||
collectd_flush(collectd_identifier($host, $plugin, is_null($pinst) ? '' : $pinst, $type, is_null($tinst) ? '' : $tinst));
|
||||
if (isset($GraphDefs[$type])) {
|
||||
$rrd_cmd = collectd_draw_generic($timespan, $host, $plugin, $pinst, $type, $tinst);
|
||||
}
|
||||
else {
|
||||
$rrd_cmd = collectd_draw_rrd($host, $plugin, $pinst, $type, $tinst);
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($rrd_cmd))
|
||||
{
|
||||
if ($_GET['from']) { $from = mres($_GET['from']); }
|
||||
if ($_GET['to']) { $to = mres($_GET['to']); }
|
||||
$rrd_cmd .= " -s " . $from . " -e " . $to;
|
||||
if (isset($rrd_cmd)) {
|
||||
if ($_GET['from']) {
|
||||
$from = mres($_GET['from']);
|
||||
}
|
||||
|
||||
if ($_GET['to']) {
|
||||
$to = mres($_GET['to']);
|
||||
}
|
||||
|
||||
$rrd_cmd .= ' -s '.$from.' -e '.$to;
|
||||
}
|
||||
|
||||
if ($_GET['legend'] == "no") { $rrd_cmd .= " -g "; }
|
||||
if ($_GET['legend'] == 'no') {
|
||||
$rrd_cmd .= ' -g ';
|
||||
}
|
||||
|
||||
if ($height < "99") { $rrd_cmd .= " --only-graph "; }
|
||||
if ($width <= "300") { $rrd_cmd .= " --font LEGEND:7:" . $config['mono_font'] . " --font AXIS:6:" . $config['mono_font'] . " "; }
|
||||
else { $rrd_cmd .= " --font LEGEND:8:" . $config['mono_font'] . " --font AXIS:7:" . $config['mono_font'] . " "; }
|
||||
if ($height < '99') {
|
||||
$rrd_cmd .= ' --only-graph ';
|
||||
}
|
||||
|
||||
if ($width <= '300') {
|
||||
$rrd_cmd .= ' --font LEGEND:7:'.$config['mono_font'].' --font AXIS:6:'.$config['mono_font'].' ';
|
||||
}
|
||||
else {
|
||||
$rrd_cmd .= ' --font LEGEND:8:'.$config['mono_font'].' --font AXIS:7:'.$config['mono_font'].' ';
|
||||
}
|
||||
|
||||
if (isset($_GET['debug'])) {
|
||||
header('Content-Type: text/plain; charset=utf-8');
|
||||
printf("Would have executed:\n%s\n", $rrd_cmd);
|
||||
return 0;
|
||||
} else if ($rrd_cmd) {
|
||||
header('Content-Type: image/png');
|
||||
header('Cache-Control: max-age=60');
|
||||
$rt = 0;
|
||||
passthru($rrd_cmd, $rt);
|
||||
if ($rt != 0)
|
||||
return error500($graph_identifier, "RRD failed to generate the graph: ".$rt);
|
||||
return $rt;
|
||||
} else {
|
||||
return error500($graph_identifier, "Failed to tell RRD how to generate the graph");
|
||||
header('Content-Type: text/plain; charset=utf-8');
|
||||
printf("Would have executed:\n%s\n", $rrd_cmd);
|
||||
return 0;
|
||||
}
|
||||
else if ($rrd_cmd) {
|
||||
header('Content-Type: image/png');
|
||||
header('Cache-Control: max-age=60');
|
||||
$rt = 0;
|
||||
passthru($rrd_cmd, $rt);
|
||||
if ($rt != 0) {
|
||||
return error500($graph_identifier, 'RRD failed to generate the graph: '.$rt);
|
||||
}
|
||||
|
||||
?>
|
||||
return $rt;
|
||||
}
|
||||
else {
|
||||
return error500($graph_identifier, 'Failed to tell RRD how to generate the graph');
|
||||
}
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
<?php
|
||||
|
||||
$units ='bps';
|
||||
$total_units ='B';
|
||||
$colours_in ='greens';
|
||||
$multiplier = "8";
|
||||
$units = 'bps';
|
||||
$total_units = 'B';
|
||||
$colours_in = 'greens';
|
||||
$multiplier = '8';
|
||||
$colours_out = 'blues';
|
||||
|
||||
$nototal = 1;
|
||||
$ds_in = "read";
|
||||
$ds_out = "written";
|
||||
$ds_in = 'read';
|
||||
$ds_out = 'written';
|
||||
|
||||
include("includes/graphs/device/diskio_common.inc.php");
|
||||
require 'includes/graphs/device/diskio_common.inc.php';
|
||||
|
||||
include("includes/graphs/generic_multi_bits_separated.inc.php");
|
||||
|
||||
?>
|
||||
require 'includes/graphs/generic_multi_bits_separated.inc.php';
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
<?php
|
||||
|
||||
$units = '';
|
||||
$units = '';
|
||||
$units_descr = 'Operations/sec';
|
||||
$total_units = 'B';
|
||||
$colours_in = 'greens';
|
||||
$multiplier = "1";
|
||||
$colours_in = 'greens';
|
||||
$multiplier = '1';
|
||||
$colours_out = 'blues';
|
||||
|
||||
$ds_in = "reads";
|
||||
$ds_out = "writes";
|
||||
$ds_in = 'reads';
|
||||
$ds_out = 'writes';
|
||||
|
||||
$nototal = 1;
|
||||
|
||||
include("includes/graphs/device/diskio_common.inc.php");
|
||||
require 'includes/graphs/device/diskio_common.inc.php';
|
||||
|
||||
include("includes/graphs/generic_multi_seperated.inc.php");
|
||||
|
||||
?>
|
||||
require 'includes/graphs/generic_multi_seperated.inc.php';
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
<?php
|
||||
|
||||
$scale_min = "0";
|
||||
$scale_min = '0';
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
require 'includes/graphs/common.inc.php';
|
||||
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/fdb_count.rrd";
|
||||
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/fdb_count.rrd';
|
||||
|
||||
$rrd_options .= " DEF:value=$rrd_filename:value:AVERAGE";
|
||||
$rrd_options .= " DEF:value_min=$rrd_filename:value:MIN";
|
||||
$rrd_options .= " DEF:value_max=$rrd_filename:value:MAX";
|
||||
|
||||
$rrd_options .= " COMMENT:'MACs Current Minimum Maximum Average\\n'";
|
||||
$rrd_options .= " AREA:value#EEEEEE:value";
|
||||
$rrd_options .= " LINE1.25:value#36393D:";
|
||||
$rrd_options .= ' AREA:value#EEEEEE:value';
|
||||
$rrd_options .= ' LINE1.25:value#36393D:';
|
||||
$rrd_options .= " 'GPRINT:value:LAST:%6.2lf ' 'GPRINT:value_min:MIN:%6.2lf '";
|
||||
$rrd_options .= " 'GPRINT:value_max:MAX:%6.2lf ' 'GPRINT:value:AVERAGE:%6.2lf\\n'";
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
<?php
|
||||
|
||||
$class = "load";
|
||||
$unit = "%%";
|
||||
$unit_long = "Load";
|
||||
$class = 'load';
|
||||
$unit = '%%';
|
||||
$unit_long = 'Load';
|
||||
|
||||
include("includes/graphs/device/sensor.inc.php");
|
||||
|
||||
?>
|
||||
require 'includes/graphs/device/sensor.inc.php';
|
||||
|
||||
@@ -13,24 +13,25 @@
|
||||
*/
|
||||
|
||||
$rrd_list = array();
|
||||
$prefix = rrd_name($device['hostname'], array($subtype, ""), "");
|
||||
foreach (glob($prefix."*.rrd") as $filename) {
|
||||
$prefix = rrd_name($device['hostname'], array($subtype, ''), '');
|
||||
foreach (glob($prefix.'*.rrd') as $filename) {
|
||||
// find out what * expanded to
|
||||
$globpart = str_replace($prefix, '', $filename); // take off the prefix
|
||||
$instance = substr($globpart, 0, -4); // take off ".rrd"
|
||||
|
||||
$ds = array();
|
||||
$mibparts = explode("-", $subtype);
|
||||
$mibvar = end($mibparts);
|
||||
$ds['ds'] = name_shorten($mibvar);
|
||||
$ds['descr'] = "$mibvar-$instance";
|
||||
$globpart = str_replace($prefix, '', $filename);
|
||||
// take off the prefix
|
||||
$instance = substr($globpart, 0, -4);
|
||||
// take off ".rrd"
|
||||
$ds = array();
|
||||
$mibparts = explode('-', $subtype);
|
||||
$mibvar = end($mibparts);
|
||||
$ds['ds'] = name_shorten($mibvar);
|
||||
$ds['descr'] = "$mibvar-$instance";
|
||||
$ds['filename'] = $filename;
|
||||
$rrd_list[] = $ds;
|
||||
$rrd_list[] = $ds;
|
||||
}
|
||||
|
||||
$colours = 'mixed';
|
||||
$scale_min = "0";
|
||||
$scale_min = '0';
|
||||
$nototal = 0;
|
||||
$simple_rrd = true;
|
||||
|
||||
include("includes/graphs/generic_multi_line.inc.php");
|
||||
require 'includes/graphs/generic_multi_line.inc.php';
|
||||
|
||||
@@ -1,23 +1,21 @@
|
||||
<?php
|
||||
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/netstats-ip_forward.rrd";
|
||||
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/netstats-ip_forward.rrd';
|
||||
|
||||
$stats = array('ipCidrRouteNumber' => array());
|
||||
|
||||
$i=0;
|
||||
foreach ($stats as $stat => $array)
|
||||
{
|
||||
$i++;
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = str_replace("ip", "", $stat);
|
||||
$rrd_list[$i]['ds'] = $stat;
|
||||
$i = 0;
|
||||
foreach ($stats as $stat => $array) {
|
||||
$i++;
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = str_replace('ip', '', $stat);
|
||||
$rrd_list[$i]['ds'] = $stat;
|
||||
}
|
||||
|
||||
$colours='mixed';
|
||||
$colours = 'mixed';
|
||||
|
||||
$scale_min = "0";
|
||||
$nototal = 1;
|
||||
$simple_rrd = TRUE;
|
||||
|
||||
include("includes/graphs/generic_multi_line.inc.php");
|
||||
$scale_min = '0';
|
||||
$nototal = 1;
|
||||
$simple_rrd = true;
|
||||
|
||||
require 'includes/graphs/generic_multi_line.inc.php';
|
||||
|
||||
@@ -12,16 +12,14 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
$scale_min = "0";
|
||||
$scale_min = '0';
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
require 'includes/graphs/common.inc.php';
|
||||
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/ping-perf.rrd";
|
||||
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/ping-perf.rrd';
|
||||
|
||||
$rrd_options .= " DEF:ping=".$rrd_filename.":ping:AVERAGE";
|
||||
$rrd_options .= ' DEF:ping='.$rrd_filename.':ping:AVERAGE';
|
||||
$rrd_options .= " 'COMMENT:Seconds Current Minimum Maximum Average\\n'";
|
||||
$rrd_options .= " LINE1.25:ping#36393D:Ping";
|
||||
$rrd_options .= " GPRINT:ping:LAST:%6.2lf GPRINT:ping:AVERAGE:%6.2lf";
|
||||
$rrd_options .= ' LINE1.25:ping#36393D:Ping';
|
||||
$rrd_options .= ' GPRINT:ping:LAST:%6.2lf GPRINT:ping:AVERAGE:%6.2lf';
|
||||
$rrd_options .= " GPRINT:ping:MAX:%6.2lf 'GPRINT:ping:AVERAGE:%6.2lf\\n'";
|
||||
|
||||
?>
|
||||
|
||||
@@ -12,16 +12,14 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
$scale_min = "0";
|
||||
$scale_min = '0';
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
require 'includes/graphs/common.inc.php';
|
||||
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/poller-perf.rrd";
|
||||
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/poller-perf.rrd';
|
||||
|
||||
$rrd_options .= " DEF:poller=".$rrd_filename.":poller:AVERAGE";
|
||||
$rrd_options .= ' DEF:poller='.$rrd_filename.':poller:AVERAGE';
|
||||
$rrd_options .= " 'COMMENT:Seconds Current Minimum Maximum Average\\n'";
|
||||
$rrd_options .= " LINE1.25:poller#36393D:Poller";
|
||||
$rrd_options .= " GPRINT:poller:LAST:%6.2lf GPRINT:poller:AVERAGE:%6.2lf";
|
||||
$rrd_options .= ' LINE1.25:poller#36393D:Poller';
|
||||
$rrd_options .= ' GPRINT:poller:LAST:%6.2lf GPRINT:poller:AVERAGE:%6.2lf';
|
||||
$rrd_options .= " GPRINT:poller:MAX:%6.2lf 'GPRINT:poller:AVERAGE:%6.2lf\\n'";
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,51 +1,58 @@
|
||||
<?php
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
require 'includes/graphs/common.inc.php';
|
||||
|
||||
if ($_GET['width'] > "300") { $descr_len = "40"; } else { $descr_len = "22"; }
|
||||
|
||||
$rrd_options .= " -E ";
|
||||
$iter = "1";
|
||||
$rrd_options .= " COMMENT:'".str_pad($unit_long,$descr_len)." Cur Min Max\\n'";
|
||||
|
||||
foreach (dbFetchRows("SELECT * FROM `sensors` WHERE `sensor_class` = ? AND `device_id` = ? ORDER BY `sensor_index`", array($class, $device['device_id'])) as $sensor)
|
||||
{
|
||||
// FIXME generic colour function
|
||||
switch ($iter)
|
||||
{
|
||||
case "1":
|
||||
$colour= "CC0000";
|
||||
break;
|
||||
case "2":
|
||||
$colour= "008C00";
|
||||
break;
|
||||
case "3":
|
||||
$colour= "4096EE";
|
||||
break;
|
||||
case "4":
|
||||
$colour= "73880A";
|
||||
break;
|
||||
case "5":
|
||||
$colour= "D01F3C";
|
||||
break;
|
||||
case "6":
|
||||
$colour= "36393D";
|
||||
break;
|
||||
case "7":
|
||||
default:
|
||||
$colour= "FF0084";
|
||||
unset($iter);
|
||||
break;
|
||||
}
|
||||
|
||||
$sensor['sensor_descr_fixed'] = substr(str_pad($sensor['sensor_descr'], $descr_len),0,$descr_len);
|
||||
$rrd_file = get_sensor_rrd($device, $sensor);
|
||||
$rrd_options .= " DEF:sensor" . $sensor['sensor_id'] . "=$rrd_file:sensor:AVERAGE ";
|
||||
$rrd_options .= " LINE1:sensor" . $sensor['sensor_id'] . "#" . $colour . ":'" . str_replace(':','\:',str_replace('\*','*',$sensor['sensor_descr_fixed'])) . "'";
|
||||
$rrd_options .= " GPRINT:sensor" . $sensor['sensor_id'] . ":LAST:%4.1lf".$unit." ";
|
||||
$rrd_options .= " GPRINT:sensor" . $sensor['sensor_id'] . ":MIN:%4.1lf".$unit." ";
|
||||
$rrd_options .= " GPRINT:sensor" . $sensor['sensor_id'] . ":MAX:%4.1lf".$unit."\\\l ";
|
||||
$iter++;
|
||||
if ($_GET['width'] > '300') {
|
||||
$descr_len = '40';
|
||||
}
|
||||
else {
|
||||
$descr_len = '22';
|
||||
}
|
||||
|
||||
?>
|
||||
$rrd_options .= ' -E ';
|
||||
$iter = '1';
|
||||
$rrd_options .= " COMMENT:'".str_pad($unit_long, $descr_len)." Cur Min Max\\n'";
|
||||
|
||||
foreach (dbFetchRows('SELECT * FROM `sensors` WHERE `sensor_class` = ? AND `device_id` = ? ORDER BY `sensor_index`', array($class, $device['device_id'])) as $sensor) {
|
||||
// FIXME generic colour function
|
||||
switch ($iter) {
|
||||
case '1':
|
||||
$colour = 'CC0000';
|
||||
break;
|
||||
|
||||
case '2':
|
||||
$colour = '008C00';
|
||||
break;
|
||||
|
||||
case '3':
|
||||
$colour = '4096EE';
|
||||
break;
|
||||
|
||||
case '4':
|
||||
$colour = '73880A';
|
||||
break;
|
||||
|
||||
case '5':
|
||||
$colour = 'D01F3C';
|
||||
break;
|
||||
|
||||
case '6':
|
||||
$colour = '36393D';
|
||||
break;
|
||||
|
||||
case '7':
|
||||
default:
|
||||
$colour = 'FF0084';
|
||||
unset($iter);
|
||||
break;
|
||||
}//end switch
|
||||
|
||||
$sensor['sensor_descr_fixed'] = substr(str_pad($sensor['sensor_descr'], $descr_len), 0, $descr_len);
|
||||
$rrd_file = get_sensor_rrd($device, $sensor);
|
||||
$rrd_options .= ' DEF:sensor'.$sensor['sensor_id']."=$rrd_file:sensor:AVERAGE ";
|
||||
$rrd_options .= ' LINE1:sensor'.$sensor['sensor_id'].'#'.$colour.":'".str_replace(':', '\:', str_replace('\*', '*', $sensor['sensor_descr_fixed']))."'";
|
||||
$rrd_options .= ' GPRINT:sensor'.$sensor['sensor_id'].':LAST:%4.1lf'.$unit.' ';
|
||||
$rrd_options .= ' GPRINT:sensor'.$sensor['sensor_id'].':MIN:%4.1lf'.$unit.' ';
|
||||
$rrd_options .= ' GPRINT:sensor'.$sensor['sensor_id'].':MAX:%4.1lf'.$unit.'\\\l ';
|
||||
$iter++;
|
||||
}//end foreach
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user