diff --git a/extras/build_rpm_rhel7.sh b/extras/build_rpm_rhel7.sh new file mode 100755 index 0000000000..6bb65d816d --- /dev/null +++ b/extras/build_rpm_rhel7.sh @@ -0,0 +1,26 @@ +#!/bin/bash +source build_vars.sh + +if [ ! -d $RPMHOME/RPMS ]; then + mkdir -p $RPMHOME/RPMS || exit 1 +fi + +echo "Creating RPM packages in $RPMHOME/RPMS" + +# Console +rpmbuild -ba $CODEHOME/pandora_console/pandora_console.rhel7.spec || exit 1 + +# Server +rpmbuild -ba $CODEHOME/pandora_server/pandora_server.rhel7.spec || exit 1 + +# Unix agent +rpmbuild -ba $CODEHOME/pandora_agents/unix/pandora_agent.rhel7.spec || exit 1 + +# Enterprise console +rpmbuild -ba $PANDHOME_ENT/pandora_console/enterprise/pandora_console_enterprise.rhel7.spec || exit 1 + +# Enterprise server +rpmbuild -ba $PANDHOME_ENT/pandora_server/PandoraFMS-Enterprise/pandora_server_enterprise.rhel7.spec || exit 1 + +exit 0 + diff --git a/extras/pandora_update_version.sh b/extras/pandora_update_version.sh index 7d143f0f03..33e0c891f7 100755 --- a/extras/pandora_update_version.sh +++ b/extras/pandora_update_version.sh @@ -26,6 +26,7 @@ $CODEHOME/pandora_server/pandora_server.spec \ $PANDHOME_ENT/pandora_console/enterprise/pandora_console_enterprise.spec \ $PANDHOME_ENT/pandora_server/PandoraFMS-Enterprise/pandora_server_enterprise.spec \ $CODEHOME/pandora_console/pandora_console.redhat.spec \ +$CODEHOME/pandora_console/pandora_console.rhel7.spec \ $CODEHOME/pandora_agents/unix/pandora_agent.redhat.spec \ $CODEHOME/pandora_server/pandora_server.redhat.spec \ $PANDHOME_ENT/pandora_console/enterprise/pandora_console_enterprise.redhat.spec \ diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 305342f0d7..ae32bb637c 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.733-190328 +Version: 7.0NG.733-190412 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index 8b8ec904c5..dfaee640cd 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.733-190328" +pandora_version="7.0NG.733-190412" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 093bc078f5..8574e5992c 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -42,7 +42,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.733'; -use constant AGENT_BUILD => '190328'; +use constant AGENT_BUILD => '190412'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; @@ -662,6 +662,8 @@ sub parse_conf_modules($) { $module->{'ff_timeout'} = $1; } elsif ($line =~ /^\s*module_each_ff\s+(\S+)\s*$/) { $module->{'each_ff'} = $1; + } elsif ($line =~ /^\s*module_ff_type\s+(\d+)\s*$/) { + $module->{'ff_type'} = $1; # Macros } elsif ($line =~ /^\s*module_macro(\S+)\s+(.*)\s*$/) { $module->{'macros'}{$1} = $2; @@ -2101,45 +2103,28 @@ sub cron_next_execution { } # 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 my $cur_time = time(); my $cur_wday = (localtime ($cur_time))[6]; - # Any day of the week - if ($wday eq '*') { - my $nex_time = cron_next_execution_date ($cron, $cur_time, $interval); - return $nex_time - time(); - } - # A range? - else { - $wday = cron_get_closest_in_range ($cur_wday, $wday); + my $nex_time = cron_next_execution_date ($cron, $cur_time, $interval); + + # Check the day + while (!cron_check_interval($wday, (localtime ($nex_time))[6])) { + # If it does not acomplish the day of the week, go to the next day. + $nex_time += 86400; + $nex_time = cron_next_execution_date ($cron, $nex_time, 0); } - # A specific day of the week - 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; + return $nex_time - time(); } ############################################################################### @@ -2151,7 +2136,30 @@ sub cron_check_syntax ($) { return 0 if !defined ($cron); 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. ############################################################################### @@ -2189,8 +2197,7 @@ sub cron_next_execution_date { my @nex_time_array = @curr_time_array; # Update minutes - my ($min_down, undef) = cron_get_interval ($min); - $nex_time_array[0] = ($min_down eq '*') ? 0 : $min_down; + $nex_time_array[0] = cron_get_next_time_element($min); $nex_time = cron_valid_date(@nex_time_array, $cur_year); 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); #Update the hour if fails - my ($hour_down, undef) = cron_get_interval ($hour); - $nex_time_array[1] = ($hour_down eq '*') ? 0 : $hour_down; + $nex_time_array[1] = cron_get_next_time_element($hour); # When an overflow is passed check the hour update again $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); #Update the day if fails - my ($mday_down, undef) = cron_get_interval ($mday); - $nex_time_array[2] = ($mday_down eq '*') ? 1 : $mday_down; + $nex_time_array[2] = cron_get_next_time_element($mday, 1); - # 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); if ($nex_time >= $cur_time) { 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); #Update the month if fails - my ($mon_down, undef) = cron_get_interval ($mon); - $nex_time_array[3] = ($mon_down eq '*') ? 0 : $mon_down; + $nex_time_array[3] = cron_get_next_time_element($mon); # When an overflow is passed check the month update in the next execution $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 return 1 unless (defined($elem_cron) || defined($elem_curr_time)); - # Go to last element if current is a wild card - if ($elem_cron ne '*') { - 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); - } - } - } + # Check the element interval + return 0 unless (cron_check_interval($elem_cron, $elem_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 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); # Check if current timestamp is a valid cron date - my $next_execution = cron_next_execution_date( + my $next_execution = cron_next_execution( $module->{'cron'}, - $now - $interval, - $interval + 0 ); - return 1 if ($next_execution == $now); + return 1 if (time() + $next_execution == $now); return 0; } @@ -2532,6 +2542,7 @@ sub write_module_xml ($@) { $Xml .= " " . $module->{'min_ff_event_critical'} . "\n" if (defined ($module->{'min_ff_event_critical'})); $Xml .= " " . $module->{'ff_timeout'} . "\n" if (defined ($module->{'ff_timeout'})); $Xml .= " " . $module->{'each_ff'} . "\n" if (defined ($module->{'each_ff'})); + $Xml .= " " . $module->{'ff_type'} . "\n" if (defined ($module->{'ff_type'})); # Data list if ($#data > 0) { diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index d2597d9f3e..f422cf9440 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.733 -%define release 190328 +%define release 190412 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index fe756636b4..aa20c8959d 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.733 -%define release 190328 +%define release 190412 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index 0e0229707f..5a37ec8afb 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.733" -PI_BUILD="190328" +PI_BUILD="190412" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/bin/pandora_agent.conf b/pandora_agents/win32/bin/pandora_agent.conf index 12ccb4e91b..3ec2bf3880 100644 --- a/pandora_agents/win32/bin/pandora_agent.conf +++ b/pandora_agents/win32/bin/pandora_agent.conf @@ -44,6 +44,8 @@ remote_config 0 #agent_name_cmd cscript.exe //B "%ProgramFiles%\Pandora_Agent\util\agentname.vbs" agent_name_cmd __rand__ +# Agent alias. Name should be unique rather than alias. Hostname by default +# agent_alias $Alias$ #Parent agent_name #parent_agent_name caprica diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 410edf850f..ab6dbf55cf 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{190328} +{190412} ViewReadme {Yes} diff --git a/pandora_agents/win32/misc/cron.cc b/pandora_agents/win32/misc/cron.cc index 2d3e5e0440..409a43f726 100644 --- a/pandora_agents/win32/misc/cron.cc +++ b/pandora_agents/win32/misc/cron.cc @@ -214,7 +214,7 @@ int Cron::getResetValue (int position) { int default_value = 0; // Days start in 1 if (position == 2) default_value = 1; - return isWildCard(position) + return (isWildCard(position) || !isNormalInterval(position)) ? default_value : this->params[position][CRDOWN]; } diff --git a/pandora_agents/win32/modules/pandora_module.cc b/pandora_agents/win32/modules/pandora_module.cc index eac38c8fa1..e7c751d367 100644 --- a/pandora_agents/win32/modules/pandora_module.cc +++ b/pandora_agents/win32/modules/pandora_module.cc @@ -78,6 +78,7 @@ Pandora_Module::Pandora_Module (string name) { this->warning_inverse = ""; this->quiet = ""; this->module_ff_interval = ""; + this->module_ff_type = ""; this->module_alert_template = ""; this->module_crontab = ""; } @@ -733,6 +734,13 @@ Pandora_Module::getXml () { module_xml += this->module_ff_interval; module_xml += "\n"; } + + /* Module FF type */ + if (this->module_ff_type != "") { + module_xml += "\t"; + module_xml += this->module_ff_type; + module_xml += "\n"; + } /* Module Alert template */ if (this->module_alert_template != "") { @@ -1028,6 +1036,16 @@ Pandora_Module::setModuleFFInterval (string 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. * diff --git a/pandora_agents/win32/modules/pandora_module.h b/pandora_agents/win32/modules/pandora_module.h index 9fb29e1183..c766766950 100644 --- a/pandora_agents/win32/modules/pandora_module.h +++ b/pandora_agents/win32/modules/pandora_module.h @@ -176,6 +176,7 @@ namespace Pandora_Modules { string unit, custom_id, str_warning, str_critical; string module_group, warning_inverse, critical_inverse, quiet; string module_ff_interval, module_alert_template, module_crontab; + string module_ff_type; string critical_instructions, warning_instructions, unknown_instructions, tags; protected: @@ -277,6 +278,7 @@ namespace Pandora_Modules { void setWarningInverse (string value); void setQuiet (string value); void setModuleFFInterval (string value); + void setModuleFFType (string value); void setModuleAlertTemplate (string value); void setModuleCrontab (string value); diff --git a/pandora_agents/win32/modules/pandora_module_factory.cc b/pandora_agents/win32/modules/pandora_module_factory.cc index 658ff724fd..b05422f104 100644 --- a/pandora_agents/win32/modules/pandora_module_factory.cc +++ b/pandora_agents/win32/modules/pandora_module_factory.cc @@ -119,6 +119,7 @@ using namespace Pandora_Strutils; #define TOKEN_WARNING_INVERSE ("module_warning_inverse ") #define TOKEN_QUIET ("module_quiet ") #define TOKEN_MODULE_FF_INTERVAL ("module_ff_interval ") +#define TOKEN_MODULE_FF_TYPE ("module_ff_type ") #define TOKEN_MACRO ("module_macro") #define TOKEN_NATIVE_ENCODING ("module_native_encoding") #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_critical_instructions, module_warning_instructions, module_unknown_instructions, module_tags; 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; Pandora_Module *module; bool numeric; @@ -254,6 +255,7 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) { module_warning_inverse = ""; module_quiet = ""; module_ff_interval = ""; + module_ff_type = ""; module_native_encoding = ""; module_alert_template = ""; module_user_session = ""; @@ -507,6 +509,10 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) { if (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 == "") { 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 != "") { pos_macro = module_alert_template.find(macro_name); if (pos_macro != string::npos){ @@ -1447,6 +1460,10 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) { if (module_ff_interval != "") { module->setModuleFFInterval (module_ff_interval); } + + if (module_ff_type != "") { + module->setModuleFFType (module_ff_type); + } if (module_alert_template != "") { module->setModuleAlertTemplate (module_alert_template); diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 4eca7665c2..29e3fa7c6c 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.733(Build 190328)") +#define PANDORA_VERSION ("7.0NG.733(Build 190412)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 0e13be6bb3..f100c45e66 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.733(Build 190328))" + VALUE "ProductVersion", "(7.0NG.733(Build 190412))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 1fd042be78..9a2377396a 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.733-190328 +Version: 7.0NG.733-190412 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index c4e5d98fa3..8ede0c1194 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.733-190328" +pandora_version="7.0NG.733-190412" package_pear=0 package_pandora=1 diff --git a/pandora_console/extras/mr/27.sql b/pandora_console/extras/mr/27.sql index 2ed92ecbaf..aff9a5eeb9 100644 --- a/pandora_console/extras/mr/27.sql +++ b/pandora_console/extras/mr/27.sql @@ -1,5 +1,43 @@ START TRANSACTION; -ALTER TABLE tnetflow_filter DROP COLUMN output; +ALTER TABLE `tnetflow_filter` DROP COLUMN `output`; + +COMMIT; +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"; + +ALTER TABLE `treport_content` ADD COLUMN `total_time` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `time_failed` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `time_in_ok_status` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `time_in_unknown_status` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `time_of_not_initialized_module` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `time_of_downtime` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `total_checks` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `checks_failed` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `checks_in_ok_status` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `unknown_checks` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `agent_max_value` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `agent_min_value` TINYINT(1) DEFAULT '1'; + +ALTER TABLE `treport_content_template` ADD COLUMN `total_time` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `time_failed` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `time_in_ok_status` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `time_in_unknown_status` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `time_of_not_initialized_module` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `time_of_downtime` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `total_checks` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `checks_failed` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `checks_in_ok_status` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `unknown_checks` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `agent_max_value` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `agent_min_value` TINYINT(1) DEFAULT '1'; COMMIT; diff --git a/pandora_console/extras/pandora_diag.php b/pandora_console/extras/pandora_diag.php index d6cd017087..10e9fbfd42 100644 --- a/pandora_console/extras/pandora_diag.php +++ b/pandora_console/extras/pandora_diag.php @@ -139,7 +139,7 @@ function get_logs_size($file) function get_status_logs($path) { $status_server_log = ''; - $size_server_log = number_format(get_logs_size($path)); + $size_server_log = get_logs_size($path); if ($size_server_log <= 1048576) { $status_server_log = "Normal Status   You have less than 10 MB of logs"; } else { @@ -157,9 +157,9 @@ function percentage_modules_per_agent() $total_modules = db_get_value_sql('SELECT count(*) FROM tagente_modulo'); $average_modules_per_agent = ($total_modules / $total_agents); if ($average_modules_per_agent <= 40) { - $status_average_modules = "Normal Status   The average of modules per agent is less than 40 percent"; + $status_average_modules = "Normal Status   The average of modules per agent is less than 40"; } else { - $status_average_modules = "Warning Status  The average of modules per agent is more than 40 percent. You can have performance problems"; + $status_average_modules = "Warning Status  The average of modules per agent is more than 40. You can have performance problems"; } return $status_average_modules; @@ -202,9 +202,9 @@ function interval_average_of_network_modules() $average_time = ((int) $total_module_interval_time / $total_network_modules); if ($average_time < 180) { - $status_average_modules = "Warning Status   The system has a lot of load and a very fine configuration is required"; + $status_average_modules = "Warning Status   The system has a lot of load (average time $average_time) and a very fine configuration is required"; } else { - $status_average_modules = "Normal Status   The system has an acceptable charge"; + $status_average_modules = "Normal Status   The system has an acceptable charge (average time $average_time) "; } if ($average_time == 0) { @@ -274,6 +274,7 @@ if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') { } $path_server_logs = '/log/pandora/pandora_server.log'; +$path_err_logs = '/log/pandora/pandora_server.error'; $path_console_logs = '/www/html/pandora_console/pandora_console.log'; $innodb_log_file_size_min_rec_value = '64M'; $innodb_log_buffer_size_min_rec_value = '16M'; @@ -710,6 +711,8 @@ render_info_data( render_row(number_format((get_logs_size($path_server_logs) / 1048576), 3).'M', 'Size server logs (current value)'); render_row(get_status_logs($path_server_logs), 'Status server logs'); + render_row(number_format((get_logs_size($path_err_logs) / 1048576), 3).'M', 'Size error logs (current value)'); + render_row(get_status_logs($path_err_logs), 'Status error logs'); render_row(number_format((get_logs_size($path_console_logs) / 1048576), 3).'M', 'Size console logs (current value)'); render_row(get_status_logs($path_console_logs), 'Status console logs'); diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 276a984831..4cdb88ac30 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -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_two_tailed` tinyint(1) unsigned default '0'; +ALTER TABLE `tlocal_component` ADD COLUMN `ff_type` tinyint(1) unsigned default '0'; -- ----------------------------------------------------- -- 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_two_tailed` tinyint(1) unsigned default '0'; +ALTER TABLE `tpolicy_modules` ADD COLUMN `ff_type` tinyint(1) unsigned default '0'; -- --------------------------------------------------------------------- -- Table `tpolicies` @@ -764,6 +766,18 @@ ALTER TABLE treport_content_template ADD COLUMN `lapse_calc` tinyint(1) default ALTER TABLE treport_content_template ADD COLUMN `lapse` int(11) default '300'; ALTER TABLE treport_content_template ADD COLUMN `visual_format` tinyint(1) default '0'; ALTER TABLE treport_content_template ADD COLUMN `hide_no_data` tinyint(1) default '0'; +ALTER TABLE `treport_content_template` ADD COLUMN `total_time` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `time_failed` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `time_in_ok_status` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `time_in_unknown_status` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `time_of_not_initialized_module` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `time_of_downtime` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `total_checks` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `checks_failed` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `checks_in_ok_status` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `unknown_checks` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `agent_max_value` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `agent_min_value` TINYINT(1) DEFAULT '1'; -- ----------------------------------------------------- -- Table `treport_content_sla_com_temp` (treport_content_sla_combined_template) @@ -1150,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 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 `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` @@ -1199,13 +1216,13 @@ ALTER TABLE titem MODIFY `source_data` int(10) unsigned; INSERT INTO `tconfig` (`token`, `value`) VALUES ('big_operation_step_datos_purge', '100'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('small_operation_step_datos_purge', '1000'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('days_autodisable_deletion', '30'); -INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 26); +INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 27); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_docs_logo', 'default_docs.png'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_support_logo', 'default_support.png'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_logo_white_bg_preview', 'pandora_logo_head_white_bg.png'); UPDATE tconfig SET value = 'https://licensing.artica.es/pandoraupdate7/server.php' WHERE token='url_update_manager'; DELETE FROM `tconfig` WHERE `token` = 'current_package_enterprise'; -INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '733'); +INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '734'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('status_monitor_fields', 'policy,agent,data_type,module_name,server_type,interval,status,graph,warn,data,timestamp'); -- --------------------------------------------------------------------- @@ -1260,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 `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 `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` @@ -1279,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_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 `ff_type` tinyint(1) unsigned default '0'; -- --------------------------------------------------------------------- -- Table `tagente` @@ -1379,6 +1401,18 @@ ALTER TABLE treport_content ADD COLUMN `hide_no_data` tinyint(1) default '0'; ALTER TABLE treport_content ADD COLUMN `recursion` tinyint(1) default NULL; ALTER TABLE treport_content ADD COLUMN `show_extended_events` tinyint(1) default '0'; UPDATE `treport_content` SET type="netflow_summary" WHERE type="netflow_pie" OR type="netflow_statistics"; +ALTER TABLE `treport_content` ADD COLUMN `total_time` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `time_failed` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `time_in_ok_status` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `time_in_unknown_status` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `time_of_not_initialized_module` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `time_of_downtime` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `total_checks` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `checks_failed` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `checks_in_ok_status` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `unknown_checks` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `agent_max_value` TINYINT(1) DEFAULT '1'; +ALTER TABLE `treport_content` ADD COLUMN `agent_min_value` TINYINT(1) DEFAULT '1'; -- --------------------------------------------------------------------- -- Table `tmodule_relationship` @@ -2058,5 +2092,14 @@ INSERT INTO `trecon_script` (`name`,`description`,`script`,`macros`) VALUES ('Di -- Add column in table `tagent_custom_fields` -- ---------------------------------------------------------------------- ALTER TABLE tagent_custom_fields ADD COLUMN `combo_values` VARCHAR(255) DEFAULT ''; -ALTER TABLE tnetflow_filter DROP COLUMN output; +-- ---------------------------------------------------------------------- +-- Add column in table `tnetflow_filter` +-- ---------------------------------------------------------------------- +ALTER TABLE `tnetflow_filter` DROP COLUMN `output`; + + +-- ---------------------------------------------------------------------- +-- Update table `tuser_task` +-- ---------------------------------------------------------------------- +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"; diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index ee92aac2c4..d3bf94ddc1 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -591,9 +591,7 @@ if ($config['menu_type'] == 'classic') { if (fixed_header) { $('div#head').addClass('fixed_header'); - $('div#page') - .css('padding-top', $('div#head').innerHeight() + 'px') - .css('position', 'relative'); + $('div#main').css('padding-top', $('div#head').innerHeight() + 'px'); } check_new_chats_icon('icon_new_messages_chat'); diff --git a/pandora_console/godmode/agentes/agent_template.php b/pandora_console/godmode/agentes/agent_template.php index 64e78320f5..f4c93bb9f1 100644 --- a/pandora_console/godmode/agentes/agent_template.php +++ b/pandora_console/godmode/agentes/agent_template.php @@ -106,6 +106,7 @@ if (isset($_POST['template_id'])) { 'min_ff_event_normal' => $row2['min_ff_event_normal'], 'min_ff_event_warning' => $row2['min_ff_event_warning'], 'min_ff_event_critical' => $row2['min_ff_event_critical'], + 'ff_type' => $row2['ff_type'], ]; $name = $row2['name']; diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 9c10099042..dd7fad8fe8 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -160,7 +160,7 @@ $module_macros = []; if ($create_agent) { $mssg_warning = 0; $alias_safe_output = io_safe_output(get_parameter('alias', '')); - $alias = io_safe_input(trim(preg_replace('/[\/\\\|%#&$-]/', '', $alias_safe_output))); + $alias = io_safe_input(trim(preg_replace('/[\/\\\|%#&$]/', '', $alias_safe_output))); $alias_as_name = (int) get_parameter_post('alias_as_name', 0); $direccion_agente = (string) get_parameter_post('direccion', ''); $unique_ip = (int) get_parameter_post('unique_ip', 0); @@ -766,7 +766,7 @@ if ($update_agent) { $id_agente = (int) get_parameter_post('id_agente'); $nombre_agente = str_replace('`', '‘', (string) get_parameter_post('agente', '')); $alias_safe_output = io_safe_output(get_parameter('alias', '')); - $alias = io_safe_input(trim(preg_replace('/[\/\\\|%#&$-]/', '', $alias_safe_output))); + $alias = io_safe_input(trim(preg_replace('/[\/\\\|%#&$]/', '', $alias_safe_output))); $alias_as_name = (int) get_parameter_post('alias_as_name', 0); $direccion_agente = (string) get_parameter_post('direccion', ''); $unique_ip = (int) get_parameter_post('unique_ip', 0); @@ -1320,6 +1320,7 @@ if ($update_module || $create_module) { $ff_event_normal = (int) get_parameter('ff_event_normal'); $ff_event_warning = (int) get_parameter('ff_event_warning'); $ff_event_critical = (int) get_parameter('ff_event_critical'); + $ff_type = (int) get_parameter('ff_type'); $each_ff = (int) get_parameter('each_ff'); $ff_timeout = (int) get_parameter('ff_timeout'); $unit = (string) get_parameter('unit_select'); @@ -1482,6 +1483,7 @@ if ($update_module) { 'min_ff_event_normal' => $ff_event_normal, 'min_ff_event_warning' => $ff_event_warning, 'min_ff_event_critical' => $ff_event_critical, + 'ff_type' => $ff_type, 'each_ff' => $each_ff, 'ff_timeout' => $ff_timeout, 'unit' => io_safe_output($unit), @@ -1677,6 +1679,7 @@ if ($create_module) { 'min_ff_event_normal' => $ff_event_normal, 'min_ff_event_warning' => $ff_event_warning, 'min_ff_event_critical' => $ff_event_critical, + 'ff_type' => $ff_type, 'each_ff' => $each_ff, 'ff_timeout' => $ff_timeout, 'unit' => io_safe_output($unit), diff --git a/pandora_console/godmode/agentes/module_manager_editor.php b/pandora_console/godmode/agentes/module_manager_editor.php index aaa2078479..9d49bb0a96 100644 --- a/pandora_console/godmode/agentes/module_manager_editor.php +++ b/pandora_console/godmode/agentes/module_manager_editor.php @@ -249,6 +249,7 @@ if ($id_agent_module) { $ff_event_normal = $module['min_ff_event_normal']; $ff_event_warning = $module['min_ff_event_warning']; $ff_event_critical = $module['min_ff_event_critical']; + $ff_type = $module['ff_type']; $each_ff = $module['each_ff']; $ff_timeout = $module['ff_timeout']; // Select tag info. @@ -393,6 +394,7 @@ if ($id_agent_module) { $ff_event_normal = ''; $ff_event_warning = ''; $ff_event_critical = ''; + $ff_type = 0; $id_category = 0; diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index 892228042a..1724ee6622 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -496,10 +496,28 @@ if (modules_is_string_type($id_module_type) || $edit) { $table_simple->data[5][1] .= '
'.__('Inverse interval').''; $table_simple->data[5][1] .= html_print_checkbox('critical_inverse', 1, $critical_inverse, true, $disabledBecauseInPolicy); -// FF stands for Flip-flop -$table_simple->data[6][0] = __('FF threshold').' '.ui_print_help_icon('ff_threshold', true); +// FF stands for Flip-flop. +$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 +).'
'; + +$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( 'ff_event', $ff_event, @@ -512,7 +530,16 @@ $table_simple->data[6][1] .= html_print_input_text( '', $classdisabledBecauseInPolicy ).'
'; -$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] .= html_print_input_text( 'ff_event_normal', @@ -526,6 +553,7 @@ $table_simple->data[6][1] .= html_print_input_text( '', $classdisabledBecauseInPolicy ).' '; + $table_simple->data[6][1] .= __('To warning'); $table_simple->data[6][1] .= html_print_input_text( 'ff_event_warning', @@ -539,6 +567,7 @@ $table_simple->data[6][1] .= html_print_input_text( '', $classdisabledBecauseInPolicy ).' '; + $table_simple->data[6][1] .= __('To critical'); $table_simple->data[6][1] .= html_print_input_text( 'ff_event_critical', @@ -552,16 +581,31 @@ $table_simple->data[6][1] .= html_print_input_text( '', $classdisabledBecauseInPolicy ); + $table_simple->data[7][0] = __('Historical data'); 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 - $table_simple->data[7][1] = html_print_checkbox('history_data_fake', 1, $history_data, true, $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. + $table_simple->data[7][1] = html_print_checkbox( + 'history_data_fake', + 1, + $history_data, + true, + $disabledBecauseInPolicy + ); $table_simple->data[7][1] .= ''; } 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->id = 'advanced'; $table_advanced->width = '100%'; diff --git a/pandora_console/godmode/massive/massive_edit_modules.php b/pandora_console/godmode/massive/massive_edit_modules.php index 568e74dbbb..ae6b5b1432 100755 --- a/pandora_console/godmode/massive/massive_edit_modules.php +++ b/pandora_console/godmode/massive/massive_edit_modules.php @@ -844,20 +844,122 @@ $table->data['edit1'][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 - $table->data['edit7'][0] = __('FF threshold').' '.ui_print_help_icon('ff_threshold', true); + // FF stands for Flip-flop. + $table->data['edit7'][0] = __('FF threshold').' '; + $table->data['edit7'][0] .= ui_print_help_icon( + 'ff_threshold', + true + ); + $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).'
'; - $table->data['edit7'][1] .= __('All state changing').' : '.html_print_input_text('min_ff_event', '', '', 5, 15, true).'
'; + $table->data['edit7'][1] = __('Mode').' '; + $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;' + ).'
'; + + $table->data['edit7'][1] .= __('All state changing').' : '; + $table->data['edit7'][1] .= html_print_input_text( + 'min_ff_event', + '', + '', + 5, + 15, + true + ).'
'; + $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 warning').html_print_input_text('min_ff_event_warning', '', '', 5, 15, true).' '; - $table->data['edit7'][1] .= __('To critical').html_print_input_text('min_ff_event_critical', '', '', 5, 15, true).' '; + $table->data['edit7'][1] .= __('To normal').' '; + $table->data['edit7'][1] .= html_print_input_text( + '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 + ).'
'; + + $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'][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'][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'][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]; } - // List of fields which can be updated + // List of fields which can be updated. $fields = [ 'dynamic_interval', 'dynamic_max', @@ -1730,6 +1832,7 @@ function process_manage_edit($module_name, $agents_select=null, $module_status=' 'min_ff_event_normal', 'min_ff_event_warning', 'min_ff_event_critical', + 'ff_type', 'each_ff', 'module_ff_interval', 'ff_timeout', diff --git a/pandora_console/godmode/modules/manage_network_components.php b/pandora_console/godmode/modules/manage_network_components.php index f1fae1785d..906f36be15 100644 --- a/pandora_console/godmode/modules/manage_network_components.php +++ b/pandora_console/godmode/modules/manage_network_components.php @@ -124,6 +124,7 @@ $pure = get_parameter('pure', 0); $ff_event_normal = (int) get_parameter('ff_event_normal'); $ff_event_warning = (int) get_parameter('ff_event_warning'); $ff_event_critical = (int) get_parameter('ff_event_critical'); +$ff_type = (int) get_parameter('ff_type'); $each_ff = (int) get_parameter('each_ff'); 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_warning' => $ff_event_warning, 'min_ff_event_critical' => $ff_event_critical, + 'ff_type' => $ff_type, 'each_ff' => $each_ff, ] ); @@ -355,6 +357,7 @@ if ($update_component) { 'min_ff_event_normal' => $ff_event_normal, 'min_ff_event_warning' => $ff_event_warning, 'min_ff_event_critical' => $ff_event_critical, + 'ff_type' => $ff_type, 'each_ff' => $each_ff, ] ); @@ -496,6 +499,7 @@ $url = ui_get_url_refresh( 'ff_event_warning' => false, 'ff_event_critical' => false, 'each_ff' => false, + 'ff_type' => false, ] ); diff --git a/pandora_console/godmode/modules/manage_network_components_form.php b/pandora_console/godmode/modules/manage_network_components_form.php index 3f9a33cb8a..fd922046d1 100644 --- a/pandora_console/godmode/modules/manage_network_components_form.php +++ b/pandora_console/godmode/modules/manage_network_components_form.php @@ -76,6 +76,7 @@ if ($create_network_from_module) { $ff_event_normal = $data_module['min_ff_event_normal']; $ff_event_warning = $data_module['min_ff_event_warning']; $ff_event_critical = $data_module['min_ff_event_critical']; + $ff_type = $data_module['ff_type']; $each_ff = $data_module['each_ff']; } @@ -134,6 +135,7 @@ if (isset($id)) { $ff_event_normal = $component['min_ff_event_normal']; $ff_event_warning = $component['min_ff_event_warning']; $ff_event_critical = $component['min_ff_event_critical']; + $ff_type = $component['ff_type']; $each_ff = $component['each_ff']; if ($type >= 15 && $type <= 18) { @@ -192,6 +194,7 @@ if (isset($id)) { $ff_event_normal = 0; $ff_event_warning = 0; $ff_event_critical = 0; + $ff_type = 0; $each_ff = 0; $snmp_version = 1; diff --git a/pandora_console/godmode/modules/manage_network_components_form_common.php b/pandora_console/godmode/modules/manage_network_components_form_common.php index 2e511c6f6f..7b33a0a275 100644 --- a/pandora_console/godmode/modules/manage_network_components_form_common.php +++ b/pandora_console/godmode/modules/manage_network_components_form_common.php @@ -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->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 +).'
'; + +$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( 'ff_event', $ff_event, @@ -242,13 +258,40 @@ $table->data[6][1] .= html_print_input_text( 15, true ).'
'; -$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] .= 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] .= 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] .= 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][1] = html_print_checkbox('history_data', 1, $history_data, true); diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 62d58c9261..85b5ee128d 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -119,6 +119,20 @@ $visual_format = 0; // Others $filter_search = ''; +// Added for select fields. +$total_time = true; +$time_failed = true; +$time_in_ok_status = true; +$time_in_unknown_status = true; +$time_of_not_initialized_module = true; +$time_of_downtime = true; +$total_checks = true; +$checks_failed = true; +$checks_in_ok_status = true; +$unknown_checks = true; +$agent_max_value = true; +$agent_min_value = true; + switch ($action) { case 'new': $actionParameter = 'save'; @@ -501,6 +515,18 @@ switch ($action) { $sunday = $item['sunday']; $time_from = $item['time_from']; $time_to = $item['time_to']; + $total_time = $item['total_time']; + $time_failed = $item['time_failed']; + $time_in_ok_status = $item['time_in_ok_status']; + $time_in_unknown_status = $item['time_in_unknown_status']; + $time_of_not_initialized_module = $item['time_of_not_initialized_module']; + $time_of_downtime = $item['time_of_downtime']; + $total_checks = $item['total_checks']; + $checks_failed = $item['checks_failed']; + $checks_in_ok_status = $item['checks_in_ok_status']; + $unknown_checks = $item['unknown_checks']; + $agent_max_value = $item['agent_max_value']; + $agent_min_value = $item['agent_min_value']; break; case 'group_report': @@ -1597,20 +1623,6 @@ $class = 'databox filters'; REPORT_EXCEPTION_CONDITION_NOT_OK => __('Not OK'), ]; html_print_select($list_exception_condition, 'exception_condition', $exception_condition); - - - /* - echo ; - html_print_radio_button ('radiobutton_exception_condition', 0, '', $exception_condition); - echo __('>='); - html_print_radio_button ('radiobutton_exception_condition', 1, '', $exception_condition); - echo __('<'); - html_print_radio_button ('radiobutton_exception_condition', 2, '', $exception_condition); - echo __('OK'); - html_print_radio_button ('radiobutton_exception_condition', 3, '', $exception_condition); - echo __('Not OK'); - html_print_radio_button ('radiobutton_exception_condition', 4, '', $exception_condition); - */ ?> @@ -1620,6 +1632,65 @@ $class = 'databox filters'; + + + + + + + + + + + + + @@ -2625,6 +2769,17 @@ $(document).ready (function () { } }); + + $("#checkbox-checkbox_show_resume").change(function(){ + if($(this).is(":checked")){ + $("#row_select_fields2").show(); + $("#row_select_fields3").show(); + } + else{ + $("#row_select_fields2").hide(); + $("#row_select_fields3").hide(); + } + }); }); @@ -3139,6 +3294,9 @@ function chooseType() { $("#row_event_type").hide(); $("#row_event_status").hide(); $("#row_source").hide(); + $('#row_select_fields').hide(); + $("#row_select_fields2").hide(); + $("#row_select_fields3").hide(); // SLA list default state $("#sla_list").hide(); @@ -3547,6 +3705,15 @@ function chooseType() { $("#row_show_resume").show(); $("#row_working_time").show(); $('#row_hide_notinit_agents').show(); + $('#row_select_fields').show(); + if($("#checkbox-checkbox_show_resume").is(":checked")){ + $("#row_select_fields2").show(); + $("#row_select_fields3").show(); + } + else{ + $("#row_select_fields2").hide(); + $("#row_select_fields3").hide(); + } $("#row_historical_db_check").hide(); break; diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 9e40223340..0d591f390f 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -70,7 +70,7 @@ global $config; // IMPORTANT NOTE: All reporting pages are used also for metaconsole reporting functionality // So, it's very important to specify full url and paths to resources because metaconsole has a different // entry point: enterprise/meta/index.php than normal console !!! -// Login check +// Login check. check_login(); enterprise_hook('open_meta_frame'); @@ -89,7 +89,7 @@ if (!$report_r && !$report_w && !$report_m) { require_once $config['homedir'].'/include/functions_reports.php'; -// Load enterprise extensions +// Load enterprise extensions. enterprise_include('operation/reporting/custom_reporting.php'); enterprise_include_once('include/functions_metaconsole.php'); @@ -98,7 +98,7 @@ if (enterprise_include_once('include/functions_reporting.php') !== ENTERPRISE_NO $enterpriseEnable = true; } -// Constant with fonts directory +// Constant with fonts directory. define('_MPDF_TTFONTPATH', 'include/fonts/'); $activeTab = get_parameter('tab', 'main'); @@ -117,10 +117,10 @@ if ($schedule_report != '') { $date = date(DATE_FORMAT); $time = date(TIME_FORMAT); $parameters[0] = get_parameter('id_schedule_report'); - // $parameters[1] = db_get_value('schedule_email', 'treport', 'id_report', $id_report); $parameters[1] = get_parameter('schedule_email_address'); $parameters[2] = get_parameter('schedule_subject', ''); $parameters[3] = get_parameter('schedule_email', ''); + $parameters[4] = get_parameter('report_type', ''); $parameters['first_execution'] = strtotime($date.' '.$time); $values = [ @@ -141,7 +141,7 @@ if ($schedule_report != '') { echo '
'; } -// Other Checks for the edit the reports +// Other Checks for the edit the reports. if ($idReport != 0) { $report = db_get_row_filter('treport', ['id_report' => $idReport]); $type_access_selected = reports_get_type_access($report); @@ -162,6 +162,10 @@ if ($idReport != 0) { $edit = true; } break; + + default: + // Default. + break; } if (! $edit) { @@ -227,6 +231,10 @@ switch ($action) { ORDER BY "order"' ); break; + + default: + // Default. + break; } if ($items === false) { @@ -234,7 +242,7 @@ switch ($action) { } - // Clean the repeated order values + // Clean the repeated order values. $order_temp = 1; foreach ($items as $item) { switch ($config['dbtype']) { @@ -254,6 +262,10 @@ switch ($action) { ['id_rc' => $item['id_rc']] ); break; + + default: + // Default. + break; } $order_temp++; @@ -281,6 +293,10 @@ switch ($action) { ORDER BY "order"' ); break; + + default: + // Default. + break; } if ($items === false) { @@ -293,7 +309,7 @@ switch ($action) { $temp = []; foreach ($items as $item) { - // Remove the contents from the block to sort + // Remove the contents from the block to sort. if (array_search($item['id_rc'], $ids) === false) { $temp[$item['order']] = $item['id_rc']; } @@ -344,6 +360,10 @@ switch ($action) { ['id_rc' => $id] ); break; + + default: + // Default. + break; } } @@ -415,6 +435,10 @@ switch ($action) { } } break; + + default: + // Default. + break; } } break; @@ -444,9 +468,9 @@ switch ($action) { break; } - // Page header for metaconsole - if ($enterpriseEnable and defined('METACONSOLE')) { - // Bread crumbs + // Page header for metaconsole. + if ($enterpriseEnable && defined('METACONSOLE')) { + // Bread crumbs. ui_meta_add_breadcrumb( [ 'link' => 'index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&pure='.$pure, @@ -456,10 +480,11 @@ switch ($action) { ui_meta_print_page_header($nav_bar); - // Print header + // Print header. ui_meta_print_header(__('Reporting'), '', $buttons); } - // Page header for normal console + + // Page header for normal console. else { ui_print_page_header(__('Custom reporting'), 'images/op_reporting.png', false, '', false, $buttons, false, '', 60); } @@ -471,7 +496,7 @@ switch ($action) { case 'group_view': if ($config['id_user'] == $report['id_user'] || is_user_admin($config['id_user'])) { $delete = true; - // owner can delete + // Owner can delete. } else { $delete = check_acl( $config['id_user'], @@ -484,7 +509,7 @@ switch ($action) { case 'group_edit': if ($config['id_user'] == $report['id_user'] || is_user_admin($config['id_user'])) { $delete = true; - // owner can delete + // Owner can delete. } else { $delete = check_acl( $config['id_user'], @@ -501,6 +526,10 @@ switch ($action) { $delete = true; } break; + + default: + // Default. + break; } if (! $delete) { @@ -571,7 +600,7 @@ switch ($action) { ui_require_jquery_file('bgiframe'); ui_require_jquery_file('autocomplete'); - // Show only selected groups + // Show only selected groups. if ($id_group > 0) { $group = ["$id_group" => $id_group]; } else { @@ -595,7 +624,7 @@ switch ($action) { } // Fix : group filter was not working - // Show only selected groups + // Show only selected groups. if ($id_group > 0) { $group = ["$id_group" => $id_group]; $filter['id_group'] = $id_group; @@ -603,8 +632,8 @@ switch ($action) { $group = false; } - // Filter normal and metaconsole reports - if ($config['metaconsole'] == 1 and defined('METACONSOLE')) { + // Filter normal and metaconsole reports. + if ($config['metaconsole'] == 1 && defined('METACONSOLE')) { $filter['metaconsole'] = 1; } else { $filter['metaconsole'] = 0; @@ -670,12 +699,12 @@ switch ($action) { $table->size['csv'] = '5%'; $next = 4; - // Calculate dinamically the number of the column + // Calculate dinamically the number of the column. if (enterprise_hook('load_custom_reporting_1') !== ENTERPRISE_NOT_HOOK) { $next = 7; } - // Admin options only for RM flag + // Admin options only for RM flag. if (check_acl($config['id_user'], 0, 'RM')) { $table->head[$next] = __('Private'); $table->size[$next] = '2%'; @@ -743,7 +772,7 @@ switch ($action) { $data[1] = ui_print_truncate_text($report['description'], 70); - // Remove html and xml button if items are larger than limit + // Remove html and xml button if items are larger than limit. $item_count = db_get_num_rows('SELECT * FROM treport_content WHERE id_report='.$report['id_report']); $report['overload'] = $item_count >= $config['report_limit']; if ($report['overload']) { @@ -752,7 +781,7 @@ switch ($action) { } else if (!$report['non_interactive']) { $data[2] = ''.html_print_image('images/html.png', true, ['title' => __('HTML view')]).''; $data[3] = ''.html_print_image('images/xml.png', true, ['title' => __('Export to XML')]).''; - // I chose ajax.php because it's supposed to give XML anyway + // I chose ajax.php because it's supposed to give XML anyway. } else { $data[2] = html_print_image( 'images/html_disabled.png', @@ -765,14 +794,14 @@ switch ($action) { } - // Calculate dinamically the number of the column + // Calculate dinamically the number of the column. $next = 4; if (enterprise_hook('load_custom_reporting_2') !== ENTERPRISE_NOT_HOOK) { $next = 7; } - // Admin options only for RM flag + // Admin options only for RM flag. if (check_acl($config['id_user'], 0, 'RM')) { if ($report['private'] == 1) { $data[$next] = __('Yes'); @@ -820,6 +849,10 @@ switch ($action) { $delete = true; } break; + + default: + // Default. + break; } if ($edit || $delete) { @@ -915,7 +948,6 @@ switch ($action) { } enterprise_hook('close_meta_frame'); - return; break; @@ -943,6 +975,10 @@ switch ($action) { $idGroupReport = $report['id_group']; $description = $report['description']; break; + + default: + // Default. + break; } break; @@ -976,6 +1012,10 @@ switch ($action) { $id_group_edit = 0; $private = 1; break; + + default: + // Default. + break; } if ($action == 'update') { @@ -1026,10 +1066,10 @@ switch ($action) { $action = 'edit'; } else if ($action == 'save') { if ($reportName != '' && $idGroupReport != '') { - // This flag allow to differentiate between normal console and metaconsole reports + // This flag allow to differentiate between normal console and metaconsole reports. $metaconsole_report = (int) is_metaconsole(); - // Juanma (07/05/2014) New feature: Custom front page for reports + // Juanma (07/05/2014) New feature: Custom front page for reports. if ($config['custom_report_front']) { $custom_font = $config['custom_report_front_font']; $logo = $config['custom_report_front_logo']; @@ -1098,7 +1138,6 @@ switch ($action) { $good_format = false; switch ($action) { case 'update': - $values = []; $values['id_report'] = $idReport; // --------------------------------------------------- @@ -1132,7 +1171,6 @@ switch ($action) { break; case 'event_report_log': - $agents_to_report = get_parameter('id_agents3'); $source = get_parameter('source', ''); $search = get_parameter('search', ''); @@ -1154,7 +1192,7 @@ switch ($action) { $values['top_n_value'] = get_parameter('quantity'); $interval_max = get_parameter('max_interval'); $interval_min = get_parameter('min_interval'); - // Checks intervals fields + // Checks intervals fields. if (preg_match('/^(\-)*[0-9]*\.?[0-9]+$/', $interval_max) and preg_match('/^(\-)*[0-9]*\.?[0-9]+$/', $interval_min)) { $good_format = true; } @@ -1221,9 +1259,21 @@ switch ($action) { case 'availability': // HACK it is saved in show_graph field. - // Show interfaces instead the modules + // Show interfaces instead the modules. $values['show_graph'] = get_parameter('checkbox_show_address_agent'); $values['period'] = get_parameter('period'); + $values['total_time'] = get_parameter('total_time'); + $values['time_failed'] = get_parameter('time_failed'); + $values['time_in_ok_status'] = get_parameter('time_in_ok_status'); + $values['time_in_unknown_status'] = get_parameter('time_in_unknown_status'); + $values['time_of_not_initialized_module'] = get_parameter('time_of_not_initialized_module'); + $values['time_of_downtime'] = get_parameter('time_of_downtime'); + $values['total_checks'] = get_parameter('total_checks'); + $values['checks_failed'] = get_parameter('checks_failed'); + $values['checks_in_ok_status'] = get_parameter('checks_in_ok_status'); + $values['unknown_checks'] = get_parameter('unknown_checks'); + $values['agent_max_value'] = get_parameter('agent_max_value'); + $values['agent_min_value'] = get_parameter('agent_min_value'); $good_format = true; break; @@ -1258,6 +1308,7 @@ switch ($action) { $values['text'] = get_parameter('text'); $values['show_graph'] = get_parameter('combo_graph_options'); $good_format = true; + break; } $values['id_agent'] = get_parameter('id_agent'); @@ -1282,6 +1333,19 @@ switch ($action) { $values['friday'] = get_parameter('friday', 0); $values['saturday'] = get_parameter('saturday', 0); $values['sunday'] = get_parameter('sunday', 0); + $values['total_time'] = get_parameter('total_time', 0); + $values['time_failed'] = get_parameter('time_failed', 0); + $values['time_in_ok_status'] = get_parameter('time_in_ok_status', 0); + $values['time_in_unknown_status'] = get_parameter('time_in_unknown_status', 0); + $values['time_of_not_initialized_module'] = get_parameter('time_of_not_initialized_module', 0); + $values['time_of_downtime'] = get_parameter('time_of_downtime', 0); + $values['total_checks'] = get_parameter('total_checks', 0); + $values['checks_failed'] = get_parameter('checks_failed', 0); + $values['checks_in_ok_status'] = get_parameter('checks_in_ok_status', 0); + $values['unknown_checks'] = get_parameter('unknown_checks', 0); + $values['agent_max_value'] = get_parameter('agent_max_value', 0); + $values['agent_min_value'] = get_parameter('agent_min_value', 0); + switch ($config['dbtype']) { case 'mysql': case 'postgresql': @@ -1293,6 +1357,10 @@ switch ($action) { $values['time_from'] = '#to_date(\''.get_parameter('time_from').'\',\'hh24:mi:ss\')'; $values['time_to'] = '#to_date(\''.get_parameter('time_to').'\', \'hh24:mi:ss\')'; break; + + default: + // Default. + break; } $values['group_by_agent'] = get_parameter('checkbox_row_group_by_agent'); @@ -1302,7 +1370,6 @@ switch ($action) { $values['exception_condition_value'] = get_parameter('exception_condition_value'); $values['id_module_group'] = get_parameter('combo_modulegroup'); $values['id_group'] = get_parameter('combo_group'); - $values['show_extended_events'] = get_parameter('include_extended_events'); $values['server_name'] = get_parameter('server_name'); $server_id = (int) get_parameter('server_id'); if ($server_id != 0) { @@ -1314,7 +1381,7 @@ switch ($action) { $values['server_name'] = get_parameter('combo_server'); } - if ((($values['type'] == 'custom_graph') or ($values['type'] == 'automatic_custom_graph')) && ($values['id_gs'] == 0 || $values['id_gs'] == '')) { + if ((($values['type'] == 'custom_graph') || ($values['type'] == 'automatic_custom_graph')) && ($values['id_gs'] == 0 || $values['id_gs'] == '')) { $resultOperationDB = false; break; } @@ -1331,7 +1398,7 @@ switch ($action) { $event_filter_search = get_parameter('filter_search', ''); - // If metaconsole is activated + // If metaconsole is activated. if ($config['metaconsole'] == 1 && defined('METACONSOLE')) { if (($values['type'] == 'custom_graph') or ($values['type'] == 'automatic_custom_graph')) { $id_gs = substr($values['id_gs'], 0, strpos($values['id_gs'], '|')); @@ -1342,7 +1409,7 @@ switch ($action) { } } - // Get agent and server name + // Get agent and server name. $agent_name_server = io_safe_output(get_parameter('agent')); if (isset($agent_name_server)) { @@ -1352,7 +1419,7 @@ switch ($action) { $server_name = substr($agent_name_server, $separator_pos); $server_name = str_replace('(', '', $server_name); $server_name = str_replace(')', '', $server_name); - // Will update server_name variable + // Will update server_name variable. $values['server_name'] = trim($server_name); $agent_name = substr($agent_name_server, 0, $separator_pos); } @@ -1448,6 +1515,10 @@ switch ($action) { $style['label'] = ''; } break; + + default: + // Default. + break; } $values['style'] = io_safe_input(json_encode($style)); @@ -1462,6 +1533,10 @@ switch ($action) { unset($values['type']); } break; + + default: + // Default. + break; } $resultOperationDB = db_process_sql_update( @@ -1483,7 +1558,7 @@ switch ($action) { $values['description'] = get_parameter('description'); $label = get_parameter('label', ''); - // Add macros name + // Add macros name. $items_label = []; $items_label['type'] = get_parameter('type'); $items_label['id_agent'] = get_parameter('id_agent'); @@ -1493,7 +1568,7 @@ switch ($action) { $values['name'] = reporting_label_macro($items_label, $name_it); // Support for projection graph, prediction date and SLA reports - // 'top_n_value', 'top_n' and 'text' fields will be reused for these types of report + // 'top_n_value', 'top_n' and 'text' fields will be reused for these types of report. switch ($values['type']) { case 'projection_graph': $values['period'] = get_parameter('period1'); @@ -1595,7 +1670,7 @@ switch ($action) { case 'availability': $values['period'] = get_parameter('period'); // HACK it is saved in show_graph field. - // Show interfaces instead the modules + // Show interfaces instead the modules. $values['show_graph'] = get_parameter('checkbox_show_address_agent'); $good_format = true; break; @@ -1670,6 +1745,10 @@ switch ($action) { $values['only_display_wrong'] = $only_display_wrong_tmp; } break; + + default: + // Default. + break; } $values['monday'] = get_parameter('monday', 0); @@ -1679,6 +1758,18 @@ switch ($action) { $values['friday'] = get_parameter('friday', 0); $values['saturday'] = get_parameter('saturday', 0); $values['sunday'] = get_parameter('sunday', 0); + $values['total_time'] = get_parameter('total_time', 0); + $values['time_failed'] = get_parameter('time_failed', 0); + $values['time_in_ok_status'] = get_parameter('time_in_ok_status', 0); + $values['time_in_unknown_status'] = get_parameter('time_in_unknown_status', 0); + $values['time_of_not_initialized_module'] = get_parameter('time_of_not_initialized_module', 0); + $values['time_of_downtime'] = get_parameter('time_of_downtime', 0); + $values['total_checks'] = get_parameter('total_checks', 0); + $values['checks_failed'] = get_parameter('checks_failed', 0); + $values['checks_in_ok_status'] = get_parameter('checks_in_ok_status', 0); + $values['unknown_checks'] = get_parameter('unknown_checks', 0); + $values['agent_max_value'] = get_parameter('agent_max_value', 0); + $values['agent_min_value'] = get_parameter('agent_min_value', 0); switch ($config['dbtype']) { case 'mysql': case 'postgresql': @@ -1690,6 +1781,10 @@ switch ($action) { $values['time_from'] = '#to_date(\''.get_parameter('time_from').'\',\'hh24:mi:ss\')'; $values['time_to'] = '#to_date(\''.get_parameter('time_to').'\', \'hh24:mi:ss\')'; break; + + default: + // Default. + break; } $values['group_by_agent'] = get_parameter('checkbox_row_group_by_agent', 0); @@ -1699,7 +1794,6 @@ switch ($action) { $values['exception_condition_value'] = get_parameter('exception_condition_value'); $values['id_module_group'] = get_parameter('combo_modulegroup'); $values['id_group'] = get_parameter('combo_group'); - $values['show_extended_events'] = get_parameter('include_extended_events'); if ((($values['type'] == 'custom_graph') or ($values['type'] == 'automatic_custom_graph')) && ($values['id_gs'] == 0 || $values['id_gs'] == '')) { @@ -1718,8 +1812,8 @@ switch ($action) { } } - if (($values['type'] == 'sql') or ($values['type'] == 'sql_graph_hbar') - or ($values['type'] == 'sql_graph_vbar') or ($values['type'] == 'sql_graph_pie') + if (($values['type'] == 'sql') || ($values['type'] == 'sql_graph_hbar') + || ($values['type'] == 'sql_graph_vbar') || ($values['type'] == 'sql_graph_pie') ) { $values['treport_custom_sql_id'] = get_parameter('id_custom'); if ($values['treport_custom_sql_id'] == 0) { @@ -1761,7 +1855,7 @@ switch ($action) { $event_filter_search = get_parameter('filter_search', ''); - // Added for events items + // Added for events items. $style['show_summary_group'] = $show_summary_group; $style['filter_event_severity'] = json_encode($filter_event_severity); $style['filter_event_type'] = json_encode($filter_event_type); @@ -1783,6 +1877,10 @@ switch ($action) { $style['label'] = ''; } break; + + default: + // Default. + break; } break; @@ -1827,6 +1925,10 @@ switch ($action) { $style['label'] = ''; } break; + + default: + // Default. + break; } $values['style'] = io_safe_input(json_encode($style)); @@ -1841,6 +1943,10 @@ switch ($action) { unset($values['type']); } break; + + default: + // Default. + break; } $result = db_process_sql_insert( @@ -1870,6 +1976,10 @@ switch ($action) { WHERE id_report = '.$idReport ); break; + + default: + // Default. + break; } if ($max === false) { @@ -1895,6 +2005,10 @@ switch ($action) { ['id_rc' => $idItem] ); break; + + default: + // Default. + break; } $resultOperationDB = true; @@ -1902,7 +2016,8 @@ switch ($action) { break; } - // If fields dont have good format + + // If fields dont have good format. else { $resultOperationDB = false; } @@ -1910,7 +2025,7 @@ switch ($action) { break; default: - if ($enterpriseEnable and $activeTab != 'advanced') { + if ($enterpriseEnable && $activeTab != 'advanced') { $resultOperationDB = reporting_enterprise_update_action(); } break; @@ -1968,7 +2083,7 @@ switch ($action) { case 'agent': case 'type': - // Sort functionality for normal console + // Sort functionality for normal console. if (!defined('METACONSOLE')) { switch ($field) { case 'module': @@ -2002,6 +2117,10 @@ switch ($action) { case 'type': $sql = 'SELECT id_rc FROM treport_content WHERE %s ORDER BY type %s'; break; + + default: + // Default. + break; } $sql = sprintf($sql, 'id_report = '.$idReport, '%s'); @@ -2013,11 +2132,15 @@ switch ($action) { case 'down': $sql = sprintf($sql, 'DESC'); break; + + default: + // Default. + break; } $ids = db_get_all_rows_sql($sql); } - // Sort functionality for metaconsole + // Sort functionality for metaconsole. else if ($config['metaconsole'] == 1) { switch ($field) { case 'agent': @@ -2035,14 +2158,14 @@ switch ($action) { foreach ($report_items as $report_item) { $connection = metaconsole_get_connection($report_item['server_name']); if (metaconsole_load_external_db($connection) != NOERR) { - // ui_print_error_message ("Error connecting to ".$server_name); + // ui_print_error_message ("Error connecting to ".$server_name);. } switch ($field) { case 'agent': $agents_name = agents_get_agents(['id_agente' => $report_item['id_agent']], 'nombre'); - // Item without agent + // Item without agent. if (!$agents_name) { $element_name = ''; } else { @@ -2054,13 +2177,17 @@ switch ($action) { case 'module': $module_name = modules_get_agentmodule_name($report_item['id_agent_module']); - // Item without module + // Item without module. if (!$module_name) { $element_name = ''; } else { $element_name = $module_name; } break; + + default: + // Default. + break; } metaconsole_restore_db(); @@ -2068,7 +2195,7 @@ switch ($action) { $temp_sort[$report_item['id_rc']] = $element_name; } - // Performes sorting + // Performes sorting. switch ($dir) { case 'up': asort($temp_sort); @@ -2077,6 +2204,10 @@ switch ($action) { case 'down': arsort($temp_sort); break; + + default: + // Default. + break; } foreach ($temp_sort as $temp_element_key => $temp_element_val) { @@ -2085,13 +2216,13 @@ switch ($action) { $i++; } - // Free resources + // Free resources. unset($temp_sort); unset($report_items); } break; - // Type case only depends of local database + // Type case only depends of local database. case 'type': $sql = 'SELECT id_rc FROM treport_content @@ -2110,10 +2241,13 @@ switch ($action) { case 'down': $sql = sprintf($sql, 'DESC'); break; + + default: + // Default. + break; } $ids = db_get_all_rows_sql($sql); - break; } } @@ -2152,6 +2286,10 @@ switch ($action) { WHERE id_rc = '.$idItem ); break; + + default: + // Default. + break; } // db_get_value_filter('order', 'treport_content', array('id_rc' => $idItem)); @@ -2163,6 +2301,10 @@ switch ($action) { case 'down': $newOrder = ($oldOrder + 1); break; + + default: + // Default. + break; } switch ($config['dbtype']) { @@ -2200,6 +2342,10 @@ switch ($action) { false ); break; + + default: + // Default. + break; } if ($resultOperationDB !== false) { @@ -2229,13 +2375,17 @@ switch ($action) { false ); break; + + default: + // Default. + break; } } break; } break; - // Added for report templates + // Added for report templates. default: if ($enterpriseEnable) { $buttons = [ @@ -2259,7 +2409,7 @@ switch ($action) { break; } - // Page header for metaconsole + // Page header for metaconsole. if ($enterpriseEnable and defined('METACONSOLE')) { // Bread crumbs ui_meta_add_breadcrumb( @@ -2271,10 +2421,10 @@ switch ($action) { ui_meta_print_page_header($nav_bar); - // Print header + // Print header. ui_meta_print_header(__('Reporting'), '', $buttons); } - // Page header for normal console + // Page header for normal console. else { ui_print_page_header($subsection, 'images/op_reporting.png', false, '', false, $buttons, false, '', 60); } @@ -2337,9 +2487,9 @@ if ($idReport != 0) { $textReportName = __('Create Custom Report'); } -// Page header for metaconsole +// Page header for metaconsole. if ($enterpriseEnable and defined('METACONSOLE')) { - // Bread crumbs + // Bread crumbs. ui_meta_add_breadcrumb( [ 'link' => 'index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&pure='.$pure, @@ -2349,7 +2499,7 @@ if ($enterpriseEnable and defined('METACONSOLE')) { ui_meta_print_page_header($nav_bar); - // Print header + // Print header. ui_meta_print_header(__('Reporting').$textReportName, '', $buttons); } else { ui_print_page_header( diff --git a/pandora_console/include/ajax/snmp_browser.ajax.php b/pandora_console/include/ajax/snmp_browser.ajax.php index 11d233c676..85f8b3e68a 100644 --- a/pandora_console/include/ajax/snmp_browser.ajax.php +++ b/pandora_console/include/ajax/snmp_browser.ajax.php @@ -121,6 +121,7 @@ if (is_ajax()) { 'min_ff_event_normal' => 0, 'min_ff_event_warning' => 0, 'min_ff_event_critical' => 0, + 'ff_type' => 0, 'each_ff' => 0, ] ); diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index a1b9b6e302..8c2bb2d844 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -20,7 +20,7 @@ /** * Pandora build version and version */ -$build_version = 'PC190328'; +$build_version = 'PC190412'; $pandora_version = 'v7.0NG.733'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index a2775f5bfb..67ad7b949c 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -434,15 +434,15 @@ function agents_get_agents( $filter_nogroup = $filter; // Get user groups - $groups = array_keys(users_get_groups($config['id_user'], $access, true)); + $groups = array_keys(users_get_groups($config['id_user'], $access, false)); // If no group specified, get all user groups - if (isset($filter['id_grupo']) === false) { + if (empty($filter['id_grupo'])) { $all_groups = true; $filter['id_grupo'] = $groups; } else if (! is_array($filter['id_grupo'])) { $all_groups = false; - // If group is specified but not allowed, return false. + // If group is specified but not allowed, return false if (! in_array($filter['id_grupo'], $groups)) { return false; } @@ -466,6 +466,11 @@ function agents_get_agents( $filter['id_group'] = $filter['id_grupo']; + if (in_array(0, $filter['id_grupo'])) { + unset($filter['id_grupo']); + unset($filter['id_group']); + } + if (!is_array($fields)) { $fields = []; $fields[0] = 'id_agente'; diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index e57dd31013..7903533d74 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -1,19 +1,36 @@ ;;; - * ;;;;;;;; - * ;;;;;;; - * ;;;;;; - * ;;;; in this order - * and separator char (after text ; ) and separator (pass in param othermode as othermode=url_encode_separator_) - * 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_| - * - * @param $thrash3 Don't use + * @param string $id Name of agent to add the module. + * @param string $thrash1 Don't use. + * @param array $other It's array, $other as param is ;;; + * ;;;;;;;; + * ;;;;;;; + * ;;;;;; + * ;;;; in this order + * and separator char (after text ; ) and separator (pass in param othermode as othermode=url_encode_separator_). + * @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_|* + * @return mixed Return. */ 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], 'critical_inverse' => $other['data'][28], 'warning_inverse' => $other['data'][29], + 'ff_type' => $other['data'][30], ]; if (! $values['descripcion']) { $values['descripcion'] = ''; - // Column 'descripcion' cannot be null + // Column 'descripcion' cannot be null. } if (! $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); 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.')); } else { returnData('string', ['type' => 'string', 'data' => $idModule]); @@ -3222,6 +3239,7 @@ function api_set_update_network_module($id_module, $thrash1, $other, $thrash3) 'critical_inverse', 'warning_inverse', 'policy_linked', + 'ff_type', ]; $values = []; @@ -3326,22 +3344,23 @@ function api_set_create_plugin_module($id, $thrash1, $other, $thrash3) 'min_ff_event_critical' => $other['data'][32], 'critical_inverse' => $other['data'][33], 'warning_inverse' => $other['data'][34], + 'ff_type' => $other['data'][35], ]; if (! $values['descripcion']) { $values['descripcion'] = ''; - // Column 'descripcion' cannot be null + // Column 'descripcion' cannot be null. } if (! $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); 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.')); } else { returnData('string', ['type' => 'string', 'data' => $idModule]); @@ -3387,7 +3406,7 @@ function api_set_update_plugin_module($id_module, $thrash1, $other, $thrash3) 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 (!util_api_check_agent_and_print_error($other['data'][0], 'string', 'AW')) { 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]); if (!$check_id_agent) { 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', 'warning_inverse', 'policy_linked', + 'ff_type', ]; $values = []; @@ -3546,22 +3566,23 @@ function api_set_create_data_module($id, $thrash1, $other, $thrash3) 'ff_timeout' => $other['data'][23], 'critical_inverse' => $other['data'][24], 'warning_inverse' => $other['data'][25], + 'ff_type' => $other['data'][26], ]; if (! $values['descripcion']) { $values['descripcion'] = ''; - // Column 'descripcion' cannot be null + // Column 'descripcion' cannot be null. } if (! $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); 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.')); } else { returnData('string', ['type' => 'string', 'data' => $idModule]); @@ -3818,7 +3839,7 @@ function api_set_update_data_module($id_module, $thrash1, $other, $thrash3) 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 (!util_api_check_agent_and_print_error($other['data'][0], 'string', 'AW')) { 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]); if (!$check_id_agent) { 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', 'warning_inverse', 'policy_linked', + 'ff_type', ]; $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 = json_encode($disabled_types_event); - // SNMP version 3 + // SNMP version 3. if ($other['data'][14] == '3') { 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\'. ')); @@ -4000,6 +4022,7 @@ function api_set_create_snmp_module($id, $thrash1, $other, $thrash3) 'min_ff_event_normal' => $other['data'][31], 'min_ff_event_warning' => $other['data'][32], 'min_ff_event_critical' => $other['data'][33], + 'ff_type' => $other['data'][34], ]; } else { $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_warning' => $other['data'][26], 'min_ff_event_critical' => $other['data'][27], + 'ff_type' => $other['data'][28], ]; } if (! $values['descripcion']) { $values['descripcion'] = ''; - // Column 'descripcion' cannot be null + // Column 'descripcion' cannot be null. } $idModule = modules_create_agent_module($idAgent, $name, $values, true); 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.')); } else { returnData('string', ['type' => 'string', 'data' => $idModule]); @@ -4091,7 +4115,7 @@ function api_set_update_snmp_module($id_module, $thrash1, $other, $thrash3) 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 (!util_api_check_agent_and_print_error($other['data'][0], 'string', 'AW')) { 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]); if (!$check_id_agent) { 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'][22] != 'AES' and $other['data'][22] != 'DES') { returnError( @@ -4180,6 +4204,7 @@ function api_set_update_snmp_module($id_module, $thrash1, $other, $thrash3) 'min_ff_event_warning', 'min_ff_event_critical', 'policy_linked', + 'ff_type', ]; } else { $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_critical', '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_warning' => $other['data'][21], 'min_ff_event_critical' => $other['data'][22], + 'ff_type' => $other['data'][23], ]; $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_warning' => $other['data'][25], 'min_ff_event_critical' => $other['data'][26], + 'ff_type' => $other['data'][27], ]; $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_warning' => $other['data'][30], 'min_ff_event_critical' => $other['data'][31], + 'ff_type' => $other['data'][32], ]; } else { $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_warning' => $other['data'][26], '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_critical' => $other['data'][9], 'ff_timeout' => $other['data'][10], + 'ff_type' => $other['data'][11], ]; $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_critical'] = $other['data'][22]; $values['ff_timeout'] = $other['data'][23]; + $values['ff_type'] = $other['data'][24]; if ($name_module_policy !== false) { 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_warning'] = $other['data'][25]; $values['min_ff_event_critical'] = $other['data'][26]; + $values['ff_type'] = $other['data'][27]; if ($name_module_policy !== false) { 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_warning'] = $other['data'][30]; $values['min_ff_event_critical'] = $other['data'][31]; + $values['ff_type'] = $other['data'][32]; if ($name_module_policy !== false) { 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_warning' => $other['data'][31], 'min_ff_event_critical' => $other['data'][32], + 'ff_type' => $other['data'][33], ]; } else { $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_warning' => $other['data'][25], 'min_ff_event_critical' => $other['data'][26], + 'ff_type' => $other['data'][27], ]; } @@ -8794,7 +8830,14 @@ function api_set_alert_actions($id, $id2, $other, $trash1) } $firesMin = $other['data'][2]; + if (!$firesMin) { + $firesMin = 0; + } + $firesMax = $other['data'][3]; + if (!$firesMax) { + $firesMax = 0; + } $values = [ 'id_alert_template_module' => $idAlertTemplateModule, @@ -11608,7 +11651,9 @@ function api_set_add_event_comment($id, $thrash2, $other, $thrash3) global $config; if (defined('METACONSOLE')) { - return; + $meta = true; + } else { + $meta = $other['data'][1]; } if (!check_acl($config['id_user'], 0, 'EW')) { @@ -11620,8 +11665,7 @@ function api_set_add_event_comment($id, $thrash2, $other, $thrash3) returnError('error_parameter', 'Error in the parameters.'); return; } else if ($other['type'] == 'array') { - $comment = io_safe_input($other['data'][0]); - $meta = $other['data'][1]; + $comment = $other['data'][0]; $history = $other['data'][2]; $status = events_comment( @@ -13268,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_warning' => $row2['min_ff_event_warning'], 'min_ff_event_critical' => $row2['min_ff_event_critical'], + 'ff_type' => $row2['ff_type'], ]; $name = $row2['name']; diff --git a/pandora_console/include/functions_cron.php b/pandora_console/include/functions_cron.php index e56a3d4a52..6a79096175 100644 --- a/pandora_console/include/functions_cron.php +++ b/pandora_console/include/functions_cron.php @@ -1,34 +1,51 @@ $module_id] - ); + $module_interval = db_get_value( + 'module_interval', + 'tagente_modulo', + 'id_agente_modulo', + $module_id + ); + + if ($cron === '* * * * *') { return db_process_sql( '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) { // Get day of the week and month from cron config. $cron_array = explode(' ', $cron); - $minute = $cron_array[0]; - $hour = $cron_array[1]; - $mday = $cron_array[2]; - $month = $cron_array[3]; $wday = $cron_array[4]; // Get last execution time. @@ -60,55 +81,35 @@ function cron_next_execution($cron, $module_interval, $module_id) $module_id ); $cur_time = ($last_execution !== false) ? $last_execution : time(); - - // Any day of the way. - if ($wday == '*') { - $nex_time = cron_next_execution_date( - $cron, - $cur_time, - $module_interval - ); - return ($nex_time - $cur_time); + $nex_time = cron_next_execution_date($cron, $cur_time, $module_interval); + $nex_wday = (int) date('w', $nex_time); + // Check the wday values to avoid infinite loop. + $wday_int = cron_get_interval($wday); + if ($wday_int['down'] !== '*' && ($wday_int['down'] > 6 || ($wday_int['up'] !== false && $wday_int['up'] > 6))) { + $wday = '*'; } - // A specific day of the week. - $count = 0; - $nex_time = $cur_time; - do { - $nex_time = cron_next_execution_date( - $cron, - $nex_time, - $module_interval - ); - $nex_time_wd = $nex_time; + // Check day of the way. + while (!cron_check_interval($nex_wday, $wday)) { + // If it does not acomplish the day of the week, go to the next day. + $nex_time += SECONDS_1DAY; + $nex_time = cron_next_execution_date($cron, $nex_time, 0); + $nex_wday = (int) date('w', $nex_time); + } - $array_nex = explode(' ', date('m w', $nex_time_wd)); - $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; + return ($nex_time - $cur_time); } -// 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) { // Get cron configuration. @@ -127,8 +128,7 @@ function cron_next_execution_date($cron, $cur_time=false, $module_interval=300) } // Update minutes. - $min_s = cron_get_interval($cron_array[0]); - $nex_time_array[0] = ($min_s['down'] == '*') ? 0 : $min_s['down']; + $nex_time_array[0] = cron_get_next_time_element($cron_array[0]); $nex_time = cron_valid_date($nex_time_array); 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. - $hour_s = cron_get_interval($cron_array[1]); - $nex_time_array[1] = ($hour_s['down'] == '*') ? 0 : $hour_s['down']; + $nex_time_array[1] = cron_get_next_time_element($cron_array[1]); // When an overflow is passed check the hour update again. $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. - $mday_s = cron_get_interval($cron_array[2]); - $nex_time_array[2] = ($mday_s['down'] == '*') ? 1 : $mday_s['down']; + $nex_time_array[2] = cron_get_next_time_element($cron_array[2]); // When an overflow is passed check the hour update in the next execution. $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. - $mon_s = cron_get_interval($cron_array[3]); - $nex_time_array[3] = ($mon_s['down'] == '*') ? 1 : $mon_s['down']; + $nex_time_array[3] = cron_get_next_time_element($cron_array[3]); // When an overflow is passed check the hour update in the next execution. $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) { // 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) { $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. - if ($elem_cron != '*') { - $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) { - 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; - } - } - } + if (cron_check_interval($elem_curr_time, $elem_cron) === false) { + return false; } 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) { $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) { 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() { global $config; @@ -429,8 +501,10 @@ function cron_list_table() } $email = $args[1]; + $report_type = $args[4]; $data[2] .= '
- '.__('Report').": "; $data[2] .= $report['name'].''; + $data[2] .= '
- '.__('Report type').': '.$report_type; $data[2] .= '
- '.__('Email').": "; $data[2] .= ui_print_truncate_text($email, 60, false).''; break; diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index dc69af7baf..0182c2141b 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -3167,8 +3167,7 @@ function events_page_general($event) $table_general->data[] = $data; - $event['owner_user'] = $event['id_usuario']; - + // $event['owner_user'] = $event['id_usuario']; $data = []; $data[0] = __('Owner'); if (empty($event['owner_user'])) { diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 4a24d5a964..30b86478f8 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -2744,28 +2744,7 @@ function html_print_autocomplete_modules( global $config; if ($id_agents === false) { - $groups = []; - 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' - ); - } + $agents = agents_get_agents(); if ($agents === false) { $agents = []; @@ -2777,10 +2756,7 @@ function html_print_autocomplete_modules( } } else { if ($ACL) { - $groups = users_get_groups($config['id_user'], 'AW', false); - $groups = array_keys($groups); - - $agents = db_get_all_rows_sql('SELECT id_agente FROM tagente WHERE id_grupo IN ('.implode(',', $groups).')'); + $agents = agents_get_agents(); if ($agents === false) { $agents = []; diff --git a/pandora_console/include/functions_menu.php b/pandora_console/include/functions_menu.php index 9b19dec55a..0dbe1049bc 100644 --- a/pandora_console/include/functions_menu.php +++ b/pandora_console/include/functions_menu.php @@ -59,11 +59,11 @@ function menu_print_menu(&$menu) $allsec2 = $sec2; } - // Open list of menu + // Open list of menu. echo ''; // Use $config because a global var is required because normal - // and godmode menu are painted separately + // and godmode menu are painted separately. if (!isset($config['count_main_menu'])) { $config['count_main_menu'] = 0; } @@ -128,7 +128,7 @@ function menu_print_menu(&$menu) if (! $submenu) { $main['sub'] = []; - // Empty array won't go through foreach + // Empty array won't go through foreach. } $submenu_output = ''; @@ -140,12 +140,12 @@ function menu_print_menu(&$menu) foreach ($main['sub'] as $subsec2 => $sub) { $count_sub++; - // Init some variables + // Init some variables. $visible = false; $selected = false; $subsec2 = io_safe_output($subsec2); - // Choose valid suboptions (sec2) + // Choose valid suboptions (sec2). $check_2 = true; if (isset($sub['sub2'])) { $check_2 = false; @@ -155,7 +155,7 @@ function menu_print_menu(&$menu) continue; } - // We store the first subsection to use it if the main section has not access + // We store the first subsection to use it if the main section has not access. if ($count_sub_access == 0) { $first_sub_sec2 = $subsec2; } @@ -175,7 +175,7 @@ function menu_print_menu(&$menu) $sec2 = ' '; } - // Check if some submenu was selected to mark this (the parent) as selected + // Check if some submenu was selected to mark this (the parent) as selected. foreach (array_keys($sub['sub2']) as $key) { if (strpos($key, $sec2) !== false) { $selected_submenu2 = true; @@ -184,13 +184,13 @@ function menu_print_menu(&$menu) } } - // Create godmode option if submenu has godmode on + // Create godmode option if submenu has godmode on. if (isset($sub['subsecs'])) { // Sometimes you need to add all paths because in the // same dir are code from visual console and reports - // for example + // for example. if (is_array($sub['subsecs'])) { - // Compare each string + // Compare each string. foreach ($sub['subsecs'] as $god_path) { if (strpos($sec2, $god_path) !== false) { $selected_submenu2 = true; @@ -198,19 +198,19 @@ function menu_print_menu(&$menu) } } } else { - // If there is only a string just compare + // If there is only a string just compare. if (strpos($sec2, $sub['subsecs']) !== false) { $selected_submenu2 = true; } } } - // Set class + // Set class. if (($sec2 == $subsec2 || $allsec2 == $subsec2 || $selected_submenu2) && isset($sub[$subsec2]['options']) && ( get_parameter_get($sub[$subsec2]['options']['name']) == $sub[$subsec2]['options']['value']) ) { - // If the subclass is selected and there are options and that options value is true + // If the subclass is selected and there are options and that options value is true. $class .= 'submenu_selected selected'; $menu_selected = true; $selected = true; @@ -231,7 +231,7 @@ function menu_print_menu(&$menu) $selected = true; $visible = true; } else { - // Else it's not selected + // Else it's not selected. $class .= 'submenu_not_selected'; } @@ -239,7 +239,7 @@ function menu_print_menu(&$menu) $sub['refr'] = 0; } - // Define submenu class to draw tree image + // Define submenu class to draw tree image. if ($count_sub >= count($main['sub'])) { $sub_tree_class = 'submenu_text submenu_text_last'; } else { @@ -247,7 +247,7 @@ function menu_print_menu(&$menu) } if (isset($sub['type']) && $sub['type'] == 'direct') { - // This is an external link + // This is an external link. $submenu_output .= '
  • '; if (isset($sub['subtype']) && $sub['subtype'] == 'nolink') { @@ -258,7 +258,7 @@ function menu_print_menu(&$menu) $submenu_output .= '
    '.$sub['text'].'
    '; } } else { - // This is an internal link + // This is an internal link. if (isset($sub[$subsec2]['options'])) { $link_add = '&'.$sub[$subsec2]['options']['name'].'='.$sub[$subsec2]['options']['value']; } else { @@ -267,7 +267,7 @@ function menu_print_menu(&$menu) $submenu_output .= '
  • '; - // Ini Add icon extension + // Ini Add icon extension. $secExtension = null; if (array_key_exists('extension', $sub)) { $secExtensionBool = $sub['extension']; @@ -275,7 +275,7 @@ function menu_print_menu(&$menu) $secExtensionBool = false; } - // DISABLE SUBMENU IMAGES + // DISABLE SUBMENU IMAGES. $secExtensionBool = false; if ($secExtensionBool) { @@ -328,7 +328,7 @@ function menu_print_menu(&$menu) } } - // Print second level submenu + // Print second level submenu. if (isset($sub['sub2'])) { $submenu2_list = ''; @@ -354,7 +354,7 @@ function menu_print_menu(&$menu) $class .= ' selected'; } - // Define submenu2 class to draw tree image + // Define submenu2 class to draw tree image. if ($count_sub2 >= count($sub['sub2'])) { $sub_tree_class = 'submenu_text submenu2_text_last'; } else { @@ -372,7 +372,7 @@ function menu_print_menu(&$menu) $sub_title = ''; } - // Add submenu2 to submenu string + // Add submenu2 to submenu string. $submenu_output .= ''; @@ -382,7 +382,7 @@ function menu_print_menu(&$menu) $submenu_output .= '
  • '; } - // Choose valid section (sec) + // Choose valid section (sec). if (enterprise_hook('enterprise_acl', [$config['id_user'], $mainsec, $main['sec2']]) == false) { if ($count_sub_access > 0) { // If any susection have access but main section not, we change main link to first subsection found @@ -398,7 +398,7 @@ function menu_print_menu(&$menu) $seleccionado = ''; } - // Print out the first level + // Print out the first level. $output .= '
  • '; // onclick="location.href=\'index.php?sec='.$mainsec.'&sec2='.$main["sec2"].($main["refr"] ? '&refr='.$main["refr"] : '').'\'">'; $length = strlen(__($main['text'])); @@ -419,7 +419,7 @@ function menu_print_menu(&$menu) $length = 0; // $output .= html_print_image("include/styles/images/toggle.png", true, array("class" => "toggle", "alt" => "toogle")); if ($submenu_output != '') { - // WARNING: IN ORDER TO MODIFY THE VISIBILITY OF MENU'S AND SUBMENU'S (eg. with cookies) YOU HAVE TO ADD TO THIS ELSEIF. DON'T MODIFY THE CSS + // WARNING: IN ORDER TO MODIFY THE VISIBILITY OF MENU'S AND SUBMENU'S (eg. with cookies) YOU HAVE TO ADD TO THIS ELSEIF. DON'T MODIFY THE CSS. if ($visible || in_array('selected', $classes)) { $visible = true; } @@ -439,9 +439,9 @@ function menu_print_menu(&$menu) $menu_selected = false; } - // Finish menu + // Finish menu. echo ''; - // Invisible UL for adding border-top + // Invisible UL for adding border-top. echo ''; } @@ -541,7 +541,7 @@ function menu_add_extras(&$menu) $menu_extra['workspace']['sub']['operation/incidents/incident_detail']['text'] = __('Manage incident'); - // Duplicate extensions as sec=extension to check it from url + // Duplicate extensions as sec=extension to check it from url. foreach ($menu as $k => $m) { if (!isset($m['sub'])) { continue; @@ -585,7 +585,7 @@ function menu_get_sec($with_categories=false) if ($with_categories) { if (!$in_godmode && $k[0] == 'g') { // Hack to dont confuse with gis activated because godmode - // sec starts with g (like gismaps) + // sec starts with g (like gismaps). if ($k != 'gismaps') { $in_godmode = true; } @@ -654,17 +654,17 @@ function menu_get_sec_pages($sec, $menu_hash=false) $sec2_array = []; if (isset($sec)) { - // Get the sec2 of the main section + // Get the sec2 of the main section. $sec2_array[$menu[$sec]['sec2']] = $menu[$sec]['text']; - // Get the sec2 of the subsections + // Get the sec2 of the subsections. foreach ($menu[$sec]['sub'] as $k => $v) { - // Avoid special cases of standalone windows + // Avoid special cases of standalone windows. if (preg_match('/^javascript:/', $k) || preg_match('/\.php/', $k)) { continue; } - // If this value has various parameters, we only get the first + // If this value has various parameters, we only get the first. $k = explode('&', $k); $k = $k[0]; @@ -672,6 +672,7 @@ function menu_get_sec_pages($sec, $menu_hash=false) } } + $sec2_array = array_unique($sec2_array); return $sec2_array; } @@ -698,8 +699,8 @@ function menu_get_sec2_pages($sec, $sec2, $menu_hash=false) $sec3_array = []; - if (isset($menu[$sec]['sub']) and isset($menu[$sec]['sub'][$sec2]['sub2'])) { - // Get the sec2 of the subsections + if (isset($menu[$sec]['sub']) && isset($menu[$sec]['sub'][$sec2]['sub2'])) { + // Get the sec2 of the subsections. foreach ($menu[$sec]['sub'][$sec2]['sub2'] as $k => $v) { $sec3_array[$k] = $v['text']; } @@ -721,7 +722,7 @@ function menu_sec2_in_sec($sec, $sec2) { $sec2_array = menu_get_sec_pages($sec); - // If this value has various parameters, we only get the first + // If this value has various parameters, we only get the first. $sec2 = explode('&', $sec2); $sec2 = $sec2[0]; @@ -737,7 +738,7 @@ function menu_sec3_in_sec2($sec, $sec2, $sec3) { $sec3_array = menu_get_sec2_pages($sec, $sec2, $menu_hash = false); - // If this value has various parameters, we only get the first + // If this value has various parameters, we only get the first. $sec3 = explode('&', $sec3); $sec3 = $sec3[0]; diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index ed19c6d2c1..18c89e11c5 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -663,10 +663,11 @@ function modules_create_agent_module( 'estado' => $status, 'known_status' => $status, 'id_agente' => (int) $id_agent, - 'utimestamp' => 0, + 'utimestamp' => (time() - (int) $values['interval']), 'status_changes' => 0, 'last_status' => $status, 'last_known_status' => $status, + 'current_interval' => (int) $values['interval'], ] ); diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 3761c0f904..502da22326 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -41,11 +41,11 @@ require_once $config['homedir'].'/include/functions_network.php'; // // CONSTANTS DEFINITIONS // // -// Priority modes +// Priority modes. define('REPORT_PRIORITY_MODE_OK', 1); define('REPORT_PRIORITY_MODE_UNKNOWN', 2); -// Status +// Status. define('REPORT_STATUS_ERR', 0); define('REPORT_STATUS_OK', 1); define('REPORT_STATUS_UNKNOWN', 2); @@ -62,7 +62,7 @@ function reporting_user_can_see_report($id_report, $id_user=null) $id_user = $config['id_user']; } - // Get Report record (to get id_group) + // Get Report record (to get id_group). $report = db_get_row('treport', 'id_report', $id_report); // Check ACL on the report to see if user has access to the report. @@ -108,6 +108,10 @@ function reporting_get_type($content) case REPORT_OLD_TYPE_SUMATORY: $content['type'] = 'sumatory'; break; + + default: + // Default. + break; } return $content['type']; @@ -205,7 +209,7 @@ function reporting_make_reporting_data( $server_name = $content['server_name']; // General reports with 0 period means last value - // Avoid to overwrite it by template value + // Avoid to overwrite it by template value. if (!empty($period) && ($content['type'] !== 'general' && $content['period'] != 0)) { $content['period'] = $period; } @@ -229,7 +233,7 @@ function reporting_make_reporting_data( if (in_array('label', $content['style'])) { if ($content['id_agent'] == 0) { - // Metaconsole connection + // Metaconsole connection. if ($metaconsole_on && $server_name != '') { $connection = metaconsole_get_connection($server_name); if (!metaconsole_load_external_db($connection)) { @@ -240,7 +244,7 @@ function reporting_make_reporting_data( array_push($agents_to_macro, modules_get_agentmodule_agent($graph_item['id_agent_module'])); if ($metaconsole_on) { - // Restore db connection + // Restore db connection. metaconsole_restore_db(); } } @@ -291,7 +295,7 @@ function reporting_make_reporting_data( $content['name'] = reporting_label_macro($items_label, $content['style']['name_label']); if ($metaconsole_on) { - // Restore db connection + // Restore db connection. metaconsole_restore_db(); } } @@ -781,6 +785,10 @@ function reporting_make_reporting_data( $pdf ); break; + + default: + // Default. + break; } $index_content++; @@ -847,7 +855,7 @@ function reporting_SLA( include_once $config['homedir'].'/include/functions_planned_downtimes.php'; $metaconsole_on = is_metaconsole(); - // checking if needed to show graph or table + // checking if needed to show graph or table. if ($content['show_graph'] == 0 || $content['show_graph'] == 1) { $show_table = 1; } else { @@ -1241,7 +1249,6 @@ function reporting_SLA( } $return['charts'] = $temp; - break; case 2: @@ -1278,7 +1285,10 @@ function reporting_SLA( } $return['charts'] = $temp; + break; + default: + // Default. break; } } @@ -1317,7 +1327,7 @@ function reporting_event_top_n( case REPORT_TOP_N_AVG: default: - // If nothing is selected then it will be shown the average data + // If nothing is selected then it will be shown the average data. $type_top_n = __('Avg'); break; } @@ -1334,7 +1344,7 @@ function reporting_event_top_n( $return['top_n'] = $content['top_n_value']; if (empty($content['subitems'])) { - // Get all the related data + // Get all the related data. $sql = sprintf( 'SELECT id_agent_module, server_name FROM treport_content_item @@ -1347,7 +1357,7 @@ function reporting_event_top_n( $tops = $content['subitems']; } - // Get chart + // Get chart. reporting_set_conf_charts( $width, $height, @@ -1371,7 +1381,7 @@ function reporting_event_top_n( $data_top = []; foreach ($tops as $key => $row) { - // Metaconsole connection + // Metaconsole connection. $server_name = $row['server_name']; if (($config['metaconsole'] == 1) && $server_name != '' && defined('METACONSOLE')) { $connection = metaconsole_get_connection($server_name); @@ -1401,7 +1411,7 @@ function reporting_event_top_n( case REPORT_TOP_N_AVG: default: - // If nothing is selected then it will be shown the average data + // If nothing is selected then it will be shown the average data. $value = reporting_get_agentmodule_data_average($row['id_agent_module'], $content['period']); break; } @@ -1415,7 +1425,7 @@ function reporting_event_top_n( $units[$key] = $unit; } - // Restore dbconnection + // Restore dbconnection. if (($config['metaconsole'] == 1) && $server_name != '' && defined('METACONSOLE')) { metaconsole_restore_db(); } @@ -1428,21 +1438,25 @@ function reporting_event_top_n( // Order to show. switch ($order_uptodown) { - // Descending + // Descending. case 1: array_multisort($data_top, SORT_DESC, $agent_name, SORT_ASC, $module_name, SORT_ASC, $id_agent_module, SORT_ASC, $units, SORT_ASC); break; - // Ascending + // Ascending. case 2: array_multisort($data_top, SORT_ASC, $agent_name, SORT_ASC, $module_name, SORT_ASC, $id_agent_module, SORT_ASC, $units, SORT_ASC); break; - // By agent name or without selection + // By agent name or without selection. case 0: case 3: array_multisort($agent_name, SORT_ASC, $data_top, SORT_ASC, $module_name, SORT_ASC, $id_agent_module, SORT_ASC, $units, SORT_ASC); break; + + default: + // Default. + break; } array_splice($data_top, $top_n_value); @@ -1458,7 +1472,7 @@ function reporting_event_top_n( $data_top_values['id_agent_module'] = $id_agent_module; $data_top_values['units'] = $units; - // Define truncate size depends the graph width + // Define truncate size depends the graph width. $truncate_size = ($width / (4 * ($config['font_size'])) - 1); if ($order_uptodown == 1 || $order_uptodown == 2) { @@ -1584,7 +1598,7 @@ function reporting_event_top_n( $ttl ); - // Display bars graph + // Display bars graph. $return['charts']['bars'] = hbar_graph( $data_hbar, $width, @@ -1609,7 +1623,7 @@ function reporting_event_top_n( $return['resume'] = null; if ($content['show_resume'] && count($data_top_values) > 0) { - // Get the very first not null value + // Get the very first not null value. $i = 0; do { $min = $data_top_values['data_top'][$i]; @@ -1689,14 +1703,14 @@ function reporting_event_report_group( $event_filter = $content['style']; $return['show_summary_group'] = $event_filter['show_summary_group']; - // filter + // Filter. $show_summary_group = $event_filter['show_summary_group']; $filter_event_severity = json_decode($event_filter['filter_event_severity'], true); $filter_event_type = json_decode($event_filter['filter_event_type'], true); $filter_event_status = json_decode($event_filter['filter_event_status'], true); $filter_event_filter_search = $event_filter['event_filter_search']; - // graphs + // Graphs. $event_graph_by_agent = $event_filter['event_graph_by_agent']; $event_graph_by_user_validator = $event_filter['event_graph_by_user_validator']; $event_graph_by_criticity = $event_filter['event_graph_by_criticity']; @@ -1858,7 +1872,7 @@ function reporting_event_report_group( metaconsole_restore_db(); } - // total_events + // total_events. if ($return['data'] != '') { $return['total_events'] = count($return['data']); } else { @@ -1911,14 +1925,14 @@ function reporting_event_report_module( $event_filter = $content['style']; $return['show_summary_group'] = $event_filter['show_summary_group']; - // filter + // Filter. $show_summary_group = $event_filter['show_summary_group']; $filter_event_severity = json_decode($event_filter['filter_event_severity'], true); $filter_event_type = json_decode($event_filter['filter_event_type'], true); $filter_event_status = json_decode($event_filter['filter_event_status'], true); $filter_event_filter_search = $event_filter['event_filter_search']; - // graphs + // Graphs. $event_graph_by_user_validator = $event_filter['event_graph_by_user_validator']; $event_graph_by_criticity = $event_filter['event_graph_by_criticity']; $event_graph_validated_vs_unvalidated = $event_filter['event_graph_validated_vs_unvalidated']; @@ -1930,7 +1944,7 @@ function reporting_event_report_module( $metaconsole_dbtable = false; } - // data events + // Data events. $data = reporting_get_module_detailed_event( $content['id_agent_module'], $content['period'], @@ -1959,7 +1973,7 @@ function reporting_event_report_module( metaconsole_restore_db(); } - // total_events + // Total_events. if ($return['data'][0]['data'] != '') { $return['total_events'] = count($return['data'][0]['data']); } else { @@ -2276,6 +2290,10 @@ function reporting_exception( $return['subtitle'] = __('Exception - Modules at critical or warning status'); $return['subtype'] = __('Modules at critical or warning status'); break; + + default: + // Default. + break; } $return['description'] = $content['description']; @@ -2286,7 +2304,7 @@ function reporting_exception( $return['resume'] = []; if (empty($content['subitems'])) { - // Get all the related data + // Get all the related data. $sql = sprintf( ' SELECT id_agent_module, server_name, operation @@ -2303,10 +2321,10 @@ function reporting_exception( if ($exceptions === false) { $return['failed'] = __('There are no Agent/Modules defined'); } else { - // Get the very first not null value + // Get the very first not null value. $i = 0; do { - // Metaconsole connection + // Metaconsole connection. $server_name = $exceptions[$i]['server_name']; if (($config['metaconsole'] == 1) && $server_name != '' && defined('METACONSOLE')) { $connection = metaconsole_get_connection($server_name); @@ -2340,12 +2358,16 @@ function reporting_exception( $content['period'] ); break; + + default: + // Default. + break; } } $i++; - // Restore dbconnection + // Restore dbconnection. if (($config['metaconsole'] == 1) && $server_name != '' && defined('METACONSOLE')) { metaconsole_restore_db(); } @@ -2357,7 +2379,7 @@ function reporting_exception( $i = 0; foreach ($exceptions as $exc) { - // Metaconsole connection + // Metaconsole connection. $server_name = $exc['server_name']; if (($config['metaconsole'] == 1) && $server_name != '' && defined('METACONSOLE')) { $connection = metaconsole_get_connection($server_name); @@ -6270,6 +6292,19 @@ function reporting_availability($report, $content, $date=false, $time=false) $return['resume']['avg'] = $avg; $return['resume']['max_text'] = $max_text; $return['resume']['max'] = $max; + $return['fields'] = []; + $return['fields']['total_time'] = $content['total_time']; + $return['fields']['time_failed'] = $content['time_failed']; + $return['fields']['time_in_ok_status'] = $content['time_in_ok_status']; + $return['fields']['time_in_unknown_status'] = $content['time_in_unknown_status']; + $return['fields']['time_of_not_initialized_module'] = $content['time_of_not_initialized_module']; + $return['fields']['time_of_downtime'] = $content['time_of_downtime']; + $return['fields']['total_checks'] = $content['total_checks']; + $return['fields']['checks_failed'] = $content['checks_failed']; + $return['fields']['checks_in_ok_status'] = $content['checks_in_ok_status']; + $return['fields']['unknown_checks'] = $content['unknown_checks']; + $return['fields']['agent_max_value'] = $content['agent_max_value']; + $return['fields']['agent_min_value'] = $content['agent_min_value']; return reporting_check_structure_content($return); } @@ -7443,6 +7478,21 @@ function reporting_check_structure_content($report) $report['date']['to'] = ''; } + if (!isset($report['fields'])) { + $return['fields']['total_time'] = ''; + $return['fields']['time_failed'] = ''; + $return['fields']['time_in_ok_status'] = ''; + $return['fields']['time_in_unknown_status'] = ''; + $return['fields']['time_of_not_initialized_module'] = ''; + $return['fields']['time_of_downtime'] = ''; + $return['fields']['total_checks'] = ''; + $return['fields']['checks_failed'] = ''; + $return['fields']['checks_in_ok_status'] = ''; + $return['fields']['unknown_checks'] = ''; + $return['fields']['agent_max_value'] = ''; + $return['fields']['agent_min_value'] = ''; + } + return $report; } @@ -7771,11 +7821,11 @@ function reporting_get_agents_detailed_event( foreach ($events as $eventRow) { foreach ($eventRow as $k => $event) { - // First pass along the class of this row + // First pass along the class of this row. $table->cellclass[$k][1] = $table->cellclass[$k][2] = $table->cellclass[$k][4] = $table->cellclass[$k][5] = $table->cellclass[$k][6] = get_priority_class($event['criticity']); $data = []; - // Colored box + // Colored box. switch ($event['estado']) { case 0: $img_st = 'images/star.png'; @@ -11442,33 +11492,95 @@ function reporting_sla_is_ignored_from_array($sla_array) * * @return integer Status */ -function reporting_sla_get_status_period($sla_times, $priority_mode=REPORT_PRIORITY_MODE_OK) -{ - if ($sla_times['time_error'] > 0) { +function reporting_sla_get_status_period( + $sla, + $priority_mode=REPORT_PRIORITY_MODE_OK +) { + if ($sla['time_error'] > 0) { return REPORT_STATUS_ERR; } - if ($priority_mode == REPORT_PRIORITY_MODE_OK && $sla_times['time_ok'] > 0) { + if ($priority_mode == REPORT_PRIORITY_MODE_OK && $sla['time_ok'] > 0) { return REPORT_STATUS_OK; } - if ($sla_times['time_out'] > 0) { + if ($sla['time_out'] > 0) { return REPORT_STATUS_IGNORED; } - if ($sla_times['time_downtime'] > 0) { + if ($sla['time_downtime'] > 0) { return REPORT_STATUS_DOWNTIME; } - if ($sla_times['time_unknown'] > 0) { + if ($sla['time_unknown'] > 0) { return REPORT_STATUS_UNKNOWN; } - if ($sla_times['time_not_init'] > 0) { + if ($sla['time_not_init'] > 0) { return REPORT_STATUS_NOT_INIT; } - if ($sla_times['time_ok'] > 0) { + if ($sla['time_ok'] > 0) { + return REPORT_STATUS_OK; + } + + return REPORT_STATUS_IGNORED; +} + + +/** + * @brief Given a period, get the SLA status + * of the period compare with sla_limit. + * + * @param Array An array with all times to calculate the SLA. + * @param int Limit SLA pass for user. + * Only used for monthly, weekly And hourly report. + * + * @return integer Status + */ +function reporting_sla_get_status_period_compliance( + $sla, + $sla_limit +) { + global $config; + + $time_compliance = ( + $sla['time_ok'] + $sla['time_unknown'] + $sla['time_downtime'] + ); + + $time_total_working = ( + $time_compliance + $sla['time_error'] + ); + + $time_compliance = ($time_compliance == 0) ? 0 : (($time_compliance / $time_total_working) * 100); + + if ($sla['time_error'] > 0 && ($time_compliance < $sla_limit)) { + return REPORT_STATUS_ERR; + } + + if ($priority_mode == REPORT_PRIORITY_MODE_OK + && $sla['time_ok'] > 0 && ($time_compliance >= $sla_limit) + ) { + return REPORT_STATUS_OK; + } + + if ($sla['time_out'] > 0 && ($time_compliance < $sla_limit)) { + return REPORT_STATUS_IGNORED; + } + + if ($sla['time_downtime'] > 0 && ($time_compliance < $sla_limit)) { + return REPORT_STATUS_DOWNTIME; + } + + if ($sla['time_unknown'] > 0 && ($time_compliance < $sla_limit)) { + return REPORT_STATUS_UNKNOWN; + } + + if ($sla['time_not_init'] > 0 && ($time_compliance < $sla_limit)) { + return REPORT_STATUS_NOT_INIT; + } + + if ($sla['time_ok'] > 0 && ($time_compliance >= $sla_limit)) { return REPORT_STATUS_OK; } diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 7265c721ec..dc6010e34a 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -2907,7 +2907,6 @@ function reporting_html_availability($table, $item, $pdf=0) io_safe_output($style), true ); - $same_agent_in_resume = ''; global $config; @@ -2927,32 +2926,62 @@ function reporting_html_availability($table, $item, $pdf=0) $table1->head[1] = __('Module'); } - $table1->head[2] = __('Total time'); - $table1->head[3] = __('Time failed'); - $table1->head[4] = __('Time OK'); - $table1->head[5] = __('Time Uknown'); - $table1->head[6] = __('Time Not Init Module'); - $table1->head[7] = __('Time Downtime'); + if ($item['fields']['total_time']) { + $table1->head[2] = __('Total time'); + } else { + $table1->head[2] = __(''); + } + + if ($item['fields']['time_failed']) { + $table1->head[3] = __('Time failed'); + } else { + $table1->head[3] = __(''); + } + + if ($item['fields']['time_in_ok_status']) { + $table1->head[4] = __('Time OK'); + } else { + $table1->head[4] = __(''); + } + + if ($item['fields']['time_in_unknown_status']) { + $table1->head[5] = __('Time Unknown'); + } else { + $table1->head[5] = __(''); + } + + if ($item['fields']['time_of_not_initialized_module']) { + $table1->head[6] = __('Time Not Init Module'); + } else { + $table1->head[6] = __(''); + } + + if ($item['fields']['time_of_downtime']) { + $table1->head[7] = __('Time Downtime'); + } else { + $table1->head[7] = __(''); + } + $table1->head[8] = __('% Ok'); $table1->headstyle = []; $table1->headstyle[0] = 'text-align: left'; $table1->headstyle[1] = 'text-align: left'; - $table1->headstyle[2] = 'text-align: right'; - $table1->headstyle[3] = 'text-align: right'; - $table1->headstyle[4] = 'text-align: right'; - $table1->headstyle[5] = 'text-align: right'; - $table1->headstyle[6] = 'text-align: right'; + $table1->headstyle[2] = 'text-align: center'; + $table1->headstyle[3] = 'text-align: center'; + $table1->headstyle[4] = 'text-align: center'; + $table1->headstyle[5] = 'text-align: center'; + $table1->headstyle[6] = 'text-align: center'; $table1->headstyle[7] = 'text-align: right'; $table1->headstyle[8] = 'text-align: right'; $table1->style[0] = 'text-align: left'; $table1->style[1] = 'text-align: left'; - $table1->style[2] = 'text-align: right'; - $table1->style[3] = 'text-align: right'; - $table1->style[4] = 'text-align: right'; - $table1->style[5] = 'text-align: right'; - $table1->style[6] = 'text-align: right'; + $table1->style[2] = 'text-align: center'; + $table1->style[3] = 'text-align: center'; + $table1->style[4] = 'text-align: center'; + $table1->style[5] = 'text-align: center'; + $table1->style[6] = 'text-align: center'; $table1->style[7] = 'text-align: right'; $table1->style[8] = 'text-align: right'; @@ -2970,10 +2999,29 @@ function reporting_html_availability($table, $item, $pdf=0) $table2->head[1] = __('Module'); } - $table2->head[2] = __('Total checks'); - $table2->head[3] = __('Checks failed'); - $table2->head[4] = __('Checks OK'); - $table2->head[5] = __('Checks Uknown'); + if ($item['fields']['total_checks']) { + $table2->head[2] = __('Total checks'); + } else { + $table2->head[2] = __(''); + } + + if ($item['fields']['checks_failed']) { + $table2->head[3] = __('Checks failed'); + } else { + $table2->head[3] = __(''); + } + + if ($item['fields']['checks_in_ok_status']) { + $table2->head[4] = __('Checks OK'); + } else { + $table2->head[4] = __(''); + } + + if ($item['fields']['unknown_checks']) { + $table2->head[5] = __('Checks Uknown'); + } else { + $table2->head[5] = __(''); + } $table2->headstyle = []; $table2->headstyle[0] = 'text-align: left'; @@ -2995,69 +3043,97 @@ function reporting_html_availability($table, $item, $pdf=0) $table_row[] = $row['agent']; $table_row[] = $row['availability_item']; - if ($row['time_total'] != 0) { + if ($row['time_total'] != 0 && $item['fields']['total_time']) { $table_row[] = human_time_description_raw( $row['time_total'], true ); - } else { + } else if ($row['time_total'] == 0 && $item['fields']['total_time']) { $table_row[] = '--'; - } + } else { + $table_row[] = ''; + }; - if ($row['time_error'] != 0) { + if ($row['time_error'] != 0 && $item['fields']['time_failed']) { $table_row[] = human_time_description_raw( $row['time_error'], true ); - } else { + } else if ($row['time_error'] == 0 && $item['fields']['time_failed']) { $table_row[] = '--'; - } + } else { + $table_row[] = ''; + }; - if ($row['time_ok'] != 0) { + if ($row['time_ok'] != 0 && $item['fields']['time_in_ok_status']) { $table_row[] = human_time_description_raw( $row['time_ok'], true ); - } else { + } else if ($row['time_ok'] == 0 && $item['fields']['time_in_ok_status']) { $table_row[] = '--'; - } + } else { + $table_row[] = ''; + }; - if ($row['time_unknown'] != 0) { + if ($row['time_unknown'] != 0 && $item['fields']['time_in_unknown_status']) { $table_row[] = human_time_description_raw( $row['time_unknown'], true ); - } else { + } else if ($row['time_unknown'] == 0 && $item['fields']['time_in_unknown_status']) { $table_row[] = '--'; - } + } else { + $table_row[] = ''; + }; - if ($row['time_not_init'] != 0) { + if ($row['time_not_init'] != 0 && $item['fields']['time_of_not_initialized_module']) { $table_row[] = human_time_description_raw( $row['time_not_init'], true ); - } else { + } else if ($row['time_not_init'] == 0 && $item['fields']['time_of_not_initialized_module']) { $table_row[] = '--'; - } + } else { + $table_row[] = ''; + }; - if ($row['time_downtime'] != 0) { + if ($row['time_downtime'] != 0 && $item['fields']['time_of_downtime']) { $table_row[] = human_time_description_raw( $row['time_downtime'], true ); - } else { + } else if ($row['time_downtime'] == 0 && $item['fields']['time_of_downtime']) { $table_row[] = '--'; - } + } else { + $table_row[] = ''; + }; $table_row[] = ''.sla_truncate($row['SLA'], $config['graph_precision']).'%'; $table_row2 = []; $table_row2[] = $row['agent']; $table_row2[] = $row['availability_item']; - $table_row2[] = $row['checks_total']; - $table_row2[] = $row['checks_error']; - $table_row2[] = $row['checks_ok']; - $table_row2[] = $row['checks_unknown']; + if ($item['fields']['total_checks']) { + $table_row2[] = $row['checks_total']; + } else { + $table_row2[] = ''; + }; + if ($item['fields']['checks_failed']) { + $table_row2[] = $row['checks_error']; + } else { + $table_row2[] = ''; + }; + if ($item['fields']['checks_in_ok_status']) { + $table_row2[] = $row['checks_ok']; + } else { + $table_row2[] = ''; + }; + if ($item['fields']['unknown_checks']) { + $table_row2[] = $row['checks_unknown']; + } else { + $table_row2[] = ''; + }; $table1->data[] = $table_row; $table2->data[] = $table_row2; @@ -3096,7 +3172,7 @@ function reporting_html_availability($table, $item, $pdf=0) if ($item['resume']['resume'] && !empty($item['data'])) { $table1->width = '99%'; $table1->data = []; - if ((strpos($item['resume']['min_text'], $same_agent_in_resume) === false)) { + if (empty($same_agent_in_resume) || (strpos($item['resume']['min_text'], $same_agent_in_resume) === false)) { $table1->head = []; $table1->head['max_text'] = __('Agent max value'); $table1->head['max'] = __('Max Value'); @@ -3131,6 +3207,19 @@ function reporting_html_availability($table, $item, $pdf=0) ).'%', 'avg' => ''.sla_truncate($item['resume']['avg'], $config['graph_precision']).'%', ]; + if ($item['fields']['agent_max_value'] == false) { + $table1->head['max_text'] = ''; + $table1->data[0]['max_text'] = ''; + $table1->head['max'] = ''; + $table1->data[0]['max'] = ''; + } + + if ($item['fields']['agent_min_value'] == false) { + $table1->head['min_text'] = ''; + $table1->data[0]['min_text'] = ''; + $table1->head['min'] = ''; + $table1->data[0]['min'] = ''; + } if ($pdf === 0) { $table->colspan[3][0] = 3; diff --git a/pandora_console/include/functions_reporting_xml.php b/pandora_console/include/functions_reporting_xml.php index 1873859bdb..0179a27b06 100644 --- a/pandora_console/include/functions_reporting_xml.php +++ b/pandora_console/include/functions_reporting_xml.php @@ -31,7 +31,7 @@ function reporting_xml_get_report($report, $filename, $return=false) unset($report['private']); unset($report['custom_logo']); // ---------------------------------------------------------------------- - // change agent name + // change agent name. if (count($report['contents']) > 0) { for ($i = 0; $i < count($report['contents']); $i++) { $aux = explode('-', $report['contents'][$i]['subtitle']); @@ -44,16 +44,18 @@ function reporting_xml_get_report($report, $filename, $return=false) $xml = preg_replace('/(<[^>]+>)(<[^>]+>)(<[^>]+>)/', "$1\n$2\n$3", $xml); $xml = preg_replace('/(<[^>]+>)(<[^>]+>)/', "$1\n$2", $xml); - // Return if is marked to return + // Return if is marked to return. if ($return) { return $xml; } - // Download if marked to download - header('Content-Type: application/xml; charset=UTF-8'); - header('Content-Disposition: attachment; filename="'.$filename.'.xml"'); + // Download if marked to download. + if ($filename === false) { + header('Content-Type: application/xml; charset=UTF-8'); + header('Content-Disposition: attachment; filename="'.$filename.'.xml"'); + } - // Clean the output buffer + // Clean the output buffer. ob_clean(); echo $xml; diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 7865a1c78a..b2a4a98b36 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -1736,10 +1736,6 @@ function ui_process_page_head($string, $bitfield) // Include countdown library $config['jquery']['countdown'] = 'include/javascript/jquery.countdown.js'; - // Include timezone user map library - $config['jquery']['OpenLayers'] = 'include/javascript/OpenLayers.js'; - $config['jquery']['jquery.timezone-picker'] = 'include/javascript/jquery.timezone-picker.js'; - // Then add each script as necessary $loaded = ['']; foreach ($config['jquery'] as $name => $filename) { diff --git a/pandora_console/include/javascript/pandora_modules.js b/pandora_console/include/javascript/pandora_modules.js index e835f87c24..d6a8e1bfe0 100644 --- a/pandora_console/include/javascript/pandora_modules.js +++ b/pandora_console/include/javascript/pandora_modules.js @@ -1,3 +1,8 @@ +/* + global $ + global jQuery +*/ + /* Modules ids to check types */ var id_modules_icmp = Array(6, 7); var id_modules_tcp = Array(8, 9, 10, 11); @@ -95,6 +100,7 @@ function configure_modules_form() { $("#text-unit").attr("value", ""); $("#checkbox-critical_inverse").attr("value", 0); $("#checkbox-warning_inverse").attr("value", 0); + $("#checkbox-ff_type").attr("value", 0); $("#textarea_critical_instructions").attr("value", ""); $("#textarea_warning_instructions").attr("value", ""); $("#textarea_unknown_instructions").attr("value", ""); @@ -177,6 +183,13 @@ function configure_modules_form() { "value", 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( "value", 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"] ); + 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 if (data["post_process"] != 0) { $("#post_process_manual").show(); diff --git a/pandora_console/install.php b/pandora_console/install.php index 6e6bbb4d77..3d0b96a7fc 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -129,7 +129,7 @@
    '."\n\t"; +echo ''."\n\t"; ?>
  • + + + + + + + + + +
    +

    + +

    +
    +

    + +

    +
    +

    + +

    +
    +

    + +

    +
    +

    + +

    +
    +

    + +

    +
    +
    @@ -1629,7 +1700,7 @@ $class = 'databox filters';
    + Select fields to show

    '); + ?> +
    + + + + + +
    +

    + +

    +
    +

    + +

    +
    +

    + +

    +
    +

    + +

    +
    +
    +
    + Select fields to show

    '); + ?> +
    + + + +
    +

    + +

    +
    +

    + +

    +
    +
    +