diff --git a/README.md b/README.md index 07069d5e84..5e3a56c5df 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Installing Pandora FMS is a very easy task. Please visit our wiki and follow all Pandora FMS is a monitoring application to watch systems and applications that allows to know the status of any element of the business systems. Pandora FMS watches your hardware, software, your multilayer system and, of course, your OS. Pandora FMS can detect if a network interface is down or the movement of any NASDAQ new technology market value. If you wish, Pandora FMS can send a SMS message when your system or your application fails or when Google stock value drops below 330 US$. Pandora FMS will fit your systems and requirements, because it has been designed to be open, modular, multiplattform and easy to customize. ### Other things Pandora FMS can do -Pandora FMS is a monitoring tool that not only measures if a parameter is right or wrong. Pandora FMS can quantify the state (right or wrong), or store a value (numeric or alphanumeric) for months if necessary. Pandora FMS can measure performances, compare values among different systems and set alarms over thresholds. Pandora FMS works against a Database so it can generate reports, statistics, SLA and meausre anything: OS, applications and hardware systems, such as firewalls, proxies, Databases, web servers, VPN, routers, switches, processes, services, remote accesses to servers, etc. Everything integrated in an open and distributed architecture. Pandora FMS can be deployed over any OS, with specific agents for each platform. There are agents for Windows (2000, XP, 2003), GNU/Linux, Solaris, HP-UX, BSD, AIX, IPSO and OpenWRT. Pandora FMS not only gathers information through its agents, but it can also monitor any hardware system with TCP/IP connectivity, such as load balancing systems, routers, switches or printers, through SNMP and TCP/ICMP checks. +Pandora FMS is a monitoring tool that not only measures if a parameter is right or wrong. Pandora FMS can quantify the state (right or wrong), or store a value (numeric or alphanumeric) for months if necessary. Pandora FMS can measure performances, compare values among different systems and set alarms over thresholds. Pandora FMS works against a Database so it can generate reports, statistics, SLA and meausre anything: OS, applications and hardware systems, such as firewalls, proxies, Databases, web servers, VPN, routers, switches, processes, services, [remote accesses to servers](https://pandorafms.com/server-monitoring/), etc. Everything integrated in an open and distributed architecture. Pandora FMS can be deployed over any OS, with specific agents for each platform. There are agents for Windows (2000, XP, 2003), GNU/Linux, Solaris, HP-UX, BSD, AIX, IPSO and OpenWRT. Pandora FMS not only gathers information through its agents, but it can also monitor any hardware system with TCP/IP connectivity, such as load balancing systems, routers, switches or printers, through SNMP and TCP/ICMP checks. ### Main features * Network monitoring diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 0cd677930e..3367fd9fc9 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.748-200810 +Version: 7.0NG.748-200827 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 e501158d27..084ba37e31 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.748-200810" +pandora_version="7.0NG.748-200827" 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 c9f6329779..04f3444a2d 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -55,7 +55,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.748'; -use constant AGENT_BUILD => '200810'; +use constant AGENT_BUILD => '200827'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; @@ -1678,7 +1678,7 @@ sub execute_command_timeout { }; my $result = ($?>>8); - print $result; + return $result; # Exit child. # Child finishes. @@ -1753,7 +1753,7 @@ sub execute_command_block { ); # Do not retry if success. - last if looks_like_number($err_level) && $err_level == 0; + $retries = 0 if looks_like_number($err_level) && $err_level == 0; } while ((--$retries) > 0); diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 9e246a36ca..0845d34af2 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.748 -%define release 200810 +%define release 200827 Summary: Pandora FMS Linux agent, PERL version Name: %{name} @@ -21,10 +21,10 @@ BuildArch: noarch Requires(pre): shadow-utils Requires(post): chkconfig /bin/ln Requires(preun): chkconfig /bin/rm /usr/sbin/userdel -Requires: fileutils textutils unzip +Requires: coreutils unzip Requires: util-linux procps grep Requires: /sbin/ip /bin/awk -Requires: perl perl(Sys::Syslog) perl(IO::Compress::Zip) perl(YAML::Tiny) +Requires: perl perl(Sys::Syslog) perl(IO::Compress::Zip) # Required by plugins #Requires: sh-utils sed passwd net-tools rpm AutoReq: 0 diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index c719fe4671..e76f9d865b 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.748 -%define release 200810 +%define release 200827 Summary: Pandora FMS Linux agent, PERL version Name: %{name} @@ -20,7 +20,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot BuildArch: noarch #PreReq: %fillup_prereq %insserv_prereq /usr/bin/sed /usr/bin/grep /usr/sbin/useradd Requires(pre,preun):/usr/bin/sed /usr/bin/grep /usr/sbin/useradd -Requires: coreutils unzip perl perl(Sys::Syslog) perl(IO::Compress::Zip) perl(YAML::Tiny) +Requires: coreutils unzip perl perl(Sys::Syslog) perl(IO::Compress::Zip) AutoReq: 0 Provides: %{name}-%{version} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index c263bdd739..8dc9c0cf63 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.748" -PI_BUILD="200810" +PI_BUILD="200827" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/unix/plugins/grep_log b/pandora_agents/unix/plugins/grep_log index 76661c5230..2143464b48 100755 --- a/pandora_agents/unix/plugins/grep_log +++ b/pandora_agents/unix/plugins/grep_log @@ -56,6 +56,8 @@ my $Reg_exp = ''; # Flag to show or not summary module my $summary_flag = 0; +my $nodatalist_flag = 0; + # Number of coincidences found my $coincidences = 0; @@ -120,7 +122,15 @@ sub error_msg ($) { # Print a help message. ############################################################################### sub print_help () { - print "Usage: $0 [--summary]\n"; + print "Usage: $0 [--summary] [--nodatalist]\n\n"; + print "Options:\n"; + print "\t\t\tPath to the log file to be monitored\n"; + print "\t\t\tName of the module that will be created\n"; + print "\t\t\tRegex string to be matched in log file\n"; + print "\t\tShows NUM lines before matching lines to provide context\n"; + print "\t\tShows NUM lines after matching lines to provide context\n"; + print "\t--summary\t\tCreates a module with the total number of matches\n"; + print "\t--nodatalist\t\tInserts all coincidences in a single data output instead of a data per line\n"; } ############################################################################### @@ -317,6 +327,7 @@ sub print_log ($) { if ($#kdata < 0) { print_summary() if ($summary_flag == 1); return; + } # Log module @@ -341,6 +352,18 @@ sub print_log ($) { $output = "\n"; $output .= "\n"; $output .= "\n"; + if ($nodatalist_flag == 1){ + $output .= "{$line}}) { + my $processed_line = $content; + $processed_line =~ "\n"; + $output .= $processed_line; + } + } + $output .= "]]>\n"; + } + else { $output .= "\n"; foreach my $line (@kdata) { $output .= "\n"; } $output .= "\n"; + } $output .= "\n"; print stdout $output; } + } ############################################################################### @@ -376,12 +401,18 @@ $Reg_exp = trim($ARGV[2]); my $up_lines = trim($ARGV[3]); my $bot_lines = trim($ARGV[4]); my $sum_flag = trim($ARGV[5]); +my $nodatalist = trim($ARGV[6]); -if ( ( defined($up_lines) && ($up_lines eq "--summary")) - || ( defined($bot_lines) && ($bot_lines eq "--summary")) - || ( defined($sum_flag) && ($sum_flag eq "--summary")) ) { - $summary_flag = 1; +if ( grep { /--summary/ } @ARGV ) +{ + $summary_flag = 1; } + +if ( grep { /--nodatalist/ } @ARGV ) +{ + $nodatalist_flag = 1; +} + # Create index file storage directory if ( ! -d $Idx_dir) { mkdir($Idx_dir) || error_msg("Error creating directory $Idx_dir: " diff --git a/pandora_agents/win32/bin/util/grep_log.exe b/pandora_agents/win32/bin/util/grep_log.exe index 4e4029fb60..dbabc454b4 100644 Binary files a/pandora_agents/win32/bin/util/grep_log.exe and b/pandora_agents/win32/bin/util/grep_log.exe differ diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index ffa8ccd558..be51441777 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{200810} +{200827} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 9e391ec3bf..b42318c02f 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.748(Build 200810)") +#define PANDORA_VERSION ("7.0NG.748(Build 200827)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 07a296d1c4..d38cc7a456 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.748(Build 200810))" + VALUE "ProductVersion", "(7.0NG.748(Build 200827))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/.htaccess b/pandora_console/.htaccess index a1e6f62d2d..ca572f7df1 100644 --- a/pandora_console/.htaccess +++ b/pandora_console/.htaccess @@ -4,5 +4,4 @@ Options -Indexes Order Allow,Deny Deny from All - - + \ No newline at end of file diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index b9f2d71fd4..8c78791b32 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.748-200810 +Version: 7.0NG.748-200827 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 bc6d9c51ea..5c9b877098 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.748-200810" +pandora_version="7.0NG.748-200827" package_pear=0 package_pandora=1 diff --git a/pandora_console/attachment/.htaccess b/pandora_console/attachment/.htaccess index 71f7bf9540..ddd1f3ee4c 100644 --- a/pandora_console/attachment/.htaccess +++ b/pandora_console/attachment/.htaccess @@ -6,6 +6,4 @@ Deny from all Allow from localhost - -php_flag engine off - + \ No newline at end of file diff --git a/pandora_console/extras/mr/41.sql b/pandora_console/extras/mr/41.sql new file mode 100644 index 0000000000..58cf54f69f --- /dev/null +++ b/pandora_console/extras/mr/41.sql @@ -0,0 +1,9 @@ +START TRANSACTION; + +ALTER TABLE `talert_templates` ADD COLUMN `previous_name` text; +ALTER TABLE `talert_actions` ADD COLUMN `previous_name` text; +ALTER TABLE `talert_commands` ADD COLUMN `previous_name` text; +ALTER TABLE `ttag` ADD COLUMN `previous_name` text NULL; +ALTER TABLE `tconfig_os` ADD COLUMN `previous_name` text NULL; + +COMMIT; \ No newline at end of file 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 193705ed89..d741afb9ae 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 @@ -1312,6 +1312,8 @@ ALTER TABLE talert_actions ADD COLUMN `field12_recovery` TEXT NOT NULL DEFAULT " ALTER TABLE talert_actions ADD COLUMN `field13_recovery` TEXT NOT NULL DEFAULT ""; ALTER TABLE talert_actions ADD COLUMN `field14_recovery` TEXT NOT NULL DEFAULT ""; ALTER TABLE talert_actions ADD COLUMN `field15_recovery` TEXT NOT NULL DEFAULT ""; +ALTER TABLE `talert_actions` ADD COLUMN `previous_name` text; + ALTER TABLE `talert_actions` MODIFY COLUMN `field11` text NOT NULL, MODIFY COLUMN `field12` text NOT NULL, MODIFY COLUMN `field13` text NOT NULL, @@ -1325,6 +1327,7 @@ UPDATE `talert_commands` SET `fields_descriptions` = '[\"Integria IMS UPDATE `talert_commands` SET `description` = 'This alert send an email using internal Pandora FMS Server SMTP capabilities (defined in each server, using: _field1_ as destination email address, and _field2_ as subject for message. _field3_ as text of message. _field4_ as content type (text/plain or html/text).', `fields_descriptions` = '[\"Destination address\",\"Subject\",\"Text\",\"Content Type\",\"\",\"\",\"\",\"\",\"\",\"\"]', `fields_values` = '[\"\",\"\",\"_html_editor_\",\"_content_type_\",\"\",\"\",\"\",\"\",\"\",\"\"]' WHERE id=1; ALTER TABLE `talert_commands` ADD COLUMN `id_group` mediumint(8) unsigned NULL default 0; ALTER TABLE `talert_commands` ADD COLUMN `fields_hidden` text; +ALTER TABLE `talert_commands` ADD COLUMN `previous_name` text; UPDATE `talert_actions` SET `field4` = 'text/html', `field4_recovery` = 'text/html' WHERE id = 1; @@ -1337,6 +1340,11 @@ ALTER TABLE `talert_commands` MODIFY COLUMN `id_group` mediumint(8) unsigned NUL -- --------------------------------------------------------------------- ALTER TABLE `tmap` MODIFY COLUMN `id_user` varchar(250) NOT NULL DEFAULT ''; +-- --------------------------------------------------------------------- +-- Table `ttag` +-- --------------------------------------------------------------------- +ALTER TABLE `ttag` ADD COLUMN `previous_name` text NULL; + -- --------------------------------------------------------------------- -- Table `tconfig` -- --------------------------------------------------------------------- @@ -1381,7 +1389,9 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES ('cr_incident_content', ''); -- Table `tconfig_os` -- --------------------------------------------------------------------- -INSERT INTO `tconfig_os` (`id_os`, `name`, `description`, `icon_name`) VALUES (100, 'Cluster', 'Cluster agent', 'so_cluster.png'); +ALTER TABLE `tconfig_os` ADD COLUMN `previous_name` text NULL; + +INSERT INTO `tconfig_os` (`id_os`, `name`, `description`, `icon_name`) VALUES (100, 'Cluster', 'Cluster agent', 'so_cluster.png', ''); UPDATE `tagente` SET `id_os` = 100 WHERE `id_os` = 21 and (select `id_os` from `tconfig_os` WHERE `id_os` = 21 and `name` = 'Cluster'); @@ -2461,6 +2471,8 @@ INSERT INTO `tnews` (`id_news`, `author`, `subject`, `text`, `timestamp`) VALUES -- Alter table `talert_templates` -- ---------------------------------------------------------------------- +ALTER TABLE `talert_templates` ADD COLUMN `previous_name` text; + ALTER TABLE `talert_templates` MODIFY COLUMN `type` ENUM('regex','max_min','max','min','equal','not_equal','warning','critical','onchange','unknown','always','not_normal'); ALTER TABLE `talert_templates` MODIFY COLUMN `field11` text NOT NULL, diff --git a/pandora_console/godmode/alerts/alert_commands.php b/pandora_console/godmode/alerts/alert_commands.php index 5df94f29c3..88eedaaa27 100644 --- a/pandora_console/godmode/alerts/alert_commands.php +++ b/pandora_console/godmode/alerts/alert_commands.php @@ -291,8 +291,8 @@ if (is_ajax()) { 'field'.$i.'_value', '', '', + __('None'), '', - 0, true, false, false, diff --git a/pandora_console/godmode/alerts/alert_templates.php b/pandora_console/godmode/alerts/alert_templates.php index 150245acaf..38b601e6b7 100644 --- a/pandora_console/godmode/alerts/alert_templates.php +++ b/pandora_console/godmode/alerts/alert_templates.php @@ -362,6 +362,7 @@ $templates = alerts_get_alert_templates( 'description', 'type', 'id_group', + 'previous_name', ] ); if ($templates === false) { diff --git a/pandora_console/godmode/alerts/configure_alert_command.php b/pandora_console/godmode/alerts/configure_alert_command.php index 2091a9ee54..9300dc038b 100644 --- a/pandora_console/godmode/alerts/configure_alert_command.php +++ b/pandora_console/godmode/alerts/configure_alert_command.php @@ -83,6 +83,10 @@ if ($update_command) { $values['command'] = $command; $values['description'] = $description; $values['id_group'] = $id_group; + // Only for Metaconsole. Save the previous name for synchronizing. + if (is_metaconsole()) { + $values['previous_name'] = db_get_value('name', 'talert_commands', 'id', $id); + } // Check it the new name is used in the other command. $id_check = db_get_value('id', 'talert_commands', 'name', $name); diff --git a/pandora_console/godmode/alerts/configure_alert_template.php b/pandora_console/godmode/alerts/configure_alert_template.php index f9f8876e9c..9333664477 100644 --- a/pandora_console/godmode/alerts/configure_alert_template.php +++ b/pandora_console/godmode/alerts/configure_alert_template.php @@ -34,6 +34,9 @@ if (! check_acl($config['id_user'], 0, 'LM')) { $duplicate_template = (bool) get_parameter('duplicate_template'); $id = (int) get_parameter('id'); $pure = get_parameter('pure', 0); +$step = (int) get_parameter('step', 1); +// We set here the number of steps. +define('LAST_STEP', 3); // If user tries to duplicate/edit a template with group=ALL then must have "PM" access privileges if ($duplicate_template) { @@ -56,7 +59,6 @@ if ($a_template !== false) { if (defined('METACONSOLE')) { alerts_meta_print_header(); } else { - $step = (int) get_parameter('step', 1); if ($step == 1) { $help_header = ''; } else if ($step == 2) { @@ -113,7 +115,6 @@ if ($a_template !== false) { if (defined('METACONSOLE')) { alerts_meta_print_header(); } else { - $step = (int) get_parameter('step', 1); if ($step == 1) { $help_header = ''; } else if ($step == 2) { @@ -252,24 +253,20 @@ function update_template($step) $wizard_level = (string) get_parameter('wizard_level'); $priority = (int) get_parameter('priority'); $id_group = get_parameter('id_group'); - - switch ($config['dbtype']) { - case 'mysql': - case 'postgresql': - $name_check = db_get_value('name', 'talert_templates', 'name', $name); - break; - - case 'oracle': - $name_check = db_get_value('name', 'talert_templates', 'to_char(name)', $name); - break; + // Only for Metaconsole. Save the previous name for synchronizing. + if (is_metaconsole()) { + $previous_name = db_get_value('name', 'talert_templates', 'id', $id); + } else { + $previous_name = ''; } $values = [ - 'name' => $name, - 'description' => $description, - 'id_group' => $id_group, - 'priority' => $priority, - 'wizard_level' => $wizard_level, + 'name' => $name, + 'description' => $description, + 'id_group' => $id_group, + 'priority' => $priority, + 'wizard_level' => $wizard_level, + 'previous_name' => $previous_name, ]; $result = alerts_update_alert_template($id, $values); diff --git a/pandora_console/godmode/modules/manage_network_components.php b/pandora_console/godmode/modules/manage_network_components.php index 4b1995cd5e..37a3483e2b 100644 --- a/pandora_console/godmode/modules/manage_network_components.php +++ b/pandora_console/godmode/modules/manage_network_components.php @@ -330,7 +330,7 @@ if ($create_component) { if ($name && !$name_check) { $id = network_components_create_network_component( - $name, + strip_tags(io_safe_input($name), '
'), $type, $id_group, [ @@ -431,7 +431,7 @@ if ($update_component) { $id, [ 'type' => $type, - 'name' => $name, + 'name' => strip_tags(io_safe_input($name, '
')), 'id_group' => $id_group, 'description' => $description, 'module_interval' => $module_interval, diff --git a/pandora_console/godmode/modules/manage_network_components_form.php b/pandora_console/godmode/modules/manage_network_components_form.php index 2a63068b8d..df524a0574 100644 --- a/pandora_console/godmode/modules/manage_network_components_form.php +++ b/pandora_console/godmode/modules/manage_network_components_form.php @@ -111,7 +111,7 @@ if (isset($id)) { $component = network_components_get_network_component((int) $id); if ($component !== false) { $id_component_type = $component['id_modulo']; - $name = $component['name']; + $name = io_safe_output($component['name']); $type = $component['type']; $description = $component['description']; $max = $component['max']; diff --git a/pandora_console/godmode/setup/os.php b/pandora_console/godmode/setup/os.php index 99cce6e61d..73e10ecd52 100644 --- a/pandora_console/godmode/setup/os.php +++ b/pandora_console/godmode/setup/os.php @@ -98,6 +98,10 @@ switch ($action) { $values = []; $values['name'] = $name; $values['description'] = $description; + // Only for Metaconsole. Save the previous name for synchronizing. + if (is_metaconsole()) { + $values['previous_name'] = db_get_value('name', 'tconfig_os', 'id_os', $idOS); + } if (($icon !== 0) && ($icon != '')) { $values['icon_name'] = $icon; diff --git a/pandora_console/godmode/tag/edit_tag.php b/pandora_console/godmode/tag/edit_tag.php index 96b4e158e3..0b4d78f748 100644 --- a/pandora_console/godmode/tag/edit_tag.php +++ b/pandora_console/godmode/tag/edit_tag.php @@ -79,6 +79,10 @@ if ($update_tag && $id_tag != 0) { $values['url'] = $url_tag; $values['email'] = $email_tag; $values['phone'] = $phone_tag; + // Only for Metaconsole. Save the previous name for synchronizing. + if (is_metaconsole()) { + $values['previous_name'] = db_get_value('name', 'ttag', 'id_tag', $id_tag); + } $result = false; if ($values['name'] != '') { diff --git a/pandora_console/godmode/users/user_list.php b/pandora_console/godmode/users/user_list.php index 9c9873a664..e0fe0d0871 100644 --- a/pandora_console/godmode/users/user_list.php +++ b/pandora_console/godmode/users/user_list.php @@ -511,34 +511,38 @@ foreach ($info as $user_id => $user_info) { $data[4] = ''; if ($user_profiles !== false) { - if (defined('METACONSOLE')) { - $data[4] .= "
"; - foreach ($user_profiles as $row) { + $total_profile = 0; + + $data[4] .= '
'; + foreach ($user_profiles as $row) { + if ($total_profile <= 5) { $data[4] .= "
"; $data[4] .= profile_get_name($row['id_perfil']); $data[4] .= ' /
'; $data[4] .= "
"; $data[4] .= groups_get_name($row['id_grupo'], true); $data[4] .= '
'; + + if ($total_profile == 0 && count($user_profiles) >= 5) { + $data[4] .= ' + '.html_print_image('images/input_zoom_gray.png', true, ['title' => __('Show')]).''; + } + $data[4] .= '
'; $data[4] .= '
'; + $data[4] .= '
'; + } else { + $data[4] .= "'; - } else { - $data[4] .= ""; - foreach ($user_profiles as $row) { - $data[4] .= ''; - $data[4] .= ''; - $data[4] .= ''; - } - - $data[4] .= '
'; - $data[4] .= profile_get_name($row['id_perfil']); - $data[4] .= ' / '; - $data[4] .= groups_get_name($row['id_grupo'], true); - $data[4] .= '
'; - } } else { $data[4] .= __('The user doesn\'t have any assigned profile/group'); } @@ -588,3 +592,17 @@ if ($config['admin_can_add_user'] !== false) { echo '
'; enterprise_hook('close_meta_frame'); + +echo ''; diff --git a/pandora_console/images/.htaccess b/pandora_console/images/.htaccess index 4b551eebe2..6504ef7a6f 100644 --- a/pandora_console/images/.htaccess +++ b/pandora_console/images/.htaccess @@ -1,5 +1,4 @@ #pandora disable phpexec - + Deny from all - -php_flag engine off + \ No newline at end of file diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php index ca17c8ab9f..230b55a476 100644 --- a/pandora_console/include/ajax/events.php +++ b/pandora_console/include/ajax/events.php @@ -937,11 +937,16 @@ if ($perform_event_response) { return; } + $target = get_parameter('target', ''); $response_id = get_parameter('response_id'); $event_id = (int) get_parameter('event_id'); $server_id = (int) get_parameter('server_id', 0); - $command = events_get_response_target($event_id, $response_id, $server_id); + if (empty($target)) { + $command = events_get_response_target($event_id, $response_id, $server_id); + } else { + $command = $target; + } $event_response = db_get_row('tevent_response', 'id', $response_id); @@ -1088,7 +1093,8 @@ if ($dialogue_event_response) { } } else { echo "
"; - echo $prompt.sprintf(__('Executing command: %s', $command)); + + echo $prompt."Executing command: $command"; echo '

'; echo "'; diff --git a/pandora_console/include/class/AgentWizard.class.php b/pandora_console/include/class/AgentWizard.class.php index ce8f07b787..d211398f48 100644 --- a/pandora_console/include/class/AgentWizard.class.php +++ b/pandora_console/include/class/AgentWizard.class.php @@ -3001,6 +3001,8 @@ class AgentWizard extends HTML $module['name'] ); + $newModule['name_oid'] = str_replace('"', '', $tmpSecond[3]); + // Add this new module to the module list. $moduleBlocks[] = $newModule; } diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index e69911aa7f..9284e4e3aa 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 = 'PC200810'; +$build_version = 'PC200827'; $pandora_version = 'v7.0NG.748'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php index cc449b3445..f4bd91645e 100644 --- a/pandora_console/include/functions_alerts.php +++ b/pandora_console/include/functions_alerts.php @@ -2780,6 +2780,11 @@ function alerts_ui_update_or_create_actions($update=true) if ($update) { $values['name'] = $name; $values['id_alert_command'] = $id_alert_command; + // Only for Metaconsole, save the previous name for synchronization. + if (is_metaconsole()) { + $values['previous_name'] = db_get_value('name', 'talert_actions', 'id', $id); + } + $result = (!$name) ? '' : alerts_update_alert_action($id, $values); } else { $name_check = db_get_value('name', 'talert_actions', 'name', $name); diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 328848fc7e..5a184c352e 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -1861,13 +1861,13 @@ function api_set_delete_agent($id, $thrash1, $other, $thrash3) foreach ($servers as $server) { if (metaconsole_connect($server) == NOERR) { if ($other['data'][0] === '1') { - $idAgent[0] = agents_get_agent_id_by_alias($id); + $idAgent = agents_get_agent_id_by_alias($id); } else { $idAgent[0] = agents_get_agent_id($id, true); } - if ($idAgent[0]) { - $result = agents_delete_agent($idAgent, true); + if (!empty($idAgent)) { + $result = agents_delete_agent($idAgent[0], true); } metaconsole_restore_db(); diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index 1a70a63f63..dc1dac2e4d 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -728,7 +728,7 @@ function notifications_print_source_select_box( "
-

