Merge remote-tracking branch 'origin/develop' into ent-3674-discovery-fase-3

Former-commit-id: 3640f0730c8f44cfe865b5a2947b8d0ee5c56ad0
This commit is contained in:
fbsanchez 2019-04-11 15:12:46 +02:00
commit 342e4b78c9
49 changed files with 825 additions and 359 deletions

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix package: pandorafms-agent-unix
Version: 7.0NG.733-190408 Version: 7.0NG.733-190411
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.733-190408" pandora_version="7.0NG.733-190411"
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.733'; use constant AGENT_VERSION => '7.0NG.733';
use constant AGENT_BUILD => '190408'; use constant AGENT_BUILD => '190411';
# 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;
@ -662,6 +662,8 @@ sub parse_conf_modules($) {
$module->{'ff_timeout'} = $1; $module->{'ff_timeout'} = $1;
} elsif ($line =~ /^\s*module_each_ff\s+(\S+)\s*$/) { } elsif ($line =~ /^\s*module_each_ff\s+(\S+)\s*$/) {
$module->{'each_ff'} = $1; $module->{'each_ff'} = $1;
} elsif ($line =~ /^\s*module_ff_type\s+(\d+)\s*$/) {
$module->{'ff_type'} = $1;
# Macros # Macros
} elsif ($line =~ /^\s*module_macro(\S+)\s+(.*)\s*$/) { } elsif ($line =~ /^\s*module_macro(\S+)\s+(.*)\s*$/) {
$module->{'macros'}{$1} = $2; $module->{'macros'}{$1} = $2;
@ -2101,45 +2103,28 @@ sub cron_next_execution {
} }
# Get day of the week and month from cron config # Get day of the week and month from cron config
my ($mday, $wday) = (split (/\s/, $cron))[2, 4]; my ($wday) = (split (/\s/, $cron))[4];
# Check the wday values to avoid infinite loop
my ($wday_down, $wday_up) = cron_get_interval($wday);
if ($wday_down ne "*" && ($wday_down > 6 || (defined($wday_up) && $wday_up > 6))) {
log_message('setup', "Invalid cron configuration $cron. Day of the week is out of limits.");
$wday = "*";
}
# Get current time and day of the week # Get current time and day of the week
my $cur_time = time(); my $cur_time = time();
my $cur_wday = (localtime ($cur_time))[6]; my $cur_wday = (localtime ($cur_time))[6];
# Any day of the week my $nex_time = cron_next_execution_date ($cron, $cur_time, $interval);
if ($wday eq '*') {
my $nex_time = cron_next_execution_date ($cron, $cur_time, $interval); # Check the day
return $nex_time - time(); while (!cron_check_interval($wday, (localtime ($nex_time))[6])) {
} # If it does not acomplish the day of the week, go to the next day.
# A range? $nex_time += 86400;
else { $nex_time = cron_next_execution_date ($cron, $nex_time, 0);
$wday = cron_get_closest_in_range ($cur_wday, $wday);
} }
# A specific day of the week return $nex_time - time();
my $count = 0;
my $nex_time = $cur_time;
do {
$nex_time = cron_next_execution_date ($cron, $nex_time, $interval);
my $nex_time_wd = $nex_time;
my ($nex_mon, $nex_wday) = (localtime ($nex_time_wd))[4, 6];
my $nex_mon_wd;
do {
# Check the day of the week
if ($nex_wday == $wday) {
return $nex_time_wd - time();
}
# Move to the next day of the month
$nex_time_wd += 86400;
($nex_mon_wd, $nex_wday) = (localtime ($nex_time_wd))[4, 6];
} while ($mday eq '*' && $nex_mon_wd == $nex_mon);
$count++;
} while ($count < 60);
# Something went wrong, default to 5 minutes
return $interval;
} }
############################################################################### ###############################################################################
@ -2151,7 +2136,30 @@ sub cron_check_syntax ($) {
return 0 if !defined ($cron); return 0 if !defined ($cron);
return ($cron =~ m/^(\d|\*|-)+ (\d|\*|-)+ (\d|\*|-)+ (\d|\*|-)+ (\d|\*|-)+$/); return ($cron =~ m/^(\d|\*|-)+ (\d|\*|-)+ (\d|\*|-)+ (\d|\*|-)+ (\d|\*|-)+$/);
} }
###############################################################################
# Check if a value is inside an interval.
###############################################################################
sub cron_check_interval {
my ($elem_cron, $elem_curr_time) = @_;
# Return 1 if wildcard.
return 1 if ($elem_cron eq "*");
my ($down, $up) = cron_get_interval($elem_cron);
# Check if it is not a range
if (!defined($up)) {
return ($down == $elem_curr_time) ? 1 : 0;
}
# Check if it is on the range
if ($down < $up) {
return 0 if ($elem_curr_time < $down || $elem_curr_time > $up);
} else {
return 0 if ($elem_curr_time > $down || $elem_curr_time < $up);
}
return 1;
}
############################################################################### ###############################################################################
# Get the next execution date for the given cron entry in seconds since epoch. # Get the next execution date for the given cron entry in seconds since epoch.
############################################################################### ###############################################################################
@ -2189,8 +2197,7 @@ sub cron_next_execution_date {
my @nex_time_array = @curr_time_array; my @nex_time_array = @curr_time_array;
# Update minutes # Update minutes
my ($min_down, undef) = cron_get_interval ($min); $nex_time_array[0] = cron_get_next_time_element($min);
$nex_time_array[0] = ($min_down eq '*') ? 0 : $min_down;
$nex_time = cron_valid_date(@nex_time_array, $cur_year); $nex_time = cron_valid_date(@nex_time_array, $cur_year);
if ($nex_time >= $cur_time) { if ($nex_time >= $cur_time) {
@ -2224,8 +2231,7 @@ sub cron_next_execution_date {
return $nex_time if cron_is_in_cron(\@cron_array, \@nex_time_array); return $nex_time if cron_is_in_cron(\@cron_array, \@nex_time_array);
#Update the hour if fails #Update the hour if fails
my ($hour_down, undef) = cron_get_interval ($hour); $nex_time_array[1] = cron_get_next_time_element($hour);
$nex_time_array[1] = ($hour_down eq '*') ? 0 : $hour_down;
# When an overflow is passed check the hour update again # When an overflow is passed check the hour update again
$nex_time = cron_valid_date(@nex_time_array, $cur_year); $nex_time = cron_valid_date(@nex_time_array, $cur_year);
@ -2253,10 +2259,9 @@ sub cron_next_execution_date {
return $nex_time if cron_is_in_cron(\@cron_array, \@nex_time_array); return $nex_time if cron_is_in_cron(\@cron_array, \@nex_time_array);
#Update the day if fails #Update the day if fails
my ($mday_down, undef) = cron_get_interval ($mday); $nex_time_array[2] = cron_get_next_time_element($mday, 1);
$nex_time_array[2] = ($mday_down eq '*') ? 1 : $mday_down;
# When an overflow is passed check the day update in the next execution # When an overflow is passed check the hour update in the next execution
$nex_time = cron_valid_date(@nex_time_array, $cur_year); $nex_time = cron_valid_date(@nex_time_array, $cur_year);
if ($nex_time >= $cur_time) { if ($nex_time >= $cur_time) {
return $nex_time if cron_is_in_cron(\@cron_array, \@nex_time_array); return $nex_time if cron_is_in_cron(\@cron_array, \@nex_time_array);
@ -2276,8 +2281,7 @@ sub cron_next_execution_date {
return $nex_time if cron_is_in_cron(\@cron_array, \@nex_time_array); return $nex_time if cron_is_in_cron(\@cron_array, \@nex_time_array);
#Update the month if fails #Update the month if fails
my ($mon_down, undef) = cron_get_interval ($mon); $nex_time_array[3] = cron_get_next_time_element($mon);
$nex_time_array[3] = ($mon_down eq '*') ? 0 : $mon_down;
# When an overflow is passed check the month update in the next execution # When an overflow is passed check the month update in the next execution
$nex_time = cron_valid_date(@nex_time_array, $cur_year); $nex_time = cron_valid_date(@nex_time_array, $cur_year);
@ -2308,23 +2312,30 @@ sub cron_is_in_cron {
#If there is no elements means that is in cron #If there is no elements means that is in cron
return 1 unless (defined($elem_cron) || defined($elem_curr_time)); return 1 unless (defined($elem_cron) || defined($elem_curr_time));
# Go to last element if current is a wild card # Check the element interval
if ($elem_cron ne '*') { return 0 unless (cron_check_interval($elem_cron, $elem_curr_time));
my ($down, $up) = cron_get_interval($elem_cron);
# Check if there is no a range
return 0 if (!defined($up) && ($down != $elem_curr_time));
# Check if there is on the range
if (defined($up)) {
if ($down < $up) {
return 0 if ($elem_curr_time < $down || $elem_curr_time > $up);
} else {
return 0 if ($elem_curr_time > $down || $elem_curr_time < $up);
}
}
}
return cron_is_in_cron(\@deref_elems_cron, \@deref_elems_curr_time); return cron_is_in_cron(\@deref_elems_cron, \@deref_elems_curr_time);
} }
################################################################################
#Get the next tentative time for a cron value or interval in case of overflow.
#Floor data is the minimum localtime data for a position. Ex:
#Ex:
# * should returns floor data.
# 5 should returns 5.
# 10-55 should returns 10.
# 55-10 should retunrs floor data.
################################################################################
sub cron_get_next_time_element {
# Default floor data is 0
my ($curr_element, $floor_data) = @_;
$floor_data = 0 unless defined($floor_data);
my ($elem_down, $elem_up) = cron_get_interval ($curr_element);
return ($elem_down eq '*' || (defined($elem_up) && $elem_down > $elem_up))
? $floor_data
: $elem_down;
}
############################################################################### ###############################################################################
# Returns the interval of a cron element. If there is not a range, # Returns the interval of a cron element. If there is not a range,
# returns an array with the first element in the first place of array # returns an array with the first element in the first place of array
@ -2416,12 +2427,11 @@ sub check_module_cron {
return 1 unless ($is_first); return 1 unless ($is_first);
# Check if current timestamp is a valid cron date # Check if current timestamp is a valid cron date
my $next_execution = cron_next_execution_date( my $next_execution = cron_next_execution(
$module->{'cron'}, $module->{'cron'},
$now - $interval, 0
$interval
); );
return 1 if ($next_execution == $now); return 1 if (time() + $next_execution == $now);
return 0; return 0;
} }
@ -2532,6 +2542,7 @@ sub write_module_xml ($@) {
$Xml .= " <min_ff_event_critical>" . $module->{'min_ff_event_critical'} . "</min_ff_event_critical>\n" if (defined ($module->{'min_ff_event_critical'})); $Xml .= " <min_ff_event_critical>" . $module->{'min_ff_event_critical'} . "</min_ff_event_critical>\n" if (defined ($module->{'min_ff_event_critical'}));
$Xml .= " <ff_timeout>" . $module->{'ff_timeout'} . "</ff_timeout>\n" if (defined ($module->{'ff_timeout'})); $Xml .= " <ff_timeout>" . $module->{'ff_timeout'} . "</ff_timeout>\n" if (defined ($module->{'ff_timeout'}));
$Xml .= " <each_ff>" . $module->{'each_ff'} . "</each_ff>\n" if (defined ($module->{'each_ff'})); $Xml .= " <each_ff>" . $module->{'each_ff'} . "</each_ff>\n" if (defined ($module->{'each_ff'}));
$Xml .= " <ff_type>" . $module->{'ff_type'} . "</ff_type>\n" if (defined ($module->{'ff_type'}));
# Data list # Data list
if ($#data > 0) { if ($#data > 0) {

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_agent_unix %define name pandorafms_agent_unix
%define version 7.0NG.733 %define version 7.0NG.733
%define release 190408 %define release 190411
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.733 %define version 7.0NG.733
%define release 190408 %define release 190411
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.733" PI_VERSION="7.0NG.733"
PI_BUILD="190408" PI_BUILD="190411"
OS_NAME=`uname -s` OS_NAME=`uname -s`
FORCE=0 FORCE=0

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{} {}
Version Version
{190408} {190411}
ViewReadme ViewReadme
{Yes} {Yes}

View File

@ -214,7 +214,7 @@ int Cron::getResetValue (int position) {
int default_value = 0; int default_value = 0;
// Days start in 1 // Days start in 1
if (position == 2) default_value = 1; if (position == 2) default_value = 1;
return isWildCard(position) return (isWildCard(position) || !isNormalInterval(position))
? default_value ? default_value
: this->params[position][CRDOWN]; : this->params[position][CRDOWN];
} }

View File

@ -78,6 +78,7 @@ Pandora_Module::Pandora_Module (string name) {
this->warning_inverse = ""; this->warning_inverse = "";
this->quiet = ""; this->quiet = "";
this->module_ff_interval = ""; this->module_ff_interval = "";
this->module_ff_type = "";
this->module_alert_template = ""; this->module_alert_template = "";
this->module_crontab = ""; this->module_crontab = "";
} }
@ -733,6 +734,13 @@ Pandora_Module::getXml () {
module_xml += this->module_ff_interval; module_xml += this->module_ff_interval;
module_xml += "</module_ff_interval>\n"; module_xml += "</module_ff_interval>\n";
} }
/* Module FF type */
if (this->module_ff_type != "") {
module_xml += "\t<ff_type>";
module_xml += this->module_ff_type;
module_xml += "</ff_type>\n";
}
/* Module Alert template */ /* Module Alert template */
if (this->module_alert_template != "") { if (this->module_alert_template != "") {
@ -1028,6 +1036,16 @@ Pandora_Module::setModuleFFInterval (string value) {
this->module_ff_interval = value; this->module_ff_interval = value;
} }
/**
* Set the module FF type for the module.
*
* @param value module FF type value to set.
*/
void
Pandora_Module::setModuleFFType (string value) {
this->module_ff_type = value;
}
/** /**
* Set the module Alert template for the module. * Set the module Alert template for the module.
* *

View File

@ -176,6 +176,7 @@ namespace Pandora_Modules {
string unit, custom_id, str_warning, str_critical; string unit, custom_id, str_warning, str_critical;
string module_group, warning_inverse, critical_inverse, quiet; string module_group, warning_inverse, critical_inverse, quiet;
string module_ff_interval, module_alert_template, module_crontab; string module_ff_interval, module_alert_template, module_crontab;
string module_ff_type;
string critical_instructions, warning_instructions, unknown_instructions, tags; string critical_instructions, warning_instructions, unknown_instructions, tags;
protected: protected:
@ -277,6 +278,7 @@ namespace Pandora_Modules {
void setWarningInverse (string value); void setWarningInverse (string value);
void setQuiet (string value); void setQuiet (string value);
void setModuleFFInterval (string value); void setModuleFFInterval (string value);
void setModuleFFType (string value);
void setModuleAlertTemplate (string value); void setModuleAlertTemplate (string value);
void setModuleCrontab (string value); void setModuleCrontab (string value);

View File

@ -119,6 +119,7 @@ using namespace Pandora_Strutils;
#define TOKEN_WARNING_INVERSE ("module_warning_inverse ") #define TOKEN_WARNING_INVERSE ("module_warning_inverse ")
#define TOKEN_QUIET ("module_quiet ") #define TOKEN_QUIET ("module_quiet ")
#define TOKEN_MODULE_FF_INTERVAL ("module_ff_interval ") #define TOKEN_MODULE_FF_INTERVAL ("module_ff_interval ")
#define TOKEN_MODULE_FF_TYPE ("module_ff_type ")
#define TOKEN_MACRO ("module_macro") #define TOKEN_MACRO ("module_macro")
#define TOKEN_NATIVE_ENCODING ("module_native_encoding") #define TOKEN_NATIVE_ENCODING ("module_native_encoding")
#define TOKEN_ALERT_TEMPLATE ("module_alert_template") #define TOKEN_ALERT_TEMPLATE ("module_alert_template")
@ -176,7 +177,7 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
string module_unit, module_group, module_custom_id, module_str_warning, module_str_critical; string module_unit, module_group, module_custom_id, module_str_warning, module_str_critical;
string module_critical_instructions, module_warning_instructions, module_unknown_instructions, module_tags; string module_critical_instructions, module_warning_instructions, module_unknown_instructions, module_tags;
string module_critical_inverse, module_warning_inverse, module_quiet, module_ff_interval; string module_critical_inverse, module_warning_inverse, module_quiet, module_ff_interval;
string module_native_encoding, module_alert_template; string module_native_encoding, module_alert_template, module_ff_type;
string macro; string macro;
Pandora_Module *module; Pandora_Module *module;
bool numeric; bool numeric;
@ -254,6 +255,7 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
module_warning_inverse = ""; module_warning_inverse = "";
module_quiet = ""; module_quiet = "";
module_ff_interval = ""; module_ff_interval = "";
module_ff_type = "";
module_native_encoding = ""; module_native_encoding = "";
module_alert_template = ""; module_alert_template = "";
module_user_session = ""; module_user_session = "";
@ -507,6 +509,10 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
if (module_ff_interval == "") { if (module_ff_interval == "") {
module_ff_interval = parseLine (line, TOKEN_MODULE_FF_INTERVAL); module_ff_interval = parseLine (line, TOKEN_MODULE_FF_INTERVAL);
} }
if (module_ff_type == "") {
module_ff_type = parseLine (line, TOKEN_MODULE_FF_TYPE);
}
if (module_alert_template == "") { if (module_alert_template == "") {
module_alert_template = parseLine (line, TOKEN_ALERT_TEMPLATE); module_alert_template = parseLine (line, TOKEN_ALERT_TEMPLATE);
@ -1087,6 +1093,13 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
} }
} }
if (module_ff_type != "") {
pos_macro = module_ff_type.find(macro_name);
if (pos_macro != string::npos){
module_ff_type.replace(pos_macro, macro_name.size(), macro_value);
}
}
if (module_alert_template != "") { if (module_alert_template != "") {
pos_macro = module_alert_template.find(macro_name); pos_macro = module_alert_template.find(macro_name);
if (pos_macro != string::npos){ if (pos_macro != string::npos){
@ -1447,6 +1460,10 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
if (module_ff_interval != "") { if (module_ff_interval != "") {
module->setModuleFFInterval (module_ff_interval); module->setModuleFFInterval (module_ff_interval);
} }
if (module_ff_type != "") {
module->setModuleFFType (module_ff_type);
}
if (module_alert_template != "") { if (module_alert_template != "") {
module->setModuleAlertTemplate (module_alert_template); module->setModuleAlertTemplate (module_alert_template);

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

View File

@ -1,5 +1,14 @@
START TRANSACTION; START TRANSACTION;
ALTER TABLE `tagente_modulo` ADD COLUMN `ff_type` tinyint(1) unsigned default '0';
ALTER TABLE `tnetwork_component` ADD COLUMN `ff_type` tinyint(1) unsigned default '0';
ALTER TABLE `tlocal_component` ADD COLUMN `ff_type` tinyint(1) unsigned default '0';
ALTER TABLE `tpolicy_modules` ADD COLUMN `ff_type` tinyint(1) unsigned default '0';
ALTER TABLE `tagente_estado` ADD COLUMN `ff_normal` int(4) unsigned default '0';
ALTER TABLE `tagente_estado` ADD COLUMN `ff_warning` int(4) unsigned default '0';
ALTER TABLE `tagente_estado` ADD COLUMN `ff_critical` int(4) unsigned default '0';
UPDATE tuser_task SET parameters = 'a:5:{i:0;a:6:{s:11:\"description\";s:28:\"Report pending to be created\";s:5:\"table\";s:7:\"treport\";s:8:\"field_id\";s:9:\"id_report\";s:10:\"field_name\";s:4:\"name\";s:4:\"type\";s:3:\"int\";s:9:\"acl_group\";s:8:\"id_group\";}i:1;a:2:{s:11:\"description\";s:46:\"Send to email addresses (separated by a comma)\";s:4:\"type\";s:4:\"text\";}i:2;a:2:{s:11:\"description\";s:7:\"Subject\";s:8:\"optional\";i:1;}i:3;a:3:{s:11:\"description\";s:7:\"Message\";s:4:\"type\";s:4:\"text\";s:8:\"optional\";i:1;}i:4;a:2:{s:11:\"description\";s:11:\"Report Type\";s:4:\"type\";s:11:\"report_type\";}}' where function_name = "cron_task_generate_report"; UPDATE tuser_task SET parameters = 'a:5:{i:0;a:6:{s:11:\"description\";s:28:\"Report pending to be created\";s:5:\"table\";s:7:\"treport\";s:8:\"field_id\";s:9:\"id_report\";s:10:\"field_name\";s:4:\"name\";s:4:\"type\";s:3:\"int\";s:9:\"acl_group\";s:8:\"id_group\";}i:1;a:2:{s:11:\"description\";s:46:\"Send to email addresses (separated by a comma)\";s:4:\"type\";s:4:\"text\";}i:2;a:2:{s:11:\"description\";s:7:\"Subject\";s:8:\"optional\";i:1;}i:3;a:3:{s:11:\"description\";s:7:\"Message\";s:4:\"type\";s:4:\"text\";s:8:\"optional\";i:1;}i:4;a:2:{s:11:\"description\";s:11:\"Report Type\";s:4:\"type\";s:11:\"report_type\";}}' where function_name = "cron_task_generate_report";
ALTER TABLE `treport_content` ADD COLUMN `total_time` TINYINT(1) DEFAULT '1'; ALTER TABLE `treport_content` ADD COLUMN `total_time` TINYINT(1) DEFAULT '1';

View File

@ -58,6 +58,7 @@ CREATE TABLE IF NOT EXISTS `tlocal_component` (
ALTER TABLE `tlocal_component` ADD COLUMN `dynamic_next` bigint(20) NOT NULL default '0'; ALTER TABLE `tlocal_component` ADD COLUMN `dynamic_next` bigint(20) NOT NULL default '0';
ALTER TABLE `tlocal_component` ADD COLUMN `dynamic_two_tailed` tinyint(1) unsigned default '0'; ALTER TABLE `tlocal_component` ADD COLUMN `dynamic_two_tailed` tinyint(1) unsigned default '0';
ALTER TABLE `tlocal_component` ADD COLUMN `ff_type` tinyint(1) unsigned default '0';
-- ----------------------------------------------------- -- -----------------------------------------------------
-- Table `tpolicy_modules` -- Table `tpolicy_modules`
@ -136,6 +137,7 @@ CREATE TABLE IF NOT EXISTS `tpolicy_modules` (
ALTER TABLE `tpolicy_modules` ADD COLUMN `dynamic_next` bigint(20) NOT NULL default '0'; ALTER TABLE `tpolicy_modules` ADD COLUMN `dynamic_next` bigint(20) NOT NULL default '0';
ALTER TABLE `tpolicy_modules` ADD COLUMN `dynamic_two_tailed` tinyint(1) unsigned default '0'; ALTER TABLE `tpolicy_modules` ADD COLUMN `dynamic_two_tailed` tinyint(1) unsigned default '0';
ALTER TABLE `tpolicy_modules` ADD COLUMN `ff_type` tinyint(1) unsigned default '0';
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
-- Table `tpolicies` -- Table `tpolicies`
@ -1162,6 +1164,9 @@ ALTER TABLE tagente_estado MODIFY `status_changes` tinyint(4) unsigned default 0
ALTER TABLE tagente_estado CHANGE `last_known_status` `known_status` tinyint(4) default 0; ALTER TABLE tagente_estado CHANGE `last_known_status` `known_status` tinyint(4) default 0;
ALTER TABLE tagente_estado ADD COLUMN `last_known_status` tinyint(4) default 0; ALTER TABLE tagente_estado ADD COLUMN `last_known_status` tinyint(4) default 0;
ALTER TABLE tagente_estado ADD COLUMN last_unknown_update bigint(20) NOT NULL default 0; ALTER TABLE tagente_estado ADD COLUMN last_unknown_update bigint(20) NOT NULL default 0;
ALTER TABLE `tagente_estado` ADD COLUMN `ff_normal` int(4) unsigned default '0';
ALTER TABLE `tagente_estado` ADD COLUMN `ff_warning` int(4) unsigned default '0';
ALTER TABLE `tagente_estado` ADD COLUMN `ff_critical` int(4) unsigned default '0';
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
-- Table `talert_actions` -- Table `talert_actions`
@ -1272,6 +1277,10 @@ ALTER TABLE tagente_modulo ADD COLUMN `dynamic_next` bigint(20) NOT NULL default
ALTER TABLE tagente_modulo ADD COLUMN `dynamic_two_tailed` tinyint(1) unsigned default '0'; ALTER TABLE tagente_modulo ADD COLUMN `dynamic_two_tailed` tinyint(1) unsigned default '0';
ALTER TABLE tagente_modulo ADD COLUMN `parent_module_id` int(10) unsigned NOT NULL default 0; ALTER TABLE tagente_modulo ADD COLUMN `parent_module_id` int(10) unsigned NOT NULL default 0;
ALTER TABLE `tagente_modulo` ADD COLUMN `cps` int NOT NULL default 0; ALTER TABLE `tagente_modulo` ADD COLUMN `cps` int NOT NULL default 0;
ALTER TABLE `tagente_modulo` ADD COLUMN `ff_type` tinyint(1) unsigned default '0';
ALTER TABLE `tagente_modulo` ADD COLUMN `ff_normal` int(4) unsigned default '0';
ALTER TABLE `tagente_modulo` ADD COLUMN `ff_warning` int(4) unsigned default '0';
ALTER TABLE `tagente_modulo` ADD COLUMN `ff_critical` int(4) unsigned default '0';
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
-- Table `tagente_datos` -- Table `tagente_datos`
@ -1291,6 +1300,7 @@ ALTER TABLE tnetwork_component ADD COLUMN `dynamic_max` int(4) default '0';
ALTER TABLE tnetwork_component ADD COLUMN `dynamic_min` int(4) default '0'; ALTER TABLE tnetwork_component ADD COLUMN `dynamic_min` int(4) default '0';
ALTER TABLE tnetwork_component ADD COLUMN `dynamic_next` bigint(20) NOT NULL default '0'; ALTER TABLE tnetwork_component ADD COLUMN `dynamic_next` bigint(20) NOT NULL default '0';
ALTER TABLE tnetwork_component ADD COLUMN `dynamic_two_tailed` tinyint(1) unsigned default '0'; ALTER TABLE tnetwork_component ADD COLUMN `dynamic_two_tailed` tinyint(1) unsigned default '0';
ALTER TABLE `tnetwork_component` ADD COLUMN `ff_type` tinyint(1) unsigned default '0';
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
-- Table `tagente` -- Table `tagente`

View File

@ -106,6 +106,7 @@ if (isset($_POST['template_id'])) {
'min_ff_event_normal' => $row2['min_ff_event_normal'], 'min_ff_event_normal' => $row2['min_ff_event_normal'],
'min_ff_event_warning' => $row2['min_ff_event_warning'], 'min_ff_event_warning' => $row2['min_ff_event_warning'],
'min_ff_event_critical' => $row2['min_ff_event_critical'], 'min_ff_event_critical' => $row2['min_ff_event_critical'],
'ff_type' => $row2['ff_type'],
]; ];
$name = $row2['name']; $name = $row2['name'];

View File

@ -1320,6 +1320,7 @@ if ($update_module || $create_module) {
$ff_event_normal = (int) get_parameter('ff_event_normal'); $ff_event_normal = (int) get_parameter('ff_event_normal');
$ff_event_warning = (int) get_parameter('ff_event_warning'); $ff_event_warning = (int) get_parameter('ff_event_warning');
$ff_event_critical = (int) get_parameter('ff_event_critical'); $ff_event_critical = (int) get_parameter('ff_event_critical');
$ff_type = (int) get_parameter('ff_type');
$each_ff = (int) get_parameter('each_ff'); $each_ff = (int) get_parameter('each_ff');
$ff_timeout = (int) get_parameter('ff_timeout'); $ff_timeout = (int) get_parameter('ff_timeout');
$unit = (string) get_parameter('unit_select'); $unit = (string) get_parameter('unit_select');
@ -1482,6 +1483,7 @@ if ($update_module) {
'min_ff_event_normal' => $ff_event_normal, 'min_ff_event_normal' => $ff_event_normal,
'min_ff_event_warning' => $ff_event_warning, 'min_ff_event_warning' => $ff_event_warning,
'min_ff_event_critical' => $ff_event_critical, 'min_ff_event_critical' => $ff_event_critical,
'ff_type' => $ff_type,
'each_ff' => $each_ff, 'each_ff' => $each_ff,
'ff_timeout' => $ff_timeout, 'ff_timeout' => $ff_timeout,
'unit' => io_safe_output($unit), 'unit' => io_safe_output($unit),
@ -1677,6 +1679,7 @@ if ($create_module) {
'min_ff_event_normal' => $ff_event_normal, 'min_ff_event_normal' => $ff_event_normal,
'min_ff_event_warning' => $ff_event_warning, 'min_ff_event_warning' => $ff_event_warning,
'min_ff_event_critical' => $ff_event_critical, 'min_ff_event_critical' => $ff_event_critical,
'ff_type' => $ff_type,
'each_ff' => $each_ff, 'each_ff' => $each_ff,
'ff_timeout' => $ff_timeout, 'ff_timeout' => $ff_timeout,
'unit' => io_safe_output($unit), 'unit' => io_safe_output($unit),

View File

@ -249,6 +249,7 @@ if ($id_agent_module) {
$ff_event_normal = $module['min_ff_event_normal']; $ff_event_normal = $module['min_ff_event_normal'];
$ff_event_warning = $module['min_ff_event_warning']; $ff_event_warning = $module['min_ff_event_warning'];
$ff_event_critical = $module['min_ff_event_critical']; $ff_event_critical = $module['min_ff_event_critical'];
$ff_type = $module['ff_type'];
$each_ff = $module['each_ff']; $each_ff = $module['each_ff'];
$ff_timeout = $module['ff_timeout']; $ff_timeout = $module['ff_timeout'];
// Select tag info. // Select tag info.
@ -393,6 +394,7 @@ if ($id_agent_module) {
$ff_event_normal = ''; $ff_event_normal = '';
$ff_event_warning = ''; $ff_event_warning = '';
$ff_event_critical = ''; $ff_event_critical = '';
$ff_type = 0;
$id_category = 0; $id_category = 0;

View File

@ -496,10 +496,28 @@ if (modules_is_string_type($id_module_type) || $edit) {
$table_simple->data[5][1] .= '<br /><em>'.__('Inverse interval').'</em>'; $table_simple->data[5][1] .= '<br /><em>'.__('Inverse interval').'</em>';
$table_simple->data[5][1] .= html_print_checkbox('critical_inverse', 1, $critical_inverse, true, $disabledBecauseInPolicy); $table_simple->data[5][1] .= html_print_checkbox('critical_inverse', 1, $critical_inverse, true, $disabledBecauseInPolicy);
// FF stands for Flip-flop // FF stands for Flip-flop.
$table_simple->data[6][0] = __('FF threshold').' '.ui_print_help_icon('ff_threshold', true); $table_simple->data[6][0] = __('FF threshold').' ';
$table_simple->data[6][0] .= ui_print_help_icon('ff_threshold', true);
$table_simple->data[6][1] = html_print_radio_button('each_ff', 0, '', $each_ff, true, $disabledBecauseInPolicy).' '.__('All state changing').' : '; $table_simple->data[6][1] .= __('Keep counters');
$table_simple->data[6][1] .= html_print_checkbox(
'ff_type',
1,
$ff_type,
true,
$disabledBecauseInPolicy
).'<br />';
$table_simple->data[6][1] .= html_print_radio_button(
'each_ff',
0,
'',
$each_ff,
true,
$disabledBecauseInPolicy
);
$table_simple->data[6][1] .= ' '.__('All state changing').' : ';
$table_simple->data[6][1] .= html_print_input_text( $table_simple->data[6][1] .= html_print_input_text(
'ff_event', 'ff_event',
$ff_event, $ff_event,
@ -512,7 +530,16 @@ $table_simple->data[6][1] .= html_print_input_text(
'', '',
$classdisabledBecauseInPolicy $classdisabledBecauseInPolicy
).'<br />'; ).'<br />';
$table_simple->data[6][1] .= html_print_radio_button('each_ff', 1, '', $each_ff, true, $disabledBecauseInPolicy).' '.__('Each state changing').' : '; $table_simple->data[6][1] .= html_print_radio_button(
'each_ff',
1,
'',
$each_ff,
true,
$disabledBecauseInPolicy
);
$table_simple->data[6][1] .= ' '.__('Each state changing').' : ';
$table_simple->data[6][1] .= __('To normal'); $table_simple->data[6][1] .= __('To normal');
$table_simple->data[6][1] .= html_print_input_text( $table_simple->data[6][1] .= html_print_input_text(
'ff_event_normal', 'ff_event_normal',
@ -526,6 +553,7 @@ $table_simple->data[6][1] .= html_print_input_text(
'', '',
$classdisabledBecauseInPolicy $classdisabledBecauseInPolicy
).' '; ).' ';
$table_simple->data[6][1] .= __('To warning'); $table_simple->data[6][1] .= __('To warning');
$table_simple->data[6][1] .= html_print_input_text( $table_simple->data[6][1] .= html_print_input_text(
'ff_event_warning', 'ff_event_warning',
@ -539,6 +567,7 @@ $table_simple->data[6][1] .= html_print_input_text(
'', '',
$classdisabledBecauseInPolicy $classdisabledBecauseInPolicy
).' '; ).' ';
$table_simple->data[6][1] .= __('To critical'); $table_simple->data[6][1] .= __('To critical');
$table_simple->data[6][1] .= html_print_input_text( $table_simple->data[6][1] .= html_print_input_text(
'ff_event_critical', 'ff_event_critical',
@ -552,16 +581,31 @@ $table_simple->data[6][1] .= html_print_input_text(
'', '',
$classdisabledBecauseInPolicy $classdisabledBecauseInPolicy
); );
$table_simple->data[7][0] = __('Historical data'); $table_simple->data[7][0] = __('Historical data');
if ($disabledBecauseInPolicy) { if ($disabledBecauseInPolicy) {
// If is disabled, we send a hidden in his place and print a false checkbox because HTML dont send disabled fields and could be disabled by error // If is disabled, we send a hidden in his place and print a false
$table_simple->data[7][1] = html_print_checkbox('history_data_fake', 1, $history_data, true, $disabledBecauseInPolicy); // checkbox because HTML dont send disabled fields
// and could be disabled by error.
$table_simple->data[7][1] = html_print_checkbox(
'history_data_fake',
1,
$history_data,
true,
$disabledBecauseInPolicy
);
$table_simple->data[7][1] .= '<input type="hidden" name="history_data" value="'.(int) $history_data.'">'; $table_simple->data[7][1] .= '<input type="hidden" name="history_data" value="'.(int) $history_data.'">';
} else { } else {
$table_simple->data[7][1] = html_print_checkbox('history_data', 1, $history_data, true, $disabledBecauseInPolicy); $table_simple->data[7][1] = html_print_checkbox(
'history_data',
1,
$history_data,
true,
$disabledBecauseInPolicy
);
} }
// Advanced form part // Advanced form part.
$table_advanced = new stdClass(); $table_advanced = new stdClass();
$table_advanced->id = 'advanced'; $table_advanced->id = 'advanced';
$table_advanced->width = '100%'; $table_advanced->width = '100%';

View File

@ -844,20 +844,122 @@ $table->data['edit1'][1] = '<table width="100%">';
$table->data['edit6'][3] = html_print_extended_select_for_unit('unit', '-1', '', '', '0', '15', true, false, false, false, 1); $table->data['edit6'][3] = html_print_extended_select_for_unit('unit', '-1', '', '', '0', '15', true, false, false, false, 1);
// FF stands for Flip-flop // FF stands for Flip-flop.
$table->data['edit7'][0] = __('FF threshold').' '.ui_print_help_icon('ff_threshold', true); $table->data['edit7'][0] = __('FF threshold').' ';
$table->data['edit7'][0] .= ui_print_help_icon(
'ff_threshold',
true
);
$table->colspan['edit7'][1] = 3; $table->colspan['edit7'][1] = 3;
$table->data['edit7'][1] = __('Mode').' '.html_print_select(['' => __('No change'), '1' => __('Each state changing'), '0' => __('All state changing')], 'each_ff', '', '', '', '', true).'<br />'; $table->data['edit7'][1] = __('Mode').' ';
$table->data['edit7'][1] .= __('All state changing').' : '.html_print_input_text('min_ff_event', '', '', 5, 15, true).'<br />'; $table->data['edit7'][1] .= html_print_select(
[
'' => __('No change'),
'1' => __('Each state changing'),
'0' => __('All state changing'),
],
'each_ff',
'',
'',
'',
'',
true,
false,
true,
'',
false,
'width: 400px;'
).'<br />';
$table->data['edit7'][1] .= __('All state changing').' : ';
$table->data['edit7'][1] .= html_print_input_text(
'min_ff_event',
'',
'',
5,
15,
true
).'<br />';
$table->data['edit7'][1] .= __('Each state changing').' : '; $table->data['edit7'][1] .= __('Each state changing').' : ';
$table->data['edit7'][1] .= __('To normal').html_print_input_text('min_ff_event_normal', '', '', 5, 15, true).' '; $table->data['edit7'][1] .= __('To normal').' ';
$table->data['edit7'][1] .= __('To warning').html_print_input_text('min_ff_event_warning', '', '', 5, 15, true).' '; $table->data['edit7'][1] .= html_print_input_text(
$table->data['edit7'][1] .= __('To critical').html_print_input_text('min_ff_event_critical', '', '', 5, 15, true).' '; 'min_ff_event_normal',
'',
'',
5,
15,
true
).' ';
$table->data['edit7'][1] .= __('To warning').' ';
$table->data['edit7'][1] .= html_print_input_text(
'min_ff_event_warning',
'',
'',
5,
15,
true
).' ';
$table->data['edit7'][1] .= __('To critical').' ';
$table->data['edit7'][1] .= html_print_input_text(
'min_ff_event_critical',
'',
'',
5,
15,
true
).'<br>';
$table->data['edit7'][1] .= __('Keep counters').' ';
$table->data['edit7'][1] .= html_print_select(
[
'' => __('No change'),
'1' => __('Active Counters'),
'0' => __('Inactive Counters'),
],
'ff_type',
'',
'',
'',
'',
true,
false,
true,
'',
false,
'width: 400px;'
);
$table->data['edit8'][0] = __('FF interval'); $table->data['edit8'][0] = __('FF interval');
$table->data['edit8'][1] = html_print_input_text('module_ff_interval', '', '', 5, 10, true).ui_print_help_tip(__('Module execution flip flop time interval (in secs).'), true); $table->data['edit8'][1] = html_print_input_text(
'module_ff_interval',
'',
'',
5,
10,
true
);
$table->data['edit8'][1] .= ui_print_help_tip(
__('Module execution flip flop time interval (in secs).'),
true
);
$table->data['edit8'][2] = __('FF timeout'); $table->data['edit8'][2] = __('FF timeout');
$table->data['edit8'][3] = html_print_input_text('ff_timeout', '', '', 5, 10, true).ui_print_help_tip(__('Timeout in secs from start of flip flop counting. If this value is exceeded, FF counter is reset. Set to 0 for no timeout.'), true); $table->data['edit8'][3] = html_print_input_text(
'ff_timeout',
'',
'',
5,
10,
true
);
$table->data['edit8'][3] .= ui_print_help_tip(
__('Timeout in secs from start of flip flop counting. If this value is exceeded, FF counter is reset. Set to 0 for no timeout.'),
true
);
$table->data['edit9'][0] = __('Historical data'); $table->data['edit9'][0] = __('Historical data');
$table->data['edit9'][1] = html_print_select(['' => __('No change'), '1' => __('Yes'), '0' => __('No')], 'history_data', '', '', '', '', true); $table->data['edit9'][1] = html_print_select(['' => __('No change'), '1' => __('Yes'), '0' => __('No')], 'history_data', '', '', '', '', true);
@ -1685,7 +1787,7 @@ function process_manage_edit($module_name, $agents_select=null, $module_status='
$agents_select = [$agents_select]; $agents_select = [$agents_select];
} }
// List of fields which can be updated // List of fields which can be updated.
$fields = [ $fields = [
'dynamic_interval', 'dynamic_interval',
'dynamic_max', 'dynamic_max',
@ -1730,6 +1832,7 @@ function process_manage_edit($module_name, $agents_select=null, $module_status='
'min_ff_event_normal', 'min_ff_event_normal',
'min_ff_event_warning', 'min_ff_event_warning',
'min_ff_event_critical', 'min_ff_event_critical',
'ff_type',
'each_ff', 'each_ff',
'module_ff_interval', 'module_ff_interval',
'ff_timeout', 'ff_timeout',

View File

@ -124,6 +124,7 @@ $pure = get_parameter('pure', 0);
$ff_event_normal = (int) get_parameter('ff_event_normal'); $ff_event_normal = (int) get_parameter('ff_event_normal');
$ff_event_warning = (int) get_parameter('ff_event_warning'); $ff_event_warning = (int) get_parameter('ff_event_warning');
$ff_event_critical = (int) get_parameter('ff_event_critical'); $ff_event_critical = (int) get_parameter('ff_event_critical');
$ff_type = (int) get_parameter('ff_type');
$each_ff = (int) get_parameter('each_ff'); $each_ff = (int) get_parameter('each_ff');
if (count($id_tag_selected) == 1 && empty($id_tag_selected[0])) { if (count($id_tag_selected) == 1 && empty($id_tag_selected[0])) {
@ -261,6 +262,7 @@ if ($create_component) {
'min_ff_event_normal' => $ff_event_normal, 'min_ff_event_normal' => $ff_event_normal,
'min_ff_event_warning' => $ff_event_warning, 'min_ff_event_warning' => $ff_event_warning,
'min_ff_event_critical' => $ff_event_critical, 'min_ff_event_critical' => $ff_event_critical,
'ff_type' => $ff_type,
'each_ff' => $each_ff, 'each_ff' => $each_ff,
] ]
); );
@ -355,6 +357,7 @@ if ($update_component) {
'min_ff_event_normal' => $ff_event_normal, 'min_ff_event_normal' => $ff_event_normal,
'min_ff_event_warning' => $ff_event_warning, 'min_ff_event_warning' => $ff_event_warning,
'min_ff_event_critical' => $ff_event_critical, 'min_ff_event_critical' => $ff_event_critical,
'ff_type' => $ff_type,
'each_ff' => $each_ff, 'each_ff' => $each_ff,
] ]
); );
@ -496,6 +499,7 @@ $url = ui_get_url_refresh(
'ff_event_warning' => false, 'ff_event_warning' => false,
'ff_event_critical' => false, 'ff_event_critical' => false,
'each_ff' => false, 'each_ff' => false,
'ff_type' => false,
] ]
); );

View File

@ -76,6 +76,7 @@ if ($create_network_from_module) {
$ff_event_normal = $data_module['min_ff_event_normal']; $ff_event_normal = $data_module['min_ff_event_normal'];
$ff_event_warning = $data_module['min_ff_event_warning']; $ff_event_warning = $data_module['min_ff_event_warning'];
$ff_event_critical = $data_module['min_ff_event_critical']; $ff_event_critical = $data_module['min_ff_event_critical'];
$ff_type = $data_module['ff_type'];
$each_ff = $data_module['each_ff']; $each_ff = $data_module['each_ff'];
} }
@ -134,6 +135,7 @@ if (isset($id)) {
$ff_event_normal = $component['min_ff_event_normal']; $ff_event_normal = $component['min_ff_event_normal'];
$ff_event_warning = $component['min_ff_event_warning']; $ff_event_warning = $component['min_ff_event_warning'];
$ff_event_critical = $component['min_ff_event_critical']; $ff_event_critical = $component['min_ff_event_critical'];
$ff_type = $component['ff_type'];
$each_ff = $component['each_ff']; $each_ff = $component['each_ff'];
if ($type >= 15 && $type <= 18) { if ($type >= 15 && $type <= 18) {
@ -192,6 +194,7 @@ if (isset($id)) {
$ff_event_normal = 0; $ff_event_normal = 0;
$ff_event_warning = 0; $ff_event_warning = 0;
$ff_event_critical = 0; $ff_event_critical = 0;
$ff_type = 0;
$each_ff = 0; $each_ff = 0;
$snmp_version = 1; $snmp_version = 1;

View File

@ -233,7 +233,23 @@ $table->data[5][1] .= html_print_checkbox('critical_inverse', 1, $critical_inver
$table->data[6][0] = __('FF threshold').' '.ui_print_help_icon('ff_threshold', true); $table->data[6][0] = __('FF threshold').' '.ui_print_help_icon('ff_threshold', true);
$table->colspan[6][1] = 3; $table->colspan[6][1] = 3;
$table->data[6][1] = html_print_radio_button('each_ff', 0, '', $each_ff, true).' '.__('All state changing').' : ';
$table->data[6][1] = __('Keep counters');
$table->data[6][1] .= html_print_checkbox(
'ff_type',
1,
$ff_type,
true
).'<br />';
$table->data[6][1] .= html_print_radio_button(
'each_ff',
0,
'',
$each_ff,
true
).' '.__('All state changing').' : ';
$table->data[6][1] .= html_print_input_text( $table->data[6][1] .= html_print_input_text(
'ff_event', 'ff_event',
$ff_event, $ff_event,
@ -242,13 +258,40 @@ $table->data[6][1] .= html_print_input_text(
15, 15,
true true
).'<br />'; ).'<br />';
$table->data[6][1] .= html_print_radio_button('each_ff', 1, '', $each_ff, true).' '.__('Each state changing').' : '; $table->data[6][1] .= html_print_radio_button(
'each_ff',
1,
'',
$each_ff,
true
).' '.__('Each state changing').' : ';
$table->data[6][1] .= __('To normal'); $table->data[6][1] .= __('To normal');
$table->data[6][1] .= html_print_input_text('ff_event_normal', $ff_event_normal, '', 5, 15, true).' '; $table->data[6][1] .= html_print_input_text(
'ff_event_normal',
$ff_event_normal,
'',
5,
15,
true
).' ';
$table->data[6][1] .= __('To warning'); $table->data[6][1] .= __('To warning');
$table->data[6][1] .= html_print_input_text('ff_event_warning', $ff_event_warning, '', 5, 15, true).' '; $table->data[6][1] .= html_print_input_text(
'ff_event_warning',
$ff_event_warning,
'',
5,
15,
true
).' ';
$table->data[6][1] .= __('To critical'); $table->data[6][1] .= __('To critical');
$table->data[6][1] .= html_print_input_text('ff_event_critical', $ff_event_critical, '', 5, 15, true); $table->data[6][1] .= html_print_input_text(
'ff_event_critical',
$ff_event_critical,
'',
5,
15,
true
);
$table->data[7][0] = __('Historical data'); $table->data[7][0] = __('Historical data');
$table->data[7][1] = html_print_checkbox('history_data', 1, $history_data, true); $table->data[7][1] = html_print_checkbox('history_data', 1, $history_data, true);

View File

@ -121,6 +121,7 @@ if (is_ajax()) {
'min_ff_event_normal' => 0, 'min_ff_event_normal' => 0,
'min_ff_event_warning' => 0, 'min_ff_event_warning' => 0,
'min_ff_event_critical' => 0, 'min_ff_event_critical' => 0,
'ff_type' => 0,
'each_ff' => 0, 'each_ff' => 0,
] ]
); );

View File

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

View File

@ -1,19 +1,36 @@
<?php <?php
/**
* Extension to manage a list of gateways and the node address where they should
* point to.
*
* @category API
* @package Pandora FMS
* @subpackage Community
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Pandora FMS- http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
global $config; global $config;
// Set character encoding to UTF-8 - fixes a lot of multibyte character headaches // Set character encoding to UTF-8
// fixes a lot of multibyte character headaches.
require_once 'functions_agents.php'; require_once 'functions_agents.php';
require_once 'functions_modules.php'; require_once 'functions_modules.php';
require_once $config['homedir'].'/include/functions_profile.php'; require_once $config['homedir'].'/include/functions_profile.php';
@ -237,7 +254,7 @@ function returnData($returnType, $data, $separator=';')
case 'json': case 'json':
$data = array_apply_io_safe_output($data); $data = array_apply_io_safe_output($data);
header('Content-type: application/json'); header('Content-type: application/json');
// Allows extra parameters to json_encode, like JSON_FORCE_OBJECT // Allows extra parameters to json_encode, like JSON_FORCE_OBJECT.
if ($separator == ';') { if ($separator == ';') {
$separator = null; $separator = null;
} }
@ -3014,21 +3031,20 @@ function api_get_policy_modules($thrash1, $thrash2, $other, $thrash3)
/** /**
* Create a network module in agent. And return the id_agent_module of new module. * Create a network module in agent.
* And return the id_agent_module of new module.
* *
* @param string $id Name of agent to add the module. * @param string $id Name of agent to add the module.
* @param $thrash1 Don't use. * @param string $thrash1 Don't use.
* @param array $other it's array, $other as param is <name_module>;<disabled>;<id_module_type>; * @param array $other It's array, $other as param is <name_module>;<disabled>;<id_module_type>;
* <id_module_group>;<min_warning>;<max_warning>;<str_warning>;<min_critical>;<max_critical>;<str_critical>;<ff_threshold>; * <id_module_group>;<min_warning>;<max_warning>;<str_warning>;<min_critical>;<max_critical>;<str_critical>;<ff_threshold>;
* <history_data>;<ip_target>;<module_port>;<snmp_community>;<snmp_oid>;<module_interval>;<post_process>; * <history_data>;<ip_target>;<module_port>;<snmp_community>;<snmp_oid>;<module_interval>;<post_process>;
* <min>;<max>;<custom_id>;<description>;<disabled_types_event>;<module_macros>; * <min>;<max>;<custom_id>;<description>;<disabled_types_event>;<module_macros>;
* <each_ff>;<ff_threshold_normal>;<ff_threshold_warning>;<ff_threshold_critical>; in this order * <each_ff>;<ff_threshold_normal>;<ff_threshold_warning>;<ff_threshold_critical>; in this order
* and separator char (after text ; ) and separator (pass in param othermode as othermode=url_encode_separator_<separator>) * and separator char (after text ; ) and separator (pass in param othermode as othermode=url_encode_separator_<separator>).
* example: * @param string $thrash3 Don't use.
* * @example: api.php?op=set&op2=create_network_module&id=pepito&other=prueba|0|7|1|10|15|0|16|18|0|15|0|www.google.es|0||0|180|0|0|0|0|latency%20ping&other_mode=url_encode_separator_|*
* api.php?op=set&op2=create_network_module&id=pepito&other=prueba|0|7|1|10|15|0|16|18|0|15|0|www.google.es|0||0|180|0|0|0|0|latency%20ping&other_mode=url_encode_separator_| * @return mixed Return.
*
* @param $thrash3 Don't use
*/ */
function api_set_create_network_module($id, $thrash1, $other, $thrash3) function api_set_create_network_module($id, $thrash1, $other, $thrash3)
{ {
@ -3090,22 +3106,23 @@ function api_set_create_network_module($id, $thrash1, $other, $thrash3)
'min_ff_event_critical' => $other['data'][27], 'min_ff_event_critical' => $other['data'][27],
'critical_inverse' => $other['data'][28], 'critical_inverse' => $other['data'][28],
'warning_inverse' => $other['data'][29], 'warning_inverse' => $other['data'][29],
'ff_type' => $other['data'][30],
]; ];
if (! $values['descripcion']) { if (! $values['descripcion']) {
$values['descripcion'] = ''; $values['descripcion'] = '';
// Column 'descripcion' cannot be null // Column 'descripcion' cannot be null.
} }
if (! $values['module_macros']) { if (! $values['module_macros']) {
$values['module_macros'] = ''; $values['module_macros'] = '';
// Column 'module_macros' cannot be null // Column 'module_macros' cannot be null.
} }
$idModule = modules_create_agent_module($idAgent, $name, $values, true); $idModule = modules_create_agent_module($idAgent, $name, $values, true);
if (is_error($idModule)) { if (is_error($idModule)) {
// TODO: Improve the error returning more info // TODO: Improve the error returning more info.
returnError('error_create_network_module', __('Error in creation network module.')); returnError('error_create_network_module', __('Error in creation network module.'));
} else { } else {
returnData('string', ['type' => 'string', 'data' => $idModule]); returnData('string', ['type' => 'string', 'data' => $idModule]);
@ -3222,6 +3239,7 @@ function api_set_update_network_module($id_module, $thrash1, $other, $thrash3)
'critical_inverse', 'critical_inverse',
'warning_inverse', 'warning_inverse',
'policy_linked', 'policy_linked',
'ff_type',
]; ];
$values = []; $values = [];
@ -3326,22 +3344,23 @@ function api_set_create_plugin_module($id, $thrash1, $other, $thrash3)
'min_ff_event_critical' => $other['data'][32], 'min_ff_event_critical' => $other['data'][32],
'critical_inverse' => $other['data'][33], 'critical_inverse' => $other['data'][33],
'warning_inverse' => $other['data'][34], 'warning_inverse' => $other['data'][34],
'ff_type' => $other['data'][35],
]; ];
if (! $values['descripcion']) { if (! $values['descripcion']) {
$values['descripcion'] = ''; $values['descripcion'] = '';
// Column 'descripcion' cannot be null // Column 'descripcion' cannot be null.
} }
if (! $values['module_macros']) { if (! $values['module_macros']) {
$values['module_macros'] = ''; $values['module_macros'] = '';
// Column 'module_macros' cannot be null // Column 'module_macros' cannot be null.
} }
$idModule = modules_create_agent_module($idAgent, $name, $values, true); $idModule = modules_create_agent_module($idAgent, $name, $values, true);
if (is_error($idModule)) { if (is_error($idModule)) {
// TODO: Improve the error returning more info // TODO: Improve the error returning more info.
returnError('error_create_plugin_module', __('Error in creation plugin module.')); returnError('error_create_plugin_module', __('Error in creation plugin module.'));
} else { } else {
returnData('string', ['type' => 'string', 'data' => $idModule]); returnData('string', ['type' => 'string', 'data' => $idModule]);
@ -3387,7 +3406,7 @@ function api_set_update_plugin_module($id_module, $thrash1, $other, $thrash3)
return; return;
} }
// If we want to change the module to a new agent // If we want to change the module to a new agent.
if ($other['data'][0] != '') { if ($other['data'][0] != '') {
if (!util_api_check_agent_and_print_error($other['data'][0], 'string', 'AW')) { if (!util_api_check_agent_and_print_error($other['data'][0], 'string', 'AW')) {
return; return;
@ -3404,7 +3423,7 @@ function api_set_update_plugin_module($id_module, $thrash1, $other, $thrash3)
} }
} }
// Check if agent exists // Check if agent exists.
$check_id_agent = db_get_value('id_agente', 'tagente', 'id_agente', $other['data'][0]); $check_id_agent = db_get_value('id_agente', 'tagente', 'id_agente', $other['data'][0]);
if (!$check_id_agent) { if (!$check_id_agent) {
returnError('error_update_data_module', __('Error updating plugin module. Id_agent doesn\'t exist.')); returnError('error_update_data_module', __('Error updating plugin module. Id_agent doesn\'t exist.'));
@ -3448,6 +3467,7 @@ function api_set_update_plugin_module($id_module, $thrash1, $other, $thrash3)
'critical_inverse', 'critical_inverse',
'warning_inverse', 'warning_inverse',
'policy_linked', 'policy_linked',
'ff_type',
]; ];
$values = []; $values = [];
@ -3546,22 +3566,23 @@ function api_set_create_data_module($id, $thrash1, $other, $thrash3)
'ff_timeout' => $other['data'][23], 'ff_timeout' => $other['data'][23],
'critical_inverse' => $other['data'][24], 'critical_inverse' => $other['data'][24],
'warning_inverse' => $other['data'][25], 'warning_inverse' => $other['data'][25],
'ff_type' => $other['data'][26],
]; ];
if (! $values['descripcion']) { if (! $values['descripcion']) {
$values['descripcion'] = ''; $values['descripcion'] = '';
// Column 'descripcion' cannot be null // Column 'descripcion' cannot be null.
} }
if (! $values['module_macros']) { if (! $values['module_macros']) {
$values['module_macros'] = ''; $values['module_macros'] = '';
// Column 'module_macros' cannot be null // Column 'module_macros' cannot be null.
} }
$idModule = modules_create_agent_module($idAgent, $name, $values, true); $idModule = modules_create_agent_module($idAgent, $name, $values, true);
if (is_error($idModule)) { if (is_error($idModule)) {
// TODO: Improve the error returning more info // TODO: Improve the error returning more info.
returnError('error_create_data_module', __('Error in creation data module.')); returnError('error_create_data_module', __('Error in creation data module.'));
} else { } else {
returnData('string', ['type' => 'string', 'data' => $idModule]); returnData('string', ['type' => 'string', 'data' => $idModule]);
@ -3818,7 +3839,7 @@ function api_set_update_data_module($id_module, $thrash1, $other, $thrash3)
return; return;
} }
// If we want to change the module to a new agent // If we want to change the module to a new agent.
if ($other['data'][0] != '') { if ($other['data'][0] != '') {
if (!util_api_check_agent_and_print_error($other['data'][0], 'string', 'AW')) { if (!util_api_check_agent_and_print_error($other['data'][0], 'string', 'AW')) {
return; return;
@ -3835,7 +3856,7 @@ function api_set_update_data_module($id_module, $thrash1, $other, $thrash3)
} }
} }
// Check if agent exists // Check if agent exists.
$check_id_agent = db_get_value('id_agente', 'tagente', 'id_agente', $other['data'][0]); $check_id_agent = db_get_value('id_agente', 'tagente', 'id_agente', $other['data'][0]);
if (!$check_id_agent) { if (!$check_id_agent) {
returnError('error_update_data_module', __('Error updating data module. Id_agent doesn\'t exist.')); returnError('error_update_data_module', __('Error updating data module. Id_agent doesn\'t exist.'));
@ -3870,6 +3891,7 @@ function api_set_update_data_module($id_module, $thrash1, $other, $thrash3)
'critical_inverse', 'critical_inverse',
'warning_inverse', 'warning_inverse',
'policy_linked', 'policy_linked',
'ff_type',
]; ];
$values = []; $values = [];
@ -3947,7 +3969,7 @@ function api_set_create_snmp_module($id, $thrash1, $other, $thrash3)
$disabled_types_event[EVENTS_GOING_UNKNOWN] = (int) !$other['data'][27]; $disabled_types_event[EVENTS_GOING_UNKNOWN] = (int) !$other['data'][27];
$disabled_types_event = json_encode($disabled_types_event); $disabled_types_event = json_encode($disabled_types_event);
// SNMP version 3 // SNMP version 3.
if ($other['data'][14] == '3') { if ($other['data'][14] == '3') {
if ($other['data'][23] != 'AES' and $other['data'][23] != 'DES') { if ($other['data'][23] != 'AES' and $other['data'][23] != 'DES') {
returnError('error_create_snmp_module', __('Error in creation SNMP module. snmp3_priv_method doesn\'t exist. Set it to \'AES\' or \'DES\'. ')); returnError('error_create_snmp_module', __('Error in creation SNMP module. snmp3_priv_method doesn\'t exist. Set it to \'AES\' or \'DES\'. '));
@ -4000,6 +4022,7 @@ function api_set_create_snmp_module($id, $thrash1, $other, $thrash3)
'min_ff_event_normal' => $other['data'][31], 'min_ff_event_normal' => $other['data'][31],
'min_ff_event_warning' => $other['data'][32], 'min_ff_event_warning' => $other['data'][32],
'min_ff_event_critical' => $other['data'][33], 'min_ff_event_critical' => $other['data'][33],
'ff_type' => $other['data'][34],
]; ];
} else { } else {
$values = [ $values = [
@ -4032,18 +4055,19 @@ function api_set_create_snmp_module($id, $thrash1, $other, $thrash3)
'min_ff_event_normal' => $other['data'][25], 'min_ff_event_normal' => $other['data'][25],
'min_ff_event_warning' => $other['data'][26], 'min_ff_event_warning' => $other['data'][26],
'min_ff_event_critical' => $other['data'][27], 'min_ff_event_critical' => $other['data'][27],
'ff_type' => $other['data'][28],
]; ];
} }
if (! $values['descripcion']) { if (! $values['descripcion']) {
$values['descripcion'] = ''; $values['descripcion'] = '';
// Column 'descripcion' cannot be null // Column 'descripcion' cannot be null.
} }
$idModule = modules_create_agent_module($idAgent, $name, $values, true); $idModule = modules_create_agent_module($idAgent, $name, $values, true);
if (is_error($idModule)) { if (is_error($idModule)) {
// TODO: Improve the error returning more info // TODO: Improve the error returning more info.
returnError('error_create_snmp_module', __('Error in creation SNMP module.')); returnError('error_create_snmp_module', __('Error in creation SNMP module.'));
} else { } else {
returnData('string', ['type' => 'string', 'data' => $idModule]); returnData('string', ['type' => 'string', 'data' => $idModule]);
@ -4091,7 +4115,7 @@ function api_set_update_snmp_module($id_module, $thrash1, $other, $thrash3)
return; return;
} }
// If we want to change the module to a new agent // If we want to change the module to a new agent.
if ($other['data'][0] != '') { if ($other['data'][0] != '') {
if (!util_api_check_agent_and_print_error($other['data'][0], 'string', 'AW')) { if (!util_api_check_agent_and_print_error($other['data'][0], 'string', 'AW')) {
return; return;
@ -4108,7 +4132,7 @@ function api_set_update_snmp_module($id_module, $thrash1, $other, $thrash3)
} }
} }
// Check if agent exists // Check if agent exists.
$check_id_agent = db_get_value('id_agente', 'tagente', 'id_agente', $other['data'][0]); $check_id_agent = db_get_value('id_agente', 'tagente', 'id_agente', $other['data'][0]);
if (!$check_id_agent) { if (!$check_id_agent) {
returnError('error_update_data_module', __('Error updating snmp module. Id_agent doesn\'t exist.')); returnError('error_update_data_module', __('Error updating snmp module. Id_agent doesn\'t exist.'));
@ -4116,7 +4140,7 @@ function api_set_update_snmp_module($id_module, $thrash1, $other, $thrash3)
} }
} }
// SNMP version 3 // SNMP version 3.
if ($other['data'][13] == '3') { if ($other['data'][13] == '3') {
if ($other['data'][22] != 'AES' and $other['data'][22] != 'DES') { if ($other['data'][22] != 'AES' and $other['data'][22] != 'DES') {
returnError( returnError(
@ -4180,6 +4204,7 @@ function api_set_update_snmp_module($id_module, $thrash1, $other, $thrash3)
'min_ff_event_warning', 'min_ff_event_warning',
'min_ff_event_critical', 'min_ff_event_critical',
'policy_linked', 'policy_linked',
'ff_type',
]; ];
} else { } else {
$snmp_module_fields = [ $snmp_module_fields = [
@ -4211,6 +4236,7 @@ function api_set_update_snmp_module($id_module, $thrash1, $other, $thrash3)
'min_ff_event_warning', 'min_ff_event_warning',
'min_ff_event_critical', 'min_ff_event_critical',
'policy_linked', 'policy_linked',
'ff_type',
]; ];
} }
@ -4308,6 +4334,7 @@ function api_set_new_network_component($id, $thrash1, $other, $thrash2)
'min_ff_event_normal' => $other['data'][20], 'min_ff_event_normal' => $other['data'][20],
'min_ff_event_warning' => $other['data'][21], 'min_ff_event_warning' => $other['data'][21],
'min_ff_event_critical' => $other['data'][22], 'min_ff_event_critical' => $other['data'][22],
'ff_type' => $other['data'][23],
]; ];
$name_check = db_get_value('name', 'tnetwork_component', 'name', $id); $name_check = db_get_value('name', 'tnetwork_component', 'name', $id);
@ -4408,6 +4435,7 @@ function api_set_new_plugin_component($id, $thrash1, $other, $thrash2)
'min_ff_event_normal' => $other['data'][24], 'min_ff_event_normal' => $other['data'][24],
'min_ff_event_warning' => $other['data'][25], 'min_ff_event_warning' => $other['data'][25],
'min_ff_event_critical' => $other['data'][26], 'min_ff_event_critical' => $other['data'][26],
'ff_type' => $other['data'][27],
]; ];
$name_check = db_get_value('name', 'tnetwork_component', 'name', $id); $name_check = db_get_value('name', 'tnetwork_component', 'name', $id);
@ -4543,6 +4571,7 @@ function api_set_new_snmp_component($id, $thrash1, $other, $thrash2)
'min_ff_event_normal' => $other['data'][29], 'min_ff_event_normal' => $other['data'][29],
'min_ff_event_warning' => $other['data'][30], 'min_ff_event_warning' => $other['data'][30],
'min_ff_event_critical' => $other['data'][31], 'min_ff_event_critical' => $other['data'][31],
'ff_type' => $other['data'][32],
]; ];
} else { } else {
$values = [ $values = [
@ -4574,6 +4603,7 @@ function api_set_new_snmp_component($id, $thrash1, $other, $thrash2)
'min_ff_event_normal' => $other['data'][25], 'min_ff_event_normal' => $other['data'][25],
'min_ff_event_warning' => $other['data'][26], 'min_ff_event_warning' => $other['data'][26],
'min_ff_event_critical' => $other['data'][27], 'min_ff_event_critical' => $other['data'][27],
'ff_type' => $other['data'][28],
]; ];
} }
@ -4654,6 +4684,7 @@ function api_set_new_local_component($id, $thrash1, $other, $thrash2)
'min_ff_event_warning' => $other['data'][8], 'min_ff_event_warning' => $other['data'][8],
'min_ff_event_critical' => $other['data'][9], 'min_ff_event_critical' => $other['data'][9],
'ff_timeout' => $other['data'][10], 'ff_timeout' => $other['data'][10],
'ff_type' => $other['data'][11],
]; ];
$name_check = enterprise_hook( $name_check = enterprise_hook(
@ -6409,6 +6440,7 @@ function api_set_add_data_module_policy($id, $thrash1, $other, $thrash3)
$values['min_ff_event_warning'] = $other['data'][21]; $values['min_ff_event_warning'] = $other['data'][21];
$values['min_ff_event_critical'] = $other['data'][22]; $values['min_ff_event_critical'] = $other['data'][22];
$values['ff_timeout'] = $other['data'][23]; $values['ff_timeout'] = $other['data'][23];
$values['ff_type'] = $other['data'][24];
if ($name_module_policy !== false) { if ($name_module_policy !== false) {
if ($name_module_policy[0]['name'] == $other['data'][0]) { if ($name_module_policy[0]['name'] == $other['data'][0]) {
@ -6650,6 +6682,7 @@ function api_set_add_network_module_policy($id, $thrash1, $other, $thrash3)
$values['min_ff_event_normal'] = $other['data'][24]; $values['min_ff_event_normal'] = $other['data'][24];
$values['min_ff_event_warning'] = $other['data'][25]; $values['min_ff_event_warning'] = $other['data'][25];
$values['min_ff_event_critical'] = $other['data'][26]; $values['min_ff_event_critical'] = $other['data'][26];
$values['ff_type'] = $other['data'][27];
if ($name_module_policy !== false) { if ($name_module_policy !== false) {
if ($name_module_policy[0]['name'] == $other['data'][0]) { if ($name_module_policy[0]['name'] == $other['data'][0]) {
@ -6859,6 +6892,7 @@ function api_set_add_plugin_module_policy($id, $thrash1, $other, $thrash3)
$values['min_ff_event_normal'] = $other['data'][29]; $values['min_ff_event_normal'] = $other['data'][29];
$values['min_ff_event_warning'] = $other['data'][30]; $values['min_ff_event_warning'] = $other['data'][30];
$values['min_ff_event_critical'] = $other['data'][31]; $values['min_ff_event_critical'] = $other['data'][31];
$values['ff_type'] = $other['data'][32];
if ($name_module_policy !== false) { if ($name_module_policy !== false) {
if ($name_module_policy[0]['name'] == $other['data'][0]) { if ($name_module_policy[0]['name'] == $other['data'][0]) {
@ -7276,6 +7310,7 @@ function api_set_add_snmp_module_policy($id, $thrash1, $other, $thrash3)
'min_ff_event_normal' => $other['data'][30], 'min_ff_event_normal' => $other['data'][30],
'min_ff_event_warning' => $other['data'][31], 'min_ff_event_warning' => $other['data'][31],
'min_ff_event_critical' => $other['data'][32], 'min_ff_event_critical' => $other['data'][32],
'ff_type' => $other['data'][33],
]; ];
} else { } else {
$values = [ $values = [
@ -7305,6 +7340,7 @@ function api_set_add_snmp_module_policy($id, $thrash1, $other, $thrash3)
'min_ff_event_normal' => $other['data'][24], 'min_ff_event_normal' => $other['data'][24],
'min_ff_event_warning' => $other['data'][25], 'min_ff_event_warning' => $other['data'][25],
'min_ff_event_critical' => $other['data'][26], 'min_ff_event_critical' => $other['data'][26],
'ff_type' => $other['data'][27],
]; ];
} }
@ -11615,7 +11651,9 @@ function api_set_add_event_comment($id, $thrash2, $other, $thrash3)
global $config; global $config;
if (defined('METACONSOLE')) { if (defined('METACONSOLE')) {
return; $meta = true;
} else {
$meta = $other['data'][1];
} }
if (!check_acl($config['id_user'], 0, 'EW')) { if (!check_acl($config['id_user'], 0, 'EW')) {
@ -11627,8 +11665,7 @@ function api_set_add_event_comment($id, $thrash2, $other, $thrash3)
returnError('error_parameter', 'Error in the parameters.'); returnError('error_parameter', 'Error in the parameters.');
return; return;
} else if ($other['type'] == 'array') { } else if ($other['type'] == 'array') {
$comment = io_safe_input($other['data'][0]); $comment = $other['data'][0];
$meta = $other['data'][1];
$history = $other['data'][2]; $history = $other['data'][2];
$status = events_comment( $status = events_comment(
@ -13275,6 +13312,7 @@ function api_set_apply_module_template($id_template, $id_agent, $thrash3, $thras
'min_ff_event_normal' => $row2['min_ff_event_normal'], 'min_ff_event_normal' => $row2['min_ff_event_normal'],
'min_ff_event_warning' => $row2['min_ff_event_warning'], 'min_ff_event_warning' => $row2['min_ff_event_warning'],
'min_ff_event_critical' => $row2['min_ff_event_critical'], 'min_ff_event_critical' => $row2['min_ff_event_critical'],
'ff_type' => $row2['ff_type'],
]; ];
$name = $row2['name']; $name = $row2['name'];

View File

@ -1,34 +1,51 @@
<?php <?php
/**
* PHP Linux cron functions.
*
* @package Linux cron functions.
* @subpackage Backend functions.
*
* Pandora FMS- http://pandorafms.com
* ==================================================
* Copyright (c) 20012 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; version 2
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
// Pandora FMS- http://pandorafms.com
// ==================================================
// Copyright (c) 20012 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
global $config; global $config;
require_once $config['homedir'].'/include/functions_db.php'; require_once $config['homedir'].'/include/functions_db.php';
// Update the execution interval of the given module.
/**
* Update the execution interval of the given module
*
* @param integer $module_id Id of module to update.
* @param string $cron String with the Linux cron configuration.
*
* @return boolean Return number of rows affected.
*/
function cron_update_module_interval($module_id, $cron) function cron_update_module_interval($module_id, $cron)
{ {
// Check for a valid cron. // Check for a valid cron.
if (!cron_check_syntax($cron)) { if (!cron_check_syntax($cron)) {
return; return false;
} }
if ($cron == '* * * * *') { $module_interval = db_get_value(
$module_interval = db_get_value_filter( 'module_interval',
'module_interval', 'tagente_modulo',
'tagente_modulo', 'id_agente_modulo',
['id_agente_modulo' => $module_id] $module_id
); );
if ($cron === '* * * * *') {
return db_process_sql( return db_process_sql(
'UPDATE tagente_estado SET current_interval = '.$module_interval.' WHERE id_agente_modulo = '.(int) $module_id 'UPDATE tagente_estado SET current_interval = '.$module_interval.' WHERE id_agente_modulo = '.(int) $module_id
); );
@ -41,15 +58,19 @@ function cron_update_module_interval($module_id, $cron)
} }
// Get the number of seconds left to the next execution of the given cron entry. /**
* Get the number of seconds left to the next execution of the given cron entry.
*
* @param string $cron String with the Linux cron configuration.
* @param integer $module_interval Module interval. Minimum increased time.
* @param integer $module_id Module id.
*
* @return integer Time to next execution time.
*/
function cron_next_execution($cron, $module_interval, $module_id) function cron_next_execution($cron, $module_interval, $module_id)
{ {
// Get day of the week and month from cron config. // Get day of the week and month from cron config.
$cron_array = explode(' ', $cron); $cron_array = explode(' ', $cron);
$minute = $cron_array[0];
$hour = $cron_array[1];
$mday = $cron_array[2];
$month = $cron_array[3];
$wday = $cron_array[4]; $wday = $cron_array[4];
// Get last execution time. // Get last execution time.
@ -60,55 +81,35 @@ function cron_next_execution($cron, $module_interval, $module_id)
$module_id $module_id
); );
$cur_time = ($last_execution !== false) ? $last_execution : time(); $cur_time = ($last_execution !== false) ? $last_execution : time();
$nex_time = cron_next_execution_date($cron, $cur_time, $module_interval);
// Any day of the way. $nex_wday = (int) date('w', $nex_time);
if ($wday == '*') { // Check the wday values to avoid infinite loop.
$nex_time = cron_next_execution_date( $wday_int = cron_get_interval($wday);
$cron, if ($wday_int['down'] !== '*' && ($wday_int['down'] > 6 || ($wday_int['up'] !== false && $wday_int['up'] > 6))) {
$cur_time, $wday = '*';
$module_interval
);
return ($nex_time - $cur_time);
} }
// A specific day of the week. // Check day of the way.
$count = 0; while (!cron_check_interval($nex_wday, $wday)) {
$nex_time = $cur_time; // If it does not acomplish the day of the week, go to the next day.
do { $nex_time += SECONDS_1DAY;
$nex_time = cron_next_execution_date( $nex_time = cron_next_execution_date($cron, $nex_time, 0);
$cron, $nex_wday = (int) date('w', $nex_time);
$nex_time, }
$module_interval
);
$nex_time_wd = $nex_time;
$array_nex = explode(' ', date('m w', $nex_time_wd)); return ($nex_time - $cur_time);
$nex_mon = $array_nex[0];
$nex_wday = $array_nex[1];
do {
// Check the day of the week.
if ($nex_wday == $wday) {
return ($nex_time_wd - $cur_time);
}
// Move to the next day of the month.
$nex_time_wd += SECONDS_1DAY;
$array_nex_w = explode(' ', date('m w', $nex_time_wd));
$nex_mon_wd = $array_nex_w[0];
$nex_wday = $array_nex_w[1];
} while ($mday == '*' && $nex_mon_wd == $nex_mon);
$count++;
} while ($count < SECONDS_1MINUTE);
// Something went wrong, default to 5 minutes.
return SECONDS_5MINUTES;
} }
// Get the next execution date for the given cron entry in seconds since epoch. /**
* Get the next execution date for the given cron entry in seconds since epoch.
*
* @param string $cron String with the Linux cron configuration.
* @param integer $cur_time Current time in utimestamp.
* @param integer $module_interval Module interval. Minimum increased time.
*
* @return integer Next execution timestamp seing the cron configuration.
*/
function cron_next_execution_date($cron, $cur_time=false, $module_interval=300) function cron_next_execution_date($cron, $cur_time=false, $module_interval=300)
{ {
// Get cron configuration. // Get cron configuration.
@ -127,8 +128,7 @@ function cron_next_execution_date($cron, $cur_time=false, $module_interval=300)
} }
// Update minutes. // Update minutes.
$min_s = cron_get_interval($cron_array[0]); $nex_time_array[0] = cron_get_next_time_element($cron_array[0]);
$nex_time_array[0] = ($min_s['down'] == '*') ? 0 : $min_s['down'];
$nex_time = cron_valid_date($nex_time_array); $nex_time = cron_valid_date($nex_time_array);
if ($nex_time >= $cur_time) { if ($nex_time >= $cur_time) {
@ -166,8 +166,7 @@ function cron_next_execution_date($cron, $cur_time=false, $module_interval=300)
} }
// Update the hour if fails. // Update the hour if fails.
$hour_s = cron_get_interval($cron_array[1]); $nex_time_array[1] = cron_get_next_time_element($cron_array[1]);
$nex_time_array[1] = ($hour_s['down'] == '*') ? 0 : $hour_s['down'];
// When an overflow is passed check the hour update again. // When an overflow is passed check the hour update again.
$nex_time = cron_valid_date($nex_time_array); $nex_time = cron_valid_date($nex_time_array);
@ -199,8 +198,7 @@ function cron_next_execution_date($cron, $cur_time=false, $module_interval=300)
} }
// Update the day if fails. // Update the day if fails.
$mday_s = cron_get_interval($cron_array[2]); $nex_time_array[2] = cron_get_next_time_element($cron_array[2]);
$nex_time_array[2] = ($mday_s['down'] == '*') ? 1 : $mday_s['down'];
// When an overflow is passed check the hour update in the next execution. // When an overflow is passed check the hour update in the next execution.
$nex_time = cron_valid_date($nex_time_array); $nex_time = cron_valid_date($nex_time_array);
@ -226,8 +224,7 @@ function cron_next_execution_date($cron, $cur_time=false, $module_interval=300)
} }
// Update the month if fails. // Update the month if fails.
$mon_s = cron_get_interval($cron_array[3]); $nex_time_array[3] = cron_get_next_time_element($cron_array[3]);
$nex_time_array[3] = ($mon_s['down'] == '*') ? 1 : $mon_s['down'];
// When an overflow is passed check the hour update in the next execution. // When an overflow is passed check the hour update in the next execution.
$nex_time = cron_valid_date($nex_time_array); $nex_time = cron_valid_date($nex_time_array);
@ -245,7 +242,33 @@ function cron_next_execution_date($cron, $cur_time=false, $module_interval=300)
} }
// Get an array with the cron interval. /**
* Get the next tentative time for a cron value or interval in case of overflow.
*
* @param string $cron_array_elem Cron element.
*
* @return integer The tentative time. Ex:
* * shold returns 0.
* 5 should returns 5.
* 10-55 should returns 10.
* 55-10 should retunrs 0.
*/
function cron_get_next_time_element($cron_array_elem)
{
$interval = cron_get_interval($cron_array_elem);
$value = ($interval['down'] == '*' || ($interval['up'] !== false && $interval['down'] > $interval['up'] )) ? 0 : $interval['down'];
return $value;
}
/**
* Get an array with the cron interval.
*
* @param string $element String with the elemen cron configuration.
*
* @return array With up and down elements.
* If there is not an interval, up element will be false.
*/
function cron_get_interval($element) function cron_get_interval($element)
{ {
// Not a range. // Not a range.
@ -263,7 +286,14 @@ function cron_get_interval($element)
} }
// Returns if a date is in a cron. Recursive. /**
* Returns if a date is in a cron. Recursive.
*
* @param array $elems_cron Cron configuration in array format.
* @param integer $elems_curr_time Time to check if is in cron.
*
* @return boolean Returns true if is in cron. False if it is outside.
*/
function cron_is_in_cron($elems_cron, $elems_curr_time) function cron_is_in_cron($elems_cron, $elems_curr_time)
{ {
$elem_cron = array_shift($elems_cron); $elem_cron = array_shift($elems_cron);
@ -275,31 +305,62 @@ function cron_is_in_cron($elems_cron, $elems_curr_time)
} }
// Go to last element if current is a wild card. // Go to last element if current is a wild card.
if ($elem_cron != '*') { if (cron_check_interval($elem_curr_time, $elem_cron) === false) {
$elem_s = cron_get_interval($elem_cron); return false;
// Check if there is no a range
if (($elem_s['up'] === false) && ($elem_s['down'] != $elem_curr_time)) {
return false;
}
// Check if there is on the range.
if ($elem_s['up'] !== false) {
if ($elem_s['down'] < $elem_s['up']) {
if ($elem_curr_time < $elem_s['down'] || $elem_curr_time > $elem_s['up']) {
return false;
}
} else {
if ($elem_curr_time > $elem_s['down'] || $elem_curr_time < $elem_s['up']) {
return false;
}
}
}
} }
return cron_is_in_cron($elems_cron, $elems_curr_time); return cron_is_in_cron($elems_cron, $elems_curr_time);
} }
/**
* Check if an element is inside the cron interval or not.
*
* @param integer $elem_curr_time Integer that represents the time to check.
* @param string $elem_cron Cron interval (splitted by hypen)
* or cron single value (a number).
*
* @return boolean True if is in interval.
*/
function cron_check_interval($elem_curr_time, $elem_cron)
{
// Go to last element if current is a wild card.
if ($elem_cron === '*') {
return true;
}
$elem_s = cron_get_interval($elem_cron);
// Check if there is no a range.
if (($elem_s['up'] === false) && ($elem_s['down'] != $elem_curr_time)) {
return false;
}
// Check if there is on the range.
if ($elem_s['up'] !== false && (int) $elem_s['up'] === (int) $elem_curr_time) {
return true;
}
if ($elem_s['down'] < $elem_s['up']) {
if ($elem_curr_time < $elem_s['down'] || $elem_curr_time > $elem_s['up']) {
return false;
}
} else {
if ($elem_curr_time > $elem_s['down'] || $elem_curr_time < $elem_s['up']) {
return false;
}
}
return true;
}
/**
* Check if a date is correct or not.
*
* @param array $da Date in array format [year, month, day, hour, minutes].
*
* @return integer Utimestamp. False if date is incorrect.
*/
function cron_valid_date($da) function cron_valid_date($da)
{ {
$st = sprintf( $st = sprintf(
@ -315,7 +376,13 @@ function cron_valid_date($da)
} }
// Check if cron is properly constructed. /**
* Check if cron is properly constructed.
*
* @param string $cron String with the Linux cron configuration.
*
* @return boolean True if is well formed. False otherwise.
*/
function cron_check_syntax($cron) function cron_check_syntax($cron)
{ {
return preg_match( return preg_match(
@ -325,6 +392,11 @@ function cron_check_syntax($cron)
} }
/**
* Cron list table.
*
* @return void It prints the HTML table.
*/
function cron_list_table() function cron_list_table()
{ {
global $config; global $config;

View File

@ -2744,28 +2744,7 @@ function html_print_autocomplete_modules(
global $config; global $config;
if ($id_agents === false) { if ($id_agents === false) {
$groups = []; $agents = agents_get_agents();
if ($ACL) {
$groups = users_get_groups($config['id_user'], 'AW', false);
$groups = array_keys($groups);
if (empty($groups)) {
$id_groups = 0;
} else {
$id_groups = implode(',', $groups);
}
$agents = db_get_all_rows_sql(
'SELECT id_agente
FROM tagente
WHERE id_grupo IN ('.$id_groups.')'
);
} else {
$agents = db_get_all_rows_sql(
'SELECT id_agente
FROM tagente'
);
}
if ($agents === false) { if ($agents === false) {
$agents = []; $agents = [];
@ -2777,10 +2756,7 @@ function html_print_autocomplete_modules(
} }
} else { } else {
if ($ACL) { if ($ACL) {
$groups = users_get_groups($config['id_user'], 'AW', false); $agents = agents_get_agents();
$groups = array_keys($groups);
$agents = db_get_all_rows_sql('SELECT id_agente FROM tagente WHERE id_grupo IN ('.implode(',', $groups).')');
if ($agents === false) { if ($agents === false) {
$agents = []; $agents = [];

View File

@ -663,10 +663,11 @@ function modules_create_agent_module(
'estado' => $status, 'estado' => $status,
'known_status' => $status, 'known_status' => $status,
'id_agente' => (int) $id_agent, 'id_agente' => (int) $id_agent,
'utimestamp' => 0, 'utimestamp' => (time() - (int) $values['interval']),
'status_changes' => 0, 'status_changes' => 0,
'last_status' => $status, 'last_status' => $status,
'last_known_status' => $status, 'last_known_status' => $status,
'current_interval' => (int) $values['interval'],
] ]
); );

View File

@ -1,3 +1,8 @@
/*
global $
global jQuery
*/
/* Modules ids to check types */ /* Modules ids to check types */
var id_modules_icmp = Array(6, 7); var id_modules_icmp = Array(6, 7);
var id_modules_tcp = Array(8, 9, 10, 11); var id_modules_tcp = Array(8, 9, 10, 11);
@ -95,6 +100,7 @@ function configure_modules_form() {
$("#text-unit").attr("value", ""); $("#text-unit").attr("value", "");
$("#checkbox-critical_inverse").attr("value", 0); $("#checkbox-critical_inverse").attr("value", 0);
$("#checkbox-warning_inverse").attr("value", 0); $("#checkbox-warning_inverse").attr("value", 0);
$("#checkbox-ff_type").attr("value", 0);
$("#textarea_critical_instructions").attr("value", ""); $("#textarea_critical_instructions").attr("value", "");
$("#textarea_warning_instructions").attr("value", ""); $("#textarea_warning_instructions").attr("value", "");
$("#textarea_unknown_instructions").attr("value", ""); $("#textarea_unknown_instructions").attr("value", "");
@ -177,6 +183,13 @@ function configure_modules_form() {
"value", "value",
data["min_ff_event"] == 0 ? 0 : data["min_ff_event"] data["min_ff_event"] == 0 ? 0 : data["min_ff_event"]
); );
if (data["ff_type"] != 0) {
$("#checkbox-ff_type").prop("checked", 1);
} else {
$("#checkbox-ff_type").prop("checked", 0);
}
$("#text-post_process").attr( $("#text-post_process").attr(
"value", "value",
data["post_process"] == 0 ? 0 : data["post_process"] data["post_process"] == 0 ? 0 : data["post_process"]
@ -413,6 +426,12 @@ function configure_modules_form() {
data["min_ff_event_critical"] == 0 ? 0 : data["min_ff_event_critical"] data["min_ff_event_critical"] == 0 ? 0 : data["min_ff_event_critical"]
); );
if (data["ff_type"] != 0) {
$("#checkbox-ff_type").prop("checked", 1);
} else {
$("#checkbox-ff_type").prop("checked", 0);
}
// Shows manual input if post_process field is setted // Shows manual input if post_process field is setted
if (data["post_process"] != 0) { if (data["post_process"] != 0) {
$("#post_process_manual").show(); $("#post_process_manual").show();

View File

@ -129,7 +129,7 @@
<div style='height: 10px'> <div style='height: 10px'>
<?php <?php
$version = '7.0NG.733'; $version = '7.0NG.733';
$build = '190408'; $build = '190411';
$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.733 %define version 7.0NG.733
%define release 190408 %define release 190411
# 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.733 %define version 7.0NG.733
%define release 190408 %define release 190411
# 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.733 %define version 7.0NG.733
%define release 190408 %define release 190411
%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

@ -164,6 +164,9 @@ CREATE TABLE IF NOT EXISTS `tagente_estado` (
`last_known_status` tinyint(4) default 0, `last_known_status` tinyint(4) default 0,
`last_error` int(4) NOT NULL default '0', `last_error` int(4) NOT NULL default '0',
`ff_start_utimestamp` bigint(20) default 0, `ff_start_utimestamp` bigint(20) default 0,
`ff_normal` int(4) unsigned default '0',
`ff_warning` int(4) unsigned default '0',
`ff_critical` int(4) unsigned default '0',
`last_dynamic_update` bigint(20) NOT NULL default '0', `last_dynamic_update` bigint(20) NOT NULL default '0',
`last_unknown_update` bigint(20) NOT NULL default '0', `last_unknown_update` bigint(20) NOT NULL default '0',
PRIMARY KEY (`id_agente_estado`), PRIMARY KEY (`id_agente_estado`),
@ -249,6 +252,7 @@ CREATE TABLE IF NOT EXISTS `tagente_modulo` (
`min_ff_event_normal` int(4) unsigned default '0', `min_ff_event_normal` int(4) unsigned default '0',
`min_ff_event_warning` int(4) unsigned default '0', `min_ff_event_warning` int(4) unsigned default '0',
`min_ff_event_critical` int(4) unsigned default '0', `min_ff_event_critical` int(4) unsigned default '0',
`ff_type` tinyint(1) unsigned default '0',
`each_ff` tinyint(1) unsigned default '0', `each_ff` tinyint(1) unsigned default '0',
`ff_timeout` int(4) unsigned default '0', `ff_timeout` int(4) unsigned default '0',
`dynamic_interval` int(4) unsigned default '0', `dynamic_interval` int(4) unsigned default '0',
@ -864,6 +868,7 @@ CREATE TABLE IF NOT EXISTS `tnetwork_component` (
`min_ff_event_normal` int(4) unsigned default '0', `min_ff_event_normal` int(4) unsigned default '0',
`min_ff_event_warning` int(4) unsigned default '0', `min_ff_event_warning` int(4) unsigned default '0',
`min_ff_event_critical` int(4) unsigned default '0', `min_ff_event_critical` int(4) unsigned default '0',
`ff_type` tinyint(1) unsigned default '0',
`each_ff` tinyint(1) unsigned default '0', `each_ff` tinyint(1) unsigned default '0',
`dynamic_interval` int(4) unsigned default '0', `dynamic_interval` int(4) unsigned default '0',
`dynamic_max` int(4) default '0', `dynamic_max` int(4) default '0',
@ -2224,6 +2229,7 @@ CREATE TABLE IF NOT EXISTS `tlocal_component` (
`min_ff_event_normal` int(4) unsigned default '0', `min_ff_event_normal` int(4) unsigned default '0',
`min_ff_event_warning` int(4) unsigned default '0', `min_ff_event_warning` int(4) unsigned default '0',
`min_ff_event_critical` int(4) unsigned default '0', `min_ff_event_critical` int(4) unsigned default '0',
`ff_type` tinyint(1) unsigned default '0',
`each_ff` tinyint(1) unsigned default '0', `each_ff` tinyint(1) unsigned default '0',
`ff_timeout` int(4) unsigned default '0', `ff_timeout` int(4) unsigned default '0',
`dynamic_interval` int(4) unsigned default '0', `dynamic_interval` int(4) unsigned default '0',
@ -2302,6 +2308,7 @@ CREATE TABLE IF NOT EXISTS `tpolicy_modules` (
`min_ff_event_normal` int(4) unsigned default '0', `min_ff_event_normal` int(4) unsigned default '0',
`min_ff_event_warning` int(4) unsigned default '0', `min_ff_event_warning` int(4) unsigned default '0',
`min_ff_event_critical` int(4) unsigned default '0', `min_ff_event_critical` int(4) unsigned default '0',
`ff_type` tinyint(1) unsigned default '0',
`each_ff` tinyint(1) unsigned default '0', `each_ff` tinyint(1) unsigned default '0',
`ff_timeout` int(4) unsigned default '0', `ff_timeout` int(4) unsigned default '0',
`dynamic_interval` int(4) unsigned default '0', `dynamic_interval` int(4) unsigned default '0',

View File

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

View File

@ -1605,53 +1605,116 @@ sub pandora_process_module ($$$$$$$$$;$) {
$current_interval = $module->{'module_interval'}; $current_interval = $module->{'module_interval'};
} }
#Update module status # Update module status.
my $min_ff_event = $module->{'min_ff_event'}; my $min_ff_event = $module->{'min_ff_event'};
my $current_utimestamp = time (); my $current_utimestamp = time ();
my $ff_timeout = $module->{'ff_timeout'}; my $ff_timeout = $module->{'ff_timeout'};
# Counters.
my $ff_warning = $agent_status->{'ff_warning'};
my $ff_critical = $agent_status->{'ff_critical'};
my $ff_normal = $agent_status->{'ff_normal'};
if ($module->{'each_ff'}) { if ($module->{'each_ff'}) {
$min_ff_event = $module->{'min_ff_event_normal'} if ($new_status == 0); $min_ff_event = $module->{'min_ff_event_normal'} if ($new_status == 0);
$min_ff_event = $module->{'min_ff_event_critical'} if ($new_status == 1); $min_ff_event = $module->{'min_ff_event_critical'} if ($new_status == 1);
$min_ff_event = $module->{'min_ff_event_warning'} if ($new_status == 2); $min_ff_event = $module->{'min_ff_event_warning'} if ($new_status == 2);
} }
if ($last_known_status == $new_status) { if ($last_known_status == $new_status) {
# Avoid overflows # Avoid overflows
$status_changes = $min_ff_event if ($status_changes > $min_ff_event); $status_changes = $min_ff_event if ($status_changes > $min_ff_event && $module->{'ff_type'} == 0);
$status_changes++; $status_changes++;
if ($module_type =~ m/async/ && $min_ff_event != 0 && $ff_timeout != 0 && ($utimestamp - $ff_start_utimestamp) > $ff_timeout) { if ($module_type =~ m/async/ && $min_ff_event != 0 && $ff_timeout != 0 && ($utimestamp - $ff_start_utimestamp) > $ff_timeout) {
$status_changes = 0; # Only type ff with counters.
$status_changes = 0 if ($module->{'ff_type'} == 0);
$ff_start_utimestamp = $utimestamp; $ff_start_utimestamp = $utimestamp;
# Reset counters because expired timeout.
$ff_normal = 0;
$ff_critical = 0;
$ff_warning = 0;
} }
} }
else { else {
$status_changes = 0; # Only type ff with counters.
$status_changes = 0 if ($module->{'ff_type'} == 0);
$ff_start_utimestamp = $utimestamp if ($module_type =~ m/async/); $ff_start_utimestamp = $utimestamp if ($module_type =~ m/async/);
} }
# Active ff interval if ($module->{'ff_type'} == 0) {
if ($module->{'module_ff_interval'} != 0 && $status_changes < $min_ff_event) { # Active ff interval.
$current_interval = $module->{'module_ff_interval'}; if ($module->{'module_ff_interval'} != 0 && $status_changes < $min_ff_event) {
} $current_interval = $module->{'module_ff_interval'};
}
# Change status
if ($status_changes >= $min_ff_event && $known_status != $new_status) { # Change status.
generate_status_event ($pa_config, $processed_data, $agent, $module, $new_status, $status, $known_status, $dbh); if ($status_changes >= $min_ff_event && $known_status != $new_status) {
$status = $new_status; generate_status_event ($pa_config, $processed_data, $agent, $module, $new_status, $status, $known_status, $dbh);
$status = $new_status;
# Update module status count. # Update module status count.
$mark_for_update = 1; $mark_for_update = 1;
# Safe mode execution. # Safe mode execution.
if ($agent->{'safe_mode_module'} == $module->{'id_agente_modulo'}) { if ($agent->{'safe_mode_module'} == $module->{'id_agente_modulo'}) {
safe_mode($pa_config, $agent, $module, $new_status, $known_status, $dbh); safe_mode($pa_config, $agent, $module, $new_status, $known_status, $dbh);
}
}
} else {
if ($status == $new_status) {
# If the status is equal to the previous status reset the counters.
$ff_normal = 0;
$ff_critical = 0;
$ff_warning = 0;
} else {
# Sequential critical and normal status are needed
# if don't, reset counters.
if ($last_known_status == 1 && $new_status != 1) {
$ff_critical = 0;
} elsif ($last_known_status == 0 && $new_status != 0) {
$ff_normal = 0;
}
# Increase counters.
$ff_critical++ if ($new_status == 1);
$ff_warning++ if ($new_status == 2);
$ff_normal++ if ($new_status == 0);
}
if ( ($new_status == 0 && $ff_normal >= $min_ff_event)
|| ($new_status == 1 && $ff_critical >= $min_ff_event)
|| ($new_status == 2 && $ff_warning >= $min_ff_event)) {
# Change status generate event.
generate_status_event ($pa_config, $processed_data, $agent, $module, $new_status, $status, $known_status, $dbh);
$status = $new_status;
# Update module status count.
$mark_for_update = 1;
# Safe mode execution.
if ($agent->{'safe_mode_module'} == $module->{'id_agente_modulo'}) {
safe_mode($pa_config, $agent, $module, $new_status, $known_status, $dbh);
}
# Reset counters because change status.
$ff_normal = 0;
$ff_critical = 0;
$ff_warning = 0;
} else {
# Active ff interval
if ($module->{'module_ff_interval'} != 0) {
$current_interval = $module->{'module_ff_interval'};
}
} }
} }
# Set not-init modules to normal status even if min_ff_event is not matched the first time they receive data. # Set not-init modules to normal status even if min_ff_event is not matched the first time they receive data.
# if critical or warning status, just pass through here and wait the time min_ff_event will be matched. # if critical or warning status, just pass through here and wait the time min_ff_event will be matched.
elsif ($status == 4) { if ($status == 4) {
generate_status_event ($pa_config, $processed_data, $agent, $module, 0, $status, $known_status, $dbh); generate_status_event ($pa_config, $processed_data, $agent, $module, 0, $status, $known_status, $dbh);
$status = 0; $status = 0;
@ -1663,6 +1726,11 @@ sub pandora_process_module ($$$$$$$$$;$) {
generate_status_event ($pa_config, $processed_data, $agent, $module, $known_status, $status, $known_status, $dbh); generate_status_event ($pa_config, $processed_data, $agent, $module, $known_status, $status, $known_status, $dbh);
$status = $known_status; $status = $known_status;
# reset counters because change status.
$ff_normal = 0;
$ff_critical = 0;
$ff_warning = 0;
# Update module status count. # Update module status count.
$mark_for_update = 1; $mark_for_update = 1;
} }
@ -1692,10 +1760,11 @@ sub pandora_process_module ($$$$$$$$$;$) {
status_changes = ?, utimestamp = ?, timestamp = ?, status_changes = ?, utimestamp = ?, timestamp = ?,
id_agente = ?, current_interval = ?, running_by = ?, id_agente = ?, current_interval = ?, running_by = ?,
last_execution_try = ?, last_try = ?, last_error = ?, last_execution_try = ?, last_try = ?, last_error = ?,
ff_start_utimestamp = ? ff_start_utimestamp = ?, ff_normal = ?, ff_warning = ?, ff_critical = ?
WHERE id_agente_modulo = ?', $processed_data, $status, $status, $new_status, $new_status, $status_changes, WHERE id_agente_modulo = ?', $processed_data, $status, $status, $new_status, $new_status, $status_changes,
$current_utimestamp, $timestamp, $module->{'id_agente'}, $current_interval, $server_id, $current_utimestamp, $timestamp, $module->{'id_agente'}, $current_interval, $server_id,
$utimestamp, ($save == 1) ? $timestamp : $agent_status->{'last_try'}, $last_error, $ff_start_utimestamp, $module->{'id_agente_modulo'}); $utimestamp, ($save == 1) ? $timestamp : $agent_status->{'last_try'}, $last_error, $ff_start_utimestamp,
$ff_normal, $ff_warning, $ff_critical, $module->{'id_agente_modulo'});
} }
# Save module data. Async and log4x modules are not compressed. # Save module data. Async and log4x modules are not compressed.

View File

@ -641,7 +641,7 @@ sub process_module_data ($$$$$$$$$$) {
'unknown_instructions' => '', 'tags' => '', 'critical_inverse' => 0, 'warning_inverse' => 0, 'quiet' => 0, 'unknown_instructions' => '', 'tags' => '', 'critical_inverse' => 0, 'warning_inverse' => 0, 'quiet' => 0,
'module_ff_interval' => 0, 'alert_template' => '', 'crontab' => '', 'min_ff_event_normal' => 0, 'module_ff_interval' => 0, 'alert_template' => '', 'crontab' => '', 'min_ff_event_normal' => 0,
'min_ff_event_warning' => 0, 'min_ff_event_critical' => 0, 'ff_timeout' => 0, 'each_ff' => 0, 'module_parent' => 0, 'min_ff_event_warning' => 0, 'min_ff_event_critical' => 0, 'ff_timeout' => 0, 'each_ff' => 0, 'module_parent' => 0,
'module_parent_unlink' => 0, 'cron_interval' => 0}; 'module_parent_unlink' => 0, 'cron_interval' => 0, 'ff_type' => 0};
# Other tags will be saved here # Other tags will be saved here
$module_conf->{'extended_info'} = ''; $module_conf->{'extended_info'} = '';

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.733"; my $pandora_version = "7.0NG.733";
my $pandora_build = "190408"; my $pandora_build = "190411";
our $VERSION = $pandora_version." ".$pandora_build; our $VERSION = $pandora_version." ".$pandora_build;
our %EXPORT_TAGS = ( 'all' => [ qw() ] ); our %EXPORT_TAGS = ( 'all' => [ qw() ] );
@ -721,6 +721,9 @@ sub print_module {
if (! (empty ($data->{min_ff_event_critical}))) { if (! (empty ($data->{min_ff_event_critical}))) {
$xml_module .= "\t<min_ff_event_critical><![CDATA[" . $data->{min_ff_event_critical} . "]]></min_ff_event_critical>\n"; $xml_module .= "\t<min_ff_event_critical><![CDATA[" . $data->{min_ff_event_critical} . "]]></min_ff_event_critical>\n";
} }
if (! (empty ($data->{ff_type}))) {
$xml_module .= "\t<ff_type><![CDATA[" . $data->{ff_type} . "]]></ff_type>\n";
}
if (! (empty ($data->{ff_timeout}))) { if (! (empty ($data->{ff_timeout}))) {
$xml_module .= "\t<ff_timeout><![CDATA[" . $data->{ff_timeout} . "]]></ff_timeout>\n"; $xml_module .= "\t<ff_timeout><![CDATA[" . $data->{ff_timeout} . "]]></ff_timeout>\n";
} }

View File

@ -1359,45 +1359,27 @@ sub cron_next_execution {
} }
# Get day of the week and month from cron config # Get day of the week and month from cron config
my ($mday, $wday) = (split (/\s/, $cron))[2, 4]; my ($wday) = (split (/\s/, $cron))[4];
# Check the wday values to avoid infinite loop
my ($wday_down, $wday_up) = cron_get_interval($wday);
if ($wday_down ne "*" && ($wday_down > 6 || (defined($wday_up) && $wday_up > 6))) {
$wday = "*";
}
# Get current time and day of the week # Get current time and day of the week
my $cur_time = time(); my $cur_time = time();
my $cur_wday = (localtime ($cur_time))[6]; my $cur_wday = (localtime ($cur_time))[6];
# Any day of the week my $nex_time = cron_next_execution_date ($cron, $cur_time, $interval);
if ($wday eq '*') {
my $nex_time = cron_next_execution_date ($cron, $cur_time, $interval); # Check the day
return $nex_time - time(); while (!cron_check_interval($wday, (localtime ($nex_time))[6])) {
} # If it does not acomplish the day of the week, go to the next day.
# A range? $nex_time += 86400;
else { $nex_time = cron_next_execution_date ($cron, $nex_time, 0);
$wday = cron_get_closest_in_range ($cur_wday, $wday);
} }
# A specific day of the week return $nex_time - time();
my $count = 0;
my $nex_time = $cur_time;
do {
$nex_time = cron_next_execution_date ($cron, $nex_time, $interval);
my $nex_time_wd = $nex_time;
my ($nex_mon, $nex_wday) = (localtime ($nex_time_wd))[4, 6];
my $nex_mon_wd;
do {
# Check the day of the week
if ($nex_wday == $wday) {
return $nex_time_wd - time();
}
# Move to the next day of the month
$nex_time_wd += 86400;
($nex_mon_wd, $nex_wday) = (localtime ($nex_time_wd))[4, 6];
} while ($mday eq '*' && $nex_mon_wd == $nex_mon);
$count++;
} while ($count < 60);
# Something went wrong, default to 5 minutes
return $interval;
} }
############################################################################### ###############################################################################
# Get the number of seconds left to the next execution of the given cron entry. # Get the number of seconds left to the next execution of the given cron entry.
@ -1409,6 +1391,30 @@ sub cron_check_syntax ($) {
return ($cron =~ m/^(\d|\*|-)+ (\d|\*|-)+ (\d|\*|-)+ (\d|\*|-)+ (\d|\*|-)+$/); return ($cron =~ m/^(\d|\*|-)+ (\d|\*|-)+ (\d|\*|-)+ (\d|\*|-)+ (\d|\*|-)+$/);
} }
############################################################################### ###############################################################################
# Check if a value is inside an interval.
###############################################################################
sub cron_check_interval {
my ($elem_cron, $elem_curr_time) = @_;
# Return 1 if wildcard.
return 1 if ($elem_cron eq "*");
my ($down, $up) = cron_get_interval($elem_cron);
# Check if it is not a range
if (!defined($up)) {
return ($down == $elem_curr_time) ? 1 : 0;
}
# Check if it is on the range
if ($down < $up) {
return 0 if ($elem_curr_time < $down || $elem_curr_time > $up);
} else {
return 0 if ($elem_curr_time > $down || $elem_curr_time < $up);
}
return 1;
}
###############################################################################
# Get the next execution date for the given cron entry in seconds since epoch. # Get the next execution date for the given cron entry in seconds since epoch.
############################################################################### ###############################################################################
sub cron_next_execution_date { sub cron_next_execution_date {
@ -1445,8 +1451,7 @@ sub cron_next_execution_date {
my @nex_time_array = @curr_time_array; my @nex_time_array = @curr_time_array;
# Update minutes # Update minutes
my ($min_down, undef) = cron_get_interval ($min); $nex_time_array[0] = cron_get_next_time_element($min);
$nex_time_array[0] = ($min_down eq '*') ? 0 : $min_down;
$nex_time = cron_valid_date(@nex_time_array, $cur_year); $nex_time = cron_valid_date(@nex_time_array, $cur_year);
if ($nex_time >= $cur_time) { if ($nex_time >= $cur_time) {
@ -1479,8 +1484,7 @@ sub cron_next_execution_date {
return $nex_time if cron_is_in_cron(\@cron_array, \@nex_time_array); return $nex_time if cron_is_in_cron(\@cron_array, \@nex_time_array);
#Update the hour if fails #Update the hour if fails
my ($hour_down, undef) = cron_get_interval ($hour); $nex_time_array[1] = cron_get_next_time_element($hour);
$nex_time_array[1] = ($hour_down eq '*') ? 0 : $hour_down;
# When an overflow is passed check the hour update again # When an overflow is passed check the hour update again
$nex_time = cron_valid_date(@nex_time_array, $cur_year); $nex_time = cron_valid_date(@nex_time_array, $cur_year);
@ -1507,8 +1511,7 @@ sub cron_next_execution_date {
return $nex_time if cron_is_in_cron(\@cron_array, \@nex_time_array); return $nex_time if cron_is_in_cron(\@cron_array, \@nex_time_array);
#Update the day if fails #Update the day if fails
my ($mday_down, undef) = cron_get_interval ($mday); $nex_time_array[2] = cron_get_next_time_element($mday, 1);
$nex_time_array[2] = ($mday_down eq '*') ? 1 : $mday_down;
# When an overflow is passed check the hour update in the next execution # When an overflow is passed check the hour update in the next execution
$nex_time = cron_valid_date(@nex_time_array, $cur_year); $nex_time = cron_valid_date(@nex_time_array, $cur_year);
@ -1530,8 +1533,7 @@ sub cron_next_execution_date {
return $nex_time if cron_is_in_cron(\@cron_array, \@nex_time_array); return $nex_time if cron_is_in_cron(\@cron_array, \@nex_time_array);
#Update the month if fails #Update the month if fails
my ($mon_down, undef) = cron_get_interval ($mon); $nex_time_array[3] = cron_get_next_time_element($mon);
$nex_time_array[3] = ($mon_down eq '*') ? 0 : $mon_down;
# When an overflow is passed check the hour update in the next execution # When an overflow is passed check the hour update in the next execution
$nex_time = cron_valid_date(@nex_time_array, $cur_year); $nex_time = cron_valid_date(@nex_time_array, $cur_year);
@ -1560,22 +1562,30 @@ sub cron_is_in_cron {
#If there is no elements means that is in cron #If there is no elements means that is in cron
return 1 unless (defined($elem_cron) || defined($elem_curr_time)); return 1 unless (defined($elem_cron) || defined($elem_curr_time));
# Go to last element if current is a wild card # Check the element interval
if ($elem_cron ne '*') { return 0 unless (cron_check_interval($elem_cron, $elem_curr_time));
my ($down, $up) = cron_get_interval($elem_cron);
# Check if there is no a range
return 0 if (!defined($up) && ($down != $elem_curr_time));
# Check if there is on the range
if (defined($up)) {
if ($down < $up) {
return 0 if ($elem_curr_time < $down || $elem_curr_time > $up);
} else {
return 0 if ($elem_curr_time > $down || $elem_curr_time < $up);
}
}
}
return cron_is_in_cron(\@deref_elems_cron, \@deref_elems_curr_time); return cron_is_in_cron(\@deref_elems_cron, \@deref_elems_curr_time);
} }
################################################################################
#Get the next tentative time for a cron value or interval in case of overflow.
#Floor data is the minimum localtime data for a position. Ex:
#Ex:
# * should returns floor data.
# 5 should returns 5.
# 10-55 should returns 10.
# 55-10 should retunrs floor data.
################################################################################
sub cron_get_next_time_element {
# Default floor data is 0
my ($curr_element, $floor_data) = @_;
$floor_data = 0 unless defined($floor_data);
my ($elem_down, $elem_up) = cron_get_interval ($curr_element);
return ($elem_down eq '*' || (defined($elem_up) && $elem_down > $elem_up))
? $floor_data
: $elem_down;
}
############################################################################### ###############################################################################
# Returns the interval of a cron element. If there is not a range, # Returns the interval of a cron element. If there is not a range,
# returns an array with the first element in the first place of array # returns an array with the first element in the first place of array

View File

@ -3,7 +3,7 @@
# #
%define name pandorafms_server %define name pandorafms_server
%define version 7.0NG.733 %define version 7.0NG.733
%define release 190408 %define release 190411
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.733 %define version 7.0NG.733
%define release 190408 %define release 190411
Summary: Pandora FMS Server Summary: Pandora FMS Server
Name: %{name} Name: %{name}

View File

@ -9,7 +9,7 @@
# ********************************************************************** # **********************************************************************
PI_VERSION="7.0NG.733" PI_VERSION="7.0NG.733"
PI_BUILD="190408" PI_BUILD="190411"
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.733 PS190408"; my $version = "7.0NG.733 PS190411";
# 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.733 PS190408"; my $version = "7.0NG.733 PS190411";
# save program name for logging # save program name for logging
my $progname = basename($0); my $progname = basename($0);