Merge branch 'develop' into ent-3409-pandora-network-traffic-analyzer-ntop-fork-fase-1

Conflicts:
	pandora_server/lib/PandoraFMS/DataServer.pm

Former-commit-id: 423e2d818730f97ef1ed0a286f717243731b5363
This commit is contained in:
fermin831 2019-01-29 18:15:59 +01:00
commit 78fd6850e7
62 changed files with 3810 additions and 3122 deletions

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.730, AIX version # Version 7.0NG.731, AIX version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.730, FreeBSD Version # Version 7.0NG.731, FreeBSD Version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.730, HP-UX Version # Version 7.0NG.731, HP-UX Version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.730, GNU/Linux # Version 7.0NG.731, GNU/Linux
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.730, GNU/Linux # Version 7.0NG.731, GNU/Linux
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.730, Solaris Version # Version 7.0NG.731, Solaris Version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,6 +1,6 @@
# Base config file for Pandora FMS Windows Agent # Base config file for Pandora FMS Windows Agent
# (c) 2006-2010 Artica Soluciones Tecnologicas # (c) 2006-2010 Artica Soluciones Tecnologicas
# Version 7.0NG.730 # Version 7.0NG.731
# This program is Free Software, you can redistribute it and/or modify it # This program is Free Software, you can redistribute it and/or modify it
# under the terms of the GNU General Public Licence as published by the Free Software # under the terms of the GNU General Public Licence as published by the Free Software

View File

@ -1,6 +1,6 @@
# Fichero de configuracion base de agentes de Pandora # Fichero de configuracion base de agentes de Pandora
# Base config file for Pandora agents # Base config file for Pandora agents
# Version 7.0NG.730, AIX version # Version 7.0NG.731, AIX version
# General Parameters # General Parameters
# ================== # ==================

View File

@ -1,6 +1,6 @@
# Fichero de configuracion base de agentes de Pandora # Fichero de configuracion base de agentes de Pandora
# Base config file for Pandora agents # Base config file for Pandora agents
# Version 7.0NG.730 # Version 7.0NG.731
# FreeBSD/IPSO version # FreeBSD/IPSO version
# Licenced under GPL licence, 2003-2007 Sancho Lerena # Licenced under GPL licence, 2003-2007 Sancho Lerena

View File

@ -1,6 +1,6 @@
# Fichero de configuracion base de agentes de Pandora # Fichero de configuracion base de agentes de Pandora
# Base config file for Pandora agents # Base config file for Pandora agents
# Version 7.0NG.730, HPUX Version # Version 7.0NG.731, HPUX Version
# General Parameters # General Parameters
# ================== # ==================

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.730 # Version 7.0NG.731
# Licensed under GPL license v2, # Licensed under GPL license v2,
# (c) 2003-2010 Artica Soluciones Tecnologicas # (c) 2003-2010 Artica Soluciones Tecnologicas
# please visit http://pandora.sourceforge.net # please visit http://pandora.sourceforge.net

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.730 # Version 7.0NG.731
# Licensed under GPL license v2, # Licensed under GPL license v2,
# (c) 2003-2009 Artica Soluciones Tecnologicas # (c) 2003-2009 Artica Soluciones Tecnologicas
# please visit http://pandora.sourceforge.net # please visit http://pandora.sourceforge.net

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.730 # Version 7.0NG.731
# Licensed under GPL license v2, # Licensed under GPL license v2,
# please visit http://pandora.sourceforge.net # please visit http://pandora.sourceforge.net

View File

@ -1,6 +1,6 @@
# Fichero de configuracion base de agentes de Pandora # Fichero de configuracion base de agentes de Pandora
# Base config file for Pandora agents # Base config file for Pandora agents
# Version 7.0NG.730, Solaris version # Version 7.0NG.731, Solaris version
# General Parameters # General Parameters
# ================== # ==================

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.730, AIX version # Version 7.0NG.731, AIX version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix package: pandorafms-agent-unix
Version: 7.0NG.730-190121 Version: 7.0NG.731
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.730-190121" pandora_version="7.0NG.731"
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

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.730, GNU/Linux # Version 7.0NG.731, GNU/Linux
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2012 Artica Soluciones Tecnologicas # Copyright (c) 2003-2012 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.730, FreeBSD Version # Version 7.0NG.731, FreeBSD Version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2016 Artica Soluciones Tecnologicas # Copyright (c) 2003-2016 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.730, HP-UX Version # Version 7.0NG.731, HP-UX Version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.730, GNU/Linux # Version 7.0NG.731, GNU/Linux
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2014 Artica Soluciones Tecnologicas # Copyright (c) 2003-2014 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.730, GNU/Linux # Version 7.0NG.731, GNU/Linux
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.730, NetBSD Version # Version 7.0NG.731, NetBSD Version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2010 Artica Soluciones Tecnologicas # Copyright (c) 2003-2010 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -1,5 +1,5 @@
# Base config file for Pandora FMS agents # Base config file for Pandora FMS agents
# Version 7.0NG.730, Solaris Version # Version 7.0NG.731, Solaris Version
# Licensed under GPL license v2, # Licensed under GPL license v2,
# Copyright (c) 2003-2009 Artica Soluciones Tecnologicas # Copyright (c) 2003-2009 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -41,8 +41,8 @@ my $Sem = undef;
# Semaphore used to control the number of threads # Semaphore used to control the number of threads
my $ThreadSem = undef; my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.730'; use constant AGENT_VERSION => '7.0NG.731';
use constant AGENT_BUILD => '190121'; use constant AGENT_BUILD => '190129';
# 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

@ -2,8 +2,8 @@
#Pandora FMS Linux Agent #Pandora FMS Linux Agent
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.730 %define version 7.0NG.731
%define release 190121 %define release 1
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -2,8 +2,8 @@
#Pandora FMS Linux Agent #Pandora FMS Linux Agent
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.730 %define version 7.0NG.731
%define release 190121 %define release 1
Summary: Pandora FMS Linux agent, PERL version Summary: Pandora FMS Linux agent, PERL version
Name: %{name} Name: %{name}

View File

@ -9,8 +9,8 @@
# Please see http://www.pandorafms.org. This code is licensed under GPL 2.0 license. # Please see http://www.pandorafms.org. This code is licensed under GPL 2.0 license.
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.730" PI_VERSION="7.0NG.731"
PI_BUILD="190121" PI_BUILD="190129"
OS_NAME=`uname -s` OS_NAME=`uname -s`
FORCE=0 FORCE=0

View File

@ -1,6 +1,6 @@
# Base config file for Pandora FMS Windows Agent # Base config file for Pandora FMS Windows Agent
# (c) 2006-2017 Artica Soluciones Tecnologicas # (c) 2006-2017 Artica Soluciones Tecnologicas
# Version 7.0NG.730 # Version 7.0NG.731
# This program is Free Software, you can redistribute it and/or modify it # This program is Free Software, you can redistribute it and/or modify it
# under the terms of the GNU General Public Licence as published by the Free Software # under the terms of the GNU General Public Licence as published by the Free Software

View File

@ -3,7 +3,7 @@ AllowLanguageSelection
{Yes} {Yes}
AppName AppName
{Pandora FMS Windows Agent v7.0NG.730} {Pandora FMS Windows Agent v7.0NG.731}
ApplicationID ApplicationID
{17E3D2CF-CA02-406B-8A80-9D31C17BD08F} {17E3D2CF-CA02-406B-8A80-9D31C17BD08F}
@ -186,7 +186,7 @@ UpgradeApplicationID
{} {}
Version Version
{190121} {190129}
ViewReadme ViewReadme
{Yes} {Yes}
@ -2387,7 +2387,7 @@ Windows,BuildSeparateArchives
{No} {No}
Windows,Executable Windows,Executable
{<%AppName%>-<%Version%>-Setup<%Ext%>} {<%AppName%>-Setup<%Ext%>}
Windows,FileDescription Windows,FileDescription
{<%AppName%> <%Version%> Setup} {<%AppName%> <%Version%> Setup}

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.730(Build 190121)") #define PANDORA_VERSION ("7.0NG.731(Build 190129)")
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.730(Build 190121))" VALUE "ProductVersion", "(7.0NG.731(Build 190129))"
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.730-190121 Version: 7.0NG.731
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.730-190121" pandora_version="7.0NG.731"
package_pear=0 package_pear=0
package_pandora=1 package_pandora=1

View File

@ -22,8 +22,8 @@
/** /**
* Pandora build version and version * Pandora build version and version
*/ */
$build_version = 'PC190121'; $build_version = 'PC190129';
$pandora_version = 'v7.0NG.730'; $pandora_version = 'v7.0NG.731';
// Do not overwrite default timezone set if defined. // Do not overwrite default timezone set if defined.
$script_tz = @date_default_timezone_get(); $script_tz = @date_default_timezone_get();

View File

@ -1215,30 +1215,29 @@ function mysql_get_fields($table) {
/** /**
* Process a file with an oracle schema sentences. * Process a file with an oracle schema sentences.
* Based on the function which installs the pandoradb.sql schema. * Based on the function which installs the pandoradb.sql schema.
* *
* @param string $path File path. * @param string $path File path.
* @param bool $handle_error Whether to handle the mysqli_query/mysql_query errors or throw an exception. * @param bool $handle_error Whether to handle the mysqli_query/mysql_query errors or throw an exception.
* *
* @return bool Return the final status of the operation. * @return bool Return the final status of the operation.
*/ */
function mysql_db_process_file ($path, $handle_error = true) { function mysql_db_process_file ($path, $handle_error = true) {
global $config; global $config;
if (file_exists($path)) { if (file_exists($path)) {
$file_content = file($path); $file_content = file($path);
$query = ""; $query = "";
// Begin the transaction // Begin the transaction
mysql_db_process_sql_begin(); mysql_db_process_sql_begin();
foreach ($file_content as $sql_line) { foreach ($file_content as $sql_line) {
if (trim($sql_line) != "" && strpos($sql_line, "--") === false) { if (trim($sql_line) != "" && strpos($sql_line, "--") === false) {
$query .= $sql_line; $query .= $sql_line;
if (preg_match("/;[\040]*\$/", $sql_line)) { if (preg_match("/;[\040]*\$/", $sql_line)) {
if ($config["mysqli"]) { if ($config["mysqli"]) {
$query_result = mysqli_query($config['dbconnection'], $query); $query_result = mysqli_query($config['dbconnection'], $query);
} }
else { else {
$query_result = mysql_query($query); $query_result = mysql_query($query);
@ -1246,9 +1245,14 @@ function mysql_db_process_file ($path, $handle_error = true) {
if (!$result = $query_result) { if (!$result = $query_result) {
// Error. Rollback the transaction // Error. Rollback the transaction
mysql_db_process_sql_rollback(); mysql_db_process_sql_rollback();
$error_message = mysql_error(); if($config["mysqli"]){
$error_message = mysqli_error($config['dbconnection']);
}
else{
$error_message = mysql_error();
}
// Handle the error // Handle the error
if ($handle_error) { if ($handle_error) {
$backtrace = debug_backtrace(); $backtrace = debug_backtrace();
@ -1258,7 +1262,7 @@ function mysql_db_process_file ($path, $handle_error = true) {
set_error_handler('db_sql_error_handler'); set_error_handler('db_sql_error_handler');
trigger_error($error); trigger_error($error);
restore_error_handler(); restore_error_handler();
return false; return false;
} }
// Throw an exception with the error message // Throw an exception with the error message
@ -1270,10 +1274,9 @@ function mysql_db_process_file ($path, $handle_error = true) {
} }
} }
} }
// No errors. Commit the transaction // No errors. Commit the transaction
mysql_db_process_sql_commit(); mysql_db_process_sql_commit();
return true; return true;
} }
else { else {

View File

@ -3399,7 +3399,7 @@ function validate_csrf_code() {
} }
function generate_hash_to_api(){ function generate_hash_to_api(){
hash('sha256', db_get_value ('value', 'tupdate_settings', '`key`', 'customer_key')); return (string)hash('sha256', db_get_value ('value', 'tupdate_settings', '`key`', 'customer_key'));
} }
/** /**
@ -3435,4 +3435,85 @@ function pandora_xhprof_display_result($key = "", $method = "link") {
} }
} }
/**
* From a network with a mask remove the smallest ip and the highest
*
* @param string address to identify the network.
* @param string mask to identify the mask network
* @return array or false with smallest ip and highest ip
*/
function range_ips_for_network($address, $mask) {
if(!isset($address) || !isset($mask)){
return false;
}
//convert ip addresses to long form
$address_long = ip2long($address);
$mask_long = ip2long($mask);
//caculate first usable address
$ip_host_first = ((~$mask_long) & $address_long);
$ip_first = ($address_long ^ $ip_host_first) + 1;
//caculate last usable address
$ip_broadcast_invert = ~$mask_long;
$ip_last = ($address_long | $ip_broadcast_invert) - 1;
$range = array(
'first' => long2ip($ip_first),
'last' => long2ip($ip_last)
);
return $range;
}
/**
* from two ips find out if there is such an ip
*
* @param string ip ip wont validate
* @param string ip_lower
* @param string ip_upper
* @return bool true or false if the ip is between the two ips
*/
function is_in_network ($ip, $ip_lower, $ip_upper) {
if(!isset($ip) || !isset($ip_lower) || !isset($ip_upper)){
return false;
}
$ip = (float)sprintf("%u",ip2long($ip));
$ip_lower = (float)sprintf("%u",ip2long($ip_lower));
$ip_upper = (float)sprintf("%u",ip2long($ip_upper));
if ($ip >= $ip_lower && $ip <= $ip_upper){
return true;
} else {
return false;
}
}
/**
*
*/
function ip_belongs_to_network($ip, $network, $mask) {
if ($ip == $network) {
return true;
}
$ranges = range_ips_for_network($network, $mask);
return is_in_network($ip, $ranges['first'], $ranges['last']);
}
/**
* convert the mask to cird format
*
* @param string mask
* @return string true or false if the ip is between the two ips
*/
function mask2cidr($mask){
if(!isset($mask))
return 0;
$long = ip2long($mask);
$base = ip2long('255.255.255.255');
return 32-log(($long ^ $base)+1,2);
}
?> ?>

View File

@ -32,7 +32,6 @@ include_once($config['homedir'] . "/include/functions_servers.php");
include_once($config['homedir'] . "/include/functions_planned_downtimes.php"); include_once($config['homedir'] . "/include/functions_planned_downtimes.php");
include_once($config['homedir'] . "/include/functions_db.php"); include_once($config['homedir'] . "/include/functions_db.php");
include_once($config['homedir'] . "/include/functions_event_responses.php"); include_once($config['homedir'] . "/include/functions_event_responses.php");
include_once($config['homedir'] . "/include/functions_policies.php");
enterprise_include_once ('include/functions_local_components.php'); enterprise_include_once ('include/functions_local_components.php');
enterprise_include_once ('include/functions_events.php'); enterprise_include_once ('include/functions_events.php');
enterprise_include_once ('include/functions_agents.php'); enterprise_include_once ('include/functions_agents.php');
@ -100,6 +99,10 @@ function returnError($typeError, $returnType = 'string') {
returnData($returnType, returnData($returnType,
array('type' => 'string', 'data' => __('No data to show.'))); array('type' => 'string', 'data' => __('No data to show.')));
break; break;
case 'centralized':
returnData($returnType,
array('type' => 'string', 'data' => __('This console is not manager of this environment, please manage this feature from centralized manager console (Metaconsole).')));
break;
default: default:
returnData("string", returnData("string",
array('type' => 'string', 'data' => __($returnType))); array('type' => 'string', 'data' => __($returnType)));
@ -150,7 +153,7 @@ function returnData($returnType, $data, $separator = ';') {
else { else {
if (!empty($data['data'])) { if (!empty($data['data'])) {
foreach ($data['data'] as $dataContent) { foreach ($data['data'] as $dataContent) {
$clean = array_map("array_apply_io_safe_output", $dataContent); $clean = array_map("array_apply_io_safe_output", (array)$dataContent);
foreach ($clean as $k => $v) { foreach ($clean as $k => $v) {
$clean[$k] = str_replace("\r", "\n", $clean[$k]); $clean[$k] = str_replace("\r", "\n", $clean[$k]);
$clean[$k] = str_replace("\n", " ", $clean[$k]); $clean[$k] = str_replace("\n", " ", $clean[$k]);
@ -4560,6 +4563,62 @@ function api_get_alert_template($id_template, $thrash1, $other, $thrash3) {
} }
} }
/**
* List of alert actions.
*
* @param array $other it's array, $other as param is <action_name>;<separator_data> and separator (pass in param
* othermode as othermode=url_encode_separator_<separator>)
* @param $returnType (csv, string or json).
*
* example:
*
* api.php?op=get&op2=alert_actions&apipass=1234&user=admin&pass=pandora&other=Create|;&other_mode=url_encode_separator_|&return_type=json
*
*/
function api_get_alert_actions($thrash1, $thrash2, $other, $returnType) {
global $config;
if (!check_acl($config['id_user'], 0, "LM")) {
returnError('forbidden', 'string');
return;
}
if (!isset($other['data'][0]))
$other['data'][1] = '';
if (!isset($other['data'][1]))
$separator = ';'; //by default
else
$separator = $other['data'][1];
$action_name = $other['data'][0];
$filter = array();
if (!is_user_admin($config['id_user']))
$filter['talert_actions.id_group'] = array_keys(users_get_groups(false, "LM"));
$filter['talert_actions.name'] = "%$action_name%";
$actions = db_get_all_rows_filter (
'talert_actions INNER JOIN talert_commands ON talert_actions.id_alert_command = talert_commands.id',
$filter,
'talert_actions.id, talert_actions.name'
);
if ($actions === false)
$actions = array ();
if ($actions !== false) {
$data['type'] = 'array';
$data['data'] = $actions;
}
if (!$actions) {
returnError('error_get_alert_actions',
__('Error getting alert actions.'));
}
else {
returnData($returnType, $data, $separator);
}
}
/** /**
* Get module groups, and print all the result like a csv. * Get module groups, and print all the result like a csv.
* *
@ -6977,9 +7036,9 @@ function api_get_graph_module_data($id, $thrash1, $other, $thrash2) {
function api_set_new_user($id, $thrash2, $other, $thrash3) { function api_set_new_user($id, $thrash2, $other, $thrash3) {
global $config; global $config;
if (defined ('METACONSOLE')) { // if (defined ('METACONSOLE')) {
return; // return;
} // }
if(!check_acl($config['id_user'], 0, "UM")) { if(!check_acl($config['id_user'], 0, "UM")) {
returnError('forbidden', 'string'); returnError('forbidden', 'string');
@ -6996,6 +7055,10 @@ function api_set_new_user($id, $thrash2, $other, $thrash3) {
$values['phone'] = $other['data'][6]; $values['phone'] = $other['data'][6];
$values['language'] = $other['data'][7]; $values['language'] = $other['data'][7];
$values['comments'] = $other['data'][8]; $values['comments'] = $other['data'][8];
$values['time_autorefresh'] = $other['data'][9];
$values['default_event_filter'] = $other['data'][10];
$values['section'] = $other['data'][11];
$values['session_time'] = $other['data'][12];
if (!create_user ($id, $password, $values)) if (!create_user ($id, $password, $values))
returnError('error_create_user', 'Error create user'); returnError('error_create_user', 'Error create user');
@ -7039,7 +7102,12 @@ function api_set_update_user($id, $thrash2, $other, $thrash3) {
'language', 'language',
'comments', 'comments',
'is_admin', 'is_admin',
'block_size' 'block_size',
'flash_chart',
'time_autorefresh',
'default_event_filter',
'section',
'session_time'
); );
if ($id == "") { if ($id == "") {
@ -7685,6 +7753,94 @@ function api_set_alert_actions($id, $id2, $other, $trash1) {
} }
} }
/**
* Create a new module group
* @param $id as module group name (mandatory)
example:
*http://localhost/pandora_console/include/api.php?op=set&op2=new_module_group&id=Module_group_name&apipass=1234&user=admin&pass=pandora
*/
function api_set_new_module_group($id, $thrash2, $other, $trash1) {
global $config;
if (defined ('METACONSOLE')) {
return;
}
if (!check_acl($config['id_user'], 0, "PM")){
returnError('forbidden', 'string');
return;
}
if ($id == '' || !$id) {
returnError('error_parameter', __('Module group must have a name'));
return;
}
$name = db_get_value ('name', 'tmodule_group', 'name', $id);
if ($name) {
returnError('error_parameter', __('Each module group must have a different name'));
return;
}
$return = db_process_sql_insert('tmodule_group', array('name' => $id));
if ($return === false)
returnError('error_new_moodule_group', 'There was a problem creating group');
else
returnData('string', array('type' => 'string', 'data' => $return));
}
/**
* synchronize module group
* @param $other as server_names (mandatory)
example:
*api.php?op=set&op2=module_group_synch&other=server_name1|server_name2|server_name3&other_mode=url_encode_separator_|&apipass=1234&user=admin&pass=pandora
*/
function api_set_module_group_synch($thrash1, $thrash2, $other, $thrash4) {
global $config;
enterprise_include_once ('meta/include/functions_meta.php');
if (is_metaconsole()) {
if (!check_acl($config['id_user'], 0, "PM")) {
returnError('forbidden', 'string');
return;
}
$targets = array();
foreach ($other['data'] as $server) {
$targets[] = $server;
}
$return = meta_module_group_synchronizing($targets, true);
$module_group_update_err = $return["module_group_update_err"];
$module_group_create_err = $return["module_group_create_err"];
$module_group_update_ok = $return["module_group_update_ok"];
$module_group_create_ok = $return["module_group_create_ok"];
$string_ok = __('Created/Updated %s/%s module groups', $module_group_create_ok, $module_group_update_ok);
// User feedback
if ($module_group_create_err > 0 or $module_group_update_err > 0) {
returnError ('module_group_synch_err',__('Error creating/updating %s/%s module groups <br>', $module_group_create_err, $module_group_update_err));
}
if ($module_group_create_ok > 0 or $module_group_update_ok > 0){
returnData ('string', array('type' => 'string', 'data' => $string_ok));
}
}
else{
returnError ('not_defined_in_metaconsole',__('This function is only for metaconsole'));
}
}
function api_set_new_event($trash1, $trash2, $other, $trash3) { function api_set_new_event($trash1, $trash2, $other, $trash3) {
$simulate = false; $simulate = false;
$time = get_system_time(); $time = get_system_time();
@ -8662,9 +8818,9 @@ function api_get_events($trash1, $trash2, $other, $returnType, $user_in_db = nul
function api_set_delete_user($id, $thrash1, $thrash2, $thrash3) { function api_set_delete_user($id, $thrash1, $thrash2, $thrash3) {
global $config; global $config;
if (defined ('METACONSOLE')) { // if (defined ('METACONSOLE')) {
return; // return;
} // }
if (!check_acl($config['id_user'], 0, "UM")) { if (!check_acl($config['id_user'], 0, "UM")) {
returnError('forbidden', 'string'); returnError('forbidden', 'string');
@ -10602,6 +10758,7 @@ function api_set_create_service($thrash1, $thrash2, $other, $thrash3) {
} }
} }
/** /**
* Update a service. * Update a service.
* *
@ -12735,4 +12892,29 @@ function api_get_session_timeout($thrash1, $thrash2, $other, $thrash3) {
} }
} }
function api_get_users($thrash1, $thrash2, $other, $returnType) {
global $config;
$user_info = get_users();
if (!isset($returnType) || empty($returnType) || $returnType == '') {
$returnType = "json";
$data['data'] = "json";
}
if (!isset($separator) || empty($separator) || $separator == '') {
$separator = ";";
}
$data['data'] = $user_info;
if (count($data) > 0 and $data !== false) {
returnData($returnType, $data, $separator);
}
else {
returnError('error_users', 'No users retrieved.');
}
}
?> ?>

View File

@ -249,6 +249,10 @@ function config_update_config () {
$error_update[] = __('Activate Log Collector'); $error_update[] = __('Activate Log Collector');
if (!config_update_value ('enable_update_manager', get_parameter('enable_update_manager'))) if (!config_update_value ('enable_update_manager', get_parameter('enable_update_manager')))
$error_update[] = __('Enable Update Manager'); $error_update[] = __('Enable Update Manager');
if (!config_update_value ('ipam_ocuppied_critical_treshold', get_parameter('ipam_ocuppied_critical_treshold')))
$error_update[] = __('Ipam Ocuppied Manager Critical');
if (!config_update_value ('ipam_ocuppied_warning_treshold', get_parameter('ipam_ocuppied_warning_treshold')))
$error_update[] = __('Ipam Ocuppied Manager Warning');
$inventory_changes_blacklist = get_parameter('inventory_changes_blacklist', array()); $inventory_changes_blacklist = get_parameter('inventory_changes_blacklist', array());
if (!config_update_value ('inventory_changes_blacklist', implode(',',$inventory_changes_blacklist))) if (!config_update_value ('inventory_changes_blacklist', implode(',',$inventory_changes_blacklist)))
@ -1085,6 +1089,14 @@ function config_process_config () {
config_update_value ('enable_update_manager', 1); config_update_value ('enable_update_manager', 1);
} }
if (!isset ($config["ipam_ocuppied_critical_treshold"])) {
config_update_value ('ipam_ocuppied_critical_treshold', 90);
}
if (!isset ($config["ipam_ocuppied_warning_treshold"])) {
config_update_value ('ipam_ocuppied_warning_treshold', 80);
}
if (!isset ($config["reset_pass_option"])) { if (!isset ($config["reset_pass_option"])) {
config_update_value ('reset_pass_option', 0); config_update_value ('reset_pass_option', 0);
} }

View File

@ -2710,7 +2710,7 @@ function events_clean_tags ($tags) {
*/ */
function events_get_count_events_by_agent ($id_group, $period, $date, function events_get_count_events_by_agent ($id_group, $period, $date,
$filter_event_severity = false, $filter_event_type = false, $filter_event_severity = false, $filter_event_type = false,
$filter_event_status = false, $filter_event_filter_search = false) { $filter_event_status = false, $filter_event_filter_search = false, $dbmeta = false) {
global $config; global $config;
@ -2802,16 +2802,22 @@ function events_get_count_events_by_agent ($id_group, $period, $date,
' OR id_evento LIKE "%' . io_safe_input($filter_event_filter_search) . '%")'; ' OR id_evento LIKE "%' . io_safe_input($filter_event_filter_search) . '%")';
} }
$tagente = 'tagente';
$tevento = 'tevento';
if($dbmeta){
$tagente = 'tmetaconsole_agent';
$tevento = 'tmetaconsole_event';
}
$sql = sprintf ('SELECT id_agente, $sql = sprintf ('SELECT id_agente,
(SELECT t2.alias (SELECT t2.alias
FROM tagente t2 FROM %s t2
WHERE t2.id_agente = t3.id_agente) AS agent_name, WHERE t2.id_agente = t3.id_agente) AS agent_name,
COUNT(*) AS count COUNT(*) AS count
FROM tevento t3 FROM %s t3
WHERE utimestamp > %d AND utimestamp <= %d WHERE utimestamp > %d AND utimestamp <= %d
AND id_grupo IN (%s) %s AND id_grupo IN (%s) %s
GROUP BY id_agente', GROUP BY id_agente',
$datelimit, $date, implode (",", $id_group), $sql_where); $tagente, $tevento, $datelimit, $date, implode (",", $id_group), $sql_where);
$rows = db_get_all_rows_sql ($sql); $rows = db_get_all_rows_sql ($sql);
@ -2843,7 +2849,7 @@ function events_get_count_events_by_agent ($id_group, $period, $date,
*/ */
function events_get_count_events_validated_by_user ($filter, $period, $date, function events_get_count_events_validated_by_user ($filter, $period, $date,
$filter_event_severity = false, $filter_event_type = false, $filter_event_severity = false, $filter_event_type = false,
$filter_event_status = false, $filter_event_filter_search = false) { $filter_event_status = false, $filter_event_filter_search = false, $dbmeta = false) {
global $config; global $config;
//group //group
$sql_filter = ' AND 1=1 '; $sql_filter = ' AND 1=1 ';
@ -2949,16 +2955,20 @@ function events_get_count_events_validated_by_user ($filter, $period, $date,
' OR id_evento LIKE "%' . io_safe_input($filter_event_filter_search) . '%")'; ' OR id_evento LIKE "%' . io_safe_input($filter_event_filter_search) . '%")';
} }
$tevento = 'tevento';
if($dbmeta)
$tevento = 'tmetaconsole_event';
$sql = sprintf ('SELECT id_usuario, $sql = sprintf ('SELECT id_usuario,
(SELECT t2.fullname (SELECT t2.fullname
FROM tusuario t2 FROM tusuario t2
WHERE t2.id_user = t3.id_usuario) AS user_name, WHERE t2.id_user = t3.id_usuario) AS user_name,
COUNT(*) AS count COUNT(*) AS count
FROM tevento t3 FROM %s t3
WHERE utimestamp > %d AND utimestamp <= %d WHERE utimestamp > %d AND utimestamp <= %d
%s %s %s %s
GROUP BY id_usuario', GROUP BY id_usuario',
$datelimit, $date, $sql_filter, $sql_where); $tevento, $datelimit, $date, $sql_filter, $sql_where);
$rows = db_get_all_rows_sql ($sql); $rows = db_get_all_rows_sql ($sql);
if ($rows == false) if ($rows == false)
@ -2988,7 +2998,7 @@ function events_get_count_events_validated_by_user ($filter, $period, $date,
*/ */
function events_get_count_events_by_criticity ($filter, $period, $date, function events_get_count_events_by_criticity ($filter, $period, $date,
$filter_event_severity = false, $filter_event_type = false, $filter_event_severity = false, $filter_event_type = false,
$filter_event_status = false, $filter_event_filter_search = false) { $filter_event_status = false, $filter_event_filter_search = false, $dbmeta = false) {
global $config; global $config;
@ -3094,13 +3104,16 @@ function events_get_count_events_by_criticity ($filter, $period, $date,
' OR id_evento LIKE "%' . io_safe_input($filter_event_filter_search) . '%")'; ' OR id_evento LIKE "%' . io_safe_input($filter_event_filter_search) . '%")';
} }
$tevento = 'tevento';
if ($dbmeta)
$tevento = 'tmetaconsole_event';
$sql = sprintf ('SELECT criticity, $sql = sprintf ('SELECT criticity,
COUNT(*) AS count COUNT(*) AS count
FROM tevento FROM %s
WHERE utimestamp > %d AND utimestamp <= %d WHERE utimestamp > %d AND utimestamp <= %d
%s %s %s %s
GROUP BY criticity', GROUP BY criticity',
$datelimit, $date, $sql_filter, $sql_where); $tevento, $datelimit, $date, $sql_filter, $sql_where);
$rows = db_get_all_rows_sql ($sql); $rows = db_get_all_rows_sql ($sql);
@ -3128,7 +3141,7 @@ function events_get_count_events_by_criticity ($filter, $period, $date,
*/ */
function events_get_count_events_validated ($filter, $period = null, $date = null, function events_get_count_events_validated ($filter, $period = null, $date = null,
$filter_event_severity = false, $filter_event_type = false, $filter_event_severity = false, $filter_event_type = false,
$filter_event_status = false, $filter_event_filter_search = false) { $filter_event_status = false, $filter_event_filter_search = false, $dbmeta = false) {
global $config; global $config;
@ -3252,7 +3265,10 @@ function events_get_count_events_validated ($filter, $period = null, $date = nul
' OR id_evento LIKE "%' . io_safe_input($filter_event_filter_search) . '%")'; ' OR id_evento LIKE "%' . io_safe_input($filter_event_filter_search) . '%")';
} }
$sql = sprintf ("SELECT estado, COUNT(*) AS count FROM tevento WHERE %s %s GROUP BY estado", $sql_filter, $sql_where); $tevento = 'tevento';
if ($dbmeta)
$tevento = 'tmetaconsole_event';
$sql = sprintf ("SELECT estado, COUNT(*) AS count FROM %s WHERE %s %s GROUP BY estado", $tevento, $sql_filter, $sql_where);
$rows = db_get_all_rows_sql ($sql); $rows = db_get_all_rows_sql ($sql);

View File

@ -1025,7 +1025,8 @@ function html_print_input_text_extended ($name, $value, $id, $alt, $size, $maxle
"title", "xml:lang", "onfocus", "onblur", "onselect", "title", "xml:lang", "onfocus", "onblur", "onselect",
"onchange", "onclick", "ondblclick", "onmousedown", "onchange", "onclick", "ondblclick", "onmousedown",
"onmouseup", "onmouseover", "onmousemove", "onmouseout", "onmouseup", "onmouseover", "onmousemove", "onmouseout",
"onkeypress", "onkeydown", "onkeyup", "required"); "onkeypress", "onkeydown", "onkeyup", "required",
"autocomplete");
$output = '<input '.($password ? 'type="password" autocomplete="off" ' : 'type="text" '); $output = '<input '.($password ? 'type="password" autocomplete="off" ' : 'type="text" ');
@ -1196,22 +1197,27 @@ function html_print_input_password ($name, $value, $alt = '',
* *
* @return string HTML code if return parameter is true. * @return string HTML code if return parameter is true.
*/ */
function html_print_input_text ($name, $value, $alt = '', $size = 50, $maxlength = 255, $return = false, $disabled = false, $required = false, $function = "", $class = "", $onChange ="") { function html_print_input_text ($name, $value, $alt = '', $size = 50, $maxlength = 255, $return = false, $disabled = false, $required = false, $function = "", $class = "", $onChange ="", $autocomplete="") {
if ($maxlength == 0) if ($maxlength == 0)
$maxlength = 255; $maxlength = 255;
if ($size == 0) if ($size == 0)
$size = 10; $size = 10;
$attr = array(); $attr = array();
if ($required) if ($required){
$attr['required'] = 'required'; $attr['required'] = 'required';
if ($class != '') }
if ($class != ''){
$attr['class'] = $class; $attr['class'] = $class;
}
if ($onChange != '') { if ($onChange != '') {
$attr['onchange'] = $onChange; $attr['onchange'] = $onChange;
} }
if($autocomplete !== ''){
$attr['autocomplete'] = $autocomplete;
}
return html_print_input_text_extended ($name, $value, 'text-'.$name, $alt, $size, $maxlength, $disabled, '', $attr, $return, false, $function); return html_print_input_text_extended ($name, $value, 'text-'.$name, $alt, $size, $maxlength, $disabled, '', $attr, $return, false, $function);
} }

View File

@ -67,12 +67,21 @@ function os_get_name($id_os) {
} }
function os_get_os() { function os_get_os($hash = false) {
$result = array();
$op_systems = db_get_all_rows_in_table('tconfig_os'); $op_systems = db_get_all_rows_in_table('tconfig_os');
if (empty($op_systems)) if (empty($op_systems))
$op_systems = array(); $op_systems = array();
return $op_systems; if ($hash) {
foreach ($op_systems as $key => $value) {
$result[$value['id_os']] = $value['name'];
}
} else {
$result = $op_systems;
}
return $result;
} }
function os_get_icon($id_os) { function os_get_icon($id_os) {

View File

@ -1538,12 +1538,17 @@ function reporting_event_report_group($report, $content,
$return['chart']['by_user_validator'] = null; $return['chart']['by_user_validator'] = null;
$return['chart']['by_criticity'] = null; $return['chart']['by_criticity'] = null;
$return['chart']['validated_vs_unvalidated'] = null; $return['chart']['validated_vs_unvalidated'] = null;
$server_name = $content['server_name'];
if (is_metaconsole() && $server_name != '')
$metaconsole_dbtable = true;
else
$metaconsole_dbtable = false;
if ($event_graph_by_agent) { if ($event_graph_by_agent) {
$data_graph = events_get_count_events_by_agent( $data_graph = events_get_count_events_by_agent(
$content['id_group'], $content['period'], $report["datetime"], $content['id_group'], $content['period'], $report["datetime"],
$filter_event_severity, $filter_event_type, $filter_event_severity, $filter_event_type,
$filter_event_status, $filter_event_filter_search); $filter_event_status, $filter_event_filter_search, $metaconsole_dbtable);
$return['chart']['by_agent']= pie_graph( $return['chart']['by_agent']= pie_graph(
$data_graph, $data_graph,
@ -1562,7 +1567,7 @@ function reporting_event_report_group($report, $content,
$data_graph = events_get_count_events_validated_by_user( $data_graph = events_get_count_events_validated_by_user(
array('id_group' => $content['id_group']), $content['period'], array('id_group' => $content['id_group']), $content['period'],
$report["datetime"],$filter_event_severity, $filter_event_type, $report["datetime"],$filter_event_severity, $filter_event_type,
$filter_event_status, $filter_event_filter_search); $filter_event_status, $filter_event_filter_search, $metaconsole_dbtable);
$return['chart']['by_user_validator'] = pie_graph( $return['chart']['by_user_validator'] = pie_graph(
$data_graph, $data_graph,
@ -1581,7 +1586,7 @@ function reporting_event_report_group($report, $content,
$data_graph = events_get_count_events_by_criticity( $data_graph = events_get_count_events_by_criticity(
array('id_group' => $content['id_group']), $content['period'], array('id_group' => $content['id_group']), $content['period'],
$report["datetime"],$filter_event_severity, $filter_event_type, $report["datetime"],$filter_event_severity, $filter_event_type,
$filter_event_status, $filter_event_filter_search); $filter_event_status, $filter_event_filter_search, $metaconsole_dbtable);
$colors = get_criticity_pie_colors($data_graph); $colors = get_criticity_pie_colors($data_graph);
@ -1604,7 +1609,7 @@ function reporting_event_report_group($report, $content,
$data_graph = events_get_count_events_validated( $data_graph = events_get_count_events_validated(
array('id_group' => $content['id_group']), $content['period'], array('id_group' => $content['id_group']), $content['period'],
$report["datetime"],$filter_event_severity, $filter_event_type, $report["datetime"],$filter_event_severity, $filter_event_type,
$filter_event_status, $filter_event_filter_search); $filter_event_status, $filter_event_filter_search, $metaconsole_dbtable);
$return['chart']['validated_vs_unvalidated'] = pie_graph( $return['chart']['validated_vs_unvalidated'] = pie_graph(
$data_graph, $data_graph,
@ -1685,13 +1690,19 @@ function reporting_event_report_module($report, $content,
$event_graph_by_criticity = $event_filter['event_graph_by_criticity']; $event_graph_by_criticity = $event_filter['event_graph_by_criticity'];
$event_graph_validated_vs_unvalidated = $event_filter['event_graph_validated_vs_unvalidated']; $event_graph_validated_vs_unvalidated = $event_filter['event_graph_validated_vs_unvalidated'];
$server_name = $content['server_name'];
if (is_metaconsole() && $server_name != '')
$metaconsole_dbtable = true;
else
$metaconsole_dbtable = false;
//data events //data events
$data = reporting_get_module_detailed_event ( $data = reporting_get_module_detailed_event (
$content['id_agent_module'], $content['period'], $report["datetime"], $content['id_agent_module'], $content['period'], $report["datetime"],
$show_summary_group, $filter_event_severity, $filter_event_type, $show_summary_group, $filter_event_severity, $filter_event_type,
$filter_event_status, $filter_event_filter_search, $force_width_chart, $filter_event_status, $filter_event_filter_search, $force_width_chart,
$event_graph_by_user_validator, $event_graph_by_criticity, $event_graph_by_user_validator, $event_graph_by_criticity,
$event_graph_validated_vs_unvalidated, $ttl, $id_server); $event_graph_validated_vs_unvalidated, $ttl, $id_server, $metaconsole_dbtable);
if (empty($data)) { if (empty($data)) {
$return['failed'] = __('No events'); $return['failed'] = __('No events');
@ -2455,11 +2466,16 @@ function reporting_event_report_agent($report, $content,
$return["chart"]["by_criticity"] = null; $return["chart"]["by_criticity"] = null;
$return["chart"]["validated_vs_unvalidated"] = null; $return["chart"]["validated_vs_unvalidated"] = null;
$server_name = $content['server_name'];
if (is_metaconsole() && $server_name != '')
$metaconsole_dbtable = true;
else
$metaconsole_dbtable = false;
if ($event_graph_by_user_validator) { if ($event_graph_by_user_validator) {
$data_graph = events_get_count_events_validated_by_user( $data_graph = events_get_count_events_validated_by_user(
array('id_agent' => $content['id_agent']), $content['period'], array('id_agent' => $content['id_agent']), $content['period'],
$report["datetime"],$filter_event_severity, $filter_event_type, $report["datetime"],$filter_event_severity, $filter_event_type,
$filter_event_status, $filter_event_filter_search); $filter_event_status, $filter_event_filter_search, $metaconsole_dbtable);
$return["chart"]["by_user_validator"] = pie_graph( $return["chart"]["by_user_validator"] = pie_graph(
$data_graph, $data_graph,
@ -2478,7 +2494,7 @@ function reporting_event_report_agent($report, $content,
$data_graph = events_get_count_events_by_criticity( $data_graph = events_get_count_events_by_criticity(
array('id_agent' => $content['id_agent']), $content['period'], array('id_agent' => $content['id_agent']), $content['period'],
$report["datetime"],$filter_event_severity, $filter_event_type, $report["datetime"],$filter_event_severity, $filter_event_type,
$filter_event_status, $filter_event_filter_search); $filter_event_status, $filter_event_filter_search, $metaconsole_dbtable);
$colors = get_criticity_pie_colors($data_graph); $colors = get_criticity_pie_colors($data_graph);
@ -2501,7 +2517,7 @@ function reporting_event_report_agent($report, $content,
$data_graph = events_get_count_events_validated( $data_graph = events_get_count_events_validated(
array('id_agent' => $content['id_agent']), $content['period'], array('id_agent' => $content['id_agent']), $content['period'],
$report["datetime"],$filter_event_severity, $filter_event_type, $report["datetime"],$filter_event_severity, $filter_event_type,
$filter_event_status, $filter_event_filter_search); $filter_event_status, $filter_event_filter_search, $metaconsole_dbtable);
$return["chart"]["validated_vs_unvalidated"] = pie_graph( $return["chart"]["validated_vs_unvalidated"] = pie_graph(
$data_graph, $data_graph,
@ -6553,7 +6569,7 @@ function reporting_simple_graph($report, $content, $type = 'dinamic',
$content['id_agent_module'], $content['id_agent_module'],
$content['period'], $content['period'],
$report["datetime"]); $report["datetime"]);
$return['chart'] = array();
foreach ($data as $d) { foreach ($data as $d) {
$return['chart'][$d['utimestamp']] = $d['data']; $return['chart'][$d['utimestamp']] = $d['data'];
} }
@ -6687,7 +6703,7 @@ function reporting_get_module_detailed_event ($id_modules, $period = 0,
$filter_event_type = false, $filter_event_status = false, $filter_event_type = false, $filter_event_status = false,
$filter_event_filter_search = false, $force_width_chart = false, $filter_event_filter_search = false, $force_width_chart = false,
$event_graph_by_user_validator = false, $event_graph_by_criticity = false, $event_graph_by_user_validator = false, $event_graph_by_criticity = false,
$event_graph_validated_vs_unvalidated = false, $ttl = 1, $id_server = false) { $event_graph_validated_vs_unvalidated = false, $ttl = 1, $id_server = false, $metaconsole_dbtable = false) {
global $config; global $config;
@ -6732,7 +6748,7 @@ function reporting_get_module_detailed_event ($id_modules, $period = 0,
if ($event_graph_by_user_validator) { if ($event_graph_by_user_validator) {
$data_graph = events_get_count_events_validated_by_user( $data_graph = events_get_count_events_validated_by_user(
array('id_agentmodule' => $id_module), $period, $date, $filter_event_severity, array('id_agentmodule' => $id_module), $period, $date, $filter_event_severity,
$filter_event_type, $filter_event_status, $filter_event_filter_search); $filter_event_type, $filter_event_status, $filter_event_filter_search, $metaconsole_dbtable);
$event['chart']['by_user_validator'] = pie_graph( $event['chart']['by_user_validator'] = pie_graph(
$data_graph, $data_graph,
@ -6750,7 +6766,7 @@ function reporting_get_module_detailed_event ($id_modules, $period = 0,
if ($event_graph_by_criticity) { if ($event_graph_by_criticity) {
$data_graph = events_get_count_events_by_criticity( $data_graph = events_get_count_events_by_criticity(
array('id_agentmodule' => $id_module), $period, $date, $filter_event_severity, array('id_agentmodule' => $id_module), $period, $date, $filter_event_severity,
$filter_event_type, $filter_event_status, $filter_event_filter_search); $filter_event_type, $filter_event_status, $filter_event_filter_search, $metaconsole_dbtable);
$colors = get_criticity_pie_colors($data_graph); $colors = get_criticity_pie_colors($data_graph);
@ -6772,7 +6788,7 @@ function reporting_get_module_detailed_event ($id_modules, $period = 0,
if ($event_graph_validated_vs_unvalidated) { if ($event_graph_validated_vs_unvalidated) {
$data_graph = events_get_count_events_validated( $data_graph = events_get_count_events_validated(
array('id_agentmodule' => $id_module), $period, $date, $filter_event_severity, array('id_agentmodule' => $id_module), $period, $date, $filter_event_severity,
$filter_event_type, $filter_event_status, $filter_event_filter_search); $filter_event_type, $filter_event_status, $filter_event_filter_search, $metaconsole_dbtable);
$event['chart']['validated_vs_unvalidated'] = pie_graph( $event['chart']['validated_vs_unvalidated'] = pie_graph(
$data_graph, $data_graph,

View File

@ -1584,8 +1584,8 @@ $config['css']['dialog'] = "include/javascript/introjs.css";
//End load JQuery //End load JQuery
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
include_once($config["homedir"] . '/include/graphs/functions_flot.php'); include_once (__DIR__ . '/graphs/functions_flot.php');
$output .= include_javascript_dependencies_flot_graph(true); $output .= include_javascript_dependencies_flot_graph (true);
$output .= '<!--[if gte IE 6]> $output .= '<!--[if gte IE 6]>
<link rel="stylesheet" href="include/styles/ie.css" type="text/css"/> <link rel="stylesheet" href="include/styles/ie.css" type="text/css"/>

File diff suppressed because it is too large Load Diff

View File

@ -115,8 +115,8 @@
</div> </div>
<div style='height: 10px'> <div style='height: 10px'>
<?php <?php
$version = '7.0NG.730'; $version = '7.0NG.731';
$build = '190121'; $build = '190129';
$banner = "v$version Build $build"; $banner = "v$version Build $build";
error_reporting(0); error_reporting(0);

View File

@ -2,8 +2,8 @@
# Pandora FMS Console # Pandora FMS Console
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.730 %define version 7.0NG.731
%define release 190121 %define release 1
# 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

@ -2,8 +2,8 @@
# Pandora FMS Console # Pandora FMS Console
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.730 %define version 7.0NG.731
%define release 190121 %define release 1
%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

@ -9,7 +9,7 @@
# This code is licensed under GPL 2.0 license. # This code is licensed under GPL 2.0 license.
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.730" PI_VERSION="7.0NG.731"
FORCE=0 FORCE=0
DESTDIR="" DESTDIR=""
LOG_TIMESTAMP=`date +"%Y/%m/%d %H:%M:%S"` LOG_TIMESTAMP=`date +"%Y/%m/%d %H:%M:%S"`

View File

@ -112,7 +112,7 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES
('MR', 23), ('MR', 23),
('identification_reminder', 1), ('identification_reminder', 1),
('identification_reminder_timestamp', 0), ('identification_reminder_timestamp', 0),
('current_package_enterprise', '730'), ('current_package_enterprise', '731'),
('post_process_custom_values', '{"0.00000038580247":"Seconds&#x20;to&#x20;months","0.00000165343915":"Seconds&#x20;to&#x20;weeks","0.00001157407407":"Seconds&#x20;to&#x20;days","0.01666666666667":"Seconds&#x20;to&#x20;minutes","0.00000000093132":"Bytes&#x20;to&#x20;Gigabytes","0.00000095367432":"Bytes&#x20;to&#x20;Megabytes","0.0009765625":"Bytes&#x20;to&#x20;Kilobytes","0.00000001653439":"Timeticks&#x20;to&#x20;weeks","0.00000011574074":"Timeticks&#x20;to&#x20;days"}'), ('post_process_custom_values', '{"0.00000038580247":"Seconds&#x20;to&#x20;months","0.00000165343915":"Seconds&#x20;to&#x20;weeks","0.00001157407407":"Seconds&#x20;to&#x20;days","0.01666666666667":"Seconds&#x20;to&#x20;minutes","0.00000000093132":"Bytes&#x20;to&#x20;Gigabytes","0.00000095367432":"Bytes&#x20;to&#x20;Megabytes","0.0009765625":"Bytes&#x20;to&#x20;Kilobytes","0.00000001653439":"Timeticks&#x20;to&#x20;weeks","0.00000011574074":"Timeticks&#x20;to&#x20;days"}'),
('custom_docs_logo', 'default_docs.png'), ('custom_docs_logo', 'default_docs.png'),
('custom_support_logo', 'default_support.png'), ('custom_support_logo', 'default_support.png'),

View File

@ -1,5 +1,5 @@
package: pandorafms-server package: pandorafms-server
Version: 7.0NG.730-190121 Version: 7.0NG.731
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.730-190121" pandora_version="7.0NG.731"
package_cpan=0 package_cpan=0
package_pandora=1 package_pandora=1

View File

@ -1,7 +1,7 @@
############################################################################# #############################################################################
# Pandora FMS Server Parameters # Pandora FMS Server Parameters
# Pandora FMS, the Flexible Monitoring System. # Pandora FMS, the Flexible Monitoring System.
# Version 7.0NG.730 # Version 7.0NG.731
# Licensed under GPL license v2, # Licensed under GPL license v2,
# (c) 2003-2017 Artica Soluciones Tecnologicas # (c) 2003-2017 Artica Soluciones Tecnologicas
# http://www.pandorafms.com # http://www.pandorafms.com

View File

@ -44,8 +44,8 @@ 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.730"; my $pandora_version = "7.0NG.731";
my $pandora_build = "190121"; my $pandora_build = "190129";
our $VERSION = $pandora_version." ".$pandora_build; our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash # Setup hash

View File

@ -604,6 +604,9 @@ sub process_xml_data ($$$$$) {
# Process events # Process events
process_events_dataserver($pa_config, $data, $agent_id, $group_id, $dbh); process_events_dataserver($pa_config, $data, $agent_id, $group_id, $dbh);
# Process disovery modules
enterprise_hook('process_discovery_data', [$pa_config, $data, $server_id, $dbh]);
} }
########################################################################## ##########################################################################

View File

@ -18,7 +18,7 @@ use warnings;
use LWP::UserAgent; use LWP::UserAgent;
use HTTP::Cookies; use HTTP::Cookies;
use HTTP::Request::Common; use HTTP::Request::Common;
use Socket qw(inet_ntoa inet_aton);
use File::Copy; use File::Copy;
use Scalar::Util qw(looks_like_number); use Scalar::Util qw(looks_like_number);
use Time::HiRes qw(time); use Time::HiRes qw(time);
@ -31,8 +31,8 @@ use base 'Exporter';
our @ISA = qw(Exporter); 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.730"; my $pandora_version = "7.0NG.731";
my $pandora_build = "190121"; my $pandora_build = "190129";
our $VERSION = $pandora_version." ".$pandora_build; our $VERSION = $pandora_version." ".$pandora_build;
our %EXPORT_TAGS = ( 'all' => [ qw() ] ); our %EXPORT_TAGS = ( 'all' => [ qw() ] );
@ -40,6 +40,8 @@ our %EXPORT_TAGS = ( 'all' => [ qw() ] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw( our @EXPORT = qw(
__ip_to_long
__long_to_ip
api_available api_available
api_call api_call
api_create_custom_field api_create_custom_field
@ -47,6 +49,7 @@ our @EXPORT = qw(
api_create_group api_create_group
call_url call_url
check_lib_version check_lib_version
csv_to_obj
decrypt decrypt
empty empty
encrypt encrypt
@ -67,6 +70,7 @@ our @EXPORT = qw(
join_by_field join_by_field
load_perl_modules load_perl_modules
logger logger
mask_to_decimal
merge_hashes merge_hashes
parse_arguments parse_arguments
parse_configuration parse_configuration
@ -74,6 +78,7 @@ our @EXPORT = qw(
process_performance process_performance
post_url post_url
print_agent print_agent
print_discovery_module
print_error print_error
print_execution_result print_execution_result
print_message print_message
@ -125,6 +130,47 @@ sub check_lib_version {
return 1; return 1;
} }
###############################################################################
# Returns IP address(v4) in longint format
###############################################################################
sub __ip_to_long {
my $ip_str = shift;
return unpack "N", inet_aton($ip_str);
}
###############################################################################
# Returns IP address(v4) in longint format
###############################################################################
sub __long_to_ip {
my $ip_long = shift;
return inet_ntoa pack("N", ($ip_long));
}
################################################################################
# Convert CSV string to hash
################################################################################
sub csv_to_obj {
my ($csv) = @_;
my @ahr;
my @lines = split /\n/, $csv;
return [] unless $#lines >= 0;
# scan headers
my @hr_headers = split /,/, shift @lines;
# Clean \n\r
@hr_headers = map { $_ =~ s/\"//g; trim($_); } @hr_headers;
foreach my $line (@lines) {
my $i = 0;
my %hr = map { $_ =~ s/\"//g; $hr_headers[$i++] => trim($_) } split /,/, $line;
push @ahr, \%hr;
}
return \@ahr;
}
################################################################################ ################################################################################
# Get current time (milis) # Get current time (milis)
################################################################################ ################################################################################
@ -134,6 +180,25 @@ sub getCurrentUTimeMilis {
return floor(time*1000); return floor(time*1000);
} }
################################################################################
# Mask to decimal
################################################################################
sub mask_to_decimal {
my $mask = shift;
my ($a,$b,$c,$d) = $mask =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/;
$a = sprintf "%08b", $a;
$b = sprintf "%08b", $b;
$c = sprintf "%08b", $c;
$d = sprintf "%08b", $d;
my $str = $a . $b . $c . $d;
$str =~ s/0.*$//;
return length($str);
}
################################################################################ ################################################################################
# Mix hashses # Mix hashses
################################################################################ ################################################################################
@ -442,8 +507,18 @@ sub print_agent {
$xml .= ">"; $xml .= ">";
foreach my $module (@{$modules_def}) { if (ref($modules_def) eq "ARRAY") {
$xml .= print_module($config, $module,1); foreach my $module (@{$modules_def}) {
if (ref($module) eq "HASH" && (defined $module->{'name'})) {
$xml .= print_module($config, $module,1);
} elsif (ref($module) eq "HASH" && (defined $module->{'discovery'})) {
$xml .= print_discovery_module($config, $module,1);
}
}
} elsif (ref($modules_def) eq "HASH" && (defined $modules_def->{'name'})) {
$xml .= print_module($config, $modules_def,1);
} elsif (ref($modules_def) eq "HASH" && (defined $modules_def->{'discovery'})) {
$xml .= print_discovery_module($config, $modules_def,1);
} }
# print tail # print tail
@ -457,6 +532,28 @@ sub print_agent {
} }
################################################################################
# print_module
################################################################################
sub print_discovery_module {
my ($conf, $global_data, $not_print_flag) = @_;
return undef if (ref($global_data) ne "HASH" || !defined($global_data->{'discovery'}));
return "" if empty($global_data);
my $data = $global_data->{'discovery'};
my $xml_module = "<discovery><![CDATA[";
$xml_module .= encode_base64(encode_json($data));
$xml_module .= "]]></discovery>\n";
if (empty ($not_print_flag)) {
print $xml_module;
}
return $xml_module;
}
################################################################################ ################################################################################
# print_module # print_module
################################################################################ ################################################################################
@ -660,7 +757,7 @@ sub transfer_xml {
my $file_path; my $file_path;
if (! (empty ($name))) { if (! (empty ($name))) {
$file_name = $name . "_" . time() . ".data"; $file_name = $name . "." . sprintf("%d",time()) . ".data";
} }
else { else {
# Inherit file name # Inherit file name
@ -672,7 +769,7 @@ sub transfer_xml {
$file_name = trim(`hostname`); $file_name = trim(`hostname`);
} }
$file_name .= "_" . time() . ".data"; $file_name .= "." . sprintf("%d",time()) . ".data";
} }
logger($conf, "transfer_xml", "Failed to generate file name.") if empty($file_name); logger($conf, "transfer_xml", "Failed to generate file name.") if empty($file_name);
@ -680,6 +777,8 @@ sub transfer_xml {
$conf->{temp} = $conf->{tmp} if (empty($conf->{temp}) && defined($conf->{tmp})); $conf->{temp} = $conf->{tmp} if (empty($conf->{temp}) && defined($conf->{tmp}));
$conf->{temp} = $conf->{temporal} if (empty($conf->{temp}) && defined($conf->{temporal})); $conf->{temp} = $conf->{temporal} if (empty($conf->{temp}) && defined($conf->{temporal}));
$conf->{temp} = $conf->{__system}->{tmp} if (empty($conf->{temp}) && defined($conf->{__system})) && (ref($conf->{__system}) eq "HASH"); $conf->{temp} = $conf->{__system}->{tmp} if (empty($conf->{temp}) && defined($conf->{__system})) && (ref($conf->{__system}) eq "HASH");
$conf->{temp} = $ENV{'TMP'} if empty($conf->{temp}) && $^O =~ /win/i;
$conf->{temp} = '/tmp' if empty($conf->{temp}) && $^O =~ /lin/i;
$file_path = $conf->{temp} . "/" . $file_name; $file_path = $conf->{temp} . "/" . $file_name;
@ -687,7 +786,7 @@ sub transfer_xml {
if ( -e $file_path ) { if ( -e $file_path ) {
sleep (1); sleep (1);
$file_name = $name . "_" . time() . ".data"; $file_name = $name . "." . sprintf("%d",time()) . ".data";
$file_path = $conf->{temp} . "/" . $file_name; $file_path = $conf->{temp} . "/" . $file_name;
} }
@ -2252,6 +2351,8 @@ sub decrypt {
sub get_unix_time { sub get_unix_time {
my ($str_time,$separator_dates,$separator_hours) = @_; my ($str_time,$separator_dates,$separator_hours) = @_;
return 0 if empty($str_time);
if (empty($separator_dates)) { if (empty($separator_dates)) {
$separator_dates = "\/"; $separator_dates = "\/";
} }
@ -2260,10 +2361,15 @@ sub get_unix_time {
$separator_hours = ":"; $separator_hours = ":";
} }
my $time;
use Time::Local; eval {
my ($mday,$mon,$year,$hour,$min,$sec) = split(/[\s$separator_dates$separator_hours]+/, $str_time); use Time::Local;
my $time = timelocal($sec,$min,$hour,$mday,$mon-1,$year); my ($mday,$mon,$year,$hour,$min,$sec) = split(/[\s$separator_dates$separator_hours]+/, $str_time);
$time = timelocal($sec,$min,$hour,$mday,$mon-1,$year);
};
if ($@) {
return 0;
}
return $time; return $time;
} }

View File

@ -112,6 +112,7 @@ our @EXPORT = qw(
md5_init md5_init
pandora_ping pandora_ping
pandora_ping_latency pandora_ping_latency
pandora_block_ping
resolve_hostname resolve_hostname
ticks_totime ticks_totime
safe_input safe_input
@ -125,6 +126,8 @@ our @EXPORT = qw(
start_server_thread start_server_thread
stop_server_threads stop_server_threads
generate_agent_name_hash generate_agent_name_hash
long_to_ip
ip_to_long
); );
# ID of the different servers # ID of the different servers
@ -1271,6 +1274,24 @@ sub pandora_ping_latency ($$$$) {
return $output; return $output;
} }
########################################################################
=head2 C<< pandora_block_ping (I<$pa_config>, I<$hosts>) >>
Ping all given hosts. Returns an array with all hosts detected as alive.
=cut
########################################################################
sub pandora_block_ping($@) {
my ($pa_config, @hosts) = @_;
# fping timeout in milliseconds
my $cmd = $pa_config->{'fping'} . " -a -q -t " . (1000 * $pa_config->{'networktimeout'}) . " " . (join (' ', @hosts));
my @output = `$cmd 2>$DEVNULL`;
return @output;
}
######################################################################## ########################################################################
=head2 C<< month_have_days (I<$month>, I<$year>) >> =head2 C<< month_have_days (I<$month>, I<$year>) >>
@ -1956,6 +1977,22 @@ sub rightrotate {
return (0xFFFFFFFF & ($x << (32 - $c))) | ($x >> $c); return (0xFFFFFFFF & ($x << (32 - $c))) | ($x >> $c);
} }
###############################################################################
# Returns IP address(v4) in longint format
###############################################################################
sub ip_to_long {
my $ip_str = shift;
return unpack "N", inet_aton($ip_str);
}
###############################################################################
# Returns IP address(v4) in longint format
###############################################################################
sub long_to_ip {
my $ip_long = shift;
return inet_ntoa pack("N", ($ip_long));
}
# End of function declaration # End of function declaration
# End of defined Code # End of defined Code

View File

@ -2,8 +2,8 @@
# Pandora FMS Server # Pandora FMS Server
# #
%define name pandorafms_server %define name pandorafms_server
%define version 7.0NG.730 %define version 7.0NG.731
%define release 190121 %define release 1
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

@ -2,8 +2,8 @@
# Pandora FMS Server # Pandora FMS Server
# #
%define name pandorafms_server %define name pandorafms_server
%define version 7.0NG.730 %define version 7.0NG.731
%define release 190121 %define release 1
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

@ -8,8 +8,8 @@
# This code is licensed under GPL 2.0 license. # This code is licensed under GPL 2.0 license.
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.730" PI_VERSION="7.0NG.731"
PI_BUILD="190121" PI_BUILD="190129"
MODE=$1 MODE=$1
if [ $# -gt 1 ]; then if [ $# -gt 1 ]; then

View File

@ -34,7 +34,7 @@ use PandoraFMS::Config;
use PandoraFMS::DB; use PandoraFMS::DB;
# version: define current version # version: define current version
my $version = "7.0NG.730 PS190121"; my $version = "7.0NG.731 PS190129";
# 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.730 PS190121"; my $version = "7.0NG.731 PS190129";
# save program name for logging # save program name for logging
my $progname = basename($0); my $progname = basename($0);
@ -144,7 +144,9 @@ sub help_screen{
help_screen_line('--create_snmp_module', "<module_name> <module_type> <agent_name> <module_address> <module_port>\n\t <version> [<community> <oid> <description> <module_group> <min> <max> <post_process> <interval>\n\t <warning_min> <warning_max> <critical_min> <critical_max> <history_data> \n\t <snmp3_priv_method> <snmp3_priv_pass> <snmp3_sec_level> <snmp3_auth_method> \n\t <snmp3_auth_user> <snmp3_auth_pass> <ff_threshold> <warning_str> \n\t <critical_str> <unknown_events> <each_ff> <ff_threshold_normal>\n\t <ff_threshold_warning> <ff_threshold_critical> <timeout> <retries> help_screen_line('--create_snmp_module', "<module_name> <module_type> <agent_name> <module_address> <module_port>\n\t <version> [<community> <oid> <description> <module_group> <min> <max> <post_process> <interval>\n\t <warning_min> <warning_max> <critical_min> <critical_max> <history_data> \n\t <snmp3_priv_method> <snmp3_priv_pass> <snmp3_sec_level> <snmp3_auth_method> \n\t <snmp3_auth_user> <snmp3_auth_pass> <ff_threshold> <warning_str> \n\t <critical_str> <unknown_events> <each_ff> <ff_threshold_normal>\n\t <ff_threshold_warning> <ff_threshold_critical> <timeout> <retries>
\n\t <critical_instructions> <warning_instructions> <unknown_instructions>\n\t <warning_inverse> <critical_inverse>]", 'Add snmp network module to agent'); \n\t <critical_instructions> <warning_instructions> <unknown_instructions>\n\t <warning_inverse> <critical_inverse>]", 'Add snmp network module to agent');
help_screen_line('--create_plugin_module', "<module_name> <module_type> <agent_name> <module_address> \n\t <module_port> <plugin_name> <user> <password> <parameters> [<description> \n\t <module_group> <min> <max> <post_process> <interval> <warning_min> <warning_max> <critical_min> \n\t <critical_max> <history_data> <ff_threshold> <warning_str> <critical_str>\n\t <unknown_events> <each_ff> <ff_threshold_normal> <ff_threshold_warning>\n\t <ff_threshold_critical> <timeout> \n\t <critical_instructions> <warning_instructions> <unknown_instructions>\n\t <warning_inverse> <critical_inverse>]", 'Add plug-in module to agent'); help_screen_line('--create_plugin_module', "<module_name> <module_type> <agent_name> <module_address> \n\t <module_port> <plugin_name> <user> <password> <parameters> [<description> \n\t <module_group> <min> <max> <post_process> <interval> <warning_min> <warning_max> <critical_min> \n\t <critical_max> <history_data> <ff_threshold> <warning_str> <critical_str>\n\t <unknown_events> <each_ff> <ff_threshold_normal> <ff_threshold_warning>\n\t <ff_threshold_critical> <timeout> \n\t <critical_instructions> <warning_instructions> <unknown_instructions>\n\t <warning_inverse> <critical_inverse>]", 'Add plug-in module to agent');
help_screen_line('--get_module_group', '[<module_group_name>]', 'Dysplay all module groups');
help_screen_line('--create_module_group', '<module_group_name>'); help_screen_line('--create_module_group', '<module_group_name>');
help_screen_line('--module_group_synch', "<server_name1|server_name2|server_name3...> [<return_type>]", 'Synchronize metaconsole module groups');
help_screen_line('--delete_module', 'Delete module from agent', '<module_name> <agent_name>'); help_screen_line('--delete_module', 'Delete module from agent', '<module_name> <agent_name>');
help_screen_line('--data_module', "<server_name> <agent_name> <module_name> \n\t <module_type> <module_new_data> [<datetime>]", 'Insert data to module'); help_screen_line('--data_module', "<server_name> <agent_name> <module_name> \n\t <module_type> <module_new_data> [<datetime>]", 'Insert data to module');
help_screen_line('--get_module_data', "<agent_name> <module_name> <interval> [<csv_separator>]", "\n\t Show the data of a module in the last X seconds (interval) in CSV format"); help_screen_line('--get_module_data', "<agent_name> <module_name> <interval> [<csv_separator>]", "\n\t Show the data of a module in the last X seconds (interval) in CSV format");
@ -162,6 +164,8 @@ sub help_screen{
help_screen_line('--enable_alerts', '', 'Enable alerts in all groups (system wide)'); help_screen_line('--enable_alerts', '', 'Enable alerts in all groups (system wide)');
help_screen_line('--create_alert_template', "<template_name> <condition_type_serialized>\n\t <time_from> <time_to> [<description> <group_name> <field1> <field2> \n\t <field3> <priority> <default_action> <days> <time_threshold> <min_alerts> \n\t <max_alerts> <alert_recovery> <field2_recovery> <field3_recovery> \n\t <condition_type_separator>]", 'Create alert template'); help_screen_line('--create_alert_template', "<template_name> <condition_type_serialized>\n\t <time_from> <time_to> [<description> <group_name> <field1> <field2> \n\t <field3> <priority> <default_action> <days> <time_threshold> <min_alerts> \n\t <max_alerts> <alert_recovery> <field2_recovery> <field3_recovery> \n\t <condition_type_separator>]", 'Create alert template');
help_screen_line('--delete_alert_template', '<template_name>', 'Delete alert template'); help_screen_line('--delete_alert_template', '<template_name>', 'Delete alert template');
help_screen_line('--get_alert_actions', '[<action_name> <separator> <return_type>]', 'get all alert actions');
help_screen_line('--get_alert_actions_meta', '[<server_name> <action_name> <separator> <return_type>]', 'get all alert actions in nodes');
help_screen_line('--update_alert_template', "<template_name> <field_to_change> \n\t <new_value>", 'Update a field of an alert template'); help_screen_line('--update_alert_template', "<template_name> <field_to_change> \n\t <new_value>", 'Update a field of an alert template');
help_screen_line('--validate_all_alerts', '', 'Validate all the alerts'); help_screen_line('--validate_all_alerts', '', 'Validate all the alerts');
help_screen_line('--create_special_day', "<special_day> <same_day> <description> <group>", 'Create special day'); help_screen_line('--create_special_day', "<special_day> <same_day> <description> <group>", 'Create special day');
@ -183,6 +187,7 @@ sub help_screen{
help_screen_line('--disable_eacl', '', 'Disable enterprise ACL system'); help_screen_line('--disable_eacl', '', 'Disable enterprise ACL system');
help_screen_line('--enable_eacl', '', 'Enable enterprise ACL system'); help_screen_line('--enable_eacl', '', 'Enable enterprise ACL system');
help_screen_line('--disable_double_auth', '<user_name>', 'Disable the double authentication for the specified user'); help_screen_line('--disable_double_auth', '<user_name>', 'Disable the double authentication for the specified user');
help_screen_line('--meta_synch_user', "<user_name1,user_name2..> <server_name> [<profile_mode> <group_name>\n\t <profile1,profile2..> <create_groups>]", 'Synchronize metaconsole users');
print "\nEVENTS:\n\n" unless $param ne ''; print "\nEVENTS:\n\n" unless $param ne '';
help_screen_line('--create_event', "<event> <event_type> <group_name> [<agent_name> <module_name>\n\t <event_status> <severity> <template_name> <user_name> <comment> \n\t <source> <id_extra> <tags> <critical_instructions> <warning_instructions> <unknown_instructions> \n\t <custom_data_json> <force_create_agent>]", 'Add event'); help_screen_line('--create_event', "<event> <event_type> <group_name> [<agent_name> <module_name>\n\t <event_status> <severity> <template_name> <user_name> <comment> \n\t <source> <id_extra> <tags> <critical_instructions> <warning_instructions> <unknown_instructions> \n\t <custom_data_json> <force_create_agent>]", 'Add event');
help_screen_line('--validate_event', "<agent_name> <module_name> <datetime_min> <datetime_max>\n\t <user_name> <criticity> <template_name>", 'Validate events'); help_screen_line('--validate_event', "<agent_name> <module_name> <datetime_min> <datetime_max>\n\t <user_name> <criticity> <template_name>", 'Validate events');
@ -241,8 +246,8 @@ sub help_screen{
######################################################################## ########################################################################
# #
######################################################################## ########################################################################
sub api_call($$$;$$$) { sub api_call($$$;$$$$) {
my ($pa_config, $op, $op2, $id, $id2, $other) = @_; my ($pa_config, $op, $op2, $id, $id2, $other, $return_type) = @_;
my $content = undef; my $content = undef;
eval { eval {
@ -256,6 +261,7 @@ sub api_call($$$;$$$) {
$params->{"id"} = $id; $params->{"id"} = $id;
$params->{"id2"} = $id2; $params->{"id2"} = $id2;
$params->{"other"} = $other; $params->{"other"} = $other;
$params->{"return_type"} = $return_type;
$params->{"other_mode"} = "url_encode_separator_|"; $params->{"other_mode"} = "url_encode_separator_|";
# Call the API. # Call the API.
@ -1605,6 +1611,54 @@ sub cli_create_module_group () {
db_insert ($dbh, 'id_mg', 'INSERT INTO tmodule_group (name) VALUES (?)', safe_input($module_group_name)); db_insert ($dbh, 'id_mg', 'INSERT INTO tmodule_group (name) VALUES (?)', safe_input($module_group_name));
} }
##############################################################################
# Show all the module group (without parameters) or the module groups with a filter parameters
# Related option: --get_module_group
##############################################################################
sub cli_get_module_group() {
my ($module_group_name) = @ARGV[2..2];
my $condition = ' 1=1 ';
if($module_group_name ne '') {
$condition .= " AND name LIKE '%$module_group_name%' ";
}
my @module_group = get_db_rows ($dbh, "SELECT * FROM tmodule_group WHERE $condition");
if(scalar(@module_group) == 0) {
print_log "[INFO] No groups found\n\n";
exit;
}
my $head_print = 0;
foreach my $groups (@module_group) {
if($head_print == 0) {
$head_print = 1;
print "id_module_group, group_name\n";
}
print $groups->{'id_mg'}.",".safe_output($groups->{'name'})."\n";
}
if($head_print == 0) {
print_log "[INFO] No groups found\n\n";
}
}
sub cli_module_group_synch() {
my $other = @ARGV[2];
my $return_type = @ARGV[3];
if ($return_type eq '') {
$return_type = 'csv';
}
my $result = api_call(\%conf,'set', 'module_group_synch', undef, undef, "$other", $return_type);
print "$result \n\n ";
}
############################################################################## ##############################################################################
# Create network module from component. # Create network module from component.
# Related option: --create_network_module_from_component # Related option: --create_network_module_from_component
@ -3029,6 +3083,35 @@ sub cli_delete_alert_template() {
exist_check($result,'alert template',$template_name); exist_check($result,'alert template',$template_name);
} }
##############################################################################
# Get alert actions.
# Related option: --get_alert_actions
##############################################################################
sub cli_get_alert_actions() {
my ($action_name,$separator,$return_type) = @ARGV[2..4];
if ($return_type eq '') {
$return_type = 'csv';
}
my $result = api_call(\%conf,'get', 'alert_actions', undef, undef, "$action_name|$separator",$return_type);
print "$result \n\n ";
}
##############################################################################
# Get alert actions in nodes.
# Related option: --get_alert_actions_meta
##############################################################################
sub cli_get_alert_actions_meta() {
my ($server_name,$action_name,$separator,$return_type) = @ARGV[2..5];
if ($return_type eq '') {
$return_type = 'csv';
}
my $result = api_call(\%conf,'get', 'alert_actions_meta', undef, undef, "$server_name|$action_name|$separator",$return_type);
print "$result \n\n ";
}
############################################################################## ##############################################################################
# Add profile. # Add profile.
# Related option: --add_profile # Related option: --add_profile
@ -4459,6 +4542,18 @@ sub cli_disable_double_auth () {
exit; exit;
} }
###############################################################################
# Synchronize metaconsole users
# Related option: --meta_synch_user
###############################################################################
sub cli_meta_synch_user() {
my ($user_name,$server_name,$profile_mode,$group,$profiles,$create_groups) = @ARGV[2..7];
my $result = api_call(\%conf,'set', 'meta_synch_user', undef, undef, "$user_name|$server_name|$profile_mode|$group|$profiles|$create_groups");
print "$result \n\n ";
}
############################################################################### ###############################################################################
# Enable user # Enable user
# Related option: --enable_user # Related option: --enable_user
@ -5710,6 +5805,10 @@ sub pandora_manage_main ($$$) {
param_check($ltotal, 1); param_check($ltotal, 1);
cli_disable_double_auth(); cli_disable_double_auth();
} }
elsif ($param eq '--meta_synch_user') {
param_check($ltotal, 6, 4);
cli_meta_synch_user();
}
elsif ($param eq '--disable_group') { elsif ($param eq '--disable_group') {
param_check($ltotal, 1); param_check($ltotal, 1);
cli_disable_group(); cli_disable_group();
@ -5734,10 +5833,19 @@ sub pandora_manage_main ($$$) {
param_check($ltotal, 38, 35); param_check($ltotal, 38, 35);
cli_create_web_module(0); cli_create_web_module(0);
} }
elsif ($param eq '--get_module_group') {
param_check($ltotal, 1, 1);
cli_get_module_group();
}
elsif ($param eq '--create_module_group') { elsif ($param eq '--create_module_group') {
param_check($ltotal, 1, 1); param_check($ltotal, 1, 1);
cli_create_module_group(); cli_create_module_group();
} }
elsif ($param eq '--module_group_synch') {
param_check($ltotal, 2, 1);
cli_module_group_synch();
}
elsif ($param eq '--create_network_module') { elsif ($param eq '--create_network_module') {
param_check($ltotal, 32, 20); param_check($ltotal, 32, 20);
cli_create_network_module(0); cli_create_network_module(0);
@ -5914,6 +6022,14 @@ sub pandora_manage_main ($$$) {
param_check($ltotal, 1); param_check($ltotal, 1);
cli_delete_alert_template(); cli_delete_alert_template();
} }
elsif ($param eq '--get_alert_actions') {
param_check($ltotal, 3, 3);
cli_get_alert_actions();
}
elsif ($param eq '--get_alert_actions_meta') {
param_check($ltotal, 4, 4);
cli_get_alert_actions_meta();
}
elsif ($param eq '--update_alert_template') { elsif ($param eq '--update_alert_template') {
param_check($ltotal, 3); param_check($ltotal, 3);
cli_alert_template_update(); cli_alert_template_update();