%s

+
%s
%s
diff --git a/pandora_console/include/javascript/pandora_events.js b/pandora_console/include/javascript/pandora_events.js index a5e5b0c36e..55c8ecb74a 100644 --- a/pandora_console/include/javascript/pandora_events.js +++ b/pandora_console/include/javascript/pandora_events.js @@ -135,7 +135,7 @@ function show_response_dialog(response_id, response) { params.push("dialogue_event_response=1"); params.push("massive=0"); params.push("event_id=" + response["event_id"]); - params.push("target=" + response["target"]); + params.push("target=" + encodeURIComponent(response["target"])); params.push("response_id=" + response_id); params.push("server_id=" + response["server_id"]); @@ -363,8 +363,17 @@ function get_response_target( if (response_params.length > 1 || response_params[0] != "") { for (var i = 0; i < response_params.length; i++) { if (!response_command) { + var response_param = "_" + response_params[i] + "_"; + + if ( + response_params[i].startsWith("_") && + response_params[i].endsWith("_") + ) { + response_param = response_params[i]; + } + target = target.replace( - "_" + response_params[i] + "_", + response_param, $("#" + response_params[i]).val() ); } else { @@ -388,7 +397,7 @@ function perform_response(response, response_id) { var params = []; params.push("page=include/ajax/events"); params.push("perform_event_response=1"); - params.push("target=" + response["target"]); + params.push("target=" + encodeURIComponent(response["target"])); params.push("response_id=" + response_id); params.push("event_id=" + response["event_id"]); params.push("server_id=" + response["server_id"]); diff --git a/pandora_console/index.php b/pandora_console/index.php index 71ae09e76c..af8671ded7 100755 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -1088,6 +1088,9 @@ if ($searchPage) { } } else if ($sec == 'gextensions') { $main_sec = get_parameter('extension_in_menu'); + if (empty($main_sec) === true) { + $main_sec = $sec; + } } else { $main_sec = $sec; } diff --git a/pandora_console/install.php b/pandora_console/install.php index 8349cc31a3..8300618ca5 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -129,7 +129,7 @@
width = '100%'; +$table->class = 'info_table'; +$table->cellpadding = '0'; +$table->cellspacing = '0'; +$table->head = []; +$table->align = []; + +$table->head[0] = "".__('Source').''; +$table->head[1] = "".__('Review').''; +$table->head[2] = "".__('Last contact').''; + +$table->style = []; +$table->style['source'] = 'width: 80%;'; + +$table->data = []; + +$row = []; + + +// Get most recent sources for active agent. +$sql = "select source, MAX(utimestamp) AS last_contact from tagent_module_log where id_agent=$agent_id GROUP BY source"; + +$logs = mysql_db_get_all_rows_sql($sql); + +foreach ($logs as $log) { + $row['source'] = $log['source']; + $row['review'] = ''.html_print_image('images/zoom.png', true, ['title' => __('Review in log viewer'), 'alt' => '', 'onclick' => "send_form('".$log['source'].'-'.$agent_id."')"]).''; + $row['last_contact'] = human_time_comparation($log['last_contact']); + + $table->data[] = $row; +} + +ob_start(); + +if (!empty($table->data)) { + echo '
'; + html_print_table($table); + echo '
'; +} else { + ui_print_info_message(['no_close' => true, 'message' => __('No log sources found') ]); + $log_sources_defined = false; +} + +// Hidden form to perform post request to Log Viewer page when clicking on the Review field icon. +echo ''; + +$html_content = ob_get_clean(); + +// Create controlled toggle content. +ui_toggle( + $html_content, + __('Log sources status'), + 'log_sources_status', + !$log_sources_defined, + false, + '', + 'white_table_graph_content no-padding-imp' +); + +?> + + diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index acb31f5cdc..e86960938a 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -1576,6 +1576,12 @@ switch ($tab) { include 'estado_monitores.php'; echo ""; include 'alerts_status.php'; + + if ($config['log_collector']) { + echo ""; + include 'log_sources_status.php'; + } + // Check permissions to read events if (check_acl($config['id_user'], 0, 'ER')) { echo ""; diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 974dd9c247..59fbb5a184 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -317,7 +317,12 @@ if (is_ajax()) { ); $count = events_get_all( 'count', - $filter + $filter, + null, + null, + null, + null, + $history ); if ($count !== false) { diff --git a/pandora_console/operation/incidents/incident_detail.php b/pandora_console/operation/incidents/incident_detail.php index 7e80ac93cf..56cb339218 100755 --- a/pandora_console/operation/incidents/incident_detail.php +++ b/pandora_console/operation/incidents/incident_detail.php @@ -137,11 +137,11 @@ if (isset($_GET['id'])) { } // Upload file - if ((check_acl($config['id_user'], $id_grupo, 'IW') == 1) and isset($_GET['upload_file']) and ($_FILES['userfile']['name'] != '')) { + if ((check_acl($config['id_user'], $id_grupo, 'IW') == 1) && isset($_GET['upload_file']) && ($_FILES['userfile']['name'] != '')) { $description = get_parameter('file_description', __('No description available')); // Insert into database - $filename = io_safe_input($_FILES['userfile']['name']); + $filename = strip_tags(io_safe_input($_FILES['userfile']['name']), '
'); $filesize = io_safe_input($_FILES['userfile']['size']); // The following is if you have clamavlib installed diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec index 7a4aa1a8bc..6c0ead03de 100644 --- a/pandora_console/pandora_console.redhat.spec +++ b/pandora_console/pandora_console.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_console %define version 7.0NG.748 -%define release 200810 +%define release 200827 # User and Group under which Apache is running %define httpd_name httpd diff --git a/pandora_console/pandora_console.rhel7.spec b/pandora_console/pandora_console.rhel7.spec index ae957d5442..03c152650d 100644 --- a/pandora_console/pandora_console.rhel7.spec +++ b/pandora_console/pandora_console.rhel7.spec @@ -3,7 +3,7 @@ # %define name pandorafms_console %define version 7.0NG.748 -%define release 200810 +%define release 200827 # User and Group under which Apache is running %define httpd_name httpd diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec index a94e407aa8..025f46e8f4 100644 --- a/pandora_console/pandora_console.spec +++ b/pandora_console/pandora_console.spec @@ -3,7 +3,7 @@ # %define name pandorafms_console %define version 7.0NG.748 -%define release 200810 +%define release 200827 %define httpd_name httpd # User and Group under which Apache is running %define httpd_name apache2 diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 68858bab4b..011e8e513f 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -381,6 +381,7 @@ CREATE TABLE IF NOT EXISTS `talert_commands` ( `fields_descriptions` TEXT, `fields_values` TEXT, `fields_hidden` TEXT, + `previous_name` text, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -423,6 +424,7 @@ CREATE TABLE IF NOT EXISTS `talert_actions` ( `field13_recovery` text NOT NULL, `field14_recovery` text NOT NULL, `field15_recovery` text NOT NULL, + `previous_name` text, PRIMARY KEY (`id`), FOREIGN KEY (`id_alert_command`) REFERENCES talert_commands(`id`) ON DELETE CASCADE ON UPDATE CASCADE @@ -490,6 +492,7 @@ CREATE TABLE IF NOT EXISTS `talert_templates` ( `wizard_level` enum('basic','advanced','nowizard') default 'nowizard', `min_alerts_reset_counter` tinyint(1) default 0, `disable_event` tinyint(1) default 0, + `previous_name` text, PRIMARY KEY (`id`), KEY `idx_template_action` (`id_alert_action`), FOREIGN KEY (`id_alert_action`) REFERENCES talert_actions(`id`) @@ -583,6 +586,7 @@ CREATE TABLE IF NOT EXISTS `tconfig_os` ( `name` varchar(100) NOT NULL default '', `description` varchar(250) default '', `icon_name` varchar(100) default '', + `previous_name` text NULL, PRIMARY KEY (`id_os`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -2038,9 +2042,10 @@ CREATE TABLE IF NOT EXISTS `ttag` ( `id_tag` integer(10) unsigned NOT NULL auto_increment, `name` varchar(100) NOT NULL default '', `description` text NOT NULL, - `url` mediumtext NOT NULL, + `url` mediumtext NOT NULL, `email` text NULL, `phone` text NULL, + `previous_name` text NULL, PRIMARY KEY (`id_tag`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 1eedc9cef4..46c878b19f 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -150,27 +150,27 @@ UNLOCK TABLES; -- LOCK TABLES `tconfig_os` WRITE; -INSERT INTO `tconfig_os` (`id_os`, `name`, `description`, `icon_name`) VALUES -(1,'Linux','Linux: All versions','so_linux.png'), -(2,'Solaris','Sun Solaris','so_solaris.png'), -(3,'AIX','IBM AIX','so_aix.png'), -(4,'BSD','OpenBSD, FreeBSD and Others','so_bsd.png'), -(5,'HP-UX','HP-UX Unix OS','so_hpux.png'), -(7,'Cisco','CISCO IOS','so_cisco.png'), -(8,'MacOS','MAC OS','so_mac.png'), -(9,'Windows','Microsoft Windows OS','so_win.png'), -(10,'Other','Other SO','so_other.png'), -(11,'Network','Network Agent','network.png'), -(12,'Web Server','Web Server/Application','network.png'), -(13,'Sensor','Hardware Agent (Sensor)','network.png'), -(14,'Embedded','Embedded device running an agent','embedded.png'), -(15,'Android','Android agent','android.png'), -(16, 'VMware', 'VMware Architecture', 'so_vmware.png'), -(17, 'Router', 'Generic router', 'so_router.png'), -(18, 'Switch', 'Generic switch', 'so_switch.png'), -(19, 'Satellite', 'Satellite agent', 'satellite.png'), -(20, 'Mainframe', 'Mainframe agent', 'so_mainframe.png'), -(100, 'Cluster', 'Cluster agent', 'so_cluster.png'); +INSERT INTO `tconfig_os` (`id_os`, `name`, `description`, `icon_name`, `previous_name`) VALUES +(1,'Linux','Linux: All versions','so_linux.png', ''), +(2,'Solaris','Sun Solaris','so_solaris.png', ''), +(3,'AIX','IBM AIX','so_aix.png', ''), +(4,'BSD','OpenBSD, FreeBSD and Others','so_bsd.png', ''), +(5,'HP-UX','HP-UX Unix OS','so_hpux.png', ''), +(7,'Cisco','CISCO IOS','so_cisco.png', ''), +(8,'MacOS','MAC OS','so_mac.png', ''), +(9,'Windows','Microsoft Windows OS','so_win.png', ''), +(10,'Other','Other SO','so_other.png', ''), +(11,'Network','Network Agent','network.png', ''), +(12,'Web Server','Web Server/Application','network.png', ''), +(13,'Sensor','Hardware Agent (Sensor)','network.png', ''), +(14,'Embedded','Embedded device running an agent','embedded.png', ''), +(15,'Android','Android agent','android.png', ''), +(16, 'VMware', 'VMware Architecture', 'so_vmware.png', ''), +(17, 'Router', 'Generic router', 'so_router.png', ''), +(18, 'Switch', 'Generic switch', 'so_switch.png', ''), +(19, 'Satellite', 'Satellite agent', 'satellite.png', ''), +(20, 'Mainframe', 'Mainframe agent', 'so_mainframe.png', ''), +(100, 'Cluster', 'Cluster agent', 'so_cluster.png', ''); UNLOCK TABLES; @@ -1187,7 +1187,7 @@ INSERT INTO `tplugin` (`id`, `name`, `description`, `max_timeout`, `max_retries` INSERT INTO `tagent_custom_fields` VALUES (1,'Serial Number',0,0,''),(2,'Department',0,0,''),(3,'Additional ID',0,0,''),(4,'eHorusID',0,0,''); -INSERT INTO `ttag` VALUES (1,'network','Network equipment','http://artica.es','',''),(2,'critical','Critical modules','','',''),(3,'dmz','DMZ Network Zone','','',''),(4,'performance','Performance anda capacity modules','','',''),(5,'configuration','','','',''); +INSERT INTO `ttag` VALUES (1,'network','Network equipment','http://artica.es','','',''),(2,'critical','Critical modules','','','',''),(3,'dmz','DMZ Network Zone','','','',''),(4,'performance','Performance anda capacity modules','','','',''),(5,'configuration','','','','',''); INSERT INTO `tevent_response` VALUES (1,'Ping to host','Ping to the agent host','ping -c 5 _agent_address_','command',0,620,500,0,'',0,90),(3,'Create incident from event','Create a incident from the event with the standard incidents system of Pandora FMS','index.php?sec=workspace&sec2=operation/incidents/incident_detail&insert_form&from_event=_event_id_','url',0,0,0,1,'',0,90),(5,'Restart agent','Restart the agent with using UDP protocol. To use this response is necessary to have installed Pandora FMS server and console in the same machine.','/usr/share/pandora_server/util/udp_client.pl _agent_address_ 41122 "REFRESH AGENT"','command',0,620,500,0,'',0,90),(6,'Ping to module agent host','Ping to the module agent host','ping -c 5 _module_address_','command',0,620,500,0,'',0,90); diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control index d468a7222a..067579d66f 100644 --- a/pandora_server/DEBIAN/control +++ b/pandora_server/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-server -Version: 7.0NG.748-200810 +Version: 7.0NG.748-200827 Architecture: all Priority: optional Section: admin diff --git a/pandora_server/DEBIAN/make_deb_package.sh b/pandora_server/DEBIAN/make_deb_package.sh index c7b8964a75..8c90388381 100644 --- a/pandora_server/DEBIAN/make_deb_package.sh +++ b/pandora_server/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.748-200810" +pandora_version="7.0NG.748-200827" package_cpan=0 package_pandora=1 diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index a1433ea98f..ce927ba86c 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -45,7 +45,7 @@ our @EXPORT = qw( # version: Defines actual version of Pandora Server for this module only my $pandora_version = "7.0NG.748"; -my $pandora_build = "200810"; +my $pandora_build = "200827"; our $VERSION = $pandora_version." ".$pandora_build; # Setup hash diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index d8e34cdfd8..fcbdfda6cb 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -1018,9 +1018,9 @@ sub pandora_execute_action ($$$$$$$$$;$) { $field15 = defined($action->{'field15'}) && $action->{'field15'} ne "" ? $action->{'field15'} : $alert->{'field15'}; } else { - $field1 = defined($alert->{'field1'}) && $alert->{'field1'} ne "" ? $alert->{'field1'} : $action->{'field1'}; - $field2 = defined($alert->{'field2'}) && $alert->{'field2'} ne "" ? $alert->{'field2'} : $action->{'field2'}; - $field3 = defined($alert->{'field3'}) && $alert->{'field3'} ne "" ? $alert->{'field3'} : $action->{'field3'}; + $field1 = defined($action->{'field1'}) && $action->{'field1'} ne "" ? $action->{'field1'} : $alert->{'field1'}; + $field2 = defined($action->{'field2'}) && $action->{'field2'} ne "" ? $action->{'field2'} : $alert->{'field2'}; + $field3 = defined($action->{'field3'}) && $action->{'field3'} ne "" ? $action->{'field3'} : $alert->{'field3'}; $field4 = defined($action->{'field4'}) && $action->{'field4'} ne "" ? $action->{'field4'} : $alert->{'field4'}; $field5 = defined($action->{'field5'}) && $action->{'field5'} ne "" ? $action->{'field5'} : $alert->{'field5'}; $field6 = defined($action->{'field6'}) && $action->{'field6'} ne "" ? $action->{'field6'} : $alert->{'field6'}; diff --git a/pandora_server/lib/PandoraFMS/DB.pm b/pandora_server/lib/PandoraFMS/DB.pm index 030ff682d4..ae07c49c96 100644 --- a/pandora_server/lib/PandoraFMS/DB.pm +++ b/pandora_server/lib/PandoraFMS/DB.pm @@ -52,8 +52,10 @@ our @EXPORT = qw( db_string db_text db_update + db_update_hash db_update_get_values set_update_agent + set_update_agentmodule get_action_id get_addr_id get_agent_addr_id @@ -912,17 +914,21 @@ sub get_db_rows_limit ($$$;@) { } ########################################################################## -## Updates agent fields using field => value -## Be careful, no filter is done. +## Updates using hashed data. +## $dbh database connector (active) +## $tablename table name +## $id hashref as { 'primary_key_id' => "value" } +## $data hashref as { 'field1' => "value", 'field2' => "value"} ########################################################################## -sub set_update_agent { - my ($dbh, $agent_id, $data) = @_; +sub db_update_hash { + my ($dbh, $tablename, $id, $data) = @_; - return undef unless (defined($agent_id) && $agent_id > 0); + return undef unless (defined($tablename) && $tablename ne ""); + return undef unless (ref($data) eq "HASH"); # Build update query - my $query = 'UPDATE tagente SET '; + my $query = 'UPDATE `'.$tablename.'` SET '; my @values; foreach my $field (keys %{$data}) { @@ -933,12 +939,50 @@ sub set_update_agent { chop($query); - $query .= ' WHERE id_agente = ? '; - push @values, $agent_id; + my @keys = keys %{$id}; + my $k = shift @keys; + + $query .= ' WHERE '.$k.' = ? '; + push @values, $id->{$k}; return db_update($dbh, $query, @values); } +########################################################################## +## Updates agent fields using field => value +## Be careful, no filter is done. +########################################################################## +sub set_update_agent { + my ($dbh, $agent_id, $data) = @_; + + return undef unless (defined($agent_id) && $agent_id > 0); + return undef unless (ref($data) eq "HASH"); + + return db_update_hash( + $dbh, + 'tagente', + { 'id_agente' => $agent_id }, + $data + ); +} + +########################################################################## +## Updates agent fields using field => value +## Be careful, no filter is done. +########################################################################## +sub set_update_agentmodule { + my ($dbh, $agentmodule_id, $data) = @_; + + return undef unless (defined($agentmodule_id) && $agentmodule_id > 0); + return undef unless (ref($data) eq "HASH"); + + return db_update_hash( + $dbh, + 'tagente_modulo', + { 'id_agente_modulo' => $agentmodule_id }, + $data + ); +} ########################################################################## ## SQL delete with a LIMIT clause. diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index ef2e975b13..44768500fc 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -632,6 +632,9 @@ sub process_module_data ($$$$$$$$$$) { # Get module parameters, matching column names in tagente_modulo my $module_conf; + + # Extra usable fields but not supported at DB level. + my $extra = {}; # Supported tags my $tags = {'name' => 0, 'data' => 0, 'type' => 0, 'description' => 0, 'max' => 0, @@ -642,7 +645,9 @@ sub process_module_data ($$$$$$$$$$) { 'unknown_instructions' => '', 'tags' => '', 'critical_inverse' => 0, 'warning_inverse' => 0, 'quiet' => 0, 'module_ff_interval' => 0, 'alert_template' => '', 'crontab' => '', 'min_ff_event_normal' => 0, 'min_ff_event_warning' => 0, 'min_ff_event_critical' => 0, 'ff_timeout' => 0, 'each_ff' => 0, 'module_parent' => 0, - 'module_parent_unlink' => 0, 'cron_interval' => 0, 'ff_type' => 0}; + 'module_parent_unlink' => 0, 'cron_interval' => 0, 'ff_type' => 0, 'min_warning_forced' => 0, 'max_warning_forced' => 0, + 'min_critical_forced' => 0, 'max_critical_forced' => 0, 'str_warning_forced' => 0, 'str_critical_forced' => 0 + }; # Other tags will be saved here $module_conf->{'extended_info'} = ''; @@ -692,7 +697,15 @@ sub process_module_data ($$$$$$$$$$) { $module_conf->{'unknown_instructions'} = '' unless defined ($module_conf->{'unknown_instructions'}); $module_conf->{'disabled_types_event'} = '' unless defined ($module_conf->{'disabled_types_event'}); $module_conf->{'module_macros'} = '' unless defined ($module_conf->{'module_macros'}); - + + # Extract extra fields. + foreach my $pk (keys %{$module_conf}) { + if ($pk =~ /_forced$/) { + $extra->{$pk} = $module_conf->{$pk}; + delete $module_conf->{$pk}; + } + } + # Get module data or create it if it does not exist my $module = get_db_single_row ($dbh, 'SELECT * FROM tagente_modulo WHERE id_agente = ? AND ' . db_text ('nombre') . ' = ?', $agent->{'id_agente'}, safe_input($module_name)); if (! defined ($module)) { @@ -825,7 +838,13 @@ sub process_module_data ($$$$$$$$$$) { # Update module configuration if in learning mode and not a policy module if ((($agent->{'modo'} eq '1') || ($agent->{'modo'} eq '2')) && $policy_linked == 0) { - update_module_configuration ($pa_config, $dbh, $module, $module_conf); + update_module_configuration( + $pa_config, + $dbh, + $module, + $module_conf, + $extra + ); } # Module disabled! @@ -898,8 +917,8 @@ sub get_macros_for_data($$){ ########################################################################## # Update module configuration in tagente_modulo if necessary. ########################################################################## -sub update_module_configuration ($$$$) { - my ($pa_config, $dbh, $module, $module_conf) = @_; +sub update_module_configuration ($$$$$) { + my ($pa_config, $dbh, $module, $module_conf, $extra) = @_; # Update if at least one of the configuration tokens has changed foreach my $conf_token ('descripcion', 'extended_info', 'module_interval') { @@ -917,6 +936,9 @@ sub update_module_configuration ($$$$) { $module->{'extended_info'} = $module_conf->{'extended_info'} if (defined($module_conf->{'extended_info'})) ; $module->{'descripcion'} = ($module_conf->{'descripcion'} eq '') ? $module->{'descripcion'} : $module_conf->{'descripcion'}; $module->{'module_interval'} = ($module_conf->{'module_interval'} eq '') ? $module->{'module_interval'} : $module_conf->{'module_interval'}; + + # Enterprise updates. + enterprise_hook('update_module_fields', [$dbh, $pa_config, $module, $extra]); } ############################################################################### diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm index aec15c9e36..c97f28f742 100644 --- a/pandora_server/lib/PandoraFMS/PluginTools.pm +++ b/pandora_server/lib/PandoraFMS/PluginTools.pm @@ -33,7 +33,7 @@ our @ISA = qw(Exporter); # version: Defines actual version of Pandora Server for this module only my $pandora_version = "7.0NG.748"; -my $pandora_build = "200810"; +my $pandora_build = "200827"; our $VERSION = $pandora_version." ".$pandora_build; our %EXPORT_TAGS = ( 'all' => [ qw() ] ); @@ -672,6 +672,24 @@ sub print_module { if (! (empty ($data->{warning_inverse}))) { $xml_module .= "\t{warning_inverse} . "]]>\n"; } + if (! (empty($data->{min_warning})) ) { + $xml_module .= "\t{min_warning_forced} . "]]>\n"; + } + if (! (empty($data->{max_warning})) ) { + $xml_module .= "\t{max_warning_forced} . "]]>\n"; + } + if (! (empty ($data->{min_critical})) ) { + $xml_module .= "\t{min_critical_forced} . "]]>\n"; + } + if (! (empty ($data->{max_critical})) ){ + $xml_module .= "\t{max_critical_forced} . "]]>\n"; + } + if (! (empty ($data->{str_warning}))) { + $xml_module .= "\t{str_warning_forced} . "]]>\n"; + } + if (! (empty ($data->{str_critical}))) { + $xml_module .= "\t{str_critical_forced} . "]]>\n"; + } if (! (empty ($data->{max}))) { $xml_module .= "\t{max} . "]]>\n"; } diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 82d39da738..3e874d9c50 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.748 -%define release 200810 +%define release 200827 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index c7dc13d9c1..820ae9b5a7 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.748 -%define release 200810 +%define release 200827 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index d7d750d630..ad366eca5a 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.748" -PI_BUILD="200810" +PI_BUILD="200827" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 019506e618..8828f1cdf8 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -35,7 +35,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.748 PS200810"; +my $version = "7.0NG.748 PS200827"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index bc15aef89c..e3ee1223ae 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.748 PS200810"; +my $version = "7.0NG.748 PS200827"; # save program name for logging my $progname = basename($0);