Compare commits
1 Commits
main
...
23.9.13005
Author | SHA1 | Date | |
---|---|---|---|
fa8a702a67 |
213
.phpcs.xml
Normal file
@ -0,0 +1,213 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<ruleset name="Observium ruleset">
|
||||||
|
<description>Observium rules for PHP CodeSniffer</description>
|
||||||
|
|
||||||
|
<arg value="sp"/>
|
||||||
|
<arg name="extensions" value="php"/>
|
||||||
|
|
||||||
|
<file>.</file>
|
||||||
|
|
||||||
|
<!-- <arg name="report" value="xml"/>
|
||||||
|
<arg name="report-file" value="phpcs-report.xml"/> -->
|
||||||
|
|
||||||
|
<!-- Exclude unused code. -->
|
||||||
|
<exclude-pattern>*/attic/*</exclude-pattern>
|
||||||
|
<!-- Exclude devel code. -->
|
||||||
|
<exclude-pattern>*/devel/*</exclude-pattern>
|
||||||
|
<!-- Exclude Composer vendor directory. -->
|
||||||
|
<exclude-pattern>*/vendor/*</exclude-pattern>
|
||||||
|
<!-- Weathermap exclude -->
|
||||||
|
<exclude-pattern>*/weathermap/*</exclude-pattern>
|
||||||
|
<!-- Self PHPCompatibility exclude -->
|
||||||
|
<exclude-pattern>tests/php-compatibility/*</exclude-pattern>
|
||||||
|
|
||||||
|
<!-- Strip the filepaths down to the relevant bit. -->
|
||||||
|
<arg name="basepath" value="./"/>
|
||||||
|
|
||||||
|
<!-- Check up to 8 files simultanously. -->
|
||||||
|
<arg name="parallel" value="8"/>
|
||||||
|
|
||||||
|
<!-- PHPCompatibility standard path -->
|
||||||
|
<!-- <config name="installed_paths" value="tests/php-compatibility"/> -->
|
||||||
|
|
||||||
|
<!-- Check for cross-version support for PHP 5.6 and higher. -->
|
||||||
|
<config name="testVersion" value="5.6-"/>
|
||||||
|
|
||||||
|
<!-- Run against the PHPCompatibility ruleset -->
|
||||||
|
<rule ref="PHPCompatibility">
|
||||||
|
<exclude-pattern>irc\.php$</exclude-pattern>
|
||||||
|
<exclude-pattern>*/weathermap/*</exclude-pattern>
|
||||||
|
<!-- random_bytes() already exist by compatibility lib -->
|
||||||
|
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.random_bytesFound"/>
|
||||||
|
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.random_intFound"/>
|
||||||
|
<!-- array_key_first() already exist by compatibility -->
|
||||||
|
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.array_key_firstFound"/>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- Whitelist the mysql_to_rfc3339() and mysql_another_function() functions. -->
|
||||||
|
<rule ref="PHPCompatibility.Extensions.RemovedExtensions">
|
||||||
|
<properties>
|
||||||
|
<property name="functionWhitelist" type="array" value="mysql_authenticate,mysql_auth_can_logout,mysql_auth_can_change_password,mysql_auth_change_password,mysql_auth_usermanagement,mysql_adduser,mysql_auth_user_exists,mysql_auth_username_by_id,mysql_auth_user_level,mysql_auth_user_id,mysql_deluser,mysql_auth_user_list,mysql_auth_user_info"/>
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- random_compat lib -->
|
||||||
|
<rule ref="PHPCompatibility.Classes.NewClasses.typeerrorFound">
|
||||||
|
<exclude-pattern>libs/random_compat/*</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
<rule ref="PHPCompatibility.Classes.NewClasses.errorFound">
|
||||||
|
<exclude-pattern>libs/random_compat/*</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
<rule ref="PHPCompatibility.IniDirectives.RemovedIniDirectives.mbstring_func_overloadDeprecated">
|
||||||
|
<exclude-pattern>libs/random_compat/*</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
<rule ref="PHPCompatibility.FunctionUse.RemovedFunctions.mcrypt_create_ivDeprecatedRemoved">
|
||||||
|
<exclude-pattern>libs/random_compat/*</exclude-pattern>
|
||||||
|
<exclude-pattern>libs/pear/Crypt/CHAP\.php</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
<rule ref="PHPCompatibility.Constants.RemovedConstants.mcrypt_dev_urandomDeprecatedRemoved">
|
||||||
|
<exclude-pattern>libs/random_compat/*</exclude-pattern>
|
||||||
|
<exclude-pattern>libs/pear/Crypt/CHAP\.php</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- pear chap lib excludes -->
|
||||||
|
<rule ref="PHPCompatibility.FunctionUse.RemovedFunctions.mcrypt_module_openDeprecatedRemoved">
|
||||||
|
<exclude-pattern>libs/pear/Crypt/CHAP\.php</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
<rule ref="PHPCompatibility.Constants.RemovedConstants.mcrypt_desDeprecatedRemoved">
|
||||||
|
<exclude-pattern>libs/pear/Crypt/CHAP\.php</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
<rule ref="PHPCompatibility.FunctionUse.RemovedFunctions.mcrypt_enc_get_iv_sizeDeprecatedRemoved">
|
||||||
|
<exclude-pattern>libs/pear/Crypt/CHAP\.php</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
<rule ref="PHPCompatibility.Constants.RemovedConstants.mcrypt_randDeprecatedRemoved">
|
||||||
|
<exclude-pattern>libs/pear/Crypt/CHAP\.php</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
<rule ref="PHPCompatibility.FunctionUse.RemovedFunctions.mcrypt_generic_initDeprecatedRemoved">
|
||||||
|
<exclude-pattern>libs/pear/Crypt/CHAP\.php</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
<rule ref="PHPCompatibility.FunctionUse.RemovedFunctions.mcrypt_genericDeprecatedRemoved">
|
||||||
|
<exclude-pattern>libs/pear/Crypt/CHAP\.php</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
<rule ref="PHPCompatibility.FunctionUse.RemovedFunctions.mcrypt_generic_deinitDeprecatedRemoved">
|
||||||
|
<exclude-pattern>libs/pear/Crypt/CHAP\.php</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
<rule ref="PHPCompatibility.FunctionUse.RemovedFunctions.mcrypt_module_closeDeprecatedRemoved">
|
||||||
|
<exclude-pattern>libs/pear/Crypt/CHAP\.php</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- pear net socket excludes -->
|
||||||
|
<rule ref="PHPCompatibility.IniDirectives.RemovedIniDirectives.track_errorsDeprecated">
|
||||||
|
<exclude-pattern>libs/pear/Net/Socket\.php</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
<rule ref="PHPCompatibility.Variables.RemovedPredefinedGlobalVariables.php_errormsgDeprecated">
|
||||||
|
<exclude-pattern>libs/pear/Net/Socket\.php</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
<rule ref="PHPCompatibility.FunctionUse.NewFunctions.error_clear_lastFound">
|
||||||
|
<exclude-pattern>libs/pear/Net/Socket\.php</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- Exclude shiff on specific patterns -->
|
||||||
|
<rule ref="PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection">
|
||||||
|
<exclude-pattern>includes/common\.inc\.php</exclude-pattern>
|
||||||
|
<exclude-pattern>libs/Fabiang/Xmpp/*</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
<rule ref="PHPCompatibility.Miscellaneous.ValidIntegers.HexNumericStringFound">
|
||||||
|
<exclude-pattern>tests/*</exclude-pattern>
|
||||||
|
<exclude-pattern>libs/pear/*</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
<rule ref="PHPCompatibility.IniDirectives.RemovedIniDirectives.magic_quotes_runtimeDeprecatedRemoved">
|
||||||
|
<exclude-pattern>libs/pear/Mail/mime*</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
<rule ref="PHPCompatibility.Constants.NewConstants.json_preserve_zero_fractionFound">
|
||||||
|
<exclude-pattern>includes/definitions\.inc\.php</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
<rule ref="PHPCompatibility.Extensions.RemovedExtensions.mysql_DeprecatedRemoved">
|
||||||
|
<exclude-pattern>includes/db/mysql\.inc\.php</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
<rule ref="PHPCompatibility.IniDirectives.RemovedIniDirectives.session_hash_functionRemoved">
|
||||||
|
<exclude-pattern>html/includes/authenticate\.inc\.php</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
<rule ref="PHPCompatibility.Constants.NewConstants.sodium_crypto_secretbox_keybytesFound">
|
||||||
|
<exclude-pattern>tests/IncludesEncryptTest\.php</exclude-pattern>
|
||||||
|
<exclude-pattern>includes/encrypt\.inc\.php</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
<rule ref="PHPCompatibility.Constants.NewConstants.sodium_crypto_secretbox_noncebytesFound">
|
||||||
|
<exclude-pattern>tests/IncludesEncryptTest\.php</exclude-pattern>
|
||||||
|
<exclude-pattern>includes/encrypt\.inc\.php</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
<rule ref="PHPCompatibility.FunctionUse.NewFunctions.sodium_padFound">
|
||||||
|
<exclude-pattern>tests/IncludesEncryptTest\.php</exclude-pattern>
|
||||||
|
<exclude-pattern>includes/encrypt\.inc\.php</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
<rule ref="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_secretboxFound">
|
||||||
|
<exclude-pattern>tests/IncludesEncryptTest\.php</exclude-pattern>
|
||||||
|
<exclude-pattern>includes/encrypt\.inc\.php</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
<rule ref="PHPCompatibility.Classes.NewClasses.sodiumexceptionFound">
|
||||||
|
<exclude-pattern>tests/IncludesEncryptTest\.php</exclude-pattern>
|
||||||
|
<exclude-pattern>includes/encrypt\.inc\.php</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
<rule ref="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_secretbox_openFound">
|
||||||
|
<exclude-pattern>tests/IncludesEncryptTest\.php</exclude-pattern>
|
||||||
|
<exclude-pattern>includes/encrypt\.inc\.php</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
<rule ref="PHPCompatibility.Extensions.RemovedExtensions.mcryptDeprecatedRemoved">
|
||||||
|
<exclude-pattern>tests/IncludesEncryptTest\.php</exclude-pattern>
|
||||||
|
<exclude-pattern>includes/encrypt\.inc\.php</exclude-pattern>
|
||||||
|
<exclude-pattern>libs/random_compat/*</exclude-pattern>
|
||||||
|
<exclude-pattern>libs/pear/Crypt/CHAP\.php</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
<rule ref="PHPCompatibility.FunctionUse.RemovedFunctions.mcrypt_encryptDeprecatedRemoved">
|
||||||
|
<exclude-pattern>tests/IncludesEncryptTest\.php</exclude-pattern>
|
||||||
|
<exclude-pattern>includes/encrypt\.inc\.php</exclude-pattern>
|
||||||
|
<exclude-pattern>libs/pear/Crypt/CHAP\.php</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
<rule ref="PHPCompatibility.FunctionUse.RemovedFunctions.mcrypt_decryptDeprecatedRemoved">
|
||||||
|
<exclude-pattern>tests/IncludesEncryptTest\.php</exclude-pattern>
|
||||||
|
<exclude-pattern>includes/encrypt\.inc\.php</exclude-pattern>
|
||||||
|
<exclude-pattern>libs/pear/Crypt/CHAP\.php</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
<rule ref="PHPCompatibility.Constants.RemovedConstants.mcrypt_rijndael_256DeprecatedRemoved">
|
||||||
|
<exclude-pattern>tests/IncludesEncryptTest\.php</exclude-pattern>
|
||||||
|
<exclude-pattern>includes/encrypt\.inc\.php</exclude-pattern>
|
||||||
|
<exclude-pattern>libs/pear/Crypt/CHAP\.php</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
<rule ref="PHPCompatibility.Constants.RemovedConstants.mcrypt_mode_ecbDeprecatedRemoved">
|
||||||
|
<exclude-pattern>tests/IncludesEncryptTest\.php</exclude-pattern>
|
||||||
|
<exclude-pattern>includes/encrypt\.inc\.php</exclude-pattern>
|
||||||
|
<exclude-pattern>libs/pear/Crypt/CHAP\.php</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
<rule ref="PHPCompatibility.FunctionUse.RemovedFunctions.get_magic_quotes_gpcDeprecated">
|
||||||
|
<exclude-pattern>html/includes/collectd/functions.php</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
<rule ref="PHPCompatibility.FunctionUse.NewFunctions.session_create_idFound">
|
||||||
|
<exclude-pattern>html/includes/authenticate.inc.php</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
<!-- compatability fixed in code -->
|
||||||
|
<rule ref="PHPCompatibility.FunctionUse.RemovedFunctions.ldap_control_paged_resultDeprecated">
|
||||||
|
<exclude-pattern>html/includes/authentication/ldap.inc.php</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
<rule ref="PHPCompatibility.FunctionUse.RemovedFunctions.ldap_control_paged_result_responseDeprecated">
|
||||||
|
<exclude-pattern>html/includes/authentication/ldap.inc.php</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
<rule ref="PHPCompatibility.FunctionUse.NewFunctionParameters.ldap_search_serverctrlsFound">
|
||||||
|
<exclude-pattern>html/includes/authentication/ldap.inc.php</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
<rule ref="PHPCompatibility.FunctionUse.NewFunctionParameters.ldap_parse_result_serverctrlsFound">
|
||||||
|
<exclude-pattern>html/includes/authentication/ldap.inc.php</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
<rule ref="PHPCompatibility.Constants.NewConstants.ldap_control_pagedresultsFound">
|
||||||
|
<exclude-pattern>html/includes/authentication/ldap.inc.php</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
<rule ref="PHPCompatibility.Miscellaneous.ValidIntegers.HexNumericStringFound">
|
||||||
|
<exclude-pattern>includes/entities/sensor.inc.php</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
<rule ref="PHPCompatibility.Constants.NewConstants.mysqli_client_ssl_dont_verify_server_certFound">
|
||||||
|
<exclude-pattern>includes/db/mysqli.inc.php</exclude-pattern>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- Run against a second ruleset -->
|
||||||
|
<!-- <rule ref="PSR2"/> -->
|
||||||
|
|
||||||
|
</ruleset>
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
* @package observium
|
* @package observium
|
||||||
* @subpackage cli
|
* @subpackage cli
|
||||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -16,18 +16,25 @@
|
|||||||
chdir(dirname($argv[0]));
|
chdir(dirname($argv[0]));
|
||||||
|
|
||||||
$options = getopt("dhpt");
|
$options = getopt("dhpt");
|
||||||
if (isset($options['d'])) { array_shift($argv); }
|
if (isset($options['d'])) {
|
||||||
|
array_shift($argv);
|
||||||
|
}
|
||||||
|
|
||||||
include("includes/sql-config.inc.php");
|
include("includes/observium.inc.php");
|
||||||
include("includes/discovery/functions.inc.php");
|
include("includes/discovery/functions.inc.php");
|
||||||
|
|
||||||
print_message("%g" . OBSERVIUM_PRODUCT . " " . OBSERVIUM_VERSION . "\n%WAdd Device(s)%n\n", 'color');
|
print_message("%g" . OBSERVIUM_PRODUCT . " " . OBSERVIUM_VERSION . "\n%WAdd Device(s)%n\n", 'color');
|
||||||
|
|
||||||
if (OBS_DEBUG) { print_versions(); }
|
if (OBS_DEBUG) {
|
||||||
|
print_versions();
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($options['h'])) { print_help(OBS_SCRIPT_NAME); exit; }
|
if (isset($options['h'])) {
|
||||||
|
print_help(OBS_SCRIPT_NAME);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
$snmp_options = array();
|
$snmp_options = [];
|
||||||
// Just test, do not add device
|
// Just test, do not add device
|
||||||
if (isset($options['t'])) {
|
if (isset($options['t'])) {
|
||||||
$snmp_options['test'] = TRUE;
|
$snmp_options['test'] = TRUE;
|
||||||
@ -42,12 +49,14 @@ if (isset($options['p'])) {
|
|||||||
$added = 0;
|
$added = 0;
|
||||||
|
|
||||||
if (!empty($argv[1])) {
|
if (!empty($argv[1])) {
|
||||||
$add_array = array();
|
$add_array = [];
|
||||||
if (is_file($argv[1])) {
|
if (is_file($argv[1])) {
|
||||||
// Parse file into array with devices to add
|
// Parse file into array with devices to add
|
||||||
foreach (new SplFileObject($argv[1]) as $line) {
|
foreach (new SplFileObject($argv[1]) as $line) {
|
||||||
$d = preg_split('/\s/', $line, -1, PREG_SPLIT_NO_EMPTY);
|
$d = preg_split('/\s/', $line, -1, PREG_SPLIT_NO_EMPTY);
|
||||||
if (empty($d) || strpos(reset($d), '#') === 0) { continue; }
|
if (empty($d) || strpos(reset($d), '#') === 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$add_array[] = $d;
|
$add_array[] = $d;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -67,7 +76,7 @@ if (!empty($argv[1])) {
|
|||||||
$snmp_port = 161;
|
$snmp_port = 161;
|
||||||
if (str_contains($hostname, ':') && get_ip_version($hostname) !== 6) {
|
if (str_contains($hostname, ':') && get_ip_version($hostname) !== 6) {
|
||||||
// Allow pass common hostname:port
|
// Allow pass common hostname:port
|
||||||
list($host_tmp, $port_tmp) = explode(':', $hostname, 2);
|
[$host_tmp, $port_tmp] = explode(':', $hostname, 2);
|
||||||
if (is_valid_param($port_tmp, 'port')) {
|
if (is_valid_param($port_tmp, 'port')) {
|
||||||
$hostname = $host_tmp;
|
$hostname = $host_tmp;
|
||||||
$snmp_port = $port_tmp;
|
$snmp_port = $port_tmp;
|
||||||
@ -112,7 +121,7 @@ if (!empty($argv[1])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($snmp_v3_seclevel !== "any") {
|
if ($snmp_v3_seclevel !== "any") {
|
||||||
$config['snmp']['v3'] = [ $snmp_v3_auth ];
|
$config['snmp']['v3'] = [$snmp_v3_auth];
|
||||||
}
|
}
|
||||||
} elseif ($snmp_v3_seclevel === "anp" || $snmp_v3_seclevel === "authNoPriv") {
|
} elseif ($snmp_v3_seclevel === "anp" || $snmp_v3_seclevel === "authNoPriv") {
|
||||||
|
|
||||||
@ -136,7 +145,7 @@ if (!empty($argv[1])) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$config['snmp']['v3'] = [ $snmp_v3_auth ];
|
$config['snmp']['v3'] = [$snmp_v3_auth];
|
||||||
} elseif ($snmp_v3_seclevel === "ap" || $snmp_v3_seclevel === "authPriv") {
|
} elseif ($snmp_v3_seclevel === "ap" || $snmp_v3_seclevel === "authPriv") {
|
||||||
$snmp_v3_auth['authlevel'] = "authPriv";
|
$snmp_v3_auth['authlevel'] = "authPriv";
|
||||||
$snmp_v3_args = array_slice($argv, 4);
|
$snmp_v3_args = array_slice($argv, 4);
|
||||||
@ -161,7 +170,7 @@ if (!empty($argv[1])) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$config['snmp']['v3'] = [ $snmp_v3_auth ];
|
$config['snmp']['v3'] = [$snmp_v3_auth];
|
||||||
}
|
}
|
||||||
//print_debug_vars($snmp_v3_auth);
|
//print_debug_vars($snmp_v3_auth);
|
||||||
//print_debug_vars($config['snmp']['v3']);
|
//print_debug_vars($config['snmp']['v3']);
|
||||||
@ -185,7 +194,7 @@ if (!empty($argv[1])) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$config['snmp']['community'] = ($snmp_community ? array($snmp_community) : $snmp_config_community);
|
$config['snmp']['community'] = ($snmp_community ? [$snmp_community] : $snmp_config_community);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add snmp context to params
|
// Add snmp context to params
|
||||||
@ -195,7 +204,7 @@ if (!empty($argv[1])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
print_message("Try to add $hostname:");
|
print_message("Try to add $hostname:");
|
||||||
if (in_array($snmp_version, array('v1', 'v2c', 'v3'))) {
|
if (in_array($snmp_version, ['v1', 'v2c', 'v3'])) {
|
||||||
// If snmp version passed in arguments, then use the exact version
|
// If snmp version passed in arguments, then use the exact version
|
||||||
$device_id = add_device($hostname, $snmp_version, $snmp_port, $snmp_transport, $snmp_options);
|
$device_id = add_device($hostname, $snmp_version, $snmp_port, $snmp_transport, $snmp_options);
|
||||||
} else {
|
} else {
|
||||||
@ -227,7 +236,8 @@ if ($added) {
|
|||||||
print_help(OBS_SCRIPT_NAME);
|
print_help(OBS_SCRIPT_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
function print_help($scriptname) {
|
function print_help($scriptname)
|
||||||
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
$snmp_version = get_versions('snmp');
|
$snmp_version = get_versions('snmp');
|
||||||
|
49
adduser.php
@ -7,47 +7,47 @@
|
|||||||
*
|
*
|
||||||
* @package observium
|
* @package observium
|
||||||
* @subpackage cli
|
* @subpackage cli
|
||||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
chdir(dirname($argv[0]));
|
chdir(dirname($argv[0]));
|
||||||
|
|
||||||
$options = getopt("d");
|
$options = getopt("d");
|
||||||
if (isset($options['d'])) { array_shift($argv); } // for compatibility
|
if (isset($options['d'])) {
|
||||||
|
array_shift($argv);
|
||||||
|
} // for compatibility
|
||||||
|
|
||||||
include("includes/sql-config.inc.php");
|
include("includes/observium.inc.php");
|
||||||
|
|
||||||
print_message("%g".OBSERVIUM_PRODUCT." ".OBSERVIUM_VERSION."\n%WAdd User%n\n", 'color');
|
print_message("%g" . OBSERVIUM_PRODUCT . " " . OBSERVIUM_VERSION . "\n%WAdd User%n\n", 'color');
|
||||||
|
|
||||||
if (OBS_DEBUG) { print_versions(); }
|
if (OBS_DEBUG) {
|
||||||
|
print_versions();
|
||||||
$auth_file = $config['html_dir'].'/includes/authentication/' . $config['auth_mechanism'] . '.inc.php';
|
}
|
||||||
if (is_file($auth_file))
|
|
||||||
{
|
|
||||||
include($auth_file);
|
|
||||||
|
|
||||||
|
$auth_file = $config['html_dir'] . '/includes/authentication/' . $config['auth_mechanism'] . '.inc.php';
|
||||||
|
if (is_file($auth_file)) {
|
||||||
// Include base auth functions calls
|
// Include base auth functions calls
|
||||||
include($config['html_dir'].'/includes/authenticate-functions.inc.php');
|
include_once($config['html_dir'] . '/includes/sessions.inc.php');
|
||||||
|
include_once($config['html_dir'] . '/includes/authenticate-functions.inc.php');
|
||||||
|
|
||||||
|
include_once($auth_file);
|
||||||
} else {
|
} else {
|
||||||
print_error("ERROR: no valid auth_mechanism defined.");
|
print_error("ERROR: no valid auth_mechanism defined.");
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auth_usermanagement())
|
if (auth_usermanagement()) {
|
||||||
{
|
if (isset($argv[1]) && isset($argv[2]) && isset($argv[3])) {
|
||||||
if (isset($argv[1]) && isset($argv[2]) && isset($argv[3]))
|
if (!auth_user_exists($argv[1])) {
|
||||||
{
|
if (adduser($argv[1], $argv[2], $argv[3], @$argv[4])) {
|
||||||
if (!auth_user_exists($argv[1]))
|
print_success("User " . $argv[1] . " added successfully.");
|
||||||
{
|
|
||||||
if (adduser($argv[1], $argv[2], $argv[3], @$argv[4]))
|
|
||||||
{
|
|
||||||
print_success("User ".$argv[1]." added successfully.");
|
|
||||||
} else {
|
} else {
|
||||||
print_error("User ".$argv[1]." creation failed!");
|
print_error("User " . $argv[1] . " creation failed!");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print_warning("User ".$argv[1]." already exists!");
|
print_warning("User " . $argv[1] . " already exists!");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$msg = "%n
|
$msg = "%n
|
||||||
@ -59,9 +59,8 @@ EXAMPLE:
|
|||||||
|
|
||||||
USER LEVELS:" . PHP_EOL;
|
USER LEVELS:" . PHP_EOL;
|
||||||
|
|
||||||
foreach($GLOBALS['config']['user_level'] as $level => $entry)
|
foreach ($GLOBALS['config']['user_level'] as $level => $entry) {
|
||||||
{
|
$msg .= ' ' . $level . ' - %W' . $entry['name'] . '%n (' . $entry['subtext'] . ')' . PHP_EOL;
|
||||||
$msg .= ' '.$level.' - %W'.$entry['name'].'%n ('.$entry['subtext'].')'. PHP_EOL;
|
|
||||||
}
|
}
|
||||||
$msg .= PHP_EOL . "%rInvalid arguments!%n";
|
$msg .= PHP_EOL . "%rInvalid arguments!%n";
|
||||||
|
|
||||||
|
18
alerter.php
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
* @package observium
|
* @package observium
|
||||||
* @subpackage cli
|
* @subpackage cli
|
||||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ chdir(dirname($argv[0]));
|
|||||||
|
|
||||||
$options = getopt("h:p:dqrsV");
|
$options = getopt("h:p:dqrsV");
|
||||||
|
|
||||||
include("includes/sql-config.inc.php");
|
include("includes/observium.inc.php");
|
||||||
|
|
||||||
include("includes/polling/functions.inc.php");
|
include("includes/polling/functions.inc.php");
|
||||||
include("html/includes/functions.inc.php");
|
include("html/includes/functions.inc.php");
|
||||||
@ -23,7 +23,7 @@ include("html/includes/functions.inc.php");
|
|||||||
$start = utime();
|
$start = utime();
|
||||||
|
|
||||||
if (isset($options['V'])) {
|
if (isset($options['V'])) {
|
||||||
print_message(OBSERVIUM_PRODUCT." ".OBSERVIUM_VERSION);
|
print_message(OBSERVIUM_PRODUCT . " " . OBSERVIUM_VERSION);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,12 +48,12 @@ if ($options['h'] === "all") {
|
|||||||
} else {
|
} else {
|
||||||
$where = "AND `hostname` LIKE ?";
|
$where = "AND `hostname` LIKE ?";
|
||||||
$doing = $options['h'];
|
$doing = $options['h'];
|
||||||
$params[] = str_replace('*','%', $options['h']);
|
$params[] = str_replace('*', '%', $options['h']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($options['p'])) {
|
if (isset($options['p'])) {
|
||||||
print_cli_heading("%WConstrained to poller partition id ".$options['p']);
|
print_cli_heading("%WConstrained to poller partition id " . $options['p']);
|
||||||
$where .= ' AND `poller_id` = ?';
|
$where .= ' AND `poller_id` = ?';
|
||||||
$params[] = $options['p'];
|
$params[] = $options['p'];
|
||||||
}
|
}
|
||||||
@ -85,7 +85,7 @@ DEBUGGING OPTIONS:
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
print_cli_heading("%WStarting alerter run at ".date("Y-m-d H:i:s"), 0);
|
print_cli_heading("%WStarting alerter run at " . date("Y-m-d H:i:s"), 0);
|
||||||
|
|
||||||
$polled_devices = 0;
|
$polled_devices = 0;
|
||||||
|
|
||||||
@ -106,13 +106,13 @@ foreach (dbFetchRows($query, $params) as $device) {
|
|||||||
|
|
||||||
process_alerts($device);
|
process_alerts($device);
|
||||||
if ($config['poller-wrapper']['notifications'] || $spam) {
|
if ($config['poller-wrapper']['notifications'] || $spam) {
|
||||||
process_notifications([ 'device_id' => $device['device_id'] ]); // Send all notifications (also for syslog from queue)
|
process_notifications(['device_id' => $device['device_id']]); // Send all notifications (also for syslog from queue)
|
||||||
}
|
}
|
||||||
|
|
||||||
dbUpdate([ 'last_alerter' => [ 'NOW()' ] ], 'devices', '`device_id` = ?', [ $device['device_id'] ]);
|
dbUpdate(['last_alerter' => ['NOW()']], 'devices', '`device_id` = ?', [$device['device_id']]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
print_cli_heading("%WFinished alerter run at ".date("Y-m-d H:i:s"), 0);
|
print_cli_heading("%WFinished alerter run at " . date("Y-m-d H:i:s"), 0);
|
||||||
|
|
||||||
// EOF
|
// EOF
|
||||||
|
@ -7,29 +7,32 @@
|
|||||||
*
|
*
|
||||||
* @package observium
|
* @package observium
|
||||||
* @subpackage cli
|
* @subpackage cli
|
||||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
chdir(dirname($argv[0]));
|
chdir(dirname($argv[0]));
|
||||||
|
|
||||||
$options = getopt("d");
|
$options = getopt("d");
|
||||||
if (isset($options['d'])) { array_shift($argv); } // for compatibility
|
if (isset($options['d'])) {
|
||||||
|
array_shift($argv);
|
||||||
|
} // for compatibility
|
||||||
|
|
||||||
include("includes/sql-config.inc.php");
|
include("includes/observium.inc.php");
|
||||||
|
|
||||||
// Check all of our interface RRD files for errors
|
// Check all of our interface RRD files for errors
|
||||||
|
|
||||||
if ($argv[1]) { $where = "AND `port_id` = ?"; $params = array($argv[1]); }
|
if ($argv[1]) {
|
||||||
|
$where = "AND `port_id` = ?";
|
||||||
|
$params = [$argv[1]];
|
||||||
|
}
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$errored = 0;
|
$errored = 0;
|
||||||
|
|
||||||
foreach (dbFetchRows("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id $where", $params) as $interface)
|
foreach (dbFetchRows("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id $where", $params) as $interface) {
|
||||||
{
|
|
||||||
$errors = $interface['ifInErrors_delta'] + $interface['ifOutErrors_delta'];
|
$errors = $interface['ifInErrors_delta'] + $interface['ifOutErrors_delta'];
|
||||||
if ($errors > '1')
|
if ($errors > '1') {
|
||||||
{
|
|
||||||
$errored[] = generate_device_link($interface, $interface['hostname'] . " - " . $interface['ifDescr'] . " - " . $interface['ifAlias'] . " - " . $interface['ifInErrors_delta'] . " - " . $interface['ifOutErrors_delta']);
|
$errored[] = generate_device_link($interface, $interface['hostname'] . " - " . $interface['ifDescr'] . " - " . $interface['ifAlias'] . " - " . $interface['ifInErrors_delta'] . " - " . $interface['ifOutErrors_delta']);
|
||||||
$errored++;
|
$errored++;
|
||||||
}
|
}
|
||||||
@ -38,13 +41,11 @@ foreach (dbFetchRows("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_
|
|||||||
|
|
||||||
echo("Checked $i interfaces\n");
|
echo("Checked $i interfaces\n");
|
||||||
|
|
||||||
if (is_array($errored))
|
if (is_array($errored)) { // If there are errored ports
|
||||||
{ // If there are errored ports
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$msg = "Interfaces with errors : \n\n";
|
$msg = "Interfaces with errors : \n\n";
|
||||||
|
|
||||||
foreach ($errored as $int)
|
foreach ($errored as $int) {
|
||||||
{
|
|
||||||
$msg .= "$int\n"; // Add a line to the report email warning about them
|
$msg .= "$int\n"; // Add a line to the report email warning about them
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
*
|
*
|
||||||
* @package observium
|
* @package observium
|
||||||
* @subpackage poller
|
* @subpackage poller
|
||||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ chdir(dirname($argv[0]));
|
|||||||
// Get options before definitions!
|
// Get options before definitions!
|
||||||
$options = getopt("o:d");
|
$options = getopt("o:d");
|
||||||
|
|
||||||
require_once("includes/sql-config.inc.php");
|
require_once("includes/observium.inc.php");
|
||||||
|
|
||||||
if (is_cli()) {
|
if (is_cli()) {
|
||||||
if (isset($options['o'])) {
|
if (isset($options['o'])) {
|
||||||
|
@ -7,25 +7,25 @@
|
|||||||
*
|
*
|
||||||
* @package observium
|
* @package observium
|
||||||
* @subpackage cli
|
* @subpackage cli
|
||||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
chdir(dirname($argv[0]));
|
chdir(dirname($argv[0]));
|
||||||
|
|
||||||
$options = getopt("d");
|
$options = getopt("d");
|
||||||
if (isset($options['d'])) { array_shift($argv); } // for compatibility
|
if (isset($options['d'])) {
|
||||||
|
array_shift($argv);
|
||||||
|
} // for compatibility
|
||||||
|
|
||||||
include("includes/sql-config.inc.php");
|
include("includes/observium.inc.php");
|
||||||
|
|
||||||
print_message("%g".OBSERVIUM_PRODUCT." ".OBSERVIUM_VERSION."\n%WRemove Device%n\n", 'color');
|
print_message("%g" . OBSERVIUM_PRODUCT . " " . OBSERVIUM_VERSION . "\n%WRemove Device%n\n", 'color');
|
||||||
|
|
||||||
// Remove a host and all related data from the system
|
// Remove a host and all related data from the system
|
||||||
if ($argv[1])
|
if ($argv[1]) {
|
||||||
{
|
|
||||||
$host = strtolower($argv[1]);
|
$host = strtolower($argv[1]);
|
||||||
if (is_numeric($host))
|
if (is_numeric($host)) {
|
||||||
{
|
|
||||||
$id = $host;
|
$id = $host;
|
||||||
} else {
|
} else {
|
||||||
$id = get_device_id_by_hostname($host);
|
$id = get_device_id_by_hostname($host);
|
||||||
@ -33,8 +33,7 @@ if ($argv[1])
|
|||||||
$delete_rrd = isset($argv[2]) && strtolower($argv[2]) === 'rrd';
|
$delete_rrd = isset($argv[2]) && strtolower($argv[2]) === 'rrd';
|
||||||
|
|
||||||
// Test if a valid id was fetched from get_device_id_by_hostname()
|
// Test if a valid id was fetched from get_device_id_by_hostname()
|
||||||
if (isset($id) && is_numeric($id))
|
if (isset($id) && is_numeric($id)) {
|
||||||
{
|
|
||||||
print_warning(delete_device($id, $delete_rrd));
|
print_warning(delete_device($id, $delete_rrd));
|
||||||
print_success("Device $host removed.");
|
print_success("Device $host removed.");
|
||||||
} else {
|
} else {
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
* @package observium
|
* @package observium
|
||||||
* @subpackage discovery
|
* @subpackage discovery
|
||||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ chdir(dirname($argv[0]));
|
|||||||
// Get options before definitions!
|
// Get options before definitions!
|
||||||
$options = getopt("h:i:m:n:p:U:dquaMV");
|
$options = getopt("h:i:m:n:p:U:dquaMV");
|
||||||
|
|
||||||
include("includes/sql-config.inc.php");
|
include("includes/observium.inc.php");
|
||||||
include("includes/discovery/functions.inc.php");
|
include("includes/discovery/functions.inc.php");
|
||||||
|
|
||||||
$cli = TRUE;
|
$cli = TRUE;
|
||||||
@ -24,18 +24,20 @@ $cli = TRUE;
|
|||||||
//if (is_cron()) { $options['q'] = TRUE; } // Set quiet for cron
|
//if (is_cron()) { $options['q'] = TRUE; } // Set quiet for cron
|
||||||
|
|
||||||
$start = utime();
|
$start = utime();
|
||||||
$runtime_stats = array();
|
$runtime_stats = [];
|
||||||
|
|
||||||
if (isset($options['V'])) {
|
if (isset($options['V'])) {
|
||||||
print_message(OBSERVIUM_PRODUCT . " " . OBSERVIUM_VERSION);
|
print_message(OBSERVIUM_PRODUCT . " " . OBSERVIUM_VERSION);
|
||||||
if (is_array($options['V'])) { print_versions(); }
|
if (is_array($options['V'])) {
|
||||||
|
print_versions();
|
||||||
|
}
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
if (isset($options['M'])) {
|
if (isset($options['M'])) {
|
||||||
print_message(OBSERVIUM_PRODUCT . " " . OBSERVIUM_VERSION);
|
print_message(OBSERVIUM_PRODUCT . " " . OBSERVIUM_VERSION);
|
||||||
|
|
||||||
print_message('Enabled discovery modules:');
|
print_message('Enabled discovery modules:');
|
||||||
$m_disabled = array();
|
$m_disabled = [];
|
||||||
foreach ($config['discovery_modules'] as $module => $ok) {
|
foreach ($config['discovery_modules'] as $module => $ok) {
|
||||||
if ($ok) {
|
if ($ok) {
|
||||||
print_message(' ' . $module);
|
print_message(' ' . $module);
|
||||||
@ -53,14 +55,18 @@ if (isset($options['M'])) {
|
|||||||
if (!isset($options['q'])) {
|
if (!isset($options['q'])) {
|
||||||
print_cli_banner();
|
print_cli_banner();
|
||||||
|
|
||||||
if (OBS_DEBUG) { print_versions(); }
|
if (OBS_DEBUG) {
|
||||||
|
print_versions();
|
||||||
|
}
|
||||||
|
|
||||||
// Warning about obsolete configs.
|
// Warning about obsolete configs.
|
||||||
if (print_obsolete_config()) { echo PHP_EOL; }
|
if (print_obsolete_config()) {
|
||||||
|
echo PHP_EOL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($options['u']) || isset($options['U']) ||
|
if (isset($options['u']) || isset($options['U']) ||
|
||||||
(isset($options['h']) && in_array($options['h'], [ 'all', 'odd', 'even', 'none' ]))) {
|
(isset($options['h']) && in_array($options['h'], ['all', 'odd', 'even', 'none']))) {
|
||||||
$options['u'] = TRUE;
|
$options['u'] = TRUE;
|
||||||
|
|
||||||
include($config['install_dir'] . '/includes/update/update.php');
|
include($config['install_dir'] . '/includes/update/update.php');
|
||||||
@ -77,7 +83,7 @@ if (isset($options['u']) || isset($options['U']) ||
|
|||||||
$where = '';
|
$where = '';
|
||||||
|
|
||||||
if (isset($options['h'])) {
|
if (isset($options['h'])) {
|
||||||
$params = array();
|
$params = [];
|
||||||
switch ($options['h']) {
|
switch ($options['h']) {
|
||||||
case 'odd':
|
case 'odd':
|
||||||
$options['n'] = 1;
|
$options['n'] = 1;
|
||||||
@ -178,8 +184,12 @@ if (!$where) {
|
|||||||
run_action_queue('tables_update');
|
run_action_queue('tables_update');
|
||||||
} else {
|
} else {
|
||||||
$silent = isset($options['q']);
|
$silent = isset($options['q']);
|
||||||
if (function_exists('update_group_tables')) { update_group_tables($silent); } // Not exist in CE
|
if (function_exists('update_group_tables')) {
|
||||||
if (function_exists('update_alert_tables')) { update_alert_tables($silent); }
|
update_group_tables($silent);
|
||||||
|
} // Not exist in CE
|
||||||
|
if (function_exists('update_alert_tables')) {
|
||||||
|
update_alert_tables($silent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,7 +212,7 @@ $params[] = $config['poller_id'];
|
|||||||
foreach (dbFetchRows("SELECT * FROM `devices` WHERE `disabled` = 0 $where ORDER BY `last_discovered_timetaken` ASC", $params) as $device) {
|
foreach (dbFetchRows("SELECT * FROM `devices` WHERE `disabled` = 0 $where ORDER BY `last_discovered_timetaken` ASC", $params) as $device) {
|
||||||
// Additional check if device SNMPable, because during
|
// Additional check if device SNMPable, because during
|
||||||
// discovery many devices (long time), the some device can be switched off
|
// discovery many devices (long time), the some device can be switched off
|
||||||
if ($options['h'] === 'new' || isSNMPable($device)) {
|
if ($options['h'] === 'new' || is_snmpable($device)) {
|
||||||
discover_device($device, $options);
|
discover_device($device, $options);
|
||||||
} else {
|
} else {
|
||||||
$string = "Device '" . $device['hostname'] . "' skipped, because switched off during runtime discovery process.";
|
$string = "Device '" . $device['hostname'] . "' skipped, because switched off during runtime discovery process.";
|
||||||
@ -221,12 +231,16 @@ $discovery_time = substr($run, 0, 5);
|
|||||||
if (($discovered_devices && !isset($options['m'])) || isset($options['a'])) {
|
if (($discovered_devices && !isset($options['m'])) || isset($options['a'])) {
|
||||||
$silent = isset($options['q']);
|
$silent = isset($options['q']);
|
||||||
if (OBS_DISTRIBUTED && !isset($options['a']) && function_exists('add_action_queue') &&
|
if (OBS_DISTRIBUTED && !isset($options['a']) && function_exists('add_action_queue') &&
|
||||||
$action_id = add_action_queue('tables_update', 'discovery', [ 'silent' => $silent ])) {
|
$action_id = add_action_queue('tables_update', 'discovery', ['silent' => $silent])) {
|
||||||
print_message("Update alert and group tables added to queue [$action_id].");
|
print_message("Update alert and group tables added to queue [$action_id].");
|
||||||
//log_event("Device with hostname '$hostname' added to queue [$action_id] for addition on remote Poller [{$vars['poller_id']}].", NULL, 'info', NULL, 7);
|
//log_event("Device with hostname '$hostname' added to queue [$action_id] for addition on remote Poller [{$vars['poller_id']}].", NULL, 'info', NULL, 7);
|
||||||
} else {
|
} else {
|
||||||
if (function_exists('update_group_tables')) { update_group_tables($silent); } // Not exist in CE
|
if (function_exists('update_group_tables')) {
|
||||||
if (function_exists('update_alert_tables')) { update_alert_tables($silent); }
|
update_group_tables($silent);
|
||||||
|
} // Not exist in CE
|
||||||
|
if (function_exists('update_alert_tables')) {
|
||||||
|
update_alert_tables($silent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,20 +251,20 @@ if ($discovered_devices) {
|
|||||||
|
|
||||||
// This discovery passed from wrapper and with process id
|
// This discovery passed from wrapper and with process id
|
||||||
if ($config['poller_id'] > 0 &&
|
if ($config['poller_id'] > 0 &&
|
||||||
$poller = dbFetchRow('SELECT * FROM `pollers` WHERE `poller_id` = ?', [ $config['poller_id'] ])) {
|
$poller = dbFetchRow('SELECT * FROM `pollers` WHERE `poller_id` = ?', [$config['poller_id']])) {
|
||||||
print_debug_vars($poller, 1);
|
print_debug_vars($poller, 1);
|
||||||
$host_id = get_local_id();
|
$host_id = get_local_id();
|
||||||
$update = [];
|
$update = [];
|
||||||
if ($poller['host_id'] != $host_id) {
|
if ($poller['host_id'] != $host_id) {
|
||||||
$update['host_id'] = $host_id;
|
$update['host_id'] = $host_id;
|
||||||
log_event("Poller ".$config['poller_id']." host ID changed: '".$poller['host_id']."' -> '".$host_id."'");
|
log_event("Poller " . $config['poller_id'] . " host ID changed: '" . $poller['host_id'] . "' -> '" . $host_id . "'");
|
||||||
}
|
}
|
||||||
if ($poller['host_uname'] != php_uname()) {
|
if ($poller['host_uname'] != php_uname()) {
|
||||||
$update['host_uname'] = php_uname();
|
$update['host_uname'] = php_uname();
|
||||||
log_event("Poller ".$config['poller_id']." host uname changed: '".$poller['host_uname']."' -> '".$update['host_uname']."'");
|
log_event("Poller " . $config['poller_id'] . " host uname changed: '" . $poller['host_uname'] . "' -> '" . $update['host_uname'] . "'");
|
||||||
}
|
}
|
||||||
if (count($update)) {
|
if (count($update)) {
|
||||||
dbUpdate($update, 'pollers', '`poller_id` = ?', [ $config['poller_id'] ]);
|
dbUpdate($update, 'pollers', '`poller_id` = ?', [$config['poller_id']]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -264,7 +278,7 @@ logfile($string);
|
|||||||
|
|
||||||
// Clean stale observium processes
|
// Clean stale observium processes
|
||||||
$process_sql = "SELECT * FROM `observium_processes` WHERE `poller_id` = ? AND `process_start` < ?";
|
$process_sql = "SELECT * FROM `observium_processes` WHERE `poller_id` = ? AND `process_start` < ?";
|
||||||
foreach (dbFetchRows($process_sql, [ $config['poller_id'], $config['time']['fourhour'] ]) as $process) {
|
foreach (dbFetchRows($process_sql, [$config['poller_id'], $config['time']['fourhour']]) as $process) {
|
||||||
// We found processes in DB, check if it exist on system
|
// We found processes in DB, check if it exist on system
|
||||||
print_debug_vars($process);
|
print_debug_vars($process);
|
||||||
$pid_info = get_pid_info($process['process_pid']);
|
$pid_info = get_pid_info($process['process_pid']);
|
||||||
@ -272,7 +286,7 @@ foreach (dbFetchRows($process_sql, [ $config['poller_id'], $config['time']['four
|
|||||||
// Process still running
|
// Process still running
|
||||||
} else {
|
} else {
|
||||||
// Remove stalled DB entries
|
// Remove stalled DB entries
|
||||||
dbDelete('observium_processes', '`process_id` = ?', array($process['process_id']));
|
dbDelete('observium_processes', '`process_id` = ?', [$process['process_id']]);
|
||||||
print_debug("Removed stale process entry from DB (cmd: '" . $process['process_command'] . "', PID: '" . $process['process_pid'] . "')");
|
print_debug("Removed stale process entry from DB (cmd: '" . $process['process_command'] . "', PID: '" . $process['process_pid'] . "')");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -284,8 +298,9 @@ if (!isset($options['q'])) {
|
|||||||
|
|
||||||
print_cli_data('Devices Discovered', $discovered_devices, 0);
|
print_cli_data('Devices Discovered', $discovered_devices, 0);
|
||||||
print_cli_data('Discovery Time', $discovery_time . " secs", 0);
|
print_cli_data('Discovery Time', $discovery_time . " secs", 0);
|
||||||
print_cli_data('Memory usage', formatStorage(memory_get_usage(TRUE), 2, 4) .
|
print_cli_data('Definitions', $defs_time . " secs", 0);
|
||||||
' (peak: ' . formatStorage(memory_get_peak_usage(TRUE), 2, 4) . ')', 0);
|
print_cli_data('Memory usage', format_bytes(memory_get_usage(TRUE), 2, 4) .
|
||||||
|
' (peak: ' . format_bytes(memory_get_peak_usage(TRUE), 2, 4) . ')', 0);
|
||||||
print_cli_data('MySQL Usage', 'Cell[' . ($db_stats['fetchcell'] + 0) . '/' . round($db_stats['fetchcell_sec'] + 0, 3) . 's]' .
|
print_cli_data('MySQL Usage', 'Cell[' . ($db_stats['fetchcell'] + 0) . '/' . round($db_stats['fetchcell_sec'] + 0, 3) . 's]' .
|
||||||
' Row[' . ($db_stats['fetchrow'] + 0) . '/' . round($db_stats['fetchrow_sec'] + 0, 3) . 's]' .
|
' Row[' . ($db_stats['fetchrow'] + 0) . '/' . round($db_stats['fetchrow_sec'] + 0, 3) . 's]' .
|
||||||
' Rows[' . ($db_stats['fetchrows'] + 0) . '/' . round($db_stats['fetchrows_sec'] + 0, 3) . 's]' .
|
' Rows[' . ($db_stats['fetchrows'] + 0) . '/' . round($db_stats['fetchrows_sec'] + 0, 3) . 's]' .
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
* @package observium
|
* @package observium
|
||||||
* @subpackage cli
|
* @subpackage cli
|
||||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -15,24 +15,28 @@ chdir(dirname($argv[0]));
|
|||||||
|
|
||||||
$options = getopt("A:VyaselurpdbiT");
|
$options = getopt("A:VyaselurpdbiT");
|
||||||
|
|
||||||
include("includes/sql-config.inc.php");
|
include("includes/observium.inc.php");
|
||||||
|
|
||||||
$cli = is_cli();
|
$cli = is_cli();
|
||||||
|
|
||||||
if (isset($options['V'])) {
|
if (isset($options['V'])) {
|
||||||
print_message(OBSERVIUM_PRODUCT." ".OBSERVIUM_VERSION);
|
print_message(OBSERVIUM_PRODUCT . " " . OBSERVIUM_VERSION);
|
||||||
if (is_array($options['V'])) { print_versions(); }
|
if (is_array($options['V'])) {
|
||||||
|
print_versions();
|
||||||
|
}
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Prevent run housekeeping on remote pollers (that not needed)
|
// Prevent running housekeeping on remote pollers (not needed, won't work properly, potential data loss vector)
|
||||||
if ($config['poller_id'] !== 0) {
|
if ($config['poller_id'] !== 0) {
|
||||||
print_message("%yHouseKeeping only needs to be run on the main node.%n\n", 'color');
|
print_message("%yHousekeeping only needs to be run on the main node. Do not run housekeeping on partitioned pollers.%n\n", 'color');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
print_message("%g".OBSERVIUM_PRODUCT." ".OBSERVIUM_VERSION."\n%WHouseKeeping%n\n", 'color');
|
print_message("%g" . OBSERVIUM_PRODUCT . " " . OBSERVIUM_VERSION . "\n%WHouseKeeping%n\n", 'color');
|
||||||
if (OBS_DEBUG) { print_versions(); }
|
if (OBS_DEBUG) {
|
||||||
|
print_versions();
|
||||||
|
}
|
||||||
|
|
||||||
// For interactive prompt/answer checks
|
// For interactive prompt/answer checks
|
||||||
// if it is started from crontab - prompt disabled and answer always 'yes'
|
// if it is started from crontab - prompt disabled and answer always 'yes'
|
||||||
@ -43,23 +47,41 @@ if (is_cron()) {
|
|||||||
}
|
}
|
||||||
$answer = TRUE;
|
$answer = TRUE;
|
||||||
|
|
||||||
$modules = array();
|
$modules = [];
|
||||||
|
|
||||||
if (isset($options['a']) || isset($options['s'])) { $modules[] = 'syslog'; }
|
if (isset($options['a']) || isset($options['s'])) {
|
||||||
if (isset($options['a']) || isset($options['e'])) { $modules[] = 'eventlog'; }
|
$modules[] = 'syslog';
|
||||||
if (isset($options['a']) || isset($options['l'])) { $modules[] = 'alertlog'; }
|
}
|
||||||
if (isset($options['a']) || isset($options['u'])) { $modules[] = 'authlog'; }
|
if (isset($options['a']) || isset($options['e'])) {
|
||||||
if (isset($options['a']) || isset($options['p'])) { $modules[] = 'ports'; }
|
$modules[] = 'eventlog';
|
||||||
if (isset($options['a']) || isset($options['b'])) { $modules[] = 'staledb'; }
|
}
|
||||||
if (isset($options['a']) || isset($options['i'])) { $modules[] = 'inventory'; }
|
if (isset($options['a']) || isset($options['l'])) {
|
||||||
if (isset($options['a']) || isset($options['r'])) { $modules[] = 'rrd'; }
|
$modules[] = 'alertlog';
|
||||||
|
}
|
||||||
|
if (isset($options['a']) || isset($options['u'])) {
|
||||||
|
$modules[] = 'authlog';
|
||||||
|
}
|
||||||
|
if (isset($options['a']) || isset($options['p'])) {
|
||||||
|
$modules[] = 'ports';
|
||||||
|
}
|
||||||
|
if (isset($options['a']) || isset($options['b'])) {
|
||||||
|
$modules[] = 'staledb';
|
||||||
|
}
|
||||||
|
if (isset($options['a']) || isset($options['i'])) {
|
||||||
|
$modules[] = 'inventory';
|
||||||
|
}
|
||||||
|
if (isset($options['a']) || isset($options['r'])) {
|
||||||
|
$modules[] = 'rrd';
|
||||||
|
}
|
||||||
|
|
||||||
// Get age from command line
|
// Get age from command line
|
||||||
if (isset($options['A'])) {
|
if (isset($options['A'])) {
|
||||||
$age = age_to_seconds($options['A']);
|
$age = age_to_seconds($options['A']);
|
||||||
if ($age) {
|
if ($age) {
|
||||||
foreach ($modules as $module) {
|
foreach ($modules as $module) {
|
||||||
if ($module === 'ports') { $module = 'deleted_ports'; }
|
if ($module === 'ports') {
|
||||||
|
$module = 'deleted_ports';
|
||||||
|
}
|
||||||
$config['housekeeping'][$module]['age'] = $age;
|
$config['housekeeping'][$module]['age'] = $age;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -109,11 +131,15 @@ $test = isset($options['T']);
|
|||||||
foreach ($modules as $module) {
|
foreach ($modules as $module) {
|
||||||
if (is_file($config['install_dir'] . "/includes/housekeeping/$module.inc.php")) {
|
if (is_file($config['install_dir'] . "/includes/housekeeping/$module.inc.php")) {
|
||||||
include($config['install_dir'] . "/includes/housekeeping/$module.inc.php");
|
include($config['install_dir'] . "/includes/housekeeping/$module.inc.php");
|
||||||
if (!$test) { set_obs_attrib("housekeeping_lastrun_$module", time()); }
|
if (!$test) {
|
||||||
|
set_obs_attrib("housekeeping_lastrun_$module", time());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
print_warning("Housekeeping module not found: $module");
|
print_warning("Housekeeping module not found: $module");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!$test) { set_obs_attrib("housekeeping_lastrun", time()); }
|
if (!$test) {
|
||||||
|
set_obs_attrib("housekeeping_lastrun", time());
|
||||||
|
}
|
||||||
|
|
||||||
// EOF
|
// EOF
|
||||||
|
@ -3,9 +3,10 @@
|
|||||||
|
|
||||||
Options FollowSymlinks Multiviews
|
Options FollowSymlinks Multiviews
|
||||||
|
|
||||||
|
ErrorDocument 404 /error.php?404
|
||||||
RedirectMatch 404 /\.
|
RedirectMatch 404 /\.
|
||||||
|
|
||||||
RewriteEngine on
|
RewriteEngine On
|
||||||
RewriteBase /
|
RewriteBase /
|
||||||
#Block access to hidden files/dirs
|
#Block access to hidden files/dirs
|
||||||
RewriteRule ^\..*$ - [F,L]
|
RewriteRule ^\..*$ - [F,L]
|
||||||
|
@ -6,19 +6,15 @@
|
|||||||
*
|
*
|
||||||
* @package observium
|
* @package observium
|
||||||
* @subpackage ajax
|
* @subpackage ajax
|
||||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$config['install_dir'] = "../..";
|
include_once("../../includes/observium.inc.php");
|
||||||
|
|
||||||
include_once("../../includes/sql-config.inc.php");
|
|
||||||
|
|
||||||
include($config['html_dir'] . "/includes/functions.inc.php");
|
|
||||||
include($config['html_dir'] . "/includes/authenticate.inc.php");
|
include($config['html_dir'] . "/includes/authenticate.inc.php");
|
||||||
|
|
||||||
if (!$_SESSION['authenticated'])
|
if (!$_SESSION['authenticated']) {
|
||||||
{
|
|
||||||
print_json_status('failed', 'Unauthorized.');
|
print_json_status('failed', 'Unauthorized.');
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
@ -26,6 +22,7 @@ if (!$_SESSION['authenticated'])
|
|||||||
$vars = get_vars([ 'JSON', 'POST' ]); // Got a JSON payload. Replace $var.
|
$vars = get_vars([ 'JSON', 'POST' ]); // Got a JSON payload. Replace $var.
|
||||||
|
|
||||||
$readonly = $_SESSION['userlevel'] < 7;
|
$readonly = $_SESSION['userlevel'] < 7;
|
||||||
|
$limitwrite = $_SESSION['userlevel'] >= 9;
|
||||||
$readwrite = $_SESSION['userlevel'] >= 10;
|
$readwrite = $_SESSION['userlevel'] >= 10;
|
||||||
|
|
||||||
switch ($vars['action']) {
|
switch ($vars['action']) {
|
||||||
@ -56,8 +53,6 @@ switch ($vars['action']) {
|
|||||||
print_json_status('ok', 'Big graphs set.');
|
print_json_status('ok', 'Big graphs set.');
|
||||||
session_unset_var("big_graphs"); // clear old
|
session_unset_var("big_graphs"); // clear old
|
||||||
}
|
}
|
||||||
//session_set_var("big_graphs", TRUE);
|
|
||||||
//print_json_status('ok', 'Big graphs set.');
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "normal_graphs":
|
case "normal_graphs":
|
||||||
@ -66,8 +61,6 @@ switch ($vars['action']) {
|
|||||||
print_json_status('ok', 'Normal graphs set.');
|
print_json_status('ok', 'Normal graphs set.');
|
||||||
session_unset_var("big_graphs"); // clear old
|
session_unset_var("big_graphs"); // clear old
|
||||||
}
|
}
|
||||||
//session_unset_var("big_graphs");
|
|
||||||
//print_json_status('ok', 'Small graphs set.');
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "touch_on":
|
case "touch_on":
|
||||||
@ -80,35 +73,6 @@ switch ($vars['action']) {
|
|||||||
print_json_status('ok', 'Touch mode disabled.');
|
print_json_status('ok', 'Touch mode disabled.');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "set_refresh":
|
|
||||||
session_set_var("dark_mode", TRUE);
|
|
||||||
print_json_status('ok', 'Dark mode set.');
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "alert_assoc_edit":
|
|
||||||
|
|
||||||
// Currently edit allowed only for Admins
|
|
||||||
if (!$readwrite) {
|
|
||||||
print_json_status('failed', 'Action not allowed.');
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dbFetchRow("SELECT * FROM `alert_tests` WHERE `alert_test_id` = ?", array($vars['alert_test_id']))) {
|
|
||||||
|
|
||||||
$rows_updated = dbUpdate([ 'alert_assoc' => $vars['alert_assoc'] ], 'alert_tests', '`alert_test_id` = ?', [ $vars['alert_test_id'] ]);
|
|
||||||
|
|
||||||
if ($rows_updated) {
|
|
||||||
update_alert_table($vars['alert_test_id']);
|
|
||||||
print_json_status('ok', '', [ 'id' => $vars['alert_test_id'],
|
|
||||||
'redirect' => generate_url([ 'page' => 'alert_check', 'alert_test_id' => $vars['alert_test_id'] ]) ]);
|
|
||||||
} else {
|
|
||||||
print_json_status('failed', 'Database was not updated.');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
print_json_status('failed', 'Alert Checker does not exist: [' . $vars['alert_test_id'] . ']');
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "save_grid": // Save current layout of dashboard grid
|
case "save_grid": // Save current layout of dashboard grid
|
||||||
|
|
||||||
// Currently edit allowed only for Admins
|
// Currently edit allowed only for Admins
|
||||||
@ -118,8 +82,8 @@ switch ($vars['action']) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($vars['grid'] as $w) {
|
foreach ($vars['grid'] as $w) {
|
||||||
dbUpdate(array('x' => $w['x'], 'y' => $w['y'], 'width' => $w['width'], 'height' => $w['height'],), 'dash_widgets',
|
dbUpdate(['x' => $w['x'], 'y' => $w['y'], 'width' => $w['width'], 'height' => $w['height'],], 'dash_widgets',
|
||||||
'`widget_id` = ?', array($w['id'])
|
'`widget_id` = ?', [$w['id']]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -133,13 +97,13 @@ switch ($vars['action']) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isset($vars['dash_id']) && isset($vars['widget_type'])) {
|
if (isset($vars['dash_id']) && isset($vars['widget_type'])) {
|
||||||
$widget_id = dbInsert(array('dash_id' => $vars['dash_id'], 'widget_config' => json_encode(array()), 'widget_type' => $vars['widget_type']),
|
$widget_id = dbInsert(['dash_id' => $vars['dash_id'], 'widget_config' => json_encode([]), 'widget_type' => $vars['widget_type']],
|
||||||
'dash_widgets'
|
'dash_widgets'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($widget_id) {
|
if ($widget_id) {
|
||||||
print_json_status('ok', '', [ 'id' => $widget_id ]);
|
print_json_status('ok', '', ['id' => $widget_id]);
|
||||||
} else {
|
} else {
|
||||||
//print_r($vars); // For debugging
|
//print_r($vars); // For debugging
|
||||||
}
|
}
|
||||||
@ -154,11 +118,11 @@ switch ($vars['action']) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (is_numeric($vars['id'])) {
|
if (is_numeric($vars['id'])) {
|
||||||
$rows_deleted = dbDelete('wifi_aps', '`wifi_ap_id` = ?', array($vars['id']));
|
$rows_deleted = dbDelete('wifi_aps', '`wifi_ap_id` = ?', [$vars['id']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($rows_deleted) {
|
if ($rows_deleted) {
|
||||||
print_json_status('ok', 'AP Deleted', [ 'id' => $vars['id'] ]);
|
print_json_status('ok', 'AP Deleted', ['id' => $vars['id']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -172,11 +136,11 @@ switch ($vars['action']) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (is_numeric($vars['widget_id'])) {
|
if (is_numeric($vars['widget_id'])) {
|
||||||
$rows_deleted = dbDelete('dash_widgets', '`widget_id` = ?', array($vars['widget_id']));
|
$rows_deleted = dbDelete('dash_widgets', '`widget_id` = ?', [$vars['widget_id']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($rows_deleted) {
|
if ($rows_deleted) {
|
||||||
print_json_status('ok', 'Widget Deleted.', [ 'id' => $vars['widget_id'] ]);
|
print_json_status('ok', 'Widget Deleted.', ['id' => $vars['widget_id']]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -189,13 +153,13 @@ switch ($vars['action']) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (is_numeric($vars['dash_id'])) {
|
if (is_numeric($vars['dash_id'])) {
|
||||||
$rows_updated = dbUpdate(array('dash_name' => $vars['dash_name']), 'dashboards', '`dash_id` = ?', array($vars['dash_id']));
|
$rows_updated = dbUpdate(['dash_name' => $vars['dash_name']], 'dashboards', '`dash_id` = ?', [$vars['dash_id']]);
|
||||||
} else {
|
} else {
|
||||||
print_json_status('failed', 'Invalid Dashboard ID.');
|
print_json_status('failed', 'Invalid Dashboard ID.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($rows_updated) {
|
if ($rows_updated) {
|
||||||
print_json_status('ok', 'Dashboard Name Updated.', [ 'id' => $vars['dash_id'] ]);
|
print_json_status('ok', 'Dashboard Name Updated.', ['id' => $vars['dash_id']]);
|
||||||
} else {
|
} else {
|
||||||
print_json_status('failed', 'Update Failed.');
|
print_json_status('failed', 'Update Failed.');
|
||||||
}
|
}
|
||||||
@ -211,14 +175,14 @@ switch ($vars['action']) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (is_numeric($vars['dash_id'])) {
|
if (is_numeric($vars['dash_id'])) {
|
||||||
$rows_deleted = dbDelete('dash_widgets', '`dash_id` = ?', array($vars['dash_id']));
|
$rows_deleted = dbDelete('dash_widgets', '`dash_id` = ?', [$vars['dash_id']]);
|
||||||
$rows_deleted += dbDelete('dashboards', '`dash_id` = ?', array($vars['dash_id']));
|
$rows_deleted += dbDelete('dashboards', '`dash_id` = ?', [$vars['dash_id']]);
|
||||||
} else {
|
} else {
|
||||||
print_json_status('failed', 'Invalid Dashboard ID.');
|
print_json_status('failed', 'Invalid Dashboard ID.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($rows_deleted) {
|
if ($rows_deleted) {
|
||||||
print_json_status('ok', 'Dashboard Deleted.', [ 'id' => $vars['dash_id'] ]);
|
print_json_status('ok', 'Dashboard Deleted.', ['id' => $vars['dash_id']]);
|
||||||
} else {
|
} else {
|
||||||
print_json_status('failed', 'Deletion Failed.');
|
print_json_status('failed', 'Deletion Failed.');
|
||||||
}
|
}
|
||||||
@ -235,30 +199,30 @@ switch ($vars['action']) {
|
|||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
$widget = dbFetchRow("SELECT * FROM `dash_widgets` WHERE `widget_id` = ?", array($vars['widget_id']));
|
$widget = dbFetchRow("SELECT * FROM `dash_widgets` WHERE `widget_id` = ?", [$vars['widget_id']]);
|
||||||
$widget['widget_config'] = safe_json_decode($widget['widget_config']);
|
$widget['widget_config'] = safe_json_decode($widget['widget_config']);
|
||||||
|
|
||||||
// Verify config value applies to this widget here
|
// Verify config value applies to this widget here
|
||||||
|
|
||||||
$default_on = [ 'legend' ];
|
$default_on = ['legend'];
|
||||||
|
|
||||||
if (isset($vars['config_field']) && isset($vars['config_value'])) {
|
if (isset($vars['config_field']) && isset($vars['config_value'])) {
|
||||||
if ( empty($vars['config_value']) ||
|
if (empty($vars['config_value']) ||
|
||||||
(in_array($vars['config_field'], $default_on) && get_var_true($vars['config_value'])) ||
|
(in_array($vars['config_field'], $default_on) && get_var_true($vars['config_value'])) ||
|
||||||
(!in_array($vars['config_field'], $default_on) && get_var_false($vars['config_value'])) ) {
|
(!in_array($vars['config_field'], $default_on) && get_var_false($vars['config_value']))) {
|
||||||
// Just unset the value if it's empty or it's a default value.
|
// Just unset the value if it's empty or it's a default value.
|
||||||
unset($widget['widget_config'][$vars['config_field']]);
|
unset($widget['widget_config'][$vars['config_field']]);
|
||||||
} else {
|
} else {
|
||||||
$widget['widget_config'][$vars['config_field']] = $vars['config_value'];
|
$widget['widget_config'][$vars['config_field']] = $vars['config_value'];
|
||||||
}
|
}
|
||||||
|
|
||||||
dbUpdate(array('widget_config' => json_encode($widget['widget_config'])), 'dash_widgets',
|
dbUpdate(['widget_config' => json_encode($widget['widget_config'])], 'dash_widgets',
|
||||||
'`widget_id` = ?', array($widget['widget_id'])
|
'`widget_id` = ?', [$widget['widget_id']]
|
||||||
);
|
);
|
||||||
|
|
||||||
//echo dbError();
|
//echo dbError();
|
||||||
|
|
||||||
print_json_status('ok', 'Widget Updated.', [ 'id' => $widget['widget_id'] ]);
|
print_json_status('ok', 'Widget Updated.', ['id' => $widget['widget_id']]);
|
||||||
} else {
|
} else {
|
||||||
print_json_status('failed', 'Update Failed.');
|
print_json_status('failed', 'Update Failed.');
|
||||||
}
|
}
|
||||||
@ -270,7 +234,7 @@ switch ($vars['action']) {
|
|||||||
// Validate CSRF Token
|
// Validate CSRF Token
|
||||||
//r($vars);
|
//r($vars);
|
||||||
$json = '';
|
$json = '';
|
||||||
if (!str_contains_array($vars['action'], [ 'widget', 'dash', 'settings_user' ]) && // widget & dashboard currently not send request token
|
if (!str_contains_array($vars['action'], ['widget', 'dash', 'settings_user']) && // widget & dashboard currently not send request token
|
||||||
!request_token_valid($vars, $json)) {
|
!request_token_valid($vars, $json)) {
|
||||||
$json = safe_json_decode($json);
|
$json = safe_json_decode($json);
|
||||||
$json['reload'] = TRUE;
|
$json['reload'] = TRUE;
|
||||||
@ -279,9 +243,8 @@ switch ($vars['action']) {
|
|||||||
}
|
}
|
||||||
unset($json);
|
unset($json);
|
||||||
|
|
||||||
$action_path = __DIR__ . '/actions/'. $vars['action'] . '.inc.php';
|
$action_path = __DIR__ . '/actions/' . $vars['action'] . '.inc.php';
|
||||||
if (is_alpha($vars['action']) && is_file($action_path))
|
if (is_alpha($vars['action']) && is_file($action_path)) {
|
||||||
{
|
|
||||||
include $action_path;
|
include $action_path;
|
||||||
} else {
|
} else {
|
||||||
print_json_status('failed', 'Unknown action requested.');
|
print_json_status('failed', 'Unknown action requested.');
|
||||||
|
38
html/ajax/actions/alert_assoc_edit.inc.php
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Observium
|
||||||
|
*
|
||||||
|
* This file is part of Observium.
|
||||||
|
*
|
||||||
|
* @package observium
|
||||||
|
* @subpackage ajax
|
||||||
|
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Currently edit allowed only for Admins
|
||||||
|
if (!$limitwrite) {
|
||||||
|
print_json_status('failed', 'Action not allowed.');
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($alert_test = dbFetchRow("SELECT * FROM `alert_tests` WHERE `alert_test_id` = ?", [ $vars['alert_test_id'] ])) {
|
||||||
|
|
||||||
|
if ($alert_test['alert_assoc'] !== $vars['alert_assoc']) {
|
||||||
|
|
||||||
|
if (dbUpdate([ 'alert_assoc' => $vars['alert_assoc'] ], 'alert_tests', '`alert_test_id` = ?', [ $vars['alert_test_id'] ])) {
|
||||||
|
update_alert_table($vars['alert_test_id']);
|
||||||
|
print_json_status('ok', 'Associations updated.',
|
||||||
|
[ 'id' => $vars['alert_test_id'],
|
||||||
|
'redirect' => generate_url([ 'page' => 'alert_check', 'alert_test_id' => $vars['alert_test_id'] ]) ]);
|
||||||
|
} else {
|
||||||
|
print_json_status('failed', 'Database was not updated.');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
print_json_status('warning', 'Associations not changed.');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
print_json_status('failed', 'Alert Checker does not exist: [' . $vars['alert_test_id'] . ']');
|
||||||
|
}
|
||||||
|
|
||||||
|
// EOF
|
@ -6,18 +6,18 @@
|
|||||||
*
|
*
|
||||||
* @package observium
|
* @package observium
|
||||||
* @subpackage ajax
|
* @subpackage ajax
|
||||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Currently allowed only for Admins
|
// Currently allowed only for Admins and Limit Write
|
||||||
if (!$readwrite) {
|
if (!$limitwrite) {
|
||||||
print_json_status('failed', 'Action not allowed.');
|
print_json_status('failed', 'Action not allowed.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ok = TRUE;
|
$ok = TRUE;
|
||||||
foreach (array('entity_type', 'alert_name', 'alert_severity', 'alert_conditions') as $var) {
|
foreach (['entity_type', 'alert_name', 'alert_severity', 'alert_conditions'] as $var) {
|
||||||
if (!isset($vars[$var]) || strlen($vars[$var]) == '0') {
|
if (!isset($vars[$var]) || strlen($vars[$var]) == '0') {
|
||||||
$ok = FALSE;
|
$ok = FALSE;
|
||||||
$failed[] = $var;
|
$failed[] = $var;
|
||||||
@ -25,17 +25,17 @@ foreach (array('entity_type', 'alert_name', 'alert_severity', 'alert_conditions'
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($ok) {
|
if ($ok) {
|
||||||
if (dbExist('alert_tests', '`entity_type` = ? AND `alert_name` = ?', [ $vars['entity_type'], $vars['alert_name'] ])) {
|
if (dbExist('alert_tests', '`entity_type` = ? AND `alert_name` = ?', [$vars['entity_type'], $vars['alert_name']])) {
|
||||||
print_json_status('failed', "Alert Checker '{$vars['alert_name']}' already exist.");
|
print_json_status('failed', "Alert Checker '{$vars['alert_name']}' already exist.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$check_array = array();
|
$check_array = [];
|
||||||
|
|
||||||
$conditions = array();
|
$conditions = [];
|
||||||
foreach (explode("\n", trim($vars['alert_conditions'])) as $cond) {
|
foreach (explode("\n", trim($vars['alert_conditions'])) as $cond) {
|
||||||
$condition = array();
|
$condition = [];
|
||||||
list($condition['metric'], $condition['condition'], $condition['value']) = explode(" ", trim($cond), 3);
|
[$condition['metric'], $condition['condition'], $condition['value']] = explode(" ", trim($cond), 3);
|
||||||
$conditions[] = $condition;
|
$conditions[] = $condition;
|
||||||
}
|
}
|
||||||
$check_array['conditions'] = safe_json_encode($conditions);
|
$check_array['conditions'] = safe_json_encode($conditions);
|
||||||
@ -55,7 +55,7 @@ if ($ok) {
|
|||||||
if (is_numeric($check_id)) {
|
if (is_numeric($check_id)) {
|
||||||
update_alert_table($check_id);
|
update_alert_table($check_id);
|
||||||
|
|
||||||
print_json_status('ok', '', [ 'id' => $check_id, 'redirect' => generate_url([ 'page' => 'alert_check', 'alert_test_id' => $check_id ]) ]);
|
print_json_status('ok', '', ['id' => $check_id, 'redirect' => generate_url(['page' => 'alert_check', 'alert_test_id' => $check_id])]);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
print_json_status('failed', 'Alert creation failed. Please note that the alert name <b>must</b> be unique.');
|
print_json_status('failed', 'Alert creation failed. Please note that the alert name <b>must</b> be unique.');
|
||||||
|
@ -6,13 +6,15 @@
|
|||||||
*
|
*
|
||||||
* @package observium
|
* @package observium
|
||||||
* @subpackage ajax
|
* @subpackage ajax
|
||||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($readonly) { return; } // Currently edit allowed only for 7+
|
if ($readonly) {
|
||||||
|
return;
|
||||||
|
} // Currently edit allowed only for 7+
|
||||||
|
|
||||||
$widget = dbFetchRow("SELECT * FROM `dash_widgets` WHERE `widget_id` = ?", [ $vars['widget_id'] ]);
|
$widget = dbFetchRow("SELECT * FROM `dash_widgets` WHERE `widget_id` = ?", [$vars['widget_id']]);
|
||||||
|
|
||||||
$widget['widget_config'] = safe_json_decode($widget['widget_config']);
|
$widget['widget_config'] = safe_json_decode($widget['widget_config']);
|
||||||
|
|
||||||
@ -52,8 +54,8 @@ switch ($widget['widget_type']) {
|
|||||||
//'url' => generate_url([ 'page' => 'syslog_rules' ]),
|
//'url' => generate_url([ 'page' => 'syslog_rules' ]),
|
||||||
'onsubmit' => "return false",
|
'onsubmit' => "return false",
|
||||||
];
|
];
|
||||||
$form['fieldset']['body'] = [ 'class' => 'modal-body' ]; // Required this class for modal body!
|
$form['fieldset']['body'] = ['class' => 'modal-body']; // Required this class for modal body!
|
||||||
$form['fieldset']['footer'] = [ 'class' => 'modal-footer' ]; // Required this class for modal footer!
|
$form['fieldset']['footer'] = ['class' => 'modal-footer']; // Required this class for modal footer!
|
||||||
|
|
||||||
$form['row'][1]['widget-config-title'] = [
|
$form['row'][1]['widget-config-title'] = [
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
@ -100,7 +102,7 @@ switch ($widget['widget_type']) {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
echo '
|
echo '
|
||||||
<form onsubmit="return false" class="form form-horizontal" style="margin-bottom: 0px;">
|
<form onsubmit="return false" class="form form-horizontal" style="margin-bottom: 0px;">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<div id="purpose_div" class="control-group" style="margin-bottom: 10px;"> <!-- START row-1 -->
|
<div id="purpose_div" class="control-group" style="margin-bottom: 10px;"> <!-- START row-1 -->
|
||||||
<label class="control-label" for="purpose">Title</label>
|
<label class="control-label" for="purpose">Title</label>
|
||||||
@ -115,16 +117,16 @@ switch ($widget['widget_type']) {
|
|||||||
<input type="checkbox" name="widget-config-legend" data-field="legend" data-type="checkbox" value="legend" '.(isset($widget['widget_config']['legend']) && $widget['widget_config']['legend'] === 'no' ? '' : 'checked').' data-id="'.$widget['widget_id'].'">
|
<input type="checkbox" name="widget-config-legend" data-field="legend" data-type="checkbox" value="legend" '.(isset($widget['widget_config']['legend']) && $widget['widget_config']['legend'] === 'no' ? '' : 'checked').' data-id="'.$widget['widget_id'].'">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</fieldset> <!-- END fieldset-body -->
|
</fieldset> <!-- END fieldset-body -->
|
||||||
|
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<button id="close" name="close" type="submit" class="btn btn-default text-nowrap" value="" data-dismiss="modal" aria-hidden="true">Close</button>
|
<button id="close" name="close" type="submit" class="btn btn-default text-nowrap" value="" data-dismiss="modal" aria-hidden="true">Close</button>
|
||||||
<!-- <button id="action" name="action" type="submit" class="btn btn-primary text-nowrap" value="add_contact"><i style="margin-right: 0px;" class="icon-ok icon-white"></i> Add Contact</button> -->
|
<!-- <button id="action" name="action" type="submit" class="btn btn-primary text-nowrap" value="add_contact"><i style="margin-right: 0px;" class="icon-ok icon-white"></i> Add Contact</button> -->
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</form>';
|
</form>';
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@ -141,8 +143,7 @@ switch ($widget['widget_type']) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
print_vars($widget);
|
r($widget['widget_config']);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// EOF
|
// EOF
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
*
|
*
|
||||||
* @package observium
|
* @package observium
|
||||||
* @subpackage ajax
|
* @subpackage ajax
|
||||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -15,15 +15,14 @@ $update_ports = [];
|
|||||||
//r($vars);
|
//r($vars);
|
||||||
//$ports_attribs = get_device_entities_attribs($device_id, 'port'); // Get all attribs
|
//$ports_attribs = get_device_entities_attribs($device_id, 'port'); // Get all attribs
|
||||||
|
|
||||||
foreach($vars['port'] as $port_id => $port_data)
|
foreach ($vars['port'] as $port_id => $port_data) {
|
||||||
{
|
|
||||||
|
|
||||||
if (is_entity_write_permitted('port', $port_id)) {
|
if (is_entity_write_permitted('port', $port_id)) {
|
||||||
$port = get_port_by_id_cache($port_id);
|
$port = get_port_by_id_cache($port_id);
|
||||||
$device = device_by_id_cache($port['device_id']);
|
$device = device_by_id_cache($port['device_id']);
|
||||||
|
|
||||||
$updated = FALSE;
|
$updated = FALSE;
|
||||||
$update_array = array();
|
$update_array = [];
|
||||||
|
|
||||||
$port_attribs = get_entity_attribs('port', $port['port_id']);
|
$port_attribs = get_entity_attribs('port', $port['port_id']);
|
||||||
|
|
||||||
@ -32,7 +31,7 @@ foreach($vars['port'] as $port_id => $port_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check ignored and disabled port
|
// Check ignored and disabled port
|
||||||
foreach (array('ignore', 'disabled') as $param) {
|
foreach (['ignore', 'disabled'] as $param) {
|
||||||
$old_param = $port[$param] ? 1 : 0;
|
$old_param = $port[$param] ? 1 : 0;
|
||||||
$new_param = (isset($port_data[$param]) && $port_data[$param]) ? 1 : 0;
|
$new_param = (isset($port_data[$param]) && $port_data[$param]) ? 1 : 0;
|
||||||
if ($old_param != $new_param) {
|
if ($old_param != $new_param) {
|
||||||
@ -41,7 +40,7 @@ foreach($vars['port'] as $port_id => $port_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (count($update_array)) {
|
if (count($update_array)) {
|
||||||
dbUpdate($update_array, 'ports', '`port_id` = ?', array($port_id));
|
dbUpdate($update_array, 'ports', '`port_id` = ?', [$port_id]);
|
||||||
$updated = TRUE;
|
$updated = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,7 +49,7 @@ foreach($vars['port'] as $port_id => $port_data)
|
|||||||
$old_ifSpeed_bool = isset($port['ifSpeed_custom']);
|
$old_ifSpeed_bool = isset($port['ifSpeed_custom']);
|
||||||
$new_ifSpeed_bool = isset($port_data['ifSpeed_custom_bool']) && $port_data['ifSpeed_custom_bool'];
|
$new_ifSpeed_bool = isset($port_data['ifSpeed_custom_bool']) && $port_data['ifSpeed_custom_bool'];
|
||||||
if ($new_ifSpeed_bool) {
|
if ($new_ifSpeed_bool) {
|
||||||
$port_data['ifSpeed_custom'] = (int) unit_string_to_numeric($port_data['ifSpeed_custom'], 1000);
|
$port_data['ifSpeed_custom'] = (int)unit_string_to_numeric($port_data['ifSpeed_custom'], 1000);
|
||||||
if ($port_data['ifSpeed_custom'] <= 0) {
|
if ($port_data['ifSpeed_custom'] <= 0) {
|
||||||
// Wrong ifSpeed, skip
|
// Wrong ifSpeed, skip
|
||||||
//print_warning("Passed incorrect value for port speed: ".unit_string_to_numeric($port_data['ifSpeed_custom'], 1000));
|
//print_warning("Passed incorrect value for port speed: ".unit_string_to_numeric($port_data['ifSpeed_custom'], 1000));
|
||||||
@ -88,7 +87,7 @@ foreach($vars['port'] as $port_id => $port_data)
|
|||||||
}
|
}
|
||||||
// Query updated sensors array
|
// Query updated sensors array
|
||||||
if ($rows_updated) {
|
if ($rows_updated) {
|
||||||
print_json_status('ok', $rows_updated.' port(s) updated.', [ 'update_array' => $update_ports ]);
|
print_json_status('ok', $rows_updated . ' port(s) updated.', ['update_array' => $update_ports]);
|
||||||
} else {
|
} else {
|
||||||
print_json_status('failed', 'No update performed.');
|
print_json_status('failed', 'No update performed.');
|
||||||
}
|
}
|
||||||
|
35
html/ajax/actions/role_del.inc.php
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Observium
|
||||||
|
*
|
||||||
|
* This file is part of Observium.
|
||||||
|
*
|
||||||
|
* @package observium
|
||||||
|
* @subpackage web
|
||||||
|
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Currently, allowed only for Admins
|
||||||
|
if (!$readwrite) {
|
||||||
|
print_json_status('failed', 'Insufficient permissions to delete role.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$role_id = (int)$vars['role_id'];
|
||||||
|
if ($role_id > 0) {
|
||||||
|
$rows_deleted = dbDelete('roles', '`role_id` = ?', [$role_id]);
|
||||||
|
//$rows_deleted = 0;
|
||||||
|
if ($rows_deleted > 0) {
|
||||||
|
dbDelete('roles_entity_permissions', '`role_id` = ?', [$role_id]);
|
||||||
|
dbDelete('roles_permissions', '`role_id` = ?', [$role_id]);
|
||||||
|
dbDelete('roles_users', '`role_id` = ?', [$role_id]);
|
||||||
|
print_json_status('ok', 'Role deleted successfully.', ['reload' => TRUE]);
|
||||||
|
} else {
|
||||||
|
print_json_status('failed', 'Failed to delete role.');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
print_json_status('failed', 'Invalid role ID.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// EOF
|
@ -6,7 +6,7 @@
|
|||||||
*
|
*
|
||||||
* @package observium
|
* @package observium
|
||||||
* @subpackage ajax
|
* @subpackage ajax
|
||||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -25,13 +25,13 @@ foreach ($vars['sensors'] as $sensor_id => $sensor_update) {
|
|||||||
|
|
||||||
if (!$sensor['sensor_state']) {
|
if (!$sensor['sensor_state']) {
|
||||||
// Normal sensors
|
// Normal sensors
|
||||||
$fields_switch = [ 'sensor_ignore', 'sensor_custom_limit' ];
|
$fields_switch = ['sensor_ignore', 'sensor_custom_limit'];
|
||||||
$fields_limit = [ 'sensor_limit', 'sensor_limit_warn', 'sensor_limit_low_warn', 'sensor_limit_low' ];
|
$fields_limit = ['sensor_limit', 'sensor_limit_warn', 'sensor_limit_low_warn', 'sensor_limit_low'];
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// State sensors not allow edit limits
|
// State sensors not allow edit limits
|
||||||
$fields_switch = array('sensor_ignore');
|
$fields_switch = ['sensor_ignore'];
|
||||||
$fields_limit = array();
|
$fields_limit = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Switch selectors
|
// Switch selectors
|
||||||
@ -48,14 +48,14 @@ foreach ($vars['sensors'] as $sensor_id => $sensor_update) {
|
|||||||
if ($sensor['sensor_custom_limit']) {
|
if ($sensor['sensor_custom_limit']) {
|
||||||
$update_array['sensor_custom_limit'] = '0';
|
$update_array['sensor_custom_limit'] = '0';
|
||||||
}
|
}
|
||||||
$update_array['sensor_limit_low'] = [ 'NULL' ];
|
$update_array['sensor_limit_low'] = ['NULL'];
|
||||||
$update_array['sensor_limit_low_warn'] = [ 'NULL' ];
|
$update_array['sensor_limit_low_warn'] = ['NULL'];
|
||||||
$update_array['sensor_limit_warn'] = [ 'NULL' ];
|
$update_array['sensor_limit_warn'] = ['NULL'];
|
||||||
$update_array['sensor_limit'] = [ 'NULL' ];
|
$update_array['sensor_limit'] = ['NULL'];
|
||||||
} elseif ($sensor_update['sensor_custom_limit']) {
|
} elseif ($sensor_update['sensor_custom_limit']) {
|
||||||
foreach ($fields_limit as $field) {
|
foreach ($fields_limit as $field) {
|
||||||
$sensor_update[$field] = !is_numeric($sensor_update[$field]) ? [ 'NULL' ] : (float)$sensor_update[$field];
|
$sensor_update[$field] = !is_numeric($sensor_update[$field]) ? ['NULL'] : (float)$sensor_update[$field];
|
||||||
$sensor[$field] = !is_numeric($sensor[$field]) ? [ 'NULL' ] : (float)$sensor[$field];
|
$sensor[$field] = !is_numeric($sensor[$field]) ? ['NULL'] : (float)$sensor[$field];
|
||||||
if ($sensor_update[$field] !== $sensor[$field]) {
|
if ($sensor_update[$field] !== $sensor[$field]) {
|
||||||
$update_array[$field] = $sensor_update[$field];
|
$update_array[$field] = $sensor_update[$field];
|
||||||
}
|
}
|
||||||
@ -63,7 +63,7 @@ foreach ($vars['sensors'] as $sensor_id => $sensor_update) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (count($update_array)) {
|
if (count($update_array)) {
|
||||||
dbUpdate($update_array, 'sensors', '`sensor_id` = ?', array($sensor['sensor_id']));
|
dbUpdate($update_array, 'sensors', '`sensor_id` = ?', [$sensor['sensor_id']]);
|
||||||
$msg = 'Sensor updated (custom): ' . $sensor['sensor_class'] . ' ' . $sensor['sensor_type'] . ' ' . $sensor['sensor_id'] . ' ' . escape_html($sensor['sensor_descr']) . ' ';
|
$msg = 'Sensor updated (custom): ' . $sensor['sensor_class'] . ' ' . $sensor['sensor_type'] . ' ' . $sensor['sensor_id'] . ' ' . escape_html($sensor['sensor_descr']) . ' ';
|
||||||
if ($update_array['sensor_limit_low']) {
|
if ($update_array['sensor_limit_low']) {
|
||||||
$msg .= '[L: ' . $update_array['sensor_limit_low'] . ']';
|
$msg .= '[L: ' . $update_array['sensor_limit_low'] . ']';
|
||||||
@ -91,7 +91,7 @@ foreach ($vars['sensors'] as $sensor_id => $sensor_update) {
|
|||||||
|
|
||||||
// Query updated sensors array
|
// Query updated sensors array
|
||||||
if ($rows_updated) {
|
if ($rows_updated) {
|
||||||
print_json_status('ok', $rows_updated.' sensor(s) updated.', [ 'update_array' => $update_entities ]);
|
print_json_status('ok', $rows_updated . ' sensor(s) updated.', ['update_array' => $update_entities]);
|
||||||
} else {
|
} else {
|
||||||
print_json_status('failed', 'No update performed.');
|
print_json_status('failed', 'No update performed.');
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
*
|
*
|
||||||
* @package observium
|
* @package observium
|
||||||
* @subpackage web
|
* @subpackage web
|
||||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ if (safe_count($sets)) {
|
|||||||
$query = 'SELECT * FROM `users_prefs` WHERE `user_id` = ?' . generate_query_values_and(array_keys($sets), 'pref');
|
$query = 'SELECT * FROM `users_prefs` WHERE `user_id` = ?' . generate_query_values_and(array_keys($sets), 'pref');
|
||||||
// Fetch current rows in config file so we know which one to UPDATE and which one to INSERT
|
// Fetch current rows in config file so we know which one to UPDATE and which one to INSERT
|
||||||
$in_db = [];
|
$in_db = [];
|
||||||
foreach (dbFetchRows($query, [ $user_id ]) as $row) {
|
foreach (dbFetchRows($query, [$user_id]) as $row) {
|
||||||
$in_db[$row['pref']] = $row['value'];
|
$in_db[$row['pref']] = $row['value'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ if (safe_count($sets)) {
|
|||||||
|
|
||||||
// Delete fields that were reset to default
|
// Delete fields that were reset to default
|
||||||
if (safe_count($deletes)) {
|
if (safe_count($deletes)) {
|
||||||
dbDelete('users_prefs', '`user_id` = ? ' . generate_query_values_and($deletes, 'pref'), [ $user_id ]);
|
dbDelete('users_prefs', '`user_id` = ? ' . generate_query_values_and($deletes, 'pref'), [$user_id]);
|
||||||
$updates++;
|
$updates++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ if ($updates) {
|
|||||||
$status = 'warning';
|
$status = 'warning';
|
||||||
$message .= ' Errors: ' . implode('; ', $errors) . '.';
|
$message .= ' Errors: ' . implode('; ', $errors) . '.';
|
||||||
}
|
}
|
||||||
print_json_status($status, $message, [ 'reload' => TRUE ]);
|
print_json_status($status, $message, ['reload' => TRUE]);
|
||||||
|
|
||||||
} elseif (safe_count($errors)) {
|
} elseif (safe_count($errors)) {
|
||||||
$status = 'failed';
|
$status = 'failed';
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
*
|
*
|
||||||
* @package observium
|
* @package observium
|
||||||
* @subpackage web
|
* @subpackage web
|
||||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ switch (str_replace('->', '|', $vars['setting'])) {
|
|||||||
// BOOL values
|
// BOOL values
|
||||||
$pref = $vars['setting'];
|
$pref = $vars['setting'];
|
||||||
if (set_user_pref($_SESSION['user_id'], $pref, serialize(get_var_true($vars['value'])))) {
|
if (set_user_pref($_SESSION['user_id'], $pref, serialize(get_var_true($vars['value'])))) {
|
||||||
print_json_status('ok', 'Setting was set.', [ 'reload' => TRUE ]);
|
print_json_status('ok', 'Setting was set.', ['reload' => TRUE]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
*
|
*
|
||||||
* @package observium
|
* @package observium
|
||||||
* @subpackage ajax
|
* @subpackage ajax
|
||||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -17,13 +17,13 @@ $update_entities = [];
|
|||||||
foreach ($vars['status'] as $status_id => $status_update) {
|
foreach ($vars['status'] as $status_id => $status_update) {
|
||||||
|
|
||||||
$update_array = [];
|
$update_array = [];
|
||||||
if(is_entity_write_permitted('status', $status_id)) {
|
if (is_entity_write_permitted('status', $status_id)) {
|
||||||
$status = get_status_by_id($status_id);
|
$status = get_status_by_id($status_id);
|
||||||
|
|
||||||
$device_id = $status['device_id'];
|
$device_id = $status['device_id'];
|
||||||
|
|
||||||
$fields_switch = array('status_ignore');
|
$fields_switch = ['status_ignore'];
|
||||||
$fields_limit = array();
|
$fields_limit = [];
|
||||||
|
|
||||||
// Switch selectors
|
// Switch selectors
|
||||||
foreach ($fields_switch as $field) {
|
foreach ($fields_switch as $field) {
|
||||||
@ -34,7 +34,7 @@ foreach ($vars['status'] as $status_id => $status_update) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (count($update_array)) {
|
if (count($update_array)) {
|
||||||
dbUpdate($update_array, 'status', '`status_id` = ?', array($status['status_id']));
|
dbUpdate($update_array, 'status', '`status_id` = ?', [$status['status_id']]);
|
||||||
$msg = 'Status updated (custom): ' . $status['status_type'] . ' ' . $status['status_id'] . ' ' . escape_html($status['status_descr']) . ' ';
|
$msg = 'Status updated (custom): ' . $status['status_type'] . ' ' . $status['status_id'] . ' ' . escape_html($status['status_descr']) . ' ';
|
||||||
log_event($msg, $device_id, 'status', $status['status_id']);
|
log_event($msg, $device_id, 'status', $status['status_id']);
|
||||||
$rows_updated++;
|
$rows_updated++;
|
||||||
@ -50,7 +50,7 @@ foreach ($vars['status'] as $status_id => $status_update) {
|
|||||||
|
|
||||||
// Query updated array
|
// Query updated array
|
||||||
if ($rows_updated) {
|
if ($rows_updated) {
|
||||||
print_json_status('ok', $rows_updated.' status(es) updated.', [ 'update_array' => $update_entities ]);
|
print_json_status('ok', $rows_updated . ' status(es) updated.', ['update_array' => $update_entities]);
|
||||||
} else {
|
} else {
|
||||||
print_json_status('failed', 'No update performed.');
|
print_json_status('failed', 'No update performed.');
|
||||||
}
|
}
|
||||||
|
@ -8,50 +8,44 @@
|
|||||||
* @package observium
|
* @package observium
|
||||||
* @subpackage ajax
|
* @subpackage ajax
|
||||||
* @author Adam Armstrong <adama@observium.org>
|
* @author Adam Armstrong <adama@observium.org>
|
||||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$config['install_dir'] = "../..";
|
include_once("../../includes/observium.inc.php");
|
||||||
|
|
||||||
include_once("../../includes/sql-config.inc.php");
|
|
||||||
|
|
||||||
include($config['html_dir'] . "/includes/functions.inc.php");
|
|
||||||
include($config['html_dir'] . "/includes/authenticate.inc.php");
|
include($config['html_dir'] . "/includes/authenticate.inc.php");
|
||||||
|
|
||||||
if (!$_SESSION['authenticated']) { echo("unauthenticated"); exit; }
|
if (!$_SESSION['authenticated']) {
|
||||||
|
echo("unauthenticated");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
if ($_SESSION['userlevel'] >= '5')
|
if ($_SESSION['userlevel'] >= '5') {
|
||||||
{
|
|
||||||
|
|
||||||
switch ($_GET['entity_type'])
|
switch ($_GET['entity_type']) {
|
||||||
{
|
|
||||||
|
|
||||||
case "sensor":
|
case "sensor":
|
||||||
foreach (dbFetch("SELECT * FROM `sensors` WHERE device_id = ?", array($_GET['device_id'])) as $sensor)
|
foreach (dbFetch("SELECT * FROM `sensors` WHERE device_id = ?", [$_GET['device_id']]) as $sensor) {
|
||||||
{
|
if (is_entity_permitted($sensor, 'sensor')) {
|
||||||
if(is_entity_permitted($sensor, 'sensor'))
|
|
||||||
{
|
|
||||||
$string = addslashes($sensor['sensor_descr']);
|
$string = addslashes($sensor['sensor_descr']);
|
||||||
echo("obj.options[obj.options.length] = new Option('".$string."','".$sensor['sensor_id']."');\n");
|
echo("obj.options[obj.options.length] = new Option('" . $string . "','" . $sensor['sensor_id'] . "');\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "netscalervsvr":
|
case "netscalervsvr":
|
||||||
foreach (dbFetch("SELECT * FROM `netscaler_vservers` WHERE `device_id` = ?", array($_GET['device_id'])) as $entity)
|
foreach (dbFetch("SELECT * FROM `netscaler_vservers` WHERE `device_id` = ?", [$_GET['device_id']]) as $entity) {
|
||||||
{
|
|
||||||
$string = addslashes($entity['vsvr_label']);
|
$string = addslashes($entity['vsvr_label']);
|
||||||
echo("obj.options[obj.options.length] = new Option('".$string."','".$entity['vsvr_id']."');\n");
|
echo("obj.options[obj.options.length] = new Option('" . $string . "','" . $entity['vsvr_id'] . "');\n");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case "port":
|
case "port":
|
||||||
foreach (dbFetch("SELECT * FROM `ports` WHERE `device_id` = ? AND `deleted` = '0'", array($_GET['device_id'])) as $port)
|
foreach (dbFetch("SELECT * FROM `ports` WHERE `device_id` = ? AND `deleted` = '0'", [$_GET['device_id']]) as $port) {
|
||||||
{
|
$string = addslashes($port['port_label_short'] . " - " . $port['ifAlias']);
|
||||||
$string = addslashes($port['port_label_short']." - ".$port['ifAlias']);
|
echo("obj.options[obj.options.length] = new Option('" . $string . "','" . $port['port_id'] . "');\n");
|
||||||
echo("obj.options[obj.options.length] = new Option('".$string."','".$port['port_id']."');\n");
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -8,38 +8,34 @@
|
|||||||
* @package observium
|
* @package observium
|
||||||
* @subpackage ajax
|
* @subpackage ajax
|
||||||
* @author Adam Armstrong <adama@observium.org>
|
* @author Adam Armstrong <adama@observium.org>
|
||||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$config['install_dir'] = "../..";
|
include_once("../../includes/observium.inc.php");
|
||||||
|
|
||||||
include_once("../../includes/sql-config.inc.php");
|
|
||||||
|
|
||||||
include($config['html_dir'] . "/includes/functions.inc.php");
|
|
||||||
include($config['html_dir'] . "/includes/authenticate.inc.php");
|
include($config['html_dir'] . "/includes/authenticate.inc.php");
|
||||||
|
|
||||||
if (!$_SESSION['authenticated']) { echo("unauthenticated"); exit; }
|
if (!$_SESSION['authenticated']) {
|
||||||
|
echo("unauthenticated");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
if (is_numeric($_GET['device_id']) && device_permitted($_GET['device_id']))
|
if (is_numeric($_GET['device_id']) && device_permitted($_GET['device_id'])) {
|
||||||
{
|
foreach (dbFetchRows("SELECT `port_id`,`port_label_short`,`ifAlias`,`ifDescr`,`ifName` FROM `ports` WHERE `device_id` = ? AND deleted = 0 ORDER BY ifIndex", [$_GET['device_id']]) as $interface) {
|
||||||
foreach (dbFetchRows("SELECT `port_id`,`port_label_short`,`ifAlias`,`ifDescr`,`ifName` FROM `ports` WHERE `device_id` = ? AND deleted = 0 ORDER BY ifIndex", array($_GET['device_id'])) as $interface)
|
$descr = [];
|
||||||
{
|
if (empty($interface['port_label_short'])) {
|
||||||
$descr = array();
|
|
||||||
if (empty($interface['port_label_short']))
|
|
||||||
{
|
|
||||||
$device = device_by_id_cache($interface['port_id']);
|
$device = device_by_id_cache($interface['port_id']);
|
||||||
process_port_label($interface, $device);
|
process_port_label($interface, $device);
|
||||||
}
|
}
|
||||||
$descr[] = $interface['port_label_short'];
|
$descr[] = $interface['port_label_short'];
|
||||||
|
|
||||||
if ($interface['ifAlias'])
|
if ($interface['ifAlias']) {
|
||||||
{
|
|
||||||
// second part
|
// second part
|
||||||
$descr[] = $interface['ifAlias'];
|
$descr[] = $interface['ifAlias'];
|
||||||
}
|
}
|
||||||
$string = addslashes(implode(" - ", $descr));
|
$string = addslashes(implode(" - ", $descr));
|
||||||
echo("obj.options[obj.options.length] = new Option('".$string."','".$interface['port_id']."');\n");
|
echo("obj.options[obj.options.length] = new Option('" . $string . "','" . $interface['port_id'] . "');\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,26 +8,24 @@
|
|||||||
* @package observium
|
* @package observium
|
||||||
* @subpackage ajax
|
* @subpackage ajax
|
||||||
* @author Adam Armstrong <adama@observium.org>
|
* @author Adam Armstrong <adama@observium.org>
|
||||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$config['install_dir'] = "../..";
|
include_once("../../includes/observium.inc.php");
|
||||||
|
|
||||||
include_once("../../includes/sql-config.inc.php");
|
|
||||||
|
|
||||||
include($config['html_dir'] . "/includes/functions.inc.php");
|
|
||||||
include($config['html_dir'] . "/includes/authenticate.inc.php");
|
include($config['html_dir'] . "/includes/authenticate.inc.php");
|
||||||
|
|
||||||
if (!$_SESSION['authenticated']) { echo("unauthenticated"); exit; }
|
if (!$_SESSION['authenticated']) {
|
||||||
|
echo("unauthenticated");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
$result = array();
|
$result = [];
|
||||||
|
|
||||||
if ($_SESSION['userlevel'] >= '5')
|
if ($_SESSION['userlevel'] >= '5') {
|
||||||
{
|
|
||||||
|
|
||||||
switch ($_GET['entity_type'])
|
switch ($_GET['entity_type']) {
|
||||||
{
|
|
||||||
|
|
||||||
case "port":
|
case "port":
|
||||||
|
|
||||||
@ -46,7 +44,7 @@ if ($_SESSION['userlevel'] >= '5')
|
|||||||
foreach ($ports_db as $port) {
|
foreach ($ports_db as $port) {
|
||||||
humanize_port($port);
|
humanize_port($port);
|
||||||
$device = device_by_id_cache($port['device_id']);
|
$device = device_by_id_cache($port['device_id']);
|
||||||
array_push($result, [ intval($port['port_id']), $device['hostname'], $port['port_label'], $port['ifAlias'], $port['ifOperStatus'] == 'up' ? 'up' : 'down' ]);
|
array_push($result, [intval($port['port_id']), $device['hostname'], $port['port_label'], $port['ifAlias'], $port['ifOperStatus'] == 'up' ? 'up' : 'down']);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -6,18 +6,18 @@
|
|||||||
*
|
*
|
||||||
* @package observium
|
* @package observium
|
||||||
* @subpackage web
|
* @subpackage web
|
||||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$config['install_dir'] = "../..";
|
require_once("../../includes/observium.inc.php");
|
||||||
|
|
||||||
require_once($config['install_dir']."/includes/sql-config.inc.php");
|
|
||||||
|
|
||||||
include($config['html_dir'] . "/includes/functions.inc.php");
|
|
||||||
include($config['html_dir'] . "/includes/authenticate.inc.php");
|
include($config['html_dir'] . "/includes/authenticate.inc.php");
|
||||||
|
|
||||||
if (!$_SESSION['authenticated']) { print_error('Session expired, please log in again!'); exit; }
|
if (!$_SESSION['authenticated']) {
|
||||||
|
print_error('Session expired, please log in again!');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
@ -25,7 +25,9 @@ $vars = get_vars([ 'JSON', 'POST', 'GET' ]);
|
|||||||
|
|
||||||
$vars['page'] = "popup";
|
$vars['page'] = "popup";
|
||||||
|
|
||||||
if(isset($vars['debug'])) { r($vars); }
|
if (isset($vars['debug'])) {
|
||||||
|
r($vars);
|
||||||
|
}
|
||||||
|
|
||||||
switch ($vars['entity_type']) {
|
switch ($vars['entity_type']) {
|
||||||
case "port":
|
case "port":
|
||||||
@ -47,7 +49,7 @@ switch ($vars['entity_type']) {
|
|||||||
|
|
||||||
if (is_numeric($vars['entity_id_b']) && (port_permitted($vars['entity_id_b']))) {
|
if (is_numeric($vars['entity_id_b']) && (port_permitted($vars['entity_id_b']))) {
|
||||||
$port = get_port_by_id($vars['entity_id_b']);
|
$port = get_port_by_id($vars['entity_id_b']);
|
||||||
echo generate_port_popup($port, '','none'); // suppress graph for b side of link
|
echo generate_port_popup($port, '', 'none'); // suppress graph for b side of link
|
||||||
} else {
|
} else {
|
||||||
print_warning("You are not permitted to view this port.");
|
print_warning("You are not permitted to view this port.");
|
||||||
}
|
}
|
||||||
@ -66,7 +68,7 @@ switch ($vars['entity_type']) {
|
|||||||
case "group":
|
case "group":
|
||||||
if (is_numeric($vars['entity_id']) && $_SESSION['userlevel'] >= 5) {
|
if (is_numeric($vars['entity_id']) && $_SESSION['userlevel'] >= 5) {
|
||||||
$group = get_group_by_id($vars['entity_id']);
|
$group = get_group_by_id($vars['entity_id']);
|
||||||
echo generate_group_popup_header($group, array());
|
echo generate_group_popup_header($group);
|
||||||
} else {
|
} else {
|
||||||
print_warning("You are not permitted to view this group.");
|
print_warning("You are not permitted to view this group.");
|
||||||
}
|
}
|
||||||
@ -79,7 +81,7 @@ switch ($vars['entity_type']) {
|
|||||||
$url = 'https://api.macvendors.com/' . urlencode($mac);
|
$url = 'https://api.macvendors.com/' . urlencode($mac);
|
||||||
$response = get_http_request($url);
|
$response = get_http_request($url);
|
||||||
if ($response) {
|
if ($response) {
|
||||||
echo 'MAC vendor: ' . $response;
|
echo 'MAC vendor: ' . escape_html($response);
|
||||||
} else {
|
} else {
|
||||||
echo 'Not Found';
|
echo 'Not Found';
|
||||||
}
|
}
|
||||||
@ -89,7 +91,7 @@ switch ($vars['entity_type']) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "ip":
|
case "ip":
|
||||||
list($ip) = explode('/', $vars['entity_id']);
|
$ip = explode('/', $vars['entity_id'])[0];
|
||||||
|
|
||||||
if ($ip_version = get_ip_version($ip)) {
|
if ($ip_version = get_ip_version($ip)) {
|
||||||
$cache_key = 'response_' . $vars['entity_type'] . '_' . $ip;
|
$cache_key = 'response_' . $vars['entity_type'] . '_' . $ip;
|
||||||
@ -122,7 +124,7 @@ switch ($vars['entity_type']) {
|
|||||||
$org = 0;
|
$org = 0;
|
||||||
foreach (explode("\n", $whois) as $line) {
|
foreach (explode("\n", $whois) as $line) {
|
||||||
if (preg_match('/^(\w[\w\s\-\/]+):.*$/', $line, $matches)) {
|
if (preg_match('/^(\w[\w\s\-\/]+):.*$/', $line, $matches)) {
|
||||||
if (in_array($matches[1], [ 'Ref', 'source', 'nic-hdl-br' ])) {
|
if (in_array($matches[1], ['Ref', 'source', 'nic-hdl-br'])) {
|
||||||
if ($org === 1) {
|
if ($org === 1) {
|
||||||
$response .= PHP_EOL;
|
$response .= PHP_EOL;
|
||||||
$org++;
|
$org++;
|
||||||
@ -130,7 +132,7 @@ switch ($vars['entity_type']) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (in_array($matches[1], array('Organization', 'org', 'mnt-irt'))) {
|
if (in_array($matches[1], ['Organization', 'org', 'mnt-irt'])) {
|
||||||
$org++; // has org info
|
$org++; // has org info
|
||||||
} elseif ($matches[1] === 'Comment') {
|
} elseif ($matches[1] === 'Comment') {
|
||||||
continue; // skip comments
|
continue; // skip comments
|
||||||
@ -147,19 +149,19 @@ switch ($vars['entity_type']) {
|
|||||||
if ($request = get_http_request($whois_url)) {
|
if ($request = get_http_request($whois_url)) {
|
||||||
$request = safe_json_decode($request); // Convert to array
|
$request = safe_json_decode($request); // Convert to array
|
||||||
if ($request['status'] === 'ok' && safe_count($request['data']['records'])) {
|
if ($request['status'] === 'ok' && safe_count($request['data']['records'])) {
|
||||||
$whois_parts = array();
|
$whois_parts = [];
|
||||||
foreach ($request['data']['records'] as $i => $parts) {
|
foreach ($request['data']['records'] as $i => $parts) {
|
||||||
$key = $parts[0]['key'];
|
$key = $parts[0]['key'];
|
||||||
|
|
||||||
if (in_array($key, [ 'NetRange', 'inetnum', 'inet6num' ])) {
|
if (in_array($key, ['NetRange', 'inetnum', 'inet6num'])) {
|
||||||
$org = 0;
|
$org = 0;
|
||||||
|
|
||||||
$whois_parts[0] = '';
|
$whois_parts[0] = '';
|
||||||
foreach ($parts as $part) {
|
foreach ($parts as $part) {
|
||||||
if (in_array($part['key'], [ 'Ref', 'source', 'nic-hdl-br' ])) {
|
if (in_array($part['key'], ['Ref', 'source', 'nic-hdl-br'])) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (in_array($part['key'], [ 'Organization', 'org', 'mnt-irt' ])) {
|
if (in_array($part['key'], ['Organization', 'org', 'mnt-irt'])) {
|
||||||
$org = 1; // has org info
|
$org = 1; // has org info
|
||||||
$org_name = $part['value'];
|
$org_name = $part['value'];
|
||||||
} elseif ($part['key'] === 'Comment') {
|
} elseif ($part['key'] === 'Comment') {
|
||||||
@ -172,7 +174,7 @@ switch ($vars['entity_type']) {
|
|||||||
|
|
||||||
$whois_parts[1] = '';
|
$whois_parts[1] = '';
|
||||||
foreach ($parts as $part) {
|
foreach ($parts as $part) {
|
||||||
if (in_array($part['key'], [ 'Ref', 'source', 'nic-hdl-br' ])) {
|
if (in_array($part['key'], ['Ref', 'source', 'nic-hdl-br'])) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ($part['key'] === 'Comment') {
|
if ($part['key'] === 'Comment') {
|
||||||
@ -192,7 +194,7 @@ switch ($vars['entity_type']) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($response) {
|
if ($response) {
|
||||||
$cache_entry = '<pre class="small">' . $response . '</pre>';
|
$cache_entry = '<pre class="small">' . escape_html($response) . '</pre>';
|
||||||
// @session_start();
|
// @session_start();
|
||||||
// $_SESSION['cache']['response_' . $vars['entity_type'] . '_' . $ip] = '<pre class="small">' . $response . '</pre>';
|
// $_SESSION['cache']['response_' . $vars['entity_type'] . '_' . $ip] = '<pre class="small">' . $response . '</pre>';
|
||||||
// session_commit();
|
// session_commit();
|
||||||
@ -225,7 +227,7 @@ switch ($vars['entity_type']) {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$entry = dbFetchRow('SELECT `remote_hostname`, `remote_ip`, `last_reason`, UNIX_TIMESTAMP(`last_checked`) AS `last_checked_unixtime` FROM `autodiscovery` WHERE `autodiscovery_id` = ?', [ $vars['entity_id'] ]);
|
$entry = dbFetchRow('SELECT `remote_hostname`, `remote_ip`, `last_reason`, UNIX_TIMESTAMP(`last_checked`) AS `last_checked_unixtime` FROM `autodiscovery` WHERE `autodiscovery_id` = ?', [$vars['entity_id']]);
|
||||||
$hostname = $entry['remote_hostname'];
|
$hostname = $entry['remote_hostname'];
|
||||||
$ip = $entry['remote_ip'];
|
$ip = $entry['remote_ip'];
|
||||||
|
|
||||||
@ -273,8 +275,9 @@ switch ($vars['entity_type']) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$cache_entry = '<div style="width: 280px;">';
|
$cache_entry = '<div style="width: 280px;">';
|
||||||
$cache_entry .= "<h4>$last_reason</h4><hr />";
|
$cache_entry .= "<h4>" . escape_html($last_reason) . "</h4><hr />";
|
||||||
$cache_entry .= '<strong style="margin-left: 10px;">Autodiscovery checked:</strong> '. format_uptime(time() - $entry['last_checked_unixtime'], 'shorter') . ' ago</span>';
|
$cache_entry .= '<strong style="margin-left: 10px;">Autodiscovery checked:</strong> ' .
|
||||||
|
format_uptime(get_time() - $entry['last_checked_unixtime'], 'shorter') . ' ago</span>';
|
||||||
$cache_entry .= '</div>';
|
$cache_entry .= '</div>';
|
||||||
//$cache_entry .= build_table_row($entry);
|
//$cache_entry .= build_table_row($entry);
|
||||||
set_cache_session($cache_key, $cache_entry);
|
set_cache_session($cache_key, $cache_entry);
|
||||||
@ -284,9 +287,76 @@ switch ($vars['entity_type']) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'latlon':
|
||||||
|
// Check if latitude and longitude are set
|
||||||
|
if (!isset($vars['lat'], $vars['lon'])) {
|
||||||
|
echo "ERROR: Latitude and Longitude required";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$location = [];
|
||||||
|
|
||||||
|
// Fetch devices and their locations
|
||||||
|
$devices = dbFetchRows("SELECT * FROM `devices` LEFT JOIN `devices_locations` USING (`device_id`) " .
|
||||||
|
generate_where_clause(generate_query_permitted_ng(['devices']),
|
||||||
|
"location_lat = ? AND location_lon = ?"),
|
||||||
|
[$vars['lat'], $vars['lon']]);
|
||||||
|
|
||||||
|
foreach ($devices as $device) {
|
||||||
|
if (!$config['web_show_disabled'] && $device["disabled"]) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($device['location'] != '') {
|
||||||
|
$location['location_name'] = $device['location'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Categorize devices as up or down
|
||||||
|
if ($device["status"] == "0" && $device["ignore"] == "0") {
|
||||||
|
$location["down_hosts"][] = $device;
|
||||||
|
} else {
|
||||||
|
$location["up_hosts"][] = $device;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Display location information
|
||||||
|
if (!isset($location['location_name'])) {
|
||||||
|
echo "Unknown Location";
|
||||||
|
} else {
|
||||||
|
$num_up = safe_count($location["up_hosts"]);
|
||||||
|
$num_down = safe_count($location["down_hosts"]);
|
||||||
|
$total_hosts = $num_up + $num_down;
|
||||||
|
|
||||||
|
$state = 'unknown';
|
||||||
|
if ($num_down > 0) {
|
||||||
|
$state = 'down';
|
||||||
|
} elseif ($num_up > 0) {
|
||||||
|
$state = 'up';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate tooltip content
|
||||||
|
$tooltip = "<h3>" . escape_html($location['location_name']) . "</h3><hr />";
|
||||||
|
$tooltip .= '<p><span class="label label-success">Up ' . $num_up . '</span>
|
||||||
|
<span class="label label-error">Down ' . $num_down . '</span></p>';
|
||||||
|
|
||||||
|
if($num_up < 50) {
|
||||||
|
foreach ($location["up_hosts"] as $host) {
|
||||||
|
$tooltip .= '<span class="label label-success">' . escape_html($host['hostname']) . '</span> ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach ($location["down_hosts"] as $host) {
|
||||||
|
$tooltip .= '<span class="label label-error">' . escape_html($host['hostname']) . '</span> ';
|
||||||
|
}
|
||||||
|
//$tooltip .= "<p><small>Coordinates: ".$vars['lat'].",".$vars['lon']."</small></p>";
|
||||||
|
|
||||||
|
echo $tooltip;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (isset($config['entities'][$vars['entity_type']])) {
|
if (isset($config['entities'][$vars['entity_type']])) {
|
||||||
$entity_ids = array();
|
$entity_ids = [];
|
||||||
foreach (explode(',', $vars['entity_id']) as $id) {
|
foreach (explode(',', $vars['entity_id']) as $id) {
|
||||||
// Filter permitted IDs
|
// Filter permitted IDs
|
||||||
if (is_numeric($id) && (is_entity_permitted($id, $vars['entity_type']))) {
|
if (is_numeric($id) && (is_entity_permitted($id, $vars['entity_type']))) {
|
||||||
@ -295,11 +365,6 @@ switch ($vars['entity_type']) {
|
|||||||
}
|
}
|
||||||
if (count($entity_ids)) {
|
if (count($entity_ids)) {
|
||||||
echo generate_entity_popup_multi($entity_ids, $vars);
|
echo generate_entity_popup_multi($entity_ids, $vars);
|
||||||
//}
|
|
||||||
//elseif (is_numeric($vars['entity_id']) && (is_entity_permitted($vars['entity_id'], $vars['entity_type'])))
|
|
||||||
//{
|
|
||||||
// $entity = get_entity_by_id_cache($vars['entity_type'], $vars['entity_id']);
|
|
||||||
// echo generate_entity_popup($entity, $vars);
|
|
||||||
} else {
|
} else {
|
||||||
print_warning("You are not permitted to view this entity.");
|
print_warning("You are not permitted to view this entity.");
|
||||||
}
|
}
|
||||||
|
95
html/ajax/geojson.php
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Observium
|
||||||
|
*
|
||||||
|
* This file is part of Observium.
|
||||||
|
*
|
||||||
|
* @package observium
|
||||||
|
* @subpackage web
|
||||||
|
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
ini_set('allow_url_fopen', 0); // Why here?
|
||||||
|
|
||||||
|
include_once("../../includes/observium.inc.php");
|
||||||
|
|
||||||
|
include($config['html_dir'] . "/includes/authenticate.inc.php");
|
||||||
|
include($config['html_dir'] . "/includes/cache-data.inc.php");
|
||||||
|
|
||||||
|
if (!$_SESSION['authenticated']) {
|
||||||
|
echo("unauthenticated");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$vars = get_vars('GET');
|
||||||
|
|
||||||
|
$geo = [];
|
||||||
|
|
||||||
|
foreach (dbFetchRows("SELECT * FROM `devices` LEFT JOIN `devices_locations` USING (`device_id`) " . generate_where_clause(generate_query_permitted_ng(['devices']))) as $device) {
|
||||||
|
|
||||||
|
if (!$config['web_show_disabled'] && $device["disabled"]) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$lat = (is_numeric($device['location_lat']) ? $device['location_lat'] : $config['geocoding']['default']['lat']);
|
||||||
|
$lon = (is_numeric($device['location_lon']) ? $device['location_lon'] : $config['geocoding']['default']['lon']);
|
||||||
|
if ($device["status"] == "0") {
|
||||||
|
if ($device["ignore"] == "0") {
|
||||||
|
$locations[$lat][$lon]["down_hosts"][] = $device;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$locations[$lat][$lon]["up_hosts"][] = $device;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($locations as $la => $lat) {
|
||||||
|
foreach ($lat as $lo => $lon) {
|
||||||
|
$tooltip = "";
|
||||||
|
$num_up = safe_count($lon["up_hosts"]);
|
||||||
|
$num_down = safe_count($lon["down_hosts"]);
|
||||||
|
$total_hosts = $num_up + $num_down;
|
||||||
|
$tooltip = '<p><span class="label label-success">Up ' . $num_up . '</span> <span class="label label-error">Down ' . $num_down . '</span></p>';
|
||||||
|
$state = 'unknown';
|
||||||
|
$location_name = "";
|
||||||
|
if ($num_down > 0) {
|
||||||
|
$state = 'down';
|
||||||
|
$location_name = ($lon['down_hosts'][0]['location'] === '' ? OBS_VAR_UNSET : $lon['down_hosts'][0]['location']);
|
||||||
|
$location_url = generate_location_url($lon['down_hosts'][0]['location']);
|
||||||
|
} elseif ($num_up > 0) {
|
||||||
|
$state = 'up';
|
||||||
|
$location_name = ($lon['up_hosts'][0]['location'] === '' ? OBS_VAR_UNSET : $lon['up_hosts'][0]['location']);
|
||||||
|
$location_url = generate_location_url($lon['up_hosts'][0]['location']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$tooltip = "<h3>" . $location_name . "</h3><hr />" . $tooltip;
|
||||||
|
foreach ($lon["down_hosts"] as $down_host) {
|
||||||
|
$tooltip .= '<span class="label label-error">' . escape_html($down_host['hostname']) . '</span> ';
|
||||||
|
}
|
||||||
|
|
||||||
|
$feature = ['geometry' => ['type' => 'Point',
|
||||||
|
'coordinates' => [(float)$lo, (float)$la]],
|
||||||
|
'type' => 'Feature',
|
||||||
|
'properties' => ['name' => $location_name,
|
||||||
|
'state' => $state,
|
||||||
|
'id' => safename($location_name),
|
||||||
|
//'popupContent' => $tooltip,
|
||||||
|
'url' => $location_url]];
|
||||||
|
$features[] = $feature;
|
||||||
|
|
||||||
|
//echo "[$la, $lo, $num_up, $num_down, \"$tooltip\", '$location_name', '$location_url'],\n ";
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$geo = ['type' => 'FeatureCollection', 'features' => $features];
|
||||||
|
|
||||||
|
header('Content-type: application/javascript');
|
||||||
|
//echo 'var geojson = ' . json_encode($geo) . ';';
|
||||||
|
|
||||||
|
//print_r($features);
|
||||||
|
|
||||||
|
echo safe_json_encode($geo);
|
||||||
|
|
||||||
|
//r($geo);
|
||||||
|
|
||||||
|
// EOF
|
@ -6,27 +6,29 @@
|
|||||||
*
|
*
|
||||||
* @package observium
|
* @package observium
|
||||||
* @subpackage ajax
|
* @subpackage ajax
|
||||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// FIXME, create api-internal for such
|
// FIXME, create api-internal for such
|
||||||
|
|
||||||
$config['install_dir'] = "../..";
|
include_once("../../includes/observium.inc.php");
|
||||||
|
|
||||||
include_once("../../includes/sql-config.inc.php");
|
|
||||||
|
|
||||||
include($config['html_dir'] . "/includes/functions.inc.php");
|
|
||||||
include($config['html_dir'] . "/includes/authenticate.inc.php");
|
include($config['html_dir'] . "/includes/authenticate.inc.php");
|
||||||
|
|
||||||
if (!$_SESSION['authenticated']) { echo('<li class="nav-header">Session expired, please log in again!</li>'); exit; }
|
if (!$_SESSION['authenticated']) {
|
||||||
|
echo('<li class="nav-header">Session expired, please log in again!</li>');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
$vars = get_vars('GET');
|
$vars = get_vars('GET');
|
||||||
$array_filter = in_array($vars['field'], [ 'syslog_program' ], TRUE); // modules with cached field
|
$array_filter = in_array($vars['field'], ['syslog_program'], TRUE); // modules with cached field
|
||||||
if (!safe_empty($vars['field']) && $vars['cache'] !== 'no' && ($array_filter || safe_empty($vars['query']))) {
|
if (!safe_empty($vars['field']) && $vars['cache'] !== 'no' && ($array_filter || safe_empty($vars['query']))) {
|
||||||
$cache_key = 'options_' . $vars['field'];
|
$cache_key = 'options_' . $vars['field'];
|
||||||
foreach ($vars as $param => $value) {
|
foreach ($vars as $param => $value) {
|
||||||
if (in_array($param, [ 'field', 'query', 'cache' ], TRUE)) { continue; }
|
if (in_array($param, ['field', 'query', 'cache'], TRUE)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$cache_key .= "_$param=$value";
|
$cache_key .= "_$param=$value";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -40,12 +42,12 @@ if ($cache_key && $options = get_cache_session($cache_key)) {
|
|||||||
//echo safe_json_encode(array('options' => $_SESSION['cache'][$cache_key]));
|
//echo safe_json_encode(array('options' => $_SESSION['cache'][$cache_key]));
|
||||||
//$options = $_SESSION['cache'][$cache_key];
|
//$options = $_SESSION['cache'][$cache_key];
|
||||||
} else {
|
} else {
|
||||||
$params = array();
|
$params = [];
|
||||||
//print_vars($vars);
|
//print_vars($vars);
|
||||||
switch ($vars['field']) {
|
switch ($vars['field']) {
|
||||||
case 'ipv4_network':
|
case 'ipv4_network':
|
||||||
case 'ipv6_network':
|
case 'ipv6_network':
|
||||||
list($ip_version) = explode('_', $vars['field']);
|
[$ip_version] = explode('_', $vars['field']);
|
||||||
$query_permitted = generate_query_permitted('ports');
|
$query_permitted = generate_query_permitted('ports');
|
||||||
$network_permitted = dbFetchColumn('SELECT DISTINCT(`' . $ip_version . '_network_id`) FROM `' . $ip_version . '_addresses` WHERE 1' . $query_permitted);
|
$network_permitted = dbFetchColumn('SELECT DISTINCT(`' . $ip_version . '_network_id`) FROM `' . $ip_version . '_addresses` WHERE 1' . $query_permitted);
|
||||||
$query = 'SELECT `' . $ip_version . '_network` FROM `' . $ip_version . '_networks` WHERE 1 ' . generate_query_values_and($network_permitted, $ip_version . '_network_id');
|
$query = 'SELECT `' . $ip_version . '_network` FROM `' . $ip_version . '_networks` WHERE 1 ' . generate_query_values_and($network_permitted, $ip_version . '_network_id');
|
||||||
@ -60,9 +62,9 @@ if ($cache_key && $options = get_cache_session($cache_key)) {
|
|||||||
|
|
||||||
case 'ifspeed':
|
case 'ifspeed':
|
||||||
$query_permitted = generate_query_permitted('ports');
|
$query_permitted = generate_query_permitted('ports');
|
||||||
$query = 'SELECT `ifSpeed`, COUNT(`ifSpeed`) as `count` FROM `ports` WHERE `ifSpeed` > 0 '. $query_permitted .' GROUP BY ifSpeed ORDER BY `count` DESC';
|
$query = 'SELECT `ifSpeed`, COUNT(`ifSpeed`) as `count` FROM `ports` WHERE `ifSpeed` > 0 ' . $query_permitted . ' GROUP BY ifSpeed ORDER BY `count` DESC';
|
||||||
$call_function = 'formatRates';
|
$call_function = 'formatRates';
|
||||||
$call_params = array(4, 4);
|
$call_params = [4, 4];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'syslog_program':
|
case 'syslog_program':
|
||||||
@ -78,10 +80,9 @@ if ($cache_key && $options = get_cache_session($cache_key)) {
|
|||||||
$column = 'bgpPeerRemoteAs';
|
$column = 'bgpPeerRemoteAs';
|
||||||
$query_permitted = generate_query_permitted('devices');
|
$query_permitted = generate_query_permitted('devices');
|
||||||
// Combine AS number and AS text into string: ASXXXX: My AS text
|
// Combine AS number and AS text into string: ASXXXX: My AS text
|
||||||
$query = 'SELECT DISTINCT CONCAT(?, CONCAT_WS(?, `'.$column.'`, `astext`)) AS `'.$vars['field'].'` FROM `bgpPeers` WHERE 1 ' . $query_permitted;
|
$query = 'SELECT DISTINCT CONCAT(?, CONCAT_WS(?, `' . $column . '`, `astext`)) AS `' . $vars['field'] . '` FROM `bgpPeers` WHERE 1 ' . $query_permitted;
|
||||||
$params[] = 'AS';
|
$params[] = 'AS';
|
||||||
$params[] = ': ';
|
$params[] = ': ';
|
||||||
//$query = 'SELECT DISTINCT `' . $column . '`, `astext` FROM `bgpPeers` WHERE 1 ' . $cache['where']['devices_permitted'] . ' ORDER BY `' . $column . '`';
|
|
||||||
if (!safe_empty($vars['query'])) {
|
if (!safe_empty($vars['query'])) {
|
||||||
$query .= ' AND (`' . $column . '` LIKE ? OR `astext` LIKE ?)';
|
$query .= ' AND (`' . $column . '` LIKE ? OR `astext` LIKE ?)';
|
||||||
$params[] = '%' . $vars['query'] . '%';
|
$params[] = '%' . $vars['query'] . '%';
|
||||||
@ -92,9 +93,8 @@ if ($cache_key && $options = get_cache_session($cache_key)) {
|
|||||||
|
|
||||||
case 'bgp_local_ip':
|
case 'bgp_local_ip':
|
||||||
case 'bgp_peer_ip':
|
case 'bgp_peer_ip':
|
||||||
$columns = array('local_ip' => 'bgpPeerLocalAddr',
|
$columns = ['local_ip' => 'bgpPeerLocalAddr',
|
||||||
'peer_ip' => 'bgpPeerRemoteAddr',
|
'peer_ip' => 'bgpPeerRemoteAddr'];
|
||||||
);
|
|
||||||
$param = str_replace('bgp_', '', $vars['field']);
|
$param = str_replace('bgp_', '', $vars['field']);
|
||||||
$column = $columns[$param];
|
$column = $columns[$param];
|
||||||
$query_permitted = generate_query_permitted('devices');
|
$query_permitted = generate_query_permitted('devices');
|
||||||
@ -112,9 +112,9 @@ if ($cache_key && $options = get_cache_session($cache_key)) {
|
|||||||
$options = dbFetchColumn($query, $params);
|
$options = dbFetchColumn($query, $params);
|
||||||
if (safe_count($options)) {
|
if (safe_count($options)) {
|
||||||
if (isset($call_function)) {
|
if (isset($call_function)) {
|
||||||
$call_options = array();
|
$call_options = [];
|
||||||
foreach ($options as $option) {
|
foreach ($options as $option) {
|
||||||
$call_options[] = call_user_func_array($call_function, array_merge(array($option), $call_params));
|
$call_options[] = call_user_func_array($call_function, array_merge([$option], $call_params));
|
||||||
}
|
}
|
||||||
$options = $call_options;
|
$options = $call_options;
|
||||||
}
|
}
|
||||||
@ -137,7 +137,7 @@ if (safe_count($options)) {
|
|||||||
if ($array_filter) {
|
if ($array_filter) {
|
||||||
$new_options = [];
|
$new_options = [];
|
||||||
foreach ($options as $option) {
|
foreach ($options as $option) {
|
||||||
if (stripos($option, $vars['query']) !== FALSE) {
|
if (str_contains_array($option, $vars['query'])) {
|
||||||
$new_options[] = $option;
|
$new_options[] = $option;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -145,7 +145,7 @@ if (safe_count($options)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
header("Content-type: application/json; charset=utf-8");
|
header("Content-type: application/json; charset=utf-8");
|
||||||
echo safe_json_encode(array( 'options' => $options ));
|
echo safe_json_encode(['options' => $options]);
|
||||||
} else {
|
} else {
|
||||||
json_output('error', 'Data fields are empty');
|
json_output('error', 'Data fields are empty');
|
||||||
}
|
}
|
||||||
|
@ -6,49 +6,42 @@
|
|||||||
*
|
*
|
||||||
* @package observium
|
* @package observium
|
||||||
* @subpackage web
|
* @subpackage web
|
||||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$config['install_dir'] = "../..";
|
include_once("../../includes/observium.inc.php");
|
||||||
|
|
||||||
include_once("../../includes/sql-config.inc.php");
|
|
||||||
|
|
||||||
include($config['html_dir'] . "/includes/functions.inc.php");
|
|
||||||
include($config['html_dir'] . "/includes/authenticate.inc.php");
|
include($config['html_dir'] . "/includes/authenticate.inc.php");
|
||||||
|
|
||||||
if (!$_SESSION['authenticated']) { echo('<li class="nav-header">Session expired, please log in again!</li>'); exit; }
|
if (!$_SESSION['authenticated']) {
|
||||||
|
echo('<li class="nav-header">Session expired, please log in again!</li>');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
include($config['html_dir'] . "/includes/cache-data.inc.php");
|
include($config['html_dir'] . "/includes/cache-data.inc.php");
|
||||||
|
|
||||||
$query_limit = 8; // Limit per query
|
$query_limit = 8; // Limit per query
|
||||||
|
|
||||||
$vars = get_vars([ 'POST', 'GET' ]);
|
$vars = get_vars(['POST', 'GET']);
|
||||||
|
|
||||||
// Is there a POST/GET query string?
|
// Is there a POST/GET query string?
|
||||||
if (isset($vars['queryString'])) {
|
if (isset($vars['queryString'])) {
|
||||||
$queryString = trim($vars['queryString']);
|
$queryString = trim($vars['queryString']);
|
||||||
|
|
||||||
// Is the string length greater than 0?
|
// Is the string length greater than 0?
|
||||||
if (strlen($queryString) > 0)
|
if (strlen($queryString) > 0) {
|
||||||
{
|
|
||||||
$query_param = "%$queryString%";
|
$query_param = "%$queryString%";
|
||||||
|
|
||||||
// Start out with a clean slate
|
// Start out with a clean slate
|
||||||
$search_results = array();
|
$search_results = [];
|
||||||
|
|
||||||
// Increase query_limit by one, so we can show "+" on result display if there are more than $query_limit entries
|
// Increase query_limit by one, so we can show "+" on result display if there are more than $query_limit entries
|
||||||
$query_limit++;
|
$query_limit++;
|
||||||
|
|
||||||
// Prepare user permission SQL query for use in search module queries
|
|
||||||
$query_permitted_device = $cache['where']['devices_permitted'];
|
|
||||||
$query_permitted_port = $cache['where']['ports_permitted'];
|
|
||||||
|
|
||||||
// Run search modules
|
// Run search modules
|
||||||
foreach ($config['wui']['search_modules'] as $module)
|
foreach ($config['wui']['search_modules'] as $module) {
|
||||||
{
|
if (is_file($config['html_dir'] . "/includes/search/$module.inc.php")) {
|
||||||
if (is_file($config['html_dir'] . "/includes/search/$module.inc.php"))
|
|
||||||
{
|
|
||||||
include($config['html_dir'] . "/includes/search/$module.inc.php");
|
include($config['html_dir'] . "/includes/search/$module.inc.php");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -56,33 +49,30 @@ if (isset($vars['queryString'])) {
|
|||||||
// Reset query_limit
|
// Reset query_limit
|
||||||
$query_limit--;
|
$query_limit--;
|
||||||
|
|
||||||
foreach ($search_results as $results)
|
foreach ($search_results as $results) {
|
||||||
{
|
|
||||||
$display_count = safe_count($results['results']);
|
$display_count = safe_count($results['results']);
|
||||||
|
|
||||||
// If there are more results than query_limit (can happen, as we ++'d above), cut array to desired size and add + to counter
|
// If there are more results than query_limit (can happen, as we ++'d above), cut array to desired size and add + to counter
|
||||||
if ($display_count > $query_limit)
|
if ($display_count > $query_limit) {
|
||||||
{
|
|
||||||
$results['results'] = array_slice($results['results'], 0, $query_limit);
|
$results['results'] = array_slice($results['results'], 0, $query_limit);
|
||||||
$display_count .= '+';
|
$display_count .= '+';
|
||||||
}
|
}
|
||||||
|
|
||||||
echo('<li class="nav-header">' . $results['descr'] . ': '. $display_count . '</li>' . PHP_EOL);
|
echo('<li class="nav-header">' . $results['descr'] . ': ' . $display_count . '</li>' . PHP_EOL);
|
||||||
|
|
||||||
foreach ($results['results'] as $result)
|
foreach ($results['results'] as $result) {
|
||||||
{
|
|
||||||
$data = [];
|
$data = [];
|
||||||
foreach ($result['data'] as $str) {
|
foreach ($result['data'] as $str) {
|
||||||
$str = str_replace('| |', '|', $str);
|
$str = str_replace('| |', '|', $str);
|
||||||
$data[] = rtrim($str, ' |');
|
$data[] = rtrim($str, ' |');
|
||||||
}
|
}
|
||||||
echo('<li class="divider" style="margin: 0px;"></li>' . PHP_EOL);
|
echo('<li class="divider" style="margin: 0px;"></li>' . PHP_EOL);
|
||||||
echo('<li style="margin: 0px;">' . PHP_EOL . ' <a href="'.$result['url'].'">' . PHP_EOL);
|
echo('<li style="margin: 0px;">' . PHP_EOL . ' <a href="' . $result['url'] . '">' . PHP_EOL);
|
||||||
echo(' <dl style="border-left: 10px solid '.$result['colour'].'; " class="dl-horizontal dl-search">' . PHP_EOL);
|
echo(' <dl style="border-left: 10px solid ' . $result['colour'] . '; " class="dl-horizontal dl-search">' . PHP_EOL);
|
||||||
echo(' <dt style="width: 64px; text-align: center; line-height: 41.5px;">' . get_icon($result['icon']) . '</dt>' . PHP_EOL);
|
echo(' <dt style="width: 64px; text-align: center; line-height: 41.5px;">' . get_icon($result['icon']) . '</dt>' . PHP_EOL);
|
||||||
echo(' <dd>' . PHP_EOL);
|
echo(' <dd>' . PHP_EOL);
|
||||||
echo(' <strong>'.html_highlight(escape_html($result['name']), $queryString) . PHP_EOL);
|
echo(' <strong>' . html_highlight(escape_html($result['name']), $queryString) . PHP_EOL);
|
||||||
echo(' <small>'. implode('<br />', $data) . '</small>' . PHP_EOL);
|
echo(' <small>' . implode('<br />', $data) . '</small>' . PHP_EOL);
|
||||||
echo(' </strong>' . PHP_EOL);
|
echo(' </strong>' . PHP_EOL);
|
||||||
echo(' </dd>' . PHP_EOL);
|
echo(' </dd>' . PHP_EOL);
|
||||||
echo('</dl>' . PHP_EOL);
|
echo('</dl>' . PHP_EOL);
|
||||||
@ -91,8 +81,7 @@ if (isset($vars['queryString'])) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!safe_count($search_results))
|
if (!safe_count($search_results)) {
|
||||||
{
|
|
||||||
echo('<li class="nav-header">No search results.</li>');
|
echo('<li class="nav-header">No search results.</li>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,33 +6,29 @@
|
|||||||
*
|
*
|
||||||
* @package observium
|
* @package observium
|
||||||
* @subpackage ajax
|
* @subpackage ajax
|
||||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$config['install_dir'] = "../..";
|
include_once("../../includes/observium.inc.php");
|
||||||
|
|
||||||
include_once("../../includes/sql-config.inc.php");
|
|
||||||
|
|
||||||
include($config['html_dir'] . "/includes/functions.inc.php");
|
|
||||||
include($config['html_dir'] . "/includes/authenticate.inc.php");
|
include($config['html_dir'] . "/includes/authenticate.inc.php");
|
||||||
|
|
||||||
if (!$_SESSION['authenticated'])
|
if (!$_SESSION['authenticated']) {
|
||||||
{
|
|
||||||
echo("unauthenticated");
|
echo("unauthenticated");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
include_dir($config['html_dir'] . "/includes/widgets/");
|
include_dir($config['html_dir'] . "/includes/widgets/");
|
||||||
|
|
||||||
$widget = dbFetchRow("SELECT * FROM `dash_widgets` WHERE widget_id = ?", array($_POST['id']));
|
$widget = dbFetchRow("SELECT * FROM `dash_widgets` WHERE widget_id = ?", [$_POST['id']]);
|
||||||
|
|
||||||
$widget['height'] = (is_numeric($_POST['height']) ? $_POST['height'] : '3');
|
$widget['height'] = (is_numeric($_POST['height']) ? $_POST['height'] : '3');
|
||||||
$widget['width'] = (is_numeric($_POST['width']) ? $_POST['width'] : '4');
|
$widget['width'] = (is_numeric($_POST['width']) ? $_POST['width'] : '4');
|
||||||
|
|
||||||
print_dash_mod($widget);
|
print_dash_mod($widget);
|
||||||
|
|
||||||
function print_dash_mod ($mod)
|
function print_dash_mod($mod)
|
||||||
{
|
{
|
||||||
|
|
||||||
global $config;
|
global $config;
|
||||||
@ -43,19 +39,17 @@ function print_dash_mod ($mod)
|
|||||||
$width = (is_numeric($mod['width']) ? $mod['width'] : 1240);
|
$width = (is_numeric($mod['width']) ? $mod['width'] : 1240);
|
||||||
$height = (is_numeric($mod['height']) ? $mod['height'] : 80);
|
$height = (is_numeric($mod['height']) ? $mod['height'] : 80);
|
||||||
|
|
||||||
switch ($mod['widget_type'])
|
switch ($mod['widget_type']) {
|
||||||
{
|
|
||||||
|
|
||||||
case "welcome":
|
case "welcome":
|
||||||
echo '<div class="box box-solid do-not-update" style="padding:10px; padding-left: 375px; background-image: url(images/login-hamster-large.png); background-position: left 10px top -100px; background-repeat: no-repeat;">';
|
echo '<div class="box box-solid do-not-update" style="padding:10px; padding-left: 375px; background-image: url(images/hamster-login.png); background-position: left 10px top -100px; background-repeat: no-repeat;">';
|
||||||
echo '<h3>Welcome to your new Observium dashboard!</h3>';
|
echo '<h3>Welcome to your new Observium dashboard!</h3>';
|
||||||
if(isset($mod['vars']['converted']))
|
if (isset($mod['vars']['converted'])) {
|
||||||
{
|
|
||||||
echo 'This was autogenerated based on your previous front page. It can be modified to suit your requirements.<br />';
|
echo 'This was autogenerated based on your previous front page. It can be modified to suit your requirements.<br />';
|
||||||
} else {
|
} else {
|
||||||
echo 'This is an autogenerated default dashboard. It can be modified to suit your requirements.<br />';
|
echo 'This is an autogenerated default dashboard. It can be modified to suit your requirements.<br />';
|
||||||
}
|
}
|
||||||
echo 'Please see the <strong><a href="'.OBSERVIUM_DOCS_URL.'/dashboard/" target="_blank">documentation</a></strong> for information about how to configure this dashboard. Including how to delete this widget!';
|
echo 'Please see the <strong><a href="' . OBSERVIUM_DOCS_URL . '/dashboard/" target="_blank">documentation</a></strong> for information about how to configure this dashboard. Including how to delete this widget!';
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -63,7 +57,7 @@ function print_dash_mod ($mod)
|
|||||||
|
|
||||||
echo '<div class="box box-solid do-not-update">';
|
echo '<div class="box box-solid do-not-update">';
|
||||||
|
|
||||||
$wmap = dbFetchRow("SELECT * FROM `weathermaps` WHERE `wmap_name` = ?", array($mod['vars']['mapname']));
|
$wmap = dbFetchRow("SELECT * FROM `weathermaps` WHERE `wmap_name` = ?", [$mod['vars']['mapname']]);
|
||||||
|
|
||||||
echo ' <div class="hover-hide widget-title" style="z-index: 900; position: absolute; overflow: hidden;" class="widget-title"><h4 style="wwriting-mode: vertical-lr; ttext-orientation: mixed;" class="box-title">' .
|
echo ' <div class="hover-hide widget-title" style="z-index: 900; position: absolute; overflow: hidden;" class="widget-title"><h4 style="wwriting-mode: vertical-lr; ttext-orientation: mixed;" class="box-title">' .
|
||||||
'' . htmlentities($wmap['wmap_name']) . '</h4>' .
|
'' . htmlentities($wmap['wmap_name']) . '</h4>' .
|
||||||
@ -71,8 +65,8 @@ function print_dash_mod ($mod)
|
|||||||
|
|
||||||
echo ' <div class="box-content" style="overflow: hidden">';
|
echo ' <div class="box-content" style="overflow: hidden">';
|
||||||
echo '<div style="height:100%; overflow:hidden; width: 110%;">';
|
echo '<div style="height:100%; overflow:hidden; width: 110%;">';
|
||||||
echo '<a href="'.generate_url(['page' => 'wmap', 'mapname' => $wmap['map_name']]).'">';
|
echo '<a href="' . generate_url(['page' => 'wmap', 'mapname' => $wmap['map_name']]) . '">';
|
||||||
echo '<img src="/weathermap.php?mapname=' . htmlentities($wmap['wmap_name']) . '&action=draw&unique=' . time() . '&width='.$width.'&height='.$height.'">';
|
echo '<img src="/weathermap.php?mapname=' . htmlentities($wmap['wmap_name']) . '&action=draw&unique=' . time() . '&width=' . $width . '&height=' . $height . '">';
|
||||||
echo '</a>';
|
echo '</a>';
|
||||||
|
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
@ -87,15 +81,8 @@ function print_dash_mod ($mod)
|
|||||||
echo '</div>';
|
echo '</div>';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "graph":
|
|
||||||
echo '<div class="box box-solid do-not-update">';
|
|
||||||
print_dash_graph($mod, $width, $height);
|
|
||||||
echo '</div>';
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "port_percent":
|
case "port_percent":
|
||||||
if($_SESSION['userlevel'] < 5)
|
if ($_SESSION['userlevel'] < 5) {
|
||||||
{
|
|
||||||
echo '<div class="box box-solid" style="width: 100%; height: 100%; float:none; display: block; padding: 10px;">';
|
echo '<div class="box box-solid" style="width: 100%; height: 100%; float:none; display: block; padding: 10px;">';
|
||||||
echo '<div class="alert statusbox alert-warning" style="border-left: 1px; width: 100%; height: 100%; margin-right: 10px; float:none; display: block;">';
|
echo '<div class="alert statusbox alert-warning" style="border-left: 1px; width: 100%; height: 100%; margin-right: 10px; float:none; display: block;">';
|
||||||
echo '<div style="margin: auto; line-height: 75px; text-align: center;">You have insufficient permissions to view this widget.</div>';
|
echo '<div style="margin: auto; line-height: 75px; text-align: center;">You have insufficient permissions to view this widget.</div>';
|
||||||
@ -113,10 +100,12 @@ function print_dash_mod ($mod)
|
|||||||
case "alert_table":
|
case "alert_table":
|
||||||
echo '<div class="box box-solid" style="overflow: hidden; height: auto; max-height: 100%">';
|
echo '<div class="box box-solid" style="overflow: hidden; height: auto; max-height: 100%">';
|
||||||
echo ' <div class="box-header" style="cursor: hand;"><h3 class="box-title">Alert Status</h3></div>';
|
echo ' <div class="box-header" style="cursor: hand;"><h3 class="box-title">Alert Status</h3></div>';
|
||||||
echo ' <div class="box-content" style="overflow:auto;">';
|
echo ' <div class="box-content" style="height: ' . ($height - 40) . 'px; overflow: auto;">';
|
||||||
print_alert_table(array('status' => 'failed',
|
//echo ' <div class="box-content" style="overflow: scroll; overflow-x:scroll;">';
|
||||||
|
//echo ' <div class="box-content" style="overflow:auto;">';
|
||||||
|
print_alert_table(['status' => 'failed',
|
||||||
'pagination' => FALSE,
|
'pagination' => FALSE,
|
||||||
'short' => TRUE)
|
'short' => TRUE]
|
||||||
);
|
);
|
||||||
echo ' </div>';
|
echo ' </div>';
|
||||||
echo ' </div>';
|
echo ' </div>';
|
||||||
@ -125,9 +114,15 @@ function print_dash_mod ($mod)
|
|||||||
|
|
||||||
case "status_summary":
|
case "status_summary":
|
||||||
echo '<div class="row">';
|
echo '<div class="row">';
|
||||||
if($width > 1000) { $div_class = "col-md-6"; } else { $div_class = "col-md-12"; }
|
if ($width > 1000) {
|
||||||
|
$div_class = "col-md-6";
|
||||||
|
} else {
|
||||||
|
$div_class = "col-md-12";
|
||||||
|
}
|
||||||
|
|
||||||
if($height < 210) { $hide_group_bar = 1; }
|
if ($height < 210) {
|
||||||
|
$hide_group_bar = 1;
|
||||||
|
}
|
||||||
|
|
||||||
include($config['html_dir'] . '/includes/cache-data.inc.php');
|
include($config['html_dir'] . '/includes/cache-data.inc.php');
|
||||||
include($config['html_dir'] . "/includes/status-summary.inc.php");
|
include($config['html_dir'] . "/includes/status-summary.inc.php");
|
||||||
@ -139,10 +134,9 @@ function print_dash_mod ($mod)
|
|||||||
//r($height);
|
//r($height);
|
||||||
include($config['html_dir'] . '/includes/cache-data.inc.php');
|
include($config['html_dir'] . '/includes/cache-data.inc.php');
|
||||||
//$count = round(($width) / 165) * round(($height+10) / 90); // 1.5 wide
|
//$count = round(($width) / 165) * round(($height+10) / 90); // 1.5 wide
|
||||||
$count = floor(($width+10) / 198) * floor(($height+10) / 96); // 1.5 wide
|
$count = floor(($width + 10) / 198) * floor(($height + 10) / 96); // 1.5 wide
|
||||||
echo '<div style="width: auto; height: 100%; overflow-x: visible; overflow-y: visible; margin-right: -25px;">';
|
echo '<div style="width: auto; height: 100%; overflow-x: visible; overflow-y: visible; margin-right: -25px;">';
|
||||||
if($mod['widget_type'] == 'alert_boxes')
|
if ($mod['widget_type'] == 'alert_boxes') {
|
||||||
{
|
|
||||||
print_status_boxes($mod, $count);
|
print_status_boxes($mod, $count);
|
||||||
} else {
|
} else {
|
||||||
print_status_boxes($config['frontpage']['device_status'], $count);
|
print_status_boxes($config['frontpage']['device_status'], $count);
|
||||||
@ -153,7 +147,7 @@ function print_dash_mod ($mod)
|
|||||||
case "old_status_table":
|
case "old_status_table":
|
||||||
echo '<div class="box box-solid" style="overflow: hidden; height: auto; max-height: 100%">';
|
echo '<div class="box box-solid" style="overflow: hidden; height: auto; max-height: 100%">';
|
||||||
echo ' <div class="box-header" style="cursor: hand;"><h3 class="box-title">Status Warnings and Notifications</h3></div>';
|
echo ' <div class="box-header" style="cursor: hand;"><h3 class="box-title">Status Warnings and Notifications</h3></div>';
|
||||||
echo ' <div class="box-content" style="height: ' . ($height - 40) .'px; overflow: auto;">';
|
echo ' <div class="box-content" style="height: ' . ($height - 40) . 'px; overflow: auto;">';
|
||||||
|
|
||||||
include($config['html_dir'] . '/includes/cache-data.inc.php');
|
include($config['html_dir'] . '/includes/cache-data.inc.php');
|
||||||
echo generate_status_table($config['frontpage']['device_status']);
|
echo generate_status_table($config['frontpage']['device_status']);
|
||||||
@ -170,9 +164,7 @@ function print_dash_mod ($mod)
|
|||||||
echo ' <div class="box-header" style="cursor: hand;"><h3 class="box-title"><a href="/syslog/">Syslog</a></h3></div>';
|
echo ' <div class="box-header" style="cursor: hand;"><h3 class="box-title"><a href="/syslog/">Syslog</a></h3></div>';
|
||||||
echo ' <div class="box-content" style="overflow: hidden; overflow-x:scroll;">';
|
echo ' <div class="box-content" style="overflow: hidden; overflow-x:scroll;">';
|
||||||
|
|
||||||
$syslog_vars = $mod['vars'];
|
$syslog_vars = array_merge($mod['vars'], ['short' => TRUE, 'pagesize' => ($height - 36) / 26,
|
||||||
|
|
||||||
$syslog_vars = array_merge($syslog_vars, ['short' => TRUE, 'pagesize' => ($height - 36) / 26,
|
|
||||||
'priority' => $config['frontpage']['syslog']['priority']]);
|
'priority' => $config['frontpage']['syslog']['priority']]);
|
||||||
|
|
||||||
print_syslogs($syslog_vars);
|
print_syslogs($syslog_vars);
|
||||||
@ -185,7 +177,11 @@ function print_dash_mod ($mod)
|
|||||||
echo ' <div class="box box-solid" style="overflow: hidden; height: auto; max-height: 100%">';
|
echo ' <div class="box box-solid" style="overflow: hidden; height: auto; max-height: 100%">';
|
||||||
echo ' <div class="box-header" style="cursor: hand;"><h3 class="box-title"><a href="/syslog_alerts/">Syslog Alerts</a></h3></div>';
|
echo ' <div class="box-header" style="cursor: hand;"><h3 class="box-title"><a href="/syslog_alerts/">Syslog Alerts</a></h3></div>';
|
||||||
echo ' <div class="box-content" style="overflow: hidden; overflow-x:scroll;">';
|
echo ' <div class="box-content" style="overflow: hidden; overflow-x:scroll;">';
|
||||||
print_logalert_log(array('short' => TRUE, 'pagesize' => ($height - 36) / 26) );
|
|
||||||
|
$alertlog_vars = array_merge($mod['vars'], ['short' => TRUE, 'pagesize' => ($height - 36) / 26]);
|
||||||
|
|
||||||
|
print_logalert_log($alertlog_vars);
|
||||||
|
|
||||||
echo ' </div>';
|
echo ' </div>';
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
break;
|
break;
|
||||||
@ -194,7 +190,10 @@ function print_dash_mod ($mod)
|
|||||||
echo ' <div class="box box-solid" style="overflow: hidden; height: auto; max-height: 100%">';
|
echo ' <div class="box box-solid" style="overflow: hidden; height: auto; max-height: 100%">';
|
||||||
echo ' <div class="box-header" style="cursor: hand;"><h3 class="box-title"><a href="/alert_log/">Alert Log</a></h3></div>';
|
echo ' <div class="box-header" style="cursor: hand;"><h3 class="box-title"><a href="/alert_log/">Alert Log</a></h3></div>';
|
||||||
echo ' <div class="box-content" style="overflow: hidden; overflow-x:scroll;">';
|
echo ' <div class="box-content" style="overflow: hidden; overflow-x:scroll;">';
|
||||||
print_alert_log_short(array('short' => TRUE, 'pagesize' => ($height - 36) / 26));
|
|
||||||
|
$alertlog_vars = array_merge($mod['vars'], ['short' => TRUE, 'pagesize' => ($height - 36) / 26]);
|
||||||
|
print_alert_log($alertlog_vars);
|
||||||
|
|
||||||
echo ' </div>';
|
echo ' </div>';
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
break;
|
break;
|
||||||
@ -207,8 +206,12 @@ function print_dash_mod ($mod)
|
|||||||
$pagesize = floor(($height - 36) / 26);
|
$pagesize = floor(($height - 36) / 26);
|
||||||
//if($width > 1000) { $pagesize -= 3; $short = FALSE; } else { $short = TRUE; }
|
//if($width > 1000) { $pagesize -= 3; $short = FALSE; } else { $short = TRUE; }
|
||||||
|
|
||||||
print_events(array('short' => TRUE, 'pagesize' => $pagesize, 'pageno' => 1,
|
|
||||||
'severity' => $config['frontpage']['eventlog']['severity']));
|
$eventlog_vars = array_merge($mod['vars'], ['short' => TRUE, 'pagesize' => $pagesize, 'pageno' => 1,
|
||||||
|
'severity' => $config['frontpage']['eventlog']['severity']]);
|
||||||
|
|
||||||
|
print_events($eventlog_vars);
|
||||||
|
|
||||||
echo ' </div>';
|
echo ' </div>';
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
break;
|
break;
|
||||||
@ -231,6 +234,12 @@ function print_dash_mod ($mod)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
||||||
|
$widget_path = $config['html_dir'] . '/includes/widgets/' . $mod['widget_type'] . '.inc.php';
|
||||||
|
|
||||||
|
if (is_file($widget_path)) {
|
||||||
|
include($widget_path);
|
||||||
|
} else {
|
||||||
echo '<div class="grid-stack-item-content box box-solid" style="overflow: hidden; justify-content: center; align-items: center;">';
|
echo '<div class="grid-stack-item-content box box-solid" style="overflow: hidden; justify-content: center; align-items: center;">';
|
||||||
echo ' <div class="box-content" style="overflow: hidden;">';
|
echo ' <div class="box-content" style="overflow: hidden;">';
|
||||||
echo ' <h3 class="box-title">Unconfigured Module</h3>';
|
echo ' <h3 class="box-title">Unconfigured Module</h3>';
|
||||||
@ -238,28 +247,29 @@ function print_dash_mod ($mod)
|
|||||||
echo '</div>';
|
echo '</div>';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//echo '</div>';
|
//echo '</div>';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function print_dash_map ($vars, $width, $height)
|
function print_dash_map($mod, $width, $height)
|
||||||
{
|
{
|
||||||
|
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
#map<?php echo $vars['widget_id']; ?> label {
|
#map<?php echo $mod['widget_id']; ?> label {
|
||||||
width: auto;
|
width: auto;
|
||||||
display: inline;
|
display: inline;
|
||||||
}
|
}
|
||||||
|
|
||||||
#map<?php echo $vars['widget_id']; ?> img {
|
#map<?php echo $mod['widget_id']; ?> img {
|
||||||
max-width: none;
|
max-width: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
#map<?php echo $vars['widget_id']; ?> {
|
#map<?php echo $mod['widget_id']; ?> {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
@ -267,183 +277,12 @@ function print_dash_map ($vars, $width, $height)
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
echo '<div id="map'.$vars['widget_id'].'"></div>';
|
echo '<div id="map' . $mod['widget_id'] . '"></div>';
|
||||||
|
|
||||||
include($config['html_dir']. '/includes/map/leaflet.inc.php');
|
$vars = $mod['vars']; // set the $vars array to be used mostly by geojson
|
||||||
|
|
||||||
|
include($config['html_dir'] . '/includes/map/leaflet.inc.php');
|
||||||
|
|
||||||
} // End show_map
|
} // End show_map
|
||||||
|
|
||||||
function print_dash_graph($mod, $width, $height) {
|
|
||||||
global $config;
|
|
||||||
|
|
||||||
$vars = $mod['vars'];
|
|
||||||
|
|
||||||
if (!isset($vars['type']))
|
|
||||||
{
|
|
||||||
|
|
||||||
echo '<div style="position: relative; top: 50%; transform: perspective(1px) translateY(-50%); width: 100%; text-align: center;">
|
|
||||||
<btn class="btn btn-primary" onclick="configWidget(' . $mod['widget_id'] . ')"><i class="icon-signal"/> Select Graph</btn>
|
|
||||||
</div>';
|
|
||||||
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($vars['timestamp_from']) && preg_match(OBS_PATTERN_TIMESTAMP, $vars['timestamp_from'])) {
|
|
||||||
$vars['from'] = strtotime($vars['timestamp_from']);
|
|
||||||
unset($vars['timestamp_from']);
|
|
||||||
}
|
|
||||||
if (isset($vars['timestamp_to']) && preg_match(OBS_PATTERN_TIMESTAMP, $vars['timestamp_to'])) {
|
|
||||||
$vars['to'] = strtotime($vars['timestamp_to']);
|
|
||||||
unset($vars['timestamp_to']);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Period alone is sufficient
|
|
||||||
|
|
||||||
/*
|
|
||||||
if (isset($vars['period']))
|
|
||||||
{
|
|
||||||
$vars['to'] = "now";
|
|
||||||
$vars['from'] = "-".$vars['period'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isset($vars['from']))
|
|
||||||
{
|
|
||||||
$vars['from'] = $config['time']['day'];
|
|
||||||
}
|
|
||||||
if (!isset($vars['to']))
|
|
||||||
{
|
|
||||||
$vars['to'] = $config['time']['now'];
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
preg_match('/^(?P<type>[a-z0-9A-Z-]+)_(?P<subtype>.+)/', $vars['type'], $graphtype);
|
|
||||||
|
|
||||||
if (OBS_DEBUG) {
|
|
||||||
print_vars($graphtype);
|
|
||||||
}
|
|
||||||
|
|
||||||
$type = $graphtype['type'];
|
|
||||||
$subtype = $graphtype['subtype'];
|
|
||||||
|
|
||||||
if (is_numeric($vars['device'])) {
|
|
||||||
$device = device_by_id_cache($vars['device']);
|
|
||||||
} elseif (!empty($vars['device'])) {
|
|
||||||
$device = device_by_name($vars['device']);
|
|
||||||
} elseif ($type === "device" && is_numeric($vars['id'])) {
|
|
||||||
$device = device_by_id_cache($vars['id']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$preserve_id = $vars['id'];
|
|
||||||
|
|
||||||
if (is_file($config['html_dir'] . "/includes/graphs/" . $type . "/auth.inc.php"))
|
|
||||||
{
|
|
||||||
include($config['html_dir'] . "/includes/graphs/" . $type . "/auth.inc.php");
|
|
||||||
}
|
|
||||||
|
|
||||||
$vars['id'] = $preserve_id;
|
|
||||||
|
|
||||||
if (!$auth) {
|
|
||||||
print_error_permission();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($config['entities'][$type])) {
|
|
||||||
$entity = get_entity_by_id_cache($type, $vars['id']);
|
|
||||||
entity_rewrite($type, $entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($type === 'bgp') {
|
|
||||||
$entity = get_entity_by_id_cache('bgp_peer', $vars['id']);
|
|
||||||
entity_rewrite('bgp_peer', $entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
//$device = device_by_id_cache($entity['device_id']);
|
|
||||||
|
|
||||||
//$graph_array['type'] = $vars['entity_type'] . '_' . $vars['graph_type'];
|
|
||||||
//$graph_array['id'] = $vars['entity_id'];
|
|
||||||
|
|
||||||
// Generate navbar with subtypes
|
|
||||||
$graph_array = $vars;
|
|
||||||
|
|
||||||
//$graph_array['from'] = '-1day';
|
|
||||||
//$graph_array['to'] = 'now';
|
|
||||||
|
|
||||||
$graph_array['width'] = $width - 76 + 14; // RRD graphs are 75px wider than request value
|
|
||||||
$graph_array['height'] = $height - 34; //68; // RRD graphs are taller than request value
|
|
||||||
|
|
||||||
if ($graph_array['width'] > 350)
|
|
||||||
{
|
|
||||||
$graph_array['width'] -= 6;
|
|
||||||
} // RRD graphs > 350px are 6 px wider because of larger legend font
|
|
||||||
if ($graph_array['width'] > 350)
|
|
||||||
{
|
|
||||||
$graph_array['height'] -= 6;
|
|
||||||
} // RRD graphs > 350px are 6 px taller because of larger legend font
|
|
||||||
|
|
||||||
$title_div = 'top:0px; left: 0px; padding: 4px; border-top-left-radius: 4px; border: 1px solid #e5e5e5; border-left: none; border-top: none; background-color: rgba(255, 255,255, 0.75); ';
|
|
||||||
$title_div = 'widget-title';
|
|
||||||
|
|
||||||
if ($height < 100)
|
|
||||||
{
|
|
||||||
$graph_array['height'] = $height;
|
|
||||||
$graph_array['width'] = $width;
|
|
||||||
$graph_array['graph_only'] = 'yes';
|
|
||||||
|
|
||||||
$title_div = 'top:5px; left: 5px; padding: none; border-radius: 2px; border: 1px solid #e5e5e5; background: rgba(255, 255, 255, 0.7);';
|
|
||||||
$title_div = 'widget-title-small';
|
|
||||||
|
|
||||||
} else {
|
|
||||||
$graph_array['draw_all'] = 'yes';
|
|
||||||
}
|
|
||||||
$t_len = $vars['width'] / 10;
|
|
||||||
|
|
||||||
$subtype_text = (isset($config['graph_types'][$type][$subtype]) ? $config['graph_types'][$type][$subtype]['descr'] : nicecase($subtype));
|
|
||||||
|
|
||||||
if (!isset($graph_array['title'])) {
|
|
||||||
if ($type === 'global')
|
|
||||||
{
|
|
||||||
$title = "Global :: " . $subtype_text;
|
|
||||||
} elseif (str_contains($type, "multi")) {
|
|
||||||
$count = safe_count($graph_array['id']);
|
|
||||||
$title = $count . ' ' . nicecase(str_replace("multi-", '', $type)) . ' :: ' . $subtype_text;
|
|
||||||
} else {
|
|
||||||
$title = device_name($device, $t_len / 2 - 2) . ($type === "device" ? ' :: ' : ' :: ' . truncate($entity['entity_shortname'], 32) . ' :: ' ) . $subtype_text;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$title = $graph_array['title'];
|
|
||||||
unset($graph_array['title']);
|
|
||||||
}
|
|
||||||
|
|
||||||
//$graph_array['format'] = 'png';
|
|
||||||
|
|
||||||
//$graph_array['img_id'] = generate_random_string(5);
|
|
||||||
//$graph_array['legend'] = 'no';
|
|
||||||
|
|
||||||
$graph_array['rigid_height'] = 'yes'; // Force height of graph to be same as height of graph_type.
|
|
||||||
|
|
||||||
$graph_array['class'] = 'image-refresh';
|
|
||||||
|
|
||||||
$graph = generate_graph_tag($graph_array, TRUE);
|
|
||||||
|
|
||||||
$link_array = $graph_array;
|
|
||||||
$link_array['page'] = "graphs";
|
|
||||||
unset($link_array['graph_only']);
|
|
||||||
unset($link_array['rigid_height']);
|
|
||||||
unset($link_array['height'], $link_array['width']);
|
|
||||||
$link = generate_url($link_array);
|
|
||||||
|
|
||||||
//echo ' <div class="box-header with-border">' . $device['hostname'] . '<span class="pull-right">' . truncate($entity['entity_name'], 32) . '</span></div>';
|
|
||||||
|
|
||||||
echo ' <div class="hover-hide ' . $title_div . '" style="z-index: 900; position: absolute; overflow: hidden;" class="widget-title"><h4 style="wwriting-mode: vertical-lr; ttext-orientation: mixed;" class="box-title">' .
|
|
||||||
'' . escape_html($title) . '</h4>' .
|
|
||||||
'</div>' . PHP_EOL;
|
|
||||||
|
|
||||||
echo ' <div class="box-content" style="overflow: hidden">';
|
|
||||||
echo '<div style="height:100%; overflow:hidden; width: 110%;">';
|
|
||||||
echo '<a href="'.$link.'">'.$graph['img_tag'].'</a>';
|
|
||||||
echo '</div>';
|
|
||||||
echo ' </div>';
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// EOF
|
// EOF
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
Options FollowSymlinks Multiviews
|
Options FollowSymlinks Multiviews
|
||||||
|
|
||||||
|
ErrorDocument 404 /error.php?404
|
||||||
RedirectMatch 404 /\.
|
RedirectMatch 404 /\.
|
||||||
|
|
||||||
RewriteEngine on
|
RewriteEngine on
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Observium
|
* Observium
|
||||||
*
|
*
|
||||||
@ -8,18 +7,27 @@
|
|||||||
* @package observium
|
* @package observium
|
||||||
* @subpackage webinterface
|
* @subpackage webinterface
|
||||||
* @author Adam Armstrong <adama@observium.org>
|
* @author Adam Armstrong <adama@observium.org>
|
||||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ini_set('allow_url_fopen', 0);
|
ini_set('allow_url_fopen', 0);
|
||||||
|
|
||||||
include_once("../includes/sql-config.inc.php");
|
include_once("../includes/observium.inc.php");
|
||||||
|
|
||||||
|
if (!$config['web_iframe'] && is_iframe()) {
|
||||||
|
print_error_permission("Not allowed to run in a iframe!");
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
include($config['html_dir'] . "/includes/functions.inc.php");
|
|
||||||
include($config['html_dir'] . "/includes/authenticate.inc.php");
|
include($config['html_dir'] . "/includes/authenticate.inc.php");
|
||||||
|
|
||||||
if ($_SERVER['REMOTE_ADDR'] != $_SERVER['SERVER_ADDR']) { if (!$_SESSION['authenticated']) { echo("unauthenticated"); exit; } }
|
if ($_SERVER['REMOTE_ADDR'] != $_SERVER['SERVER_ADDR']) {
|
||||||
|
if (!$_SESSION['authenticated']) {
|
||||||
|
// not authenticated
|
||||||
|
die("Unauthenticated");
|
||||||
|
}
|
||||||
|
}
|
||||||
require_once($config['html_dir'] . "/includes/jpgraph/src/jpgraph.php");
|
require_once($config['html_dir'] . "/includes/jpgraph/src/jpgraph.php");
|
||||||
require_once($config['html_dir'] . "/includes/jpgraph/src/jpgraph_line.php");
|
require_once($config['html_dir'] . "/includes/jpgraph/src/jpgraph_line.php");
|
||||||
require_once($config['html_dir'] . "/includes/jpgraph/src/jpgraph_bar.php");
|
require_once($config['html_dir'] . "/includes/jpgraph/src/jpgraph_bar.php");
|
||||||
@ -28,12 +36,9 @@ require_once($config['html_dir'] . "/includes/jpgraph/src/jpgraph_date.php");
|
|||||||
|
|
||||||
$vars = get_vars('GET');
|
$vars = get_vars('GET');
|
||||||
|
|
||||||
if (is_numeric($vars['bill_id']))
|
if (is_numeric($vars['bill_id'])) {
|
||||||
{
|
if ($_SERVER['REMOTE_ADDR'] != $_SERVER['SERVER_ADDR']) {
|
||||||
if ($_SERVER['REMOTE_ADDR'] != $_SERVER['SERVER_ADDR'])
|
if (bill_permitted($vars['bill_id'])) {
|
||||||
{
|
|
||||||
if (bill_permitted($vars['bill_id']))
|
|
||||||
{
|
|
||||||
$bill_id = $vars['bill_id'];
|
$bill_id = $vars['bill_id'];
|
||||||
} else {
|
} else {
|
||||||
echo("Unauthorised Access Prohibited.");
|
echo("Unauthorised Access Prohibited.");
|
||||||
@ -48,48 +53,46 @@ if (is_numeric($vars['bill_id']))
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Workaround for JPGraph 3.5 on Ubuntu per 0015246
|
// Workaround for JPGraph 3.5 on Ubuntu per 0015246
|
||||||
if( !function_exists('imageantialias') ) {
|
if (!function_exists('imageantialias')) {
|
||||||
function imageantialias( $image, $enabled ) {
|
function imageantialias($image, $enabled)
|
||||||
return false;
|
{
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$start = $vars['from'];
|
$start = $vars['from'];
|
||||||
$end = $vars['to'];
|
$end = $vars['to'];
|
||||||
$xsize = (is_numeric($vars['x']) ? $vars['x'] : "800" );
|
$xsize = (is_numeric($vars['x']) ? $vars['x'] : "800");
|
||||||
$ysize = (is_numeric($vars['y']) ? $vars['y'] : "250" );
|
$ysize = (is_numeric($vars['y']) ? $vars['y'] : "250");
|
||||||
//$count = (is_numeric($_GET['count']) ? $_GET['count'] : "0" );
|
//$count = (is_numeric($_GET['count']) ? $_GET['count'] : "0" );
|
||||||
//$type = (isset($_GET['type']) ? $_GET['type'] : "date" );
|
//$type = (isset($_GET['type']) ? $_GET['type'] : "date" );
|
||||||
//$dur = $end - $start;
|
//$dur = $end - $start;
|
||||||
//$datefrom = date('Ymthis', $start);
|
//$datefrom = date('Ymthis', $start);
|
||||||
//$dateto = date('Ymthis', $end);
|
//$dateto = date('Ymthis', $end);
|
||||||
$imgtype = (isset($vars['type']) ? $vars['type'] : "historical" );
|
$imgtype = (isset($vars['type']) ? $vars['type'] : "historical");
|
||||||
$imgbill = (isset($vars['imgbill']) ? $vars['imgbill'] : false);
|
$imgbill = (isset($vars['imgbill']) ? $vars['imgbill'] : FALSE);
|
||||||
$yaxistitle = "Bytes";
|
$yaxistitle = "Bytes";
|
||||||
|
|
||||||
$in_data = array();
|
$in_data = [];
|
||||||
$out_data = array();
|
$out_data = [];
|
||||||
$tot_data = array();
|
$tot_data = [];
|
||||||
$allow_data = array();
|
$allow_data = [];
|
||||||
$ave_data = array();
|
$ave_data = [];
|
||||||
$overuse_data = array();
|
$overuse_data = [];
|
||||||
$ticklabels = array();
|
$ticklabels = [];
|
||||||
|
|
||||||
if ($imgtype == "historical")
|
if ($imgtype == "historical") {
|
||||||
{
|
|
||||||
$i = "0";
|
$i = "0";
|
||||||
|
|
||||||
foreach (dbFetchRows("SELECT * FROM `bill_history` WHERE `bill_id` = ? ORDER BY `bill_datefrom` DESC LIMIT 12", array($bill_id)) as $data)
|
foreach (dbFetchRows("SELECT * FROM `bill_history` WHERE `bill_id` = ? ORDER BY `bill_datefrom` DESC LIMIT 12", [$bill_id]) as $data) {
|
||||||
{
|
|
||||||
$datefrom = strftime("%e %b %Y", strtotime($data['bill_datefrom']));
|
$datefrom = strftime("%e %b %Y", strtotime($data['bill_datefrom']));
|
||||||
$dateto = strftime("%e %b %Y", strtotime($data['bill_dateto']));
|
$dateto = strftime("%e %b %Y", strtotime($data['bill_dateto']));
|
||||||
$datelabel = $datefrom."\n".$dateto;
|
$datelabel = $datefrom . "\n" . $dateto;
|
||||||
$traf['in'] = $data['traf_in'];
|
$traf['in'] = $data['traf_in'];
|
||||||
$traf['out'] = $data['traf_out'];
|
$traf['out'] = $data['traf_out'];
|
||||||
$traf['total'] = $data['traf_total'];
|
$traf['total'] = $data['traf_total'];
|
||||||
|
|
||||||
if ($data['bill_type'] == "Quota")
|
if ($data['bill_type'] == "Quota") {
|
||||||
{
|
|
||||||
$traf['allowed'] = $data['bill_allowed'];
|
$traf['allowed'] = $data['bill_allowed'];
|
||||||
$traf['overuse'] = $data['bill_overuse'];
|
$traf['overuse'] = $data['bill_overuse'];
|
||||||
} else {
|
} else {
|
||||||
@ -107,12 +110,10 @@ if ($imgtype == "historical")
|
|||||||
//print_vars($data);
|
//print_vars($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($i < 12)
|
if ($i < 12) {
|
||||||
{
|
|
||||||
$y = 12 - $i;
|
$y = 12 - $i;
|
||||||
for ($x=0;$x<$y;$x++)
|
for ($x = 0; $x < $y; $x++) {
|
||||||
{
|
$allowed = (($x == "0") ? $traf['allowed'] : "0");
|
||||||
$allowed = (($x == "0") ? $traf['allowed'] : "0" );
|
|
||||||
array_push($in_data, "0");
|
array_push($in_data, "0");
|
||||||
array_push($out_data, "0");
|
array_push($out_data, "0");
|
||||||
array_push($tot_data, "0");
|
array_push($tot_data, "0");
|
||||||
@ -124,12 +125,10 @@ if ($imgtype == "historical")
|
|||||||
$yaxistitle = "Gigabytes";
|
$yaxistitle = "Gigabytes";
|
||||||
$graph_name = "Historical bandwidth over the last 12 billing periods";
|
$graph_name = "Historical bandwidth over the last 12 billing periods";
|
||||||
} else {
|
} else {
|
||||||
$data = array();
|
$data = [];
|
||||||
$average = 0;
|
$average = 0;
|
||||||
if ($imgtype == "day")
|
if ($imgtype == "day") {
|
||||||
{
|
foreach (dbFetch("SELECT DISTINCT UNIX_TIMESTAMP(timestamp) as timestamp, SUM(delta) as traf_total, SUM(in_delta) as traf_in, SUM(out_delta) as traf_out FROM bill_data WHERE `bill_id` = ? AND `timestamp` >= FROM_UNIXTIME(?) AND `timestamp` <= FROM_UNIXTIME(?) GROUP BY DATE(timestamp) ORDER BY timestamp ASC", [$bill_id, $start, $end]) as $data) {
|
||||||
foreach (dbFetch("SELECT DISTINCT UNIX_TIMESTAMP(timestamp) as timestamp, SUM(delta) as traf_total, SUM(in_delta) as traf_in, SUM(out_delta) as traf_out FROM bill_data WHERE `bill_id` = ? AND `timestamp` >= FROM_UNIXTIME(?) AND `timestamp` <= FROM_UNIXTIME(?) GROUP BY DATE(timestamp) ORDER BY timestamp ASC", array($bill_id, $start, $end)) as $data)
|
|
||||||
{
|
|
||||||
$traf['in'] = (isset($data['traf_in']) ? $data['traf_in'] : 0);
|
$traf['in'] = (isset($data['traf_in']) ? $data['traf_in'] : 0);
|
||||||
$traf['out'] = (isset($data['traf_out']) ? $data['traf_out'] : 0);
|
$traf['out'] = (isset($data['traf_out']) ? $data['traf_out'] : 0);
|
||||||
$traf['total'] = (isset($data['traf_total']) ? $data['traf_total'] : 0);
|
$traf['total'] = (isset($data['traf_total']) ? $data['traf_total'] : 0);
|
||||||
@ -141,21 +140,17 @@ if ($imgtype == "historical")
|
|||||||
$average += $data['traf_total'];
|
$average += $data['traf_total'];
|
||||||
}
|
}
|
||||||
$ave_count = count($tot_data);
|
$ave_count = count($tot_data);
|
||||||
if ($imgbill != false)
|
if ($imgbill != FALSE) {
|
||||||
{
|
|
||||||
$days = strftime("%e", date($end - $start)) - $ave_count - 1;
|
$days = strftime("%e", date($end - $start)) - $ave_count - 1;
|
||||||
for ($x=0;$x<$days;$x++)
|
for ($x = 0; $x < $days; $x++) {
|
||||||
{
|
|
||||||
array_push($ticklabels, "");
|
array_push($ticklabels, "");
|
||||||
array_push($in_data, 0);
|
array_push($in_data, 0);
|
||||||
array_push($out_data, 0);
|
array_push($out_data, 0);
|
||||||
array_push($tot_data, 0);
|
array_push($tot_data, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif ($imgtype == "hour")
|
} elseif ($imgtype == "hour") {
|
||||||
{
|
foreach (dbFetch("SELECT DISTINCT UNIX_TIMESTAMP(timestamp) as timestamp, SUM(delta) as traf_total, SUM(in_delta) as traf_in, SUM(out_delta) as traf_out FROM bill_data WHERE `bill_id` = ? AND `timestamp` >= FROM_UNIXTIME(?) AND `timestamp` <= FROM_UNIXTIME(?) GROUP BY HOUR(timestamp) ORDER BY timestamp ASC", [$bill_id, $start, $end]) as $data) {
|
||||||
foreach (dbFetch("SELECT DISTINCT UNIX_TIMESTAMP(timestamp) as timestamp, SUM(delta) as traf_total, SUM(in_delta) as traf_in, SUM(out_delta) as traf_out FROM bill_data WHERE `bill_id` = ? AND `timestamp` >= FROM_UNIXTIME(?) AND `timestamp` <= FROM_UNIXTIME(?) GROUP BY HOUR(timestamp) ORDER BY timestamp ASC", array($bill_id, $start, $end)) as $data)
|
|
||||||
{
|
|
||||||
$traf['in'] = (isset($data['traf_in']) ? $data['traf_in'] : 0);
|
$traf['in'] = (isset($data['traf_in']) ? $data['traf_in'] : 0);
|
||||||
$traf['out'] = (isset($data['traf_out']) ? $data['traf_out'] : 0);
|
$traf['out'] = (isset($data['traf_out']) ? $data['traf_out'] : 0);
|
||||||
$traf['total'] = (isset($data['traf_total']) ? $data['traf_total'] : 0);
|
$traf['total'] = (isset($data['traf_total']) ? $data['traf_total'] : 0);
|
||||||
@ -171,91 +166,89 @@ if ($imgtype == "historical")
|
|||||||
|
|
||||||
$decimal = 0;
|
$decimal = 0;
|
||||||
$average = $average / $ave_count;
|
$average = $average / $ave_count;
|
||||||
for ($x = 0; $x <= count($tot_data); $x++)
|
for ($x = 0; $x <= count($tot_data); $x++) {
|
||||||
{
|
|
||||||
array_push($ave_data, $average);
|
array_push($ave_data, $average);
|
||||||
}
|
}
|
||||||
$graph_name = date('M j g:ia', $start)." - ".date('M j g:ia', $end);
|
$graph_name = date('M j g:ia', $start) . " - " . date('M j g:ia', $end);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the graph. These two calls are always required
|
// Create the graph. These two calls are always required
|
||||||
$graph = new Graph($xsize, $ysize, $graph_name);
|
$graph = new Graph($xsize, $ysize, $graph_name);
|
||||||
$graph->img->SetImgFormat("png");
|
$graph -> img -> SetImgFormat("png");
|
||||||
|
|
||||||
#$graph->SetScale("textlin",0,0,$start,$end);
|
#$graph->SetScale("textlin",0,0,$start,$end);
|
||||||
|
|
||||||
$graph->SetScale("textlin");
|
$graph -> SetScale("textlin");
|
||||||
#$graph->title->Set("$graph_name");
|
#$graph->title->Set("$graph_name");
|
||||||
$graph->title->SetFont(FF_FONT2, FS_BOLD, 10);
|
$graph -> title -> SetFont(FF_FONT2, FS_BOLD, 10);
|
||||||
$graph->SetMarginColor("white");
|
$graph -> SetMarginColor("white");
|
||||||
$graph->SetFrame(false);
|
$graph -> SetFrame(FALSE);
|
||||||
$graph->SetMargin("75", "30", "30", "65");
|
$graph -> SetMargin("75", "30", "30", "65");
|
||||||
$graph->legend->SetFont(FF_FONT1, FS_NORMAL);
|
$graph -> legend -> SetFont(FF_FONT1, FS_NORMAL);
|
||||||
$graph->legend->SetLayout(LEGEND_HOR);
|
$graph -> legend -> SetLayout(LEGEND_HOR);
|
||||||
$graph->legend->Pos("0.52", "0.91", "center");
|
$graph -> legend -> Pos("0.52", "0.91", "center");
|
||||||
|
|
||||||
$graph->xaxis->SetFont(FF_FONT1, FS_BOLD);
|
$graph -> xaxis -> SetFont(FF_FONT1, FS_BOLD);
|
||||||
$graph->xaxis->SetPos('min');
|
$graph -> xaxis -> SetPos('min');
|
||||||
$graph->xaxis->SetTitleMargin(30);
|
$graph -> xaxis -> SetTitleMargin(30);
|
||||||
$graph->xaxis->SetTickLabels($ticklabels);
|
$graph -> xaxis -> SetTickLabels($ticklabels);
|
||||||
$graph->xgrid->Show(true,true);
|
$graph -> xgrid -> Show(TRUE, TRUE);
|
||||||
$graph->xgrid->SetColor('#e0e0e0','#efefef');
|
$graph -> xgrid -> SetColor('#e0e0e0', '#efefef');
|
||||||
|
|
||||||
$graph->yaxis->SetFont(FF_FONT1);
|
$graph -> yaxis -> SetFont(FF_FONT1);
|
||||||
$graph->yaxis->SetTitleMargin(50);
|
$graph -> yaxis -> SetTitleMargin(50);
|
||||||
$graph->yaxis->title->SetFont(FF_FONT1, FS_NORMAL, 10);
|
$graph -> yaxis -> title -> SetFont(FF_FONT1, FS_NORMAL, 10);
|
||||||
$graph->yaxis->title->Set("Bytes Transferred");
|
$graph -> yaxis -> title -> Set("Bytes Transferred");
|
||||||
$graph->yaxis->SetLabelFormatCallback('format_bytes_billing');
|
$graph -> yaxis -> SetLabelFormatCallback('format_bytes_billing');
|
||||||
$graph->ygrid->SetFill(true,'#EFEFEF@0.5','#FFFFFF@0.5');
|
$graph -> ygrid -> SetFill(TRUE, '#EFEFEF@0.5', '#FFFFFF@0.5');
|
||||||
|
|
||||||
// Create the bar plots
|
// Create the bar plots
|
||||||
$barplot_tot = new BarPlot($tot_data);
|
$barplot_tot = new BarPlot($tot_data);
|
||||||
$barplot_tot->SetLegend("Traffic total");
|
$barplot_tot -> SetLegend("Traffic total");
|
||||||
$barplot_tot->SetColor('darkgray');
|
$barplot_tot -> SetColor('darkgray');
|
||||||
$barplot_tot->SetFillColor('lightgray@0.4');
|
$barplot_tot -> SetFillColor('lightgray@0.4');
|
||||||
$barplot_tot->value->Show();
|
$barplot_tot -> value -> Show();
|
||||||
$barplot_tot->value->SetFormatCallback('format_bytes_billing_short');
|
$barplot_tot -> value -> SetFormatCallback('format_bytes_billing_short');
|
||||||
|
|
||||||
$barplot_in = new BarPlot($in_data);
|
$barplot_in = new BarPlot($in_data);
|
||||||
$barplot_in->SetLegend("Traffic In");
|
$barplot_in -> SetLegend("Traffic In");
|
||||||
$barplot_in->SetColor('#'.$config['graph_colours']['greens'][1]);
|
$barplot_in -> SetColor('#' . $config['graph_colours']['greens'][1]);
|
||||||
$barplot_in->SetFillColor('#'.$config['graph_colours']['greens'][0]);
|
$barplot_in -> SetFillColor('#' . $config['graph_colours']['greens'][0]);
|
||||||
$barplot_in->SetWeight(1);
|
$barplot_in -> SetWeight(1);
|
||||||
|
|
||||||
$barplot_out = new BarPlot($out_data);
|
$barplot_out = new BarPlot($out_data);
|
||||||
$barplot_out->SetLegend("Traffic Out");
|
$barplot_out -> SetLegend("Traffic Out");
|
||||||
$barplot_out->SetColor('#'.$config['graph_colours']['blues'][0]);
|
$barplot_out -> SetColor('#' . $config['graph_colours']['blues'][0]);
|
||||||
$barplot_out->SetFillColor('#'.$config['graph_colours']['blues'][1]);
|
$barplot_out -> SetFillColor('#' . $config['graph_colours']['blues'][1]);
|
||||||
$barplot_out->SetWeight(1);
|
$barplot_out -> SetWeight(1);
|
||||||
|
|
||||||
if ($imgtype == "historical")
|
if ($imgtype == "historical") {
|
||||||
{
|
|
||||||
$barplot_over = new BarPlot($overuse_data);
|
$barplot_over = new BarPlot($overuse_data);
|
||||||
$barplot_over->SetLegend("Traffic Overusage");
|
$barplot_over -> SetLegend("Traffic Overusage");
|
||||||
$barplot_over->SetColor('darkred');
|
$barplot_over -> SetColor('darkred');
|
||||||
$barplot_over->SetFillColor('lightred@0.4');
|
$barplot_over -> SetFillColor('lightred@0.4');
|
||||||
$barplot_over->SetWeight(1);
|
$barplot_over -> SetWeight(1);
|
||||||
|
|
||||||
$lineplot_allow = new LinePlot($allow_data);
|
$lineplot_allow = new LinePlot($allow_data);
|
||||||
$lineplot_allow->SetLegend("Traffic Allowed");
|
$lineplot_allow -> SetLegend("Traffic Allowed");
|
||||||
$lineplot_allow->SetColor('black');
|
$lineplot_allow -> SetColor('black');
|
||||||
$lineplot_allow->SetWeight(1);
|
$lineplot_allow -> SetWeight(1);
|
||||||
|
|
||||||
$gbplot = new GroupBarPlot(array($barplot_in, $barplot_tot, $barplot_out, $barplot_over));
|
$gbplot = new GroupBarPlot([$barplot_in, $barplot_tot, $barplot_out, $barplot_over]);
|
||||||
} else {
|
} else {
|
||||||
$lineplot_allow = new LinePlot($ave_data);
|
$lineplot_allow = new LinePlot($ave_data);
|
||||||
//$lineplot_allow->SetLegend("Average per ".$imgtype);
|
//$lineplot_allow->SetLegend("Average per ".$imgtype);
|
||||||
$lineplot_allow->SetLegend("Average");
|
$lineplot_allow -> SetLegend("Average");
|
||||||
$lineplot_allow->SetColor('black');
|
$lineplot_allow -> SetColor('black');
|
||||||
$lineplot_allow->SetWeight(1);
|
$lineplot_allow -> SetWeight(1);
|
||||||
|
|
||||||
$gbplot = new GroupBarPlot(array($barplot_in, $barplot_tot, $barplot_out));
|
$gbplot = new GroupBarPlot([$barplot_in, $barplot_tot, $barplot_out]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$graph->Add($gbplot);
|
$graph -> Add($gbplot);
|
||||||
$graph->Add($lineplot_allow);
|
$graph -> Add($lineplot_allow);
|
||||||
|
|
||||||
// Display the graph
|
// Display the graph
|
||||||
$graph->Stroke();
|
$graph -> Stroke();
|
||||||
|
|
||||||
// EOF
|
// EOF
|
||||||
|
2
html/css/easymde.min.css
vendored
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* easymde v2.17.0
|
* easymde v2.18.0
|
||||||
* Copyright Jeroen Akkerman
|
* Copyright Jeroen Akkerman
|
||||||
* @link https://github.com/ionaru/easy-markdown-editor
|
* @link https://github.com/ionaru/easy-markdown-editor
|
||||||
* @license MIT
|
* @license MIT
|
||||||
|
@ -6025,6 +6025,8 @@ a .icon-flip-vertical:before {
|
|||||||
-webkit-background-clip: padding-box;
|
-webkit-background-clip: padding-box;
|
||||||
-moz-background-clip: padding;
|
-moz-background-clip: padding;
|
||||||
background-clip: padding-box;
|
background-clip: padding-box;
|
||||||
|
/*scrollbar-width: thin;
|
||||||
|
scrollbar-color: rgba(128, 128, 128, 0.2) @brand-border;*/
|
||||||
}
|
}
|
||||||
.dropdown-menu.pull-right {
|
.dropdown-menu.pull-right {
|
||||||
right: 0;
|
right: 0;
|
||||||
@ -6045,16 +6047,22 @@ a .icon-flip-vertical:before {
|
|||||||
color: #333333;
|
color: #333333;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
.dropdown-menu ::-webkit-scrollbar {
|
.dropdown-menu::-webkit-scrollbar-track {
|
||||||
|
background-color: #f9f9f9;
|
||||||
|
}
|
||||||
|
.dropdown-menu::-webkit-scrollbar-corner {
|
||||||
|
background-color: #f9f9f9;
|
||||||
|
}
|
||||||
|
.dropdown-menu::-webkit-scrollbar {
|
||||||
width: 10px;
|
width: 10px;
|
||||||
|
height: 10px;
|
||||||
|
/* background-color: @box-header-bg; */
|
||||||
}
|
}
|
||||||
.dropdown-menu ::-webkit-scrollbar-track {
|
.dropdown-menu::-webkit-scrollbar-thumb {
|
||||||
-webkit-box-shadow: inset 0 0 65px rgba(0, 0, 0, 0.3);
|
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
}
|
background-color: #dddddd;
|
||||||
.dropdown-menu ::-webkit-scrollbar-thumb {
|
border: 2px solid #f9f9f9;
|
||||||
border-radius: 2px;
|
/*border: 2px solid @box-header-bg;*/
|
||||||
-webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.6);
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
.navbar-narrow .dropdown-menu {
|
.navbar-narrow .dropdown-menu {
|
||||||
@ -6831,10 +6839,7 @@ i.menu-icon,
|
|||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
}
|
}
|
||||||
.box-body {
|
.box-body {
|
||||||
border-top-left-radius: 0;
|
border-radius: 0 0 3px 3px;
|
||||||
border-top-right-radius: 0;
|
|
||||||
border-bottom-right-radius: 3px;
|
|
||||||
border-bottom-left-radius: 3px;
|
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
.no-header .box-body {
|
.no-header .box-body {
|
||||||
@ -6858,22 +6863,13 @@ i.menu-icon,
|
|||||||
margin: -9px;
|
margin: -9px;
|
||||||
}
|
}
|
||||||
.box-body .box-pane {
|
.box-body .box-pane {
|
||||||
border-top-left-radius: 0;
|
border-radius: 0 0 0 3px;
|
||||||
border-top-right-radius: 0;
|
|
||||||
border-bottom-right-radius: 0;
|
|
||||||
border-bottom-left-radius: 3px;
|
|
||||||
}
|
}
|
||||||
.box-body .box-pane-right {
|
.box-body .box-pane-right {
|
||||||
border-top-left-radius: 0;
|
border-radius: 0 0 3px 0;
|
||||||
border-top-right-radius: 0;
|
|
||||||
border-bottom-right-radius: 3px;
|
|
||||||
border-bottom-left-radius: 0;
|
|
||||||
}
|
}
|
||||||
.box-footer {
|
.box-footer {
|
||||||
border-top-left-radius: 0;
|
border-radius: 0 0 3px 3px;
|
||||||
border-top-right-radius: 0;
|
|
||||||
border-bottom-right-radius: 3px;
|
|
||||||
border-bottom-left-radius: 3px;
|
|
||||||
border-top: 1px solid #f4f4f4;
|
border-top: 1px solid #f4f4f4;
|
||||||
border-top: none;
|
border-top: none;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
@ -6902,6 +6898,27 @@ i.menu-icon,
|
|||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.box-content {
|
||||||
|
/*scrollbar-width: thin;
|
||||||
|
scrollbar-color: rgba(128, 128, 128, 0.2) @brand-border;*/
|
||||||
|
}
|
||||||
|
.box-content::-webkit-scrollbar-track {
|
||||||
|
background-color: #f9f9f9;
|
||||||
|
}
|
||||||
|
.box-content::-webkit-scrollbar-corner {
|
||||||
|
background-color: #f9f9f9;
|
||||||
|
}
|
||||||
|
.box-content::-webkit-scrollbar {
|
||||||
|
width: 10px;
|
||||||
|
height: 10px;
|
||||||
|
/* background-color: @box-header-bg; */
|
||||||
|
}
|
||||||
|
.box-content::-webkit-scrollbar-thumb {
|
||||||
|
border-radius: 2px;
|
||||||
|
background-color: #dddddd;
|
||||||
|
border: 2px solid #f9f9f9;
|
||||||
|
/*border: 2px solid @box-header-bg;*/
|
||||||
|
}
|
||||||
.fade {
|
.fade {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
-moz-transition: opacity 0.15s linear;
|
-moz-transition: opacity 0.15s linear;
|
||||||
@ -10635,20 +10652,6 @@ x:-o-prefocus,
|
|||||||
.grid-stack > .grid-stack-item > .grid-stack-item-content {
|
.grid-stack > .grid-stack-item > .grid-stack-item-content {
|
||||||
z-index: unset!important;
|
z-index: unset!important;
|
||||||
}
|
}
|
||||||
.box-content::-webkit-scrollbar-track {
|
|
||||||
background-color: #dddddd;
|
|
||||||
}
|
|
||||||
.box-content::-webkit-scrollbar {
|
|
||||||
width: 10px;
|
|
||||||
height: 10px;
|
|
||||||
background-color: #fafafa;
|
|
||||||
}
|
|
||||||
.box-content::-webkit-scrollbar-thumb {
|
|
||||||
border-radius: 10px;
|
|
||||||
background-color: #333333;
|
|
||||||
background-color: rgba(128, 128, 128, 0.2);
|
|
||||||
border: 2px solid #fafafa;
|
|
||||||
}
|
|
||||||
.widget-title {
|
.widget-title {
|
||||||
top: 3px;
|
top: 3px;
|
||||||
left: 4px;
|
left: 4px;
|
||||||
|
@ -6,14 +6,17 @@
|
|||||||
*
|
*
|
||||||
* @package observium
|
* @package observium
|
||||||
* @subpackage web
|
* @subpackage web
|
||||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
|
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
include_once("../includes/observium.inc.php");
|
||||||
|
|
||||||
include_once("../includes/sql-config.inc.php");
|
if (!$config['web_iframe'] && is_iframe()) {
|
||||||
|
print_error_permission("Not allowed to run in a iframe!");
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
include($config['html_dir'] . "/includes/functions.inc.php");
|
|
||||||
include($config['html_dir'] . "/includes/authenticate.inc.php");
|
include($config['html_dir'] . "/includes/authenticate.inc.php");
|
||||||
|
|
||||||
if (is_numeric($_GET['id']) && ($config['allow_unauth_graphs'] || port_permitted($_GET['id']))) {
|
if (is_numeric($_GET['id']) && ($config['allow_unauth_graphs'] || port_permitted($_GET['id']))) {
|
||||||
@ -24,14 +27,14 @@ if (is_numeric($_GET['id']) && ($config['allow_unauth_graphs'] || port_permitted
|
|||||||
$auth = TRUE;
|
$auth = TRUE;
|
||||||
|
|
||||||
$time = time();
|
$time = time();
|
||||||
$HC = ($port['port_64bit'] ? 'HC' : '');
|
$HC = $port['port_64bit'] ? 'HC' : '';
|
||||||
|
|
||||||
$data = snmp_get_multi_oid($device, "if{$HC}InOctets.".$port['ifIndex']." if{$HC}OutOctets.".$port['ifIndex'], [], "IF-MIB");
|
$data = snmp_get_multi_oid($device, "if{$HC}InOctets." . $port['ifIndex'] . " if{$HC}OutOctets." . $port['ifIndex'], [], "IF-MIB");
|
||||||
|
|
||||||
printf("%lf|%s|%s\n", $time, $data[$port['ifIndex']]["if{$HC}InOctets"], $data[$port['ifIndex']]["if{$HC}OutOctets"]);
|
printf("%lf|%s|%s\n", $time, $data[$port['ifIndex']]["if{$HC}InOctets"], $data[$port['ifIndex']]["if{$HC}OutOctets"]);
|
||||||
} else {
|
} else {
|
||||||
echo("unauthenticated");
|
// not authenticated
|
||||||
exit;
|
die("Unauthenticated");
|
||||||
}
|
}
|
||||||
|
|
||||||
// EOF
|
// EOF
|
||||||
|
18
html/error.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Observium
|
||||||
|
*
|
||||||
|
* This file is part of Observium.
|
||||||
|
*
|
||||||
|
* @package observium
|
||||||
|
* @subpackage web
|
||||||
|
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
include_once("../includes/observium.inc.php");
|
||||||
|
|
||||||
|
//r(array_key_first($_GET));
|
||||||
|
display_error_http(array_key_first($_GET));
|
||||||
|
|
||||||
|
// EOF
|
204
html/feed.php
@ -6,24 +6,16 @@
|
|||||||
*
|
*
|
||||||
* @package observium
|
* @package observium
|
||||||
* @subpackage feed
|
* @subpackage feed
|
||||||
* @author Mike Stupalov <mike@observium.org>
|
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
|
||||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
include_once("../includes/observium.inc.php");
|
||||||
if (isset($_GET['debug']) && $_GET['debug'])
|
|
||||||
{
|
if (is_iframe()) {
|
||||||
ini_set('display_errors', 1);
|
display_error_http(403, 'Not allowed to run in a iframe');
|
||||||
ini_set('display_startup_errors', 0);
|
}
|
||||||
ini_set('log_errors', 0);
|
|
||||||
ini_set('allow_url_fopen', 0);
|
|
||||||
ini_set('error_reporting', E_ALL);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
include_once("../includes/sql-config.inc.php");
|
|
||||||
|
|
||||||
include($config['html_dir'] . "/includes/functions.inc.php");
|
|
||||||
//include($config['html_dir'] . "/includes/authenticate.inc.php"); // not for RSS!
|
//include($config['html_dir'] . "/includes/authenticate.inc.php"); // not for RSS!
|
||||||
|
|
||||||
$auth = FALSE;
|
$auth = FALSE;
|
||||||
@ -31,20 +23,16 @@ $vars = get_vars('GET');
|
|||||||
|
|
||||||
// Auth
|
// Auth
|
||||||
if (isset($vars['hash']) && strlen($vars['hash']) >= 16 &&
|
if (isset($vars['hash']) && strlen($vars['hash']) >= 16 &&
|
||||||
is_numeric($vars['id']) && $vars['id'] > 0)
|
is_numeric($vars['id']) && $vars['id'] > 0) {
|
||||||
{
|
|
||||||
$key = get_user_pref($vars['id'], 'atom_key');
|
$key = get_user_pref($vars['id'], 'atom_key');
|
||||||
if ($key)
|
if ($key) {
|
||||||
{
|
|
||||||
// Check hash auth
|
// Check hash auth
|
||||||
if ($data = decrypt($vars['hash'], $key))
|
if ($data = decrypt($vars['hash'], $key)) {
|
||||||
{
|
|
||||||
//var_dump($data);
|
//var_dump($data);
|
||||||
$data = explode('|', $data); // user_id|user_level|auth_mechanism
|
$data = explode('|', $data); // user_id|user_level|auth_mechanism
|
||||||
|
|
||||||
$data_c = count($data);
|
$data_c = count($data);
|
||||||
if ($data_c == 3)
|
if ($data_c == 3) {
|
||||||
{
|
|
||||||
$user_id = $data[0];
|
$user_id = $data[0];
|
||||||
$user_level = $data[1]; // FIXME, need new way for check userlevel, because it can be changed
|
$user_level = $data[1]; // FIXME, need new way for check userlevel, because it can be changed
|
||||||
$check_auth_mechanism = $config['auth_mechanism'] == $data[2];
|
$check_auth_mechanism = $config['auth_mechanism'] == $data[2];
|
||||||
@ -61,137 +49,115 @@ if (isset($vars['hash']) && strlen($vars['hash']) >= 16 &&
|
|||||||
}
|
}
|
||||||
|
|
||||||
//var_dump($auth);
|
//var_dump($auth);
|
||||||
if (!$auth)
|
if (!$auth) {
|
||||||
{
|
display_error_http(401, 'Update feed url');
|
||||||
//header("HTTP/1.1 401 Unauthorized"); // This force basic auth form (login/password), which unsupported here
|
|
||||||
header("HTTP/1.1 403 Forbidden");
|
|
||||||
|
|
||||||
if ($vars)
|
|
||||||
{
|
|
||||||
?>
|
|
||||||
<HTML>
|
|
||||||
<HEAD>
|
|
||||||
<TITLE>Unauthorized</TITLE>
|
|
||||||
</HEAD>
|
|
||||||
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
|
|
||||||
<H1>Unauthorized</H1>
|
|
||||||
<H2>Update feed url</H2>
|
|
||||||
</BODY>
|
|
||||||
</HTML>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
// End auth
|
// End auth
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
$_SESSION['user_id'] = $user_id;
|
$_SESSION['user_id'] = $user_id;
|
||||||
$_SESSION['userlevel'] = $user_level;
|
$_SESSION['userlevel'] = $user_level;
|
||||||
|
|
||||||
$permissions = permissions_cache($_SESSION['user_id']);
|
$permissions = permissions_cache($_SESSION['user_id']);
|
||||||
session_commit();
|
session_write_close();
|
||||||
|
|
||||||
include($config['html_dir'] . "/includes/cache-data.inc.php"); // Need for check permissions
|
include($config['html_dir'] . "/includes/cache-data.inc.php"); // Need for check permissions
|
||||||
|
|
||||||
$use_rss = ($vars['v'] == 'rss' ? TRUE : FALSE); // In most cases used ATOM feed
|
$use_rss = $vars['v'] === 'rss'; // In most cases used ATOM feed
|
||||||
$param = array('short' => TRUE, 'pagesize' => 25);
|
$param = ['short' => TRUE, 'pagesize' => 25];
|
||||||
if (is_numeric($vars['size']))
|
if (is_numeric($vars['size'])) {
|
||||||
{
|
|
||||||
$param['pagesize'] = $vars['size'];
|
$param['pagesize'] = $vars['size'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// base feed info
|
// base feed info
|
||||||
$base_url = rtrim($GLOBALS['config']['base_url'], '/');
|
$base_url = rtrim($GLOBALS['config']['base_url'], '/');
|
||||||
$feed_generator = OBSERVIUM_PRODUCT.' '.OBSERVIUM_VERSION;
|
$feed_generator = OBSERVIUM_PRODUCT . ' ' . OBSERVIUM_VERSION;
|
||||||
$feed_title = 'Observium ['.$_SERVER["SERVER_NAME"].'] :: Eventlog Feed';
|
$feed_title = 'Observium [' . $_SERVER["SERVER_NAME"] . '] :: Eventlog Feed';
|
||||||
$feed_description = "Latest eventlogs from observium on $base_url";
|
$feed_description = "Latest eventlogs from observium on $base_url";
|
||||||
$feed_link = $base_url.'/eventlog/';
|
$feed_link = $base_url . '/eventlog/';
|
||||||
|
|
||||||
$events = get_events_array($param);
|
$events = get_events_array($param);
|
||||||
if ($use_rss)
|
if ($use_rss) {
|
||||||
{
|
|
||||||
// create rss
|
// create rss
|
||||||
// See format options here: http://validator.w3.org/feed/docs/rss2.html
|
// See format options here: http://validator.w3.org/feed/docs/rss2.html
|
||||||
$xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"></rss>');
|
$xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"></rss>');
|
||||||
$xml->addChild('channel');
|
$xml -> addChild('channel');
|
||||||
$xml->channel->addChild('title', $feed_title);
|
$xml -> channel -> addChild('title', $feed_title);
|
||||||
$xml->channel->addChild('description', $feed_description);
|
$xml -> channel -> addChild('description', $feed_description);
|
||||||
$xml->channel->addChild('link', $feed_link);
|
$xml -> channel -> addChild('link', $feed_link);
|
||||||
$xml->channel->addChild('language', 'en-us');
|
$xml -> channel -> addChild('language', 'en-us');
|
||||||
$xml->channel->addChild('generator', $feed_generator);
|
$xml -> channel -> addChild('generator', $feed_generator);
|
||||||
$xml->channel->addChild('pubDate', date(DATE_RSS, strtotime($events['updated'])));
|
$xml -> channel -> addChild('pubDate', date(DATE_RSS, strtotime($events['updated'])));
|
||||||
$xml->channel->addChild('ttl', '5'); // a number of minutes that indicates how long a channel can be cached before refreshing
|
$xml -> channel -> addChild('ttl', '5'); // a number of minutes that indicates how long a channel can be cached before refreshing
|
||||||
} else {
|
} else {
|
||||||
// create atom
|
// create atom
|
||||||
// See format options here: http://validator.w3.org/feed/docs/atom.html
|
// See format options here: http://validator.w3.org/feed/docs/atom.html
|
||||||
$atom_ns = 'http://www.w3.org/2005/Atom';
|
$atom_ns = 'http://www.w3.org/2005/Atom';
|
||||||
$xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><feed xml:lang="en-US" xmlns="'.$atom_ns.'"></feed>');
|
$xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><feed xml:lang="en-US" xmlns="' . $atom_ns . '"></feed>');
|
||||||
$xml->addChild('title', $feed_title);
|
$xml -> addChild('title', $feed_title);
|
||||||
$xml->addChild('subtitle', $feed_description);
|
$xml -> addChild('subtitle', $feed_description);
|
||||||
$xml->addChild('id', $feed_link);
|
$xml -> addChild('id', $feed_link);
|
||||||
$xml->addChild('icon', $base_url.'/'.$GLOBALS['config']['favicon']);
|
$xml -> addChild('icon', $base_url . '/' . $GLOBALS['config']['favicon']);
|
||||||
$xml->addChild('link');
|
$xml -> addChild('link');
|
||||||
$xml->link->addAttribute('href', $feed_link);
|
$xml -> link -> addAttribute('href', $feed_link);
|
||||||
$self_link = $xml->addChild('link', '', $atom_ns);
|
$self_link = $xml -> addChild('link', '', $atom_ns);
|
||||||
$self_link->addAttribute('href', $base_url.$_SERVER['REQUEST_URI']);
|
$self_link -> addAttribute('href', $base_url . $_SERVER['REQUEST_URI']);
|
||||||
$self_link->addAttribute('rel', 'self');
|
$self_link -> addAttribute('rel', 'self');
|
||||||
$self_link->addAttribute('type', 'application/atom+xml');
|
$self_link -> addAttribute('type', 'application/atom+xml');
|
||||||
$xml->addChild('generator', $feed_generator);
|
$xml -> addChild('generator', $feed_generator);
|
||||||
$xml->addChild('updated', date(DATE_ATOM, strtotime($events['updated'])));
|
$xml -> addChild('updated', date(DATE_ATOM, strtotime($events['updated'])));
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($events['entries'] as $entry)
|
foreach ($events['entries'] as $entry) {
|
||||||
{
|
|
||||||
$entry_device = device_by_id_cache($entry['device_id']);
|
$entry_device = device_by_id_cache($entry['device_id']);
|
||||||
$entry_vars = array('page' => 'device',
|
$entry_vars = ['page' => 'device',
|
||||||
'device' => $entry['device_id'],
|
'device' => $entry['device_id'],
|
||||||
'tab' => 'logs',
|
'tab' => 'logs',
|
||||||
'section' => 'eventlog',
|
'section' => 'eventlog',
|
||||||
'type' => $entry['type'],
|
'type' => $entry['type'],
|
||||||
'timestamp_from' => $entry['timestamp'],
|
'timestamp_from' => $entry['timestamp'],
|
||||||
'timestamp_to' => $entry['timestamp']);
|
'timestamp_to' => $entry['timestamp']];
|
||||||
$entry_title = escape_html('['.$entry_device['hostname'].'] '.$entry['message']);
|
$entry_title = escape_html('[' . $entry_device['hostname'] . '] ' . $entry['message']);
|
||||||
$entry_description = escape_html('['.$entry_device['hostname']."]\n".strtoupper($entry['type']).': '.$entry['message']);
|
$entry_description = escape_html('[' . $entry_device['hostname'] . "]\n" . strtoupper($entry['type']) . ': ' . $entry['message']);
|
||||||
$entry_link = $base_url.'/'.generate_device_url($entry_device, $entry_vars);
|
$entry_link = $base_url . '/' . generate_device_url($entry_device, $entry_vars);
|
||||||
$entry_id = $entry_link.'guid='.md5($entry['event_id']);
|
$entry_id = $entry_link . 'guid=' . md5($entry['event_id']);
|
||||||
|
|
||||||
if ($use_rss)
|
if ($use_rss) {
|
||||||
{
|
|
||||||
// add item element for each article
|
// add item element for each article
|
||||||
$item = $xml->channel->addChild('item');
|
$item = $xml -> channel -> addChild('item');
|
||||||
$item->addChild('title', $entry_title);
|
$item -> addChild('title', $entry_title);
|
||||||
$item->addChild('description', $entry_description);
|
$item -> addChild('description', $entry_description);
|
||||||
$item->addChild('guid', $entry_id);
|
$item -> addChild('guid', $entry_id);
|
||||||
$item->addChild('link', $entry_link);
|
$item -> addChild('link', $entry_link);
|
||||||
$item->addChild('h:dc:creator', $entry['type']);
|
$item -> addChild('h:dc:creator', $entry['type']);
|
||||||
$item->addChild('pubDate', date(DATE_RSS, strtotime($entry['timestamp'])));
|
$item -> addChild('pubDate', date(DATE_RSS, strtotime($entry['timestamp'])));
|
||||||
} else {
|
} else {
|
||||||
// add entry element for each article
|
// add entry element for each article
|
||||||
$item = $xml->addChild('entry');
|
$item = $xml -> addChild('entry');
|
||||||
$item->addChild('title', $entry_title);
|
$item -> addChild('title', $entry_title);
|
||||||
$item->addChild('summary', $entry_description);
|
$item -> addChild('summary', $entry_description);
|
||||||
$item->addChild('id', $entry_id);
|
$item -> addChild('id', $entry_id);
|
||||||
$item->addChild('link');
|
$item -> addChild('link');
|
||||||
$item->link->addAttribute('href', $entry_link);
|
$item -> link -> addAttribute('href', $entry_link);
|
||||||
$item->addChild('author');
|
$item -> addChild('author');
|
||||||
$item->author->addChild('name', $entry['type']);
|
$item -> author -> addChild('name', $entry['type']);
|
||||||
$item->addChild('updated', date(DATE_ATOM, strtotime($entry['timestamp'])));
|
$item -> addChild('updated', date(DATE_ATOM, strtotime($entry['timestamp'])));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Unset & destroy session
|
// Unset & destroy session
|
||||||
session_unset();
|
session_unset();
|
||||||
session_destroy();
|
session_destroy();
|
||||||
|
|
||||||
// Print feed
|
// Print feed
|
||||||
header('Content-Type: text/xml; charset=utf-8');
|
header('Content-Type: text/xml; charset=utf-8');
|
||||||
echo $xml->asXML();
|
echo $xml -> asXML();
|
||||||
|
|
||||||
|
|
||||||
// DOCME needs phpdoc block
|
// DOCME needs phpdoc block
|
||||||
function content_cdata($content)
|
function content_cdata($content)
|
||||||
{
|
{
|
||||||
return '<![CDATA['.$content.']]>';
|
return '<![CDATA[' . $content . ']]>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// EOF
|
// EOF
|
||||||
|
100
html/geojson.php
@ -1,100 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Observium
|
|
||||||
*
|
|
||||||
* This file is part of Observium.
|
|
||||||
*
|
|
||||||
* @package observium
|
|
||||||
* @subpackage web
|
|
||||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
ini_set('allow_url_fopen', 0);
|
|
||||||
|
|
||||||
include_once("../includes/sql-config.inc.php");
|
|
||||||
|
|
||||||
include($config['html_dir'] . "/includes/functions.inc.php");
|
|
||||||
include($config['html_dir'] . "/includes/authenticate.inc.php");
|
|
||||||
include($config['html_dir'] . "/includes/cache-data.inc.php");
|
|
||||||
|
|
||||||
if ($_SERVER['REMOTE_ADDR'] != $_SERVER['SERVER_ADDR']) {
|
|
||||||
if (!$_SESSION['authenticated']) { echo("unauthenticated"); exit; }
|
|
||||||
}
|
|
||||||
|
|
||||||
$vars = get_vars('GET');
|
|
||||||
|
|
||||||
$geo = array();
|
|
||||||
|
|
||||||
foreach ($GLOBALS['cache']['devices']['id'] as $device)
|
|
||||||
{
|
|
||||||
if (!$config['web_show_disabled'] && $device["disabled"]) { continue; }
|
|
||||||
$lat = (is_numeric($device['location_lat']) ? $device['location_lat'] : $config['geocoding']['default']['lat']);
|
|
||||||
$lon = (is_numeric($device['location_lon']) ? $device['location_lon'] : $config['geocoding']['default']['lon']);
|
|
||||||
if ($device["status"] == "0")
|
|
||||||
{
|
|
||||||
if ($device["ignore"] == "0")
|
|
||||||
{
|
|
||||||
$locations[$lat][$lon]["down_hosts"][] = $device;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$locations[$lat][$lon]["up_hosts"][] = $device;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($locations as $la => $lat)
|
|
||||||
{
|
|
||||||
foreach ($lat as $lo => $lon)
|
|
||||||
{
|
|
||||||
$tooltip = "";
|
|
||||||
$num_up = safe_count($lon["up_hosts"]);
|
|
||||||
$num_down = safe_count($lon["down_hosts"]);
|
|
||||||
$total_hosts = $num_up + $num_down;
|
|
||||||
$tooltip = '<p><span class="label label-success">Up '.$num_up.'</span> <span class="label label-error">Down '.$num_down.'</span></p>';
|
|
||||||
$state = 'unknown';
|
|
||||||
$location_name = "";
|
|
||||||
if ($num_down > 0)
|
|
||||||
{
|
|
||||||
$state = 'down';
|
|
||||||
$location_name = ($lon['down_hosts'][0]['location'] === '' ? OBS_VAR_UNSET : $lon['down_hosts'][0]['location']);
|
|
||||||
$location_url = generate_location_url($lon['down_hosts'][0]['location']);
|
|
||||||
}
|
|
||||||
elseif ($num_up > 0)
|
|
||||||
{
|
|
||||||
$state = 'up';
|
|
||||||
$location_name = ($lon['up_hosts'][0]['location'] === '' ? OBS_VAR_UNSET : $lon['up_hosts'][0]['location']);
|
|
||||||
$location_url = generate_location_url($lon['up_hosts'][0]['location']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$tooltip = "<h3>".$location_name."</h3><hr />".$tooltip;
|
|
||||||
foreach ($lon["down_hosts"] as $down_host) {
|
|
||||||
$tooltip .= '<span class="label label-error">' . escape_html($down_host['hostname']) .'</span> ';
|
|
||||||
}
|
|
||||||
|
|
||||||
$feature = array('geometry' => array('type' => 'Point',
|
|
||||||
'coordinates' => array((float)$lo, (float)$la)),
|
|
||||||
'type' => 'Feature',
|
|
||||||
'properties' => array('name' => $location_name,
|
|
||||||
'state' => $state,
|
|
||||||
'id' => safename($location_name),
|
|
||||||
'popupContent' => $tooltip,
|
|
||||||
'url' => $location_url));
|
|
||||||
$features[] = $feature;
|
|
||||||
|
|
||||||
//echo "[$la, $lo, $num_up, $num_down, \"$tooltip\", '$location_name', '$location_url'],\n ";
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$geo = array('type' => 'FeatureCollection', 'features' => $features);
|
|
||||||
|
|
||||||
header('Content-type: application/javascript');
|
|
||||||
//echo 'var geojson = ' . json_encode($geo) . ';';
|
|
||||||
|
|
||||||
//print_r($features);
|
|
||||||
|
|
||||||
echo safe_json_encode($geo);
|
|
||||||
|
|
||||||
//r($geo);
|
|
||||||
|
|
||||||
// EOF
|
|
@ -12,9 +12,16 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
include_once("../includes/sql-config.inc.php");
|
include_once("../includes/observium.inc.php");
|
||||||
|
|
||||||
|
if (!$config['web_iframe'] && is_iframe() &&
|
||||||
|
!http_match_referer('!/device/device=\d+/tab=port/.*?/view=realtime/!')) {
|
||||||
|
//bdump($_SERVER['HTTP_SEC_FETCH_DEST']);
|
||||||
|
//bdump($_SERVER['HTTP_REFERER']); //'HTTP_SEC_FETCH_SITE' => 'same-origin'
|
||||||
|
print_error_permission("Not allowed to run in a iframe!");
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
include($config['html_dir'] . "/includes/functions.inc.php");
|
|
||||||
include($config['html_dir'] . "/includes/authenticate.inc.php");
|
include($config['html_dir'] . "/includes/authenticate.inc.php");
|
||||||
|
|
||||||
// Push $_GET into $vars to be compatible with web interface naming
|
// Push $_GET into $vars to be compatible with web interface naming
|
||||||
@ -22,16 +29,14 @@ $vars = get_vars('GET');
|
|||||||
|
|
||||||
if (is_numeric($vars['id']) && ($config['allow_unauth_graphs'] || port_permitted($vars['id'])))
|
if (is_numeric($vars['id']) && ($config['allow_unauth_graphs'] || port_permitted($vars['id'])))
|
||||||
{
|
{
|
||||||
$port = get_port_by_id($vars['id']);
|
$port = get_port_by_id_cache($vars['id']);
|
||||||
$device = device_by_id_cache($port['device_id']);
|
$device = device_by_id_cache($port['device_id']);
|
||||||
$title = generate_device_link($device);
|
$title = generate_device_link($device);
|
||||||
$title .= " :: Port ".generate_port_link($port);
|
$title .= " :: Port " . generate_port_link($port);
|
||||||
$auth = TRUE;
|
$auth = TRUE;
|
||||||
} else {
|
} else {
|
||||||
|
// not authenticated
|
||||||
echo("Unauthenticated");
|
die("Unauthenticated");
|
||||||
die;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
header("Content-type: image/svg+xml");
|
header("Content-type: image/svg+xml");
|
||||||
@ -42,46 +47,41 @@ $ifname = escape_html($port['port_label']); //Interface name that will be sho
|
|||||||
//$hostname = short_hostname($device['hostname']);
|
//$hostname = short_hostname($device['hostname']);
|
||||||
$hostname = escape_html(device_name($device, TRUE));
|
$hostname = escape_html(device_name($device, TRUE));
|
||||||
|
|
||||||
if($vars['title']) { $ifname = escape_html($vars['title']); }
|
if ($vars['title']) { $ifname = escape_html($vars['title']); }
|
||||||
|
|
||||||
/********* Other conf *******/
|
/********* Other conf *******/
|
||||||
$scale_type="follow"; //Autoscale default setup : "up" = only increase scale; "follow" = increase and decrease scale according to current graphed datas
|
$scale_type = "follow"; // Autoscale default setup : "up" = only increase scale; "follow" = increase and decrease scale according to current graphed datas
|
||||||
$nb_plot=240; //NB plot in graph
|
$nb_plot = 240; // NB plot in graph
|
||||||
|
|
||||||
if (is_numeric($vars['interval']))
|
// Refresh time Interval
|
||||||
{
|
$time_interval = is_numeric($vars['interval']) ? $vars['interval'] : 1;
|
||||||
$time_interval = $vars['interval'];
|
|
||||||
} else {
|
|
||||||
$time_interval = 1; // Refresh time Interval
|
|
||||||
}
|
|
||||||
|
|
||||||
$fetch_link = "data.php?id=".$vars['id'];
|
$fetch_link = "data.php?id=" . $vars['id'];
|
||||||
if (OBS_DEBUG)
|
if (OBS_DEBUG) {
|
||||||
{
|
|
||||||
$fetch_link .= '&debug=yes';
|
$fetch_link .= '&debug=yes';
|
||||||
}
|
}
|
||||||
|
|
||||||
//SVG attributes
|
// SVG attributes
|
||||||
$attribs['axis']='fill="black" stroke="black"';
|
$attribs['axis'] = 'fill="black" stroke="black"';
|
||||||
$attribs['in']='fill="green" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="7"';
|
$attribs['in'] = 'fill="green" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="7"';
|
||||||
$attribs['out']='fill="blue" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="7"';
|
$attribs['out'] = 'fill="blue" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="7"';
|
||||||
$attribs['graph_in']='fill="none" stroke="green" stroke-opacity="0.8"';
|
$attribs['graph_in'] = 'fill="none" stroke="green" stroke-opacity="0.8"';
|
||||||
$attribs['graph_out']='fill="none" stroke="blue" stroke-opacity="0.8"';
|
$attribs['graph_out'] = 'fill="none" stroke="blue" stroke-opacity="0.8"';
|
||||||
$attribs['legend']='fill="black" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="4"';
|
$attribs['legend'] = 'fill="black" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="4"';
|
||||||
$attribs['graphname']='fill="#435370" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="9"';
|
$attribs['graphname'] = 'fill="#435370" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="9"';
|
||||||
$attribs['hostname']='fill="#435370" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="6"';
|
$attribs['hostname'] = 'fill="#435370" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="6"';
|
||||||
$attribs['grid_txt']='fill="gray" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="6"';
|
$attribs['grid_txt'] = 'fill="gray" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="6"';
|
||||||
$attribs['grid']='stroke="gray" stroke-opacity="0.5"';
|
$attribs['grid'] = 'stroke="gray" stroke-opacity="0.5"';
|
||||||
$attribs['switch_unit']='fill="#435370" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="4" text-decoration="underline"';
|
$attribs['switch_unit'] = 'fill="#435370" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="4" text-decoration="underline"';
|
||||||
$attribs['switch_scale']='fill="#435370" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="4" text-decoration="underline"';
|
$attribs['switch_scale'] = 'fill="#435370" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="4" text-decoration="underline"';
|
||||||
$attribs['error']='fill="blue" font-family="Arial" font-size="4"';
|
$attribs['error'] = 'fill="blue" font-family="Arial" font-size="4"';
|
||||||
$attribs['collect_initial']='fill="gray" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="4"';
|
$attribs['collect_initial'] = 'fill="gray" font-family="Tahoma, Verdana, Arial, Helvetica, sans-serif" font-size="4"';
|
||||||
|
|
||||||
//Error text if we cannot fetch data : depends on which method is used
|
//Error text if we cannot fetch data : depends on which method is used
|
||||||
$error_text = "Can't get data about port $ifnum";
|
$error_text = "Can't get data about port $ifnum";
|
||||||
|
|
||||||
$height=125; //SVG internal height : do not modify
|
$height = 125; // SVG internal height : do not modify
|
||||||
$width=300; //SVG internal width : do not modify
|
$width = 300; // SVG internal width : do not modify
|
||||||
|
|
||||||
/********* Graph DATA **************/
|
/********* Graph DATA **************/
|
||||||
print('<?xml version="1.0" encoding="iso-8859-1"?>' . PHP_EOL);
|
print('<?xml version="1.0" encoding="iso-8859-1"?>' . PHP_EOL);
|
||||||
@ -94,23 +94,23 @@ print('<?xml version="1.0" encoding="iso-8859-1"?>' . PHP_EOL);
|
|||||||
<line id="axis_y" x1="0" y1="100%" x2="100%" y2="100%" <?php echo($attribs['axis']) ?>/>
|
<line id="axis_y" x1="0" y1="100%" x2="100%" y2="100%" <?php echo($attribs['axis']) ?>/>
|
||||||
<path id="graph_out" d="M0 <?php echo($height) ?> L 0 <?php echo($height); ?>" <?php echo($attribs['graph_out']) ?>/>
|
<path id="graph_out" d="M0 <?php echo($height) ?> L 0 <?php echo($height); ?>" <?php echo($attribs['graph_out']) ?>/>
|
||||||
<path id="graph_in" d="M0 <?php echo($height) ?> L 0 <?php echo($height); ?>" <?php echo($attribs['graph_in']) ?>/>
|
<path id="graph_in" d="M0 <?php echo($height) ?> L 0 <?php echo($height); ?>" <?php echo($attribs['graph_in']) ?>/>
|
||||||
<path id="grid" d="M0 <?php echo($height/4*1) ?> L <?php echo($width) ?> <?php echo($height/4*1) ?> M0 <?php echo($height/4*2) ?> L <?php echo($width) ?> <?php echo($height/4*2) ?> M0 <?php echo ($height/4*3) ?> L <?php echo($width . ' ' . ($height/4*3)) ?>" <?php echo($attribs['grid'])?>/>
|
<path id="grid" d="M0 <?php echo($height / 4) ?> L <?php echo($width) ?> <?php echo($height / 4) ?> M0 <?php echo($height / 4 * 2) ?> L <?php echo($width) ?> <?php echo($height / 4 * 2) ?> M0 <?php echo ($height / 4 * 3) ?> L <?php echo($width . ' ' . ($height / 4 * 3)) ?>" <?php echo($attribs['grid'])?>/>
|
||||||
<text id="grid_txt1" x="<?php echo($width) ?>" y="<?php echo($height/4*1) ?>" <?php echo($attribs['grid_txt']) ?> text-anchor="end"> </text>
|
<text id="grid_txt1" x="<?php echo($width) ?>" y="<?php echo($height / 4) ?>" <?php echo($attribs['grid_txt']) ?> text-anchor="end"> </text>
|
||||||
<text id="grid_txt2" x="<?php echo($width) ?>" y="<?php echo($height/4*2) ?>" <?php echo($attribs['grid_txt']) ?> text-anchor="end"> </text>
|
<text id="grid_txt2" x="<?php echo($width) ?>" y="<?php echo($height / 4 * 2) ?>" <?php echo($attribs['grid_txt']) ?> text-anchor="end"> </text>
|
||||||
<text id="grid_txt3" x="<?php echo($width) ?>" y="<?php echo($height/4*3) ?>" <?php echo($attribs['grid_txt']) ?> text-anchor="end"> </text>
|
<text id="grid_txt3" x="<?php echo($width) ?>" y="<?php echo($height / 4 * 3) ?>" <?php echo($attribs['grid_txt']) ?> text-anchor="end"> </text>
|
||||||
<text id="graph_in_lbl" x="5" y="8" <?php echo($attribs['in']) ?>>In</text>
|
<text id="graph_in_lbl" x="5" y="8" <?php echo($attribs['in']) ?>>In</text>
|
||||||
<text id="graph_out_lbl" x="5" y="16" <?php echo($attribs['out']) ?>>Out</text>
|
<text id="graph_out_lbl" x="5" y="16" <?php echo($attribs['out']) ?>>Out</text>
|
||||||
<text id="graph_in_txt" x="20" y="8" <?php echo($attribs['in']) ?>> </text>
|
<text id="graph_in_txt" x="20" y="8" <?php echo($attribs['in']) ?>> </text>
|
||||||
<text id="graph_out_txt" x="20" y="16" <?php echo($attribs['out']) ?>> </text>
|
<text id="graph_out_txt" x="20" y="16" <?php echo($attribs['out']) ?>> </text>
|
||||||
<text id="ifname" x="<?php echo($width-2) ?>" y="8" <?php echo($attribs['graphname']) ?> text-anchor="end"><?php echo($ifname) ?></text>
|
<text id="ifname" x="<?php echo($width - 2) ?>" y="8" <?php echo($attribs['graphname']) ?> text-anchor="end"><?php echo($ifname) ?></text>
|
||||||
<text id="hostname" x="<?php echo($width-2) ?>" y="14" <?php echo($attribs['hostname']) ?> text-anchor="end"><?php echo($hostname) ?></text>
|
<text id="hostname" x="<?php echo($width - 2) ?>" y="14" <?php echo($attribs['hostname']) ?> text-anchor="end"><?php echo($hostname) ?></text>
|
||||||
<text id="switch_unit" x="<?php echo($width*0.55) ?>" y="5" <?php echo($attribs['switch_unit']) ?>>Switch to bytes/s</text>
|
<text id="switch_unit" x="<?php echo($width * 0.55) ?>" y="5" <?php echo($attribs['switch_unit']) ?>>Switch to bytes/s</text>
|
||||||
<text id="switch_scale" x="<?php echo($width*0.55) ?>" y="11" <?php echo($attribs['switch_scale']) ?>>AutoScale (<?php echo($scale_type) ?>)</text>
|
<text id="switch_scale" x="<?php echo($width * 0.55) ?>" y="11" <?php echo($attribs['switch_scale']) ?>>AutoScale (<?php echo($scale_type) ?>)</text>
|
||||||
<text id="datetime" x="<?php echo($width*0.33) ?>" y="5" <?php echo($attribs['legend']) ?>> </text>
|
<text id="datetime" x="<?php echo($width * 0.33) ?>" y="5" <?php echo($attribs['legend']) ?>> </text>
|
||||||
<text id="graphlast" x="<?php echo($width*0.55) ?>" y="17" <?php echo($attribs['legend']) ?>>Graph shows last <?php echo($time_interval*$nb_plot) ?> seconds</text>
|
<text id="graphlast" x="<?php echo($width * 0.55) ?>" y="17" <?php echo($attribs['legend']) ?>>Graph shows last <?php echo($time_interval * $nb_plot) ?> seconds</text>
|
||||||
<polygon id="axis_arrow_x" <?php echo($attribs['axis']) ?> points="<?php echo($width . "," . $height) ?> <?php echo(($width-2) . "," . ($height-2)) ?> <?php echo(($width-2) . "," . $height) ?>"/>
|
<polygon id="axis_arrow_x" <?php echo($attribs['axis']) ?> points="<?php echo($width . "," . $height) ?> <?php echo(($width - 2) . "," . ($height - 2)) ?> <?php echo(($width - 2) . "," . $height) ?>"/>
|
||||||
<text id="error" x="<?php echo($width*0.5) ?>" y="<?php echo($height*0.5) ?>" visibility="hidden" <?php echo($attribs['error']) ?> text-anchor="middle"><?php echo($error_text) ?></text>
|
<text id="error" x="<?php echo($width * 0.5) ?>" y="<?php echo($height * 0.5) ?>" visibility="hidden" <?php echo($attribs['error']) ?> text-anchor="middle"><?php echo($error_text) ?></text>
|
||||||
<text id="collect_initial" x="<?php echo($width*0.5) ?>" y="<?php echo($height*0.5) ?>" visibility="hidden" <?php echo($attribs['collect_initial']) ?> text-anchor="middle">Collecting initial data, please wait...</text>
|
<text id="collect_initial" x="<?php echo($width * 0.5) ?>" y="<?php echo($height * 0.5) ?>" visibility="hidden" <?php echo($attribs['collect_initial']) ?> text-anchor="middle">Collecting initial data, please wait...</text>
|
||||||
</g>
|
</g>
|
||||||
<script type="text/ecmascript">
|
<script type="text/ecmascript">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
@ -127,31 +127,33 @@ if (typeof getURL == 'undefined') {
|
|||||||
try {
|
try {
|
||||||
if (typeof callback.operationComplete == 'function')
|
if (typeof callback.operationComplete == 'function')
|
||||||
callback = callback.operationComplete;
|
callback = callback.operationComplete;
|
||||||
} catch (e) {}
|
} catch (e) {
|
||||||
|
}
|
||||||
if (typeof callback != 'function')
|
if (typeof callback != 'function')
|
||||||
throw 'No callback function for getURL';
|
throw 'No callback function for getURL';
|
||||||
|
|
||||||
var http_request = null;
|
var http_request = null;
|
||||||
if (typeof XMLHttpRequest != 'undefined') {
|
if (typeof XMLHttpRequest != 'undefined') {
|
||||||
http_request = new XMLHttpRequest();
|
http_request = new XMLHttpRequest();
|
||||||
}
|
} else if (typeof ActiveXObject != 'undefined') {
|
||||||
else if (typeof ActiveXObject != 'undefined'){
|
|
||||||
try {
|
try {
|
||||||
http_request = new ActiveXObject('Msxml2.XMLHTTP');
|
http_request = new ActiveXObject('Msxml2.XMLHTTP');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
try {
|
try {
|
||||||
http_request = new ActiveXObject('Microsoft.XMLHTTP');
|
http_request = new ActiveXObject('Microsoft.XMLHTTP');
|
||||||
} catch (e) {}
|
} catch (e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!http_request)
|
if (!http_request)
|
||||||
throw 'Both getURL and XMLHttpRequest are undefined';
|
throw 'Both getURL and XMLHttpRequest are undefined';
|
||||||
|
|
||||||
http_request.onreadystatechange = function() {
|
http_request.onreadystatechange = function() {
|
||||||
if (http_request.readyState == 4) {
|
if (http_request.readyState === 4) {
|
||||||
callback( { success : true,
|
callback({ success: true,
|
||||||
content : http_request.responseText,
|
content: http_request.responseText,
|
||||||
contentType : http_request.getResponseHeader("Content-Type") } );
|
contentType: http_request.getResponseHeader("Content-Type")
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
http_request.open('GET', url, true);
|
http_request.open('GET', url, true);
|
||||||
@ -180,15 +182,13 @@ function init(evt) {
|
|||||||
fetch_data();
|
fetch_data();
|
||||||
}
|
}
|
||||||
|
|
||||||
function switch_unit(event)
|
function switch_unit(event) {
|
||||||
{
|
|
||||||
SVGDoc.getElementById('switch_unit').firstChild.data = 'Switch to ' + unit + '/s';
|
SVGDoc.getElementById('switch_unit').firstChild.data = 'Switch to ' + unit + '/s';
|
||||||
unit = (unit == 'bits') ? 'bytes' : 'bits';
|
unit = (unit === 'bits') ? 'bytes' : 'bits';
|
||||||
}
|
}
|
||||||
|
|
||||||
function switch_scale(event)
|
function switch_scale(event) {
|
||||||
{
|
scale_type = (scale_type === 'up') ? 'follow' : 'up';
|
||||||
scale_type = (scale_type == 'up') ? 'follow' : 'up';
|
|
||||||
SVGDoc.getElementById('switch_scale').firstChild.data = 'AutoScale (' + scale_type + ')';
|
SVGDoc.getElementById('switch_scale').firstChild.data = 'AutoScale (' + scale_type + ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,18 +224,18 @@ function plot_data(obj) {
|
|||||||
if (ifin >= last_ifin) {
|
if (ifin >= last_ifin) {
|
||||||
diff_ifin = ifin - last_ifin;
|
diff_ifin = ifin - last_ifin;
|
||||||
} else {
|
} else {
|
||||||
var max = (last_ifin > Math.pow(2,32)) ? Math.pow(2,64) : Math.pow(2,32);
|
var max = (last_ifin > Math.pow(2, 32)) ? Math.pow(2, 64) : Math.pow(2, 32);
|
||||||
diff_ifin = max - last_ifin + ifin;
|
diff_ifin = max - last_ifin + ifin;
|
||||||
}
|
}
|
||||||
var diff_ifout;
|
var diff_ifout;
|
||||||
if (ifout >= last_ifout) {
|
if (ifout >= last_ifout) {
|
||||||
diff_ifout = ifout - last_ifout;
|
diff_ifout = ifout - last_ifout;
|
||||||
} else {
|
} else {
|
||||||
var max = (last_ifout > Math.pow(2,32)) ? Math.pow(2,64) : Math.pow(2,32);
|
var max = (last_ifout > Math.pow(2, 32)) ? Math.pow(2, 64) : Math.pow(2, 32);
|
||||||
diff_ifout = max - last_ifout + ifout;
|
diff_ifout = max - last_ifout + ifout;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (diff_ugmt == 0)
|
if (diff_ugmt === 0)
|
||||||
diff_ugmt = 1; /* avoid division by zero */
|
diff_ugmt = 1; /* avoid division by zero */
|
||||||
|
|
||||||
last_ugmt = ugmt;
|
last_ugmt = ugmt;
|
||||||
@ -247,7 +247,7 @@ function plot_data(obj) {
|
|||||||
SVGDoc.getElementById("collect_initial").setAttributeNS(null, 'visibility', 'visible');
|
SVGDoc.getElementById("collect_initial").setAttributeNS(null, 'visibility', 'visible');
|
||||||
plot_in[0] = diff_ifin / diff_ugmt;
|
plot_in[0] = diff_ifin / diff_ugmt;
|
||||||
plot_out[0] = diff_ifout / diff_ugmt;
|
plot_out[0] = diff_ifout / diff_ugmt;
|
||||||
setTimeout('fetch_data()',<?php echo(1000*$time_interval) ?>);
|
setTimeout('fetch_data()',<?php echo(1000 * $time_interval) ?>);
|
||||||
return;
|
return;
|
||||||
case 1:
|
case 1:
|
||||||
SVGDoc.getElementById("collect_initial").setAttributeNS(null, 'visibility', 'hidden');
|
SVGDoc.getElementById("collect_initial").setAttributeNS(null, 'visibility', 'hidden');
|
||||||
@ -256,7 +256,7 @@ function plot_data(obj) {
|
|||||||
// shift plot to left if the maximum number of plot points has been reached
|
// shift plot to left if the maximum number of plot points has been reached
|
||||||
var i = 0;
|
var i = 0;
|
||||||
while (i < max_num_points) {
|
while (i < max_num_points) {
|
||||||
plot_in[i] = plot_in[i+1];
|
plot_in[i] = plot_in[i + 1];
|
||||||
plot_out[i] = plot_out[++i];
|
plot_out[i] = plot_out[++i];
|
||||||
}
|
}
|
||||||
plot_in.length--;
|
plot_in.length--;
|
||||||
@ -271,13 +271,12 @@ function plot_data(obj) {
|
|||||||
SVGDoc.getElementById('graph_out_txt').firstChild.data = formatSpeed(plot_out[index_plot], unit);
|
SVGDoc.getElementById('graph_out_txt').firstChild.data = formatSpeed(plot_out[index_plot], unit);
|
||||||
|
|
||||||
/* determine peak for sensible scaling */
|
/* determine peak for sensible scaling */
|
||||||
if (scale_type == 'up') {
|
if (scale_type === 'up') {
|
||||||
if (plot_in[index_plot] > max)
|
if (plot_in[index_plot] > max)
|
||||||
max = plot_in[index_plot];
|
max = plot_in[index_plot];
|
||||||
if (plot_out[index_plot] > max)
|
if (plot_out[index_plot] > max)
|
||||||
max = plot_out[index_plot];
|
max = plot_out[index_plot];
|
||||||
}
|
} else if (scale_type === 'follow') {
|
||||||
else if (scale_type == 'follow') {
|
|
||||||
i = 0;
|
i = 0;
|
||||||
max = 0;
|
max = 0;
|
||||||
while (i < plot_in.length) {
|
while (i < plot_in.length) {
|
||||||
@ -291,14 +290,14 @@ function plot_data(obj) {
|
|||||||
|
|
||||||
var rmax; // max, rounded up
|
var rmax; // max, rounded up
|
||||||
|
|
||||||
if (unit == 'bits') {
|
if (unit === 'bits') {
|
||||||
/* round up max, such that
|
/* round up max, such that
|
||||||
100 kbps -> 200 kbps -> 400 kbps -> 800 kbps -> 1 Mbps -> 2 Mbps -> ... */
|
100 kbps -> 200 kbps -> 400 kbps -> 800 kbps -> 1 Mbps -> 2 Mbps -> ... */
|
||||||
rmax = 12500;
|
rmax = 12500;
|
||||||
i = 0;
|
i = 0;
|
||||||
while (max > rmax) {
|
while (max > rmax) {
|
||||||
i++;
|
i++;
|
||||||
if (i && (i % 4 == 0))
|
if (i && (i % 4 === 0))
|
||||||
rmax *= 1.25;
|
rmax *= 1.25;
|
||||||
else
|
else
|
||||||
rmax *= 2;
|
rmax *= 2;
|
||||||
@ -310,12 +309,12 @@ function plot_data(obj) {
|
|||||||
i = 0;
|
i = 0;
|
||||||
while (max > rmax) {
|
while (max > rmax) {
|
||||||
i++;
|
i++;
|
||||||
if (i && (i % 4 == 0))
|
if (i && (i % 4 === 0))
|
||||||
rmax *= 1.25;
|
rmax *= 1.25;
|
||||||
else
|
else
|
||||||
rmax *= 2;
|
rmax *= 2;
|
||||||
|
|
||||||
if (i == 8)
|
if (i === 8)
|
||||||
rmax *= 1.024;
|
rmax *= 1.024;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -323,14 +322,13 @@ function plot_data(obj) {
|
|||||||
scale = <?php echo($height) ?> / rmax;
|
scale = <?php echo($height) ?> / rmax;
|
||||||
|
|
||||||
/* change labels accordingly */
|
/* change labels accordingly */
|
||||||
SVGDoc.getElementById('grid_txt1').firstChild.data = formatSpeed(3*rmax/4,unit);
|
SVGDoc.getElementById('grid_txt1').firstChild.data = formatSpeed(3 * rmax / 4, unit);
|
||||||
SVGDoc.getElementById('grid_txt2').firstChild.data = formatSpeed(2*rmax/4,unit);
|
SVGDoc.getElementById('grid_txt2').firstChild.data = formatSpeed(2 * rmax / 4, unit);
|
||||||
SVGDoc.getElementById('grid_txt3').firstChild.data = formatSpeed(rmax/4,unit);
|
SVGDoc.getElementById('grid_txt3').firstChild.data = formatSpeed(rmax / 4, unit);
|
||||||
|
|
||||||
var path_in = "M 0 " + (<?php echo($height) ?> - (plot_in[0] * scale));
|
var path_in = "M 0 " + (<?php echo($height) ?> - (plot_in[0] * scale));
|
||||||
var path_out = "M 0 " + (<?php echo($height) ?> - (plot_out[0] * scale));
|
var path_out = "M 0 " + (<?php echo($height) ?> - (plot_out[0] * scale));
|
||||||
for (i = 1; i < plot_in.length; i++)
|
for (i = 1; i < plot_in.length; i++) {
|
||||||
{
|
|
||||||
var x = step * i;
|
var x = step * i;
|
||||||
var y_in = <?php echo($height) ?> - (plot_in[i] * scale);
|
var y_in = <?php echo($height) ?> - (plot_in[i] * scale);
|
||||||
var y_out = <?php echo($height) ?> - (plot_out[i] * scale);
|
var y_out = <?php echo($height) ?> - (plot_out[i] * scale);
|
||||||
@ -342,12 +340,12 @@ function plot_data(obj) {
|
|||||||
SVGDoc.getElementById('graph_in').setAttributeNS(null, 'd', path_in);
|
SVGDoc.getElementById('graph_in').setAttributeNS(null, 'd', path_in);
|
||||||
SVGDoc.getElementById('graph_out').setAttributeNS(null, 'd', path_out);
|
SVGDoc.getElementById('graph_out').setAttributeNS(null, 'd', path_out);
|
||||||
|
|
||||||
setTimeout('fetch_data()',<?php echo(1000*$time_interval) ?>);
|
setTimeout('fetch_data()', <?php echo(1000 * $time_interval) ?>);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handle_error() {
|
function handle_error() {
|
||||||
SVGDoc.getElementById("error").setAttributeNS(null, 'visibility', 'visible');
|
SVGDoc.getElementById("error").setAttributeNS(null, 'visibility', 'visible');
|
||||||
setTimeout('fetch_data()',<?php echo(1000*$time_interval) ?>);
|
setTimeout('fetch_data()', <?php echo(1000 * $time_interval) ?>);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isNumber(a) {
|
function isNumber(a) {
|
||||||
@ -355,9 +353,9 @@ function isNumber(a) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function formatSpeed(speed, unit) {
|
function formatSpeed(speed, unit) {
|
||||||
if (unit == 'bits')
|
if (unit === 'bits')
|
||||||
return formatSpeedBits(speed);
|
return formatSpeedBits(speed);
|
||||||
if (unit == 'bytes')
|
if (unit === 'bytes')
|
||||||
return formatSpeedBytes(speed);
|
return formatSpeedBytes(speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -367,8 +365,10 @@ function formatSpeedBits(speed) {
|
|||||||
return Math.round(speed / 125) + " Kbps";
|
return Math.round(speed / 125) + " Kbps";
|
||||||
if (speed < 125000000)
|
if (speed < 125000000)
|
||||||
return Math.round(speed / 1250)/100 + " Mbps";
|
return Math.round(speed / 1250)/100 + " Mbps";
|
||||||
|
if (speed < 125000000000)
|
||||||
|
return Math.round(speed / 1250000)/100 + " Gbps";
|
||||||
// else
|
// else
|
||||||
return Math.round(speed / 1250000)/100 + " Gbps"; /* wow! */
|
return Math.round(speed / 125000000000)/100 + " Tbps"; /* wow! */
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatSpeedBytes(speed) {
|
function formatSpeedBytes(speed) {
|
||||||
@ -377,8 +377,10 @@ function formatSpeedBytes(speed) {
|
|||||||
return Math.round(speed / 10.24)/100 + " KB/s";
|
return Math.round(speed / 10.24)/100 + " KB/s";
|
||||||
if (speed < 1073741824)
|
if (speed < 1073741824)
|
||||||
return Math.round(speed / 10485.76)/100 + " MB/s";
|
return Math.round(speed / 10485.76)/100 + " MB/s";
|
||||||
|
if (speed < 1099511627776)
|
||||||
|
return Math.round(speed / 10737418.24)/100 + " GB/s";
|
||||||
// else
|
// else
|
||||||
return Math.round(speed / 10737418.24)/100 + " GB/s"; /* wow! */
|
return Math.round(speed / 10995116277.76)/100 + " TB/s"; /* wow! */
|
||||||
}
|
}
|
||||||
|
|
||||||
function LZ(x) {
|
function LZ(x) {
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
*
|
*
|
||||||
* @package observium
|
* @package observium
|
||||||
* @subpackage graphs
|
* @subpackage graphs
|
||||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2023 Observium Limited
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -17,9 +17,7 @@ define('OBS_GRAPH', TRUE);
|
|||||||
|
|
||||||
$start = microtime(TRUE); // Needs common.php
|
$start = microtime(TRUE); // Needs common.php
|
||||||
|
|
||||||
include_once("../includes/sql-config.inc.php");
|
include_once("../includes/observium.inc.php");
|
||||||
|
|
||||||
include($config['html_dir'] . "/includes/functions.inc.php");
|
|
||||||
|
|
||||||
if (isset($config['allow_unauth_graphs']) && $config['allow_unauth_graphs']) {
|
if (isset($config['allow_unauth_graphs']) && $config['allow_unauth_graphs']) {
|
||||||
$auth = TRUE; // hardcode auth for all with config function
|
$auth = TRUE; // hardcode auth for all with config function
|
||||||
@ -36,6 +34,8 @@ if (!isset($auth) || !$auth) {
|
|||||||
// Normal auth
|
// Normal auth
|
||||||
include($config['html_dir'] . "/includes/authenticate.inc.php");
|
include($config['html_dir'] . "/includes/authenticate.inc.php");
|
||||||
$auth = $_SESSION['authenticated'];
|
$auth = $_SESSION['authenticated'];
|
||||||
|
} elseif (!isset($_SESSION['userlevel']) && $auth) {
|
||||||
|
$_SESSION['userlevel'] = 7; // Set global read for session when $auth hardcoded
|
||||||
}
|
}
|
||||||
|
|
||||||
// Push $_GET into $vars to be compatible with web interface naming
|
// Push $_GET into $vars to be compatible with web interface naming
|
||||||
@ -46,6 +46,6 @@ include($config['html_dir'] . "/includes/graphs/graph.inc.php");
|
|||||||
|
|
||||||
$runtime = microtime(TRUE) - $start;
|
$runtime = microtime(TRUE) - $start;
|
||||||
|
|
||||||
print_debug("Runtime ".$runtime." secs");
|
print_debug("Runtime " . $runtime . " secs");
|
||||||
|
|
||||||
// EOF
|
// EOF
|
||||||
|
Before Width: | Height: | Size: 781 B |
Before Width: | Height: | Size: 733 B |
Before Width: | Height: | Size: 523 B |
Before Width: | Height: | Size: 464 B |
Before Width: | Height: | Size: 619 B |
Before Width: | Height: | Size: 524 B |
Before Width: | Height: | Size: 610 B |
Before Width: | Height: | Size: 533 B |
Before Width: | Height: | Size: 703 B |
Before Width: | Height: | Size: 656 B |
Before Width: | Height: | Size: 467 B |
Before Width: | Height: | Size: 592 B |
Before Width: | Height: | Size: 605 B |
Before Width: | Height: | Size: 714 B |
Before Width: | Height: | Size: 612 B |
Before Width: | Height: | Size: 581 B |
Before Width: | Height: | Size: 634 B |
Before Width: | Height: | Size: 685 B |
Before Width: | Height: | Size: 670 B |
Before Width: | Height: | Size: 656 B |
Before Width: | Height: | Size: 701 B |
Before Width: | Height: | Size: 487 B |
Before Width: | Height: | Size: 525 B |
Before Width: | Height: | Size: 585 B |
Before Width: | Height: | Size: 478 B |
Before Width: | Height: | Size: 547 B |
Before Width: | Height: | Size: 581 B |
Before Width: | Height: | Size: 510 B |
Before Width: | Height: | Size: 483 B |
Before Width: | Height: | Size: 520 B |
Before Width: | Height: | Size: 432 B |
Before Width: | Height: | Size: 492 B |
Before Width: | Height: | Size: 493 B |
Before Width: | Height: | Size: 576 B |
Before Width: | Height: | Size: 555 B |
Before Width: | Height: | Size: 476 B |
Before Width: | Height: | Size: 473 B |
Before Width: | Height: | Size: 465 B |
Before Width: | Height: | Size: 426 B |
Before Width: | Height: | Size: 507 B |
Before Width: | Height: | Size: 582 B |
Before Width: | Height: | Size: 677 B |
Before Width: | Height: | Size: 379 B |
Before Width: | Height: | Size: 600 B |
Before Width: | Height: | Size: 551 B |
Before Width: | Height: | Size: 626 B |
Before Width: | Height: | Size: 345 B |
Before Width: | Height: | Size: 484 B |
Before Width: | Height: | Size: 384 B |
Before Width: | Height: | Size: 625 B |
Before Width: | Height: | Size: 685 B |
Before Width: | Height: | Size: 506 B |
Before Width: | Height: | Size: 349 B |
Before Width: | Height: | Size: 608 B |
Before Width: | Height: | Size: 602 B |
Before Width: | Height: | Size: 683 B |
Before Width: | Height: | Size: 516 B |
Before Width: | Height: | Size: 489 B |
Before Width: | Height: | Size: 631 B |
Before Width: | Height: | Size: 372 B |