Merge remote-tracking branch 'origin/develop' into ent-7519-cambio-de-fuentes-en-la-consola-a-nivel-global

This commit is contained in:
marcos 2021-05-25 10:49:31 +02:00
commit f2c30b6c73
54 changed files with 473 additions and 519 deletions

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix package: pandorafms-agent-unix
Version: 7.0NG.754-210518 Version: 7.0NG.754-210525
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="7.0NG.754-210518" pandora_version="7.0NG.754-210525"
echo "Test if you has the tools for to make the packages." echo "Test if you has the tools for to make the packages."
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null

View File

@ -1015,7 +1015,7 @@ my $Sem = undef;
my $ThreadSem = undef; my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.754'; use constant AGENT_VERSION => '7.0NG.754';
use constant AGENT_BUILD => '210518'; use constant AGENT_BUILD => '210525';
# Agent log default file size maximum and instances # Agent log default file size maximum and instances
use constant DEFAULT_MAX_LOG_SIZE => 600000; use constant DEFAULT_MAX_LOG_SIZE => 600000;

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.754 %define version 7.0NG.754
%define release 210518 %define release 210525
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.754 %define version 7.0NG.754
%define release 210518 %define release 210525
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -10,7 +10,7 @@
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.754" PI_VERSION="7.0NG.754"
PI_BUILD="210518" PI_BUILD="210525"
OS_NAME=`uname -s` OS_NAME=`uname -s`
FORCE=0 FORCE=0

View File

