parent
342acf50f1
commit
f3ba8947f7
|
@ -12,6 +12,7 @@
|
|||
namespace LibreNMS\Alert\Transport;
|
||||
|
||||
use LibreNMS\Alert\Transport;
|
||||
use LibreNMS\Config;
|
||||
|
||||
class Kayako extends Transport
|
||||
{
|
||||
|
@ -28,11 +29,10 @@ class Kayako extends Transport
|
|||
|
||||
public function contactKayako($host, $kayako)
|
||||
{
|
||||
global $config;
|
||||
$url = $kayako['url']."/Tickets/Ticket";
|
||||
$key = $kayako['key'];
|
||||
$secret = $kayako['secret'];
|
||||
$user = $config['email_from'];
|
||||
$user = Config::get('email_from');
|
||||
$department = $kayako['department'];
|
||||
$ticket_type= 1;
|
||||
$ticket_status = 1;
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
namespace LibreNMS\Alert\Transport;
|
||||
|
||||
use LibreNMS\Alert\Transport;
|
||||
use LibreNMS\Config;
|
||||
|
||||
class Osticket extends Transport
|
||||
{
|
||||
|
@ -26,12 +27,10 @@ class Osticket extends Transport
|
|||
|
||||
public function contactOsticket($obj, $opts)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$url = $opts['url'];
|
||||
$token = $opts['token'];
|
||||
|
||||
foreach (parse_email($config['email_from']) as $from => $from_name) {
|
||||
foreach (parse_email(Config::get('email_from')) as $from => $from_name) {
|
||||
$email = $from_name . ' <' . $from . '>';
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
*
|
||||
* To save lots of redundant queries to the LDAP server and speed up the
|
||||
* libreNMS WebUI, all information is cached within the PHP $_SESSION as
|
||||
* long as specified in $config['auth_ldap_cache_ttl'] (Default: 300s).
|
||||
* long as specified in the 'auth_ldap_cache_ttl' setting (Default: 300s).
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Authentication;
|
||||
|
|
|
@ -45,7 +45,7 @@ class SSOAuthorizer extends MysqlAuthorizer
|
|||
public function authenticate($credentials)
|
||||
{
|
||||
if (empty($credentials['username'])) {
|
||||
throw new AuthenticationException('$config[\'sso\'][\'user_attr\'] was not found or was empty');
|
||||
throw new AuthenticationException('\'sso.user_attr\' config setting was not found or was empty');
|
||||
}
|
||||
|
||||
// Build the user's details from attributes
|
||||
|
@ -97,7 +97,7 @@ class SSOAuthorizer extends MysqlAuthorizer
|
|||
return null;
|
||||
}
|
||||
} else {
|
||||
throw new AuthenticationException('$config[\'sso\'][\'trusted_proxies\'] is set, but this connection did not originate from trusted source: ' . $_SERVER['REMOTE_ADDR']);
|
||||
throw new AuthenticationException('\'sso.trusted_proxies\'] is set in your config, but this connection did not originate from trusted source: ' . $_SERVER['REMOTE_ADDR']);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -155,23 +155,23 @@ class SSOAuthorizer extends MysqlAuthorizer
|
|||
throw new AuthenticationException('group assignment by attribute requested, but httpd is not setting the attribute to a number');
|
||||
}
|
||||
} else {
|
||||
throw new AuthenticationException('group assignment by attribute requested, but $config[\'sso\'][\'level_attr\'] not set');
|
||||
throw new AuthenticationException('group assignment by attribute requested, but \'sso.level_attr\' not set in your config');
|
||||
}
|
||||
} elseif (Config::get('sso.group_strategy') === 'map') {
|
||||
if (Config::get('sso.group_level_map') && is_array(Config::get('sso.group_level_map')) && Config::get('sso.group_delimiter') && Config::get('sso.group_attr')) {
|
||||
return (int) $this->authSSOParseGroups();
|
||||
} else {
|
||||
throw new AuthenticationException('group assignment by level map requested, but $config[\'sso\'][\'group_level_map\'], $config[\'sso\'][\'group_attr\'], or $config[\'sso\'][\'group_delimiter\'] are not set');
|
||||
throw new AuthenticationException('group assignment by level map requested, but \'sso.group_level_map\', \'sso.group_attr\', or \'sso.group_delimiter\' are not set in your config');
|
||||
}
|
||||
} elseif (Config::get('sso.group_strategy') === 'static') {
|
||||
if (Config::get('sso.static_level')) {
|
||||
return (int) Config::get('sso.static_level');
|
||||
} else {
|
||||
throw new AuthenticationException('group assignment by static level was requested, but $config[\'sso\'][\'group_level_map\'] was not set');
|
||||
throw new AuthenticationException('group assignment by static level was requested, but \'sso.group_level_map\' was not set in your config');
|
||||
}
|
||||
}
|
||||
|
||||
throw new AuthenticationException('$config[\'sso\'][\'group_strategy\'] is not set to one of attribute, map or static - configuration is unsafe');
|
||||
throw new AuthenticationException('\'sso.group_strategy\' is not set to one of attribute in your config, map or static - configuration is unsafe');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -336,6 +336,16 @@ class Config
|
|||
return json_encode($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the full configuration array
|
||||
* @return array
|
||||
*/
|
||||
public static function getAll()
|
||||
{
|
||||
global $config;
|
||||
return $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* merge the database config with the global config
|
||||
* Global config overrides db
|
||||
|
|
|
@ -68,10 +68,9 @@ class IRCBot
|
|||
|
||||
public function __construct()
|
||||
{
|
||||
global $config;
|
||||
$this->log('Setting up IRC-Bot..');
|
||||
|
||||
$this->config = $config;
|
||||
$this->config = Config::getAll();
|
||||
$this->debug = $this->config['irc_debug'];
|
||||
$this->config['irc_authtime'] = $this->config['irc_authtime'] ? $this->config['irc_authtime'] : 3;
|
||||
$this->max_retry = $this->config['irc_maxretry'];
|
||||
|
@ -623,15 +622,9 @@ class IRCBot
|
|||
private function _reload()
|
||||
{
|
||||
if ($this->user['level'] == 10) {
|
||||
global $config;
|
||||
$config = array();
|
||||
$config['install_dir'] = $this->config['install_dir'];
|
||||
chdir($config['install_dir']);
|
||||
include 'includes/defaults.inc.php';
|
||||
include 'config.php';
|
||||
include 'includes/definitions.inc.php';
|
||||
$new_config = Config::load();
|
||||
$this->respond('Reloading configuration & defaults');
|
||||
if ($config != $this->config) {
|
||||
if ($new_config != $this->config) {
|
||||
return $this->__construct();
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -42,7 +42,6 @@ class ObjectCache implements ArrayAccess
|
|||
*/
|
||||
public function __construct($obj)
|
||||
{
|
||||
global $config;
|
||||
$this->obj = $obj;
|
||||
if (isset($GLOBALS['_ObjCache'][$obj])) {
|
||||
$this->data = $GLOBALS['_ObjCacheSkell'][$obj];
|
||||
|
@ -55,9 +54,9 @@ class ObjectCache implements ArrayAccess
|
|||
$GLOBALS['_ObjCache'] = array();
|
||||
}
|
||||
|
||||
if (file_exists($config['install_dir'].'/includes/caches/'.$obj.'.inc.php')) {
|
||||
if (file_exists(\LibreNMS\Config::get('install_dir') . '/includes/caches/' . $obj . '.inc.php')) {
|
||||
$data = array();
|
||||
include $config['install_dir'].'/includes/caches/'.$obj.'.inc.php';
|
||||
include \LibreNMS\Config::get('install_dir') . '/includes/caches/' . $obj . '.inc.php';
|
||||
$this->data = $data;
|
||||
$GLOBALS['_ObjCacheSkell'][$obj] = $this->data;
|
||||
if (!(isset($GLOBALS['_ObjCache'][$obj]) && is_array($GLOBALS['_ObjCache'][$obj]))) {
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
namespace LibreNMS\RRD;
|
||||
|
||||
use LibreNMS\Config;
|
||||
use LibreNMS\Exceptions\InvalidRrdTypeException;
|
||||
|
||||
class RrdDefinition
|
||||
|
@ -53,8 +54,6 @@ class RrdDefinition
|
|||
*/
|
||||
public function addDataset($name, $type, $min = null, $max = null, $heartbeat = null)
|
||||
{
|
||||
global $config;
|
||||
|
||||
if (empty($name)) {
|
||||
d_echo("DS must be set to a non-empty string.");
|
||||
}
|
||||
|
@ -62,7 +61,7 @@ class RrdDefinition
|
|||
$ds = array();
|
||||
$ds[] = $this->escapeName($name);
|
||||
$ds[] = $this->checkType($type);
|
||||
$ds[] = is_null($heartbeat) ? $config['rrd']['heartbeat'] : $heartbeat;
|
||||
$ds[] = is_null($heartbeat) ? Config::get('rrd.heartbeat') : $heartbeat;
|
||||
$ds[] = is_null($min) ? 'U' : $min;
|
||||
$ds[] = is_null($max) ? 'U' : $max;
|
||||
|
||||
|
|
46
addhost.php
46
addhost.php
|
@ -11,6 +11,7 @@
|
|||
* @copyright (C) 2006 - 2012 Adam Armstrong
|
||||
*/
|
||||
|
||||
use LibreNMS\Config;
|
||||
use LibreNMS\Exceptions\HostUnreachableException;
|
||||
|
||||
$init_modules = array();
|
||||
|
@ -24,8 +25,8 @@ if (isset($options['g']) && $options['g'] >= 0) {
|
|||
array_shift($argv);
|
||||
array_unshift($argv, $cmd);
|
||||
$poller_group = $options['g'];
|
||||
} elseif ($config['distributed_poller'] === true) {
|
||||
$poller_group = $config['distributed_poller_group'];
|
||||
} elseif (Config::get('distributed_poller') === true) {
|
||||
$poller_group = Config::get('distributed_poller_group');
|
||||
} else {
|
||||
$poller_group = 0;
|
||||
}
|
||||
|
@ -39,7 +40,7 @@ if (isset($options['f']) && $options['f'] == 0) {
|
|||
$force_add = false;
|
||||
}
|
||||
|
||||
$port_assoc_mode = $config['default_port_association_mode'];
|
||||
$port_assoc_mode = Config::get('default_port_association_mode');
|
||||
$valid_assoc_modes = get_port_assoc_modes();
|
||||
if (isset($options['p'])) {
|
||||
$port_assoc_mode = $options['p'];
|
||||
|
@ -67,6 +68,7 @@ if (isset($options['b'])) {
|
|||
array_unshift($argv, $cmd);
|
||||
}
|
||||
|
||||
$transports_regex = implode('|', Config::get('snmp.transports'));
|
||||
if (!empty($argv[1])) {
|
||||
$host = strtolower($argv[1]);
|
||||
$community = $argv[2];
|
||||
|
@ -111,7 +113,7 @@ if (!empty($argv[1])) {
|
|||
// parse all remaining args
|
||||
if (is_numeric($arg)) {
|
||||
$port = $arg;
|
||||
} elseif (preg_match('/^('.implode('|', $config['snmp']['transports']).')$/', $arg)) {
|
||||
} elseif (preg_match('/^(' . $transports_regex . ')$/', $arg)) {
|
||||
$transport = $arg;
|
||||
} else {
|
||||
// should add a sanity check of chars allowed in user
|
||||
|
@ -120,7 +122,9 @@ if (!empty($argv[1])) {
|
|||
}
|
||||
|
||||
if ($seclevel === 'nanp') {
|
||||
array_unshift($config['snmp']['v3'], $v3);
|
||||
$v3_config = Config::get('snmp.v3');
|
||||
array_unshift($v3_config, $v3);
|
||||
Config::set('snmp.v3', $v3_config);
|
||||
}
|
||||
} elseif ($seclevel === 'anp' or $seclevel === 'authNoPriv') {
|
||||
$v3['authlevel'] = 'authNoPriv';
|
||||
|
@ -132,7 +136,7 @@ if (!empty($argv[1])) {
|
|||
// parse all remaining args
|
||||
if (is_numeric($arg)) {
|
||||
$port = $arg;
|
||||
} elseif (preg_match('/^('.implode('|', $config['snmp']['transports']).')$/i', $arg)) {
|
||||
} elseif (preg_match('/^(' . $transports_regex . ')$/i', $arg)) {
|
||||
$transport = $arg;
|
||||
} elseif (preg_match('/^(sha|md5)$/i', $arg)) {
|
||||
$v3['authalgo'] = $arg;
|
||||
|
@ -142,7 +146,9 @@ if (!empty($argv[1])) {
|
|||
}
|
||||
}
|
||||
|
||||
array_unshift($config['snmp']['v3'], $v3);
|
||||
$v3_config = Config::get('snmp.v3');
|
||||
array_unshift($v3_config, $v3);
|
||||
Config::set('snmp.v3', $v3_config);
|
||||
} elseif ($seclevel === 'ap' or $seclevel === 'authPriv') {
|
||||
$v3['authlevel'] = 'authPriv';
|
||||
$v3args = array_slice($argv, 4);
|
||||
|
@ -154,7 +160,7 @@ if (!empty($argv[1])) {
|
|||
// parse all remaining args
|
||||
if (is_numeric($arg)) {
|
||||
$port = $arg;
|
||||
} elseif (preg_match('/^('.implode('|', $config['snmp']['transports']).')$/i', $arg)) {
|
||||
} elseif (preg_match('/^(' . $transports_regex . ')$/i', $arg)) {
|
||||
$transport = $arg;
|
||||
} elseif (preg_match('/^(sha|md5)$/i', $arg)) {
|
||||
$v3['authalgo'] = $arg;
|
||||
|
@ -166,7 +172,9 @@ if (!empty($argv[1])) {
|
|||
}
|
||||
}//end while
|
||||
|
||||
array_unshift($config['snmp']['v3'], $v3);
|
||||
$v3_config = Config::get('snmp.v3');
|
||||
array_unshift($v3_config, $v3);
|
||||
Config::set('snmp.v3', $v3_config);
|
||||
}
|
||||
} else {
|
||||
// v2c or v1
|
||||
|
@ -176,7 +184,7 @@ if (!empty($argv[1])) {
|
|||
// parse all remaining args
|
||||
if (is_numeric($arg)) {
|
||||
$port = $arg;
|
||||
} elseif (preg_match('/('.implode('|', $config['snmp']['transports']).')/i', $arg)) {
|
||||
} elseif (preg_match('/(' . $transports_regex . ')/i', $arg)) {
|
||||
$transport = $arg;
|
||||
} elseif (preg_match('/^(v1|v2c)$/i', $arg)) {
|
||||
$snmpver = $arg;
|
||||
|
@ -184,7 +192,9 @@ if (!empty($argv[1])) {
|
|||
}
|
||||
|
||||
if ($community) {
|
||||
array_unshift($config['snmp']['community'], $community);
|
||||
$comm_config = Config::get('snmp.community');
|
||||
array_unshift($comm_config, $community);
|
||||
Config::set('snmp.community', $comm_config);
|
||||
}
|
||||
}//end if
|
||||
|
||||
|
@ -205,21 +215,21 @@ if (!empty($argv[1])) {
|
|||
}
|
||||
} else {
|
||||
c_echo(
|
||||
"\n".$config['project_name_version'].' Add Host Tool
|
||||
"\n" . Config::get('project_name_version') . ' Add Host Tool
|
||||
|
||||
Usage (SNMPv1/2c) : ./addhost.php [-g <poller group>] [-f] [-b] [-p <port assoc mode>] <%Whostname%n> [community] [v1|v2c] [port] ['.implode('|', $config['snmp']['transports']).']
|
||||
Usage (SNMPv1/2c) : ./addhost.php [-g <poller group>] [-f] [-b] [-p <port assoc mode>] <%Whostname%n> [community] [v1|v2c] [port] [' . $transports_regex . ']
|
||||
Usage (SNMPv3) :
|
||||
Config Defaults : ./addhost.php [-g <poller group>] [-f] [-b] [-p <port assoc mode>] <%Whostname%n> any v3 [user] [port] ['.implode('|', $config['snmp']['transports']).']
|
||||
No Auth, No Priv : ./addhost.php [-g <poller group>] [-f] [-b] [-p <port assoc mode>] <%Whostname%n> nanp v3 [user] [port] ['.implode('|', $config['snmp']['transports']).']
|
||||
Auth, No Priv : ./addhost.php [-g <poller group>] [-f] [-b] [-p <port assoc mode>] <%Whostname%n> anp v3 <user> <password> [md5|sha] [port] ['.implode('|', $config['snmp']['transports']).']
|
||||
Auth, Priv : ./addhost.php [-g <poller group>] [-f] [-b] [-p <port assoc mode>] <%Whostname%n> ap v3 <user> <password> <enckey> [md5|sha] [aes|dsa] [port] ['.implode('|', $config['snmp']['transports']).']
|
||||
Config Defaults : ./addhost.php [-g <poller group>] [-f] [-b] [-p <port assoc mode>] <%Whostname%n> any v3 [user] [port] [' . $transports_regex . ']
|
||||
No Auth, No Priv : ./addhost.php [-g <poller group>] [-f] [-b] [-p <port assoc mode>] <%Whostname%n> nanp v3 [user] [port] [' . $transports_regex . ']
|
||||
Auth, No Priv : ./addhost.php [-g <poller group>] [-f] [-b] [-p <port assoc mode>] <%Whostname%n> anp v3 <user> <password> [md5|sha] [port] [' . $transports_regex . ']
|
||||
Auth, Priv : ./addhost.php [-g <poller group>] [-f] [-b] [-p <port assoc mode>] <%Whostname%n> ap v3 <user> <password> <enckey> [md5|sha] [aes|dsa] [port] [' . $transports_regex . ']
|
||||
Usage (ICMP only) : ./addhost.php [-g <poller group>] [-f] -P <%Whostname%n> [os] [hardware]
|
||||
|
||||
-g <poller group> allows you to add a device to be pinned to a specific poller when using distributed polling. X can be any number associated with a poller group
|
||||
-f forces the device to be added by skipping the icmp and snmp check against the host.
|
||||
-p <port assoc mode> allow you to set a port association mode for this device. By default ports are associated by \'ifIndex\'.
|
||||
For Linux/Unix based devices \'ifName\' or \'ifDescr\' might be useful for a stable iface mapping.
|
||||
The default for this installation is \'' . $config['default_port_association_mode'] . '\'
|
||||
The default for this installation is \'' . Config::get('default_port_association_mode') . '\'
|
||||
Valid port assoc modes are: ' . join(', ', $valid_assoc_modes) . '
|
||||
-b Add the host with SNMP if it replies to it, otherwise only ICMP.
|
||||
-P Add the host with only ICMP, no SNMP or OS discovery.
|
||||
|
|
|
@ -38,7 +38,7 @@ if (set_debug(isset($options['d']))) {
|
|||
echo "DEBUG!\n";
|
||||
}
|
||||
|
||||
if (!defined('TEST') && $config['alert']['disable'] != 'true') {
|
||||
if (!defined('TEST') && \LibreNMS\Config::get('alert.disable') != 'true') {
|
||||
echo 'Start: '.date('r')."\r\n";
|
||||
echo "ClearStaleAlerts():" . PHP_EOL;
|
||||
ClearStaleAlerts();
|
||||
|
|
|
@ -81,7 +81,7 @@ class MenuComposer
|
|||
$vars['port_counts']['pseudowire'] = Config::get('enable_pseudowires') ? ObjectCache::portCounts(['pseudowire'])['pseudowire'] : 0;
|
||||
|
||||
$vars['port_counts']['alerted'] = 0; // not actually supported on old...
|
||||
$vars['custom_port_descr'] = collect(\LibreNMS\Config::get('custom_descr', []))
|
||||
$vars['custom_port_descr'] = collect(Config::get('custom_descr', []))
|
||||
->filter()
|
||||
->map(function ($descr) {
|
||||
return strtolower($descr);
|
||||
|
@ -217,7 +217,7 @@ class MenuComposer
|
|||
})->count();
|
||||
|
||||
// Search bar
|
||||
$vars['typeahead_limit'] = \LibreNMS\Config::get('webui.global_search_result_limit');
|
||||
$vars['typeahead_limit'] = Config::get('webui.global_search_result_limit');
|
||||
|
||||
$view->with($vars);
|
||||
}
|
||||
|
|
|
@ -192,20 +192,13 @@ class Device extends BaseModel
|
|||
|
||||
public function loadOs($force = false)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$yaml_file = base_path('/includes/definitions/' . $this->os . '.yaml');
|
||||
|
||||
if ((empty($config['os'][$this->os]['definition_loaded']) || $force) && file_exists($yaml_file)) {
|
||||
if ((!\LibreNMS\Config::getOsSetting($this->os, 'definition_loaded') || $force) && file_exists($yaml_file)) {
|
||||
$os = \Symfony\Component\Yaml\Yaml::parse(file_get_contents($yaml_file));
|
||||
|
||||
if (isset($config['os'][$this->os])) {
|
||||
$config['os'][$this->os] = array_replace_recursive($os, $config['os'][$this->os]);
|
||||
} else {
|
||||
$config['os'][$this->os] = $os;
|
||||
}
|
||||
|
||||
$config['os'][$this->os]['definition_loaded'] = true;
|
||||
\LibreNMS\Config::set("os.$this->os", array_replace_recursive($os, \LibreNMS\Config::get("os.$this->os", [])));
|
||||
\LibreNMS\Config::set("os.$this->os.definition_loaded", true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,14 +22,14 @@ if (set_debug(isset($options['d']))) {
|
|||
}
|
||||
|
||||
if (isset($options['f'])) {
|
||||
$config['noinfluxdb'] = true;
|
||||
\LibreNMS\Config::set('noinfluxdb', true);
|
||||
}
|
||||
|
||||
if (isset($options['p'])) {
|
||||
$prometheus = false;
|
||||
}
|
||||
|
||||
if ($config['noinfluxdb'] !== true && $config['influxdb']['enable'] === true) {
|
||||
if (\LibreNMS\Config::get('noinfluxdb') !== true && \LibreNMS\Config::get('influxdb.enable') === true) {
|
||||
$influxdb = influxdb_connect();
|
||||
} else {
|
||||
$influxdb = false;
|
||||
|
@ -106,7 +106,7 @@ $poller_run = ($poller_end - $poller_start);
|
|||
$poller_time = substr($poller_run, 0, 5);
|
||||
|
||||
|
||||
$string = $argv[0]." ".date($config['dateformat']['compact'])
|
||||
$string = $argv[0] . " " . date(\LibreNMS\Config::get('dateformat.compact'))
|
||||
." - $polled_services services polled in $poller_time secs";
|
||||
d_echo("$string\n");
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ foreach (dbFetchRows('SELECT * FROM `ipv4_networks`') as $data) {
|
|||
$end = ip2long($broadcast);
|
||||
while ($ip < $end) {
|
||||
$ipdotted = long2ip($ip);
|
||||
if (dbFetchCell('SELECT COUNT(ipv4_address_id) FROM `ipv4_addresses` WHERE `ipv4_address` = ?', array($ipdotted)) == '0' && match_network($config['nets'], $ipdotted)) {
|
||||
if (dbFetchCell('SELECT COUNT(ipv4_address_id) FROM `ipv4_addresses` WHERE `ipv4_address` = ?', [$ipdotted]) == '0' && match_network(\LibreNMS\Config::get('nets'), $ipdotted)) {
|
||||
fputs($handle, $ipdotted."\n");
|
||||
}
|
||||
|
||||
|
@ -39,4 +39,4 @@ foreach (dbFetchRows('SELECT * FROM `ipv4_networks`') as $data) {
|
|||
|
||||
fclose($handle);
|
||||
|
||||
shell_exec($config['fping'] . ' -t 100 -f ips.txt > ips-scanned.txt');
|
||||
shell_exec(\LibreNMS\Config::get('fping') . ' -t 100 -f ips.txt > ips-scanned.txt');
|
||||
|
|
18
daily.php
18
daily.php
|
@ -25,13 +25,13 @@ if (isset($options['d'])) {
|
|||
}
|
||||
|
||||
if ($options['f'] === 'update') {
|
||||
if (!$config['update']) {
|
||||
if (!Config::get('base_url')) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if ($config['update_channel'] == 'master') {
|
||||
if (Config::get('base_url') == 'master') {
|
||||
exit(1);
|
||||
} elseif ($config['update_channel'] == 'release') {
|
||||
} elseif (Config::get('base_url') == 'release') {
|
||||
exit(3);
|
||||
}
|
||||
exit(0);
|
||||
|
@ -243,11 +243,11 @@ if ($options['f'] === 'purgeusers') {
|
|||
}
|
||||
|
||||
$purge = 0;
|
||||
if (is_numeric($config['radius']['users_purge']) && $config['auth_mechanism'] === 'radius') {
|
||||
$purge = $config['radius']['users_purge'];
|
||||
if (is_numeric(\LibreNMS\Config::get('radius.users_purge')) && Config::get('base_url') === 'radius') {
|
||||
$purge = \LibreNMS\Config::get('radius.users_purge');
|
||||
}
|
||||
if (is_numeric($config['active_directory']['users_purge']) && $config['auth_mechanism'] === 'active_directory') {
|
||||
$purge = $config['active_directory']['users_purge'];
|
||||
if (is_numeric(\LibreNMS\Config::get('active_directory.users_purge')) && Config::get('base_url') === 'active_directory') {
|
||||
$purge = \LibreNMS\Config::get('active_directory.users_purge');
|
||||
}
|
||||
if ($purge > 0) {
|
||||
foreach (dbFetchRows("SELECT DISTINCT(`user`) FROM `authlog` WHERE `datetime` >= DATE_SUB(NOW(), INTERVAL ? DAY)", array($purge)) as $user) {
|
||||
|
@ -309,9 +309,9 @@ if ($options['f'] === 'refresh_device_groups') {
|
|||
}
|
||||
|
||||
if ($options['f'] === 'notify') {
|
||||
if (isset($config['alert']['default_mail'])) {
|
||||
if (\LibreNMS\Config::has('alert.default_mail')) {
|
||||
send_mail(
|
||||
$config['alert']['default_mail'],
|
||||
\LibreNMS\Config::get('alert.default_mail'),
|
||||
'[LibreNMS] Auto update has failed for ' . Config::get('distributed_poller_name'),
|
||||
"We just attempted to update your install but failed. The information below should help you fix this.\r\n\r\n" . $options['o']
|
||||
);
|
||||
|
|
2
daily.sh
2
daily.sh
|
@ -25,7 +25,7 @@ DAILY_SCRIPT=$(readlink -f "$0")
|
|||
LIBRENMS_DIR=$(dirname "$DAILY_SCRIPT")
|
||||
COMPOSER="php ${LIBRENMS_DIR}/scripts/composer_wrapper.php --no-interaction"
|
||||
|
||||
# set log_file, using librenms $config['log_dir'], if set
|
||||
# set log_file, using librenms 'log_dir' config setting, if set
|
||||
# otherwise we default to <LibreNMS Install Directory>/logs
|
||||
LOG_DIR=$(php -r "@include '${LIBRENMS_DIR}/config.php'; echo isset(\$config['log_dir']) ? \$config['log_dir'] : '${LIBRENMS_DIR}/logs';")
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ $sqlparams = array();
|
|||
$options = getopt('h:m:i:n:d::v::a::q', array('os:','type:'));
|
||||
|
||||
if (!isset($options['q'])) {
|
||||
echo $config['project_name_version']." Discovery\n";
|
||||
echo \LibreNMS\Config::get('project_name_version') . " Discovery\n";
|
||||
}
|
||||
|
||||
if (isset($options['h'])) {
|
||||
|
@ -111,8 +111,8 @@ $module_override = parse_modules('discovery', $options);
|
|||
|
||||
$discovered_devices = 0;
|
||||
|
||||
if (!empty($config['distributed_poller_group'])) {
|
||||
$where .= ' AND poller_group IN('.$config['distributed_poller_group'].')';
|
||||
if (!empty(\LibreNMS\Config::get('distributed_poller_group'))) {
|
||||
$where .= ' AND poller_group IN(' . \LibreNMS\Config::get('distributed_poller_group') . ')';
|
||||
}
|
||||
|
||||
global $device;
|
||||
|
@ -125,7 +125,14 @@ $run = ($end - $start);
|
|||
$proctime = substr($run, 0, 5);
|
||||
|
||||
if ($discovered_devices) {
|
||||
dbInsert(array('type' => 'discover', 'doing' => $doing, 'start' => $start, 'duration' => $proctime, 'devices' => $discovered_devices, 'poller' => $config['distributed_poller_name']), 'perf_times');
|
||||
dbInsert([
|
||||
'type' => 'discover',
|
||||
'doing' => $doing,
|
||||
'start' => $start,
|
||||
'duration' => $proctime,
|
||||
'devices' => $discovered_devices,
|
||||
'poller' => \LibreNMS\Config::get('distributed_poller_name')
|
||||
], 'perf_times');
|
||||
if ($doing === 'new') {
|
||||
// We have added a new device by this point so we might want to do some other work
|
||||
oxidized_reload_nodes();
|
||||
|
@ -136,7 +143,7 @@ if ($doing === 'new') {
|
|||
$new_discovery_lock->release();
|
||||
}
|
||||
|
||||
$string = $argv[0]." $doing ".date($config['dateformat']['compact'])." - $discovered_devices devices discovered in $proctime secs";
|
||||
$string = $argv[0] . " $doing " . date(\LibreNMS\Config::get('dateformat.compact')) . " - $discovered_devices devices discovered in $proctime secs";
|
||||
d_echo("$string\n");
|
||||
|
||||
if (!isset($options['q'])) {
|
||||
|
|
|
@ -47,8 +47,8 @@ if (isset($options['l'])) {
|
|||
echo 'Poller '.$options['u']." has been removed\n";
|
||||
}
|
||||
} elseif (isset($options['r'])) {
|
||||
if (dbInsert(array('poller_name' => $config['distributed_poller_name'], 'last_polled' => '0000-00-00 00:00:00', 'devices' => 0, 'time_taken' => 0), 'pollers') >= 0) {
|
||||
echo 'Poller '.$config['distributed_poller_name']." has been registered\n";
|
||||
if (dbInsert(['poller_name' => Config::get('base_url'), 'last_polled' => '0000-00-00 00:00:00', 'devices' => 0, 'time_taken' => 0], 'pollers') >= 0) {
|
||||
echo 'Poller ' . Config::get('base_url') . " has been registered\n";
|
||||
}
|
||||
} else {
|
||||
echo "-l pollers | groups List registered pollers or poller groups\n";
|
||||
|
|
|
@ -58,7 +58,7 @@ header('Content-type: application/json');
|
|||
if (isset($_GET['term'])) {
|
||||
load_all_os();
|
||||
$_GET['term'] = clean($_GET['term']);
|
||||
$sortos = levsortos($_GET['term'], $config['os'], array("text", "os"));
|
||||
$sortos = levsortos($_GET['term'], \LibreNMS\Config::get('os'), ["text", "os"]);
|
||||
$sortos = array_slice($sortos, 0, 20);
|
||||
foreach ($sortos as $lev => $os) {
|
||||
$ret[$lev] = array_intersect_key($os, array('os' => true, 'text' => true));
|
||||
|
|
|
@ -30,6 +30,6 @@ if (isset($_SESSION['stage']) && $_SESSION['stage'] == 2) {
|
|||
set_debug($_REQUEST['debug']);
|
||||
$id = basename($_REQUEST['id']);
|
||||
|
||||
if ($id && is_file($config['install_dir'] . "/includes/html/output/$id.inc.php")) {
|
||||
require $config['install_dir'] . "/includes/html/output/$id.inc.php";
|
||||
if ($id && is_file(\LibreNMS\Config::get('install_dir') . "/includes/html/output/$id.inc.php")) {
|
||||
require \LibreNMS\Config::get('install_dir') . "/includes/html/output/$id.inc.php";
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ if (isset($_REQUEST['search'])) {
|
|||
'device_ports' => $num_ports,
|
||||
'device_image' => getIcon($result),
|
||||
'device_hardware' => $result['hardware'],
|
||||
'device_os' => $config['os'][$result['os']]['text'],
|
||||
'device_os' => \LibreNMS\Config::getOsSetting($result['os'], 'text'),
|
||||
'version' => $result['version'],
|
||||
'location' => $result['location'],
|
||||
);
|
||||
|
@ -243,7 +243,7 @@ if (isset($_REQUEST['search'])) {
|
|||
'colours' => $highlight_colour,
|
||||
'device_image' => getIcon($result),
|
||||
'device_hardware' => $result['hardware'],
|
||||
'device_os' => $config['os'][$result['os']]['text'],
|
||||
'device_os' => \LibreNMS\Config::getOsSetting($result['os'], 'text'),
|
||||
'version' => $result['version'],
|
||||
'location' => $result['location'],
|
||||
);
|
||||
|
@ -289,7 +289,7 @@ if (isset($_REQUEST['search'])) {
|
|||
'colours' => $highlight_colour,
|
||||
'device_image' => getIcon($result),
|
||||
'device_hardware' => $result['hardware'],
|
||||
'device_os' => $config['os'][$result['os']]['text'],
|
||||
'device_os' => \LibreNMS\Config::getOsSetting($result['os'], 'text'),
|
||||
'version' => $result['version'],
|
||||
'location' => $result['location'],
|
||||
'plugin' => $result['mplug_type'],
|
||||
|
|
|
@ -28,7 +28,7 @@ if (is_numeric($_GET['bill_hist_id'])) {
|
|||
$urlargs['to'] = $_GET['to'];
|
||||
}
|
||||
|
||||
$url = "{$config['base_url']}graph.php?";
|
||||
$url = Config::get('base_url') . 'graph.php?';
|
||||
$i = 0;
|
||||
foreach ($urlargs as $name => $value) {
|
||||
if ($i++ > 0) {
|
||||
|
|
|
@ -36,7 +36,7 @@ if (isset($_GET['ave'])) {
|
|||
$urlargs['ave'] = $_GET['ave'];
|
||||
}
|
||||
|
||||
$url = "{$config['base_url']}graph.php?";
|
||||
$url = Config::get('base_url') . 'graph.php?';
|
||||
$i = 0;
|
||||
foreach ($urlargs as $name => $value) {
|
||||
if ($i++ > 0) {
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
$init_modules = array('web', 'auth');
|
||||
require realpath(__DIR__ . '/..') . '/includes/init.php';
|
||||
|
||||
if (is_numeric($_GET['id']) && ($config['allow_unauth_graphs'] || port_permitted($_GET['id']))) {
|
||||
if (is_numeric($_GET['id']) && (\LibreNMS\Config::get('allow_unauth_graphs') || port_permitted($_GET['id']))) {
|
||||
$port = cleanPort(get_port_by_id($_GET['id']));
|
||||
$device = device_by_id_cache($port['device_id']);
|
||||
$title = generate_device_link($device);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
$init_modules = array('web', 'auth');
|
||||
require realpath(__DIR__ . '/..') . '/includes/init.php';
|
||||
|
||||
if (is_numeric($_GET['id']) && ($config['allow_unauth_graphs'] || port_permitted($_GET['id']))) {
|
||||
if (is_numeric($_GET['id']) && (Config::get('base_url') || port_permitted($_GET['id']))) {
|
||||
$port = cleanPort(get_port_by_id($_GET['id']));
|
||||
$device = device_by_id_cache($port['device_id']);
|
||||
$title = generate_device_link($device);
|
||||
|
|
|
@ -26,7 +26,7 @@ set_debug(isset($_GET['debug']));
|
|||
|
||||
rrdtool_initialize(false);
|
||||
|
||||
require $config['install_dir'] . '/includes/html/graphs/graph.inc.php';
|
||||
require \LibreNMS\Config::get('install_dir') . '/includes/html/graphs/graph.inc.php';
|
||||
|
||||
rrdtool_close();
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
use LibreNMS\Config;
|
||||
|
||||
session_start();
|
||||
$librenms_dir = realpath(__DIR__ . '/..');
|
||||
|
@ -105,12 +106,12 @@ $complete = 1;
|
|||
<!DOCTYPE HTML>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title><?php echo($config['page_title_prefix']); ?></title>
|
||||
<title><?php echo(Config::get('page_title_prefix')); ?></title>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css" />
|
||||
<link href="<?php echo($config['stylesheet']); ?>" rel="stylesheet" type="text/css" />
|
||||
<link href="<?php echo(Config::get('stylesheet')); ?>" rel="stylesheet" type="text/css"/>
|
||||
<script src="js/jquery.min.js"></script>
|
||||
<script src="js/bootstrap.min.js"></script>
|
||||
<script src="js/bootstrap-hover-dropdown.min.js"></script>
|
||||
|
@ -120,7 +121,7 @@ $complete = 1;
|
|||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-6 col-md-offset-3">
|
||||
<h2 class="text-center">Welcome to the <?php echo($config['project_name']); ?> install</h2>
|
||||
<h2 class="text-center">Welcome to the <?php echo(Config::get('project_name')); ?> install</h2>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
use LibreNMS\Config;
|
||||
|
||||
$links = 1;
|
||||
|
||||
|
@ -32,12 +33,8 @@ if (strpos($_SERVER['REQUEST_URI'], 'anon')) {
|
|||
$anon = 1;
|
||||
}
|
||||
|
||||
if (isset($config['branding']) && is_array($config['branding'])) {
|
||||
if (isset($config['branding'][$_SERVER['SERVER_NAME']])) {
|
||||
$config = array_replace_recursive($config, $config['branding'][$_SERVER['SERVER_NAME']]);
|
||||
} else {
|
||||
$config = array_replace_recursive($config, $config['branding']['default']);
|
||||
}
|
||||
if (is_array(Config::get('branding'))) {
|
||||
Config::set('branding', array_replace_recursive(Config::get('branding'), Config::get('branding.' . $_SERVER['SERVER_NAME']) ?: Config::get('branding.default')));
|
||||
}
|
||||
|
||||
$where = '';
|
||||
|
@ -74,7 +71,7 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format'])) {
|
|||
}
|
||||
$loc_id = $locations[$device['location']];
|
||||
|
||||
$map .= "\"".$device['hostname']."\" [fontsize=20, fillcolor=\"lightblue\", group=".$loc_id." URL=\"{$config['base_url']}/device/device=".$device['device_id']."/tab=neighbours/selection=map/\" shape=box3d]\n";
|
||||
$map .= "\"" . $device['hostname'] . "\" [fontsize=20, fillcolor=\"lightblue\", group=" . $loc_id . " URL=\"" . Config::get('base_url') . "/device/device=" . $device['device_id'] . "/tab=neighbours/selection=map/\" shape=box3d]\n";
|
||||
}
|
||||
|
||||
foreach ($links as $link) {
|
||||
|
@ -135,24 +132,24 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format'])) {
|
|||
}
|
||||
$ifdone[$src][$sif['port_id']] = 1;
|
||||
} else {
|
||||
$map .= "\"" . $sif['port_id'] . "\" [label=\"" . $sif['label'] . "\", fontsize=12, fillcolor=lightblue, URL=\"{$config['base_url']}/device/device=".$device['device_id']."/tab=port/port=$local_port_id/\"]\n";
|
||||
$map .= "\"" . $sif['port_id'] . "\" [label=\"" . $sif['label'] . "\", fontsize=12, fillcolor=lightblue, URL=\"" . Config::get('base_url') . "/device/device=" . $device['device_id'] . "/tab=port/port=$local_port_id/\"]\n";
|
||||
if (!$ifdone[$src][$sif['port_id']]) {
|
||||
$map .= "\"$src\" -> \"" . $sif['port_id'] . "\" [weight=500000, arrowsize=0, len=0];\n";
|
||||
$ifdone[$src][$sif['port_id']] = 1;
|
||||
}
|
||||
|
||||
if ($dst_host) {
|
||||
$map .= "\"$dst\" [URL=\"{$config['base_url']}/device/device=$dst_host/tab=neighbours/selection=map/\", fontsize=20, shape=box3d]\n";
|
||||
$map .= "\"$dst\" [URL=\"" . Config::get('base_url') . "/device/device=$dst_host/tab=neighbours/selection=map/\", fontsize=20, shape=box3d]\n";
|
||||
} else {
|
||||
$map .= "\"$dst\" [ fontsize=20 shape=box3d]\n";
|
||||
}
|
||||
|
||||
if ($dst_host == $device['device_id'] || $where == '') {
|
||||
$map .= "\"" . $dif['port_id'] . "\" [label=\"" . $dif['label'] . "\", fontsize=12, fillcolor=lightblue, URL=\"{$config['base_url']}/device/device=$dst_host/tab=port/port=$remote_port_id/\"]\n";
|
||||
$map .= "\"" . $dif['port_id'] . "\" [label=\"" . $dif['label'] . "\", fontsize=12, fillcolor=lightblue, URL=\"" . Config::get('base_url') . "/device/device=$dst_host/tab=port/port=$remote_port_id/\"]\n";
|
||||
} else {
|
||||
$map .= "\"" . $dif['port_id'] . "\" [label=\"" . $dif['label'] . " \", fontsize=12, fillcolor=lightgray";
|
||||
if ($dst_host) {
|
||||
$map .= ", URL=\"{$config['base_url']}/device/device=$dst_host/tab=port/port=$remote_port_id/\"";
|
||||
$map .= ", URL=\"" . Config::get('base_url') . "/device/device=$dst_host/tab=port/port=$remote_port_id/\"";
|
||||
}
|
||||
$map .= "]\n";
|
||||
}
|
||||
|
@ -192,19 +189,19 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format'])) {
|
|||
|
||||
if ($links > 30) {
|
||||
// Unflatten if there are more than 10 links. beyond that it gets messy
|
||||
$maptool = $config['dot'];
|
||||
$maptool = Config::get('dot');
|
||||
} else {
|
||||
$maptool = $config['dot'];
|
||||
$maptool = Config::get('dot');
|
||||
}
|
||||
|
||||
if ($where == '') {
|
||||
$maptool = $config['sfdp'] . ' -Gpack -Goverlap=prism -Gcharset=latin1 -Gsize=20,20';
|
||||
$maptool = $config['dot'];
|
||||
$maptool = Config::get('sfdp') . ' -Gpack -Goverlap=prism -Gcharset=latin1 -Gsize=20,20';
|
||||
$maptool = Config::get('dot');
|
||||
}
|
||||
|
||||
$descriptorspec = array(0 => array("pipe", "r"),1 => array("pipe", "w") );
|
||||
|
||||
$mapfile = $config['temp_dir'] . "/" . strgen() . ".png";
|
||||
$mapfile = Config::get('temp_dir') . "/" . strgen() . ".png";
|
||||
|
||||
$process = proc_open($maptool.' -T'.$_GET['format'], $descriptorspec, $pipes);
|
||||
|
||||
|
@ -229,7 +226,7 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format'])) {
|
|||
if (LegacyAuth::check()) {
|
||||
// FIXME level 10 only?
|
||||
echo '<center>
|
||||
<object width=1200 height=1000 data="'. $config['base_url'] . '/network-map.php?format=svg" type="image/svg+xml"></object>
|
||||
<object width=1200 height=1000 data="' . Config::get('base_url') . '/network-map.php?format=svg" type="image/svg+xml"></object>
|
||||
</center>
|
||||
';
|
||||
}
|
||||
|
|
|
@ -117,9 +117,9 @@ function GenSQLOld($rule)
|
|||
*/
|
||||
function RunMacros($rule, $x = 1)
|
||||
{
|
||||
global $config;
|
||||
krsort($config['alert']['macros']['rule']);
|
||||
foreach ($config['alert']['macros']['rule'] as $macro => $value) {
|
||||
$macros = Config::get('alert.macros.rule', []) .
|
||||
krsort($macros);
|
||||
foreach ($macros as $macro => $value) {
|
||||
if (!strstr($macro, " ")) {
|
||||
$rule = str_replace('%macros.'.$macro, '('.$value.')', $rule);
|
||||
}
|
||||
|
@ -257,8 +257,6 @@ function RunRules($device_id)
|
|||
*/
|
||||
function GetContacts($results)
|
||||
{
|
||||
global $config;
|
||||
|
||||
if (empty($results)) {
|
||||
return [];
|
||||
}
|
||||
|
@ -284,7 +282,7 @@ function GetContacts($results)
|
|||
}
|
||||
}
|
||||
if (is_numeric($result["device_id"])) {
|
||||
if ($config['alert']['syscontact'] == true) {
|
||||
if (Config::get('alert.syscontact') == true) {
|
||||
if (dbFetchCell("SELECT attrib_value FROM devices_attribs WHERE attrib_type = 'override_sysContact_bool' AND device_id = ?", [$result["device_id"]])) {
|
||||
$tmpa = dbFetchCell("SELECT attrib_value FROM devices_attribs WHERE attrib_type = 'override_sysContact_string' AND device_id = ?", array($result["device_id"]));
|
||||
} else {
|
||||
|
@ -310,11 +308,11 @@ function GetContacts($results)
|
|||
if (empty($user['level'])) {
|
||||
$user['level'] = LegacyAuth::get()->getUserlevel($user['username']);
|
||||
}
|
||||
if ($config['alert']['globals'] && ( $user['level'] >= 5 && $user['level'] < 10 )) {
|
||||
if (Config::get('alert.globals') && ($user['level'] >= 5 && $user['level'] < 10)) {
|
||||
$contacts[$user['email']] = $user['realname'];
|
||||
} elseif ($config['alert']['admins'] && $user['level'] == 10) {
|
||||
} elseif (Config::get('alert.admins') && $user['level'] == 10) {
|
||||
$contacts[$user['email']] = $user['realname'];
|
||||
} elseif ($config['alert']['users'] == true && in_array($user['user_id'], $uids)) {
|
||||
} elseif (Config::get('alert.users') == true && in_array($user['user_id'], $uids)) {
|
||||
$contacts[$user['email']] = $user['realname'];
|
||||
}
|
||||
}
|
||||
|
@ -344,13 +342,13 @@ function GetContacts($results)
|
|||
}
|
||||
|
||||
# Copy all email alerts to default contact if configured.
|
||||
if (!isset($tmp_contacts[$config['alert']['default_mail']]) && ($config['alert']['default_copy'])) {
|
||||
$tmp_contacts[$config['alert']['default_mail']] = '';
|
||||
if (!isset($tmp_contacts[Config::get('alert.default_mail')]) && (Config::get('alert.default_copy'))) {
|
||||
$tmp_contacts[Config::get('alert.default_mail')] = '';
|
||||
}
|
||||
|
||||
# Send email to default contact if no other contact found
|
||||
if ((count($tmp_contacts) == 0) && ($config['alert']['default_if_none']) && (!empty($config['alert']['default_mail']))) {
|
||||
$tmp_contacts[$config['alert']['default_mail']] = '';
|
||||
if ((count($tmp_contacts) == 0) && (Config::get('alert.default_if_none')) && (!empty(Config::get('alert.default_mail')))) {
|
||||
$tmp_contacts[Config::get('alert.default_mail')] = '';
|
||||
}
|
||||
|
||||
return $tmp_contacts;
|
||||
|
@ -575,12 +573,11 @@ function IsRuleValid($device_id, $rule)
|
|||
*/
|
||||
function IssueAlert($alert)
|
||||
{
|
||||
global $config;
|
||||
if (dbFetchCell('SELECT attrib_value FROM devices_attribs WHERE attrib_type = "disable_notify" && device_id = ?', array($alert['device_id'])) == '1') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($config['alert']['fixed-contacts'] == false) {
|
||||
if (Config::get('alert.fixed-contacts') == false) {
|
||||
if (empty($alert['query'])) {
|
||||
$alert['query'] = GenSQL($alert['rule'], $alert['builder']);
|
||||
}
|
||||
|
@ -703,7 +700,6 @@ function loadAlerts($where)
|
|||
*/
|
||||
function RunAlerts()
|
||||
{
|
||||
global $config;
|
||||
foreach (loadAlerts('alerts.state != 2 && alerts.open = 1') as $alert) {
|
||||
$noiss = false;
|
||||
$noacc = false;
|
||||
|
@ -723,7 +719,7 @@ function RunAlerts()
|
|||
if (!empty($rextra['count']) && empty($rextra['interval'])) {
|
||||
// This check below is for compat-reasons
|
||||
if (!empty($rextra['delay'])) {
|
||||
if ((time() - strtotime($alert['time_logged']) + $config['alert']['tolerance_window']) < $rextra['delay'] || (!empty($alert['details']['delay']) && (time() - $alert['details']['delay'] + $config['alert']['tolerance_window']) < $rextra['delay'])) {
|
||||
if ((time() - strtotime($alert['time_logged']) + Config::get('alert.tolerance_window')) < $rextra['delay'] || (!empty($alert['details']['delay']) && (time() - $alert['details']['delay'] + Config::get('alert.tolerance_window')) < $rextra['delay'])) {
|
||||
continue;
|
||||
} else {
|
||||
$alert['details']['delay'] = time();
|
||||
|
@ -741,12 +737,12 @@ function RunAlerts()
|
|||
}
|
||||
} else {
|
||||
// This is the new way
|
||||
if (!empty($rextra['delay']) && (time() - strtotime($alert['time_logged']) + $config['alert']['tolerance_window']) < $rextra['delay']) {
|
||||
if (!empty($rextra['delay']) && (time() - strtotime($alert['time_logged']) + Config::get('alert.tolerance_window')) < $rextra['delay']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!empty($rextra['interval'])) {
|
||||
if (!empty($alert['details']['interval']) && (time() - $alert['details']['interval'] + $config['alert']['tolerance_window']) < $rextra['interval']) {
|
||||
if (!empty($alert['details']['interval']) && (time() - $alert['details']['interval'] + Config::get('alert.tolerance_window')) < $rextra['interval']) {
|
||||
continue;
|
||||
} else {
|
||||
$alert['details']['interval'] = time();
|
||||
|
|
|
@ -116,7 +116,7 @@ if ($enabled == 1) {
|
|||
|
||||
$post = curl_init();
|
||||
set_curl_proxy($post);
|
||||
curl_setopt($post, CURLOPT_URL, $config['callback_post']);
|
||||
curl_setopt($post, CURLOPT_URL, \LibreNMS\Config::get('callback_post'));
|
||||
curl_setopt($post, CURLOPT_POST, count($submit));
|
||||
curl_setopt($post, CURLOPT_POSTFIELDS, $fields);
|
||||
curl_setopt($post, CURLOPT_RETURNTRANSFER, 1);
|
||||
|
@ -127,7 +127,7 @@ if ($enabled == 1) {
|
|||
|
||||
$clear = curl_init();
|
||||
set_curl_proxy($clear);
|
||||
curl_setopt($clear, CURLOPT_URL, $config['callback_clear']);
|
||||
curl_setopt($clear, CURLOPT_URL, \LibreNMS\Config::get('callback_clear'));
|
||||
curl_setopt($clear, CURLOPT_POST, count($clear));
|
||||
curl_setopt($clear, CURLOPT_POSTFIELDS, $fields);
|
||||
curl_setopt($clear, CURLOPT_RETURNTRANSFER, 1);
|
||||
|
|
|
@ -200,10 +200,8 @@ function get_sensor_rrd($device, $sensor)
|
|||
|
||||
function get_sensor_rrd_name($device, $sensor)
|
||||
{
|
||||
global $config;
|
||||
|
||||
# For IPMI, sensors tend to change order, and there is no index, so we prefer to use the description as key here.
|
||||
if ($config['os'][$device['os']]['sensor_descr'] || $sensor['poller_type'] == "ipmi") {
|
||||
if (Config::getOsSetting($device['os'], 'sensor_descr') || $sensor['poller_type'] == "ipmi") {
|
||||
return array('sensor', $sensor['sensor_class'], $sensor['sensor_type'], $sensor['sensor_descr']);
|
||||
} else {
|
||||
return array('sensor', $sensor['sensor_class'], $sensor['sensor_type'], $sensor['sensor_index']);
|
||||
|
@ -758,13 +756,11 @@ function is_client_authorized($clientip)
|
|||
*/
|
||||
function get_graph_subtypes($type, $device = null)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$type = basename($type);
|
||||
$types = array();
|
||||
|
||||
// find the subtypes defined in files
|
||||
if ($handle = opendir($config['install_dir'] . "/includes/html/graphs/$type/")) {
|
||||
if ($handle = opendir(Config::get('install_dir') . "/includes/html/graphs/$type/")) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if ($file != "." && $file != ".." && $file != "auth.inc.php" && strstr($file, ".inc.php")) {
|
||||
$types[] = str_replace(".inc.php", "", $file);
|
||||
|
@ -777,8 +773,8 @@ function get_graph_subtypes($type, $device = null)
|
|||
// find the MIB subtypes
|
||||
$graphs = get_device_graphs($device);
|
||||
|
||||
foreach ($config['graph_types'] as $type => $unused1) {
|
||||
foreach ($config['graph_types'][$type] as $subtype => $unused2) {
|
||||
foreach (Config::get('graph_types') as $type => $unused1) {
|
||||
foreach (Config::get("graph_types.$type") as $subtype => $unused2) {
|
||||
if (is_mib_graph($type, $subtype) && in_array($subtype, $graphs)) {
|
||||
$types[] = $subtype;
|
||||
}
|
||||
|
@ -798,9 +794,8 @@ function get_device_graphs($device)
|
|||
|
||||
function get_smokeping_files($device)
|
||||
{
|
||||
global $config;
|
||||
$smokeping_files = array();
|
||||
if (isset($config['smokeping']['dir'])) {
|
||||
if (Config::has('smokeping.dir')) {
|
||||
$smokeping_dir = generate_smokeping_file($device);
|
||||
if ($handle = opendir($smokeping_dir)) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
|
@ -814,8 +809,8 @@ function get_smokeping_files($device)
|
|||
} else {
|
||||
$target = str_replace('.rrd', '', $file);
|
||||
$target = str_replace('_', '.', $target);
|
||||
$smokeping_files['in'][$target][$config['own_hostname']] = $file;
|
||||
$smokeping_files['out'][$config['own_hostname']][$target] = $file;
|
||||
$smokeping_files['in'][$target][Config::get('own_hostname')] = $file;
|
||||
$smokeping_files['out'][Config::get('own_hostname')][$target] = $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -828,11 +823,10 @@ function get_smokeping_files($device)
|
|||
|
||||
function generate_smokeping_file($device, $file = '')
|
||||
{
|
||||
global $config;
|
||||
if ($config['smokeping']['integration'] === true) {
|
||||
return $config['smokeping']['dir'] .'/'. $device['type'] .'/' . $file;
|
||||
if (Config::get('smokeping.integration') === true) {
|
||||
return Config::get('smokeping.dir') . '/' . $device['type'] . '/' . $file;
|
||||
} else {
|
||||
return $config['smokeping']['dir'] . '/' . $file;
|
||||
return Config::get('smokeping.dir') . '/' . $file;
|
||||
}
|
||||
} // generate_smokeping_file
|
||||
|
||||
|
@ -861,7 +855,7 @@ function is_mib_poller_enabled($device)
|
|||
{
|
||||
$val = get_dev_attrib($device, 'poll_mib');
|
||||
if ($val == null) {
|
||||
return is_module_enabled('poller', 'mib');
|
||||
return Config::get("poller_modules.mib", false);
|
||||
}
|
||||
return $val;
|
||||
} // is_mib_poller_enabled
|
||||
|
@ -1032,20 +1026,6 @@ function can_ping_device($attribs)
|
|||
} // end can_ping_device
|
||||
|
||||
|
||||
/*
|
||||
* @return true if the requested module type & name is globally enabled
|
||||
*/
|
||||
function is_module_enabled($type, $module)
|
||||
{
|
||||
global $config;
|
||||
if (isset($config[$type.'_modules'][$module])) {
|
||||
return $config[$type.'_modules'][$module] == 1;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} // is_module_enabled
|
||||
|
||||
|
||||
/*
|
||||
* @return true if every string in $arr begins with $str
|
||||
*/
|
||||
|
@ -1089,7 +1069,7 @@ function print_mib_poller_disabled()
|
|||
{
|
||||
echo '<h4>MIB polling is not enabled</h4>
|
||||
<p>
|
||||
Set <code>$config[\'poller_modules\'][\'mib\'] = 1;</code> in <code>config.php</code> or enable for this device specifically to enable.
|
||||
Set \'poller_modules.mib\' in your config or enable for this device specifically to enable.
|
||||
</p>';
|
||||
} // print_mib_poller_disabled
|
||||
|
||||
|
@ -1135,17 +1115,16 @@ function parse_location($location)
|
|||
*/
|
||||
function version_info($remote = false)
|
||||
{
|
||||
global $config;
|
||||
$version = \LibreNMS\Util\Version::get();
|
||||
$output = [
|
||||
'local_ver' => $version->local(),
|
||||
];
|
||||
if (Git::repoPresent() && Git::binaryExists()) {
|
||||
if ($remote === true && $config['update_channel'] == 'master') {
|
||||
if ($remote === true && Config::get('update_channel') == 'master') {
|
||||
$api = curl_init();
|
||||
set_curl_proxy($api);
|
||||
curl_setopt($api, CURLOPT_USERAGENT, 'LibreNMS');
|
||||
curl_setopt($api, CURLOPT_URL, $config['github_api'].'commits/master');
|
||||
curl_setopt($api, CURLOPT_URL, Config::get('github_api') . 'commits/master');
|
||||
curl_setopt($api, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($api, CURLOPT_TIMEOUT, 5);
|
||||
curl_setopt($api, CURLOPT_TIMEOUT_MS, 5000);
|
||||
|
@ -1161,10 +1140,10 @@ function version_info($remote = false)
|
|||
$output['php_ver'] = phpversion();
|
||||
$output['mysql_ver'] = dbIsConnected() ? dbFetchCell('SELECT version()') : '?';
|
||||
$output['rrdtool_ver'] = str_replace('1.7.01.7.0', '1.7.0', implode(' ', array_slice(explode(' ', shell_exec(
|
||||
($config['rrdtool'] ?: 'rrdtool') . ' --version |head -n1'
|
||||
Config::get('rrdtool', 'rrdtool') . ' --version |head -n1'
|
||||
)), 1, 1)));
|
||||
$output['netsnmp_ver'] = str_replace('version: ', '', rtrim(shell_exec(
|
||||
($config['snmpget'] ?: 'snmpget').' --version 2>&1'
|
||||
Config::get('snmpget', 'snmpget') . ' --version 2>&1'
|
||||
)));
|
||||
|
||||
return $output;
|
||||
|
@ -1534,40 +1513,35 @@ function display($value, $purifier_config = [])
|
|||
*/
|
||||
function load_os(&$device)
|
||||
{
|
||||
global $config;
|
||||
|
||||
if (!isset($device['os'])) {
|
||||
d_echo("No OS to load\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isset($config['os'][$device['os']]['definition_loaded'])) {
|
||||
if (!Config::get("os.{$device['os']}.definition_loaded")) {
|
||||
$tmp_os = Symfony\Component\Yaml\Yaml::parse(
|
||||
file_get_contents($config['install_dir'] . '/includes/definitions/' . $device['os'] . '.yaml')
|
||||
file_get_contents(Config::get('install_dir') . '/includes/definitions/' . $device['os'] . '.yaml')
|
||||
);
|
||||
|
||||
if (isset($config['os'][$device['os']])) {
|
||||
$config['os'][$device['os']] = array_replace_recursive($tmp_os, $config['os'][$device['os']]);
|
||||
} else {
|
||||
$config['os'][$device['os']] = $tmp_os;
|
||||
}
|
||||
Config::set("os.{$device['os']}", array_replace_recursive($tmp_os, Config::get("os.{$device['os']}", [])));
|
||||
}
|
||||
|
||||
// Set type to a predefined type for the OS if it's not already set
|
||||
if ((!isset($device['attribs']['override_device_type']) && $device['attribs']['override_device_type'] != 1) && $config['os'][$device['os']]['type'] != $device['type']) {
|
||||
log_event('Device type changed ' . $device['type'] . ' => ' . $config['os'][$device['os']]['type'], $device, 'system', 3);
|
||||
$device['type'] = $config['os'][$device['os']]['type'];
|
||||
dbUpdate(array('type' => $device['type']), 'devices', 'device_id=?', array($device['device_id']));
|
||||
d_echo("Device type changed to " . $device['type'] . "!\n");
|
||||
$loaded_os_type = Config::get("os.{$device['os']}.type");
|
||||
if ((!isset($device['attribs']['override_device_type']) && $device['attribs']['override_device_type'] != 1) && $loaded_os_type != $device['type']) {
|
||||
log_event('Device type changed ' . $device['type'] . ' => ' . $loaded_os_type, $device, 'system', 3);
|
||||
$device['type'] = $loaded_os_type;
|
||||
dbUpdate(['type' => $loaded_os_type], 'devices', 'device_id=?', [$device['device_id']]);
|
||||
d_echo("Device type changed to $loaded_os_type!\n");
|
||||
}
|
||||
|
||||
if ($config['os'][$device['os']]['group']) {
|
||||
$device['os_group'] = $config['os'][$device['os']]['group'];
|
||||
if ($os_group = Config::get("os.{$device['os']}.group")) {
|
||||
$device['os_group'] = $os_group;
|
||||
} else {
|
||||
unset($device['os_group']);
|
||||
}
|
||||
|
||||
$config['os'][$device['os']]['definition_loaded'] = true;
|
||||
Config::set("os.{$device['os']}.definition_loaded", true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1579,10 +1553,10 @@ function load_os(&$device)
|
|||
*/
|
||||
function load_all_os($existing = false, $cached = true)
|
||||
{
|
||||
global $config;
|
||||
$cache_file = $config['install_dir'] . '/cache/os_defs.cache';
|
||||
$install_dir = Config::get('install_dir');
|
||||
$cache_file = $install_dir . '/cache/os_defs.cache';
|
||||
|
||||
if ($cached && is_file($cache_file) && (time() - filemtime($cache_file) < $config['os_def_cache_time'])) {
|
||||
if ($cached && is_file($cache_file) && (time() - filemtime($cache_file) < Config::get('os_def_cache_time'))) {
|
||||
// Cached
|
||||
$os_defs = unserialize(file_get_contents($cache_file));
|
||||
|
||||
|
@ -1591,26 +1565,22 @@ function load_all_os($existing = false, $cached = true)
|
|||
$os_defs = array_diff_key($os_defs, dbFetchColumn('SELECT DISTINCT(`os`) FROM `devices`'));
|
||||
}
|
||||
|
||||
$config['os'] = array_replace_recursive($os_defs, $config['os']);
|
||||
Config::set('os', array_replace_recursive($os_defs, Config::get('os')));
|
||||
} else {
|
||||
// load from yaml
|
||||
if ($existing) {
|
||||
$os_list = array_map(function ($os) use ($config) {
|
||||
return $config['install_dir'] . '/includes/definitions/'. $os . '.yaml';
|
||||
$os_list = array_map(function ($os) use ($install_dir) {
|
||||
return $install_dir . '/includes/definitions/' . $os . '.yaml';
|
||||
}, dbFetchColumn('SELECT DISTINCT(`os`) FROM `devices`'));
|
||||
} else {
|
||||
$os_list = glob($config['install_dir'].'/includes/definitions/*.yaml');
|
||||
$os_list = glob($install_dir . '/includes/definitions/*.yaml');
|
||||
}
|
||||
|
||||
foreach ($os_list as $file) {
|
||||
if (is_readable($file)) {
|
||||
$tmp = Symfony\Component\Yaml\Yaml::parse(file_get_contents($file));
|
||||
|
||||
if (isset($config['os'][$tmp['os']])) {
|
||||
$config['os'][$tmp['os']] = array_replace_recursive($tmp, $config['os'][$tmp['os']]);
|
||||
} else {
|
||||
$config['os'][$tmp['os']] = $tmp;
|
||||
}
|
||||
Config::set("os.{$tmp['os']}", array_replace_recursive($tmp, Config::get("os.{$tmp['os']}", [])));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1631,7 +1601,7 @@ function update_os_cache($force = false)
|
|||
d_echo('Updating os_def.cache... ');
|
||||
|
||||
// remove previously cached os settings and replace with user settings
|
||||
$config = array('os' => array()); // local $config variable, not global
|
||||
$config = ['os' => []]; // local $config variable, not global
|
||||
include "$install_dir/config.php";
|
||||
Config::set('os', $config['os']);
|
||||
|
||||
|
@ -1709,13 +1679,11 @@ function set_numeric($value, $default = 0)
|
|||
|
||||
function get_vm_parent_id($device)
|
||||
{
|
||||
global $config;
|
||||
|
||||
if (empty($device['hostname'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return dbFetchCell("SELECT `device_id` FROM `vminfo` WHERE `vmwVmDisplayName` = ? OR `vmwVmDisplayName` = ?", array($device['hostname'],$device['hostname'].'.'.$config['mydomain']));
|
||||
return dbFetchCell("SELECT `device_id` FROM `vminfo` WHERE `vmwVmDisplayName` = ? OR `vmwVmDisplayName` = ?", [$device['hostname'], $device['hostname'] . '.' . Config::get('mydomain')]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -30,7 +30,7 @@ function dbIsConnected()
|
|||
|
||||
/**
|
||||
* Connect to the database.
|
||||
* Will use global $config variables if they are not sent: db_host, db_user, db_pass, db_name, db_port, db_socket
|
||||
* Will use global config variables if they are not sent: db_host, db_user, db_pass, db_name, db_port, db_socket
|
||||
*
|
||||
* @param string $db_host
|
||||
* @param string $db_user
|
||||
|
|
|
@ -369,12 +369,20 @@ $config['network_map_legend'] = array(
|
|||
'90' => '#d12300',
|
||||
'95' => '#cc0000',
|
||||
'100' => '#cc0000',
|
||||
'di.edge' => '#dddddd88',
|
||||
'di.border' => '#cccccc',
|
||||
'di.node' => '#eeeeee',
|
||||
'dn.edge' => '#ff777788',
|
||||
'dn.border' => '#ff5555',
|
||||
'dn.node' => '#ffdddd',
|
||||
[
|
||||
'di' => [
|
||||
'edge' => '#dddddd88',
|
||||
'border' => '#cccccc',
|
||||
'node' => '#eeeeee',
|
||||
]
|
||||
],
|
||||
[
|
||||
'dn' => [
|
||||
'edge' => '#ff777788',
|
||||
'border' => '#ff5555',
|
||||
'node' => '#ffdddd',
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
// Default mini graph time options:
|
||||
|
|
|
@ -39,7 +39,7 @@ if ($device['os'] == 'junos') {
|
|||
} elseif ($device['os'] == 'timos') {
|
||||
$entity_array = array();
|
||||
echo 'tmnxHwObjs';
|
||||
$entity_array = snmpwalk_cache_multi_oid($device, 'tmnxHwObjs', $entity_array, 'TIMETRA-CHASSIS-MIB', '+'.$config['mib_dir'].'/aos:'.$config['mib_dir']);
|
||||
$entity_array = snmpwalk_cache_multi_oid($device, 'tmnxHwObjs', $entity_array, 'TIMETRA-CHASSIS-MIB', 'nokia');
|
||||
} else {
|
||||
$entity_array = array();
|
||||
echo ' entPhysicalEntry';
|
||||
|
|
|
@ -153,9 +153,7 @@ function parse_modules($type, $options)
|
|||
|
||||
function logfile($string)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$fd = fopen($config['log_file'], 'a');
|
||||
$fd = fopen(Config::get('log_file'), 'a');
|
||||
fputs($fd, $string . "\n");
|
||||
fclose($fd);
|
||||
}
|
||||
|
@ -338,10 +336,9 @@ function percent_colour($perc)
|
|||
// Returns the last in/out errors value in RRD
|
||||
function interface_errors($rrd_file, $period = '-1d')
|
||||
{
|
||||
global $config;
|
||||
$errors = array();
|
||||
|
||||
$cmd = $config['rrdtool']." fetch -s $period -e -300s $rrd_file AVERAGE | grep : | cut -d\" \" -f 4,5";
|
||||
$cmd = Config::get('rrdtool') . " fetch -s $period -e -300s $rrd_file AVERAGE | grep : | cut -d\" \" -f 4,5";
|
||||
$data = trim(shell_exec($cmd));
|
||||
$in_errors = 0;
|
||||
$out_errors = 0;
|
||||
|
@ -429,7 +426,7 @@ function renamehost($id, $new, $source = 'console')
|
|||
|
||||
function delete_device($id)
|
||||
{
|
||||
global $config, $debug;
|
||||
global $debug;
|
||||
|
||||
if (isCli() === false) {
|
||||
ignore_user_abort(true);
|
||||
|
@ -507,8 +504,6 @@ function delete_device($id)
|
|||
*/
|
||||
function addHost($host, $snmp_version = '', $port = '161', $transport = 'udp', $poller_group = '0', $force_add = false, $port_assoc_mode = 'ifIndex', $additional = array())
|
||||
{
|
||||
global $config;
|
||||
|
||||
// Test Database Exists
|
||||
if (host_exists($host)) {
|
||||
throw new HostExistsException("Already have host $host");
|
||||
|
@ -520,7 +515,7 @@ function addHost($host, $snmp_version = '', $port = '161', $transport = 'udp', $
|
|||
}
|
||||
|
||||
// check if we have the host by IP
|
||||
if ($config['addhost_alwayscheckip'] === true) {
|
||||
if (Config::get('addhost_alwayscheckip') === true) {
|
||||
$ip = gethostbyname($host);
|
||||
} else {
|
||||
$ip = $host;
|
||||
|
@ -558,7 +553,7 @@ function addHost($host, $snmp_version = '', $port = '161', $transport = 'udp', $
|
|||
foreach ($snmpvers as $snmpver) {
|
||||
if ($snmpver === "v3") {
|
||||
// Try each set of parameters from config
|
||||
foreach ($config['snmp']['v3'] as $v3) {
|
||||
foreach (Config::get('snmp.v3') as $v3) {
|
||||
$device = deviceArray($host, null, $snmpver, $port, $transport, $v3, $port_assoc_mode);
|
||||
if ($force_add === true || isSNMPable($device)) {
|
||||
return createHost($host, null, $snmpver, $port, $transport, $v3, $poller_group, $port_assoc_mode, $force_add);
|
||||
|
@ -568,7 +563,7 @@ function addHost($host, $snmp_version = '', $port = '161', $transport = 'udp', $
|
|||
}
|
||||
} elseif ($snmpver === "v2c" || $snmpver === "v1") {
|
||||
// try each community from config
|
||||
foreach ($config['snmp']['community'] as $community) {
|
||||
foreach (Config::get('snmp.community') as $community) {
|
||||
$device = deviceArray($host, $community, $snmpver, $port, $transport, null, $port_assoc_mode);
|
||||
|
||||
if ($force_add === true || isSNMPable($device)) {
|
||||
|
@ -626,8 +621,6 @@ function formatUptime($diff, $format = "long")
|
|||
|
||||
function isSNMPable($device)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$pos = snmp_check($device);
|
||||
if ($pos === true) {
|
||||
return true;
|
||||
|
@ -687,9 +680,9 @@ function getpollergroup($poller_group = '0')
|
|||
$poller_group_array=explode(',', $poller_group);
|
||||
return getpollergroup($poller_group_array[0]);
|
||||
} else {
|
||||
if ($config['distributed_poller_group']) {
|
||||
if (Config::get('distributed_poller_group')) {
|
||||
//If not use the poller's group from the config
|
||||
return getpollergroup($config['distributed_poller_group']);
|
||||
return getpollergroup(Config::get('distributed_poller_group'));
|
||||
} else {
|
||||
//If all else fails use default
|
||||
return '0';
|
||||
|
@ -911,42 +904,41 @@ function parse_email($emails)
|
|||
|
||||
function send_mail($emails, $subject, $message, $html = false)
|
||||
{
|
||||
global $config;
|
||||
if (is_array($emails) || ($emails = parse_email($emails))) {
|
||||
d_echo("Attempting to email $subject to: " . implode('; ', array_keys($emails)) . PHP_EOL);
|
||||
$mail = new PHPMailer(true);
|
||||
try {
|
||||
$mail->Hostname = php_uname('n');
|
||||
|
||||
foreach (parse_email($config['email_from']) as $from => $from_name) {
|
||||
foreach (parse_email(Config::get('email_from')) as $from => $from_name) {
|
||||
$mail->setFrom($from, $from_name);
|
||||
}
|
||||
foreach ($emails as $email => $email_name) {
|
||||
$mail->addAddress($email, $email_name);
|
||||
}
|
||||
$mail->Subject = $subject;
|
||||
$mail->XMailer = $config['project_name_version'];
|
||||
$mail->XMailer = Config::get('project_name_version');
|
||||
$mail->CharSet = 'utf-8';
|
||||
$mail->WordWrap = 76;
|
||||
$mail->Body = $message;
|
||||
if ($html) {
|
||||
$mail->isHTML(true);
|
||||
}
|
||||
switch (strtolower(trim($config['email_backend']))) {
|
||||
switch (strtolower(trim(Config::get('email_backend')))) {
|
||||
case 'sendmail':
|
||||
$mail->Mailer = 'sendmail';
|
||||
$mail->Sendmail = $config['email_sendmail_path'];
|
||||
$mail->Sendmail = Config::get('email_sendmail_path');
|
||||
break;
|
||||
case 'smtp':
|
||||
$mail->isSMTP();
|
||||
$mail->Host = $config['email_smtp_host'];
|
||||
$mail->Timeout = $config['email_smtp_timeout'];
|
||||
$mail->SMTPAuth = $config['email_smtp_auth'];
|
||||
$mail->SMTPSecure = $config['email_smtp_secure'];
|
||||
$mail->Port = $config['email_smtp_port'];
|
||||
$mail->Username = $config['email_smtp_username'];
|
||||
$mail->Password = $config['email_smtp_password'];
|
||||
$mail->SMTPAutoTLS= $config['email_auto_tls'];
|
||||
$mail->Host = Config::get('email_smtp_host');
|
||||
$mail->Timeout = Config::get('email_smtp_timeout');
|
||||
$mail->SMTPAuth = Config::get('email_smtp_auth');
|
||||
$mail->SMTPSecure = Config::get('email_smtp_secure');
|
||||
$mail->Port = Config::get('email_smtp_port');
|
||||
$mail->Username = Config::get('email_smtp_username');
|
||||
$mail->Password = Config::get('email_smtp_password');
|
||||
$mail->SMTPAutoTLS = Config::get('email_auto_tls');
|
||||
$mail->SMTPDebug = false;
|
||||
break;
|
||||
default:
|
||||
|
@ -996,18 +988,18 @@ function isHexString($str)
|
|||
# Include all .inc.php files in $dir
|
||||
function include_dir($dir, $regex = "")
|
||||
{
|
||||
global $device, $config, $valid;
|
||||
global $device, $valid;
|
||||
|
||||
if ($regex == "") {
|
||||
$regex = "/\.inc\.php$/";
|
||||
}
|
||||
|
||||
if ($handle = opendir($config['install_dir'] . '/' . $dir)) {
|
||||
if ($handle = opendir(Config::get('install_dir') . '/' . $dir)) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if (filetype($config['install_dir'] . '/' . $dir . '/' . $file) == 'file' && preg_match($regex, $file)) {
|
||||
d_echo("Including: " . $config['install_dir'] . '/' . $dir . '/' . $file . "\n");
|
||||
if (filetype(Config::get('install_dir') . '/' . $dir . '/' . $file) == 'file' && preg_match($regex, $file)) {
|
||||
d_echo("Including: " . Config::get('install_dir') . '/' . $dir . '/' . $file . "\n");
|
||||
|
||||
include($config['install_dir'] . '/' . $dir . '/' . $file);
|
||||
include(Config::get('install_dir') . '/' . $dir . '/' . $file);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1119,17 +1111,14 @@ function port_fill_missing(&$port, $device)
|
|||
|
||||
function scan_new_plugins()
|
||||
{
|
||||
|
||||
global $config;
|
||||
|
||||
$installed = 0; // Track how many plugins we install.
|
||||
|
||||
if (file_exists($config['plugin_dir'])) {
|
||||
$plugin_files = scandir($config['plugin_dir']);
|
||||
if (file_exists(Config::get('plugin_dir'))) {
|
||||
$plugin_files = scandir(Config::get('plugin_dir'));
|
||||
foreach ($plugin_files as $name) {
|
||||
if (is_dir($config['plugin_dir'].'/'.$name)) {
|
||||
if (is_dir(Config::get('plugin_dir') . '/' . $name)) {
|
||||
if ($name != '.' && $name != '..') {
|
||||
if (is_file($config['plugin_dir'].'/'.$name.'/'.$name.'.php') && is_file($config['plugin_dir'].'/'.$name.'/'.$name.'.inc.php')) {
|
||||
if (is_file(Config::get('plugin_dir') . '/' . $name . '/' . $name . '.php') && is_file(Config::get('plugin_dir') . '/' . $name . '/' . $name . '.inc.php')) {
|
||||
$plugin_id = dbFetchRow("SELECT `plugin_id` FROM `plugins` WHERE `plugin_name` = '$name'");
|
||||
if (empty($plugin_id)) {
|
||||
if (dbInsert(array('plugin_name' => $name, 'plugin_active' => '0'), 'plugins')) {
|
||||
|
@ -1147,8 +1136,6 @@ function scan_new_plugins()
|
|||
|
||||
function validate_device_id($id)
|
||||
{
|
||||
|
||||
global $config;
|
||||
if (empty($id) || !is_numeric($id)) {
|
||||
$return = false;
|
||||
} else {
|
||||
|
@ -1334,16 +1321,14 @@ function set_curl_proxy($curl)
|
|||
*/
|
||||
function get_proxy()
|
||||
{
|
||||
global $config;
|
||||
|
||||
if (getenv('http_proxy')) {
|
||||
return getenv('http_proxy');
|
||||
} elseif (getenv('https_proxy')) {
|
||||
return getenv('https_proxy');
|
||||
} elseif (isset($config['callback_proxy'])) {
|
||||
return $config['callback_proxy'];
|
||||
} elseif (isset($config['http_proxy'])) {
|
||||
return $config['http_proxy'];
|
||||
} elseif ($callback_proxy = Config::get('callback_proxy')) {
|
||||
return $callback_proxy;
|
||||
} elseif ($http_proxy = Config::get('http_proxy')) {
|
||||
return $http_proxy;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1533,17 +1518,15 @@ function snmpTransportToAddressFamily($transport)
|
|||
*/
|
||||
function host_exists($hostname, $sysName = null)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$query = "SELECT COUNT(*) FROM `devices` WHERE `hostname`=?";
|
||||
$params = array($hostname);
|
||||
|
||||
if (!empty($sysName) && !$config['allow_duplicate_sysName']) {
|
||||
if (!empty($sysName) && !Config::get('allow_duplicate_sysName')) {
|
||||
$query .= " OR `sysName`=?";
|
||||
$params[] = $sysName;
|
||||
|
||||
if (!empty($config['mydomain'])) {
|
||||
$full_sysname = rtrim($sysName, '.') . '.' . $config['mydomain'];
|
||||
if (!empty(Config::get('mydomain'))) {
|
||||
$full_sysname = rtrim($sysName, '.') . '.' . Config::get('mydomain');
|
||||
$query .= " OR `sysName`=?";
|
||||
$params[] = $full_sysname;
|
||||
}
|
||||
|
@ -1553,11 +1536,8 @@ function host_exists($hostname, $sysName = null)
|
|||
|
||||
function oxidized_reload_nodes()
|
||||
{
|
||||
|
||||
global $config;
|
||||
|
||||
if ($config['oxidized']['enabled'] === true && $config['oxidized']['reload_nodes'] === true && isset($config['oxidized']['url'])) {
|
||||
$oxidized_reload_url = $config['oxidized']['url'] . '/reload.json';
|
||||
if (Config::get('oxidized.enabled') === true && Config::get('oxidized.reload_nodes') === true && Config::has('oxidized.url')) {
|
||||
$oxidized_reload_url = Config::get('oxidized.url') . '/reload.json';
|
||||
$ch = curl_init($oxidized_reload_url);
|
||||
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
|
||||
|
@ -1617,9 +1597,8 @@ function dnslookup($device, $type = false, $return = false)
|
|||
|
||||
function rrdtest($path, &$stdOutput, &$stdError)
|
||||
{
|
||||
global $config;
|
||||
//rrdtool info <escaped rrd path>
|
||||
$command = $config['rrdtool'].' info '.escapeshellarg($path);
|
||||
$command = Config::get('rrdtool') . ' info ' . escapeshellarg($path);
|
||||
$process = proc_open(
|
||||
$command,
|
||||
array (
|
||||
|
@ -1762,8 +1741,7 @@ function delta_to_bits($delta, $period)
|
|||
|
||||
function report_this($message)
|
||||
{
|
||||
global $config;
|
||||
return '<h2>'.$message.' Please <a href="'.$config['project_issues'].'">report this</a> to the '.$config['project_name'].' developers.</h2>';
|
||||
return '<h2>' . $message . ' Please <a href="' . Config::get('project_issues') . '">report this</a> to the ' . Config::get('project_name') . ' developers.</h2>';
|
||||
}//end report_this()
|
||||
|
||||
function hytera_h2f($number, $nd)
|
||||
|
@ -2248,8 +2226,7 @@ function update_device_logo(&$device)
|
|||
*/
|
||||
function cache_peeringdb()
|
||||
{
|
||||
global $config;
|
||||
if ($config['peeringdb']['enabled'] === true) {
|
||||
if (Config::get('peeringdb.enabled') === true) {
|
||||
$peeringdb_url = 'https://peeringdb.com/api';
|
||||
// We cache for 71 hours
|
||||
$cached = dbFetchCell("SELECT count(*) FROM `pdb_ix` WHERE (UNIX_TIMESTAMP() - timestamp) < 255600");
|
||||
|
@ -2413,10 +2390,8 @@ function dump_db_schema()
|
|||
*/
|
||||
function get_schema_list()
|
||||
{
|
||||
global $config;
|
||||
|
||||
// glob returns an array sorted by filename
|
||||
$files = glob($config['install_dir'].'/sql-schema/*.sql');
|
||||
$files = glob(Config::get('install_dir') . '/sql-schema/*.sql');
|
||||
|
||||
// set the keys to the db schema version
|
||||
$files = array_reduce($files, function ($array, $file) {
|
||||
|
|
|
@ -14,10 +14,10 @@
|
|||
|
||||
function graphite_update($device, $measurement, $tags, $fields)
|
||||
{
|
||||
global $graphite, $config;
|
||||
global $graphite;
|
||||
if ($graphite != false) {
|
||||
$timestamp = time();
|
||||
$graphite_prefix = $config['graphite']['prefix'];
|
||||
$graphite_prefix = \LibreNMS\Config::get('graphite.prefix');
|
||||
// metrics will be built as prefix.hostname.measurement.field value timestamp
|
||||
// metric fields can not contain . as this is used by graphite as a field separator
|
||||
$hostname = preg_replace('/\./', '_', $device['hostname']);
|
||||
|
|
|
@ -123,8 +123,7 @@ function check_is_read()
|
|||
|
||||
function check_not_demo()
|
||||
{
|
||||
global $config;
|
||||
if ($config['api_demo'] == 1) {
|
||||
if (Config::get('api_demo') == 1) {
|
||||
api_error(500, 'This feature isn\'t available in the demo');
|
||||
}
|
||||
}
|
||||
|
@ -132,7 +131,6 @@ function check_not_demo()
|
|||
function get_graph_by_port_hostname()
|
||||
{
|
||||
// This will return a graph for a given port by the ifName
|
||||
global $config;
|
||||
$app = \Slim\Slim::getInstance();
|
||||
$router = $app->router()->getCurrentRoute()->getParams();
|
||||
$hostname = $router['hostname'];
|
||||
|
@ -209,7 +207,6 @@ function get_port_stats_by_port_hostname()
|
|||
function get_graph_generic_by_hostname()
|
||||
{
|
||||
// This will return a graph type given a device id.
|
||||
global $config;
|
||||
$app = \Slim\Slim::getInstance();
|
||||
$router = $app->router()->getCurrentRoute()->getParams();
|
||||
$hostname = $router['hostname'];
|
||||
|
@ -378,7 +375,6 @@ function add_device()
|
|||
|
||||
// This will add a device using the data passed encoded with json
|
||||
// FIXME: Execution flow through this function could be improved
|
||||
global $config;
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
|
||||
$additional = array();
|
||||
|
@ -392,7 +388,7 @@ function add_device()
|
|||
}
|
||||
|
||||
$hostname = $data['hostname'];
|
||||
$port = $data['port'] ? mres($data['port']) : $config['snmp']['port'];
|
||||
$port = $data['port'] ? mres($data['port']) : Config::get('snmp.port');
|
||||
$transport = $data['transport'] ? mres($data['transport']) : 'udp';
|
||||
$poller_group = $data['poller_group'] ? mres($data['poller_group']) : 0;
|
||||
$force_add = $data['force_add'] ? true : false;
|
||||
|
@ -406,7 +402,7 @@ function add_device()
|
|||
);
|
||||
} elseif ($data['version'] == 'v1' || $data['version'] == 'v2c') {
|
||||
if ($data['community']) {
|
||||
$config['snmp']['community'] = array($data['community']);
|
||||
Config::set('snmp.community', [$data['community']]);
|
||||
}
|
||||
|
||||
$snmpver = mres($data['version']);
|
||||
|
@ -420,7 +416,9 @@ function add_device()
|
|||
'cryptoalgo' => mres($data['cryptoalgo']),
|
||||
);
|
||||
|
||||
array_unshift($config['snmp']['v3'], $v3);
|
||||
$v3_config = Config::get('snmp.v3');
|
||||
array_unshift($v3_config, $v3);
|
||||
Config::set('snmp.v3', $v3_config);
|
||||
$snmpver = 'v3';
|
||||
} else {
|
||||
api_error(400, 'You haven\'t specified an SNMP version to use');
|
||||
|
@ -440,7 +438,6 @@ function del_device()
|
|||
check_is_admin();
|
||||
|
||||
// This will add a device using the data passed encoded with json
|
||||
global $config;
|
||||
$app = \Slim\Slim::getInstance();
|
||||
$router = $app->router()->getCurrentRoute()->getParams();
|
||||
$hostname = $router['hostname'];
|
||||
|
@ -503,12 +500,11 @@ function get_vlans()
|
|||
|
||||
function show_endpoints()
|
||||
{
|
||||
global $config;
|
||||
$app = \Slim\Slim::getInstance();
|
||||
$routes = $app->router()->getNamedRoutes();
|
||||
$output = array();
|
||||
foreach ($routes as $route) {
|
||||
$output[$route->getName()] = $config['base_url'].$route->getPattern();
|
||||
$output[$route->getName()] = Config::get('base_url') . $route->getPattern();
|
||||
}
|
||||
|
||||
$app->response->setStatus('200');
|
||||
|
@ -634,7 +630,6 @@ function list_ospf()
|
|||
function get_graph_by_portgroup()
|
||||
{
|
||||
check_is_read();
|
||||
global $config;
|
||||
$app = \Slim\Slim::getInstance();
|
||||
$router = $app->router()->getCurrentRoute()->getParams();
|
||||
$group = $router['group'] ?: '';
|
||||
|
@ -768,7 +763,6 @@ function delete_components()
|
|||
|
||||
function get_graphs()
|
||||
{
|
||||
global $config;
|
||||
$app = \Slim\Slim::getInstance();
|
||||
$router = $app->router()->getCurrentRoute()->getParams();
|
||||
$hostname = $router['hostname'];
|
||||
|
@ -787,7 +781,7 @@ function get_graphs()
|
|||
'name' => 'device_ping_perf',
|
||||
);
|
||||
foreach (dbFetchRows('SELECT * FROM device_graphs WHERE device_id = ? ORDER BY graph', array($device_id)) as $graph) {
|
||||
$desc = $config['graph_types']['device'][$graph['graph']]['descr'];
|
||||
$desc = Config::get("graph_types.device.{$graph['graph']}.descr");
|
||||
$graphs[] = array(
|
||||
'desc' => $desc,
|
||||
'name' => 'device_'.$graph['graph'],
|
||||
|
@ -1246,7 +1240,6 @@ function unmute_alert()
|
|||
|
||||
function get_inventory()
|
||||
{
|
||||
global $config;
|
||||
$app = \Slim\Slim::getInstance();
|
||||
$router = $app->router()->getCurrentRoute()->getParams();
|
||||
|
||||
|
@ -1282,14 +1275,13 @@ function get_inventory()
|
|||
function list_oxidized()
|
||||
{
|
||||
check_is_read();
|
||||
global $config;
|
||||
$app = \Slim\Slim::getInstance();
|
||||
$router = $app->router()->getCurrentRoute()->getParams();
|
||||
|
||||
$hostname = $router['hostname'];
|
||||
$devices = array();
|
||||
$device_types = "'".implode("','", $config['oxidized']['ignore_types'])."'";
|
||||
$device_os = "'".implode("','", $config['oxidized']['ignore_os'])."'";
|
||||
$device_types = "'" . implode("','", Config::get('oxidized.ignore_types')) . "'";
|
||||
$device_os = "'" . implode("','", Config::get('oxidized.ignore_os')) . "'";
|
||||
|
||||
$sql = '';
|
||||
$params = array();
|
||||
|
@ -1303,12 +1295,12 @@ function list_oxidized()
|
|||
$device['ip'] = inet6_ntop($device['ip']);
|
||||
|
||||
// Pre-populate the group with the default
|
||||
if ($config['oxidized']['group_support'] === true && !empty($config['oxidized']['default_group'])) {
|
||||
$device['group'] = $config['oxidized']['default_group'];
|
||||
if (Config::get('oxidized.group_support') === true && !empty(Config::get('oxidized.default_group'))) {
|
||||
$device['group'] = Config::get('oxidized.default_group');
|
||||
}
|
||||
foreach ($config['oxidized']['maps'] as $maps_column => $maps) {
|
||||
foreach (Config::get('oxidized.maps') as $maps_column => $maps) {
|
||||
// Based on Oxidized group support we can apply groups by setting group_support to true
|
||||
if ($maps_column == "group" && (!isset($config['oxidized']['group_support']) or $config['oxidized']['group_support'] !== true)) {
|
||||
if ($maps_column == "group" && Config::get('oxidized.group_support', true) !== true) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1347,7 +1339,6 @@ function list_oxidized()
|
|||
|
||||
function list_bills()
|
||||
{
|
||||
global $config;
|
||||
$app = \Slim\Slim::getInstance();
|
||||
$router = $app->router()->getCurrentRoute()->getParams();
|
||||
|
||||
|
@ -1422,7 +1413,6 @@ function list_bills()
|
|||
|
||||
function get_bill_graph()
|
||||
{
|
||||
global $config;
|
||||
$app = \Slim\Slim::getInstance();
|
||||
$router = $app->router()->getCurrentRoute()->getParams();
|
||||
$bill_id = mres($router['bill_id']);
|
||||
|
@ -1448,7 +1438,6 @@ function get_bill_graph()
|
|||
|
||||
function get_bill_graphdata()
|
||||
{
|
||||
global $config;
|
||||
$app = \Slim\Slim::getInstance();
|
||||
$router = $app->router()->getCurrentRoute()->getParams();
|
||||
$bill_id = mres($router['bill_id']);
|
||||
|
@ -1477,7 +1466,6 @@ function get_bill_graphdata()
|
|||
|
||||
function get_bill_history()
|
||||
{
|
||||
global $config;
|
||||
$app = \Slim\Slim::getInstance();
|
||||
$router = $app->router()->getCurrentRoute()->getParams();
|
||||
$bill_id = mres($router['bill_id']);
|
||||
|
@ -1496,8 +1484,6 @@ function get_bill_history()
|
|||
|
||||
function get_bill_history_graph()
|
||||
{
|
||||
global $config;
|
||||
|
||||
$app = \Slim\Slim::getInstance();
|
||||
$router = $app->router()->getCurrentRoute()->getParams();
|
||||
$bill_id = mres($router['bill_id']);
|
||||
|
@ -1540,8 +1526,6 @@ function get_bill_history_graph()
|
|||
|
||||
function get_bill_history_graphdata()
|
||||
{
|
||||
global $config;
|
||||
|
||||
$app = \Slim\Slim::getInstance();
|
||||
$router = $app->router()->getCurrentRoute()->getParams();
|
||||
$bill_id = mres($router['bill_id']);
|
||||
|
@ -1755,7 +1739,6 @@ function create_edit_bill()
|
|||
function update_device()
|
||||
{
|
||||
check_is_admin();
|
||||
global $config;
|
||||
$app = \Slim\Slim::getInstance();
|
||||
$router = $app->router()->getCurrentRoute()->getParams();
|
||||
$hostname = $router['hostname'];
|
||||
|
@ -1797,7 +1780,6 @@ function update_device()
|
|||
function rename_device()
|
||||
{
|
||||
check_is_admin();
|
||||
global $config;
|
||||
$app = \Slim\Slim::getInstance();
|
||||
$router = $app->router()->getCurrentRoute()->getParams();
|
||||
$hostname = $router['hostname'];
|
||||
|
@ -2186,7 +2168,6 @@ function list_arp()
|
|||
function list_services()
|
||||
{
|
||||
check_is_read();
|
||||
global $config;
|
||||
$app = \Slim\Slim::getInstance();
|
||||
$router = $app->router()->getCurrentRoute()->getParams();
|
||||
$services = array();
|
||||
|
@ -2304,10 +2285,8 @@ function list_logs()
|
|||
|
||||
function validate_column_list($columns, $tableName)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$column_names = explode(',', $columns);
|
||||
$db_schema = Symfony\Component\Yaml\Yaml::parse(file_get_contents($config['install_dir'] . '/misc/db_schema.yaml'));
|
||||
$db_schema = Symfony\Component\Yaml\Yaml::parse(file_get_contents(Config::get('install_dir') . '/misc/db_schema.yaml'));
|
||||
$valid_columns = array_column($db_schema[$tableName]['Columns'], 'Field');
|
||||
$invalid_columns = array_diff(array_map('trim', $column_names), $valid_columns);
|
||||
|
||||
|
@ -2326,7 +2305,6 @@ function validate_column_list($columns, $tableName)
|
|||
|
||||
function add_service_for_host()
|
||||
{
|
||||
global $config;
|
||||
$app = \Slim\Slim::getInstance();
|
||||
$router = $app->router()->getCurrentRoute()->getParams();
|
||||
$hostname = $router['hostname'];
|
||||
|
|
|
@ -3,65 +3,59 @@
|
|||
* Configuration file for Collectd graph browser
|
||||
*/
|
||||
|
||||
if (isset($config['rrdgraph_def_text'])) {
|
||||
$config['rrdgraph_def_text'] = str_replace(' ', ' ', $config['rrdgraph_def_text']);
|
||||
$config['rrd_opts_array'] = explode(' ', trim($config['rrdgraph_def_text']));
|
||||
use LibreNMS\Config;
|
||||
|
||||
if (Config::has('rrdgraph_def_text')) {
|
||||
Config::set('rrdgraph_def_text', str_replace(' ', ' ', Config::get('rrdgraph_def_text')));
|
||||
Config::set('rrd_opts_array', explode(' ', trim(Config::get('rrdgraph_def_text'))));
|
||||
}
|
||||
|
||||
// Array of paths when collectd's rrdtool plugin writes RRDs
|
||||
$config['datadirs'] = array($config['collectd_dir']);
|
||||
Config::set('datadirs', [Config::get('collectd_dir')]);
|
||||
// Width of graph to be generated by rrdgraph
|
||||
if (isset($_GET['width'])) {
|
||||
$config['rrd_width'] = $_GET['width'];
|
||||
} else {
|
||||
$config['rrd_width'] = 270;
|
||||
}
|
||||
Config::set('rrd_width', $_GET['width'] ?? 270);
|
||||
|
||||
// Height of graph to be generated by rrdgraph
|
||||
if (isset($_GET['height'])) {
|
||||
$config['rrd_height'] = $_GET['height'];
|
||||
} else {
|
||||
$config['rrd_height'] = 120;
|
||||
}
|
||||
Config::set('rrd_height', $_GET['height'] ?? 120);
|
||||
|
||||
// List of supported timespans (used for period drop-down list)
|
||||
$config['timespan'] = array(
|
||||
array(
|
||||
'name' => 'hour',
|
||||
'label' => 'past hour',
|
||||
Config::set('timespan', [
|
||||
[
|
||||
'name' => 'hour',
|
||||
'label' => 'past hour',
|
||||
'seconds' => 3600,
|
||||
),
|
||||
array(
|
||||
'name' => 'day',
|
||||
'label' => 'past day',
|
||||
],
|
||||
[
|
||||
'name' => 'day',
|
||||
'label' => 'past day',
|
||||
'seconds' => 86400,
|
||||
),
|
||||
array(
|
||||
'name' => 'week',
|
||||
'label' => 'past week',
|
||||
],
|
||||
[
|
||||
'name' => 'week',
|
||||
'label' => 'past week',
|
||||
'seconds' => 604800,
|
||||
),
|
||||
array(
|
||||
'name' => 'month',
|
||||
'label' => 'past month',
|
||||
],
|
||||
[
|
||||
'name' => 'month',
|
||||
'label' => 'past month',
|
||||
'seconds' => 2678400,
|
||||
),
|
||||
array(
|
||||
'name' => 'year',
|
||||
'label' => 'past year',
|
||||
],
|
||||
[
|
||||
'name' => 'year',
|
||||
'label' => 'past year',
|
||||
'seconds' => 31622400,
|
||||
),
|
||||
);
|
||||
],
|
||||
]);
|
||||
// Interval at which values are collectd (currently ignored)
|
||||
$config['rrd_interval'] = 10;
|
||||
Config::set('rrd_interval', 10);
|
||||
// Average rows/rra (currently ignored)
|
||||
$config['rrd_rows'] = 2400;
|
||||
Config::set('rrd_rows', 2400);
|
||||
// Additional options to pass to rrdgraph
|
||||
// $config['rrd_opts'] = (isset($config['rrdgraph_defaults']) ? $config['rrdgraph_defaults'] : '');
|
||||
// $config['rrd_opts'] = array('-E', "-c", "SHADEA#a5a5a5", "-c", "SHADEB#a5a5a5", "-c", "FONT#000000", "-c", "CANVAS#FFFFFF", "-c", "GRID#aaaaaa",
|
||||
// Config::set('rrd_opts', (Config::get('rrdgraph_defaults', ''));
|
||||
// Config::set('rrd_opts', array('-E', "-c", "SHADEA#a5a5a5", "-c", "SHADEB#a5a5a5", "-c", "FONT#000000", "-c", "CANVAS#FFFFFF", "-c", "GRID#aaaaaa",
|
||||
// "-c", "MGRID#FFAAAA", "-c", "FRAME#3e3e3e", "-c", "ARROW#5e5e5e", "-R", "normal");
|
||||
// Predefined set of colors for use by collectd_draw_rrd()
|
||||
$config['rrd_colors'] = array(
|
||||
Config::set('rrd_colors', [
|
||||
'h_1' => 'F7B7B7',
|
||||
'f_1' => 'FF0000', // Red
|
||||
'h_2' => 'B7EFB7',
|
||||
|
@ -88,14 +82,14 @@ $config['rrd_colors'] = array(
|
|||
'f_12' => 'FF0051',
|
||||
'h_13' => 'BBBBBB',
|
||||
'f_13' => '555555',
|
||||
);
|
||||
]);
|
||||
/*
|
||||
* Path to TTF font file to use in error images
|
||||
* (fallback when file does not exist is GD fixed font)
|
||||
*/
|
||||
$config['error_font'] = '/usr/share/fonts/corefonts/arial.ttf';
|
||||
Config::set('error_font', '/usr/share/fonts/corefonts/arial.ttf');
|
||||
|
||||
/*
|
||||
* Constant defining full path to rrdtool
|
||||
*/
|
||||
define('RRDTOOL', $config['rrdtool']);
|
||||
define('RRDTOOL', Config::get('rrdtool'));
|
||||
|
|
|
@ -40,7 +40,6 @@ function load_graph_definitions_local($logarithmic = false, $tinylegend = false)
|
|||
|
||||
function meta_graph_local($host, $plugin, $plugin_instance, $type, $type_instances, $opts = array())
|
||||
{
|
||||
global $config;
|
||||
$sources = array();
|
||||
|
||||
$title = "$host/$plugin".(!is_null($plugin_instance) ? "-$plugin_instance" : '')."/$type";
|
||||
|
@ -64,7 +63,7 @@ function meta_graph_local($host, $plugin, $plugin_instance, $type, $type_instanc
|
|||
$type_instances = array('ham', 'spam', 'malware', 'sent', 'deferred', 'reject', 'bounced'); */
|
||||
foreach ($type_instances as $inst) {
|
||||
$file = '';
|
||||
foreach ($config['datadirs'] as $datadir) {
|
||||
foreach (\LibreNMS\Config::get('datadirs') as $datadir) {
|
||||
if (is_file($datadir.'/'.$title.'-'.$inst.'.rrd')) {
|
||||
$file = $datadir.'/'.$title.'-'.$inst.'.rrd';
|
||||
break;
|
||||
|
|
|
@ -1665,7 +1665,6 @@ function load_graph_definitions($logarithmic = false, $tinylegend = false)
|
|||
|
||||
function meta_graph_files_count($host, $plugin, $plugin_instance, $type, $type_instances, $opts = array())
|
||||
{
|
||||
global $config;
|
||||
$sources = array();
|
||||
|
||||
$title = "$host/$plugin".(!is_null($plugin_instance) ? "-$plugin_instance" : '')."/$type";
|
||||
|
@ -1683,7 +1682,7 @@ function meta_graph_files_count($host, $plugin, $plugin_instance, $type, $type_i
|
|||
$type_instances = array('incoming', 'active', 'deferred');
|
||||
while (list($k, $inst) = each($type_instances)) {
|
||||
$file = '';
|
||||
foreach ($config['datadirs'] as $datadir) {
|
||||
foreach (Config::get('datadirs') as $datadir) {
|
||||
if (is_file($datadir.'/'.$title.'-'.$inst.'.rrd')) {
|
||||
$file = $datadir.'/'.$title.'-'.$inst.'.rrd';
|
||||
break;
|
||||
|
@ -1701,7 +1700,6 @@ function meta_graph_files_count($host, $plugin, $plugin_instance, $type, $type_i
|
|||
|
||||
function meta_graph_files_size($host, $plugin, $plugin_instance, $type, $type_instances, $opts = array())
|
||||
{
|
||||
global $config;
|
||||
$sources = array();
|
||||
|
||||
$title = "$host/$plugin".(!is_null($plugin_instance) ? "-$plugin_instance" : '')."/$type";
|
||||
|
@ -1719,7 +1717,7 @@ function meta_graph_files_size($host, $plugin, $plugin_instance, $type, $type_in
|
|||
$type_instances = array('incoming', 'active', 'deferred');
|
||||
while (list($k, $inst) = each($type_instances)) {
|
||||
$file = '';
|
||||
foreach ($config['datadirs'] as $datadir) {
|
||||
foreach (Config::get('datadirs') as $datadir) {
|
||||
if (is_file($datadir.'/'.$title.'-'.$inst.'.rrd')) {
|
||||
$file = $datadir.'/'.$title.'-'.$inst.'.rrd';
|
||||
break;
|
||||
|
@ -1737,7 +1735,6 @@ function meta_graph_files_size($host, $plugin, $plugin_instance, $type, $type_in
|
|||
|
||||
function meta_graph_cpu($host, $plugin, $plugin_instance, $type, $type_instances, $opts = array())
|
||||
{
|
||||
global $config;
|
||||
$sources = array();
|
||||
|
||||
$title = "$host/$plugin".(!is_null($plugin_instance) ? "-$plugin_instance" : '')."/$type";
|
||||
|
@ -1760,7 +1757,7 @@ function meta_graph_cpu($host, $plugin, $plugin_instance, $type, $type_instances
|
|||
$type_instances = array('idle', 'wait', 'nice', 'user', 'system', 'softirq', 'interrupt', 'steal');
|
||||
while (list($k, $inst) = each($type_instances)) {
|
||||
$file = '';
|
||||
foreach ($config['datadirs'] as $datadir) {
|
||||
foreach (Config::get('datadirs') as $datadir) {
|
||||
if (is_file($datadir.'/'.$title.'-'.$inst.'.rrd')) {
|
||||
$file = $datadir.'/'.$title.'-'.$inst.'.rrd';
|
||||
break;
|
||||
|
@ -1778,7 +1775,6 @@ function meta_graph_cpu($host, $plugin, $plugin_instance, $type, $type_instances
|
|||
|
||||
function meta_graph_memory($host, $plugin, $plugin_instance, $type, $type_instances, $opts = array())
|
||||
{
|
||||
global $config;
|
||||
$sources = array();
|
||||
|
||||
$title = "$host/$plugin".(!is_null($plugin_instance) ? "-$plugin_instance" : '')."/$type";
|
||||
|
@ -1800,7 +1796,7 @@ function meta_graph_memory($host, $plugin, $plugin_instance, $type, $type_instan
|
|||
$type_instances = array('free', 'cached', 'buffered', 'used');
|
||||
while (list($k, $inst) = each($type_instances)) {
|
||||
$file = '';
|
||||
foreach ($config['datadirs'] as $datadir) {
|
||||
foreach (Config::get('datadirs') as $datadir) {
|
||||
if (is_file($datadir.'/'.$title.'-'.$inst.'.rrd')) {
|
||||
$file = $datadir.'/'.$title.'-'.$inst.'.rrd';
|
||||
break;
|
||||
|
@ -1818,7 +1814,6 @@ function meta_graph_memory($host, $plugin, $plugin_instance, $type, $type_instan
|
|||
|
||||
function meta_graph_vs_threads($host, $plugin, $plugin_instance, $type, $type_instances, $opts = array())
|
||||
{
|
||||
global $config;
|
||||
$sources = array();
|
||||
|
||||
$title = "$host/$plugin".(!is_null($plugin_instance) ? "-$plugin_instance" : '')."/$type";
|
||||
|
@ -1838,7 +1833,7 @@ function meta_graph_vs_threads($host, $plugin, $plugin_instance, $type, $type_in
|
|||
$type_instances = array('total', 'running', 'onhold', 'uninterruptable');
|
||||
while (list($k, $inst) = each($type_instances)) {
|
||||
$file = '';
|
||||
foreach ($config['datadirs'] as $datadir) {
|
||||
foreach (Config::get('datadirs') as $datadir) {
|
||||
if (is_file($datadir.'/'.$title.'-'.$inst.'.rrd')) {
|
||||
$file = $datadir.'/'.$title.'-'.$inst.'.rrd';
|
||||
break;
|
||||
|
@ -1856,7 +1851,6 @@ function meta_graph_vs_threads($host, $plugin, $plugin_instance, $type, $type_in
|
|||
|
||||
function meta_graph_vs_memory($host, $plugin, $plugin_instance, $type, $type_instances, $opts = array())
|
||||
{
|
||||
global $config;
|
||||
$sources = array();
|
||||
|
||||
$title = "$host/$plugin".(!is_null($plugin_instance) ? "-$plugin_instance" : '')."/$type";
|
||||
|
@ -1876,7 +1870,7 @@ function meta_graph_vs_memory($host, $plugin, $plugin_instance, $type, $type_ins
|
|||
$type_instances = array('anon', 'rss', 'vml', 'vm');
|
||||
while (list($k, $inst) = each($type_instances)) {
|
||||
$file = '';
|
||||
foreach ($config['datadirs'] as $datadir) {
|
||||
foreach (Config::get('datadirs') as $datadir) {
|
||||
if (is_file($datadir.'/'.$title.'-'.$inst.'.rrd')) {
|
||||
$file = $datadir.'/'.$title.'-'.$inst.'.rrd';
|
||||
break;
|
||||
|
@ -1894,7 +1888,6 @@ function meta_graph_vs_memory($host, $plugin, $plugin_instance, $type, $type_ins
|
|||
|
||||
function meta_graph_if_rx_errors($host, $plugin, $plugin_instance, $type, $type_instances, $opts = array())
|
||||
{
|
||||
global $config;
|
||||
$sources = array();
|
||||
|
||||
$title = "$host/$plugin".(!is_null($plugin_instance) ? "-$plugin_instance" : '')."/$type";
|
||||
|
@ -1906,7 +1899,7 @@ function meta_graph_if_rx_errors($host, $plugin, $plugin_instance, $type, $type_
|
|||
|
||||
while (list($k, $inst) = each($type_instances)) {
|
||||
$file = '';
|
||||
foreach ($config['datadirs'] as $datadir) {
|
||||
foreach (Config::get('datadirs') as $datadir) {
|
||||
if (is_file($datadir.'/'.$title.'-'.$inst.'.rrd')) {
|
||||
$file = $datadir.'/'.$title.'-'.$inst.'.rrd';
|
||||
break;
|
||||
|
@ -1924,7 +1917,6 @@ function meta_graph_if_rx_errors($host, $plugin, $plugin_instance, $type, $type_
|
|||
|
||||
function meta_graph_mysql_commands($host, $plugin, $plugin_instance, $type, $type_instances, $opts = array())
|
||||
{
|
||||
global $config;
|
||||
$sources = array();
|
||||
|
||||
$title = "$host/$plugin".(!is_null($plugin_instance) ? "-$plugin_instance" : '')."/$type";
|
||||
|
@ -1936,7 +1928,7 @@ function meta_graph_mysql_commands($host, $plugin, $plugin_instance, $type, $typ
|
|||
|
||||
while (list($k, $inst) = each($type_instances)) {
|
||||
$file = '';
|
||||
foreach ($config['datadirs'] as $datadir) {
|
||||
foreach (Config::get('datadirs') as $datadir) {
|
||||
if (is_file($datadir.'/'.$title.'-'.$inst.'.rrd')) {
|
||||
$file = $datadir.'/'.$title.'-'.$inst.'.rrd';
|
||||
break;
|
||||
|
@ -1954,7 +1946,6 @@ function meta_graph_mysql_commands($host, $plugin, $plugin_instance, $type, $typ
|
|||
|
||||
function meta_graph_nfs_procedure($host, $plugin, $plugin_instance, $type, $type_instances, $opts = array())
|
||||
{
|
||||
global $config;
|
||||
$sources = array();
|
||||
|
||||
$title = "$host/$plugin".(!is_null($plugin_instance) ? "-$plugin_instance" : '')."/$type";
|
||||
|
@ -1966,7 +1957,7 @@ function meta_graph_nfs_procedure($host, $plugin, $plugin_instance, $type, $type
|
|||
|
||||
while (list($k, $inst) = each($type_instances)) {
|
||||
$file = '';
|
||||
foreach ($config['datadirs'] as $datadir) {
|
||||
foreach (Config::get('datadirs') as $datadir) {
|
||||
if (is_file($datadir.'/'.$title.'-'.$inst.'.rrd')) {
|
||||
$file = $datadir.'/'.$title.'-'.$inst.'.rrd';
|
||||
break;
|
||||
|
@ -1984,7 +1975,6 @@ function meta_graph_nfs_procedure($host, $plugin, $plugin_instance, $type, $type
|
|||
|
||||
function meta_graph_ps_state($host, $plugin, $plugin_instance, $type, $type_instances, $opts = array())
|
||||
{
|
||||
global $config;
|
||||
$sources = array();
|
||||
|
||||
$title = "$host/$plugin".(!is_null($plugin_instance) ? "-$plugin_instance" : '')."/$type";
|
||||
|
@ -2005,7 +1995,7 @@ function meta_graph_ps_state($host, $plugin, $plugin_instance, $type, $type_inst
|
|||
$type_instances = array('paging', 'blocked', 'zombies', 'stopped', 'running', 'sleeping');
|
||||
while (list($k, $inst) = each($type_instances)) {
|
||||
$file = '';
|
||||
foreach ($config['datadirs'] as $datadir) {
|
||||
foreach (Config::get('datadirs') as $datadir) {
|
||||
if (is_file($datadir.'/'.$title.'-'.$inst.'.rrd')) {
|
||||
$file = $datadir.'/'.$title.'-'.$inst.'.rrd';
|
||||
break;
|
||||
|
@ -2023,7 +2013,6 @@ function meta_graph_ps_state($host, $plugin, $plugin_instance, $type, $type_inst
|
|||
|
||||
function meta_graph_swap($host, $plugin, $plugin_instance, $type, $type_instances, $opts = array())
|
||||
{
|
||||
global $config;
|
||||
$sources = array();
|
||||
|
||||
$title = "$host/$plugin".(!is_null($plugin_instance) ? "-$plugin_instance" : '')."/$type";
|
||||
|
@ -2042,7 +2031,7 @@ function meta_graph_swap($host, $plugin, $plugin_instance, $type, $type_instance
|
|||
$type_instances = array('free', 'cached', 'used');
|
||||
while (list($k, $inst) = each($type_instances)) {
|
||||
$file = '';
|
||||
foreach ($config['datadirs'] as $datadir) {
|
||||
foreach (Config::get('datadirs') as $datadir) {
|
||||
if (is_file($datadir.'/'.$title.'-'.$inst.'.rrd')) {
|
||||
$file = $datadir.'/'.$title.'-'.$inst.'.rrd';
|
||||
break;
|
||||
|
@ -2060,7 +2049,6 @@ function meta_graph_swap($host, $plugin, $plugin_instance, $type, $type_instance
|
|||
|
||||
function meta_graph_apache_scoreboard($host, $plugin, $plugin_instance, $type, $type_instances, $opts = array())
|
||||
{
|
||||
global $config;
|
||||
$sources = array();
|
||||
|
||||
$title = "$host/$plugin".(!is_null($plugin_instance) ? "-$plugin_instance" : '')."/$type";
|
||||
|
@ -2087,7 +2075,7 @@ function meta_graph_apache_scoreboard($host, $plugin, $plugin_instance, $type, $
|
|||
$type_instances = array(/* 'open',*/ 'waiting', 'starting', 'reading', 'sending', 'keepalive', 'dnslookup', 'logging', 'closing', 'finishing', 'idle_cleanup');
|
||||
while (list($k, $inst) = each($type_instances)) {
|
||||
$file = '';
|
||||
foreach ($config['datadirs'] as $datadir) {
|
||||
foreach (Config::get('datadirs') as $datadir) {
|
||||
if (is_file($datadir.'/'.$title.'-'.$inst.'.rrd')) {
|
||||
$file = $datadir.'/'.$title.'-'.$inst.'.rrd';
|
||||
break;
|
||||
|
@ -2105,7 +2093,6 @@ function meta_graph_apache_scoreboard($host, $plugin, $plugin_instance, $type, $
|
|||
|
||||
function meta_graph_tcp_connections($host, $plugin, $plugin_instance, $type, $type_instances, $opts = array())
|
||||
{
|
||||
global $config;
|
||||
$sources = array();
|
||||
|
||||
$title = "$host/$plugin".(!is_null($plugin_instance) ? "-$plugin_instance" : '')."/$type";
|
||||
|
@ -2133,7 +2120,7 @@ function meta_graph_tcp_connections($host, $plugin, $plugin_instance, $type, $ty
|
|||
$type_instances = array('ESTABLISHED', 'SYN_SENT', 'SYN_RECV', 'FIN_WAIT1', 'FIN_WAIT2', 'TIME_WAIT', 'CLOSE', 'CLOSE_WAIT', 'LAST_ACK', 'CLOSING', 'LISTEN');
|
||||
while (list($k, $inst) = each($type_instances)) {
|
||||
$file = '';
|
||||
foreach ($config['datadirs'] as $datadir) {
|
||||
foreach (Config::get('datadirs') as $datadir) {
|
||||
if (is_file($datadir.'/'.$title.'-'.$inst.'.rrd')) {
|
||||
$file = $datadir.'/'.$title.'-'.$inst.'.rrd';
|
||||
break;
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
require 'includes/html/collectd/CollectdColor.php';
|
||||
|
||||
use LibreNMS\Config;
|
||||
use LibreNMS\CollectdColor;
|
||||
|
||||
define('REGEXP_HOST', '/^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/');
|
||||
|
@ -84,10 +85,8 @@ function collectd_compare_host($a, $b)
|
|||
*/
|
||||
function collectd_list_hosts()
|
||||
{
|
||||
global $config;
|
||||
|
||||
$hosts = array();
|
||||
foreach ($config['datadirs'] as $datadir) {
|
||||
foreach (Config::get('datadirs') as $datadir) {
|
||||
if ($d = @opendir($datadir)) {
|
||||
while (($dent = readdir($d)) !== false) {
|
||||
if ($dent != '.' && $dent != '..' && is_dir($datadir.'/'.$dent) && preg_match(REGEXP_HOST, $dent)) {
|
||||
|
@ -113,10 +112,8 @@ function collectd_list_hosts()
|
|||
*/
|
||||
function collectd_list_plugins($arg_host)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$plugins = array();
|
||||
foreach ($config['datadirs'] as $datadir) {
|
||||
foreach (Config::get('datadirs') as $datadir) {
|
||||
if (preg_match(REGEXP_HOST, $arg_host) && ($d = @opendir($datadir.'/'.$arg_host))) {
|
||||
while (($dent = readdir($d)) !== false) {
|
||||
if ($dent != '.' && $dent != '..' && is_dir($datadir.'/'.$arg_host.'/'.$dent)) {
|
||||
|
@ -147,10 +144,8 @@ function collectd_list_plugins($arg_host)
|
|||
*/
|
||||
function collectd_list_pinsts($arg_host, $arg_plugin)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$pinsts = array();
|
||||
foreach ($config['datadirs'] as $datadir) {
|
||||
foreach (Config::get('datadirs') as $datadir) {
|
||||
if (preg_match(REGEXP_HOST, $arg_host) && ($d = opendir($datadir.'/'.$arg_host))) {
|
||||
while (($dent = readdir($d)) !== false) {
|
||||
if ($dent != '.' && $dent != '..' && is_dir($datadir.'/'.$arg_host.'/'.$dent)) {
|
||||
|
@ -187,15 +182,13 @@ function collectd_list_pinsts($arg_host, $arg_plugin)
|
|||
*/
|
||||
function collectd_list_types($arg_host, $arg_plugin, $arg_pinst)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$types = array();
|
||||
$my_plugin = $arg_plugin.(strlen($arg_pinst) ? '-'.$arg_pinst : '');
|
||||
if (!preg_match(REGEXP_PLUGIN, $my_plugin)) {
|
||||
return $types;
|
||||
}
|
||||
|
||||
foreach ($config['datadirs'] as $datadir) {
|
||||
foreach (Config::get('datadirs') as $datadir) {
|
||||
if (preg_match(REGEXP_HOST, $arg_host) && ($d = @opendir($datadir.'/'.$arg_host.'/'.$my_plugin))) {
|
||||
while (($dent = readdir($d)) !== false) {
|
||||
if ($dent != '.' && $dent != '..' && is_file($datadir.'/'.$arg_host.'/'.$my_plugin.'/'.$dent) && substr($dent, (strlen($dent) - 4)) == '.rrd') {
|
||||
|
@ -228,15 +221,13 @@ function collectd_list_types($arg_host, $arg_plugin, $arg_pinst)
|
|||
*/
|
||||
function collectd_list_tinsts($arg_host, $arg_plugin, $arg_pinst, $arg_type)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$tinsts = array();
|
||||
$my_plugin = $arg_plugin.(strlen($arg_pinst) ? '-'.$arg_pinst : '');
|
||||
if (!preg_match(REGEXP_PLUGIN, $my_plugin)) {
|
||||
return $tinsts;
|
||||
}
|
||||
|
||||
foreach ($config['datadirs'] as $datadir) {
|
||||
foreach (Config::get('datadirs') as $datadir) {
|
||||
if (preg_match(REGEXP_HOST, $arg_host) && ($d = @opendir($datadir.'/'.$arg_host.'/'.$my_plugin))) {
|
||||
while (($dent = readdir($d)) !== false) {
|
||||
if ($dent != '.' && $dent != '..' && is_file($datadir.'/'.$arg_host.'/'.$my_plugin.'/'.$dent) && substr($dent, (strlen($dent) - 4)) == '.rrd') {
|
||||
|
@ -280,11 +271,10 @@ function collectd_list_tinsts($arg_host, $arg_plugin, $arg_pinst, $arg_type)
|
|||
*/
|
||||
function collectd_identifier($host, $plugin, $type, $pinst, $tinst)
|
||||
{
|
||||
global $config;
|
||||
$rrd_realpath = null;
|
||||
$orig_identifier = sprintf('%s/%s%s%s/%s%s%s', $host, $plugin, strlen($pinst) ? '-' : '', $pinst, $type, strlen($tinst) ? '-' : '', $tinst);
|
||||
$identifier = null;
|
||||
foreach ($config['datadirs'] as $datadir) {
|
||||
foreach (Config::get('datadirs') as $datadir) {
|
||||
if (is_file($datadir.'/'.$orig_identifier.'.rrd')) {
|
||||
$rrd_realpath = realpath($datadir.'/'.$orig_identifier.'.rrd');
|
||||
break;
|
||||
|
@ -317,9 +307,7 @@ function collectd_identifier($host, $plugin, $type, $pinst, $tinst)
|
|||
*/
|
||||
function collectd_flush($identifier)
|
||||
{
|
||||
global $config;
|
||||
|
||||
if (!$config['collectd_sock']) {
|
||||
if (!Config::get('collectd_sock')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -329,7 +317,7 @@ function collectd_flush($identifier)
|
|||
|
||||
$u_errno = 0;
|
||||
$u_errmsg = '';
|
||||
if ($socket = @fsockopen($config['collectd_sock'], 0, $u_errno, $u_errmsg)) {
|
||||
if ($socket = @fsockopen(Config::get('collectd_sock'), 0, $u_errno, $u_errmsg)) {
|
||||
$cmd = 'FLUSH plugin=rrdtool';
|
||||
if (is_array($identifier)) {
|
||||
foreach ($identifier as $val) {
|
||||
|
@ -448,17 +436,16 @@ function _rrd_info($file)
|
|||
|
||||
function rrd_get_color($code, $line = true)
|
||||
{
|
||||
global $config;
|
||||
$name = ($line ? 'f_' : 'h_').$code;
|
||||
if (!isset($config['rrd_colors'][$name])) {
|
||||
if (!Config::has("rrd_colors.$name")) {
|
||||
$c_f = new CollectdColor('random');
|
||||
$c_h = new CollectdColor($c_f);
|
||||
$c_h->fade();
|
||||
$config['rrd_colors']['f_'.$code] = $c_f->toString();
|
||||
$config['rrd_colors']['h_'.$code] = $c_h->toString();
|
||||
Config::set("rrd_colors.f_$code", $c_f->toString());
|
||||
Config::set("rrd_colors.h_$code", $c_h->toString());
|
||||
}
|
||||
|
||||
return $config['rrd_colors'][$name];
|
||||
return Config::get("rrd_colors.$name");
|
||||
}//end rrd_get_color()
|
||||
|
||||
|
||||
|
@ -475,12 +462,12 @@ function rrd_get_color($code, $line = true)
|
|||
*/
|
||||
function collectd_draw_rrd($host, $plugin, $type, $pinst = null, $tinst = null, $opts = array())
|
||||
{
|
||||
global $config;
|
||||
$timespan_def = null;
|
||||
$timespans = Config::get('timespan');
|
||||
if (!isset($opts['timespan'])) {
|
||||
$timespan_def = reset($config['timespan']);
|
||||
$timespan_def = reset($timespans);
|
||||
} else {
|
||||
foreach ($config['timespan'] as &$ts) {
|
||||
foreach ($timespans as &$ts) {
|
||||
if ($ts['name'] == $opts['timespan']) {
|
||||
$timespan_def = $ts;
|
||||
}
|
||||
|
@ -497,7 +484,7 @@ function collectd_draw_rrd($host, $plugin, $type, $pinst = null, $tinst = null,
|
|||
|
||||
$rrdinfo = null;
|
||||
$rrdfile = sprintf('%s/%s%s%s/%s%s%s', $host, $plugin, is_null($pinst) ? '' : '-', $pinst, $type, is_null($tinst) ? '' : '-', $tinst);
|
||||
foreach ($config['datadirs'] as $datadir) {
|
||||
foreach (Config::get('datadirs') as $datadir) {
|
||||
if (is_file($datadir.'/'.$rrdfile.'.rrd')) {
|
||||
$rrdinfo = _rrd_info($datadir.'/'.$rrdfile.'.rrd');
|
||||
if (isset($rrdinfo['RRA']) && is_array($rrdinfo['RRA'])) {
|
||||
|
@ -599,7 +586,7 @@ function collectd_draw_rrd($host, $plugin, $type, $pinst = null, $tinst = null,
|
|||
}
|
||||
}//end while
|
||||
|
||||
// $rrd_cmd = array(RRDTOOL, 'graph', '-', '-E', '-a', 'PNG', '-w', $config['rrd_width'], '-h', $config['rrd_height'], '-t', $rrdfile);
|
||||
// $rrd_cmd = array(RRDTOOL, 'graph', '-', '-E', '-a', 'PNG', '-w', Config::get('rrd_width'), '-h', Config::get('rrd_height'), '-t', $rrdfile);
|
||||
$rrd_cmd = array(
|
||||
RRDTOOL,
|
||||
'graph',
|
||||
|
@ -608,11 +595,11 @@ function collectd_draw_rrd($host, $plugin, $type, $pinst = null, $tinst = null,
|
|||
'-a',
|
||||
'PNG',
|
||||
'-w',
|
||||
$config['rrd_width'],
|
||||
Config::get('rrd_width'),
|
||||
'-h',
|
||||
$config['rrd_height'],
|
||||
Config::get('rrd_height'),
|
||||
);
|
||||
if ($config['rrd_width'] <= '300') {
|
||||
if (Config::get('rrd_width') <= '300') {
|
||||
$small_opts = array(
|
||||
'--font',
|
||||
'LEGEND:7:mono',
|
||||
|
@ -624,7 +611,7 @@ function collectd_draw_rrd($host, $plugin, $type, $pinst = null, $tinst = null,
|
|||
$rrd_cmd = array_merge($rrd_cmd, $small_opts);
|
||||
}
|
||||
|
||||
$rrd_cmd = array_merge($rrd_cmd, $config['rrd_opts_array'], $opts['rrd_opts'], $graph);
|
||||
$rrd_cmd = array_merge($rrd_cmd, Config::get('rrd_opts_array'), $opts['rrd_opts'], $graph);
|
||||
|
||||
$cmd = RRDTOOL;
|
||||
$count_rrd_cmd = count($rrd_cmd);
|
||||
|
@ -649,16 +636,17 @@ function collectd_draw_rrd($host, $plugin, $type, $pinst = null, $tinst = null,
|
|||
*/
|
||||
function collectd_draw_generic($timespan, $host, $plugin, $type, $pinst = null, $tinst = null)
|
||||
{
|
||||
global $config, $GraphDefs;
|
||||
global $GraphDefs;
|
||||
$timespan_def = null;
|
||||
foreach ($config['timespan'] as &$ts) {
|
||||
$timespans = Config::get('timespan');
|
||||
foreach ($timespans as &$ts) {
|
||||
if ($ts['name'] == $timespan) {
|
||||
$timespan_def = $ts;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_null($timespan_def)) {
|
||||
$timespan_def = reset($config['timespan']);
|
||||
$timespan_def = reset($timespans);
|
||||
}
|
||||
|
||||
if (!isset($GraphDefs[$type])) {
|
||||
|
@ -666,7 +654,7 @@ function collectd_draw_generic($timespan, $host, $plugin, $type, $pinst = null,
|
|||
}
|
||||
|
||||
$rrd_file = sprintf('%s/%s%s%s/%s%s%s', $host, $plugin, is_null($pinst) ? '' : '-', $pinst, $type, is_null($tinst) ? '' : '-', $tinst);
|
||||
// $rrd_cmd = array(RRDTOOL, 'graph', '-', '-E', '-a', 'PNG', '-w', $config['rrd_width'], '-h', $config['rrd_height'], '-t', $rrd_file);
|
||||
// $rrd_cmd = array(RRDTOOL, 'graph', '-', '-E', '-a', 'PNG', '-w', Config::get('rrd_width'), '-h', Config::get('rrd_height'), '-t', $rrd_file);
|
||||
$rrd_cmd = array(
|
||||
RRDTOOL,
|
||||
'graph',
|
||||
|
@ -675,12 +663,12 @@ function collectd_draw_generic($timespan, $host, $plugin, $type, $pinst = null,
|
|||
'-a',
|
||||
'PNG',
|
||||
'-w',
|
||||
$config['rrd_width'],
|
||||
Config::get('rrd_width'),
|
||||
'-h',
|
||||
$config['rrd_height'],
|
||||
Config::get('rrd_height'),
|
||||
);
|
||||
|
||||
if ($config['rrd_width'] <= '300') {
|
||||
if (Config::get('rrd_width') <= '300') {
|
||||
$small_opts = array(
|
||||
'--font',
|
||||
'LEGEND:7:mono',
|
||||
|
@ -692,10 +680,10 @@ function collectd_draw_generic($timespan, $host, $plugin, $type, $pinst = null,
|
|||
$rrd_cmd = array_merge($rrd_cmd, $small_opts);
|
||||
}
|
||||
|
||||
$rrd_cmd = array_merge($rrd_cmd, $config['rrd_opts_array']);
|
||||
$rrd_cmd = array_merge($rrd_cmd, Config::get('rrd_opts_array'));
|
||||
$rrd_args = $GraphDefs[$type];
|
||||
|
||||
foreach ($config['datadirs'] as $datadir) {
|
||||
foreach (Config::get('datadirs') as $datadir) {
|
||||
$file = $datadir.'/'.$rrd_file.'.rrd';
|
||||
if (!is_file($file)) {
|
||||
continue;
|
||||
|
@ -726,12 +714,12 @@ function collectd_draw_generic($timespan, $host, $plugin, $type, $pinst = null,
|
|||
*/
|
||||
function collectd_draw_meta_stack(&$opts, &$sources)
|
||||
{
|
||||
global $config;
|
||||
$timespan_def = null;
|
||||
$timespans = Config::get('timespan');
|
||||
if (!isset($opts['timespan'])) {
|
||||
$timespan_def = reset($config['timespan']);
|
||||
$timespan_def = reset($timespans);
|
||||
} else {
|
||||
foreach ($config['timespan'] as &$ts) {
|
||||
foreach ($timespans as &$ts) {
|
||||
if ($ts['name'] == $opts['timespan']) {
|
||||
$timespan_def = $ts;
|
||||
}
|
||||
|
@ -754,7 +742,7 @@ function collectd_draw_meta_stack(&$opts, &$sources)
|
|||
array_unshift($opts['rrd_opts'], '-o');
|
||||
}
|
||||
|
||||
// $cmd = array(RRDTOOL, 'graph', '-', '-E', '-a', 'PNG', '-w', $config['rrd_width'], '-h', $config['rrd_height'],
|
||||
// $cmd = array(RRDTOOL, 'graph', '-', '-E', '-a', 'PNG', '-w', Config::get('rrd_width'), '-h', Config::get('rrd_height'),
|
||||
// '-t', $opts['title']);
|
||||
$cmd = array(
|
||||
RRDTOOL,
|
||||
|
@ -764,12 +752,12 @@ function collectd_draw_meta_stack(&$opts, &$sources)
|
|||
'-a',
|
||||
'PNG',
|
||||
'-w',
|
||||
$config['rrd_width'],
|
||||
Config::get('rrd_width'),
|
||||
'-h',
|
||||
$config['rrd_height'],
|
||||
Config::get('rrd_height'),
|
||||
);
|
||||
|
||||
if ($config['rrd_width'] <= '300') {
|
||||
if (Config::get('rrd_width') <= '300') {
|
||||
$small_opts = array(
|
||||
'--font',
|
||||
'LEGEND:7:mono',
|
||||
|
@ -781,7 +769,7 @@ function collectd_draw_meta_stack(&$opts, &$sources)
|
|||
$cmd = array_merge($cmd, $small_opts);
|
||||
}
|
||||
|
||||
$cmd = array_merge($cmd, $config['rrd_opts_array'], $opts['rrd_opts']);
|
||||
$cmd = array_merge($cmd, Config::get('rrd_opts_array'), $opts['rrd_opts']);
|
||||
$max_inst_name = 0;
|
||||
|
||||
foreach ($sources as &$inst_data) {
|
||||
|
@ -863,12 +851,12 @@ function collectd_draw_meta_stack(&$opts, &$sources)
|
|||
*/
|
||||
function collectd_draw_meta_line(&$opts, &$sources)
|
||||
{
|
||||
global $config;
|
||||
$timespan_def = null;
|
||||
$timespans = Config::get('timespan');
|
||||
if (!isset($opts['timespan'])) {
|
||||
$timespan_def = reset($config['timespan']);
|
||||
$timespan_def = reset($timespans);
|
||||
} else {
|
||||
foreach ($config['timespan'] as &$ts) {
|
||||
foreach ($timespans as &$ts) {
|
||||
if ($ts['name'] == $opts['timespan']) {
|
||||
$timespan_def = $ts;
|
||||
}
|
||||
|
@ -891,8 +879,8 @@ function collectd_draw_meta_line(&$opts, &$sources)
|
|||
array_unshift($opts['rrd_opts'], '-o');
|
||||
}
|
||||
|
||||
// $cmd = array(RRDTOOL, 'graph', '-', '-E', '-a', 'PNG', '-w', $config['rrd_width'], '-h', $config['rrd_height'], '-t', $opts['title']);
|
||||
// $cmd = array_merge($cmd, $config['rrd_opts_array'], $opts['rrd_opts']);
|
||||
// $cmd = array(RRDTOOL, 'graph', '-', '-E', '-a', 'PNG', '-w', Config::get('rrd_width'), '-h', Config::get('rrd_height'), '-t', $opts['title']);
|
||||
// $cmd = array_merge($cmd, Config::get('rrd_opts_array'), $opts['rrd_opts']);
|
||||
$cmd = array(
|
||||
RRDTOOL,
|
||||
'graph',
|
||||
|
@ -901,12 +889,12 @@ function collectd_draw_meta_line(&$opts, &$sources)
|
|||
'-a',
|
||||
'PNG',
|
||||
'-w',
|
||||
$config['rrd_width'],
|
||||
Config::get('rrd_width'),
|
||||
'-h',
|
||||
$config['rrd_height'],
|
||||
Config::get('rrd_height'),
|
||||
);
|
||||
|
||||
if ($config['rrd_width'] <= '300') {
|
||||
if (Config::get('rrd_width') <= '300') {
|
||||
$small_opts = array(
|
||||
'--font',
|
||||
'LEGEND:7:mono',
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
use LibreNMS\Config;
|
||||
|
||||
if (isset($settings['mode_select']) && $settings['mode_select'] !== '') {
|
||||
$mode = $settings['mode_select'];
|
||||
|
@ -28,7 +29,7 @@ $select_modes = array(
|
|||
'2' => 'devices and services',
|
||||
);
|
||||
|
||||
if ($config['webui']['availability_map_compact'] == 1) {
|
||||
if (Config::get('webui.availability_map_compact') == 1) {
|
||||
$compact_tile = $settings['tile_size'];
|
||||
}
|
||||
|
||||
|
@ -46,7 +47,7 @@ if (defined('SHOW_SETTINGS')) {
|
|||
</div>
|
||||
</div>';
|
||||
|
||||
if ($config['webui']['availability_map_compact'] === false) {
|
||||
if (Config::get('webui.availability_map_compact') === false) {
|
||||
$common_output[] = '
|
||||
<div class="form-group">
|
||||
<div class="col-sm-4">
|
||||
|
@ -62,7 +63,7 @@ if (defined('SHOW_SETTINGS')) {
|
|||
';
|
||||
}
|
||||
|
||||
if ($config['webui']['availability_map_compact'] == 1) {
|
||||
if (Config::get('webui.availability_map_compact') == 1) {
|
||||
$common_output[] = '
|
||||
<div class="form-group">
|
||||
<div class="col-sm-4">
|
||||
|
@ -103,7 +104,7 @@ if (defined('SHOW_SETTINGS')) {
|
|||
<div class="col-sm-6">
|
||||
<select name="mode_select" class="form-control">';
|
||||
|
||||
if ($config['show_services'] == 0) {
|
||||
if (Config::get('show_services') == 0) {
|
||||
$common_output[] = '<option value="0" selected>only devices</option>';
|
||||
} else {
|
||||
foreach ($select_modes as $mode_select => $option) {
|
||||
|
@ -120,7 +121,7 @@ if (defined('SHOW_SETTINGS')) {
|
|||
</div>
|
||||
</div>';
|
||||
|
||||
if ($config['webui']['availability_map_compact'] == 1) {
|
||||
if (Config::get('webui.availability_map_compact') == 1) {
|
||||
$common_outputp[] = '
|
||||
<div class="form-group">
|
||||
<div class="col-sm-4">
|
||||
|
@ -156,7 +157,7 @@ if (defined('SHOW_SETTINGS')) {
|
|||
$service_ignored_count = 0;
|
||||
$service_disabled_count = 0;
|
||||
|
||||
if ($config['webui']['availability_map_sort_status'] == 1) {
|
||||
if (Config::get('webui.availability_map_sort_status') == 1) {
|
||||
$deviceOrderBy = 'status';
|
||||
$serviceOrderBy = '`S`.`service_status` DESC';
|
||||
} else {
|
||||
|
@ -166,7 +167,7 @@ if (defined('SHOW_SETTINGS')) {
|
|||
|
||||
if ($mode == 0 || $mode == 2) {
|
||||
// Only show devices if mode is 0 or 2 (Only Devices or both)
|
||||
if ($config['webui']['availability_map_use_device_groups'] != 0) {
|
||||
if (Config::get('webui.availability_map_use_device_groups') != 0) {
|
||||
$device_group = 'SELECT `D`.`device_id` FROM `device_group_device` AS `D` WHERE `device_group_id` = ?';
|
||||
$in_devices = dbFetchColumn($device_group, [$_SESSION['group_view']]);
|
||||
}
|
||||
|
@ -187,7 +188,7 @@ if (defined('SHOW_SETTINGS')) {
|
|||
$sql .= '(`D`.`status` IN (0,1,2) OR `D`.`ignore` = 1 OR `D`.`disabled` = 1)';
|
||||
}
|
||||
|
||||
if ($config['webui']['availability_map_use_device_groups'] != 0 && !empty($in_devices)) {
|
||||
if (Config::get('webui.availability_map_use_device_groups') != 0 && !empty($in_devices)) {
|
||||
$sql .= " AND `D`.`device_id` IN " . dbGenPlaceholders(count($in_devices));
|
||||
$param = array_merge($param, $in_devices);
|
||||
}
|
||||
|
@ -206,7 +207,7 @@ if (defined('SHOW_SETTINGS')) {
|
|||
$deviceLabel = "label-default";
|
||||
$host_ignored_count++;
|
||||
} elseif ($device['status'] == '1') {
|
||||
if (($device['uptime'] < $config['uptime_warning']) && ($device['uptime'] != 0)) {
|
||||
if (($device['uptime'] < Config::get('uptime_warning')) && ($device['uptime'] != 0)) {
|
||||
$deviceState = 'warn';
|
||||
$deviceLabel = 'label-warning';
|
||||
$deviceLabelOld = 'availability-map-oldview-box-warn';
|
||||
|
@ -225,12 +226,12 @@ if (defined('SHOW_SETTINGS')) {
|
|||
}
|
||||
$device_system_name = format_hostname($device);
|
||||
|
||||
if ($config['webui']['availability_map_compact'] == 0) {
|
||||
if (Config::get('webui.availability_map_compact') == 0) {
|
||||
if ($directpage == "yes") {
|
||||
$deviceIcon = getIconTag($device);
|
||||
$temp_output[] = '
|
||||
<a href="' .generate_device_url($device). '" title="' . $device_system_name . " - " . formatUptime($device['uptime']) . '">
|
||||
<div class="device-availability ' . $deviceState . '" style="width:' . $config['webui']['availability_map_box_size'] . 'px;">
|
||||
<div class="device-availability ' . $deviceState . '" style="width:' . Config::get('webui.availability_map_box_size') . 'px;">
|
||||
<span class="availability-label label ' . $deviceLabel . ' label-font-border">' . $deviceState . '</span>
|
||||
<span class="device-icon">' . $deviceIcon . '</span><br>
|
||||
<span class="small">' . shorthost($device_system_name) . '</span>
|
||||
|
@ -252,7 +253,7 @@ if (defined('SHOW_SETTINGS')) {
|
|||
}
|
||||
}
|
||||
|
||||
if (($mode == 1 || $mode == 2) && ($config['show_services'] != 0)) {
|
||||
if (($mode == 1 || $mode == 2) && (Config::get('show_services') != 0)) {
|
||||
if (LegacyAuth::user()->hasGlobalRead()) {
|
||||
$service_query = 'select `S`.`service_type`, `S`.`service_id`, `S`.`service_desc`, `S`.`service_status`, `D`.`hostname`, `D`.`sysName`, `D`.`device_id`, `D`.`os`, `D`.`icon` from services S, devices D where `S`.`device_id` = `D`.`device_id` ORDER BY '.$serviceOrderBy.';';
|
||||
$service_par = array();
|
||||
|
@ -281,12 +282,12 @@ if (defined('SHOW_SETTINGS')) {
|
|||
}
|
||||
$service_system_name = format_hostname($service);
|
||||
|
||||
if ($config['webui']['availability_map_compact'] == 0) {
|
||||
if (Config::get('webui.availability_map_compact') == 0) {
|
||||
if ($directpage == "yes") {
|
||||
$deviceIcon = getIconTag($service);
|
||||
$temp_output[] = '
|
||||
<a href="' . generate_url(array('page' => 'device', 'tab' => 'services', 'device' => $service['device_id'])) . '" title="' . $service_system_name . " - " . $service['service_type'] . " - " . $service['service_desc'] . '">
|
||||
<div class="service-availability ' . $serviceState . '" style="width:' . $config['webui']['availability_map_box_size'] . 'px;">
|
||||
<div class="service-availability ' . $serviceState . '" style="width:' . Config::get('webui.availability_map_box_size') . 'px;">
|
||||
<span class="service-name-label label ' . $serviceLabel . ' label-font-border">' . $service["service_type"] . '</span>
|
||||
<span class="availability-label label ' . $serviceLabel . ' label-font-border">' . $serviceState . '</span>
|
||||
<span class="device-icon">' . $deviceIcon . '</span><br>
|
||||
|
@ -319,7 +320,7 @@ if (defined('SHOW_SETTINGS')) {
|
|||
<span class="page-availability-title">Availability map for</span>
|
||||
<select id="mode" class="page-availability-report-select" name="mode">';
|
||||
|
||||
if ($config['show_services'] == 0) {
|
||||
if (Config::get('show_services') == 0) {
|
||||
$temp_header[] = '<option value="0" selected>only devices</option>';
|
||||
} else {
|
||||
foreach ($select_modes as $mode_select => $option) {
|
||||
|
@ -337,7 +338,7 @@ if (defined('SHOW_SETTINGS')) {
|
|||
</div>
|
||||
<div class="page-availability-title-right">';
|
||||
|
||||
if (($config['webui']['availability_map_use_device_groups'] != 0) && ($mode == 0 || $mode == 2)) {
|
||||
if ((Config::get('webui.availability_map_use_device_groups') != 0) && ($mode == 0 || $mode == 2)) {
|
||||
$sql = 'SELECT `G`.`id`, `G`.`name` FROM `device_groups` AS `G`';
|
||||
$dev_groups = dbFetchRows($sql);
|
||||
|
||||
|
@ -389,7 +390,7 @@ if (defined('SHOW_SETTINGS')) {
|
|||
</div>';
|
||||
}
|
||||
|
||||
if (($mode == 1 || $mode == 2) && ($config['show_services'] != 0)) {
|
||||
if (($mode == 1 || $mode == 2) && (Config::get('show_services') != 0)) {
|
||||
$temp_header[] = '
|
||||
<div class="' . $serviceClass . '">
|
||||
<span>Total services</span>
|
||||
|
|
|
@ -12,7 +12,7 @@ $temp_output = '
|
|||
<th><span class="red">Down</span></th>
|
||||
<th><span class="grey">Ignored</span></th>
|
||||
<th><span class="black">Disabled</span></th>
|
||||
'.($config['summary_errors'] ? '<th>Errored</th>' : '').'
|
||||
' . (\LibreNMS\Config::get('summary_errors') ? '<th>Errored</th>' : '') . '
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -23,7 +23,7 @@ $temp_output = '
|
|||
<td><a href="devices/state=down/format=list_detail/"><span class="red"> '.$devices['down'].'</span></a></td>
|
||||
<td><a href="devices/ignore=1/format=list_detail/"><span class="grey"> '.$devices['ignored'].'</span></a></td>
|
||||
<td><a href="devices/disabled=1/format=list_detail/"><span class="black"> '.$devices['disabled'].'</span></a></td>
|
||||
'.($config['summary_errors'] ? '<td>-</td>' : '').'
|
||||
' . (\LibreNMS\Config::get('summary_errors') ? '<td>-</td>' : '') . '
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="ports/">Ports</a></td>
|
||||
|
@ -32,9 +32,9 @@ $temp_output = '
|
|||
<td><a href="ports/format=list_detail/state=down/"><span class="red"> '.$ports['down'].'</span></a></td>
|
||||
<td><a href="ports/format=list_detail/ignore=1/"><span class="grey"> '.$ports['ignored'].'</span></a></td>
|
||||
<td><a href="ports/format=list_detail/state=admindown/"><span class="black"> '.$ports['shutdown'].'</span></a></td>
|
||||
'.($config['summary_errors'] ? '<td><a href="ports/format=list_detail/errors=1/"><span class="black"> '.$ports['errored'].'</span></a></td>' : '').'
|
||||
' . (\LibreNMS\Config::get('summary_errors') ? '<td><a href="ports/format=list_detail/errors=1/"><span class="black"> ' . $ports['errored'] . '</span></a></td>' : '') . '
|
||||
</tr>';
|
||||
if ($config['show_services']) {
|
||||
if (\LibreNMS\Config::get('show_services')) {
|
||||
$temp_output .= '
|
||||
<tr>
|
||||
<td><a href="services/">Services</a></td>
|
||||
|
@ -43,7 +43,7 @@ if ($config['show_services']) {
|
|||
<td><a href="services/state=critical/view=details/"><span class="red"> '.$services['down'].'</span></a></td>
|
||||
<td><a href="services/ignore=1/view=details/"><span class="grey"> '.$services['ignored'].'</span></a></td>
|
||||
<td><a href="services/disabled=1/view=details/"><span class="black"> '.$services['disabled'].'</span></a></td>
|
||||
'.($config['summary_errors'] ? '<td>-</td>' : '').'
|
||||
' . (\LibreNMS\Config::get('summary_errors') ? '<td>-</td>' : '') . '
|
||||
</tr>';
|
||||
}
|
||||
$temp_output .= '
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
use LibreNMS\Config;
|
||||
|
||||
require_once 'includes/html/object-cache.inc.php';
|
||||
|
||||
$temp_output = '
|
||||
|
@ -11,7 +14,7 @@ $temp_output = '
|
|||
<th><a href="ports/">Ports</a></th>
|
||||
';
|
||||
|
||||
if ($config['show_services']) {
|
||||
if (Config::get('show_services')) {
|
||||
$temp_output .= '
|
||||
<th><a href="services/">Services</a></th>
|
||||
';
|
||||
|
@ -26,7 +29,7 @@ $temp_output .= '
|
|||
<td><a href="devices/format=list_detail/state=up/"><span class="green">'. $devices['up'] .'</span></a></td>
|
||||
<td><a href="ports/format=list_detail/state=up/"><span class="green">'. $ports['up'] .'</span></a></td>
|
||||
';
|
||||
if ($config['show_services']) {
|
||||
if (Config::get('show_services')) {
|
||||
$temp_output .= '
|
||||
<td><a href="services/view=details/state=ok/"><span class="green">'. $services['up'] .'</span></a></td>
|
||||
';
|
||||
|
@ -40,7 +43,7 @@ $temp_output .= '
|
|||
<td><a href="ports/format=list_detail/state=down/"><span class="red">'. $ports['down'] .'</span></a></td>
|
||||
';
|
||||
|
||||
if ($config['show_services']) {
|
||||
if (Config::get('show_services')) {
|
||||
$temp_output .= '
|
||||
<td><a href="services/view=details/state=critical/"><span class="red">'. $services['down'] .'</span></a></td>
|
||||
';
|
||||
|
@ -54,7 +57,7 @@ $temp_output .= '
|
|||
<td><a href="ports/format=list_detail/ignore=1/"><span class="grey">'. $ports['ignored'] .'</span></a></td>
|
||||
';
|
||||
|
||||
if ($config['show_services']) {
|
||||
if (Config::get('show_services')) {
|
||||
$temp_output .= '
|
||||
<td><a href="services/view=details/ignore=1/"><span class="grey">'. $services['ignored'] .'</span></a></td>
|
||||
';
|
||||
|
@ -68,13 +71,13 @@ $temp_output .= '
|
|||
<td><a href="ports/format=list_detail/state=admindown/"><span class="black">'. $ports['shutdown'] .'</span></a></td>
|
||||
';
|
||||
|
||||
if ($config['show_services']) {
|
||||
if (Config::get('show_services')) {
|
||||
$temp_output .= '
|
||||
<td><a href="services/view=details/disabled=1/"><span class="black">'. $services['disabled'] .'</span></a></td>
|
||||
';
|
||||
}
|
||||
|
||||
if ($config['summary_errors']) {
|
||||
if (Config::get('summary_errors')) {
|
||||
$temp_output .= '
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -82,7 +85,7 @@ if ($config['summary_errors']) {
|
|||
<td>-</td>
|
||||
<td><a href="ports/format=list_detail/errors=1/"><span class="black"> '.$ports['errored'].'</span></a></td>
|
||||
';
|
||||
if ($config['show_services']) {
|
||||
if (Config::get('show_services')) {
|
||||
$temp_output .= '
|
||||
<td>-</td>
|
||||
';
|
||||
|
@ -97,7 +100,7 @@ $temp_output .= '
|
|||
<td><a href="ports/"><span>'. $ports['count'] .'</span></a></td>
|
||||
';
|
||||
|
||||
if ($config['show_services']) {
|
||||
if (Config::get('show_services')) {
|
||||
$temp_output .= '
|
||||
<td><a href="services/"><span>'. $services['count'] .'</span></a></td>
|
||||
';
|
||||
|
|
|
@ -47,7 +47,7 @@ foreach (getlocations() as $location_row) {
|
|||
$count = 0;
|
||||
$down = 0;
|
||||
foreach (dbFetchRows("SELECT `device_id`, `hostname`, `status` FROM `devices` WHERE `location_id` = ? && `disabled` = 0 && `ignore` = 0 GROUP BY `hostname`", [$location_id]) as $device) {
|
||||
if ($config['frontpage_globe']['markers'] == 'devices' || empty($config['frontpage_globe']['markers'])) {
|
||||
if (\LibreNMS\Config::get('frontpage_globe.markers') == 'devices' || empty(\LibreNMS\Config::get('frontpage_globe.markers'))) {
|
||||
$devices[] = $device['hostname'];
|
||||
$count++;
|
||||
if ($device['status'] == "0") {
|
||||
|
@ -56,7 +56,7 @@ foreach (getlocations() as $location_row) {
|
|||
} else {
|
||||
$devices_up[] = $device;
|
||||
}
|
||||
} elseif ($config['frontpage_globe']['markers'] == 'ports') {
|
||||
} elseif (\LibreNMS\Config::get('frontpage_globe.markers') == 'ports') {
|
||||
foreach (dbFetchRows("SELECT ifName,ifOperStatus,ifAdminStatus FROM ports WHERE ports.device_id = ? && ports.ignore = 0 && ports.disabled = 0 && ports.deleted = 0", array($device['device_id'])) as $port) {
|
||||
$count++;
|
||||
if ($port['ifOperStatus'] == 'down' && $port['ifAdminStatus'] == 'up') {
|
||||
|
@ -69,17 +69,17 @@ foreach (getlocations() as $location_row) {
|
|||
}
|
||||
}
|
||||
$pdown = $count ? ($down / $count)*100 : 0;
|
||||
if ($config['frontpage_globe']['markers'] == 'devices' || empty($config['frontpage_globe']['markers'])) {
|
||||
if (\LibreNMS\Config::get('frontpage_globe.markers') == 'devices' || empty(\LibreNMS\Config::get('frontpage_globe.markers'))) {
|
||||
$devices_down = array_merge(array(count($devices_up). " Devices OK"), $devices_down);
|
||||
} elseif ($config['frontpage_globe']['markers'] == 'ports') {
|
||||
} elseif (\LibreNMS\Config::get('frontpage_globe.markers') == 'ports') {
|
||||
$devices_down = array_merge(array(count($devices_up). " Ports OK"), $devices_down);
|
||||
}
|
||||
$locations[] = " ['".$location."', ".$pdown.", ".$count.", '".implode(",<br/> ", $devices_down)."']";
|
||||
}
|
||||
$temp_output .= implode(",\n", $locations);
|
||||
|
||||
$map_world = $config['frontpage_globe']['region'] ? $config['frontpage_globe']['region'] : 'world';
|
||||
$map_countries = $config['frontpage_globe']['resolution'] ? $config['frontpage_globe']['resolution'] : 'countries';
|
||||
$map_world = \LibreNMS\Config::get('frontpage_globe.region', 'world');
|
||||
$map_countries = \LibreNMS\Config::get('frontpage_globe.resolution', 'countries');
|
||||
|
||||
$temp_output .= "
|
||||
]);
|
||||
|
|
|
@ -72,7 +72,7 @@ if (!empty($filter_device)) {
|
|||
';
|
||||
}
|
||||
|
||||
if (isset($config['graylog']['timezone'])) {
|
||||
if (\LibreNMS\Config::has('graylog.timezone')) {
|
||||
$timezone = 'row.timestamp;';
|
||||
} else {
|
||||
$timezone = 'moment.parseZone(row.timestamp).local().format("YYYY-MM-DD HH:MM:SS");';
|
||||
|
|
|
@ -12,7 +12,7 @@ echo "<div class='row'>
|
|||
<div class='panel panel-default panel-condensed device-overview'>
|
||||
<div class='panel-heading'>";
|
||||
|
||||
if ($config['overview_show_sysDescr']) {
|
||||
if (Config::get('overview_show_sysDescr')) {
|
||||
echo '<i class="fa fa-id-card fa-lg icon-theme" aria-hidden="true"></i> <strong>';
|
||||
echo Config::get('overview_show_sysDescr', true) ? $device['sysDescr'] : 'System';
|
||||
echo '</strong>';
|
||||
|
@ -34,7 +34,7 @@ if ($device['features']) {
|
|||
$device['features'] = '('.$device['features'].')';
|
||||
}
|
||||
|
||||
$device['os_text'] = $config['os'][$device['os']]['text'];
|
||||
$device['os_text'] = Config::get("os.{$device['os']}.text");
|
||||
|
||||
echo '<div class="row">
|
||||
<div class="col-sm-4">System Name</div>
|
||||
|
@ -43,7 +43,7 @@ echo '<div class="row">
|
|||
|
||||
if (!empty($device['ip'])) {
|
||||
echo "<div class='row'><div class='col-sm-4'>Resolved IP</div><div class='col-sm-8'>{$device['ip']}</div></div>";
|
||||
} elseif ($config['force_ip_to_sysname'] === true) {
|
||||
} elseif (Config::get('force_ip_to_sysname') === true) {
|
||||
try {
|
||||
$ip = IP::parse($device['hostname']);
|
||||
echo "<div class='row'><div class='col-sm-4'>IP Address</div><div class='col-sm-8'>$ip</div></div>";
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
use LibreNMS\Config;
|
||||
|
||||
echo getLogoTag($device, 'device-icon-header pull-left') .'
|
||||
<div class="pull-left" style="margin-top: 5px;">';
|
||||
|
||||
|
@ -17,22 +19,22 @@ echo '
|
|||
|
||||
|
||||
if ($device['snmp_disable']) {
|
||||
$graphs = $config['os']['ping']['over'];
|
||||
} elseif (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'];
|
||||
$graphs = Config::get('os.ping.over');
|
||||
} elseif (Config::has("os.{$device['os']}.over")) {
|
||||
$graphs = Config::get("os.{$device['os']}.over");
|
||||
} elseif (isset($device['os_group']) && Config::has("os.{$device['os_group']}.over")) {
|
||||
$graphs = Config::get("os.{$device['os_group']}.over");
|
||||
} else {
|
||||
$graphs = $config['os']['default']['over'];
|
||||
$graphs = Config::get('os.default.over');
|
||||
}
|
||||
|
||||
$graph_array = array();
|
||||
$graph_array['height'] = '100';
|
||||
$graph_array['width'] = '310';
|
||||
$graph_array['to'] = $config['time']['now'];
|
||||
$graph_array['to'] = Config::get('time.now');
|
||||
$graph_array['device'] = $device['device_id'];
|
||||
$graph_array['type'] = 'device_bits';
|
||||
$graph_array['from'] = $config['time']['day'];
|
||||
$graph_array['from'] = Config::get('time.day');
|
||||
$graph_array['legend'] = 'no';
|
||||
$graph_array['popup_title'] = $descr;
|
||||
|
||||
|
@ -40,7 +42,7 @@ $graph_array['height'] = '45';
|
|||
$graph_array['width'] = '150';
|
||||
$graph_array['bg'] = 'FFFFFF00';
|
||||
|
||||
if (device_permitted($device['device_id']) || $config['allow_unauth_graphs']) {
|
||||
if (device_permitted($device['device_id']) || Config::get('allow_unauth_graphs')) {
|
||||
echo '<div class="pull-right">';
|
||||
foreach ($graphs as $entry) {
|
||||
if ($entry['graph']) {
|
||||
|
|
|
@ -25,7 +25,7 @@ if (!isset($module) && validate_device_id($device['device_id']) === false) {
|
|||
$state = 0;
|
||||
}
|
||||
|
||||
if (isset($attribs['discover_'.$module]) && $attribs['discover_'.$module] != $config['discover_modules'][$module]) {
|
||||
if (isset($attribs['discover_' . $module]) && $attribs['discover_' . $module] != \LibreNMS\Config::get("discover_modules.$module")) {
|
||||
del_dev_attrib($device, $module);
|
||||
} else {
|
||||
set_dev_attrib($device, $module, $state);
|
||||
|
|
|
@ -24,7 +24,7 @@ if (!isset($module) && validate_device_id($device['device_id']) === false) {
|
|||
$state = 0;
|
||||
}
|
||||
|
||||
if (isset($attribs['poll_'.$module]) && $attribs['poll_'.$module] != $config['poller_modules'][$module]) {
|
||||
if (isset($attribs['poll_' . $module]) && $attribs['poll_' . $module] != \LibreNMS\Config::get("poller_modules.$module")) {
|
||||
del_dev_attrib($device, $module);
|
||||
} else {
|
||||
set_dev_attrib($device, $module, $state);
|
||||
|
|
|
@ -23,7 +23,7 @@ if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
|||
$transport = $vars['transport'] ?: null;
|
||||
$transport_id = $vars['transport_id'] ?: null;
|
||||
|
||||
require_once $config['install_dir'].'/includes/alerts.inc.php';
|
||||
require_once Config::get('install_dir') . '/includes/alerts.inc.php';
|
||||
$tmp = array(dbFetchRow('select device_id,hostname,sysDescr,version,hardware,location_id from devices order by device_id asc limit 1'));
|
||||
$tmp['contacts'] = GetContacts($tmp);
|
||||
$obj = array(
|
||||
|
@ -33,7 +33,7 @@ $obj = array(
|
|||
"version" => $tmp[0]['version'],
|
||||
"hardware" => $tmp[0]['hardware'],
|
||||
"location" => $tmp[0]['location'],
|
||||
"title" => "Testing transport from ".$config['project_name'],
|
||||
"title" => "Testing transport from " . Config::get('project_name'),
|
||||
"elapsed" => "11s",
|
||||
"id" => "000",
|
||||
"faults" => false,
|
||||
|
|
|
@ -40,7 +40,7 @@ if (!empty($ifName) && is_numeric($port_id) && is_numeric($port_id)) {
|
|||
$device_tune = get_dev_attrib($device, 'override_rrdtool_tune');
|
||||
if ($port_tune == "true" ||
|
||||
($device_tune == "true" && $port_tune != 'false') ||
|
||||
($config['rrdtool_tune'] == "true" && $port_tune != 'false' && $device_tune != 'false')) {
|
||||
(\LibreNMS\Config::get('rrdtool_tune') == "true" && $port_tune != 'false' && $device_tune != 'false')) {
|
||||
$rrdfile = get_port_rrdfile_path($device['hostname'], $port_id);
|
||||
rrdtool_tune('port', $rrdfile, $speed);
|
||||
}
|
||||
|
|
|
@ -20,8 +20,8 @@ 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)) {
|
||||
foreach (get_matching_files(\LibreNMS\Config::get('html_dir') . '/includes/front/', '/^top_.*\.php$/') as $file) {
|
||||
if (($file == 'top_ports.inc.php' && \LibreNMS\Config::get('top_ports') == 0) || ($file == 'top_device_bits.inc.php' && \LibreNMS\Config::get('top_devices') == 0)) {
|
||||
} else {
|
||||
echo "<div class=box>\n";
|
||||
include_once $file;
|
||||
|
|
|
@ -17,7 +17,7 @@ use LibreNMS\Authentication\LegacyAuth;
|
|||
|
||||
$minutes = 15;
|
||||
$seconds = ($minutes * 60);
|
||||
$top = $config['front_page_settings']['top']['devices'];
|
||||
$top = \LibreNMS\Config::get('front_page_settings.top.devices');
|
||||
if (LegacyAuth::user()->hasGlobalRead()) {
|
||||
$query = "
|
||||
SELECT *, sum(p.ifInOctets_rate + p.ifOutOctets_rate) as total
|
||||
|
@ -49,14 +49,7 @@ if (LegacyAuth::user()->hasGlobalRead()) {
|
|||
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 '<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, \LibreNMS\Config::get('time.day'), \LibreNMS\Config::get('time.now'), 'device_bits', 'no', 150, 21, '&', 'top10'), array(), 0, 0, 0).'</td>'."</tr>\n";
|
||||
}
|
||||
|
||||
echo "</table>\n";
|
||||
|
|
|
@ -17,7 +17,7 @@ use LibreNMS\Authentication\LegacyAuth;
|
|||
|
||||
$minutes = 15;
|
||||
$seconds = ($minutes * 60);
|
||||
$top = $config['front_page_settings']['top']['ports'];
|
||||
$top = \LibreNMS\Config::get('front_page_settings.top.ports');
|
||||
if (LegacyAuth::user()->hasGlobalRead()) {
|
||||
$query = "
|
||||
SELECT *, p.ifInOctets_rate + p.ifOutOctets_rate as total
|
||||
|
|
|
@ -134,11 +134,9 @@ function escape_quotes($text)
|
|||
|
||||
function generate_overlib_content($graph_array, $text)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$overlib_content = '<div class=overlib><span class=overlib-text>' . $text . '</span><br />';
|
||||
foreach (array('day', 'week', 'month', 'year') as $period) {
|
||||
$graph_array['from'] = $config['time'][$period];
|
||||
$graph_array['from'] = Config::get("time.$period");
|
||||
$overlib_content .= escape_quotes(generate_graph_tag($graph_array));
|
||||
}
|
||||
|
||||
|
@ -168,14 +166,12 @@ function generate_device_url($device, $vars = array())
|
|||
|
||||
function generate_device_link($device, $text = null, $vars = array(), $start = 0, $end = 0, $escape_text = 1, $overlib = 1)
|
||||
{
|
||||
global $config;
|
||||
|
||||
if (!$start) {
|
||||
$start = $config['time']['day'];
|
||||
$start = Config::get('time.day');
|
||||
}
|
||||
|
||||
if (!$end) {
|
||||
$end = $config['time']['now'];
|
||||
$end = Config::get('time.now');
|
||||
}
|
||||
|
||||
$class = devclass($device);
|
||||
|
@ -186,13 +182,13 @@ function generate_device_link($device, $text = null, $vars = array(), $start = 0
|
|||
$text = format_hostname($device, $text);
|
||||
|
||||
if ($device['snmp_disable']) {
|
||||
$graphs = $config['os']['ping']['over'];
|
||||
} elseif (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'];
|
||||
$graphs = Config::get('os.ping.over');
|
||||
} elseif (Config::has("os.{$device['os']}.over")) {
|
||||
$graphs = Config::get("os.{$device['os']}.over");
|
||||
} elseif (isset($device['os_group']) && Config::has("os.{$device['os_group']}.over")) {
|
||||
$graphs = Config::get("os.{$device['os_group']}.over");
|
||||
} else {
|
||||
$graphs = $config['os']['default']['over'];
|
||||
$graphs = Config::get('os.default.over');
|
||||
}
|
||||
|
||||
$url = generate_device_url($device, $vars);
|
||||
|
@ -204,7 +200,7 @@ function generate_device_link($device, $text = null, $vars = array(), $start = 0
|
|||
}
|
||||
|
||||
if ($device['os']) {
|
||||
$contents .= ' - ' . mres($config['os'][$device['os']]['text']);
|
||||
$contents .= ' - ' . Config::get("os.{$device['os']}.text");
|
||||
}
|
||||
|
||||
if ($device['version']) {
|
||||
|
@ -227,7 +223,7 @@ function generate_device_link($device, $text = null, $vars = array(), $start = 0
|
|||
$contents .= '<div class="overlib-box">';
|
||||
$contents .= '<span class="overlib-title">' . $graphhead . '</span><br />';
|
||||
$contents .= generate_minigraph_image($device, $start, $end, $graph);
|
||||
$contents .= generate_minigraph_image($device, $config['time']['week'], $end, $graph);
|
||||
$contents .= generate_minigraph_image($device, Config::get('time.week'), $end, $graph);
|
||||
$contents .= '</div>';
|
||||
}
|
||||
|
||||
|
@ -257,8 +253,6 @@ function overlib_link($url, $text, $contents, $class = null)
|
|||
|
||||
function generate_graph_popup($graph_array)
|
||||
{
|
||||
global $config;
|
||||
|
||||
// Take $graph_array and print day,week,month,year graps in overlib, hovered over graph
|
||||
$original_from = $graph_array['from'];
|
||||
|
||||
|
@ -268,13 +262,13 @@ function generate_graph_popup($graph_array)
|
|||
$graph_array['legend'] = 'yes';
|
||||
$graph_array['height'] = '100';
|
||||
$graph_array['width'] = '340';
|
||||
$graph_array['from'] = $config['time']['day'];
|
||||
$graph_array['from'] = Config::get('time.day');
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$graph_array['from'] = $config['time']['week'];
|
||||
$graph_array['from'] = Config::get('time.week');
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$graph_array['from'] = $config['time']['month'];
|
||||
$graph_array['from'] = Config::get('time.month');
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$graph_array['from'] = $config['time']['year'];
|
||||
$graph_array['from'] = Config::get('time.year');
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$content .= '</div>';
|
||||
|
||||
|
@ -436,7 +430,7 @@ function print_percentage_bar($width, $height, $percent, $left_text, $left_colou
|
|||
|
||||
function generate_entity_link($type, $entity, $text = null, $graph_type = null)
|
||||
{
|
||||
global $config, $entity_cache;
|
||||
global $entity_cache;
|
||||
|
||||
if (is_numeric($entity)) {
|
||||
$entity = get_entity_by_id_cache($type, $entity);
|
||||
|
@ -465,8 +459,6 @@ function generate_entity_link($type, $entity, $text = null, $graph_type = null)
|
|||
|
||||
function generate_port_link($port, $text = null, $type = null, $overlib = 1, $single_graph = 0)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$graph_array = array();
|
||||
|
||||
if (!$text) {
|
||||
|
@ -497,16 +489,16 @@ function generate_port_link($port, $text = null, $type = null, $overlib = 1, $si
|
|||
$graph_array['legend'] = 'yes';
|
||||
$graph_array['height'] = '100';
|
||||
$graph_array['width'] = '340';
|
||||
$graph_array['to'] = $config['time']['now'];
|
||||
$graph_array['from'] = $config['time']['day'];
|
||||
$graph_array['to'] = Config::get('time.now');
|
||||
$graph_array['from'] = Config::get('time.day');
|
||||
$graph_array['id'] = $port['port_id'];
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
if ($single_graph == 0) {
|
||||
$graph_array['from'] = $config['time']['week'];
|
||||
$graph_array['from'] = Config::get('time.week');
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$graph_array['from'] = $config['time']['month'];
|
||||
$graph_array['from'] = Config::get('time.month');
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$graph_array['from'] = $config['time']['year'];
|
||||
$graph_array['from'] = Config::get('time.year');
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
}
|
||||
|
||||
|
@ -611,10 +603,9 @@ function generate_port_image($args)
|
|||
|
||||
function generate_port_thumbnail($port)
|
||||
{
|
||||
global $config;
|
||||
$port['graph_type'] = 'port_bits';
|
||||
$port['from'] = $config['time']['day'];
|
||||
$port['to'] = $config['time']['now'];
|
||||
$port['from'] = Config::get('time.day');
|
||||
$port['to'] = Config::get('time.now');
|
||||
$port['width'] = 150;
|
||||
$port['height'] = 21;
|
||||
return generate_port_image($port);
|
||||
|
@ -731,8 +722,6 @@ function foldersize($path)
|
|||
|
||||
function generate_ap_link($args, $text = null, $type = null)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$args = cleanPort($args);
|
||||
if (!$text) {
|
||||
$text = fixIfName($args['label']);
|
||||
|
@ -761,15 +750,15 @@ function generate_ap_link($args, $text = null, $type = null)
|
|||
$graph_array['legend'] = 'yes';
|
||||
$graph_array['height'] = '100';
|
||||
$graph_array['width'] = '340';
|
||||
$graph_array['to'] = $config['time']['now'];
|
||||
$graph_array['from'] = $config['time']['day'];
|
||||
$graph_array['to'] = Config::get('time.now');
|
||||
$graph_array['from'] = Config::get('time.day');
|
||||
$graph_array['id'] = $args['accesspoint_id'];
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$graph_array['from'] = $config['time']['week'];
|
||||
$graph_array['from'] = Config::get('time.week');
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$graph_array['from'] = $config['time']['month'];
|
||||
$graph_array['from'] = Config::get('time.month');
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$graph_array['from'] = $config['time']['year'];
|
||||
$graph_array['from'] = Config::get('time.year');
|
||||
$content .= generate_graph_tag($graph_array);
|
||||
$content .= '</div>';
|
||||
|
||||
|
@ -789,8 +778,7 @@ function generate_ap_url($ap, $vars = array())
|
|||
|
||||
function report_this_text($message)
|
||||
{
|
||||
global $config;
|
||||
return $message . '\nPlease report this to the ' . $config['project_name'] . ' developers at ' . $config['project_issues'] . '\n';
|
||||
return $message . '\nPlease report this to the ' . Config::get('project_name') . ' developers at ' . Config::get('project_issues') . '\n';
|
||||
}//end report_this_text()
|
||||
|
||||
|
||||
|
@ -799,8 +787,6 @@ function report_this_text($message)
|
|||
|
||||
function get_matching_files($dir, $match = '/\.php$/')
|
||||
{
|
||||
global $config;
|
||||
|
||||
$list = array();
|
||||
if ($handle = opendir($dir)) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
|
@ -1176,8 +1162,6 @@ function generate_dynamic_config_panel($title, $config_groups, $items = array(),
|
|||
*/
|
||||
function get_ports_from_type($given_types)
|
||||
{
|
||||
global $config;
|
||||
|
||||
# Make the arg an array if it isn't, so subsequent steps only have to handle arrays.
|
||||
if (!is_array($given_types)) {
|
||||
$given_types = array($given_types);
|
||||
|
@ -1187,13 +1171,14 @@ function get_ports_from_type($given_types)
|
|||
# be key/valued to some other string that's actually searched for in the DB. Merge or append the
|
||||
# configured value if it's an array or a string. Or append the argument itself if there's no matching
|
||||
# entry in config.
|
||||
$search_types = array();
|
||||
$search_types = [];
|
||||
foreach ($given_types as $type) {
|
||||
if (isset($config[$type . '_descr']) === true) {
|
||||
if (is_array($config[$type . '_descr']) === true) {
|
||||
$search_types = array_merge($search_types, $config[$type . '_descr']);
|
||||
if (Config::has($type . '_descr')) {
|
||||
$type_descr = Config::get($type . '_descr');
|
||||
if (is_array($type_descr)) {
|
||||
$search_types = array_merge($search_types, $type_descr);
|
||||
} else {
|
||||
$search_types[] = $config[$type . '_descr'];
|
||||
$search_types[] = $type_descr;
|
||||
}
|
||||
} else {
|
||||
$search_types[] = $type;
|
||||
|
@ -1242,14 +1227,12 @@ function file_download($filename, $content)
|
|||
|
||||
function get_rules_from_json()
|
||||
{
|
||||
global $config;
|
||||
return json_decode(file_get_contents($config['install_dir'] . '/misc/alert_rules.json'), true);
|
||||
return json_decode(file_get_contents(Config::get('install_dir') . '/misc/alert_rules.json'), true);
|
||||
}
|
||||
|
||||
function search_oxidized_config($search_in_conf_textbox)
|
||||
{
|
||||
global $config;
|
||||
$oxidized_search_url = $config['oxidized']['url'] . '/nodes/conf_search?format=json';
|
||||
$oxidized_search_url = Config::get('oxidized.url') . '/nodes/conf_search?format=json';
|
||||
$postdata = http_build_query(
|
||||
array(
|
||||
'search_in_conf_textbox' => $search_in_conf_textbox,
|
||||
|
@ -1312,9 +1295,7 @@ function set_image_type()
|
|||
|
||||
function get_image_type()
|
||||
{
|
||||
global $config;
|
||||
|
||||
if ($config['webui']['graph_type'] === 'svg') {
|
||||
if (Config::get('webui.graph_type') === 'svg') {
|
||||
return 'image/svg+xml';
|
||||
} else {
|
||||
return 'image/png';
|
||||
|
@ -1323,15 +1304,13 @@ function get_image_type()
|
|||
|
||||
function get_oxidized_nodes_list()
|
||||
{
|
||||
global $config;
|
||||
|
||||
$context = stream_context_create(array(
|
||||
'http' => array(
|
||||
'header' => "Accept: application/json",
|
||||
)
|
||||
));
|
||||
|
||||
$data = json_decode(file_get_contents($config['oxidized']['url'] . '/nodes?format=json', false, $context), true);
|
||||
$data = json_decode(file_get_contents(Config::get('oxidized.url') . '/nodes?format=json', false, $context), true);
|
||||
|
||||
foreach ($data as $object) {
|
||||
$device = device_by_name($object['name']);
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use LibreNMS\Config;
|
||||
|
||||
/*
|
||||
* Bind9 Query Graph
|
||||
* @author Daniel Preussker <f0o@devilcode.org>
|
||||
|
@ -46,7 +48,7 @@ $array = array(
|
|||
$colours = 'merged';
|
||||
$rrd_list = array();
|
||||
|
||||
$config['graph_colours']['merged'] = array_merge($config['graph_colours']['greens'], $config['graph_colours']['blues']);
|
||||
Config::set('graph_colours.merged', array_merge(Config::get('graph_colours.greens'), Config::get('graph_colours.blues')));
|
||||
|
||||
if (rrdtool_check_rrd_exists($rrd_filename)) {
|
||||
foreach ($array as $ds) {
|
||||
|
|
|
@ -40,7 +40,7 @@ if (rrdtool_check_rrd_exists($rrd_filename)) {
|
|||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = $var['descr'];
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$rrd_list[$i]['colour'] = $config['graph_colours'][$colours][$i+2];
|
||||
$rrd_list[$i]['colour'] = \LibreNMS\Config::get("graph_colours.$colours" . ($i + 2));
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -40,7 +40,7 @@ if (rrdtool_check_rrd_exists($rrd_filename)) {
|
|||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = $var['descr'];
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$rrd_list[$i]['colour'] = $config['graph_colours'][$colours][$i];
|
||||
$rrd_list[$i]['colour'] = \LibreNMS\Config::get("graph_colours.$colours.$i");
|
||||
$rrd_list[$i]['area'] = $var['area'];
|
||||
$i++;
|
||||
}
|
||||
|
|
|
@ -17,13 +17,13 @@ $i = 0;
|
|||
$x = 0;
|
||||
|
||||
if (rrdtool_check_rrd_exists($rrd_filename)) {
|
||||
$max_colours = count($config['graph_colours'][$colours]);
|
||||
$max_colours = count(Config::get("graph_colours.$colours"));
|
||||
foreach ($array as $ds => $var) {
|
||||
$x = (($x <= $max_colours) ? $x : 0);
|
||||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = $var['descr'];
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$rrd_list[$i]['colour'] = $config['graph_colours'][$colours][$x];
|
||||
$rrd_list[$i]['colour'] = \LibreNMS\Config::get("graph_colours.$colours.$x");
|
||||
$i++;
|
||||
$x++;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ if (rrdtool_check_rrd_exists($rrd_filename)) {
|
|||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = $var['descr'];
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$rrd_list[$i]['colour'] = $config['graph_colours'][$colours][$i];
|
||||
$rrd_list[$i]['colour'] = \LibreNMS\Config::get("graph_colours.$colours.$i");
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -48,7 +48,7 @@ if (rrdtool_check_rrd_exists($rrd_filename)) {
|
|||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = $var['descr'];
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$rrd_list[$i]['colour'] = $config['graph_colours'][$colours][$i];
|
||||
$rrd_list[$i]['colour'] = \LibreNMS\Config::get("graph_colours.$colours.$i");
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -39,7 +39,7 @@ if (rrdtool_check_rrd_exists($rrd_filename)) {
|
|||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = $var['descr'];
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$rrd_list[$i]['colour'] = $config['graph_colours'][$colours][$i];
|
||||
$rrd_list[$i]['colour'] = \LibreNMS\Config::get("graph_colours.$colours.$i");
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -46,7 +46,7 @@ if (rrdtool_check_rrd_exists($rrd_filename)) {
|
|||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = $var['descr'];
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$rrd_list[$i]['colour'] = $config['graph_colours'][$colours][$i];
|
||||
$rrd_list[$i]['colour'] = \LibreNMS\Config::get("graph_colours.$colours.$i");
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -55,7 +55,7 @@ if (rrdtool_check_rrd_exists($rrd_filename)) {
|
|||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = $var['descr'];
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$rrd_list[$i]['colour'] = $config['graph_colours']['default'][$i];
|
||||
$rrd_list[$i]['colour'] = \LibreNMS\Config::get("graph_colours.default.$i");
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -47,7 +47,7 @@ if (rrdtool_check_rrd_exists($rrd_filename)) {
|
|||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = $var['descr'];
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$rrd_list[$i]['colour'] = $config['graph_colours'][$colours][$i];
|
||||
$rrd_list[$i]['colour'] = \LibreNMS\Config::get("graph_colours.$colours.$i");
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -96,7 +96,7 @@ if (rrdtool_check_rrd_exists($rrd_filename)) {
|
|||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = $var['descr'];
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$rrd_list[$i]['colour'] = $config['graph_colours']['manycolours'][$i];
|
||||
$rrd_list[$i]['colour'] = \LibreNMS\Config::get("graph_colours.manycolours.$i");
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
require 'includes/html/graphs/common.inc.php';
|
||||
|
||||
$ds = 'frequency';
|
||||
$colour_area = $config['graph_colours']['pinks'][0].'33';
|
||||
$colour_line = $config['graph_colours']['pinks'][0];
|
||||
$colour_area = \LibreNMS\Config::get('graph_colours.pinks.0') . '33';
|
||||
$colour_line = \LibreNMS\Config::get('graph_colours.pinks.0');
|
||||
$colour_area_max = 'FFEE99';
|
||||
$graph_max = 100;
|
||||
$unit_text = 'Frequency';
|
||||
|
|
|
@ -20,7 +20,7 @@ if (rrdtool_check_rrd_exists($rrd_filename)) {
|
|||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = $var['descr'];
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$rrd_list[$i]['colour'] = $config['graph_colours'][$colours][$i];
|
||||
$rrd_list[$i]['colour'] = \LibreNMS\Config::get("graph_colours.$colours.$i");
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -20,7 +20,7 @@ if (rrdtool_check_rrd_exists($rrd_filename)) {
|
|||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = $var['descr'];
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$rrd_list[$i]['colour'] = $config['graph_colours'][$colours][$i];
|
||||
$rrd_list[$i]['colour'] = \LibreNMS\Config::get("graph_colours.$colours.$i");
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
require 'includes/html/graphs/common.inc.php';
|
||||
|
||||
$ds = 'frequency';
|
||||
$colour_area = $config['graph_colours']['pinks'][0].'33';
|
||||
$colour_line = $config['graph_colours']['pinks'][0];
|
||||
$colour_area = \LibreNMS\Config::get('graph_colours.pinks.0') . '33';
|
||||
$colour_line = \LibreNMS\Config::get('graph_colours.pinks.0');
|
||||
$colour_area_max = 'FFEE99';
|
||||
$graph_max = 100;
|
||||
$unit_text = 'Frequency';
|
||||
|
|
|
@ -20,7 +20,7 @@ if (rrdtool_check_rrd_exists($rrd_filename)) {
|
|||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = $var['descr'];
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$rrd_list[$i]['colour'] = $config['graph_colours'][$colours][$i];
|
||||
$rrd_list[$i]['colour'] = \LibreNMS\Config::get("graph_colours.$colours.$i");
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -4,8 +4,8 @@ require 'includes/html/graphs/common.inc.php';
|
|||
|
||||
$scale_min = 0;
|
||||
$ds = 'uptime';
|
||||
$colour_area = $config['graph_colours']['purples'][0].'33';
|
||||
$colour_line = $config['graph_colours']['purples'][0];
|
||||
$colour_area = \LibreNMS\Config::get('graph_colours.purples.0') . '33';
|
||||
$colour_line = \LibreNMS\Config::get('graph_colours.purples.0');
|
||||
$colour_area_max = 'FFEE99';
|
||||
$graph_max = 0;
|
||||
$unit_text = 'Seconds';
|
||||
|
|
|
@ -40,7 +40,7 @@ if (rrdtool_check_rrd_exists($rrd_filename)) {
|
|||
$rrd_list[$i]['filename'] = $rrd_filename;
|
||||
$rrd_list[$i]['descr'] = $var['descr'];
|
||||
$rrd_list[$i]['ds'] = $ds;
|
||||
$rrd_list[$i]['colour'] = $config['graph_colours'][$colours][$i];
|
||||
$rrd_list[$i]['colour'] = \LibreNMS\Config::get("graph_colours.$colours.$i");
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -48,7 +48,7 @@ foreach ($rrd_list as $rrd) {
|
|||
$stack = ':STACK';
|
||||
}
|
||||
|
||||
$colour = $config['graph_colours'][$colours][$x];
|
||||
$colour = \LibreNMS\Config::get("graph_colours.$colours.$x");
|
||||
$rrd_options .= ' DEF:cur'.$x.'='.$rrd['filename'].':current:AVERAGE';
|
||||
$rrd_options .= ' DEF:peak'.$x.'='.$rrd['filename'].':peak:MAX';
|
||||
$rrd_options .= ' DEF:unique'.$x.'='.$rrd['filename'].':unique:AVERAGE';
|
||||
|
@ -65,14 +65,14 @@ foreach ($rrd_list as $rrd) {
|
|||
$totunique .= ',unique'.$x.',+';
|
||||
}
|
||||
|
||||
$x = (($x < count($config['graph_colours'][$colours]) - 1) ? $x + 1 : 0);
|
||||
$x = (($x < count(\LibreNMS\Config::get("graph_colours.$colours")) - 1) ? $x + 1 : 0);
|
||||
// $x++;
|
||||
}//end foreach
|
||||
|
||||
if (!$nototal) {
|
||||
$strlen = ((strlen($total_text) < $descr_len) ? ($descr_len - strlen($total_text)) : '0');
|
||||
$descr = (isset($total_text) ? rrdtool_escape($total_text, ($desc_len + $strlen)) : 'Total');
|
||||
$colour = $config['graph_colours'][$colours][$x];
|
||||
$colour = \LibreNMS\Config::get("graph_colours.$colours.$x");
|
||||
for ($z = 0; $z < $strlen;
|
||||
$z++) {
|
||||
$descr .= ' ';
|
||||
|
|
|
@ -38,4 +38,4 @@ $rrd_options .= " GPRINT:avg:\"\:%8.2lf\\n\"";
|
|||
$rrd_options .= ' LINE1:peak#C000FFFF:"Peak Listeners "';
|
||||
$rrd_options .= " GPRINT:peak:LAST:\"\:%8.2lf\\n\"";
|
||||
$rrd_options .= " TICK:stream_offline#B4FF00FF:1.0:\"Streaming client offline\\n\"";
|
||||
$rrd_options .= ' TICK:server_offline'.$config['warn_colour_alt'].'FF:1.0:"Streaming server offline"';
|
||||
$rrd_options .= ' TICK:server_offline' . \LibreNMS\Config::get('warn_colour_alt') . 'FF:1.0:"Streaming server offline"';
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use LibreNMS\Config;
|
||||
|
||||
/*
|
||||
* TinyDNS Query Graph
|
||||
* @author Daniel Preussker <f0o@devilcode.org>
|
||||
|
@ -46,7 +48,7 @@ $array = array(
|
|||
$colours = 'merged';
|
||||
$rrd_list = array();
|
||||
|
||||
$config['graph_colours']['merged'] = array_merge($config['graph_colours']['greens'], $config['graph_colours']['blues']);
|
||||
Config::set('graph_colours.merged', array_merge(Config::get('graph_colours.greens'), Config::get('graph_colours.blues')));
|
||||
|
||||
if (rrdtool_check_rrd_exists($rrd_filename)) {
|
||||
foreach ($array as $ds) {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
use LibreNMS\Config;
|
||||
|
||||
require 'includes/html/graphs/common.inc.php';
|
||||
|
||||
$i = 0;
|
||||
|
@ -31,7 +33,7 @@ $array = array(
|
|||
$colours = 'merged';
|
||||
$rrd_list = array();
|
||||
|
||||
$config['graph_colours']['merged'] = array_merge($config['graph_colours']['greens'], $config['graph_colours']['blues']);
|
||||
Config::set('graph_colours.merged', array_merge(Config::get('graph_colours.greens'), Config::get('graph_colours.blues')));
|
||||
|
||||
if (rrdtool_check_rrd_exists($rrd_filename)) {
|
||||
foreach ($array as $ds) {
|
||||
|
|
|
@ -47,9 +47,7 @@ $graph->xgrid->SetColor('#e0e0e0', '#efefef');
|
|||
|
||||
function YCallback($value)
|
||||
{
|
||||
global $config;
|
||||
|
||||
return format_number($value, $config['billing']['base'], 2, 1).'B';
|
||||
return format_number($value, \LibreNMS\Config::get('billing.base'), 2, 1) . 'B';
|
||||
}
|
||||
|
||||
$graph->yaxis->SetFont(FF_FONT1);
|
||||
|
|
|
@ -48,9 +48,7 @@ $graph->xgrid->SetColor('#e0e0e0', '#efefef');
|
|||
|
||||
function YCallback($value)
|
||||
{
|
||||
global $config;
|
||||
|
||||
return format_number($value, $config['billing']['base'], 2, 1).'B';
|
||||
return format_number($value, \LibreNMS\Config::get('billing.base'), 2, 1) . 'B';
|
||||
}
|
||||
|
||||
$graph->yaxis->SetFont(FF_FONT1);
|
||||
|
|
|
@ -14,7 +14,7 @@ if ($_GET['width']) {
|
|||
$width = (int)$_GET['width'];
|
||||
}
|
||||
|
||||
if ($config['trim_tobias']) {
|
||||
if (\LibreNMS\Config::get('trim_tobias')) {
|
||||
$width += 12;
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ if (isset($scale_rigid)) {
|
|||
}
|
||||
|
||||
$rrd_options .= ' -E --start '.$from.' --end '.$to.' --width '.$width.' --height '.$height.' ';
|
||||
$rrd_options .= $config['rrdgraph_def_text'].' -c FONT#'.$config['rrdgraph_def_text_color'];
|
||||
$rrd_options .= \LibreNMS\Config::get('rrdgraph_def_text') . ' -c FONT#' . \LibreNMS\Config::get('rrdgraph_def_text_color');
|
||||
|
||||
if ($_GET['bg']) {
|
||||
$rrd_options .= ' -c CANVAS#' . Clean::alphaDash($_GET['bg']) . ' ';
|
||||
|
@ -98,9 +98,9 @@ if ($height < '99') {
|
|||
}
|
||||
|
||||
if ($width <= '300') {
|
||||
$rrd_options .= ' --font LEGEND:7:'.$config['mono_font'].' --font AXIS:6:'.$config['mono_font'];
|
||||
$rrd_options .= ' --font LEGEND:7:' . \LibreNMS\Config::get('mono_font') . ' --font AXIS:6:' . \LibreNMS\Config::get('mono_font');
|
||||
} else {
|
||||
$rrd_options .= ' --font LEGEND:8:'.$config['mono_font'].' --font AXIS:7:'.$config['mono_font'];
|
||||
$rrd_options .= ' --font LEGEND:8:' . \LibreNMS\Config::get('mono_font') . ' --font AXIS:7:' . \LibreNMS\Config::get('mono_font');
|
||||
}
|
||||
|
||||
$rrd_options .= ' --font-render-mode normal';
|
||||
|
|
|
@ -23,7 +23,7 @@ $components = $components[$device['device_id']];
|
|||
include "includes/html/graphs/common.inc.php";
|
||||
$rrd_options .= " -l 0 -E ";
|
||||
$rrd_options .= " COMMENT:'GTM Pool Dropped Requests Now Avg Max\\n'";
|
||||
$colours = array_merge($config['graph_colours']['mixed'], $config['graph_colours']['manycolours']);
|
||||
$colours = array_merge(\LibreNMS\Config::get('graph_colours.mixed'), \LibreNMS\Config::get('graph_colours.manycolours'));
|
||||
$colcount = 0;
|
||||
$count = 0;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ $components = $components[$device['device_id']];
|
|||
include "includes/html/graphs/common.inc.php";
|
||||
$rrd_options .= " -l 0 -E ";
|
||||
$rrd_options .= " COMMENT:'GTM Pool Resolved Requests Now Avg Max\\n'";
|
||||
$colours = array_merge($config['graph_colours']['mixed'], $config['graph_colours']['manycolours']);
|
||||
$colours = array_merge(\LibreNMS\Config::get('graph_colours.mixed'), \LibreNMS\Config::get('graph_colours.manycolours'));
|
||||
$colcount = 0;
|
||||
$count = 0;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ $components = $components[$device['device_id']];
|
|||
include "includes/html/graphs/common.inc.php";
|
||||
$rrd_options .= " -l 0 -E ";
|
||||
$rrd_options .= " COMMENT:'Wide IP Dropped Requests Now Avg Max\\n'";
|
||||
$colours = array_merge($config['graph_colours']['mixed'], $config['graph_colours']['manycolours']);
|
||||
$colours = array_merge(\LibreNMS\Config::get('graph_colours.mixed'), \LibreNMS\Config::get('graph_colours.manycolours'));
|
||||
$colcount = 0;
|
||||
$count = 0;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ $components = $components[$device['device_id']];
|
|||
include "includes/html/graphs/common.inc.php";
|
||||
$rrd_options .= " -l 0 -E ";
|
||||
$rrd_options .= " COMMENT:'Wide IP Requests Now Avg Max\\n'";
|
||||
$colours = array_merge($config['graph_colours']['mixed'], $config['graph_colours']['manycolours']);
|
||||
$colours = array_merge(\LibreNMS\Config::get('graph_colours.mixed'), \LibreNMS\Config::get('graph_colours.manycolours'));
|
||||
$colcount = 0;
|
||||
$count = 0;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ $components = $components[$device['device_id']];
|
|||
include "includes/html/graphs/common.inc.php";
|
||||
$rrd_options .= " -l 0 -E ";
|
||||
$rrd_options .= " COMMENT:'Wide IP Resolved Requests Now Avg Max\\n'";
|
||||
$colours = array_merge($config['graph_colours']['mixed'], $config['graph_colours']['manycolours']);
|
||||
$colours = array_merge(\LibreNMS\Config::get('graph_colours.mixed'), \LibreNMS\Config::get('graph_colours.manycolours'));
|
||||
$colcount = 0;
|
||||
$count = 0;
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ $components = $keep;
|
|||
include "includes/html/graphs/common.inc.php";
|
||||
$rrd_options .= " -l 0 -E ";
|
||||
$rrd_options .= " COMMENT:'LTM Pool Members Now Avg Max\\n'";
|
||||
$colours = array_merge($config['graph_colours']['mixed'], $config['graph_colours']['manycolours'], $config['graph_colours']['manycolours']);
|
||||
$colours = array_merge(\LibreNMS\Config::get('graph_colours.mixed'), \LibreNMS\Config::get('graph_colours.manycolours'), \LibreNMS\Config::get('graph_colours.manycolours'));
|
||||
$count = 0;
|
||||
d_echo("<pre>");
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ $components = $keep;
|
|||
include "includes/html/graphs/common.inc.php";
|
||||
$rrd_options .= " -l 0 -E ";
|
||||
$rrd_options .= " COMMENT:'LTM Pool Members Now Avg Max\\n'";
|
||||
$colours = array_merge($config['graph_colours']['mixed'], $config['graph_colours']['manycolours'], $config['graph_colours']['manycolours']);
|
||||
$colours = array_merge(\LibreNMS\Config::get('graph_colours.mixed'), \LibreNMS\Config::get('graph_colours.manycolours'), \LibreNMS\Config::get('graph_colours.manycolours'));
|
||||
$count = 0;
|
||||
d_echo("<pre>");
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ $components = $keep;
|
|||
include "includes/html/graphs/common.inc.php";
|
||||
$rrd_options .= " -l 0 -E ";
|
||||
$rrd_options .= " COMMENT:'LTM Pool Members Now Avg Max\\n'";
|
||||
$colours = array_merge($config['graph_colours']['mixed'], $config['graph_colours']['manycolours'], $config['graph_colours']['manycolours']);
|
||||
$colours = array_merge(\LibreNMS\Config::get('graph_colours.mixed'), \LibreNMS\Config::get('graph_colours.manycolours'), \LibreNMS\Config::get('graph_colours.manycolours'));
|
||||
$count = 0;
|
||||
d_echo("<pre>");
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ $components = $keep;
|
|||
include "includes/html/graphs/common.inc.php";
|
||||
$rrd_options .= " -l 0 -E ";
|
||||
$rrd_options .= " COMMENT:'LTM Pool Members Now Avg Max\\n'";
|
||||
$colours = array_merge($config['graph_colours']['mixed'], $config['graph_colours']['manycolours'], $config['graph_colours']['manycolours']);
|
||||
$colours = array_merge(\LibreNMS\Config::get('graph_colours.mixed'), \LibreNMS\Config::get('graph_colours.manycolours'), \LibreNMS\Config::get('graph_colours.manycolours'));
|
||||
$count = 0;
|
||||
d_echo("<pre>");
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ $components = $keep;
|
|||
include "includes/html/graphs/common.inc.php";
|
||||
$rrd_options .= " -l 0 -E ";
|
||||
$rrd_options .= " COMMENT:'LTM Pool Members Now Avg Max\\n'";
|
||||
$colours = array_merge($config['graph_colours']['mixed'], $config['graph_colours']['manycolours'], $config['graph_colours']['manycolours']);
|
||||
$colours = array_merge(\LibreNMS\Config::get('graph_colours.mixed'), \LibreNMS\Config::get('graph_colours.manycolours'), \LibreNMS\Config::get('graph_colours.manycolours'));
|
||||
$count = 0;
|
||||
d_echo("<pre>");
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ $components = $components[$device['device_id']];
|
|||
include "includes/html/graphs/common.inc.php";
|
||||
$rrd_options .= " -l 0 -E ";
|
||||
$rrd_options .= " COMMENT:'LTM Vitrual Servers Now Avg Max\\n'";
|
||||
$colours = array_merge($config['graph_colours']['mixed'], $config['graph_colours']['manycolours']);
|
||||
$colours = array_merge(\LibreNMS\Config::get('graph_colours.mixed'), \LibreNMS\Config::get('graph_colours.manycolours'));
|
||||
$colcount = 0;
|
||||
$count = 0;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ $components = $components[$device['device_id']];
|
|||
include "includes/html/graphs/common.inc.php";
|
||||
$rrd_options .= " -l 0 -E ";
|
||||
$rrd_options .= " COMMENT:'LTM Vitrual Servers Now Avg Max\\n'";
|
||||
$colours = array_merge($config['graph_colours']['mixed'], $config['graph_colours']['manycolours']);
|
||||
$colours = array_merge(\LibreNMS\Config::get('graph_colours.mixed'), \LibreNMS\Config::get('graph_colours.manycolours'));
|
||||
$colcount = 0;
|
||||
$count = 0;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ $components = $components[$device['device_id']];
|
|||
include "includes/html/graphs/common.inc.php";
|
||||
$rrd_options .= " -l 0 -E ";
|
||||
$rrd_options .= " COMMENT:'VS Total Connections Now Avg Max\\n'";
|
||||
$colours = array_merge($config['graph_colours']['mixed'], $config['graph_colours']['manycolours']);
|
||||
$colours = array_merge(\LibreNMS\Config::get('graph_colours.mixed'), \LibreNMS\Config::get('graph_colours.manycolours'));
|
||||
$colcount = 0;
|
||||
$count = 0;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ $components = $components[$device['device_id']];
|
|||
include "includes/html/graphs/common.inc.php";
|
||||
$rrd_options .= " -l 0 -E ";
|
||||
$rrd_options .= " COMMENT:'LTM Vitrual Servers Now Avg Max\\n'";
|
||||
$colours = array_merge($config['graph_colours']['mixed'], $config['graph_colours']['manycolours']);
|
||||
$colours = array_merge(\LibreNMS\Config::get('graph_colours.mixed'), \LibreNMS\Config::get('graph_colours.manycolours'));
|
||||
$colcount = 0;
|
||||
$count = 0;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ $components = $components[$device['device_id']];
|
|||
include "includes/html/graphs/common.inc.php";
|
||||
$rrd_options .= " -l 0 -E ";
|
||||
$rrd_options .= " COMMENT:'LTM Vitrual Servers Now Avg Max\\n'";
|
||||
$colours = array_merge($config['graph_colours']['mixed'], $config['graph_colours']['manycolours']);
|
||||
$colours = array_merge(\LibreNMS\Config::get('graph_colours.mixed'), \LibreNMS\Config::get('graph_colours.manycolours'));
|
||||
$colcount = 0;
|
||||
$count = 0;
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@ $ds_out = 'OUTOCTETS';
|
|||
|
||||
foreach (dbFetchRows('SELECT * FROM `ports` WHERE `device_id` = ? AND `disabled` = 0', array($device['device_id'])) as $port) {
|
||||
$ignore = 0;
|
||||
if (is_array($config['device_traffic_iftype'])) {
|
||||
foreach ($config['device_traffic_iftype'] as $iftype) {
|
||||
if (is_array(\LibreNMS\Config::get('device_traffic_iftype'))) {
|
||||
foreach (\LibreNMS\Config::get('device_traffic_iftype') as $iftype) {
|
||||
if ($iftype == '/l2vlan/' && $device['os']=='asa') {
|
||||
// ASA (at least in multicontext) reports all interfaces as l2vlan even if they are l3
|
||||
// so every context has no graph displayed unless l2vlan are accepted for all.
|
||||
|
@ -20,8 +20,8 @@ foreach (dbFetchRows('SELECT * FROM `ports` WHERE `device_id` = ? AND `disabled`
|
|||
}
|
||||
}
|
||||
|
||||
if (is_array($config['device_traffic_descr'])) {
|
||||
foreach ($config['device_traffic_descr'] as $ifdescr) {
|
||||
if (is_array(\LibreNMS\Config::get('device_traffic_descr'))) {
|
||||
foreach (\LibreNMS\Config::get('device_traffic_descr') as $ifdescr) {
|
||||
if (preg_match($ifdescr.'i', $port['ifDescr']) || preg_match($ifdescr.'i', $port['ifName'])) {
|
||||
$ignore = 1;
|
||||
}
|
||||
|
|
|
@ -36,11 +36,7 @@ foreach ($components as $id => $array) {
|
|||
}
|
||||
|
||||
// Grab a color from the array.
|
||||
if (isset($config['graph_colours']['mixed'][$count])) {
|
||||
$color = $config['graph_colours']['mixed'][$count];
|
||||
} else {
|
||||
$color = $config['graph_colours']['oranges'][$count-7];
|
||||
}
|
||||
$color = \LibreNMS\Config::get("graph_colours.mixed.$count", \LibreNMS\Config::get('graph_colours.oranges.' . ($count - 7)));
|
||||
|
||||
$rrd_additions .= " DEF:DS" . $count . "=" . $rrd_filename . ":count:AVERAGE ";
|
||||
$rrd_additions .= " AREA:DS" . $count . "#" . $color . ":'" . str_pad(substr($components[$id]['endpoint'], 0, 15), 15) . "'" . $stack;
|
||||
|
|
|
@ -36,11 +36,7 @@ foreach ($components as $id => $array) {
|
|||
}
|
||||
|
||||
// Grab a color from the array.
|
||||
if (isset($config['graph_colours']['mixed'][$count])) {
|
||||
$color = $config['graph_colours']['mixed'][$count];
|
||||
} else {
|
||||
$color = $config['graph_colours']['oranges'][$count-7];
|
||||
}
|
||||
$color = \LibreNMS\Config::get("graph_colours.mixed.$count", \LibreNMS\Config::get('graph_colours.oranges.' . ($count - 7)));
|
||||
|
||||
$rrd_additions .= " DEF:DS" . $count . "=" . $rrd_filename . ":count:AVERAGE ";
|
||||
$rrd_additions .= " AREA:DS" . $count . "#" . $color . ":'" . str_pad(substr($components[$id]['label'], 0, 15), 15) . "'" . $stack;
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
use LibreNMS\Config;
|
||||
|
||||
require 'includes/html/collectd/config.php';
|
||||
require 'includes/html/collectd/functions.php';
|
||||
require 'includes/html/collectd/definitions.php';
|
||||
|
@ -52,14 +54,12 @@ function makeTextBlock($text, $fontfile, $fontsize, $width)
|
|||
*/
|
||||
function error($code, $code_msg, $title, $msg)
|
||||
{
|
||||
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);
|
||||
$w = (Config::get('rrd_width') + 81);
|
||||
$h = (Config::get('rrd_height') + 79);
|
||||
|
||||
$png = imagecreate($w, $h);
|
||||
$c_bkgnd = imagecolorallocate($png, 240, 240, 240);
|
||||
|
@ -92,9 +92,9 @@ function error($code, $code_msg, $title, $msg)
|
|||
|
||||
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'])) {
|
||||
if (function_exists('imagettfbbox') && is_file(Config::get('error_font'))) {
|
||||
// Detailled error message
|
||||
$errorfont = $config['error_font'];
|
||||
$errorfont = Config::get('error_font');
|
||||
$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);
|
||||
|
@ -169,9 +169,9 @@ $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::get('timespan.0.name'));
|
||||
$timespan_ok = false;
|
||||
foreach ($config['timespan'] as &$ts) {
|
||||
foreach (Config::get('timespan') as &$ts) {
|
||||
if ($ts['name'] == $timespan) {
|
||||
$timespan_ok = true;
|
||||
}
|
||||
|
@ -244,9 +244,9 @@ if ($height < '99') {
|
|||
}
|
||||
|
||||
if ($width <= '300') {
|
||||
$rrd_cmd .= ' --font LEGEND:7:'.$config['mono_font'].' --font AXIS:6:'.$config['mono_font'].' ';
|
||||
$rrd_cmd .= ' --font LEGEND:7:' . Config::get('mono_font') . ' --font AXIS:6:' . Config::get('mono_font') . ' ';
|
||||
} else {
|
||||
$rrd_cmd .= ' --font LEGEND:8:'.$config['mono_font'].' --font AXIS:7:'.$config['mono_font'].' ';
|
||||
$rrd_cmd .= ' --font LEGEND:8:' . Config::get('mono_font') . ' --font AXIS:7:' . Config::get('mono_font') . ' ';
|
||||
}
|
||||
|
||||
if (isset($_GET['debug'])) {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue