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

Former-commit-id: 311dc42f717a4419371d0de20c048bd5e0a9cd00
This commit is contained in:
fermin831 2019-01-30 12:04:56 +01:00
commit ac3792690c
28 changed files with 307 additions and 34 deletions

View File

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

@ -42,7 +42,7 @@ my $Sem = undef;
my $ThreadSem = undef; my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.731'; use constant AGENT_VERSION => '7.0NG.731';
use constant AGENT_BUILD => '190129'; use constant AGENT_BUILD => '190130';
# 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.731 %define version 7.0NG.731
%define release 1 %define release 190130
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.731 %define version 7.0NG.731
%define release 1 %define release 190130
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.731" PI_VERSION="7.0NG.731"
PI_BUILD="190129" PI_BUILD="190130"
OS_NAME=`uname -s` OS_NAME=`uname -s`
FORCE=0 FORCE=0

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{} {}
Version Version
{190129} {190130}
ViewReadme ViewReadme
{Yes} {Yes}
@ -2387,7 +2387,7 @@ Windows,BuildSeparateArchives
{No} {No}
Windows,Executable Windows,Executable
{<%AppName%>-Setup<%Ext%>} {<%AppName%>-<%Version%>-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.731(Build 190129)") #define PANDORA_VERSION ("7.0NG.731(Build 190130)")
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.731(Build 190129))" VALUE "ProductVersion", "(7.0NG.731(Build 190130))"
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.731 Version: 7.0NG.731-190130
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.731" pandora_version="7.0NG.731-190130"
package_pear=0 package_pear=0
package_pandora=1 package_pandora=1

View File

@ -22,7 +22,7 @@
/** /**
* Pandora build version and version * Pandora build version and version
*/ */
$build_version = 'PC190129'; $build_version = 'PC190130';
$pandora_version = 'v7.0NG.731'; $pandora_version = 'v7.0NG.731';
// Do not overwrite default timezone set if defined. // Do not overwrite default timezone set if defined.

View File

@ -37,6 +37,7 @@ enterprise_include_once ('include/functions_events.php');
enterprise_include_once ('include/functions_agents.php'); enterprise_include_once ('include/functions_agents.php');
enterprise_include_once ('include/functions_modules.php'); enterprise_include_once ('include/functions_modules.php');
enterprise_include_once ('include/functions_clusters.php'); enterprise_include_once ('include/functions_clusters.php');
enterprise_include_once ('include/functions_alerts.php');
/** /**
* Parse the "other" parameter. * Parse the "other" parameter.
@ -4514,6 +4515,45 @@ function api_get_all_alert_templates($thrash1, $thrash2, $other, $thrash3) {
} }
} }
function api_get_all_alert_commands($thrash1, $thrash2, $other, $thrash3) {
global $config;
if (defined ('METACONSOLE')) {
return;
}
if (!isset($other['data'][0]))
$separator = ';'; // by default
else
$separator = $other['data'][0];
if (!check_acl($config["id_user"], 0, "LM")) {
returnError("forbidden", "csv");
return;
}
$commands = db_get_all_rows_filter(
'talert_commands',
array('id_group' => array_keys(users_get_groups(false, "LM")))
);
if ($commands === false) $commands = array ();
if ($commands !== false) {
$data['type'] = 'array';
$data['data'] = $commands;
}
if (!$commands) {
returnError('error_get_all_alert_commands',
__('Error getting all alert commands.'));
}
else {
returnData('csv', $data, $separator);
}
}
/** /**
* Get an alert tamplate, and print the result like a csv. * Get an alert tamplate, and print the result like a csv.
* *
@ -7841,6 +7881,108 @@ function api_set_module_group_synch($thrash1, $thrash2, $other, $thrash4) {
} }
/**
* Create a new alert command
* @param $id as command name (optional)
* other=<serialized_parameters> (mandatory). Are the following in this order:
* <name>
* <command> (mandatory)
* <id_group> (optional)
* <description> (optional)
* <internal> (optional)
* <field_description_1><field_value_1><field_description_2><field_value_2>...<field_description_n><field_value_n> (optional)
example:
*http://localhost/pandora_console/include/api.php?op=set&op2=alert_commands&id=PRUEBA1&other=command|0|Desc|1|des1|val1|des2|val2|des3|val3||val4|des5&other_mode=url_encode_separator_|&apipass=1234&user=admin&pass=pandora
*/
function api_set_alert_commands($id, $thrash2, $other, $trash1) {
global $config;
$command = $other['data'][0];
$id_group = 0;
if ($other['data'][1] != '')
$id_group = $other['data'][1];
$description = $other['data'][2];
$internal = $other['data'][3];
if (defined ('METACONSOLE')) {
return;
}
if (!check_acl($config['id_user'], 0, "LW")){
returnError('forbidden', 'string');
return;
}
$name = db_get_value ('id', 'talert_commands', 'name', $id);
$group = db_get_value ('id_grupo', 'tgrupo', 'id_grupo', $id_group);
if ($id == '' || !$id) {
returnError('error_parameter', __('Name cannot be empty.'));
return;
}
if ($command == '' || !$command) {
returnError('error_parameter', __('Command cannot be empty.'));
return;
}
if ($name) {
returnError('error_parameter', __('Name already exist'));
return;
}
if (!$group && $id_group != 0) {
returnError('error_parameter', __('Group does not exist'));
return;
}
if ($other['type'] == 'string') {
returnError('error_parameter', 'Error in the parameters.');
return;
}
else if ($other['type'] == 'array') {
$fields_descriptions = array();
$fields_values = array();
$max_macro_fields = $config['max_macro_fields'] * 2;
$values = array();
for ($i=0;$i<$max_macro_fields; $i++) {
$n = $i + 4;
if (!$other['data'][$n])
$other['data'][$n] = '';
if ($n%2==0)
$fields_descriptions[] = $other['data'][$n];
else
$fields_values[] = $other['data'][$n];
}
$fields_descriptions_encode = io_json_mb_encode($fields_descriptions);
$fields_values_encode = io_json_mb_encode($fields_values);
$values = array('id_group' => $id_group,
'description' => $description, 'internal' => $internal, 'fields_descriptions' => $fields_descriptions_encode,
'fields_values' => $fields_values_encode);
$return = alerts_create_alert_command($id, $command, $values);
$data['type'] = 'string';
if ($return === false) {
$data['data'] = 0;
}
else {
$data['data'] = $return;
}
returnData('string', $data);
return;
}
}
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();

View File

@ -6395,7 +6395,7 @@ function reporting_custom_graph($report, $content, $type = 'dinamic',
$graphs = db_get_all_rows_field_filter ("tgraph", "id_graph", $content['id_gs']); $graphs = db_get_all_rows_field_filter ("tgraph", "id_graph", $content['id_gs']);
$id_graph = $content['id_gs']; $id_graph = $content['id_gs'];
} }
else if($type_report == "automatic_graph"){ else if($type_report == "automatic_graph") {
$graphs[0]["stacked"] = ''; $graphs[0]["stacked"] = '';
$graphs[0]["summatory_series"] = ''; $graphs[0]["summatory_series"] = '';
$graphs[0]["average_series"] = ''; $graphs[0]["average_series"] = '';
@ -6403,15 +6403,14 @@ function reporting_custom_graph($report, $content, $type = 'dinamic',
$graphs[0]["fullscale"] = $content['style']['fullscale']; $graphs[0]["fullscale"] = $content['style']['fullscale'];
$modules = $content['id_agent_module']; $modules = $content['id_agent_module'];
if(!$modules){ if (is_metaconsole()) {
$module_source = db_get_all_rows_sql( $module_source = db_get_all_rows_sql(
"SELECT id_agent_module, id_server "SELECT id_agent_module, id_server
FROM tgraph_source FROM tgraph_source
WHERE id_graph = " . WHERE id_graph = " .
$content['id_gs'] $content['id_gs']);
);
if(isset($module_source) && is_array($module_source)){ if(isset($module_source) && is_array($module_source)) {
$modules = array(); $modules = array();
foreach ($module_source as $key => $value) { foreach ($module_source as $key => $value) {
$modules[$key]['module'] = $value['id_agent_module']; $modules[$key]['module'] = $value['id_agent_module'];

View File

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

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_console %define name pandorafms_console
%define version 7.0NG.731 %define version 7.0NG.731
%define release 1 %define release 190130
# 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.731 %define version 7.0NG.731
%define release 1 %define release 190130
%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

@ -1,5 +1,5 @@
package: pandorafms-server package: pandorafms-server
Version: 7.0NG.731 Version: 7.0NG.731-190130
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.731" pandora_version="7.0NG.731-190130"
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.731"; my $pandora_version = "7.0NG.731";
my $pandora_build = "190129"; my $pandora_build = "190130";
our $VERSION = $pandora_version." ".$pandora_build; our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash # Setup hash

View File

@ -163,6 +163,7 @@ our @EXPORT = qw(
pandora_add_agent_address pandora_add_agent_address
pandora_audit pandora_audit
pandora_create_agent pandora_create_agent
pandora_create_alert_command
pandora_create_group pandora_create_group
pandora_create_incident pandora_create_incident
pandora_create_module pandora_create_module
@ -2681,6 +2682,23 @@ sub pandora_delete_all_template_module_actions ($$) {
return db_do ($dbh, 'DELETE FROM talert_template_module_actions WHERE id_alert_template_module = ?', $template_module_id); return db_do ($dbh, 'DELETE FROM talert_template_module_actions WHERE id_alert_template_module = ?', $template_module_id);
} }
########################################################################
=head2 C<< pandora_create_alert_command(I<$pa_config>, I<$parameters>, I<$dbh>) >>
Create a alert command.
=cut
########################################################################
sub pandora_create_alert_command ($$$) {
my ($pa_config, $parameters, $dbh) = @_;
logger($pa_config, "Creating alert command '$parameters->{'name'}'.", 10);
my $command_id = db_process_insert($dbh, 'id', 'talert_commands', $parameters);
return $command_id;
}
######################################################################## ########################################################################
=head2 C<< pandora_update_agent_address(I<$pa_config>, I<$agent_id>, I<$address>, I<$dbh>) >> =head2 C<< pandora_update_agent_address(I<$pa_config>, I<$agent_id>, I<$address>, I<$dbh>) >>

View File

@ -62,6 +62,7 @@ our @EXPORT = qw(
get_agent_module_id get_agent_module_id
get_alert_template_module_id get_alert_template_module_id
get_alert_template_name get_alert_template_name
get_command_id
get_db_rows get_db_rows
get_db_rows_limit get_db_rows_limit
get_db_single_row get_db_single_row
@ -209,6 +210,16 @@ sub get_action_id ($$) {
return defined ($rc) ? $rc : -1; return defined ($rc) ? $rc : -1;
} }
########################################################################
## Return command ID given the command name.
########################################################################
sub get_command_id ($$) {
my ($dbh, $command_name) = @_;
my $rc = get_db_value ($dbh, "SELECT id FROM talert_commands WHERE name = ?", safe_input($command_name));
return defined ($rc) ? $rc : -1;
}
######################################################################## ########################################################################
## Return agent ID given the agent name. ## Return agent ID given the agent name.
######################################################################## ########################################################################

View File

@ -32,7 +32,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.731"; my $pandora_version = "7.0NG.731";
my $pandora_build = "190129"; my $pandora_build = "190130";
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.731 %define version 7.0NG.731
%define release 1 %define release 190130
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.731 %define version 7.0NG.731
%define release 1 %define release 190130
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

@ -9,7 +9,7 @@
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.731" PI_VERSION="7.0NG.731"
PI_BUILD="190129" PI_BUILD="190130"
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.731 PS190129"; my $version = "7.0NG.731 PS190130";
# 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.731 PS190129"; my $version = "7.0NG.731 PS190130";
# save program name for logging # save program name for logging
my $progname = basename($0); my $progname = basename($0);
@ -164,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('--create_alert_command', "<command_name> <comand> [<id_group> <description> \n\t <internal> <fields_descriptions> <fields_values>", 'Create alert command');
help_screen_line('--get_alert_commands', "[<command_name> <comand> <id_group> <description> \n\t <internal>]", 'Displays all alert commands');
help_screen_line('--get_alert_actions', '[<action_name> <separator> <return_type>]', 'get all alert actions'); 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('--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');
@ -3083,6 +3085,99 @@ sub cli_delete_alert_template() {
exist_check($result,'alert template',$template_name); exist_check($result,'alert template',$template_name);
} }
##############################################################################
# Add alert command.
# Related option: --create_alert_command
##############################################################################
sub cli_create_alert_command() {
my ($command_name,$command,$group_name,$description,$internal,$fields_descriptions,$fields_values) = @ARGV[2..8];
print_log "[INFO] Adding command '$command_name'\n\n";
my $command_id = get_command_id($dbh,$command_name);
non_exist_check($command_id,'command',$command_name);
my $id_group;
if (! $group_name || $group_name eq "All") {
$id_group = 0;
}
else {
$id_group = get_group_id($dbh,$group_name);
exist_check($id_group,'group',$group_name);
}
my %parameters;
$parameters{'name'} = $command_name;
$parameters{'command'} = $command;
$parameters{'id_group'} = $id_group;
$parameters{'description'} = $description;
$parameters{'internal'} = $internal;
$parameters{'fields_descriptions'} = $fields_descriptions;
$parameters{'fields_values'} = $fields_values;
pandora_create_alert_command ($conf, \%parameters, $dbh);
}
##############################################################################
# Show all the alert commands (without parameters) or the alert commands with a filter parameters
# Related option: --get_alert_commands
##############################################################################
sub cli_get_alert_commands() {
my ($command_name, $command, $group_name, $description, $internal) = @ARGV[2..6];
my $id_group;
my $condition = ' 1=1 ';
if($command_name ne '') {
my $name = safe_input ($command_name);
$condition .= " AND name LIKE '%$name%' ";
}
if($command ne '') {
$condition .= " AND command LIKE '%$command%' ";
}
if($group_name ne '') {
$id_group = get_group_id($dbh, $group_name);
exist_check($id_group,'group',$group_name);
$condition .= " AND id_group = $id_group ";
}
if($description ne '') {
$condition .= " AND description LIKE '%$description%' ";
}
if($internal ne '') {
$condition .= " AND internal = $internal ";
}
my @alert_command = get_db_rows ($dbh, "SELECT * FROM talert_commands WHERE $condition");
if(scalar(@alert_command) == 0) {
print_log "[INFO] No commands found\n\n";
exit;
}
my $head_print = 0;
foreach my $commands (@alert_command) {
if($head_print == 0) {
$head_print = 1;
print "id_command, command_name\n";
}
print $commands->{'id'}.",".safe_output($commands->{'name'})."\n";
}
if($head_print == 0) {
print_log "[INFO] No commands found\n\n";
}
}
############################################################################## ##############################################################################
# Get alert actions. # Get alert actions.
# Related option: --get_alert_actions # Related option: --get_alert_actions
@ -6019,9 +6114,17 @@ sub pandora_manage_main ($$$) {
cli_create_alert_template(); cli_create_alert_template();
} }
elsif ($param eq '--delete_alert_template') { elsif ($param eq '--delete_alert_template') {
param_check($ltotal, 1); param_check($ltotal, 7);
cli_delete_alert_template(); cli_delete_alert_template();
} }
elsif ($param eq '--create_alert_command') {
param_check($ltotal, 7, 2);
cli_create_alert_command();
}
elsif ($param eq '--get_alert_commands') {
param_check($ltotal, 5, 5);
cli_get_alert_commands();
}
elsif ($param eq '--get_alert_actions') { elsif ($param eq '--get_alert_actions') {
param_check($ltotal, 3, 3); param_check($ltotal, 3, 3);
cli_get_alert_actions(); cli_get_alert_actions();