@ -3,7 +3,7 @@
######################################################################## ########################################################################
# Pandora FMS - Remote Event Tool (via WEB API) # Pandora FMS - Remote Event Tool (via WEB API)
######################################################################## ########################################################################
# Copyright (c) 2013 Artica Soluciones Tecnologicas S.L # Copyright (c) 2021 Artica Soluciones Tecnologicas S.L
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 2 # modify it under the terms of the GNU General Public License version 2
@ -12,6 +12,7 @@
# Includes list # Includes list
use strict; use strict;
use LWP::Simple; use LWP::Simple;
use LWP::UserAgent;
use MIME::Base64; use MIME::Base64;
use lib '/usr/lib/perl5'; use lib '/usr/lib/perl5';
use PandoraFMS::Tools; use PandoraFMS::Tools;
@ -33,12 +34,12 @@ sub help_screen{
Where options:\n Where options:\n
-u <credentials> : API credentials separated by comma: <api_pass>,<user>,<pass> -u <credentials> : API credentials separated by comma: <api_pass>,<user>,<pass>
-name <event_name> : Free text -name <event_name> : Free text (surrounded by single-quotes, for security reasons)
-group <id_group> : Group ID (use 0 for 'all') -group <id_group> : Group ID (use 0 for 'all')
-agent : Agent ID
Optional parameters: Optional parameters:
[-agent <id_agent] : Agent ID
[-status <status>] : 0 New, 1 Validated, 2 In process [-status <status>] : 0 New, 1 Validated, 2 In process
[-user <id_user>] : User comment (use in combination with -comment option) [-user <id_user>] : User comment (use in combination with -comment option)
[-type <event_type>] : unknown, alert_fired, alert_recovered, alert_ceased [-type <event_type>] : unknown, alert_fired, alert_recovered, alert_ceased
@ -57,7 +58,7 @@ Optional parameters:
[-c_instructions <critical_instructions>] [-c_instructions <critical_instructions>]
[-w_instructions <warning_instructions>] [-w_instructions <warning_instructions>]
[-u_instructions <unknown_instructions>] [-u_instructions <unknown_instructions>]
[-user_comment <comment>] [-user_comment <comment>] : Free text (surrounded by single-quotes, for security reasons)
[-owner_user <owner event>] : Use the login name, not the descriptive [-owner_user <owner event>] : Use the login name, not the descriptive
[-source <source>] : (By default 'Pandora') [-source <source>] : (By default 'Pandora')
[-tag <tags>] : Tag (must exist in the system to be imported) [-tag <tags>] : Tag (must exist in the system to be imported)
@ -65,6 +66,7 @@ Optional parameters:
[-id_extra <id extra>] : Id extra [-id_extra <id extra>] : Id extra
[-agent_name <Agent name>] : Agent name, Not to be confused with the alias. [-agent_name <Agent name>] : Agent name, Not to be confused with the alias.
[-force_create_agent<0 o 1>] : Force the creation of agent through an event this will create when it is 1. [-force_create_agent<0 o 1>] : Force the creation of agent through an event this will create when it is 1.
[-separator '<char/s>'] : If you use the vertical bar `|` in the event name, you must set other character for send the info. This must be surrounded by single-quotes
[-server_id <server_id>] : The pandora node server_id\n\n"; [-server_id <server_id>] : The pandora node server_id\n\n";
print "Example of event generation:\n\n"; print "Example of event generation:\n\n";
@ -88,7 +90,7 @@ Optional parameters:
############################################################################## ##############################################################################
sub tool_api_init () { sub tool_api_init () {
print "\nPandora FMS Remote Event Tool Copyright (c) 2013-2015 Artica ST\n"; print "\nPandora FMS Remote Event Tool Copyright (c) 2013-2021 Artica ST\n";
print "This program is Free Software, licensed under the terms of GPL License v2\n"; print "This program is Free Software, licensed under the terms of GPL License v2\n";
print "You can download latest versions and documentation at http://www.pandorafms.org\n\n"; print "You can download latest versions and documentation at http://www.pandorafms.org\n\n";
@ -120,7 +122,7 @@ sub tool_api_main () {
my $db_user; my $db_user;
my $db_pass; my $db_pass;
my @db_info; my @db_info;
my $id_agent; my $id_agent = '0';
my $id_user = ''; my $id_user = '';
my $status = ''; my $status = '';
my $id_agent_module = ''; my $id_agent_module = '';
@ -141,6 +143,7 @@ sub tool_api_main () {
my $call_api; my $call_api;
my $custom_data = ""; my $custom_data = "";
my $server_id = 0; my $server_id = 0;
my $separator = '|';
#~ help or api path (required) #~ help or api path (required)
if ($ARGV[0] eq '-h') { if ($ARGV[0] eq '-h') {
@ -185,12 +188,18 @@ sub tool_api_main () {
if ($line eq '-agent') { if ($line eq '-agent') {
$id_agent = $ARGV[$i + 1]; $id_agent = $ARGV[$i + 1];
# If not defined, send 0 for API.
if ($id_agent eq undef) {
$id_agent = '0';
}
} }
if ($line eq '-group') { if ($line eq '-group') {
$id_group = $ARGV[$i + 1]; $id_group = $ARGV[$i + 1];
} }
if ($line eq '-name') { if ($line eq '-name') {
$event_name = $ARGV[$i + 1]; $event_name = $ARGV[$i + 1];
$event_name =~ s/#/%23/g;
} }
if ($line eq '-type') { if ($line eq '-type') {
$event_type = $ARGV[$i + 1]; $event_type = $ARGV[$i + 1];
@ -250,50 +259,49 @@ sub tool_api_main () {
if ($line eq '-server_id') { if ($line eq '-server_id') {
$server_id = $ARGV[$i + 1]; $server_id = $ARGV[$i + 1];
} }
if ($line eq '-separator') {
$separator = $ARGV[$i + 1];
}
$i++; $i++;
} }
if ($event_name eq "") { if ($event_name eq "") {
print "[ERROR] Missing id agent! Read help info:\n\n"; print "[ERROR] Missing event name! Read help info:\n\n";
help_screen (); help_screen ();
} }
if ($id_group eq "") { if ($id_group eq "") {
print "[ERROR] Missing event group! Read help info:\n\n"; print "[ERROR] Missing event group! Read help info:\n\n";
help_screen (); help_screen ();
} }
if ($id_agent eq "" && $agent_name eq "") {
print "[ERROR] Missing id agent! and agent_name Read help info:\n\n";
help_screen ();
}
$data_event = $event_name . $data_event = $event_name .
"|" . $id_group . $separator . $id_group .
"|" . $id_agent . $separator . $id_agent .
"|" . $status . $separator . $status .
"|" . $id_user . $separator . $id_user .
"|" . $event_type . $separator . $event_type .
"|" . $severity . $separator . $severity .
"|" . $id_agent_module . $separator . $id_agent_module .
"|" . $id_alert_am . $separator . $id_alert_am .
"|" . $critical_instructions . $separator . $critical_instructions .
"|" . $warning_instructions . $separator . $warning_instructions .
"|" . $unknown_instructions . $separator . $unknown_instructions .
"|" . $user_comment . $separator . $user_comment .
"|" . $owner_user . $separator . $owner_user .
"|" . $source . $separator . $source .
"|" . $tags . $separator . $tags .
"|" . $custom_data . $separator . $custom_data .
"|" . $server_id . $separator . $server_id .
"|" . $id_extra . $separator . $id_extra .
"|" . $agent_name . $separator . $agent_name .
"|" . $force_create_agent; $separator . $force_create_agent;
$call_api = $api_path . '?' . $call_api = $api_path . '?' .
'op=set&' . 'op=set&' .
'op2=create_event&' . 'op2=create_event&' .
'other=' . $data_event .'&' . 'other=' . $data_event .'&' .
'other_mode=url_encode_separator_|&' . 'other_mode=url_encode_separator_'.$separator.'&' .
'apipass=' . $api_pass . '&' . 'apipass=' . $api_pass . '&' .
'user=' . $db_user . '&' . 'user=' . $db_user . '&' .
'pass=' . $db_pass; 'pass=' . $db_pass;
@ -321,7 +329,8 @@ sub tool_api_main () {
exit; exit;
} }
else { else {
my $content = get($call_api); my $ua = LWP::UserAgent->new(ssl_opts => { verify_hostname => 0 });
my $content = $ua->get($call_api);
if ($option eq '-create_event') { if ($option eq '-create_event') {
if ($content eq undef) { if ($content eq undef) {
@ -329,7 +338,7 @@ sub tool_api_main () {
help_screen(); help_screen();
} }
else { else {
print "Event ID: $content"; print "Event ID: $content->{'_content'}";
} }
} }
elsif ($option eq '-validate_event') { elsif ($option eq '-validate_event') {

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{} {}
Version Version
{210518} {210525}
ViewReadme ViewReadme
{Yes} {Yes}

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils; using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1 #define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("7.0NG.754 Build 210518") #define PANDORA_VERSION ("7.0NG.754 Build 210525")
string pandora_path; string pandora_path;
string pandora_dir; string pandora_dir;

View File

@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Artica ST" VALUE "LegalCopyright", "Artica ST"
VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent" VALUE "ProductName", "Pandora FMS Windows Agent"
VALUE "ProductVersion", "(7.0NG.754(Build 210518))" VALUE "ProductVersion", "(7.0NG.754(Build 210525))"
VALUE "FileVersion", "1.0.0.0" VALUE "FileVersion", "1.0.0.0"
END END
END END

View File

@ -1,5 +1,5 @@
package: pandorafms-console package: pandorafms-console
Version: 7.0NG.754-210518 Version: 7.0NG.754-210525
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="7.0NG.754-210518" pandora_version="7.0NG.754-210525"
package_pear=0 package_pear=0
package_pandora=1 package_pandora=1

View File

@ -31,18 +31,18 @@ require 'vendor/autoload.php';
define('AJAX', true); define('AJAX', true);
if (!defined('__PAN_XHPROF__')) { if (defined('__PAN_XHPROF__') === false) {
define('__PAN_XHPROF__', 0); define('__PAN_XHPROF__', 0);
} }
if (__PAN_XHPROF__ === 1) { if (__PAN_XHPROF__ === 1) {
if (function_exists('tideways_xhprof_enable')) { if (function_exists('tideways_xhprof_enable') === true) {
tideways_xhprof_enable(); tideways_xhprof_enable();
} }
} }
if ((! file_exists('include/config.php')) if (file_exists('include/config.php') === false
|| (! is_readable('include/config.php')) || is_readable('include/config.php') === false
) { ) {
exit; exit;
} }
@ -57,11 +57,11 @@ require_once 'include/auth/mysql.php';
if (isset($config['console_log_enabled']) === true if (isset($config['console_log_enabled']) === true
&& $config['console_log_enabled'] == 1 && $config['console_log_enabled'] == 1
) { ) {
ini_set('log_errors', 1); ini_set('log_errors', true);
ini_set('error_log', $config['homedir'].'/log/console.log'); ini_set('error_log', $config['homedir'].'/log/console.log');
} else { } else {
ini_set('log_errors', 0); ini_set('log_errors', false);
ini_set('error_log', null); ini_set('error_log', '');
} }
// Sometimes input is badly retrieved from caller... // Sometimes input is badly retrieved from caller...
@ -98,9 +98,11 @@ if (isset($_GET['loginhash']) === true) {
} }
} }
// Another auth class example: PandoraFMS\Dashboard\Manager.
$auth_class = io_safe_output( $auth_class = io_safe_output(
get_parameter('auth_class', 'PandoraFMS\Dashboard\Manager') get_parameter('auth_class', 'PandoraFMS\User')
); );
$public_hash = get_parameter('auth_hash', false); $public_hash = get_parameter('auth_hash', false);
$public_login = false; $public_login = false;
// Check user. // Check user.
@ -124,7 +126,7 @@ if (class_exists($auth_class) === false || $public_hash === false) {
ob_start(); ob_start();
// Enterprise support. // Enterprise support.
if (file_exists(ENTERPRISE_DIR.'/load_enterprise.php')) { if (file_exists(ENTERPRISE_DIR.'/load_enterprise.php') === true) {
include_once ENTERPRISE_DIR.'/load_enterprise.php'; include_once ENTERPRISE_DIR.'/load_enterprise.php';
} }
@ -142,12 +144,12 @@ if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK) {
); );
} }
if (is_metaconsole()) { if (is_metaconsole() === true) {
// Backward compatibility. // Backward compatibility.
define('METACONSOLE', true); define('METACONSOLE', true);
} }
if (file_exists($page)) { if (file_exists($page) === true) {
include_once $page; include_once $page;
} else { } else {
echo '<br /><b class="error">Sorry! I can\'t find the page '.$page.'!</b>'; echo '<br /><b class="error">Sorry! I can\'t find the page '.$page.'!</b>';
@ -172,7 +174,7 @@ if (isset($config['force_instant_logout']) === true
header_remove('Set-Cookie'); header_remove('Set-Cookie');
setcookie(session_name(), $_COOKIE[session_name()], (time() - 4800), '/'); setcookie(session_name(), $_COOKIE[session_name()], (time() - 4800), '/');
if ($config['auth'] == 'saml') { if ($config['auth'] === 'saml') {
include_once $config['saml_path'].'simplesamlphp/lib/_autoload.php'; include_once $config['saml_path'].'simplesamlphp/lib/_autoload.php';
$as = new SimpleSAML_Auth_Simple('PandoraFMS'); $as = new SimpleSAML_Auth_Simple('PandoraFMS');
$as->logout(); $as->logout();

View File

@ -82,3 +82,4 @@ include/lib/WSManager.php
include/lib/WebSocketServer.php include/lib/WebSocketServer.php
include/lib/WebSocketUser.php include/lib/WebSocketUser.php
operation/network/network_explorer.php operation/network/network_explorer.php
operation/vsual_console/pure_ajax.php

View File

@ -14,6 +14,8 @@
global $config; global $config;
global $statusProcessInDB; global $statusProcessInDB;
use PandoraFMS\User;
check_login(); check_login();
require_once $config['homedir'].'/include/functions_visual_map.php'; require_once $config['homedir'].'/include/functions_visual_map.php';
@ -753,8 +755,8 @@ if (!defined('METACONSOLE')) {
$url_view = 'index.php?sec=screen&sec2=screens/screens&action=visualmap&pure=0&id_visualmap='.$idVisualConsole.'&refr='.$view_refresh; $url_view = 'index.php?sec=screen&sec2=screens/screens&action=visualmap&pure=0&id_visualmap='.$idVisualConsole.'&refr='.$view_refresh;
} }
// Hash for auto-auth in public link // Hash for auto-auth in public link.
$hash = md5($config['dbpass'].$idVisualConsole.$config['id_user']); $hash = User::generatePublicHash();
$buttons = []; $buttons = [];

View File

@ -867,6 +867,7 @@ class HTML
} }
$output .= '<ul class="wizard">'.$output_submit.'</ul>'; $output .= '<ul class="wizard">'.$output_submit.'</ul>';
$output .= html_print_csrf_hidden(true);
$output .= '</form>'; $output .= '</form>';
$output .= '<script>'.$js.'</script>'; $output .= '<script>'.$js.'</script>';
if ($rawjs) { if ($rawjs) {
@ -1002,6 +1003,7 @@ class HTML
$output .= '</div>'; $output .= '</div>';
$output .= '<ul class="wizard">'.$output_submit.'</ul>'; $output .= '<ul class="wizard">'.$output_submit.'</ul>';
$output .= html_print_csrf_hidden(true);
$output .= '</form>'; $output .= '</form>';
$output .= '<script>'.$js.'</script>'; $output .= '<script>'.$js.'</script>';
if ($rawjs) { if ($rawjs) {
@ -1073,6 +1075,7 @@ class HTML
$output .= '</div>'; $output .= '</div>';
$output .= '<ul class="wizard">'.$output_submit.'</ul>'; $output .= '<ul class="wizard">'.$output_submit.'</ul>';
$output .= html_print_csrf_hidden(true);
$output .= '</form>'; $output .= '</form>';
$output .= '<script>'.$js.'</script>'; $output .= '<script>'.$js.'</script>';
if ($rawjs) { if ($rawjs) {

View File

@ -20,7 +20,7 @@
/** /**
* Pandora build version and version * Pandora build version and version
*/ */
$build_version = 'PC210518'; $build_version = 'PC210525';
$pandora_version = 'v7.0NG.754'; $pandora_version = 'v7.0NG.754';
// Do not overwrite default timezone set if defined. // Do not overwrite default timezone set if defined.

View File

@ -12818,8 +12818,10 @@ function api_set_create_event($id, $trash1, $other, $returnType)
$error_msg = ''; $error_msg = '';
if ($other['data'][2] != '') { if ($other['data'][2] != '') {
// Id agent assignment. If come from pandora_revent, id_agent can be 0.
$id_agent = $other['data'][2]; $id_agent = $other['data'][2];
if (is_metaconsole()) { // To the next if is metaconsole and id_agent is not none.
if (is_metaconsole() === true && $id_agent > 0) {
// On metaconsole, connect with the node to check the permissions // On metaconsole, connect with the node to check the permissions
if (empty($values['server_id'])) { if (empty($values['server_id'])) {
$agent_cache = db_get_row('tmetaconsole_agent', 'id_tagente', $id_agent); $agent_cache = db_get_row('tmetaconsole_agent', 'id_tagente', $id_agent);
@ -12842,7 +12844,7 @@ function api_set_create_event($id, $trash1, $other, $returnType)
$values['id_agente'] = $id_agent; $values['id_agente'] = $id_agent;
if (!util_api_check_agent_and_print_error($id_agent, 'string', 'AR')) { if ((int) $id_agent > 0 && util_api_check_agent_and_print_error($id_agent, 'string', 'AR') === false) {
if (is_metaconsole()) { if (is_metaconsole()) {
metaconsole_restore_db(); metaconsole_restore_db();
} }

View File

@ -3152,10 +3152,6 @@ function events_get_agent(
} }
} }
if (is_metaconsole() === true && empty($id_server) === false) {
$sql_where .= ' AND server_id = '.$id_server;
}
if ($show_summary_group) { if ($show_summary_group) {
return events_get_events_grouped( return events_get_events_grouped(
$sql_where, $sql_where,
@ -3169,7 +3165,7 @@ function events_get_agent(
} else { } else {
return events_get_events_no_grouped( return events_get_events_no_grouped(
$sql_where, $sql_where,
(is_metaconsole() === true && empty($id_server) === false) ? true : false, (is_metaconsole() === true && (int) $id_server === 0) ? true : false,
$history $history
); );
} }

View File

@ -4306,10 +4306,14 @@ function html_print_sort_arrows($params, $order_tag, $up='up', $down='down')
/** /**
* Print an input hidden with a new csrf token generated * Print an input hidden with a new csrf token generated
*
* @param boolean $return If it is true return a string with the output instead to echo the output.
*
* @return void
*/ */
function html_print_csrf_hidden() function html_print_csrf_hidden(bool $return=false)
{ {
html_print_input_hidden('csrf_code', generate_csrf_code()); return html_print_input_hidden('csrf_code', generate_csrf_code(), $return);
} }

View File

@ -1837,6 +1837,7 @@ function reporting_event_report_group(
$content['name'] = __('Event Report Group'); $content['name'] = __('Event Report Group');
} }
$id_meta = 0;
if (is_metaconsole() === true && empty($content['server_name']) === false) { if (is_metaconsole() === true && empty($content['server_name']) === false) {
$id_meta = metaconsole_get_id_server($content['server_name']); $id_meta = metaconsole_get_id_server($content['server_name']);
$server = metaconsole_get_connection_by_id($id_meta); $server = metaconsole_get_connection_by_id($id_meta);
@ -1928,7 +1929,7 @@ function reporting_event_report_group(
true, true,
false, false,
false, false,
false, $id_meta,
$filter_event_filter_exclude $filter_event_filter_exclude
); );
@ -2176,10 +2177,6 @@ function reporting_event_report_module(
); );
} }
if (is_metaconsole()) {
metaconsole_restore_db();
}
$return['description'] = $content['description']; $return['description'] = $content['description'];
$return['show_extended_events'] = $content['show_extended_events']; $return['show_extended_events'] = $content['show_extended_events'];
$return['date'] = reporting_get_date_text($report, $content); $return['date'] = reporting_get_date_text($report, $content);
@ -2241,7 +2238,7 @@ function reporting_event_report_module(
$return['data'] = array_reverse($data); $return['data'] = array_reverse($data);
} }
if ($config['metaconsole']) { if (is_metaconsole() === true) {
metaconsole_restore_db(); metaconsole_restore_db();
} }
@ -3242,10 +3239,6 @@ function reporting_event_report_agent(
); );
} }
if ($config['metaconsole']) {
metaconsole_restore_db();
}
$label = (isset($content['style']['label'])) ? $content['style']['label'] : ''; $label = (isset($content['style']['label'])) ? $content['style']['label'] : '';
if ($label != '') { if ($label != '') {
$label = reporting_label_macro( $label = reporting_label_macro(
@ -3292,9 +3285,14 @@ function reporting_event_report_agent(
$filter_event_type, $filter_event_type,
$filter_event_status, $filter_event_status,
$filter_event_filter_search, $filter_event_filter_search,
$filter_event_filter_exclude $filter_event_filter_exclude,
$id_server
); );
if (is_metaconsole() === true) {
metaconsole_restore_db();
}
reporting_set_conf_charts( reporting_set_conf_charts(
$width, $width,
$height, $height,
@ -9580,12 +9578,21 @@ function reporting_get_module_detailed_event(
* It construct a table object with all the grouped events happened in an agent * It construct a table object with all the grouped events happened in an agent
* during a period of time. * during a period of time.
* *
* @param mixed Agent id(s) to get the report from. * @param mixed $id_agents Agent id(s) to get the report from.
* @param int Period of time (in seconds) to get the report. * @param integer $period Period of time (in seconds) to get the report.
* @param int Beginning date (unixtime) of the report * @param integer $date Beginning date (unixtime) of the report.
* @param bool Flag to return or echo the report table (echo by default). * @param boolean $return Flag to return or echo the report table (echo by default).
* @param boolean $only_data Only data.
* @param boolean $history History.
* @param boolean $show_summary_group Show summary group.
* @param boolean $filter_event_severity Filter.
* @param boolean $filter_event_type Filter.
* @param boolean $filter_event_status Filter.
* @param boolean $filter_event_filter_search Filter.
* @param boolean $filter_event_filter_exclude Filter.
* @param integer $id_server Id server.
* *
* @return A table object (XHTML) * @return array table object (XHTML)
*/ */
function reporting_get_agents_detailed_event( function reporting_get_agents_detailed_event(
$id_agents, $id_agents,
@ -9599,7 +9606,8 @@ function reporting_get_agents_detailed_event(
$filter_event_type=false, $filter_event_type=false,
$filter_event_status=false, $filter_event_status=false,
$filter_event_filter_search=false, $filter_event_filter_search=false,
$filter_event_filter_exclude=false $filter_event_filter_exclude=false,
$id_server=0
) { ) {
global $config; global $config;
@ -9634,7 +9642,7 @@ function reporting_get_agents_detailed_event(
false, false,
false, false,
false, false,
false, $id_server,
$filter_event_filter_exclude $filter_event_filter_exclude
); );

View File

@ -1151,7 +1151,9 @@ function dashboardLoadVC(settings) {
300 * 1000, 300 * 1000,
handleUpdate, handleUpdate,
beforeUpdate, beforeUpdate,
settings.size settings.size,
settings.id_user,
settings.hash
); );
} }

View File

@ -17,6 +17,9 @@
* @param {function | null} onUpdate Callback which will be execuded when the Visual Console. * @param {function | null} onUpdate Callback which will be execuded when the Visual Console.
* is updated. It will receive two arguments with the old and the new Visual Console's * is updated. It will receive two arguments with the old and the new Visual Console's
* data structure. * data structure.
* @param {string|null} id_user User id given for public access.
* @param {string|null} hash Authorization hash given for public access.
*
* @return {VisualConsole | null} The Visual Console instance or a null value. * @return {VisualConsole | null} The Visual Console instance or a null value.
*/ */
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
@ -28,7 +31,9 @@ function createVisualConsole(
updateInterval, updateInterval,
onUpdate, onUpdate,
beforeUpdate, beforeUpdate,
size size,
id_user,
hash
) { ) {
if (container == null || props == null || items == null) return null; if (container == null || props == null || items == null) return null;
if (baseUrl == null) baseUrl = ""; if (baseUrl == null) baseUrl = "";
@ -46,6 +51,8 @@ function createVisualConsole(
baseUrl, baseUrl,
visualConsoleId, visualConsoleId,
size, size,
id_user,
hash,
function(error, data) { function(error, data) {
if (error) { if (error) {
//Remove spinner change VC. //Remove spinner change VC.
@ -69,7 +76,7 @@ function createVisualConsole(
"[API]", "[API]",
error.message error.message
); );
done(); abortable.abort();
return; return;
} }
@ -651,6 +658,8 @@ function createVisualConsole(
* Fetch a Visual Console's structure and its items. * Fetch a Visual Console's structure and its items.
* @param {string} baseUrl Base URL to build the API path. * @param {string} baseUrl Base URL to build the API path.
* @param {number} vcId Identifier of the Visual Console. * @param {number} vcId Identifier of the Visual Console.
* @param {string|null} id_user User id given for public access.
* @param {string|null} hash Authorization hash given for public access.
* @param {function} callback Function to be executed on request success or fail. * @param {function} callback Function to be executed on request success or fail.
* On success, the function will receive an object with the next properties: * On success, the function will receive an object with the next properties:
* - `props`: object with the Visual Console's data structure. * - `props`: object with the Visual Console's data structure.
@ -658,7 +667,7 @@ function createVisualConsole(
* @return {Object} Cancellable. Object which include and .abort([statusText]) function. * @return {Object} Cancellable. Object which include and .abort([statusText]) function.
*/ */
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
function loadVisualConsoleData(baseUrl, vcId, size, callback) { function loadVisualConsoleData(baseUrl, vcId, size, id_user, hash, callback) {
// var apiPath = baseUrl + "/include/rest-api"; // var apiPath = baseUrl + "/include/rest-api";
var apiPath = baseUrl + "/ajax.php"; var apiPath = baseUrl + "/ajax.php";
var vcJqXHR = null; var vcJqXHR = null;
@ -720,7 +729,9 @@ function loadVisualConsoleData(baseUrl, vcId, size, callback) {
{ {
page: "include/rest-api/index", page: "include/rest-api/index",
getVisualConsole: 1, getVisualConsole: 1,
visualConsoleId: vcId visualConsoleId: vcId,
id_user: typeof id_user == undefined ? id_user : null,
auth_hash: typeof hash == undefined ? hash : null
}, },
"json" "json"
) )
@ -735,7 +746,9 @@ function loadVisualConsoleData(baseUrl, vcId, size, callback) {
page: "include/rest-api/index", page: "include/rest-api/index",
getVisualConsoleItems: 1, getVisualConsoleItems: 1,
size: size, size: size,
visualConsoleId: vcId visualConsoleId: vcId,
id_user: typeof id_user == undefined ? id_user : null,
auth_hash: typeof hash == undefined ? hash : null
}, },
"json" "json"
) )

View File

@ -5,11 +5,12 @@ namespace PandoraFMS\Dashboard;
use PandoraFMS\View; use PandoraFMS\View;
use PandoraFMS\Dashboard\Cell; use PandoraFMS\Dashboard\Cell;
use PandoraFMS\PublicLogin;
/** /**
* Dashboard manager. * Dashboard manager.
*/ */
class Manager class Manager implements PublicLogin
{ {
/** /**

View File

@ -29,7 +29,7 @@
namespace PandoraFMS\Dashboard; namespace PandoraFMS\Dashboard;
// Load Visual Console. // Load Visual Console.
use Models\VisualConsole\Container as VisualConsole; use Models\VisualConsole\Container as VisualConsole;
use PandoraFMS\User;
/** /**
* Maps by users Widgets. * Maps by users Widgets.
*/ */
@ -498,6 +498,8 @@ class MapsMadeByUser extends Widget
'ratio' => $ratio_t, 'ratio' => $ratio_t,
'size' => $size, 'size' => $size,
'cellId' => $this->cellId, 'cellId' => $this->cellId,
'hash' => User::generatePublicHash(),
'id_user' => $config['id_user'],
] ]
); );

View File

@ -0,0 +1,61 @@
<?php
/**
* Public access interface to provide access using hash and id_user.
*
* @category Interfaces
* @package Pandora FMS
* @subpackage Login
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Begin.
namespace PandoraFMS;
interface PublicLogin
{
/**
* Generates a hash to authenticate in public views.
*
* @param string|null $other_secret If you need to authenticate using a
* varable string, use this 'other_secret' to customize the hash.
*
* @return string Returns a hash with the authenticaction.
*/
public static function generatePublicHash(?string $other_secret=''):string;
/**
* Validates a hash to authenticate in public view.
*
* @param string $hash Hash to be checked.
* @param string $other_secret Any custom string needed for you.
*
* @return boolean Returns true if hash is valid.
*/
public static function validatePublicHash(
string $hash,
string $other_secret=''
):bool;
}

View File

@ -32,7 +32,7 @@ namespace PandoraFMS;
/** /**
* Object user. * Object user.
*/ */
class User class User implements PublicLogin
{ {
/** /**
@ -53,11 +53,11 @@ class User
/** /**
* Initializes a user object. * Initializes a user object.
* *
* @param array $data User information * @param array|null $data User information.
* - Username * - Username
* - PHP session ID. * - PHP session ID.
*/ */
public function __construct($data) public function __construct(?array $data)
{ {
global $config; global $config;
@ -88,17 +88,20 @@ class User
if (isset($data['id_usuario']) === true if (isset($data['id_usuario']) === true
&& isset($data['password']) === true && isset($data['password']) === true
) { ) {
$user_in_db = process_user_login($user, $password, true); $user_in_db = process_user_login(
$data['id_usuario'],
$data['password'],
true
);
if ($user_in_db !== false) { if ($user_in_db !== false) {
$config['id_usuario'] = $user_in_db; $config['id_usuario'] = $user_in_db;
$correctLogin = true;
// Originally at api.php. // Originally at api.php.
if (session_status() === PHP_SESSION_NONE) { if (session_status() === PHP_SESSION_NONE) {
session_start(); session_start();
} }
$_SESSION['id_usuario'] = $user; $_SESSION['id_usuario'] = $data['id_usuario'];
session_write_close(); session_write_close();
$this->idUser = $data['id_usuario']; $this->idUser = $data['id_usuario'];
@ -113,4 +116,81 @@ class User
} }
/**
* Generates a hash to authenticate in public views.
*
* @param string|null $other_secret If you need to authenticate using a
* varable string, use this 'other_secret' to customize the hash.
*
* @return string Returns a hash with the authenticaction.
*/
public static function generatePublicHash(?string $other_secret=''):string
{
global $config;
$str = $config['dbpass'];
$str .= $config['id_user'];
$str .= $other_secret;
return hash('sha256', $str);
}
/**
* Validates a hash to authenticate in public view.
*
* @param string $hash Hash to be checked.
* @param string $other_secret Any custom string needed for you.
*
* @return boolean Returns true if hash is valid.
*/
public static function validatePublicHash(
string $hash,
string $other_secret=''
):bool {
global $config;
if (isset($config['id_user']) === true) {
// Already logged in.
return true;
}
$userFromParams = false;
// Try to get id_user from parameters if it is missing.
if (isset($config['id_user']) === false) {
$userFromParams = true;
$config['id_user'] = get_parameter('id_user', false);
// It is impossible to authenticate without an id user.
if ($config['id_user'] === false) {
unset($config['id_user']);
return false;
}
} else {
$config['public_access'] = false;
}
// Build a hash to check.
$hashCheck = self::generatePublicHash($other_secret);
if ($hashCheck === $hash) {
// "Log" user in.
if (session_status() !== PHP_SESSION_ACTIVE) {
session_start();
}
$_SESSION['id_usuario'] = $config['id_user'];
session_write_close();
$config['public_access'] = true;
$config['force_instant_logout'] = true;
return true;
}
// Remove id user from config array if authentication has failed.
if ($userFromParams === true) {
unset($config['id_user']);
}
return false;
}
} }

View File

@ -148,7 +148,7 @@ class WebSocketUser
* Initializes a websocket user. * Initializes a websocket user.
* *
* @param string $id Id of the new user. * @param string $id Id of the new user.
* @param Socket $socket Socket where communication is stablished. * @param \Socket $socket Socket where communication is stablished.
*/ */
public function __construct($id, $socket) public function __construct($id, $socket)
{ {

View File

@ -1071,9 +1071,8 @@ class Item extends CachedModel
$mobile_navigation = false; $mobile_navigation = false;
if (isset($_SERVER['PHP_SELF']) === true if (strstr(($_SERVER['PHP_SELF'] ?? ''), 'mobile/') !== false
&& (strstr($_SERVER['PHP_SELF'], 'mobile/') !== false || strstr(($_SERVER['HTTP_REFERER'] ?? ''), 'mobile/') !== false
|| strstr($_SERVER['HTTP_REFERER'], 'mobile/') !== false)
) { ) {
$mobile_navigation = true; $mobile_navigation = true;
} }

View File

@ -2,6 +2,10 @@
display: inline-block; display: inline-block;
} }
#rules {
display: block;
}
li#li-buttons-alert-list > div { li#li-buttons-alert-list > div {
margin-left: 10px; margin-left: 10px;
} }
@ -131,11 +135,14 @@ div.target {
width: 100%; width: 100%;
} }
div.target.flex { div.target.flex {
display: block;
border: 2px dashed #ddd; border: 2px dashed #ddd;
margin-left: 0em; margin-left: 0em;
margin-top: 10px; margin-top: 10px;
padding: 1em; padding: 1em;
display: flex;
flex-direction: row;
flex-wrap: wrap;
height: fit-content;
} }
.fields, .fields,
@ -188,6 +195,8 @@ div#rules.show {
font-weight: 600; font-weight: 600;
background-color: #333; background-color: #333;
word-break: break-all; word-break: break-all;
height: fit-content;
min-height: 2.3em;
} }
.field.opacityElements { .field.opacityElements {
@ -213,6 +222,11 @@ div#rules.show {
background-color: #82b92e; background-color: #82b92e;
} }
.variable:empty::before {
content: "empty";
font-style: italic;
}
.modifier { .modifier {
background-color: #cba9d2; background-color: #cba9d2;
} }

View File

@ -129,7 +129,7 @@
<div style='height: 10px'> <div style='height: 10px'>
<?php <?php
$version = '7.0NG.754'; $version = '7.0NG.754';
$build = '210518'; $build = '210525';
$banner = "v$version Build $build"; $banner = "v$version Build $build";
error_reporting(0); error_reporting(0);

View File

@ -153,7 +153,7 @@ if (is_ajax()) {
// Case. // Case.
'lower', 'lower',
// NoACL. // NoACL.
true, false,
// ChildGroups. // ChildGroups.
$recursion, $recursion,
// Serialized. // Serialized.

View File

@ -15,7 +15,11 @@
// The session is configured and started inside the config process. // The session is configured and started inside the config process.
require_once '../../include/config.php'; require_once '../../include/config.php';
// Set root on homedir, as defined in setup require_once $config['homedir'].'/vendor/autoload.php';
use PandoraFMS\User;
// Set root on homedir, as defined in setup.
chdir($config['homedir']); chdir($config['homedir']);
ob_start(); ob_start();
@ -61,10 +65,13 @@ $id_layout = (int) get_parameter('id_layout');
$graph_javascript = (bool) get_parameter('graph_javascript'); $graph_javascript = (bool) get_parameter('graph_javascript');
$config['id_user'] = get_parameter('id_user'); $config['id_user'] = get_parameter('id_user');
$myhash = md5($config['dbpass'].$id_layout.$config['id_user']); // Check input hash.
if (User::validatePublicHash($hash) !== true) {
// Check input hash db_pandora_audit(
if ($myhash != $hash) { 'Invalid public visual console',
'Trying to access public visual console'
);
include 'general/noaccess.php';
exit; exit;
} }

View File

@ -13,6 +13,8 @@
// GNU General Public License for more details. // GNU General Public License for more details.
global $config; global $config;
use PandoraFMS\User;
// Login check // Login check
require_once $config['homedir'].'/include/functions_visual_map.php'; require_once $config['homedir'].'/include/functions_visual_map.php';
ui_require_css_file('visual_maps'); ui_require_css_file('visual_maps');
@ -122,7 +124,9 @@ $options['consoles_list']['text'] = '<a href="index.php?sec=network&sec2=godmode
if ($vconsole_write || $vconsole_manage) { if ($vconsole_write || $vconsole_manage) {
$url_base = 'index.php?sec=network&sec2=godmode/reporting/visual_console_builder&action='; $url_base = 'index.php?sec=network&sec2=godmode/reporting/visual_console_builder&action=';
$hash = md5($config['dbpass'].$id_layout.$config['id_user']); // Hash for auto-auth in public link.
$hash = User::generatePublicHash();
$options['public_link']['text'] = '<a href="'.ui_get_full_url( $options['public_link']['text'] = '<a href="'.ui_get_full_url(
'operation/visual_console/public_console.php?hash='.$hash.'&id_layout='.$id_layout.'&id_user='.$config['id_user'] 'operation/visual_console/public_console.php?hash='.$hash.'&id_layout='.$id_layout.'&id_user='.$config['id_user']

View File

@ -16,6 +16,10 @@
require_once '../../include/config.php'; require_once '../../include/config.php';
$legacy = (bool) get_parameter('legacy', $config['legacy_vc']); $legacy = (bool) get_parameter('legacy', $config['legacy_vc']);
if (is_metaconsole() === true) {
$config['requirements_use_base_url'] = true;
}
if ($legacy === false) { if ($legacy === false) {
include_once $config['homedir'].'/operation/visual_console/public_view.php'; include_once $config['homedir'].'/operation/visual_console/public_view.php';
} else { } else {

View File

@ -13,6 +13,8 @@
// GNU General Public License for more details. // GNU General Public License for more details.
require_once '../../include/config.php'; require_once '../../include/config.php';
use PandoraFMS\User;
// Set root on homedir, as defined in setup. // Set root on homedir, as defined in setup.
chdir($config['homedir']); chdir($config['homedir']);
@ -67,10 +69,13 @@ if (!isset($config['pure'])) {
$config['pure'] = 0; $config['pure'] = 0;
} }
$myhash = md5($config['dbpass'].$visualConsoleId.$config['id_user']);
// Check input hash. // Check input hash.
if ($myhash != $hash) { if (User::validatePublicHash($hash) !== true) {
db_pandora_audit(
'Invalid public visual console',
'Trying to access public visual console'
);
include 'general/noaccess.php';
exit; exit;
} }
@ -259,7 +264,15 @@ $visualConsoleItems = VisualConsole::getItemsFromDB(
items, items,
baseUrl, baseUrl,
<?php echo ($refr * 1000); ?>, <?php echo ($refr * 1000); ?>,
handleUpdate handleUpdate,
// BeforeUpdate.
null,
// Size.
null,
// User id.
"<?php echo get_parameter('id_user', ''); ?>",
// Hash.
"<?php echo get_parameter('hash', ''); ?>"
); );
var controls = document.getElementById('vc-controls'); var controls = document.getElementById('vc-controls');

View File

@ -1,314 +0,0 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
global $config;
// Login check
require_once $config['homedir'].'/include/functions_visual_map.php';
check_login();
if (!defined('METACONSOLE')) {
$id_layout = (int) get_parameter('id');
} else {
$id_layout = (int) get_parameter('id_visualmap');
}
if ($id_layout) {
$default_action = 'edit';
} else {
$default_action = 'new';
}
if (!defined('METACONSOLE')) {
$action = get_parameterBetweenListValues(
'action',
[
'new',
'save',
'edit',
'update',
'delete',
],
$default_action
);
} else {
$action = get_parameterBetweenListValues(
'action2',
[
'new',
'save',
'edit',
'update',
'delete',
],
$default_action
);
}
$refr = (int) get_parameter('refr', $config['vc_refr']);
$graph_javascript = (bool) get_parameter('graph_javascript', false);
$vc_refr = false;
if (isset($config['vc_refr']) and $config['vc_refr'] != 0) {
$view_refresh = $config['vc_refr'];
} else {
$view_refresh = '300';
}
// Get input parameter for layout id
if (! $id_layout) {
db_pandora_audit(
'ACL Violation',
'Trying to access visual console without id layout'
);
include 'general/noaccess.php';
exit;
}
$layout = db_get_row('tlayout', 'id', $id_layout);
if (! $layout) {
db_pandora_audit(
'ACL Violation',
'Trying to access visual console without id layout'
);
include 'general/noaccess.php';
exit;
}
$id_group = $layout['id_group'];
$layout_name = $layout['name'];
$background = $layout['background'];
$bwidth = $layout['width'];
$bheight = $layout['height'];
$pure_url = '&pure='.$config['pure'];
// ACL
$vconsole_read = check_acl($config['id_user'], $id_group, 'VR');
$vconsole_write = check_acl($config['id_user'], $id_group, 'VW');
$vconsole_manage = check_acl($config['id_user'], $id_group, 'VM');
if (! $vconsole_read && !$vconsole_write && !$vconsole_manage) {
db_pandora_audit(
'ACL Violation',
'Trying to access visual console without group access'
);
include 'general/noaccess.php';
exit;
}
// Render map
$options = [];
$options['consoles_list']['text'] = '<a href="index.php?sec=network&sec2=godmode/reporting/map_builder&refr='.$refr.'">'.html_print_image(
'images/visual_console.png',
true,
['title' => __('Visual consoles list')]
).'</a>';
if ($vconsole_write || $vconsole_manage) {
$url_base = 'index.php?sec=network&sec2=godmode/reporting/visual_console_builder&action=';
$hash = md5($config['dbpass'].$id_layout.$config['id_user']);
$options['public_link']['text'] = '<a href="'.ui_get_full_url('operation/visual_console/public_console.php?hash='.$hash.'&id_layout='.$id_layout.'&id_user='.$config['id_user']).'" target="_blank">'.html_print_image(
'images/camera_mc.png',
true,
[
'title' => __('Show link to public Visual Console'),
'class' => 'invert_filter',
]
).'</a>';
$options['public_link']['active'] = false;
$options['data']['text'] = '<a href="'.$url_base.$action.'&tab=data&id_visual_console='.$id_layout.'">'.html_print_image(
'images/op_reporting.png',
true,
[
'title' => __('Main data'),
'class' => 'invert_filter',
]
).'</a>';
$options['list_elements']['text'] = '<a href="'.$url_base.$action.'&tab=list_elements&id_visual_console='.$id_layout.'">'.html_print_image(
'images/list.png',
true,
[
'title' => __('List elements'),
'class' => 'invert_filter',
]
).'</a>';
if (enterprise_installed()) {
$options['wizard_services']['text'] = '<a href="'.$url_base.$action.'&tab=wizard_services&id_visual_console='.$id_layout.'">'.html_print_image(
'images/wand_services.png',
true,
[
'title' => __('Services wizard'),
'class' => 'invert_filter',
]
).'</a>';
}
$options['wizard']['text'] = '<a href="'.$url_base.$action.'&tab=wizard&id_visual_console='.$id_layout.'">'.html_print_image(
'images/wand.png',
true,
[
'title' => __('Wizard'),
'class' => 'invert_filter',
]
).'</a>';
$options['editor']['text'] = '<a href="'.$url_base.$action.'&tab=editor&id_visual_console='.$id_layout.'">'.html_print_image(
'images/builder.png',
true,
[
'title' => __('Builder'),
'class' => 'invert_filter',
]
).'</a>';
}
$options['view']['text'] = '<a href="index.php?sec=network&sec2=operation/visual_console/render_view&id='.$id_layout.'&refr='.$view_refresh.'">'.html_print_image(
'images/eye.png',
true,
[
'title' => __('View'),
'class' => 'invert_filter',
]
).'</a>';
$options['view']['active'] = true;
if (!is_metaconsole()) {
if (!$config['pure']) {
$options['pure']['text'] = '<a href="index.php?sec=network&sec2=operation/visual_console/render_view&id='.$id_layout.'&refr='.$refr.'&pure=1">'.html_print_image(
'images/full_screen.png',
true,
[
'title' => __('Full screen mode'),
'class' => 'invert_filter',
]
).'</a>';
ui_print_page_header($layout_name, 'images/visual_console.png', false, '', false, $options);
}
// Set the hidden value for the javascript
html_print_input_hidden('metaconsole', 0);
} else {
// Set the hidden value for the javascript
html_print_input_hidden('metaconsole', 1);
}
visual_map_print_visual_map(
$id_layout,
true,
true,
null,
null,
'',
false,
$graph_javascript
);
?>
<style type="text/css">
/* Avoid the main_pure container 1000px height */
body.pure {
min-height: 100px;
}
div#main_pure {
height: 100%;
margin: 0px;
}
</style>
<?php
ui_require_javascript_file('wz_jsgraphics');
ui_require_javascript_file('pandora_visual_console');
$ignored_params['refr'] = '';
?>
<script language="javascript" type="text/javascript">
$(document).ready (function () {
var refr = <?php echo (int) $refr; ?>;
var pure = <?php echo (int) $config['pure']; ?>;
var href = "<?php echo ui_get_url_refresh($ignored_params); ?>";
$(".module_graph .menu_graph").css('display','none');
$(".parent_graph").each(function(){
if($(this).css('background-color') != 'rgb(255, 255, 255)'){
$(this).css('color', '#999');
}
});
$(".overlay").removeClass("overlay").addClass("overlaydisabled");
});
$(window).on('load', function () {
$('.item:not(.icon) img').each(function(){
if($(this).css('float')=='left' || $(this).css('float')=='right'){
$(this).css('margin-top',(parseInt($(this).parent().parent().css('height'))/2-parseInt($(this).css('height'))/2)+'px');
$(this).css('margin-left','');
}
else{
$(this).css('margin-left',(parseInt($(this).parent().parent().css('width'))/2-parseInt($(this).css('width'))/2)+'px');
$(this).css('margin-top','');
}
});
$('.item > div').each( function() {
if ($(this).css('float')=='left' || $(this).css('float')=='right') {
if($(this).attr('id').indexOf('clock') || $(this).attr('id').indexOf('overlay')){
$(this).css('margin-top',(parseInt($(this).parent().css('height'))/2-parseInt($(this).css('height'))/2)+'px');
}
else{
$(this).css('margin-top',(parseInt($(this).parent().css('height'))/2-parseInt($(this).css('height'))/2-15)+'px');
}
$(this).css('margin-left','');
}
else {
$(this).css('margin-left',(parseInt($(this).parent().css('width'))/2-parseInt($(this).css('width'))/2)+'px');
$(this).css('margin-top','');
}
});
$('.item > a > div').each(function(){
if($(this).css('float')=='left' || $(this).css('float')=='right'){
$(this).css('margin-top',(parseInt($(this).parent().parent().css('height'))/2-parseInt($(this).css('height'))/2-5)+'px');
$(this).css('margin-left','');
}
else{
$(this).css('margin-left',(parseInt($(this).parent().parent().css('width'))/2-parseInt($(this).css('width'))/2)+'px');
$(this).css('margin-top','');
}
});
$(".graph:not([class~='noresizevc'])").each(function(){
height = parseInt($(this).css("height")) - 30;
$(this).css('height', height);
});
});
</script>

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.754 %define version 7.0NG.754
%define release 210518 %define release 210525
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name httpd %define httpd_name httpd

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.754 %define version 7.0NG.754
%define release 210518 %define release 210525
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name httpd %define httpd_name httpd

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.754 %define version 7.0NG.754
%define release 210518 %define release 210525
%define httpd_name httpd %define httpd_name httpd
# User and Group under which Apache is running # User and Group under which Apache is running
%define httpd_name apache2 %define httpd_name apache2

View File

@ -42,6 +42,8 @@ namespace Composer\Autoload;
*/ */
class ClassLoader class ClassLoader
{ {
private $vendorDir;
// PSR-4 // PSR-4
private $prefixLengthsPsr4 = array(); private $prefixLengthsPsr4 = array();
private $prefixDirsPsr4 = array(); private $prefixDirsPsr4 = array();
@ -57,6 +59,13 @@ class ClassLoader
private $missingClasses = array(); private $missingClasses = array();
private $apcuPrefix; private $apcuPrefix;
private static $registeredLoaders = array();
public function __construct($vendorDir = null)
{
$this->vendorDir = $vendorDir;
}
public function getPrefixes() public function getPrefixes()
{ {
if (!empty($this->prefixesPsr0)) { if (!empty($this->prefixesPsr0)) {
@ -300,6 +309,17 @@ class ClassLoader
public function register($prepend = false) public function register($prepend = false)
{ {
spl_autoload_register(array($this, 'loadClass'), true, $prepend); spl_autoload_register(array($this, 'loadClass'), true, $prepend);
if (null === $this->vendorDir) {
return;
}
if ($prepend) {
self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
} else {
unset(self::$registeredLoaders[$this->vendorDir]);
self::$registeredLoaders[$this->vendorDir] = $this;
}
} }
/** /**
@ -308,6 +328,10 @@ class ClassLoader
public function unregister() public function unregister()
{ {
spl_autoload_unregister(array($this, 'loadClass')); spl_autoload_unregister(array($this, 'loadClass'));
if (null !== $this->vendorDir) {
unset(self::$registeredLoaders[$this->vendorDir]);
}
} }
/** /**
@ -367,6 +391,16 @@ class ClassLoader
return $file; return $file;
} }
/**
* Returns the currently registered loaders indexed by their corresponding vendor directories.
*
* @return self[]
*/
public static function getRegisteredLoaders()
{
return self::$registeredLoaders;
}
private function findFileWithExtension($class, $ext) private function findFileWithExtension($class, $ext)
{ {
// PSR-4 lookup // PSR-4 lookup

View File

@ -113,6 +113,7 @@ return array(
'Models\\VisualConsole\\Items\\Label' => $baseDir . '/include/rest-api/models/VisualConsole/Items/Label.php', 'Models\\VisualConsole\\Items\\Label' => $baseDir . '/include/rest-api/models/VisualConsole/Items/Label.php',
'Models\\VisualConsole\\Items\\Line' => $baseDir . '/include/rest-api/models/VisualConsole/Items/Line.php', 'Models\\VisualConsole\\Items\\Line' => $baseDir . '/include/rest-api/models/VisualConsole/Items/Line.php',
'Models\\VisualConsole\\Items\\ModuleGraph' => $baseDir . '/include/rest-api/models/VisualConsole/Items/ModuleGraph.php', 'Models\\VisualConsole\\Items\\ModuleGraph' => $baseDir . '/include/rest-api/models/VisualConsole/Items/ModuleGraph.php',
'Models\\VisualConsole\\Items\\NetworkLink' => $baseDir . '/include/rest-api/models/VisualConsole/Items/NetworkLink.php',
'Models\\VisualConsole\\Items\\Percentile' => $baseDir . '/include/rest-api/models/VisualConsole/Items/Percentile.php', 'Models\\VisualConsole\\Items\\Percentile' => $baseDir . '/include/rest-api/models/VisualConsole/Items/Percentile.php',
'Models\\VisualConsole\\Items\\SimpleValue' => $baseDir . '/include/rest-api/models/VisualConsole/Items/SimpleValue.php', 'Models\\VisualConsole\\Items\\SimpleValue' => $baseDir . '/include/rest-api/models/VisualConsole/Items/SimpleValue.php',
'Models\\VisualConsole\\Items\\StaticGraph' => $baseDir . '/include/rest-api/models/VisualConsole/Items/StaticGraph.php', 'Models\\VisualConsole\\Items\\StaticGraph' => $baseDir . '/include/rest-api/models/VisualConsole/Items/StaticGraph.php',
@ -320,6 +321,7 @@ return array(
'PandoraFMS\\Module' => $baseDir . '/include/lib/Module.php', 'PandoraFMS\\Module' => $baseDir . '/include/lib/Module.php',
'PandoraFMS\\ModuleStatus' => $baseDir . '/include/lib/ModuleStatus.php', 'PandoraFMS\\ModuleStatus' => $baseDir . '/include/lib/ModuleStatus.php',
'PandoraFMS\\ModuleType' => $baseDir . '/include/lib/ModuleType.php', 'PandoraFMS\\ModuleType' => $baseDir . '/include/lib/ModuleType.php',
'PandoraFMS\\PublicLogin' => $baseDir . '/include/lib/PublicLogin.php',
'PandoraFMS\\User' => $baseDir . '/include/lib/User.php', 'PandoraFMS\\User' => $baseDir . '/include/lib/User.php',
'PandoraFMS\\View' => $baseDir . '/include/lib/View.php', 'PandoraFMS\\View' => $baseDir . '/include/lib/View.php',
'PandoraFMS\\Websockets\\WSManager' => $baseDir . '/include/lib/Websockets/WSManager.php', 'PandoraFMS\\Websockets\\WSManager' => $baseDir . '/include/lib/Websockets/WSManager.php',

View File

@ -25,7 +25,7 @@ class ComposerAutoloaderInitfdecadadce22e6dde51e9535fe4ad7aa
require __DIR__ . '/platform_check.php'; require __DIR__ . '/platform_check.php';
spl_autoload_register(array('ComposerAutoloaderInitfdecadadce22e6dde51e9535fe4ad7aa', 'loadClassLoader'), true, true); spl_autoload_register(array('ComposerAutoloaderInitfdecadadce22e6dde51e9535fe4ad7aa', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInitfdecadadce22e6dde51e9535fe4ad7aa', 'loadClassLoader')); spl_autoload_unregister(array('ComposerAutoloaderInitfdecadadce22e6dde51e9535fe4ad7aa', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());

View File

@ -195,6 +195,7 @@ class ComposerStaticInitfdecadadce22e6dde51e9535fe4ad7aa
'Models\\VisualConsole\\Items\\Label' => __DIR__ . '/../..' . '/include/rest-api/models/VisualConsole/Items/Label.php', 'Models\\VisualConsole\\Items\\Label' => __DIR__ . '/../..' . '/include/rest-api/models/VisualConsole/Items/Label.php',
'Models\\VisualConsole\\Items\\Line' => __DIR__ . '/../..' . '/include/rest-api/models/VisualConsole/Items/Line.php', 'Models\\VisualConsole\\Items\\Line' => __DIR__ . '/../..' . '/include/rest-api/models/VisualConsole/Items/Line.php',
'Models\\VisualConsole\\Items\\ModuleGraph' => __DIR__ . '/../..' . '/include/rest-api/models/VisualConsole/Items/ModuleGraph.php', 'Models\\VisualConsole\\Items\\ModuleGraph' => __DIR__ . '/../..' . '/include/rest-api/models/VisualConsole/Items/ModuleGraph.php',
'Models\\VisualConsole\\Items\\NetworkLink' => __DIR__ . '/../..' . '/include/rest-api/models/VisualConsole/Items/NetworkLink.php',
'Models\\VisualConsole\\Items\\Percentile' => __DIR__ . '/../..' . '/include/rest-api/models/VisualConsole/Items/Percentile.php', 'Models\\VisualConsole\\Items\\Percentile' => __DIR__ . '/../..' . '/include/rest-api/models/VisualConsole/Items/Percentile.php',
'Models\\VisualConsole\\Items\\SimpleValue' => __DIR__ . '/../..' . '/include/rest-api/models/VisualConsole/Items/SimpleValue.php', 'Models\\VisualConsole\\Items\\SimpleValue' => __DIR__ . '/../..' . '/include/rest-api/models/VisualConsole/Items/SimpleValue.php',
'Models\\VisualConsole\\Items\\StaticGraph' => __DIR__ . '/../..' . '/include/rest-api/models/VisualConsole/Items/StaticGraph.php', 'Models\\VisualConsole\\Items\\StaticGraph' => __DIR__ . '/../..' . '/include/rest-api/models/VisualConsole/Items/StaticGraph.php',
@ -402,6 +403,7 @@ class ComposerStaticInitfdecadadce22e6dde51e9535fe4ad7aa
'PandoraFMS\\Module' => __DIR__ . '/../..' . '/include/lib/Module.php', 'PandoraFMS\\Module' => __DIR__ . '/../..' . '/include/lib/Module.php',
'PandoraFMS\\ModuleStatus' => __DIR__ . '/../..' . '/include/lib/ModuleStatus.php', 'PandoraFMS\\ModuleStatus' => __DIR__ . '/../..' . '/include/lib/ModuleStatus.php',
'PandoraFMS\\ModuleType' => __DIR__ . '/../..' . '/include/lib/ModuleType.php', 'PandoraFMS\\ModuleType' => __DIR__ . '/../..' . '/include/lib/ModuleType.php',
'PandoraFMS\\PublicLogin' => __DIR__ . '/../..' . '/include/lib/PublicLogin.php',
'PandoraFMS\\User' => __DIR__ . '/../..' . '/include/lib/User.php', 'PandoraFMS\\User' => __DIR__ . '/../..' . '/include/lib/User.php',
'PandoraFMS\\View' => __DIR__ . '/../..' . '/include/lib/View.php', 'PandoraFMS\\View' => __DIR__ . '/../..' . '/include/lib/View.php',
'PandoraFMS\\Websockets\\WSManager' => __DIR__ . '/../..' . '/include/lib/Websockets/WSManager.php', 'PandoraFMS\\Websockets\\WSManager' => __DIR__ . '/../..' . '/include/lib/Websockets/WSManager.php',

View File

@ -1,5 +1,5 @@
package: pandorafms-server package: pandorafms-server
Version: 7.0NG.754-210518 Version: 7.0NG.754-210525
Architecture: all Architecture: all
Priority: optional Priority: optional
Section: admin Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
pandora_version="7.0NG.754-210518" pandora_version="7.0NG.754-210525"
package_cpan=0 package_cpan=0
package_pandora=1 package_pandora=1

View File

@ -45,7 +45,7 @@ our @EXPORT = qw(
# version: Defines actual version of Pandora Server for this module only # version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.754"; my $pandora_version = "7.0NG.754";
my $pandora_build = "210518"; my $pandora_build = "210525";
our $VERSION = $pandora_version." ".$pandora_build; our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash # Setup hash

View File

@ -34,7 +34,7 @@ our @ISA = qw(Exporter);
# version: Defines actual version of Pandora Server for this module only # version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.754"; my $pandora_version = "7.0NG.754";
my $pandora_build = "210518"; my $pandora_build = "210525";
our $VERSION = $pandora_version." ".$pandora_build; our $VERSION = $pandora_version." ".$pandora_build;
our %EXPORT_TAGS = ( 'all' => [ qw() ] ); our %EXPORT_TAGS = ( 'all' => [ qw() ] );

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_server %define name pandorafms_server
%define version 7.0NG.754 %define version 7.0NG.754
%define release 210518 %define release 210525
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_server %define name pandorafms_server
%define version 7.0NG.754 %define version 7.0NG.754
%define release 210518 %define release 210525
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

@ -9,7 +9,7 @@
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.754" PI_VERSION="7.0NG.754"
PI_BUILD="210518" PI_BUILD="210525"
MODE=$1 MODE=$1
if [ $# -gt 1 ]; then if [ $# -gt 1 ]; then

View File

@ -35,7 +35,7 @@ use PandoraFMS::Config;
use PandoraFMS::DB; use PandoraFMS::DB;
# version: define current version # version: define current version
my $version = "7.0NG.754 Build 210518"; my $version = "7.0NG.754 Build 210525";
# Pandora server configuration # Pandora server configuration
my %conf; my %conf;

View File

@ -36,7 +36,7 @@ use Encode::Locale;
Encode::Locale::decode_argv; Encode::Locale::decode_argv;
# version: define current version # version: define current version
my $version = "7.0NG.754 Build 210518"; my $version = "7.0NG.754 Build 210525";
# save program name for logging # save program name for logging
my $progname = basename($0); my $progname = basename($0);

View File

@ -3,7 +3,7 @@
######################################################################## ########################################################################
# Pandora FMS - Remote Event Tool (via WEB API) # Pandora FMS - Remote Event Tool (via WEB API)
######################################################################## ########################################################################
# Copyright (c) 2013-2021 Artica Soluciones Tecnologicas S.L # Copyright (c) 2021 Artica Soluciones Tecnologicas S.L
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 2 # modify it under the terms of the GNU General Public License version 2
@ -12,6 +12,7 @@
# Includes list # Includes list
use strict; use strict;
use LWP::Simple; use LWP::Simple;
use LWP::UserAgent;
use MIME::Base64; use MIME::Base64;
use lib '/usr/lib/perl5'; use lib '/usr/lib/perl5';
use PandoraFMS::Tools; use PandoraFMS::Tools;
@ -33,12 +34,12 @@ sub help_screen{
Where options:\n Where options:\n
-u <credentials> : API credentials separated by comma: <api_pass>,<user>,<pass> -u <credentials> : API credentials separated by comma: <api_pass>,<user>,<pass>
-name <event_name> : Free text -name <event_name> : Free text (surrounded by single-quotes, for security reasons)
-group <id_group> : Group ID (use 0 for 'all') -group <id_group> : Group ID (use 0 for 'all')
-agent : Agent ID
Optional parameters: Optional parameters:
[-agent <id_agent] : Agent ID
[-status <status>] : 0 New, 1 Validated, 2 In process [-status <status>] : 0 New, 1 Validated, 2 In process
[-user <id_user>] : User comment (use in combination with -comment option) [-user <id_user>] : User comment (use in combination with -comment option)
[-type <event_type>] : unknown, alert_fired, alert_recovered, alert_ceased [-type <event_type>] : unknown, alert_fired, alert_recovered, alert_ceased
@ -57,14 +58,15 @@ Optional parameters:
[-c_instructions <critical_instructions>] [-c_instructions <critical_instructions>]
[-w_instructions <warning_instructions>] [-w_instructions <warning_instructions>]
[-u_instructions <unknown_instructions>] [-u_instructions <unknown_instructions>]
[-user_comment <comment>] [-user_comment <comment>] : Free text (surrounded by single-quotes, for security reasons)
[-owner_user <owner event>] : Use the login name, not the descriptive [-owner_user <owner event>] : Use the login name, not the descriptive
[-source <source>] : (By default 'Pandora') [-source <source>] : (By default 'Pandora')
[-tag <tags>] : Tag (must exist in the system to be imported) [-tag <tags>] : Tag (must exist in the system to be imported)
[-custom_data <custom_data>]: Custom data should be a base 64 encoded JSON document example -custom_data \'{\"test1\" : 1, \"test2\": 2}\' [-custom_data <custom_data>]: Custom data has to be in JSON format. Example: -custom_data \'{\"test1\" : \"t1\", \"test2\": \"2\"}\'
[-id_extra <id extra>] : Id extra [-id_extra <id extra>] : Id extra
[-agent_name <Agent name>] : Agent name, Not to be confused with the alias. [-agent_name <Agent name>] : Agent name, Not to be confused with the alias.
[-force_create_agent<0 o 1>] : Force the creation of agent through an event this will create when it is 1. [-force_create_agent<0 o 1>] : Force the creation of agent through an event this will create when it is 1.
[-separator '<char/s>'] : If you use the vertical bar `|` in the event name, you must set other character for send the info. This must be surrounded by single-quotes
[-server_id <server_id>] : The pandora node server_id\n\n"; [-server_id <server_id>] : The pandora node server_id\n\n";
print "Example of event generation:\n\n"; print "Example of event generation:\n\n";
@ -120,7 +122,7 @@ sub tool_api_main () {
my $db_user; my $db_user;
my $db_pass; my $db_pass;
my @db_info; my @db_info;
my $id_agent; my $id_agent = '0';
my $id_user = ''; my $id_user = '';
my $status = ''; my $status = '';
my $id_agent_module = ''; my $id_agent_module = '';
@ -141,6 +143,7 @@ sub tool_api_main () {
my $call_api; my $call_api;
my $custom_data = ""; my $custom_data = "";
my $server_id = 0; my $server_id = 0;
my $separator = '|';
#~ help or api path (required) #~ help or api path (required)
if ($ARGV[0] eq '-h') { if ($ARGV[0] eq '-h') {
@ -185,12 +188,18 @@ sub tool_api_main () {
if ($line eq '-agent') { if ($line eq '-agent') {
$id_agent = $ARGV[$i + 1]; $id_agent = $ARGV[$i + 1];
# If not defined, send 0 for API.
if ($id_agent eq undef) {
$id_agent = '0';
}
} }
if ($line eq '-group') { if ($line eq '-group') {
$id_group = $ARGV[$i + 1]; $id_group = $ARGV[$i + 1];
} }
if ($line eq '-name') { if ($line eq '-name') {
$event_name = $ARGV[$i + 1]; $event_name = $ARGV[$i + 1];
$event_name =~ s/#/%23/g;
} }
if ($line eq '-type') { if ($line eq '-type') {
$event_type = $ARGV[$i + 1]; $event_type = $ARGV[$i + 1];
@ -250,50 +259,49 @@ sub tool_api_main () {
if ($line eq '-server_id') { if ($line eq '-server_id') {
$server_id = $ARGV[$i + 1]; $server_id = $ARGV[$i + 1];
} }
if ($line eq '-separator') {
$separator = $ARGV[$i + 1];
}
$i++; $i++;
} }
if ($event_name eq "") { if ($event_name eq "") {
print "[ERROR] Missing id agent! Read help info:\n\n"; print "[ERROR] Missing event name! Read help info:\n\n";
help_screen (); help_screen ();
} }
if ($id_group eq "") { if ($id_group eq "") {
print "[ERROR] Missing event group! Read help info:\n\n"; print "[ERROR] Missing event group! Read help info:\n\n";
help_screen (); help_screen ();
} }
if ($id_agent eq "" && $agent_name eq "") {
print "[ERROR] Missing id agent! and agent_name Read help info:\n\n";
help_screen ();
}
$data_event = $event_name . $data_event = $event_name .
"|" . $id_group . $separator . $id_group .
"|" . $id_agent . $separator . $id_agent .
"|" . $status . $separator . $status .
"|" . $id_user . $separator . $id_user .
"|" . $event_type . $separator . $event_type .
"|" . $severity . $separator . $severity .
"|" . $id_agent_module . $separator . $id_agent_module .
"|" . $id_alert_am . $separator . $id_alert_am .
"|" . $critical_instructions . $separator . $critical_instructions .
"|" . $warning_instructions . $separator . $warning_instructions .
"|" . $unknown_instructions . $separator . $unknown_instructions .
"|" . $user_comment . $separator . $user_comment .
"|" . $owner_user . $separator . $owner_user .
"|" . $source . $separator . $source .
"|" . $tags . $separator . $tags .
"|" . $custom_data . $separator . $custom_data .
"|" . $server_id . $separator . $server_id .
"|" . $id_extra . $separator . $id_extra .
"|" . $agent_name . $separator . $agent_name .
"|" . $force_create_agent; $separator . $force_create_agent;
$call_api = $api_path . '?' . $call_api = $api_path . '?' .
'op=set&' . 'op=set&' .
'op2=create_event&' . 'op2=create_event&' .
'other=' . $data_event .'&' . 'other=' . $data_event .'&' .
'other_mode=url_encode_separator_|&' . 'other_mode=url_encode_separator_'.$separator.'&' .
'apipass=' . $api_pass . '&' . 'apipass=' . $api_pass . '&' .
'user=' . $db_user . '&' . 'user=' . $db_user . '&' .
'pass=' . $db_pass; 'pass=' . $db_pass;
@ -321,13 +329,8 @@ sub tool_api_main () {
exit; exit;
} }
else { else {
#-----------DEBUG---------------------------- my $ua = LWP::UserAgent->new(ssl_opts => { verify_hostname => 0 });
#print($call_api . "\n\n\n"); my $content = $ua->get($call_api);
my $content = get($call_api);
#-----------DEBUG----------------------------
#print($content . "\n\n\n");
if ($option eq '-create_event') { if ($option eq '-create_event') {
if ($content eq undef) { if ($content eq undef) {
@ -335,7 +338,7 @@ sub tool_api_main () {
help_screen(); help_screen();
} }
else { else {
print "Event ID: $content"; print "Event ID: $content->{'_content'}";
} }
} }
elsif ($option eq '-validate_event') { elsif ($option eq '-validate_event') {