From 1b1bc4aa2e148a27b9f58c02aa8ae625a33647bc Mon Sep 17 00:00:00 2001 From: daniel Date: Thu, 28 Jun 2018 13:34:55 +0200 Subject: [PATCH 01/79] add new column evaluate_sla into table tservice --- pandora_console/extras/mr/18.sql | 2 + .../pandoradb_migrate_6.0_to_7.0.mysql.sql | 1 + pandora_console/include/functions_api.php | 48 ++++++++++++------- pandora_console/pandoradb.sql | 1 + 4 files changed, 34 insertions(+), 18 deletions(-) diff --git a/pandora_console/extras/mr/18.sql b/pandora_console/extras/mr/18.sql index b7e4be33e0..77be46c8e0 100644 --- a/pandora_console/extras/mr/18.sql +++ b/pandora_console/extras/mr/18.sql @@ -10,4 +10,6 @@ ALTER TABLE `tmetaconsole_agent` ADD COLUMN `cps` int NOT NULL DEFAULT '0'; ALTER TABLE `tagente_modulo` ADD COLUMN `cps` int NOT NULL DEFAULT '0'; +ALTER TABLE `tservice` ADD COLUMN `evaluate_sla` int(1) NOT NULL DEFAULT '0'; + 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 6752754a5c..c651cc7e3b 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 @@ -1269,6 +1269,7 @@ UPDATE tagente SET tagente.alias = tagente.nombre; ALTER TABLE `tservice` ADD COLUMN `quiet` tinyint(1) NOT NULL default 0; ALTER TABLE `tservice` ADD COLUMN `cps` int NOT NULL default 0; ALTER TABLE `tservice` ADD COLUMN `cascade_protection` tinyint(1) NOT NULL default 0; +ALTER TABLE `tservice` ADD COLUMN `evaluate_sla` int(1) NOT NULL default 0; -- --------------------------------------------------------------------- -- Table `tlayout` diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index ce31336723..1d98bcd51b 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -10339,10 +10339,11 @@ function api_set_create_special_day($thrash1, $thrash2, $other, $thrash3) { * * @param $thrash1 Don't use. * @param $thrash2 Don't use. - * @param array $other it's array, $other as param is ;;; + * @param array $other it's array, $other as param is ;;; * ;;;;; - * ;; - * in this order and separator char (after text ; ) and separator + * ;;; + * ;; + * in this order and separator char (after text ; ) and separator * (pass in param othermode as othermode=url_encode_separator_) * @param $thrash3 Don't use * @@ -10370,6 +10371,7 @@ function api_set_create_service($thrash1, $thrash2, $other, $thrash3) { $id_critical_module_sla = $other['data'][10]; $quiet = $other['data'][11]; $cascade_protection = $other['data'][12]; + $evaluate_sla = $other['data'][13]; if(empty($name)){ returnError('error_create_service', __('Error in creation service. No name')); @@ -10419,6 +10421,9 @@ function api_set_create_service($thrash1, $thrash2, $other, $thrash3) { if(empty($cascade_protection)){ $cascade_protection = 0; } + if(empty($evaluate_sla)){ + $evaluate_sla = 0; + } $result = services_create_service ( $name, $description, $id_group, @@ -10426,7 +10431,7 @@ function api_set_create_service($thrash1, $thrash2, $other, $thrash3) { $mode, $id_agent, $sla_interval, $sla_limit, $id_warning_module_template, $id_critical_module_template, $id_unknown_module_template, $id_critical_module_sla, - $quiet, $cascade_protection + $quiet, $cascade_protection, $evaluate_sla ); if($result){ @@ -10441,10 +10446,11 @@ function api_set_create_service($thrash1, $thrash2, $other, $thrash3) { * * @param $thrash1 service id. * @param $thrash2 Don't use. - * @param array $other it's array, $other as param is ;;;; + * @param array $other it's array, $other as param is ;;;; * ;;;;; - * ;; - * in this order and separator char (after text ; ) and separator + * ;;; + * ;; + * in this order and separator char (after text ; ) and separator * (pass in param othermode as othermode=url_encode_separator_) * @param $thrash3 Don't use * @@ -10542,6 +10548,11 @@ function api_set_update_service($thrash1, $thrash2, $other, $thrash3) { $cascade_protection = $service['cascade_protection']; } + $evaluate_sla = $other['data'][13]; + if(empty($evaluate_sla)){ + $evaluate_sla = $service['evaluate_sla']; + } + $result = services_update_service ( $id_service, $name,$description, $id_group, $critical, $warning, SECONDS_5MINUTES, $mode, @@ -10550,7 +10561,8 @@ function api_set_update_service($thrash1, $thrash2, $other, $thrash3) { $id_critical_module_template, $id_unknown_module_template, $id_critical_module_sla, - $quiet, $cascade_protection + $quiet, $cascade_protection, + $evaluate_sla ); if($result){ @@ -10565,10 +10577,10 @@ function api_set_update_service($thrash1, $thrash2, $other, $thrash3) { * * @param $thrash1 service id. * @param $thrash2 Don't use. - * @param array $other it's a json, $other as param is ;;; + * @param array $other it's a json, $other as param is ;;; * ;;;;; - * ;; - * in this order and separator char (after text ; ) and separator + * ;; + * in this order and separator char (after text ; ) and separator * (pass in param othermode as othermode=url_encode_separator_) * @param $thrash3 Don't use * @@ -10584,7 +10596,7 @@ function api_set_add_element_service($thrash1, $thrash2, $other, $thrash3) { if (is_metaconsole()) return; $id = $thrash1; - + if(empty($id)){ returnError('error_add_service_element', __('Error adding elements to service. No service id')); return; @@ -10613,7 +10625,7 @@ function api_set_add_element_service($thrash1, $thrash2, $other, $thrash3) { continue; } break; - + case 'module': $agent_id = 0; $id_service_child = 0; @@ -10622,7 +10634,7 @@ function api_set_add_element_service($thrash1, $thrash2, $other, $thrash3) { continue; } break; - + case 'service': $agent_id = 0; $id_agente_modulo = 0; @@ -10635,7 +10647,7 @@ function api_set_add_element_service($thrash1, $thrash2, $other, $thrash3) { } break; } - + $values = array( 'id_agente_modulo' => $id_agente_modulo, 'description' => $element['description'], @@ -10647,20 +10659,20 @@ function api_set_add_element_service($thrash1, $thrash2, $other, $thrash3) { 'id_agent' => $agent_id, 'id_service_child' => $id_service_child, 'id_server_meta' => 0); - + $result = db_process_sql_insert('tservice_element',$values); if($result && !$results){ $results = $result; } } } - + if($results){ returnData('string', array('type' => 'string', 'data' => 1)); } else { returnError('error_add_service_element', __('Error adding elements to service')); } - + } /** * Update a special day. And return a message with the result of the operation. diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 5b77263b6a..9fb551ad87 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -2429,6 +2429,7 @@ CREATE TABLE IF NOT EXISTS `tservice` ( `quiet` tinyint(1) NOT NULL default 0, `cps` int NOT NULL default 0, `cascade_protection` tinyint(1) NOT NULL default 0, + `evaluate_sla` int(1) NOT NULL default 0, PRIMARY KEY (`id`) ) ENGINE=InnoDB COMMENT = 'Table to define services to monitor' From f430b8998f6074c7338f2c8f0c271d829f40c2b0 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Tue, 3 Jul 2018 12:01:37 +0200 Subject: [PATCH 02/79] Added DB changes to support ProvisioningServer 2 --- pandora_console/extras/mr/18.sql | 36 +++++++++++++++ .../pandoradb_migrate_6.0_to_7.0.mysql.sql | 44 +++++++++++++++++++ pandora_console/pandoradb.sql | 43 ++++++++++++++++++ 3 files changed, 123 insertions(+) diff --git a/pandora_console/extras/mr/18.sql b/pandora_console/extras/mr/18.sql index b7e4be33e0..e82f940bfb 100644 --- a/pandora_console/extras/mr/18.sql +++ b/pandora_console/extras/mr/18.sql @@ -10,4 +10,40 @@ ALTER TABLE `tmetaconsole_agent` ADD COLUMN `cps` int NOT NULL DEFAULT '0'; ALTER TABLE `tagente_modulo` ADD COLUMN `cps` int NOT NULL DEFAULT '0'; +CREATE TABLE `tautoconfig` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(100) NOT NULL, + `order` int(11) NOT NULL DEFAULT '0', + `description` text, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + +CREATE TABLE `tautoconfig_rules` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `id_autoconfig` int(10) unsigned NOT NULL, + `order_by` int(11) NOT NULL DEFAULT '0', + `operator` enum('AND','OR') DEFAULT 'OR', + `type` enum('alias','ip-range','group','os','custom-field','script') DEFAULT 'alias', + `value` varchar(100) NOT NULL DEFAULT '', + `custom` varchar(100) NOT NULL DEFAULT '', + PRIMARY KEY (`id`), + KEY `id_autoconfig` (`id_autoconfig`), + CONSTRAINT `tautoconfig_rules_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + +CREATE TABLE `tautoconfig_actions` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `id_autoconfig` int(10) unsigned NOT NULL, + `order` int(11) NOT NULL DEFAULT '0', + `action_type` enum('set-group', 'set-secondary-group','apply-policy','apply-all-policies','launch-event','launch-alert-action','raw-config') DEFAULT 'launch-event', + `value` varchar(100) NOT NULL DEFAULT '', + `custom` varchar(100) NOT NULL DEFAULT '', + PRIMARY KEY (`id`), + KEY `id_autoconfig` (`id_autoconfig`), + CONSTRAINT `tautoconfig_action_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + 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 6752754a5c..19add1b91a 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 @@ -1667,3 +1667,47 @@ create table IF NOT EXISTS `tmetaconsole_agent_secondary_group`( ALTER TABLE tagente ADD COLUMN `update_secondary_groups` tinyint(1) NOT NULL default '0'; ALTER TABLE tmetaconsole_agent ADD COLUMN `update_secondary_groups` tinyint(1) NOT NULL default '0'; ALTER TABLE tusuario_perfil ADD COLUMN `is_secondary` tinyint(1) NOT NULL default '0'; + +-- --------------------------------------------------------------------- +-- Table `tautoconfig` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tautoconfig` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(100) NOT NULL, + `order` int(11) NOT NULL DEFAULT '0', + `description` text, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- --------------------------------------------------------------------- +-- Table `tautoconfig_rules` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tautoconfig_rules` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `id_autoconfig` int(10) unsigned NOT NULL, + `order_by` int(11) NOT NULL DEFAULT '0', + `operator` enum('AND','OR') DEFAULT 'OR', + `type` enum('alias','ip-range','group','os','custom-field','script') DEFAULT 'alias', + `value` varchar(100) NOT NULL DEFAULT '', + `custom` varchar(100) NOT NULL DEFAULT '', + PRIMARY KEY (`id`), + KEY `id_autoconfig` (`id_autoconfig`), + CONSTRAINT `tautoconfig_rules_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- --------------------------------------------------------------------- +-- Table `tautoconfig_actions` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tautoconfig_actions` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `id_autoconfig` int(10) unsigned NOT NULL, + `order` int(11) NOT NULL DEFAULT '0', + `action_type` enum('set-group', 'set-secondary-group','apply-policy','apply-all-policies','launch-event','launch-alert-action','raw-config') DEFAULT 'launch-event', + `value` varchar(100) NOT NULL DEFAULT '', + `custom` varchar(100) NOT NULL DEFAULT '', + PRIMARY KEY (`id`), + KEY `id_autoconfig` (`id_autoconfig`), + CONSTRAINT `tautoconfig_action_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 5b77263b6a..a06099511b 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -3195,3 +3195,46 @@ create table IF NOT EXISTS `tmetaconsole_agent_secondary_group`( ON DELETE CASCADE ) engine=InnoDB DEFAULT CHARSET=utf8; +-- --------------------------------------------------------------------- +-- Table `tautoconfig` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tautoconfig` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(100) NOT NULL, + `order` int(11) NOT NULL DEFAULT '0', + `description` text, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- --------------------------------------------------------------------- +-- Table `tautoconfig_rules` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tautoconfig_rules` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `id_autoconfig` int(10) unsigned NOT NULL, + `order_by` int(11) NOT NULL DEFAULT '0', + `operator` enum('AND','OR') DEFAULT 'OR', + `type` enum('alias','ip-range','group','os','custom-field','script') DEFAULT 'alias', + `value` varchar(100) NOT NULL DEFAULT '', + `custom` varchar(100) NOT NULL DEFAULT '', + PRIMARY KEY (`id`), + KEY `id_autoconfig` (`id_autoconfig`), + CONSTRAINT `tautoconfig_rules_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- --------------------------------------------------------------------- +-- Table `tautoconfig_actions` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tautoconfig_actions` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `id_autoconfig` int(10) unsigned NOT NULL, + `order` int(11) NOT NULL DEFAULT '0', + `action_type` enum('set-group', 'set-secondary-group','apply-policy','apply-all-policies','launch-event','launch-alert-action','raw-config') DEFAULT 'launch-event', + `value` varchar(100) NOT NULL DEFAULT '', + `custom` varchar(100) NOT NULL DEFAULT '', + PRIMARY KEY (`id`), + KEY `id_autoconfig` (`id_autoconfig`), + CONSTRAINT `tautoconfig_action_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + From c800061bc23673dd285242b54f4170b9fa300ac3 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 4 Jul 2018 18:39:06 +0200 Subject: [PATCH 03/79] Autoconfiguration v1 --- pandora_console/extras/mr/18.sql | 10 +++---- .../pandoradb_migrate_6.0_to_7.0.mysql.sql | 10 +++---- pandora_console/pandoradb.sql | 10 +++---- pandora_server/lib/PandoraFMS/Config.pm | 5 ++++ pandora_server/lib/PandoraFMS/DB.pm | 30 +++++++++++++++++++ pandora_server/lib/PandoraFMS/DataServer.pm | 6 ++++ pandora_server/lib/PandoraFMS/PluginTools.pm | 12 ++++++++ 7 files changed, 68 insertions(+), 15 deletions(-) diff --git a/pandora_console/extras/mr/18.sql b/pandora_console/extras/mr/18.sql index e82f940bfb..310e42c1c8 100644 --- a/pandora_console/extras/mr/18.sql +++ b/pandora_console/extras/mr/18.sql @@ -25,8 +25,8 @@ CREATE TABLE `tautoconfig_rules` ( `order_by` int(11) NOT NULL DEFAULT '0', `operator` enum('AND','OR') DEFAULT 'OR', `type` enum('alias','ip-range','group','os','custom-field','script') DEFAULT 'alias', - `value` varchar(100) NOT NULL DEFAULT '', - `custom` varchar(100) NOT NULL DEFAULT '', + `value` text, + `custom` text, PRIMARY KEY (`id`), KEY `id_autoconfig` (`id_autoconfig`), CONSTRAINT `tautoconfig_rules_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE @@ -37,9 +37,9 @@ CREATE TABLE `tautoconfig_actions` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id_autoconfig` int(10) unsigned NOT NULL, `order` int(11) NOT NULL DEFAULT '0', - `action_type` enum('set-group', 'set-secondary-group','apply-policy','apply-all-policies','launch-event','launch-alert-action','raw-config') DEFAULT 'launch-event', - `value` varchar(100) NOT NULL DEFAULT '', - `custom` varchar(100) NOT NULL DEFAULT '', + `action_type` enum('set-group', 'set-secondary-group', 'apply-policiy', 'launch-script', 'launch-event', 'launch-alert-action', 'raw-config') DEFAULT 'launch-event', + `value` text, + `custom` text, PRIMARY KEY (`id`), KEY `id_autoconfig` (`id_autoconfig`), CONSTRAINT `tautoconfig_action_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE 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 19add1b91a..233f376410 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 @@ -1688,8 +1688,8 @@ CREATE TABLE IF NOT EXISTS `tautoconfig_rules` ( `order_by` int(11) NOT NULL DEFAULT '0', `operator` enum('AND','OR') DEFAULT 'OR', `type` enum('alias','ip-range','group','os','custom-field','script') DEFAULT 'alias', - `value` varchar(100) NOT NULL DEFAULT '', - `custom` varchar(100) NOT NULL DEFAULT '', + `value` text, + `custom` text, PRIMARY KEY (`id`), KEY `id_autoconfig` (`id_autoconfig`), CONSTRAINT `tautoconfig_rules_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE @@ -1702,9 +1702,9 @@ CREATE TABLE IF NOT EXISTS `tautoconfig_actions` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id_autoconfig` int(10) unsigned NOT NULL, `order` int(11) NOT NULL DEFAULT '0', - `action_type` enum('set-group', 'set-secondary-group','apply-policy','apply-all-policies','launch-event','launch-alert-action','raw-config') DEFAULT 'launch-event', - `value` varchar(100) NOT NULL DEFAULT '', - `custom` varchar(100) NOT NULL DEFAULT '', + `action_type` enum('set-group', 'set-secondary-group', 'apply-policiy', 'launch-script', 'launch-event', 'launch-alert-action', 'raw-config') DEFAULT 'launch-event', + `value` text, + `custom` text, PRIMARY KEY (`id`), KEY `id_autoconfig` (`id_autoconfig`), CONSTRAINT `tautoconfig_action_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index a06099511b..c3e6bdd9c7 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -3215,8 +3215,8 @@ CREATE TABLE IF NOT EXISTS `tautoconfig_rules` ( `order_by` int(11) NOT NULL DEFAULT '0', `operator` enum('AND','OR') DEFAULT 'OR', `type` enum('alias','ip-range','group','os','custom-field','script') DEFAULT 'alias', - `value` varchar(100) NOT NULL DEFAULT '', - `custom` varchar(100) NOT NULL DEFAULT '', + `value` text, + `custom` text, PRIMARY KEY (`id`), KEY `id_autoconfig` (`id_autoconfig`), CONSTRAINT `tautoconfig_rules_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE @@ -3229,9 +3229,9 @@ CREATE TABLE IF NOT EXISTS `tautoconfig_actions` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id_autoconfig` int(10) unsigned NOT NULL, `order` int(11) NOT NULL DEFAULT '0', - `action_type` enum('set-group', 'set-secondary-group','apply-policy','apply-all-policies','launch-event','launch-alert-action','raw-config') DEFAULT 'launch-event', - `value` varchar(100) NOT NULL DEFAULT '', - `custom` varchar(100) NOT NULL DEFAULT '', + `action_type` enum('set-group', 'set-secondary-group', 'apply-policiy', 'launch-script', 'launch-event', 'launch-alert-action', 'raw-config') DEFAULT 'launch-event', + `value` text, + `custom` text, PRIMARY KEY (`id`), KEY `id_autoconfig` (`id_autoconfig`), CONSTRAINT `tautoconfig_action_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index afe1c98dfd..88eafe660a 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -487,6 +487,8 @@ sub pandora_load_config { $pa_config->{"provisioningserver_threads"} = 1; # 7.0 720 $pa_config->{"provisioning_cache_interval"} = 300; # 7.0 720 + $pa_config->{"autoconfigure_agents"} = 1; # 7.0 725 + # Check for UID0 if ($pa_config->{"quiet"} != 0){ if ($> == 0){ @@ -1113,6 +1115,9 @@ sub pandora_load_config { elsif ($parametro =~ m/^provisioning_cache_interval\s+([0-9]*)/i){ $pa_config->{'provisioning_cache_interval'}= clean_blank($1); } + elsif ($parametro =~ m/^autoconfigure_agents\s+([0-1])/i){ + $pa_config->{'autoconfigure_agents'}= clean_blank($1); + } } # end of loop for parameter # # Set to RDBMS' standard port diff --git a/pandora_server/lib/PandoraFMS/DB.pm b/pandora_server/lib/PandoraFMS/DB.pm index 1fe1208d78..417fd9cf5d 100644 --- a/pandora_server/lib/PandoraFMS/DB.pm +++ b/pandora_server/lib/PandoraFMS/DB.pm @@ -50,6 +50,7 @@ our @EXPORT = qw( db_text db_update db_update_get_values + set_update_agent get_action_id get_addr_id get_agent_addr_id @@ -801,6 +802,35 @@ sub get_db_rows_limit ($$$;@) { return @rows; } +########################################################################## +## 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"); + + # Build update query + my $query = 'UPDATE tagente SET '; + + my @values; + foreach my $field (keys %{$data}) { + push @values, $data->{$field}; + + $query .= ' ' . $field . ' = ?,'; + } + + chop($query); + + $query .= ' WHERE id_agente = ? '; + push @values, $agent_id; + + return db_update($dbh, $query, @values); +} + + ########################################################################## ## SQL delete with a LIMIT clause. ########################################################################## diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index ef62bab200..f0c05da7a4 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -409,6 +409,12 @@ sub process_xml_data ($$$$$) { } } } + + if (defined($pa_config->{'autoconfigure_agents'}) && $pa_config->{'autoconfigure_agents'} == 1) { + # Update agent configuration once, before create agent - MetaConsole port to Node + enterprise_hook('autoconfigure_agent', [$pa_config, $agent_name, $agent_id, $data, $dbh]); + } + } # Get the data of the agent, if fail return diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm index 3afa5ff898..45ac0a6e93 100644 --- a/pandora_server/lib/PandoraFMS/PluginTools.pm +++ b/pandora_server/lib/PandoraFMS/PluginTools.pm @@ -990,6 +990,18 @@ sub init { return $conf; } +################################################################################ +# Update internal UA timeout +################################################################################ +sub ua_set_timeout { + my ($config, $timeout) = @_; + return unless looks_like_number($timeout) and $timeout > 0; + my $sys = get_sys_environment($config); + + return unless defined($sys->{'ua'}); + $sys->{'ua'}->timeout($timeout); +} + ################################################################################ # initialize plugin (basic) ################################################################################ From fb0800d37574fbc36e0b5a1e3583d30230a56924 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 4 Jul 2018 19:47:10 +0200 Subject: [PATCH 04/79] Minor fixes --- pandora_console/extras/mr/18.sql | 2 +- pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql | 2 +- pandora_console/pandoradb.sql | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pandora_console/extras/mr/18.sql b/pandora_console/extras/mr/18.sql index 310e42c1c8..26f97d8e21 100644 --- a/pandora_console/extras/mr/18.sql +++ b/pandora_console/extras/mr/18.sql @@ -22,7 +22,7 @@ CREATE TABLE `tautoconfig` ( CREATE TABLE `tautoconfig_rules` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id_autoconfig` int(10) unsigned NOT NULL, - `order_by` int(11) NOT NULL DEFAULT '0', + `order` int(11) NOT NULL DEFAULT '0', `operator` enum('AND','OR') DEFAULT 'OR', `type` enum('alias','ip-range','group','os','custom-field','script') DEFAULT 'alias', `value` text, 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 233f376410..203449fa1c 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 @@ -1685,7 +1685,7 @@ CREATE TABLE IF NOT EXISTS `tautoconfig` ( CREATE TABLE IF NOT EXISTS `tautoconfig_rules` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id_autoconfig` int(10) unsigned NOT NULL, - `order_by` int(11) NOT NULL DEFAULT '0', + `order` int(11) NOT NULL DEFAULT '0', `operator` enum('AND','OR') DEFAULT 'OR', `type` enum('alias','ip-range','group','os','custom-field','script') DEFAULT 'alias', `value` text, diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index c3e6bdd9c7..350b7dac99 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -3212,7 +3212,7 @@ CREATE TABLE IF NOT EXISTS `tautoconfig` ( CREATE TABLE IF NOT EXISTS `tautoconfig_rules` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id_autoconfig` int(10) unsigned NOT NULL, - `order_by` int(11) NOT NULL DEFAULT '0', + `order` int(11) NOT NULL DEFAULT '0', `operator` enum('AND','OR') DEFAULT 'OR', `type` enum('alias','ip-range','group','os','custom-field','script') DEFAULT 'alias', `value` text, From 23a9cf7842afa7f52981b3ea111b355b842fcbed Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 4 Jul 2018 19:47:10 +0200 Subject: [PATCH 05/79] Minor fixes --- pandora_console/extras/mr/18.sql | 4 ++-- pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql | 4 ++-- pandora_console/pandoradb.sql | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pandora_console/extras/mr/18.sql b/pandora_console/extras/mr/18.sql index 310e42c1c8..0c86b45170 100644 --- a/pandora_console/extras/mr/18.sql +++ b/pandora_console/extras/mr/18.sql @@ -22,7 +22,7 @@ CREATE TABLE `tautoconfig` ( CREATE TABLE `tautoconfig_rules` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id_autoconfig` int(10) unsigned NOT NULL, - `order_by` int(11) NOT NULL DEFAULT '0', + `order` int(11) NOT NULL DEFAULT '0', `operator` enum('AND','OR') DEFAULT 'OR', `type` enum('alias','ip-range','group','os','custom-field','script') DEFAULT 'alias', `value` text, @@ -37,7 +37,7 @@ CREATE TABLE `tautoconfig_actions` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id_autoconfig` int(10) unsigned NOT NULL, `order` int(11) NOT NULL DEFAULT '0', - `action_type` enum('set-group', 'set-secondary-group', 'apply-policiy', 'launch-script', 'launch-event', 'launch-alert-action', 'raw-config') DEFAULT 'launch-event', + `action_type` enum('set-group', 'set-secondary-group', 'apply-policy', 'launch-script', 'launch-event', 'launch-alert-action', 'raw-config') DEFAULT 'launch-event', `value` text, `custom` text, PRIMARY KEY (`id`), 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 233f376410..caaa95402d 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 @@ -1685,7 +1685,7 @@ CREATE TABLE IF NOT EXISTS `tautoconfig` ( CREATE TABLE IF NOT EXISTS `tautoconfig_rules` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id_autoconfig` int(10) unsigned NOT NULL, - `order_by` int(11) NOT NULL DEFAULT '0', + `order` int(11) NOT NULL DEFAULT '0', `operator` enum('AND','OR') DEFAULT 'OR', `type` enum('alias','ip-range','group','os','custom-field','script') DEFAULT 'alias', `value` text, @@ -1702,7 +1702,7 @@ CREATE TABLE IF NOT EXISTS `tautoconfig_actions` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id_autoconfig` int(10) unsigned NOT NULL, `order` int(11) NOT NULL DEFAULT '0', - `action_type` enum('set-group', 'set-secondary-group', 'apply-policiy', 'launch-script', 'launch-event', 'launch-alert-action', 'raw-config') DEFAULT 'launch-event', + `action_type` enum('set-group', 'set-secondary-group', 'apply-policy', 'launch-script', 'launch-event', 'launch-alert-action', 'raw-config') DEFAULT 'launch-event', `value` text, `custom` text, PRIMARY KEY (`id`), diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index c3e6bdd9c7..e00ecfc28a 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -3212,7 +3212,7 @@ CREATE TABLE IF NOT EXISTS `tautoconfig` ( CREATE TABLE IF NOT EXISTS `tautoconfig_rules` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id_autoconfig` int(10) unsigned NOT NULL, - `order_by` int(11) NOT NULL DEFAULT '0', + `order` int(11) NOT NULL DEFAULT '0', `operator` enum('AND','OR') DEFAULT 'OR', `type` enum('alias','ip-range','group','os','custom-field','script') DEFAULT 'alias', `value` text, @@ -3229,7 +3229,7 @@ CREATE TABLE IF NOT EXISTS `tautoconfig_actions` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id_autoconfig` int(10) unsigned NOT NULL, `order` int(11) NOT NULL DEFAULT '0', - `action_type` enum('set-group', 'set-secondary-group', 'apply-policiy', 'launch-script', 'launch-event', 'launch-alert-action', 'raw-config') DEFAULT 'launch-event', + `action_type` enum('set-group', 'set-secondary-group', 'apply-policy', 'launch-script', 'launch-event', 'launch-alert-action', 'raw-config') DEFAULT 'launch-event', `value` text, `custom` text, PRIMARY KEY (`id`), From 20afc77c873f47f5cf97bcd9a2454fc2d1d468f5 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 5 Jul 2018 15:01:23 +0200 Subject: [PATCH 06/79] [GeoIP] Refactorized the ip geolocalization --- pandora_server/lib/PandoraFMS/Config.pm | 6 +- pandora_server/lib/PandoraFMS/GIS.pm | 117 +-- pandora_server/lib/PandoraFMS/GeoIP.pm | 891 ------------------- pandora_server/lib/PandoraFMS/ReconServer.pm | 2 +- 4 files changed, 41 insertions(+), 975 deletions(-) delete mode 100644 pandora_server/lib/PandoraFMS/GeoIP.pm diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index b19867114f..c271ade075 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -267,7 +267,7 @@ sub pandora_load_config { $pa_config->{"activate_gis"} = 0; # 3.1 $pa_config->{"location_error"} = 50; # 3.1 $pa_config->{"recon_reverse_geolocation_mode"} = 'disabled'; # 3.1 - $pa_config->{"recon_reverse_geolocation_file"} = '/usr/local/share/GeoIP/GeoIPCity.dat'; # 3.1 + $pa_config->{"recon_reverse_geolocation_file"} = ''; # 3.1 $pa_config->{"recon_location_scatter_radius"} = 50; # 3.1 $pa_config->{"update_parent"} = 0; # 3.1 $pa_config->{"google_maps_description"} = 0; @@ -869,6 +869,10 @@ sub pandora_load_config { } #FIXME: Find a better regexp to validate the path elsif ($parametro =~ m/^recon_reverse_geolocation_file\s+(.*)/i) { $pa_config->{'recon_reverse_geolocation_file'} = clean_blank($1); + if ( ! -r $pa_config->{'recon_reverse_geolocation_file'} ) { + print "[WARN] Invalid recon_reverse_geolocation_file.\n"; + $pa_config->{'recon_reverse_geolocation_file'} = ''; + } } elsif ($parametro =~ m/^recon_location_scatter_radius\s+(\d+)/i) { $pa_config->{'recon_location_scatter_radius'} = clean_blank($1); diff --git a/pandora_server/lib/PandoraFMS/GIS.pm b/pandora_server/lib/PandoraFMS/GIS.pm index a91eee5c3d..4d7f745133 100644 --- a/pandora_server/lib/PandoraFMS/GIS.pm +++ b/pandora_server/lib/PandoraFMS/GIS.pm @@ -40,11 +40,7 @@ Exported Functions: =item * C -=item * C - -=item * C - -=item * C +=item * C =back @@ -54,15 +50,13 @@ Exported Functions: use strict; use warnings; +use Geo::IP; # Default lib dir for RPM and DEB packages use lib '/usr/lib/perl5'; use PandoraFMS::DB; use PandoraFMS::Tools; -# TODO:Test if is instaled - -my $geoIPPurePerlavilable= (eval 'use PandoraFMS::GeoIP; 1') ? 1 : 0; require Exporter; @@ -72,9 +66,7 @@ our %EXPORT_TAGS = ( 'all' => [ qw( ) ] ); our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); our @EXPORT = qw( distance_moved - get_reverse_geoip_sql - get_reverse_geoip_file - get_random_close_point + get_geoip_info ); # Some intenrnal constants @@ -137,84 +129,43 @@ sub distance_moved ($$$$$$$) { } ########################################################################## -=head2 C<< get_revesrse_geoip_sql (I<$pa_config>, I<$ip_addr>, I<$dbh>) >> +=head2 C<< get_geoip_info (I<$pa_config>, I<$address>, I<$dispersion>) >> -Gets the GIS information obtained from the B Database: +Get GIS information from the MaxMind GeoIP database on file using Geo::IP module -B: I if there is not information available or a B with: - * I - * I - * I - * I - * I - * I +B: I if there is not information available or a B with: * I * I - * I - * I =cut ########################################################################## -sub get_reverse_geoip_sql($$$) { - my ($pa_config,$ip_addr, $dbh) = @_; - - my $id_range = get_db_value($dbh, - 'SELECT ' . $RDBMS_QUOTE . 'id_range' . $RDBMS_QUOTE . ' - FROM tgis_reverse_geoip_ranges - WHERE INET_ATON(?) >= ' . $RDBMS_QUOTE . 'first_IP_decimal' . $RDBMS_QUOTE . ' - AND INET_ATON(?) <= ' . $RDBMS_QUOTE . 'last_IP_decimal ' . $RDBMS_QUOTE . ' - LIMIT 1', $ip_addr, $ip_addr); - - if (defined($id_range)) { - logger($pa_config,"Range id of '$ip_addr' is '$id_range'", 8); - my $region_info = get_db_single_row($dbh, - 'SELECT * - FROM tgis_reverse_geoip_info - WHERE ' . $RDBMS_QUOTE . 'id_range ' . $RDBMS_QUOTE . ' = ?', - $id_range); - - logger($pa_config, "region info of id_range '$id_range' is: country:".$region_info->{'country_name'}." region:".$region_info->{'region'}." city:".$region_info->{'city'}." longitude:".$region_info->{'longitude'}." latitude:".$region_info->{'longitude'}, 8); - - return $region_info; +sub get_geoip_info { + my ($pa_config, $address) = @_; + + # Return undef if feature is not activated + return undef unless ($pa_config->{'activate_gis'} && $pa_config->{'recon_reverse_geolocation_file'} ne ''); + + my $record = undef; + eval { + local $SIG{__DIE__}; + my $gi = Geo::IP->open("/tmp/pandorafms/GeoLiteCity.dat", GEOIP_STANDARD); + die("Cannot load the geoip file \"" . $pa_config->{'recon_reverse_geolocation_file'} . "\".\n") unless defined($gi); + $record = $gi->record_by_addr($address); + }; + if ($@) { + logger($pa_config, "Error giving coordinates to IP: $address. $@", 8); } - return undef; -} + return undef unless defined($record); -########################################################################## -=head2 C<< get_reverse_geoip_file (I<$pa_config>, I<$ip_addr>) >> + # Fuzzy position filter + my ($longitude, $latitude) = get_random_close_point ( + $pa_config, $record->longitude, $record->latitude + ); -Gets GIS information from the MaxMind GeooIP database on file using the -GPL perl API from MaxMindGeoIP - -B: I if there is not information available or a B with: - * I - * I - * I - * I - * I - * I - * I - * I - * I - * I - -=cut -########################################################################## -sub get_reverse_geoip_file($$) { - my ($pa_config,$ip_addr) = @_; - if ($geoIPPurePerlavilable == 1) { - my $geoipdb = PandoraFMS::GeoIP->open( $pa_config->{'recon_reverse_geolocation_file'}); - if (defined($geoipdb)) { - my $region_info = $geoipdb->get_city_record_as_hash($ip_addr); - logger($pa_config, "Region info found for IP '$ip_addr' is: country:".$region_info->{'country_name'}." region:".$region_info->{'region'}." city:".$region_info->{'city'}." longitude:".$region_info->{'longitude'}." latitude:".$region_info->{'latitude'}, 8); - return $region_info; - } - else { - logger($pa_config, "WARNING: Can't open reverse geolocation file ($pa_config->{'recon_reverse_geolocation_file'}) :$!",8); - } - } - - return undef; + return { + "longitude" => $longitude, + "latitude" => $latitude + }; } ########################################################################## @@ -228,7 +179,9 @@ Returns C<< (I<$longitude>, I<$laitiutde>) >> ########################################################################## sub get_random_close_point ($$$) { my ($pa_config, $center_longitude, $center_latitude) = @_; - + + return ($center_longitude, $center_latitude) if ($pa_config->{'recon_location_scatter_radius'} == 0); + my $sign = int rand(2); my $longitude = ($sign*(-1)+(1-$sign)) * rand($pa_config->{'recon_location_scatter_radius'}/$earth_radius_in_meters)*$to_degrees; logger($pa_config,"Longitude random offset '$longitude' ", 8); @@ -250,7 +203,7 @@ __END__ =head1 DEPENDENCIES -L, L (Optional L to use file reverse geolocation database that is faster than the SQL) +L, L, L =head1 LICENSE @@ -262,6 +215,6 @@ L, L =head1 COPYRIGHT -Copyright (c) 2005-2010 Artica Soluciones Tecnologicas S.L +Copyright (c) 2005-2018 Artica Soluciones Tecnologicas S.L =cut diff --git a/pandora_server/lib/PandoraFMS/GeoIP.pm b/pandora_server/lib/PandoraFMS/GeoIP.pm deleted file mode 100644 index 342c565179..0000000000 --- a/pandora_server/lib/PandoraFMS/GeoIP.pm +++ /dev/null @@ -1,891 +0,0 @@ -package PandoraFMS::GeoIP; - -use strict; -use FileHandle; -use File::Spec; - -BEGIN { - if ( $] >= 5.008 ) { - require Encode; - Encode->import(qw/ decode /); - } - else { - *decode = sub { - local $_ = $_[1]; - use bytes; - s/([\x80-\xff])/my $c = ord($1); - my $p = $c >= 192 ? 1 : 0; - pack ( 'CC' => 0xc2 + $p , $c & ~0x40 ); /ge; - return $_; - }; - } -}; - - -use vars qw( @ISA $VERSION @EXPORT $OPEN_TYPE_PATH ); - -use constant GEOIP_CHARSET_ISO_8859_1 => 0; -use constant GEOIP_CHARSET_UTF8 => 1; - -use constant FULL_RECORD_LENGTH => 50; -use constant GEOIP_COUNTRY_BEGIN => 16776960; -use constant RECORD_LENGTH => 3; -use constant GEOIP_STATE_BEGIN_REV0 => 16700000; -use constant GEOIP_STATE_BEGIN_REV1 => 16000000; -use constant STRUCTURE_INFO_MAX_SIZE => 20; -use constant DATABASE_INFO_MAX_SIZE => 100; -use constant GEOIP_COUNTRY_EDITION => 1; -use constant GEOIP_REGION_EDITION_REV0 => 7; -use constant GEOIP_REGION_EDITION_REV1 => 3; -use constant GEOIP_CITY_EDITION_REV0 => 6; -use constant GEOIP_CITY_EDITION_REV1 => 2; -use constant GEOIP_ORG_EDITION => 5; -use constant GEOIP_ISP_EDITION => 4; -use constant GEOIP_PROXY_EDITION => 8; -use constant GEOIP_ASNUM_EDITION => 9; -use constant GEOIP_NETSPEED_EDITION => 10; -use constant GEOIP_DOMAIN_EDITION => 11; -use constant SEGMENT_RECORD_LENGTH => 3; -use constant STANDARD_RECORD_LENGTH => 3; -use constant ORG_RECORD_LENGTH => 4; -use constant MAX_RECORD_LENGTH => 4; -use constant MAX_ORG_RECORD_LENGTH => 300; -use constant US_OFFSET => 1; -use constant CANADA_OFFSET => 677; -use constant WORLD_OFFSET => 1353; -use constant FIPS_RANGE => 360; - -$VERSION = '1.24'; - -require Exporter; -@ISA = qw(Exporter); - -# cheat --- try to load Sys::Mmap -BEGIN { - eval { - # wrap into eval again, as workaround for centos / mod_perl issue - # seems they use $@ without eval somewhere - - eval "require Sys::Mmap" - ? Sys::Mmap->import - : do { - for (qw/ PROT_READ MAP_PRIVATE MAP_SHARED /) { - no strict 'refs'; - my $unused_stub = $_; # we must use a copy - *$unused_stub = sub { die 'Sys::Mmap required for mmap support' }; - } # for - }; # do - 1; - }; # eval -} # begin - - -sub GEOIP_STANDARD(){0;} -sub GEOIP_MEMORY_CACHE(){1;} - -#sub GEOIP_CHECK_CACHE(){2;} -#sub GEOIP_INDEX_CACHE(){4;} -sub GEOIP_MMAP_CACHE(){8;} - -sub GEOIP_UNKNOWN_SPEED(){0;} -sub GEOIP_DIALUP_SPEED(){1;} -sub GEOIP_CABLEDSL_SPEED(){2;} -sub GEOIP_CORPORATE_SPEED(){3;} - -@EXPORT = qw( GEOIP_STANDARD GEOIP_MEMORY_CACHE GEOIP_MMAP_CACHE - GEOIP_UNKNOWN_SPEED GEOIP_DIALUP_SPEED GEOIP_CABLEDSL_SPEED GEOIP_CORPORATE_SPEED ); -my @countries = -(undef,"AP","EU","AD","AE","AF","AG","AI","AL","AM","AN","AO","AQ","AR","AS","AT","AU","AW","AZ","BA","BB","BD","BE","BF","BG","BH","BI","BJ","BM","BN","BO","BR","BS","BT","BV","BW","BY","BZ","CA","CC","CD","CF","CG","CH","CI","CK","CL","CM","CN","CO","CR","CU","CV","CX","CY","CZ","DE","DJ","DK","DM","DO","DZ","EC","EE","EG","EH","ER","ES","ET","FI","FJ","FK","FM","FO","FR","FX","GA","GB","GD","GE","GF","GH","GI","GL","GM","GN","GP","GQ","GR","GS","GT","GU","GW","GY","HK","HM","HN","HR","HT","HU","ID","IE","IL","IN","IO","IQ","IR","IS","IT","JM","JO","JP","KE","KG","KH","KI","KM","KN","KP","KR","KW","KY","KZ","LA","LB","LC","LI","LK","LR","LS","LT","LU","LV","LY","MA","MC","MD","MG","MH","MK","ML","MM","MN","MO","MP","MQ","MR","MS","MT","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NF","NG","NI","NL","NO","NP","NR","NU","NZ","OM","PA","PE","PF","PG","PH","PK","PL","PM","PN","PR","PS","PT","PW","PY","QA","RE","RO","RU","RW","SA","SB","SC","SD","SE","SG","SH","SI","SJ","SK","SL","SM","SN","SO","SR","ST","SV","SY","SZ","TC","TD","TF","TG","TH","TJ","TK","TM","TN","TO","TL","TR","TT","TV","TW","TZ","UA","UG","UM","US","UY","UZ","VA","VC","VE","VG","VI","VN","VU","WF","WS","YE","YT","RS","ZA","ZM","ME","ZW","A1","A2","O1","AX","GG","IM","JE","BL","MF"); -my @code3s = ( undef,"AP","EU","AND","ARE","AFG","ATG","AIA","ALB","ARM","ANT","AGO","AQ","ARG","ASM","AUT","AUS","ABW","AZE","BIH","BRB","BGD","BEL","BFA","BGR","BHR","BDI","BEN","BMU","BRN","BOL","BRA","BHS","BTN","BV","BWA","BLR","BLZ","CAN","CC","COD","CAF","COG","CHE","CIV","COK","CHL","CMR","CHN","COL","CRI","CUB","CPV","CX","CYP","CZE","DEU","DJI","DNK","DMA","DOM","DZA","ECU","EST","EGY","ESH","ERI","ESP","ETH","FIN","FJI","FLK","FSM","FRO","FRA","FX","GAB","GBR","GRD","GEO","GUF","GHA","GIB","GRL","GMB","GIN","GLP","GNQ","GRC","GS","GTM","GUM","GNB","GUY","HKG","HM","HND","HRV","HTI","HUN","IDN","IRL","ISR","IND","IO","IRQ","IRN","ISL","ITA","JAM","JOR","JPN","KEN","KGZ","KHM","KIR","COM","KNA","PRK","KOR","KWT","CYM","KAZ","LAO","LBN","LCA","LIE","LKA","LBR","LSO","LTU","LUX","LVA","LBY","MAR","MCO","MDA","MDG","MHL","MKD","MLI","MMR","MNG","MAC","MNP","MTQ","MRT","MSR","MLT","MUS","MDV","MWI","MEX","MYS","MOZ","NAM","NCL","NER","NFK","NGA","NIC","NLD","NOR","NPL","NRU","NIU","NZL","OMN","PAN","PER","PYF","PNG","PHL","PAK","POL","SPM","PCN","PRI","PSE","PRT","PLW","PRY","QAT","REU","ROU","RUS","RWA","SAU","SLB","SYC","SDN","SWE","SGP","SHN","SVN","SJM","SVK","SLE","SMR","SEN","SOM","SUR","STP","SLV","SYR","SWZ","TCA","TCD","TF","TGO","THA","TJK","TKL","TKM","TUN","TON","TLS","TUR","TTO","TUV","TWN","TZA","UKR","UGA","UM","USA","URY","UZB","VAT","VCT","VEN","VGB","VIR","VNM","VUT","WLF","WSM","YEM","YT","SRB","ZAF","ZMB","MNE","ZWE","A1","A2","O1","ALA","GGY","IMN","JEY","BLM","MAF"); -my @names = (undef,"Asia/Pacific Region","Europe","Andorra","United Arab Emirates","Afghanistan","Antigua and Barbuda", - "Anguilla","Albania","Armenia","Netherlands Antilles","Angola","Antarctica","Argentina","American Samoa", - "Austria","Australia","Aruba","Azerbaijan","Bosnia and Herzegovina","Barbados","Bangladesh","Belgium","Burkina Faso", - "Bulgaria","Bahrain","Burundi","Benin","Bermuda","Brunei Darussalam","Bolivia","Brazil","Bahamas","Bhutan","Bouvet Island", - "Botswana","Belarus","Belize","Canada","Cocos (Keeling) Islands","Congo, The Democratic Republic of the","Central African Republic", - "Congo","Switzerland","Cote D'Ivoire","Cook Islands","Chile","Cameroon","China","Colombia","Costa Rica","Cuba","Cape Verde", - "Christmas Island","Cyprus","Czech Republic","Germany","Djibouti","Denmark","Dominica","Dominican Republic","Algeria","Ecuador", - "Estonia","Egypt","Western Sahara","Eritrea","Spain","Ethiopia","Finland","Fiji","Falkland Islands (Malvinas)", - "Micronesia, Federated States of","Faroe Islands","France","France, Metropolitan","Gabon","United Kingdom","Grenada","Georgia", - "French Guiana","Ghana","Gibraltar","Greenland","Gambia","Guinea","Guadeloupe","Equatorial Guinea","Greece", - "South Georgia and the South Sandwich Islands","Guatemala","Guam","Guinea-Bissau","Guyana","Hong Kong", - "Heard Island and McDonald Islands","Honduras","Croatia","Haiti","Hungary","Indonesia","Ireland","Israel","India", - "British Indian Ocean Territory","Iraq","Iran, Islamic Republic of","Iceland","Italy","Jamaica","Jordan","Japan","Kenya", - "Kyrgyzstan","Cambodia","Kiribati","Comoros","Saint Kitts and Nevis","Korea, Democratic People's Republic of","Korea, Republic of", - "Kuwait","Cayman Islands","Kazakhstan","Lao People's Democratic Republic","Lebanon","Saint Lucia","Liechtenstein","Sri Lanka", - "Liberia","Lesotho","Lithuania","Luxembourg","Latvia","Libyan Arab Jamahiriya","Morocco","Monaco","Moldova, Republic of", - "Madagascar","Marshall Islands","Macedonia","Mali","Myanmar","Mongolia","Macau","Northern Mariana Islands","Martinique", - "Mauritania","Montserrat","Malta","Mauritius","Maldives","Malawi","Mexico","Malaysia","Mozambique","Namibia","New Caledonia", - "Niger","Norfolk Island","Nigeria","Nicaragua","Netherlands","Norway","Nepal","Nauru","Niue","New Zealand","Oman","Panama","Peru", - "French Polynesia","Papua New Guinea","Philippines","Pakistan","Poland","Saint Pierre and Miquelon","Pitcairn Islands","Puerto Rico", - "Palestinian Territory","Portugal","Palau","Paraguay","Qatar","Reunion","Romania","Russian Federation","Rwanda","Saudi Arabia", - "Solomon Islands","Seychelles","Sudan","Sweden","Singapore","Saint Helena","Slovenia","Svalbard and Jan Mayen","Slovakia","Sierra Leone", - "San Marino","Senegal","Somalia","Suriname","Sao Tome and Principe","El Salvador","Syrian Arab Republic","Swaziland", - "Turks and Caicos Islands","Chad","French Southern Territories","Togo","Thailand","Tajikistan","Tokelau","Turkmenistan","Tunisia", - "Tonga","Timor-Leste","Turkey","Trinidad and Tobago","Tuvalu","Taiwan","Tanzania, United Republic of","Ukraine","Uganda", - "United States Minor Outlying Islands","United States","Uruguay","Uzbekistan","Holy See (Vatican City State)", - "Saint Vincent and the Grenadines","Venezuela","Virgin Islands, British","Virgin Islands, U.S.","Vietnam","Vanuatu", - "Wallis and Futuna","Samoa","Yemen","Mayotte","Serbia","South Africa","Zambia","Montenegro","Zimbabwe","Anonymous Proxy", - "Satellite Provider","Other","Aland Islands","Guernsey","Isle of Man","Jersey","Saint Barthelemy","Saint Martin"); - - -# --- unfortunately we do not know the path so we assume the -# default path /usr/local/share/GeoIP -# if thats not true, you can set $Geo::IP::PurePerl::OPEN_TYPE_PATH -# -sub open_type { - my ( $class, $type, $flags ) = @_; - my %type_dat_name_mapper = ( - GEOIP_COUNTRY_EDITION() => 'GeoIP', - GEOIP_REGION_EDITION_REV0() => 'GeoIPRegion', - GEOIP_REGION_EDITION_REV1() => 'GeoIPRegion', - GEOIP_CITY_EDITION_REV0() => 'GeoIPCity', - GEOIP_CITY_EDITION_REV1() => 'GeoIPCity', - GEOIP_ISP_EDITION() => 'GeoIPISP', - GEOIP_ORG_EDITION() => 'GeoIPOrg', - GEOIP_PROXY_EDITION() => 'GeoIPProxy', - GEOIP_ASNUM_EDITION() => 'GeoIPASNum', - GEOIP_NETSPEED_EDITION() => 'GeoIPNetSpeed', - GEOIP_DOMAIN_EDITION() => 'GeoIPDomain', - ); - - # backward compatibility for 2003 databases. - $type -= 105 if $type >= 106; - - my $name = $type_dat_name_mapper{$type}; - die("Invalid database type $type\n") unless $name; - - my $mkpath = sub { File::Spec->catfile( File::Spec->rootdir, @_ ) }; - - my $path = - defined $Geo::IP::PurePerl::OPEN_TYPE_PATH - ? $Geo::IP::PurePerl::OPEN_TYPE_PATH - : do { - $^O eq 'NetWare' - ? $mkpath->(qw/ etc GeoIP /) - : do { - $^O eq 'MSWin32' - ? $mkpath->(qw/ GeoIP /) - : $mkpath->(qw/ usr local share GeoIP /); - } - }; - - my $filename = File::Spec->catfile( $path, $name . '.dat' ); - return $class->open( $filename, $flags ); -} - - -sub open { - die "Geo::IP::PurePerl::open() requires a path name" - unless( @_ > 1 and $_[1] ); - my ($class, $db_file, $flags) = @_; - my $fh = FileHandle->new; - my $gi; - CORE::open $fh, $db_file or die "Error opening $db_file"; - binmode($fh); - if ( $flags && ( $flags & ( GEOIP_MEMORY_CACHE | GEOIP_MMAP_CACHE ) ) ) { - my %self; - - if ( $flags & GEOIP_MMAP_CACHE ) { - die "Sys::Mmap required for MMAP support" - unless defined $Sys::Mmap::VERSION; - mmap( $self{buf} = undef, 0, PROT_READ, MAP_PRIVATE, $fh ) - or die "mmap: $!"; - } - else { - local $/ = undef; - $self{buf} = <$fh>; - } - $self{fh} = $fh; - $gi = bless \%self, $class; - } - else { - $gi = bless { fh => $fh }, $class; - } - $gi->_setup_segments(); - return $gi; -} - -sub new { - my ($class, $db_file, $flags) = @_; - # this will be less messy once deprecated new( $path, [$flags] ) - # is no longer supported (that's what open() is for) - - my $def_db_file = '/usr/local/share/GeoIP/GeoIP.dat'; - if ($^O eq 'NetWare') { - $def_db_file = 'sys:/etc/GeoIP/GeoIP.dat'; - } elsif ($^O eq 'MSWin32') { - $def_db_file = 'c:/GeoIP/GeoIP.dat'; - } - if ( !defined $db_file ) { - # called as new() - $db_file = $def_db_file; - } elsif ( $db_file =~ /^\d+$/ ) { - # db_file is GEOIP_MEMORY_CACHE or GEOIP_STANDARD - # called as new( $flags ) - $flags = $db_file; - $db_file = $def_db_file; - } # else called as new( $database_filename, [$flags] ); - - $class->open( $db_file, $flags ); -} - -#this function setups the database segments -sub _setup_segments { - my ($gi) = @_; - my $a = 0; - my $i = 0; - my $j = 0; - my $delim; - my $buf; - $gi->{_charset} = GEOIP_CHARSET_ISO_8859_1; - $gi->{"databaseType"} = GEOIP_COUNTRY_EDITION; - $gi->{"record_length"} = STANDARD_RECORD_LENGTH; - - my $filepos = tell($gi->{fh}); - seek($gi->{fh}, -3, 2); - for ($i = 0; $i < STRUCTURE_INFO_MAX_SIZE; $i++) { - read($gi->{fh},$delim,3); - - #find the delim - if ($delim eq (chr(255).chr(255).chr(255))) { - read($gi->{fh},$a,1); - - #read the databasetype - $gi->{"databaseType"} = ord($a); - - # backward compatibility for 2003 databases. - $gi->{databaseType} -= 105 if $gi->{databaseType} >= 106; - - #chose the database segment for the database type - #if database Type is GEOIP_REGION_EDITION then use database segment GEOIP_STATE_BEGIN - if ($gi->{"databaseType"} == GEOIP_REGION_EDITION_REV0) { - $gi->{"databaseSegments"} = GEOIP_STATE_BEGIN_REV0; - } elsif ($gi->{"databaseType"} == GEOIP_REGION_EDITION_REV1) { - $gi->{"databaseSegments"} = GEOIP_STATE_BEGIN_REV1; - } - - #if database Type is GEOIP_CITY_EDITION, GEOIP_ISP_EDITION or GEOIP_ORG_EDITION then - #read in the database segment - elsif (($gi->{"databaseType"} == GEOIP_CITY_EDITION_REV0) || - ($gi->{"databaseType"} == GEOIP_CITY_EDITION_REV1) || - ($gi->{"databaseType"} == GEOIP_ORG_EDITION) || - ($gi->{"databaseType"} == GEOIP_ASNUM_EDITION) || - ($gi->{"databaseType"} == GEOIP_ISP_EDITION)) { - $gi->{"databaseSegments"} = 0; - - #read in the database segment for the database type - read($gi->{fh},$buf,SEGMENT_RECORD_LENGTH); - for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++) { - $gi->{"databaseSegments"} += (ord(substr($buf,$j,1)) << ($j * 8)); - } - - #record length is four for ISP databases and ORG databases - #record length is three for country databases, region database and city databases - if ($gi->{"databaseType"} == GEOIP_ORG_EDITION || - $gi->{"databaseType"} == GEOIP_ISP_EDITION) { - $gi->{"record_length"} = ORG_RECORD_LENGTH; - } - } - last; - } else { - seek($gi->{fh}, -4 , 1); - } - } - #if database Type is GEOIP_COUNTY_EDITION then use database segment GEOIP_COUNTRY_BEGIN - if ($gi->{"databaseType"} == GEOIP_COUNTRY_EDITION || - $gi->{"databaseType"} == GEOIP_NETSPEED_EDITION) { - $gi->{"databaseSegments"} = GEOIP_COUNTRY_BEGIN; - } - seek($gi->{fh},$filepos,0); - return $gi; -} - -sub _seek_country { - my ($gi, $ipnum) = @_; - - my $fh = $gi->{fh}; - my $offset = 0; - - my ($x0, $x1); - - my $reclen = $gi->{"record_length"}; - - for (my $depth = 31; $depth >= 0; $depth--) { - unless ( exists $gi->{buf} ) { - seek $fh, $offset * 2 * $reclen, 0; - read $fh, $x0, $reclen; - read $fh, $x1, $reclen; - } else { - - $x0 = substr($gi->{buf}, $offset * 2 * $reclen, $reclen); - $x1 = substr($gi->{buf}, $offset * 2 * $reclen + $reclen, $reclen); - } - - $x0 = unpack("V1", $x0."\0"); - $x1 = unpack("V1", $x1."\0"); - - if ($ipnum & (1 << $depth)) { - if ($x1 >= $gi->{"databaseSegments"}) { - $gi->{last_netmask} = 32 - $depth; - return $x1; - } - $offset = $x1; - } else { - if ($x0 >= $gi->{"databaseSegments"}) { - $gi->{last_netmask} = 32 - $depth; - return $x0; - } - $offset = $x0; - } - } - - print STDERR "Error Traversing Database for ipnum = $ipnum - Perhaps database is corrupt?"; -} -sub charset { - return $_[0]->{_charset}; -} - -sub set_charset{ - my ( $gi, $charset ) = @_; - my $old_charset = $gi->{_charset}; - $gi->{_charset} = $charset; - - return $old_charset; -} - -#this function returns the country code of ip address -sub country_code_by_addr { - my ($gi, $ip_address) = @_; - return unless $ip_address =~ m!^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$!; - return $countries[$gi->id_by_addr($ip_address)]; -} - -#this function returns the country code3 of ip address -sub country_code3_by_addr { - my ($gi, $ip_address) = @_; - return unless $ip_address =~ m!^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$!; - return $code3s[$gi->id_by_addr($ip_address)]; -} - -#this function returns the name of ip address -sub country_name_by_addr { - my ($gi, $ip_address) = @_; - return unless $ip_address =~ m!^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$!; - return $names[$gi->id_by_addr($ip_address)]; -} - -sub id_by_addr { - my ($gi, $ip_address) = @_; - return unless $ip_address =~ m!^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$!; - return $gi->_seek_country(addr_to_num($ip_address)) - GEOIP_COUNTRY_BEGIN; -} - -#this function returns the country code of domain name -sub country_code_by_name { - my ($gi, $host) = @_; - my $country_id = $gi->id_by_name($host); - return $countries[$country_id]; -} - -#this function returns the country code3 of domain name -sub country_code3_by_name { - my ($gi, $host) = @_; - my $country_id = $gi->id_by_name($host); - return $code3s[$country_id]; -} - -#this function returns the country name of domain name -sub country_name_by_name { - my ($gi, $host) = @_; - my $country_id = $gi->id_by_name($host); - return $names[$country_id]; -} - -sub id_by_name { - my ($gi, $host) = @_; - my $ip_address; - if ($host =~ m!^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$!) { - $ip_address = $host; - } else { - $ip_address = join('.',unpack('C4',(gethostbyname($host))[4])); - } - return unless $ip_address; - return $gi->_seek_country(addr_to_num($ip_address)) - GEOIP_COUNTRY_BEGIN; -} - -#this function returns the city record as a array -sub get_city_record { - my ($gi, $host) = @_; - my $ip_address = $gi->get_ip_address($host); - return unless $ip_address; - my $record_buf; - my $record_buf_pos; - my $char; - my $metroarea_combo; - my $record_country_code = ""; - my $record_country_code3 = ""; - my $record_country_name = ""; - my $record_region = ""; - my $record_city = ""; - my $record_postal_code = ""; - my $record_latitude = ""; - my $record_longitude = ""; - my $record_metro_code = ""; - my $record_area_code = ""; - my $str_length = 0; - my $i; - my $j; - - #lookup the city - my $seek_country = $gi->_seek_country(addr_to_num($ip_address)); - if ($seek_country == $gi->{"databaseSegments"}) { - return; - } - #set the record pointer to location of the city record - my $record_pointer = $seek_country + (2 * $gi->{"record_length"} - 1) * $gi->{"databaseSegments"}; - - unless ( exists $gi->{buf} ) { - seek( $gi->{"fh"}, $record_pointer, 0 ); - read( $gi->{"fh"}, $record_buf, FULL_RECORD_LENGTH ); - $record_buf_pos = 0; - } - else { - $record_buf = substr($gi->{buf}, $record_pointer, FULL_RECORD_LENGTH); - $record_buf_pos = 0; - } - - #get the country - $char = ord(substr($record_buf,$record_buf_pos,1)); - $record_country_code = $countries[$char];#get the country code - $record_country_code3 = $code3s[$char];#get the country code with 3 letters - $record_country_name = $names[$char];#get the country name - $record_buf_pos++; - - #get the region - $char = ord(substr($record_buf,$record_buf_pos+$str_length,1)); - while ($char != 0) { - $str_length++;#get the length of string - $char = ord(substr($record_buf,$record_buf_pos+$str_length,1)); - } - if ($str_length > 0) { - $record_region = substr($record_buf,$record_buf_pos,$str_length); - } - $record_buf_pos += $str_length + 1; - $str_length = 0; - - #get the city - $char = ord(substr($record_buf,$record_buf_pos+$str_length,1)); - while ($char != 0) { - $str_length++;#get the length of string - $char = ord(substr($record_buf,$record_buf_pos+$str_length,1)); - } - if ($str_length > 0) { - $record_city = substr($record_buf,$record_buf_pos,$str_length); - } - $record_buf_pos += $str_length + 1; - $str_length = 0; - - #get the postal code - $char = ord(substr($record_buf,$record_buf_pos+$str_length,1)); - while ($char != 0) { - $str_length++;#get the length of string - $char = ord(substr($record_buf,$record_buf_pos+$str_length,1)); - } - if ($str_length > 0) { - $record_postal_code = substr($record_buf,$record_buf_pos,$str_length); - } - $record_buf_pos += $str_length + 1; - $str_length = 0; - my $latitude = 0; - my $longitude = 0; - - #get the latitude - for ($j = 0;$j < 3; ++$j) { - $char = ord(substr($record_buf,$record_buf_pos++,1)); - $latitude += ($char << ($j * 8)); - } - $record_latitude = ($latitude/10000) - 180; - - #get the longitude - for ($j = 0;$j < 3; ++$j) { - $char = ord(substr($record_buf,$record_buf_pos++,1)); - $longitude += ($char << ($j * 8)); - } - $record_longitude = ($longitude/10000) - 180; - - #get the metro code and the area code - if (GEOIP_CITY_EDITION_REV1 == $gi->{"databaseType"}) { - $metroarea_combo = 0; - if ($record_country_code eq "US") { - #if the country is US then read the metro area combo - for ($j = 0;$j < 3;++$j) { - $char = ord(substr($record_buf,$record_buf_pos++,1)); - $metroarea_combo += ($char << ($j * 8)); - } - #split the metro area combo into the metro code and the area code - $record_metro_code = int($metroarea_combo/1000); - $record_area_code = $metroarea_combo%1000; - } - } - - # the pureperl API must convert the string by themself to UTF8 - # using Encode for perl >= 5.008 otherwise use it's own iso-8859-1 to utf8 converter - $record_city = decode( 'iso-8859-1' => $record_city ) - if $gi->charset == GEOIP_CHARSET_UTF8; - - return ($record_country_code,$record_country_code3,$record_country_name,$record_region,$record_city,$record_postal_code,$record_latitude,$record_longitude,$record_metro_code,$record_area_code); -} - -#this function returns the city record as a hash ref -sub get_city_record_as_hash { - my ($gi, $host) = @_; - my %h; - @h{qw/ country_code country_code3 country_name - region city postal_code - latitude longitude metro_code - area_code /} - = $gi->get_city_record($host); - $h{dma_code} = $h{metro_code}; # alias for depreciated dma_code - return \%h; -} - -#this function returns isp or org of the domain name -sub org_by_name { - my ($gi, $host) = @_; - my $ip_address = $gi->get_ip_address($host); - my $seek_org = $gi->_seek_country(addr_to_num($ip_address)); - my $char; - my $org_buf; - my $org_buf_length = 0; - my $record_pointer; - - if ($seek_org == $gi->{"databaseSegments"}) { - return undef; - } - - $record_pointer = $seek_org + (2 * $gi->{"record_length"} - 1) * $gi->{"databaseSegments"}; - - unless ( exists $gi->{buf} ) { - seek( $gi->{"fh"}, $record_pointer, 0 ); - read( $gi->{"fh"}, $org_buf, MAX_ORG_RECORD_LENGTH ); - } - else { - $org_buf = substr($gi->{buf}, $record_pointer, MAX_ORG_RECORD_LENGTH ); - } - - $char = ord(substr($org_buf,0,1)); - while ($char != 0) { - $org_buf_length++; - $char = ord(substr($org_buf,$org_buf_length,1)); - } - - $org_buf = substr($org_buf, 0, $org_buf_length); - return $org_buf; -} - -#this function returns isp or org of the domain name -*isp_by_name = \*org_by_name; - -*org_by_addr = \*org_by_name; -*isp_by_addr = \*org_by_name; - -#this function returns the region -sub region_by_name { - my ($gi, $host) = @_; - my $ip_address = $gi->get_ip_address($host); - return unless $ip_address; - if ($gi->{"databaseType"} == GEOIP_REGION_EDITION_REV0) { - my $seek_region = $gi->_seek_country(addr_to_num($ip_address)) - GEOIP_STATE_BEGIN_REV0; - if ($seek_region >= 1000) { - return ("US",chr(($seek_region - 1000)/26 + 65) . chr(($seek_region - 1000)%26 + 65)); - } else { - return ($countries[$seek_region],""); - } - } elsif ($gi->{"databaseType"} == GEOIP_REGION_EDITION_REV1) { - my $seek_region = $gi->_seek_country(addr_to_num($ip_address)) - GEOIP_STATE_BEGIN_REV1; - if ($seek_region < US_OFFSET) { - return ("",""); - } elsif ($seek_region < CANADA_OFFSET) { - # return a us state - return ("US",chr(($seek_region - US_OFFSET)/26 + 65) . chr(($seek_region - US_OFFSET)%26 + 65)); - } elsif ($seek_region < WORLD_OFFSET) { - # return a canada province - return ("CA",chr(($seek_region - CANADA_OFFSET)/26 + 65) . chr(($seek_region - CANADA_OFFSET)%26 + 65)); - } else { - # return a country of the world - my $c = $countries[($seek_region - WORLD_OFFSET) / FIPS_RANGE]; - my $a2 = ($seek_region - WORLD_OFFSET) % FIPS_RANGE; - my $r = chr(($a2 / 100)+48) . chr((($a2 / 10) % 10)+48) . chr(($a2 % 10)+48); - return ($c,$r); - } - } -} - -sub get_ip_address { - my ($gi, $host) = @_; - my $ip_address; - #check if host is ip address - if ($host =~ m!^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$!) { - #host is ip address - $ip_address = $host; - } else { - #host is domain name do a dns lookup - $ip_address = join('.',unpack('C4',(gethostbyname($host))[4])); - } - return $ip_address; -} - -sub addr_to_num { unpack( N => pack( C4 => split( /\./, $_[0] ) ) ) } -sub num_to_addr { join q{.}, unpack( C4 => pack( N => $_[0] ) ) } - -sub database_info { - my $gi = shift; - my $i = 0; - my $buf; - my $retval; - my $hasStructureInfo; - seek($gi->{fh},-3,2); - for (my $i = 0;$i < STRUCTURE_INFO_MAX_SIZE;$i++) { - read($gi->{fh},$buf,3); - if ($buf eq (chr(255) . chr(255) . chr(255))) { - $hasStructureInfo = 1; - last; - } - seek($gi->{fh},-4,1); - } - if ($hasStructureInfo == 1) { - seek($gi->{fh},-6,1); - } else { - # no structure info, must be pre Sep 2002 database, go back to - seek($gi->{fh},-3,2); - } - for (my $i = 0;$i < DATABASE_INFO_MAX_SIZE;$i++){ - read($gi->{fh},$buf,3); - if ($buf eq (chr(0). chr(0). chr(0))){ - read($gi->{fh},$retval,$i); - return $retval; - } - seek($gi->{fh},-4,1); - } - return ""; -} - -sub range_by_ip { - my $gi = shift; - my $ipnum = addr_to_num( shift ); - my $c = $gi->_seek_country( $ipnum ); - my $nm = $gi->last_netmask; - my $m = 0xffffffff << 32 - $nm; - my $left_seek_num = $ipnum & $m; - my $right_seek_num = $left_seek_num + ( 0xffffffff & ~$m ); - - while ( $left_seek_num != 0 - and $c == $gi->_seek_country( $left_seek_num - 1) ) { - my $lm = 0xffffffff << 32 - $gi->last_netmask; - $left_seek_num = ( $left_seek_num - 1 ) & $lm; - } - while ( $right_seek_num != 0xffffffff - and $c == $gi->_seek_country( $right_seek_num + 1 ) ) { - my $rm = 0xffffffff << 32 - $gi->last_netmask; - $right_seek_num = ( $right_seek_num + 1 ) & $rm; - $right_seek_num += ( 0xffffffff & ~$rm ); - } - return ( num_to_addr($left_seek_num), num_to_addr($right_seek_num) ); -} - -sub netmask { $_[0]->{last_netmask} = $_[1] } - -sub last_netmask { - return $_[0]->{last_netmask}; -} - -sub DESTROY { - my $gi = shift; - - if ( exists $gi->{buf} && $gi->{flags} && ( $gi->{flags} & GEOIP_MMAP_CACHE ) ) { - munmap( $gi->{buf} ) or die "munmap: $!"; - delete $gi->{buf}; - } -} -1; -__END__ - -=head1 NAME - -Geo::IP::PurePerl - Look up country by IP Address - -=head1 SYNOPSIS - - use Geo::IP::PurePerl; - - my $gi = Geo::IP::PurePerl->new(GEOIP_STANDARD); - - # look up IP address '24.24.24.24' - my $country = $gi->country_code_by_addr('24.24.24.24'); - $country = $gi->country_code_by_name('yahoo.com'); - # $country is equal to "US" - -=head1 DESCRIPTION - -This module uses a file based database. This database simply contains -IP blocks as keys, and countries as values. This database is more -complete and accurate than reverse DNS lookups. - -This module can be used to automatically select the geographically closest mirror, -to analyze your web server logs -to determine the countries of your visiters, for credit card fraud -detection, and for software export controls. - -=head1 IP ADDRESS TO COUNTRY DATABASES - -The database is available for free, updated monthly: - - http://www.maxmind.com/download/geoip/database/ - -This free database is similar to the database contained in IP::Country, -as well as many paid databases. It uses ARIN, RIPE, APNIC, and LACNIC -whois to obtain the IP->Country mappings. - -If you require greater accuracy, MaxMind offers a paid database -on a paid subscription basis from http://www.maxmind.com/app/country - -=head1 CLASS METHODS - -=over 4 - -=item $gi = Geo::IP->new( [$flags] ); - -Constructs a new Geo::IP object with the default database located inside your system's -I, typically I. - -Flags can be set to either GEOIP_STANDARD, or for faster performance -(at a cost of using more memory), GEOIP_MEMORY_CACHE. -The default flag is GEOIP_STANDARD (uses less memory, but runs slower). - -=item $gi = Geo::IP->new( $database_filename ); - -Calling the C constructor in this fashion was was deprecated after version -0.26 in order to make the XS and pure perl interfaces more similar. Use the -C constructor (below) if you need to specify a path. Eventually, this -means of calling C will no longer be supported. - -Flags can be set to either GEOIP_STANDARD, or for faster performance -(at a cost of using more memory), GEOIP_MEMORY_CACHE. - -=item $gi = Geo::IP->open( $database_filename, [$flags] ); - -Constructs a new Geo::IP object with the database located at C<$database_filename>. -The default flag is GEOIP_STANDARD (uses less memory, but runs slower). - -=back - -=head1 OBJECT METHODS - -=over 4 - -=item $code = $gi->country_code_by_addr( $ipaddr ); - -Returns the ISO 3166 country code for an IP address. - -=item $code = $gi->country_code_by_name( $ipname ); - -Returns the ISO 3166 country code for a hostname. - -=item $code = $gi->country_code3_by_addr( $ipaddr ); - -Returns the 3 letter country code for an IP address. - -=item $code = $gi->country_code3_by_name( $ipname ); - -Returns the 3 letter country code for a hostname. - -=item $name = $gi->country_name_by_addr( $ipaddr ); - -Returns the full country name for an IP address. - -=item $name = $gi->country_name_by_name( $ipname ); - -Returns the full country name for a hostname. - -=item $info = $gi->database_info; - -Returns database string, includes version, date, build number and copyright notice. - -=item $old_charset = $gi->set_charset( $charset ); - -Set the charset for the city name - defaults to GEOIP_CHARSET_ISO_8859_1. To -set UTF8, pass GEOIP_CHARSET_UTF8 to set_charset. - -=item $charset = $gi->charset; - -Gets the currently used charset. - -=item $netmask = $gi->last_netmask; - -Gets netmask of network block from last lookup. - -=item $gi->netmask(12); - -Sets netmask for the last lookup - -=item my ( $from, $to ) = $gi->range_by_ip('24.24.24.24'); - -Returns the start and end of the current network block. The method tries to join several continous netblocks. - -=item @data = $gi->get_city_record( $addr ); - - Returns a array filled with information about the city. - - my ($country_code,$country_code3,$country_name,$region,$city,$postal_code,$latitude,$longitude,$metro_code,$area_code ) = $gi->get_city_record($addr); - -=item $href = get_city_record_as_hash( $addr ); - - Returns a hashref filled with information about the city. - - my $href = $gi->get_city_record_as_hash($addr); - -The hash include the following keys: -country_code, country_code3, country_name, region, city, postal_code, latitude, longitude, metro_code, area_code - -=item $gi->isp_by_addr($addr) - - Returns the isp name for an ipaddress - -=item $gi->isp_by_name($name) - - Returns the isp name for a hostname - -=item $gi->org_by_addr($addr) - - Returns the organisation name for an ipaddress - -=item $gi->org_by_name($name) - - Returns the organisation name for a hostname - -=back - -=head1 MAILING LISTS AND CVS - -Are available from SourceForge, see -http://sourceforge.net/projects/geoip/ - -=head1 VERSION - -1.23 - -=head1 SEE ALSO - -Geo::IP - this now has the PurePerl code merged it, so it supports -both XS and Pure Perl implementations. The XS implementation is -a wrapper around the GeoIP C API, which is much faster than the -Pure Perl API. - -=head1 AUTHOR - -Copyright (c) 2008 MaxMind Inc - -All rights reserved. This package is free software; it is licensed -under the GPL. - -=cut diff --git a/pandora_server/lib/PandoraFMS/ReconServer.pm b/pandora_server/lib/PandoraFMS/ReconServer.pm index 0d00e3c9ca..88aceebb2b 100644 --- a/pandora_server/lib/PandoraFMS/ReconServer.pm +++ b/pandora_server/lib/PandoraFMS/ReconServer.pm @@ -36,7 +36,7 @@ use PandoraFMS::Tools; use PandoraFMS::DB; use PandoraFMS::Core; use PandoraFMS::ProducerConsumerServer; -use PandoraFMS::GIS qw(get_reverse_geoip_sql get_reverse_geoip_file get_random_close_point); +use PandoraFMS::GIS; use PandoraFMS::Recon::Base; # Patched Nmap::Parser. See http://search.cpan.org/dist/Nmap-Parser/. From 219988018fb6db2c4790caad56217a4858948b4c Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 5 Jul 2018 15:19:13 +0200 Subject: [PATCH 07/79] [GeoIP] Modified server conf file to remove recon_reverse_geolocation_mode --- pandora_server/FreeBSD/pandora_server.conf.new | 11 +---------- pandora_server/NetBSD/pandora_server.conf.new | 11 +---------- pandora_server/conf/pandora_server.conf.new | 11 +---------- pandora_server/conf/pandora_server.conf.windows | 11 +---------- pandora_server/lib/PandoraFMS/Config.pm | 4 ---- pandora_server/util/gis.README | 3 --- 6 files changed, 4 insertions(+), 47 deletions(-) diff --git a/pandora_server/FreeBSD/pandora_server.conf.new b/pandora_server/FreeBSD/pandora_server.conf.new index af51a7ce6b..93d9abbc75 100644 --- a/pandora_server/FreeBSD/pandora_server.conf.new +++ b/pandora_server/FreeBSD/pandora_server.conf.new @@ -330,18 +330,9 @@ restart_delay 60 #location_error 50 -# Recon reverse geolocation mode [disabled, sql, file] -# disabled The recon task doesn't try to geolocate the ip discovered. -# sql The recon task trys to query the SQL database to geolocate the -# ip discovered -# file The recon task trys to find the geolocation information of the -# ip discovered in the file indicated in the -# recon_reverse_geolocation_file parameter - -# recon_reverse_geolocation_mode disabled - # Recon reverse geolocation file. This is the database with the reverse # geolocation information using MaxMind GPL GeoLiteCity.dat format). +# Comment it to disable the IP geolocation on agent creation. #recon_reverse_geolocation_file /usr/local/share/GeoIP/GeoIPCity.dat diff --git a/pandora_server/NetBSD/pandora_server.conf.new b/pandora_server/NetBSD/pandora_server.conf.new index ac0db6f2b1..5f38a678da 100644 --- a/pandora_server/NetBSD/pandora_server.conf.new +++ b/pandora_server/NetBSD/pandora_server.conf.new @@ -325,18 +325,9 @@ restart_delay 60 #location_error 50 -# Recon reverse geolocation mode [disabled, sql, file] -# disabled The recon task doesn't try to geolocate the ip discovered. -# sql The recon task trys to query the SQL database to geolocate the -# ip discovered -# file The recon task trys to find the geolocation information of the -# ip discovered in the file indicated in the -# recon_reverse_geolocation_file parameter - -# recon_reverse_geolocation_mode disabled - # Recon reverse geolocation file. This is the database with the reverse # geolocation information using MaxMind GPL GeoLiteCity.dat format). +# Comment it to disable the IP geolocation on agent creation. #recon_reverse_geolocation_file /usr/local/share/GeoIP/GeoIPCity.dat diff --git a/pandora_server/conf/pandora_server.conf.new b/pandora_server/conf/pandora_server.conf.new index 9d0bc569e2..ee1b5491dc 100644 --- a/pandora_server/conf/pandora_server.conf.new +++ b/pandora_server/conf/pandora_server.conf.new @@ -342,18 +342,9 @@ restart_delay 60 #location_error 50 -# Recon reverse geolocation mode [disabled, sql, file] -# disabled The recon task doesn't try to geolocate the ip discovered. -# sql The recon task trys to query the SQL database to geolocate the -# ip discovered -# file The recon task trys to find the geolocation information of the -# ip discovered in the file indicated in the -# recon_reverse_geolocation_file parameter - -# recon_reverse_geolocation_mode disabled - # Recon reverse geolocation file. This is the database with the reverse # geolocation information using MaxMind GPL GeoLiteCity.dat format). +# Comment it to disable the IP geolocation on agent creation. #recon_reverse_geolocation_file /usr/local/share/GeoIP/GeoIPCity.dat diff --git a/pandora_server/conf/pandora_server.conf.windows b/pandora_server/conf/pandora_server.conf.windows index a1429970b1..c78fbc86c7 100644 --- a/pandora_server/conf/pandora_server.conf.windows +++ b/pandora_server/conf/pandora_server.conf.windows @@ -301,18 +301,9 @@ restart_delay 60 #location_error 50 -# Recon reverse geolocation mode [disabled, sql, file] -# disabled The recon task doesn't try to geolocate the ip discovered. -# sql The recon task trys to query the SQL database to geolocate the -# ip discovered -# file The recon task trys to find the geolocation information of the -# ip discovered in the file indicated in the -# recon_reverse_geolocation_file parameter - -# recon_reverse_geolocation_mode disabled - # Recon reverse geolocation file. This is the database with the reverse # geolocation information using MaxMind GPL GeoLiteCity.dat format). +# Comment it to disable the IP geolocation on agent creation. #recon_reverse_geolocation_file /usr/local/share/GeoIP/GeoIPCity.dat diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index c271ade075..d4767a1447 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -266,7 +266,6 @@ sub pandora_load_config { $pa_config->{"web_engine"} = 'lwp'; # 5.1 $pa_config->{"activate_gis"} = 0; # 3.1 $pa_config->{"location_error"} = 50; # 3.1 - $pa_config->{"recon_reverse_geolocation_mode"} = 'disabled'; # 3.1 $pa_config->{"recon_reverse_geolocation_file"} = ''; # 3.1 $pa_config->{"recon_location_scatter_radius"} = 50; # 3.1 $pa_config->{"update_parent"} = 0; # 3.1 @@ -863,9 +862,6 @@ sub pandora_load_config { } elsif ($parametro =~ m/^location_error\s+(\d+)/i) { $pa_config->{'location_error'} = clean_blank($1); - } - elsif ($parametro =~ m/^recon_reverse_geolocation_mode\s+(\w+)/i) { - $pa_config->{'recon_reverse_geolocation_mode'} = clean_blank($1); } #FIXME: Find a better regexp to validate the path elsif ($parametro =~ m/^recon_reverse_geolocation_file\s+(.*)/i) { $pa_config->{'recon_reverse_geolocation_file'} = clean_blank($1); diff --git a/pandora_server/util/gis.README b/pandora_server/util/gis.README index 500e768524..1d8a85c632 100644 --- a/pandora_server/util/gis.README +++ b/pandora_server/util/gis.README @@ -5,8 +5,6 @@ In order to be able to use GeoIP/GIS features of the Pandora FMS reconserver, yo http://www.maxmind.com/app/geoip_resources http://www.maxmind.com/app/installation http://www.maxmind.com/app/geolitecity - -Install manually Geo-IP-PurePerl-1.24.tar.gz This database will be used with Pandora FMS recon server for positioning detected host Systems. Check Pandora FMS documentacion for more information. @@ -15,7 +13,6 @@ Prior to use this database you need to decompress it with gzip -d and edit your activate_gis 1 recon_reverse_geolocation_file /usr/share/pandora_server/util/GeoLiteCity.dat location_error 50 - recon_reverse_geolocation_mode file recon_location_scatter_radius 1000 Get a new version at: From 3c1f192ab46d9191cd154631ac8ddb3237ba6a19 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 5 Jul 2018 16:43:41 +0200 Subject: [PATCH 08/79] [GeoIP] Added geolocalization to Recon and DataServer --- pandora_server/lib/PandoraFMS/DataServer.pm | 12 ++++++++---- pandora_server/lib/PandoraFMS/ReconServer.pm | 8 ++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index ef62bab200..524aaf0a76 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -39,6 +39,7 @@ use PandoraFMS::Tools; use PandoraFMS::DB; use PandoraFMS::Core; use PandoraFMS::ProducerConsumerServer; +use PandoraFMS::GIS; # Inherits from PandoraFMS::ProducerConsumerServer our @ISA = qw(PandoraFMS::ProducerConsumerServer); @@ -362,10 +363,13 @@ sub process_xml_data ($$$$$) { my $description = ''; $description = $data->{'description'} if (defined ($data->{'description'})); my $alias = (defined ($data->{'agent_alias'}) && $data->{'agent_alias'} ne '') ? $data->{'agent_alias'} : $data->{'agent_name'}; - - $agent_id = pandora_create_agent($pa_config, $pa_config->{'servername'}, $agent_name, $address, $group_id, $parent_id, $os, - $description, $interval, $dbh, $timezone_offset, undef, undef, undef, undef, $custom_id, $url_address, $agent_mode, $alias); - + my $location = get_geoip_info($pa_config, $address); + $agent_id = pandora_create_agent($pa_config, $pa_config->{'servername'}, $agent_name, $address, + $group_id, $parent_id, $os, + $description, $interval, $dbh, $timezone_offset, + $location->{'longitude'}, $location->{'latitude'}, undef, undef, + $custom_id, $url_address, $agent_mode, $alias + ); if (! defined ($agent_id)) { return; } diff --git a/pandora_server/lib/PandoraFMS/ReconServer.pm b/pandora_server/lib/PandoraFMS/ReconServer.pm index 88aceebb2b..f0c272b3c7 100644 --- a/pandora_server/lib/PandoraFMS/ReconServer.pm +++ b/pandora_server/lib/PandoraFMS/ReconServer.pm @@ -418,8 +418,12 @@ sub PandoraFMS::Recon::Base::create_agent($$) { # Are we filtering hosts by TCP port? return if ($self->{'recon_ports'} ne '' && $self->tcp_scan($device) == 0); - - $agent_id = pandora_create_agent($self->{'pa_config'}, $self->{'pa_config'}->{'servername'}, $host_name, $device, $self->{'group_id'}, 0, $id_os, '', 300, $self->{'dbh'}); + my $location = get_geoip_info($self->{'pa_config'}, $device); + $agent_id = pandora_create_agent($self->{'pa_config'}, $self->{'pa_config'}->{'servername'}, $host_name, $device, + $self->{'group_id'}, 0, $id_os, + '', 300, $self->{'dbh'}, undef, + $location->{'longitude'}, $location->{'latitude'} + ); return undef unless defined ($agent_id) and ($agent_id > 0); pandora_event($self->{'pa_config'}, "[RECON] New " . safe_output($self->get_device_type($device)) . " found (" . join(',', safe_output($self->get_addresses($device))) . ").", $self->{'group_id'}, $agent_id, 2, 0, 0, 'recon_host_detected', 0, $self->{'dbh'}); $agent_learning = 1; From e8666da878d816672908dcb727340c9788954fc4 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 5 Jul 2018 18:43:48 +0200 Subject: [PATCH 09/79] [GeoIP] Added Geo::IP package to Docker image --- tests/Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/Dockerfile b/tests/Dockerfile index f9efb5f2fc..14b8fd20f1 100644 --- a/tests/Dockerfile +++ b/tests/Dockerfile @@ -104,7 +104,10 @@ RUN yum install -y \ RUN wget http://rpmfind.net/linux/centos/6.9/os/i386/Packages/gettext-0.17-18.el6.i686.rpm; \ yum localinstall -y gettext-0.17-18.el6.i686.rpm; \ - rm -rf gettext-0.17-18.el6.i686.rpm; + rm -rf gettext-0.17-18.el6.i686.rpm; \ + wget http://ftp.tu-chemnitz.de/pub/linux/dag/redhat/el6/en/x86_64/rpmforge/RPMS/perl-Geo-IP-1.38-1.el6.rf.x86_64.rpm; \ + yum localinstall -y perl-Geo-IP-1.38-1.el6.rf.x86_64.rpm; \ + rm -rf perl-Geo-IP-1.38-1.el6.rf.x86_64.rpm; #Install phantomjs required for export graph pdf. RUN mkdir -p /opt/phantomjs/bin && cd /opt/phantomjs/bin; \ From 743d5a4a42920bec2b065e881529c184823841d0 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 5 Jul 2018 19:04:13 +0200 Subject: [PATCH 10/79] [GeoIP] Added Geo::IP package to server packages --- pandora_server/DEBIAN/control | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control index 07bd6fe28b..1053c33aab 100644 --- a/pandora_server/DEBIAN/control +++ b/pandora_server/DEBIAN/control @@ -6,5 +6,5 @@ Section: admin Installed-Size: 640 Maintainer: Miguel de Dios Homepage: http://pandorafms.org/ -Depends: perl (>= 5.8), libdbi-perl, libdbd-mysql-perl, libtime-format-perl, libnetaddr-ip-perl, libtime-format-perl, libxml-simple-perl, libxml-twig-perl, libhtml-parser-perl, snmp, snmpd, traceroute, xprobe2, nmap, sudo, libwww-perl, libsocket6-perl, libio-socket-inet6-perl, snmp-mibs-downloader, libjson-perl, libnet-telnet-perl, libencode-locale-perl +Depends: perl (>= 5.8), libdbi-perl, libdbd-mysql-perl, libtime-format-perl, libnetaddr-ip-perl, libtime-format-perl, libxml-simple-perl, libxml-twig-perl, libhtml-parser-perl, snmp, snmpd, traceroute, xprobe2, nmap, sudo, libwww-perl, libsocket6-perl, libio-socket-inet6-perl, snmp-mibs-downloader, libjson-perl, libnet-telnet-perl, libencode-locale-perl, libgeo-ip-perl Description: Pandora FMS is a monitoring system for big IT environments. It uses remote tests, or local agents to grab information. Pandora supports all standard OS (Linux, AIX, HP-UX, Solaris and Windows XP,2000/2003), and support multiple setups in HA enviroments. This is the server package. Server makes the remote checks and process information transfer by Pandora FMS agents to the server. diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 02b24425e5..6bb81c5011 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -30,7 +30,7 @@ Requires: perl(NetAddr::IP) net-snmp net-tools Requires: perl(IO::Socket::INET6) perl(Net::Telnet) Requires: nmap sudo perl(JSON) Requires: perl(Time::HiRes) perl(Encode::Locale) -Requires: perl perl(Sys::Syslog) perl(HTML::Entities) +Requires: perl perl(Sys::Syslog) perl(HTML::Entities) perl(Geo::IP) %description Pandora FMS is a monitoring system for big IT environments. It uses remote tests, or local agents to grab information. Pandora supports all standard OS (Linux, AIX, HP-UX, Solaris and Windows XP,2000/2003), and support multiple setups in HA enviroments. diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index a031bc94d7..c725dc7e3b 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -25,7 +25,7 @@ Requires: perl-DBI perl-DBD-mysql perl-libwww-perl Requires: perl-NetAddr-IP net-snmp net-tools perl-XML-Twig Requires: nmap sudo perl-HTML-Tree perl-XML-Simple perl-Net-Telnet Requires: perl-IO-Socket-INET6 perl-Socket6 snmp-mibs perl-JSON -Requires: perl-Encode-Locale +Requires: perl-Encode-Locale perl-Geo-IP %description From 4632be803c10b3b7519905b8f45444e9e5f0cf12 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Fri, 6 Jul 2018 09:11:55 +0200 Subject: [PATCH 11/79] [GeoIP] Added dependency to open makefile --- pandora_server/Makefile.PL | 1 + 1 file changed, 1 insertion(+) diff --git a/pandora_server/Makefile.PL b/pandora_server/Makefile.PL index 59d3e9cfee..ac1c613f3b 100644 --- a/pandora_server/Makefile.PL +++ b/pandora_server/Makefile.PL @@ -31,6 +31,7 @@ WriteMakefile( HTML::Entities => 0, IO::Socket::INET6 => 0, JSON => 0, + Geo::IP => 0, }, EXE_FILES => [ @exe_files ], PMLIBDIRS => [ 'lib' ], From f455fe3657bcc67c61e8be29c47f836d39072023 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Fri, 6 Jul 2018 13:58:45 +0200 Subject: [PATCH 12/79] [GeoIP] Added script agent_gis_update.pl --- pandora_server/util/agent_gis_update.pl | 92 +++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100755 pandora_server/util/agent_gis_update.pl diff --git a/pandora_server/util/agent_gis_update.pl b/pandora_server/util/agent_gis_update.pl new file mode 100755 index 0000000000..9f1b4c8419 --- /dev/null +++ b/pandora_server/util/agent_gis_update.pl @@ -0,0 +1,92 @@ +#!/usr/bin/perl + +############################################################################### +# Pandora FMS DB Management +############################################################################### +# Copyright (c) 2005-2018 Artica Soluciones Tecnologicas S.L +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; version 2 +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,USA +############################################################################### + +# Includes list +use strict; +use warnings; +use Time::Local; # DateTime basic manipulation +use DBI; # DB interface with MySQL +use POSIX qw(strftime); +use Time::HiRes qw(usleep); + +# Default lib dir for RPM and DEB packages +use lib '/usr/lib/perl5'; + +use PandoraFMS::Core; +use PandoraFMS::Config; +use PandoraFMS::DB; +use PandoraFMS::GIS; + +# Pandora server configuration +my %conf; + +# Pandora db handler +my $dbh; + +# FLUSH in each IO +$| = 1; + +sub print_agent_gis_update_help() { + print "Usage: $0 \n"; +} + +# Get options +my ($configuration_file) = @ARGV; +if (!defined($configuration_file) || $configuration_file eq '-h' || $configuration_file eq '--help') { + print_agent_gis_update_help(); + exit defined($configuration_file) ? 0 : 1; +} + +# Load configuration file +$conf{'pandora_path'} = $configuration_file; +$conf{'quiet'} = 0; +pandora_load_config(\%conf); + +use Data::Dumper; +#print Dumper(\%conf); + +if (!$conf{'activate_gis'} || $conf{'recon_reverse_geolocation_file'} eq '') { + print "Geolocation feature es blocked.\n"; + exit 0; +} + +# Connect to the DB +$dbh = db_connect ('mysql', $conf{'dbname'}, $conf{'dbhost'}, $conf{'dbport'}, $conf{'dbuser'}, $conf{'dbpass'}); +if (!defined($dbh)){ + print "Cannot connect to database\n"; + exit 1; +} + +# Get all agents with IP assigned +my @agents = get_db_rows($dbh, + "SELECT id_agente, direccion, alias FROM tagente WHERE disabled = 0 AND direccion <> ''" +); + +my $c_time = strftime ("%Y/%m/%d %H:%M:%S", localtime()); +foreach my $agent (@agents) { + my $location = get_geoip_info (\%conf, $agent->{'direccion'}); + if (defined($location)) { + pandora_update_gis_data(\%conf, $dbh, $agent->{'id_agente'}, $agent->{'id_agente'}, $location->{'longitude'}, $location->{'latitude'}, undef, undef, $c_time); + } +} + +print "Successfull relocation\n"; + +db_disconnect($dbh); +exit 0; \ No newline at end of file From de58fe7b900744ec84614bc45cb1615ca0a71dc0 Mon Sep 17 00:00:00 2001 From: Alejandro Gallardo Escobar Date: Fri, 6 Jul 2018 14:03:05 +0200 Subject: [PATCH 13/79] Fixes --- pandora_console/include/functions.php | 6 +----- pandora_console/include/functions_agents.php | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 95892d211a..6adcfa475b 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -1360,11 +1360,7 @@ function safe_sql_string($string) { function is_metaconsole() { global $config; - - if ($config['metaconsole']) - return true; - else - return false; + return (bool) $config['metaconsole']; } /** diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 65e27936cd..a5bb41a29a 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -799,8 +799,17 @@ function agents_common_modules ($id_agent, $filter = false, $indexed = true, $ge * * @return array An array with all agents in the group or an empty array */ -function agents_get_group_agents ($id_group = 0, $search = false, - $case = "lower", $noACL = false, $childGroups = false, $serialized = false, $separator = '|', $add_alert_bulk_op = false) { +function agents_get_group_agents ( + $id_group = 0, + $search = false, + $case = "lower", + $noACL = false, + $childGroups = false, + $serialized = false, + $separator = '|', + $add_alert_bulk_op = false, + $meta_use_main_id = false +) { global $config; @@ -951,7 +960,7 @@ function agents_get_group_agents ($id_group = 0, $search = false, $table_name = 'tmetaconsole_agent'; $fields = array( - 'id_tagente AS id_agente', + $meta_use_main_id ? 'id_agente' : 'id_tagente AS id_agente', 'alias', 'id_tmetaconsole_setup AS id_server' ); @@ -2010,7 +2019,8 @@ function agents_get_agentmodule_group ($id_module) { * @return int The group id */ function agents_get_agent_group ($id_agent) { - return (int) db_get_value ('id_grupo', 'tagente', 'id_agente', (int) $id_agent); + $table = is_metaconsole() ? "tmetaconsole_agent" : "tagente"; + return (int) db_get_value ('id_grupo', $table, 'id_agente', (int) $id_agent); } /** From 466846cae642fee1057bea9e0edbf1c8a465b75a Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Mon, 9 Jul 2018 16:34:20 +0200 Subject: [PATCH 14/79] Fixed pandora_plugins/SNMP/snmp_bandwidth.pl path --- extras/pandora_update_version.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extras/pandora_update_version.sh b/extras/pandora_update_version.sh index 6716f06701..0b22878285 100755 --- a/extras/pandora_update_version.sh +++ b/extras/pandora_update_version.sh @@ -58,7 +58,7 @@ PERL_PLUGIN_FILES="$PANDHOME_ENT/pandora_server/util/plugin/vmware-plugin.pl \ $PANDHOME_ENT/pandora_plugins/NGINX/nginx_requests_queued.pl \ $PANDHOME_ENT/pandora_plugins/Sybase/sybase_plugin.pl \ $PANDHOME_ENT/pandora_plugins/SNMP/dynamic_snmp.pl \ -$PANDHOME_ENT/pandora_plugins/SNMP/snmp_bandwith.pl \ +$PANDHOME_ENT/pandora_plugins/SNMP/snmp_bandwidth.pl \ $PANDHOME_ENT/pandora_plugins/laboratory/cacti/cacti2pandora.pl \ $PANDHOME_ENT/pandora_plugins/MarkLogic/pandora_marklogic.pl \ $PANDHOME_ENT/pandora_plugins/MySQL/pandora_mysql.pl \ From 49afdcb4fd23e31237bddf9dba17805ca912a640 Mon Sep 17 00:00:00 2001 From: artica Date: Tue, 10 Jul 2018 00:01:27 +0200 Subject: [PATCH 15/79] Auto-updated build strings. --- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 2 +- pandora_agents/unix/pandora_agent.spec | 2 +- pandora_agents/unix/pandora_agent_installer | 2 +- pandora_agents/win32/installer/pandora.mpi | 2 +- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 2 +- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.spec | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 2e7aeb7cca..bba07f146f 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.724-180709 +Version: 7.0NG.724-180710 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 b8477530bf..eca9398f80 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.724-180709" +pandora_version="7.0NG.724-180710" 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 042d378994..6c852468a5 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.724'; -use constant AGENT_BUILD => '180709'; +use constant AGENT_BUILD => '180710'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 03ea86e464..eb633f7bb2 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.724 -%define release 180709 +%define release 180710 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 ebccbe9ec7..b76760c12c 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.724 -%define release 180709 +%define release 180710 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 ce6e75b18b..7fce245fca 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.724" -PI_BUILD="180709" +PI_BUILD="180710" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 3aeb65940c..536257ae56 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{180709} +{180710} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 4c8da297e2..89b62f7f4a 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.724(Build 180709)") +#define PANDORA_VERSION ("7.0NG.724(Build 180710)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 0ca9628da2..aebac57d60 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.724(Build 180709))" + VALUE "ProductVersion", "(7.0NG.724(Build 180710))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index c711f20df3..a7f998e8f4 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.724-180709 +Version: 7.0NG.724-180710 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 65405dbb1f..58e5ce4157 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.724-180709" +pandora_version="7.0NG.724-180710" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index a1176d418c..c8cf0aec6f 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -22,7 +22,7 @@ /** * Pandora build version and version */ -$build_version = 'PC180709'; +$build_version = 'PC180710'; $pandora_version = 'v7.0NG.724'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index 4eb38e4995..ab4a76041f 100755 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -71,7 +71,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 5fd6d07a8e..b542a81a54 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.724 -%define release 180709 +%define release 180710 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index d2c440d847..a7ba6fb868 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.724 -%define release 180709 +%define release 180710 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index c02ef4fdc6..64bebb763d 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.724" -PI_BUILD="180709" +PI_BUILD="180710" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 03ef6b4a64..8e5bb55baf 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -34,7 +34,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.724 PS180709"; +my $version = "7.0NG.724 PS180710"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index cffeebc54d..abae7eb6c2 100644 --- 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.724 PS180709"; +my $version = "7.0NG.724 PS180710"; # save program name for logging my $progname = basename($0); From e24b10ad7427169bc2eecd86994ba0e1b2d90c0d Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 10 Jul 2018 14:40:48 +0200 Subject: [PATCH 16/79] fixed minor error debugPrint in function graph --- pandora_console/include/functions_graph.php | 1 - 1 file changed, 1 deletion(-) diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 66dc64e639..dd9b9b393d 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -420,7 +420,6 @@ function grafico_modulo_sparse_data( $data_module_graph['id_module_type'] == 9 || $data_module_graph['id_module_type'] == 31 || $data_module_graph['id_module_type'] == 100 ){ - html_debug_prinbt('entra'); $array_data = grafico_modulo_sparse_data_chart ( $agent_module_id, $date_array, From 73a5a639569d29303fe2eb9da5fcc871046dbd63 Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 10 Jul 2018 16:12:14 +0200 Subject: [PATCH 17/79] fixed errors delete modules sla_value and sla for services --- pandora_console/include/functions_modules.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index 59e88d9cdf..0a0660cf33 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -473,6 +473,8 @@ function modules_update_agent_module ($id, $values, */ function modules_create_agent_module ($id_agent, $name, $values = false, $disableACL = false, $tags = false) { + +html_debug_print('entra la hostia'); global $config; if (!$disableACL) { @@ -488,7 +490,7 @@ function modules_create_agent_module ($id_agent, $name, $values = false, $disabl if (mb_ereg_match('[\xc2\xa1\xc2\xbf\xc3\xb7\xc2\xba\xc2\xaa]', io_safe_output($name)) !== false) { return ERR_GENERIC; } - + html_debug_print('sigue'); if (! is_array ($values)) $values = array (); $values['nombre'] = $name; @@ -513,7 +515,7 @@ function modules_create_agent_module ($id_agent, $name, $values = false, $disabl } $id_agent_module = db_process_sql_insert ('tagente_modulo', $values); - +html_debug_print($id_agent_module); if ($id_agent_module === false) return ERR_DB; From b36bf868b1422523ca11955f9a48d0d9299b29c9 Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 10 Jul 2018 16:13:17 +0200 Subject: [PATCH 18/79] fixed minor error --- pandora_console/include/functions_modules.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index 0a0660cf33..59e88d9cdf 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -473,8 +473,6 @@ function modules_update_agent_module ($id, $values, */ function modules_create_agent_module ($id_agent, $name, $values = false, $disableACL = false, $tags = false) { - -html_debug_print('entra la hostia'); global $config; if (!$disableACL) { @@ -490,7 +488,7 @@ html_debug_print('entra la hostia'); if (mb_ereg_match('[\xc2\xa1\xc2\xbf\xc3\xb7\xc2\xba\xc2\xaa]', io_safe_output($name)) !== false) { return ERR_GENERIC; } - html_debug_print('sigue'); + if (! is_array ($values)) $values = array (); $values['nombre'] = $name; @@ -515,7 +513,7 @@ html_debug_print('entra la hostia'); } $id_agent_module = db_process_sql_insert ('tagente_modulo', $values); -html_debug_print($id_agent_module); + if ($id_agent_module === false) return ERR_DB; From aaf8173b8aa4b448b99e2c6576f4bf944ce3542b Mon Sep 17 00:00:00 2001 From: fermin831 Date: Tue, 10 Jul 2018 17:49:46 +0200 Subject: [PATCH 19/79] Added is_central_policies function --- pandora_console/include/functions.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 6adcfa475b..240b06e5b9 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -1363,6 +1363,11 @@ function is_metaconsole() { return (bool) $config['metaconsole']; } +function is_central_policies() { + global $config; + return is_metaconsole() && $config["centralized_management"]; +} + /** * Checks if current execution is under an AJAX request. * From fce669ae2118c8388791ba00ca8ac6083e69db58 Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 10 Jul 2018 17:53:19 +0200 Subject: [PATCH 20/79] fixed minor errors in legend charts --- pandora_console/include/functions.php | 42 +++++++++---------- .../include/graphs/flot/pandora.flot.js | 4 +- 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 95892d211a..7af3256453 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -3117,29 +3117,25 @@ function series_type_graph_array($data, $show_elements_graph){ } } - if(($show_elements_graph['fullscale'] || - $show_elements_graph['type_mode_graph'] ) && - strpos($key, 'baseline') === false ){ - $data_return['legend'][$key] .= - __('Min:') . remove_right_zeros( - number_format( - $value['min'], - $config['graph_precision'] - ) - ) . ' ' . - __('Max:') . remove_right_zeros( - number_format( - $value['max'], - $config['graph_precision'] - ) - ) . ' ' . - _('Avg:') . remove_right_zeros( - number_format( - $value['avg'], - $config['graph_precision'] - ) - ) . ' ' . $str; - } + $data_return['legend'][$key] .= + __('Min:') . remove_right_zeros( + number_format( + $value['min'], + $config['graph_precision'] + ) + ) . ' ' . + __('Max:') . remove_right_zeros( + number_format( + $value['max'], + $config['graph_precision'] + ) + ) . ' ' . + _('Avg:') . remove_right_zeros( + number_format( + $value['avg'], + $config['graph_precision'] + ) + ) . ' ' . $str; if($show_elements_graph['compare'] == 'overlapped' && $key == 'sum2'){ $data_return['color'][$key] = $color_series['overlapped']; diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js index ff5882b9df..226d911d6d 100644 --- a/pandora_console/include/graphs/flot/pandora.flot.js +++ b/pandora_console/include/graphs/flot/pandora.flot.js @@ -2026,13 +2026,13 @@ function pandoraFlotArea( graph_id, values, legend, avg_bigger = ""; } - data_legend[index] = + data_legend[index] = ' Min: ' + (short_data ? number_format(min_y, 0, "", short_data) : parseFloat(min_y)) + min_bigger + ' Max: ' + (short_data ? number_format(max_y, 0, "", short_data) : parseFloat(max_y)) + max_bigger + ' Avg: ' + (short_data ? number_format(avg_y, 0, "", short_data) : parseFloat(avg_y)) + avg_bigger; }); - var label_aux = legend[series.label] + data_legend[series.label]; + var label_aux = legend[series.label].split(":")[0] + data_legend[series.label]; $('#legend_' + graph_id + ' .legendLabel').eq(i).html(label_aux); } } From 1df52459a6dd82389ba1da10b976880aa167dd4d Mon Sep 17 00:00:00 2001 From: artica Date: Wed, 11 Jul 2018 00:01:28 +0200 Subject: [PATCH 21/79] Auto-updated build strings. --- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 2 +- pandora_agents/unix/pandora_agent.spec | 2 +- pandora_agents/unix/pandora_agent_installer | 2 +- pandora_agents/win32/installer/pandora.mpi | 2 +- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 2 +- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.spec | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index bba07f146f..3f2fbfc91c 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.724-180710 +Version: 7.0NG.724-180711 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 eca9398f80..cb958b98dd 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.724-180710" +pandora_version="7.0NG.724-180711" 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 6c852468a5..24eac79117 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.724'; -use constant AGENT_BUILD => '180710'; +use constant AGENT_BUILD => '180711'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index eb633f7bb2..c5d16fbd7b 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.724 -%define release 180710 +%define release 180711 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 b76760c12c..c4282ee67b 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.724 -%define release 180710 +%define release 180711 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 7fce245fca..b803d15f99 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.724" -PI_BUILD="180710" +PI_BUILD="180711" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 536257ae56..4adb76decd 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{180710} +{180711} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 89b62f7f4a..f33c75cccd 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.724(Build 180710)") +#define PANDORA_VERSION ("7.0NG.724(Build 180711)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index aebac57d60..db9ff03e77 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.724(Build 180710))" + VALUE "ProductVersion", "(7.0NG.724(Build 180711))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index a7f998e8f4..bbc8f96e38 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.724-180710 +Version: 7.0NG.724-180711 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 58e5ce4157..ec2eeab2a1 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.724-180710" +pandora_version="7.0NG.724-180711" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index c8cf0aec6f..836e55a91e 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -22,7 +22,7 @@ /** * Pandora build version and version */ -$build_version = 'PC180710'; +$build_version = 'PC180711'; $pandora_version = 'v7.0NG.724'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index ab4a76041f..fbe8f5b28e 100755 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -71,7 +71,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index b542a81a54..96cccbd07e 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.724 -%define release 180710 +%define release 180711 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index a7ba6fb868..8d19d90f49 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.724 -%define release 180710 +%define release 180711 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 64bebb763d..58c31546cc 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.724" -PI_BUILD="180710" +PI_BUILD="180711" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 8e5bb55baf..4d476cf064 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -34,7 +34,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.724 PS180710"; +my $version = "7.0NG.724 PS180711"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index abae7eb6c2..8737ca809d 100644 --- 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.724 PS180710"; +my $version = "7.0NG.724 PS180711"; # save program name for logging my $progname = basename($0); From 6d04b2450be44bfd2fe28986a756c2d4427ac22b Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 11 Jul 2018 12:33:28 +0200 Subject: [PATCH 22/79] fixed baseline graph --- pandora_console/include/functions_graph.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index dd9b9b393d..5db1914089 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -264,7 +264,9 @@ function grafico_modulo_sparse_data_chart ( $data_module_graph['id_module_type'] == 18 || $data_module_graph['id_module_type'] == 9 || $data_module_graph['id_module_type'] == 31 || - $data_module_graph['id_module_type'] == 100 ){ + $data_module_graph['id_module_type'] == 100 || + $params['baseline'] + ){ $data = db_get_all_rows_filter ( 'tagente_datos', From 62ed69af90b0ba94994a2f86183a755e9440c57c Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Wed, 11 Jul 2018 13:07:37 +0200 Subject: [PATCH 23/79] Fix the service cascade protection. --- pandora_server/lib/PandoraFMS/Core.pm | 40 ++++++++----------- .../lib/PandoraFMS/PredictionServer.pm | 2 +- 2 files changed, 18 insertions(+), 24 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 12ac711da5..19caec0169 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -352,16 +352,6 @@ sub pandora_generate_alerts ($$$$$$$$;$$$) { return; } - if ($agent->{'cps'} > 0) { - logger($pa_config, "Generate Alert. The agent '" . $agent->{'nombre'} . "' is in quiet mode by cascade protection services.", 10); - return; - } - - if ($module->{'cps'} > 0) { - logger($pa_config, "Generate Alert. The module '" . $module->{'nombre'} . "' is in quiet mode by cascade protection services.", 10); - return; - } - # Do not generate alerts for disabled groups if (is_group_disabled ($dbh, $agent->{'id_grupo'})) { return; @@ -1649,7 +1639,7 @@ sub pandora_process_module ($$$$$$$$$;$) { } # Generate alerts - if (pandora_inhibit_alerts ($pa_config, $agent, $dbh, 0) == 0) { + if (pandora_inhibit_alerts ($pa_config, $agent, $dbh, 0) == 0 && pandora_cps_enabled($agent, $module) == 0) { pandora_generate_alerts ($pa_config, $processed_data, $status, $agent, $module, $utimestamp, $dbh, $timestamp, $extra_macros, $last_data_value); } else { @@ -3140,11 +3130,6 @@ sub pandora_event ($$$$$$$$$$;$$$$$$$$$) { logger($pa_config, "Generate Event. The agent '" . $agent->{'nombre'} . "' is in quiet mode.", 10); return; } - - if (defined ($agent) && $agent->{'cps'} > 0) { - logger($pa_config, "Generate Event. The agent '" . $agent->{'nombre'} . "' is in quiet mode by cascade protection services.", 10); - return; - } } my $module = undef; @@ -3154,11 +3139,6 @@ sub pandora_event ($$$$$$$$$$;$$$$$$$$$) { logger($pa_config, "Generate Event. The module '" . $module->{'nombre'} . "' is in quiet mode.", 10); return; } - - if (defined ($module) && $module->{'cps'} > 0) { - logger($pa_config, "Generate Event. The module '" . $module->{'nombre'} . "' is in quiet mode by cascade protection services.", 10); - return; - } } # Get module tags @@ -4289,6 +4269,20 @@ sub pandora_inhibit_alerts { return pandora_inhibit_alerts ($pa_config, $agent, $dbh, $depth + 1); } +########################################################################## +# Returns 1 if service cascade protection is enabled for the given +# agent/module, 0 otherwise. +########################################################################## +sub pandora_cps_enabled($$) { + my ($agent, $module) = @_; + + return 1 if ($agent->{'cps'} > 0); + + return 1 if ($module->{'cps'} > 0); + + return 0; +} + ########################################################################## =head2 C<< save_agent_position (I<$pa_config>, I<$current_longitude>, I<$current_latitude>, I<$current_altitude>, I<$agent_id>, I<$dbh>, [I<$start_timestamp>], [I<$description>]) >> @@ -4925,7 +4919,7 @@ sub pandora_module_unknown ($$) { pandora_mark_agent_for_module_update ($dbh, $module->{'id_agente'}); # Generate alerts - if (pandora_inhibit_alerts ($pa_config, $agent, $dbh, 0) == 0) { + if (pandora_inhibit_alerts ($pa_config, $agent, $dbh, 0) == 0 && pandora_cps_enabled($agent, $module) == 0) { pandora_generate_alerts ($pa_config, 0, 3, $agent, $module, time (), $dbh, undef, undef, 0, 'unknown'); } else { @@ -4969,7 +4963,7 @@ sub pandora_module_unknown ($$) { pandora_mark_agent_for_module_update ($dbh, $module->{'id_agente'}); # Generate alerts - if (pandora_inhibit_alerts ($pa_config, $agent, $dbh, 0) == 0) { + if (pandora_inhibit_alerts ($pa_config, $agent, $dbh, 0) == 0 && pandora_cps_enabled($agent, $module) == 0) { pandora_generate_alerts ($pa_config, 0, 3, $agent, $module, time (), $dbh, undef, undef, 0, 'unknown'); } else { diff --git a/pandora_server/lib/PandoraFMS/PredictionServer.pm b/pandora_server/lib/PandoraFMS/PredictionServer.pm index ec7fa7e586..361eb338e2 100644 --- a/pandora_server/lib/PandoraFMS/PredictionServer.pm +++ b/pandora_server/lib/PandoraFMS/PredictionServer.pm @@ -176,7 +176,7 @@ sub exec_prediction_module ($$$$) { logger ($pa_config, "Executing service module " . $agent_module->{'id_agente_modulo'} . " " . $agent_module->{'nombre'}, 10); - enterprise_hook ('exec_service_module', [$pa_config, $agent_module, $server_id, $dbh]); + enterprise_hook ('exec_service_module', [$pa_config, $agent_module, undef, $server_id, $dbh]); } return; From 000e8b6457bb183c10fb829891b40e11ebf2a8c1 Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 11 Jul 2018 13:47:00 +0200 Subject: [PATCH 24/79] fixed errors in forecast charts --- pandora_console/include/functions_graph.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 5db1914089..06d965d939 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -265,7 +265,7 @@ function grafico_modulo_sparse_data_chart ( $data_module_graph['id_module_type'] == 9 || $data_module_graph['id_module_type'] == 31 || $data_module_graph['id_module_type'] == 100 || - $params['baseline'] + $params['baseline'] || $params['projection'] ){ $data = db_get_all_rows_filter ( @@ -421,7 +421,8 @@ function grafico_modulo_sparse_data( $data_module_graph['id_module_type'] == 18 || $data_module_graph['id_module_type'] == 9 || $data_module_graph['id_module_type'] == 31 || - $data_module_graph['id_module_type'] == 100 ){ + $data_module_graph['id_module_type'] == 100 || + $params['projection'] ){ $array_data = grafico_modulo_sparse_data_chart ( $agent_module_id, $date_array, @@ -899,6 +900,10 @@ function grafico_modulo_sparse ($params) { $params['type_mode_graph'] = $config['type_mode_graph']; } + if(!isset($params['projection'])){ + $params['projection'] = false; + } + //XXXX Configurable $params['grid_color'] = '#C1C1C1'; $params['legend_color'] = '#636363'; @@ -1214,6 +1219,7 @@ function graphic_combined_module ( } else{ $params['stacked'] = 'area'; + $params['projection'] = $params_combined['projection']; } if(!isset($params_combined['labels'])){ From ecd34f41f8b1ec0d7860e974e72b2dbbd0d58c9c Mon Sep 17 00:00:00 2001 From: fermin831 Date: Wed, 11 Jul 2018 18:56:49 +0200 Subject: [PATCH 25/79] Fixed recon_reverse_geolocation_file configuration --- pandora_server/lib/PandoraFMS/GIS.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_server/lib/PandoraFMS/GIS.pm b/pandora_server/lib/PandoraFMS/GIS.pm index 4d7f745133..3db240395c 100644 --- a/pandora_server/lib/PandoraFMS/GIS.pm +++ b/pandora_server/lib/PandoraFMS/GIS.pm @@ -148,7 +148,7 @@ sub get_geoip_info { my $record = undef; eval { local $SIG{__DIE__}; - my $gi = Geo::IP->open("/tmp/pandorafms/GeoLiteCity.dat", GEOIP_STANDARD); + my $gi = Geo::IP->open($pa_config->{'recon_reverse_geolocation_file'}, GEOIP_STANDARD); die("Cannot load the geoip file \"" . $pa_config->{'recon_reverse_geolocation_file'} . "\".\n") unless defined($gi); $record = $gi->record_by_addr($address); }; From 8ab387581d3fd05012102e2aaec8170e62b15578 Mon Sep 17 00:00:00 2001 From: artica Date: Thu, 12 Jul 2018 00:01:56 +0200 Subject: [PATCH 26/79] Auto-updated build strings. --- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 2 +- pandora_agents/unix/pandora_agent.spec | 2 +- pandora_agents/unix/pandora_agent_installer | 2 +- pandora_agents/win32/installer/pandora.mpi | 2 +- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 2 +- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.spec | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 3f2fbfc91c..a17e946413 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.724-180711 +Version: 7.0NG.724-180712 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 cb958b98dd..9c139130ae 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.724-180711" +pandora_version="7.0NG.724-180712" 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 24eac79117..68d6ab4cbe 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.724'; -use constant AGENT_BUILD => '180711'; +use constant AGENT_BUILD => '180712'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index c5d16fbd7b..e9440ca228 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.724 -%define release 180711 +%define release 180712 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 c4282ee67b..9bc625ad1b 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.724 -%define release 180711 +%define release 180712 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 b803d15f99..e5f802ef23 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.724" -PI_BUILD="180711" +PI_BUILD="180712" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 4adb76decd..c7e29843dc 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{180711} +{180712} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index f33c75cccd..33aa297e5f 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.724(Build 180711)") +#define PANDORA_VERSION ("7.0NG.724(Build 180712)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index db9ff03e77..5a78131972 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.724(Build 180711))" + VALUE "ProductVersion", "(7.0NG.724(Build 180712))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index bbc8f96e38..bf5aec9c6c 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.724-180711 +Version: 7.0NG.724-180712 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 ec2eeab2a1..3ba88d22d1 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.724-180711" +pandora_version="7.0NG.724-180712" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 836e55a91e..6da4c2295a 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -22,7 +22,7 @@ /** * Pandora build version and version */ -$build_version = 'PC180711'; +$build_version = 'PC180712'; $pandora_version = 'v7.0NG.724'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index fbe8f5b28e..ff16f52b65 100755 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -71,7 +71,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 96cccbd07e..8ff30d402c 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.724 -%define release 180711 +%define release 180712 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 8d19d90f49..63fdd89991 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.724 -%define release 180711 +%define release 180712 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 58c31546cc..1005ff738a 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.724" -PI_BUILD="180711" +PI_BUILD="180712" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 4d476cf064..3967ee3f62 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -34,7 +34,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.724 PS180711"; +my $version = "7.0NG.724 PS180712"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 8737ca809d..48d9d27c23 100644 --- 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.724 PS180711"; +my $version = "7.0NG.724 PS180712"; # save program name for logging my $progname = basename($0); From 78f17b9970cc5106f432bf9f74db6bdb4071bdbd Mon Sep 17 00:00:00 2001 From: daniel Date: Thu, 12 Jul 2018 09:48:51 +0200 Subject: [PATCH 27/79] fixed error bbdd new field CPS in tpolicy_modules --- pandora_console/extras/mr/18.sql | 2 ++ pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql | 1 + pandora_console/pandoradb.sql | 1 + 3 files changed, 4 insertions(+) diff --git a/pandora_console/extras/mr/18.sql b/pandora_console/extras/mr/18.sql index b7e4be33e0..dd394645a8 100644 --- a/pandora_console/extras/mr/18.sql +++ b/pandora_console/extras/mr/18.sql @@ -10,4 +10,6 @@ ALTER TABLE `tmetaconsole_agent` ADD COLUMN `cps` int NOT NULL DEFAULT '0'; ALTER TABLE `tagente_modulo` ADD COLUMN `cps` int NOT NULL DEFAULT '0'; +ALTER TABLE `tpolicy_modules` ADD COLUMN `cps` int NOT NULL DEFAULT '0'; + 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 6752754a5c..fe494ad6a1 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 @@ -1353,6 +1353,7 @@ ALTER TABLE tlocal_component ADD COLUMN `dynamic_two_tailed` tinyint(1) unsigned ALTER TABLE tpolicy_modules ADD COLUMN `ip_target`varchar(100) default ''; 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 `cps` int NOT NULL DEFAULT 0; -- --------------------------------------------------------------------- -- Table `tmetaconsole_agent` diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 5b77263b6a..4399b4a546 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -2158,6 +2158,7 @@ CREATE TABLE IF NOT EXISTS `tpolicy_modules` ( `prediction_sample_window` int(10) default 0, `prediction_samples` int(4) default 0, `prediction_threshold` int(4) default 0, + `cps` int NOT NULL DEFAULT 0, PRIMARY KEY (`id`), KEY `main_idx` (`id_policy`), UNIQUE (`id_policy`, `name`) From fa4446bb91017d4cb0d7a1b6e09d9eca31e23d01 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 12 Jul 2018 12:34:05 +0200 Subject: [PATCH 28/79] Fixed min/max absolute values in charts --- pandora_console/include/functions_graph.php | 39 ++++++++++++++------- 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 66dc64e639..65db581cdf 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -4084,21 +4084,32 @@ function fullscale_data ( $data["sum" . $series_suffix]['data'][] = array($real_date , $sum_data/$count_data); if($type_mode_graph && !$params['baseline']){ - $data["min" . $series_suffix]['data'][] = array($real_date , $min_value); - $data["max" . $series_suffix]['data'][] = array($real_date , $max_value); + if($min_value != PHP_INT_MAX) { + $data["min" . $series_suffix]['data'][] = array($real_date , $min_value); + } + + if($max_value != -PHP_INT_MAX) { + $data["max" . $series_suffix]['data'][] = array($real_date , $max_value); + } } else{ - $data["sum" . $series_suffix]['slice_data'][$real_date]['min'] = $min_value; + if($min_value != PHP_INT_MAX) { + $data["sum" . $series_suffix]['slice_data'][$real_date]['min'] = $min_value; + } + $data["sum" . $series_suffix]['slice_data'][$real_date]['avg'] = $sum_data/$count_data; - $data["sum" . $series_suffix]['slice_data'][$real_date]['max'] = $max_value; + + if($max_value != -PHP_INT_MAX) { + $data["sum" . $series_suffix]['slice_data'][$real_date]['max'] = $max_value; + } } //max_total - if($max_value >= $max_value_total){ + if($max_value >= $max_value_total && $max_value != -PHP_INT_MAX){ $max_value_total = $max_value; } //min_total - if($min_value <= $min_value_total){ + if($min_value <= $min_value_total && $min_value != PHP_INT_MAX){ $min_value_total = $min_value; } //avg sum_total @@ -4110,27 +4121,31 @@ function fullscale_data ( if($type_mode_graph && !$params['baseline']){ /*MIN*/ //max_min - if($min_value >= $min_value_max){ + if($min_value >= $min_value_max && $min_value != PHP_INT_MAX){ $min_value_max = $min_value; } //min_min - if($min_value <= $min_value_min){ + if($min_value <= $min_value_min && $min_value != PHP_INT_MAX){ $min_value_min = $min_value; } //avg sum_min - $sum_data_min += $min_value; + if ($min_value != PHP_INT_MAX) { + $sum_data_min += $min_value; + } /*MAX*/ //max_max - if($max_value >= $max_value_max){ + if($max_value >= $max_value_max && $max_value != -PHP_INT_MAX){ $max_value_max = $max_value; } //min_max - if($max_value <= $max_value_min){ + if($max_value <= $max_value_min && $max_value != -PHP_INT_MAX){ $max_value_min = $max_value; } //avg sum_max - $sum_data_max += $max_value; + if ($max_value != -PHP_INT_MAX) { + $sum_data_max += $max_value; + } /*AVG*/ //max_max From f4847d5347ecd06a64b3afa380ee6a06e06e4a9d Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Thu, 12 Jul 2018 12:36:53 +0200 Subject: [PATCH 29/79] Add the _rca_ macro to the help files. --- pandora_console/include/help/en/help_alert_config.php | 1 + pandora_console/include/help/en/help_alert_macros.php | 1 + pandora_console/include/help/es/help_alert_config.php | 1 + pandora_console/include/help/es/help_alert_macros.php | 1 + pandora_console/include/help/ja/help_alert_config.php | 1 + pandora_console/include/help/ja/help_alert_macros.php | 1 + 6 files changed, 6 insertions(+) diff --git a/pandora_console/include/help/en/help_alert_config.php b/pandora_console/include/help/en/help_alert_config.php index b8d02b6282..8eeb49e34d 100644 --- a/pandora_console/include/help/en/help_alert_config.php +++ b/pandora_console/include/help/en/help_alert_config.php @@ -90,6 +90,7 @@ Apart from the defined module macros, the following macros are also available:
  • _plugin_parameters_: Module plugin parameters.
  • _policy_: Name of the policy that the module belongs to (if applies).
  • _prevdata_: Module previous data before the alert has been triggered.
  • +
  • _rca_: Root cause analysis chain (only for services).
  • _server_ip_: Ip of server assigned to agent.
  • _server_name_: Name of server assigned to agent.
  • _target_ip_: IP address for the module’s target.
  • diff --git a/pandora_console/include/help/en/help_alert_macros.php b/pandora_console/include/help/en/help_alert_macros.php index d2afc89053..a40d56e122 100644 --- a/pandora_console/include/help/en/help_alert_macros.php +++ b/pandora_console/include/help/en/help_alert_macros.php @@ -75,6 +75,7 @@ Besides the defined module macros, the following macros are available:
  • _plugin_parameters_: Module plugin parameters.
  • _policy_: Name of the policy that the module belongs to (if applies).
  • _prevdata_: Module previous data before the alert has been triggered.
  • +
  • _rca_: Root cause analysis chain (only for services).
  • _server_ip_: Ip of server assigned to agent.
  • _server_name_: Name of server assigned to agent.
  • _target_ip_: IP address for the module’s target.
  • diff --git a/pandora_console/include/help/es/help_alert_config.php b/pandora_console/include/help/es/help_alert_config.php index 312862a10e..e26533ba9a 100644 --- a/pandora_console/include/help/es/help_alert_config.php +++ b/pandora_console/include/help/es/help_alert_config.php @@ -92,6 +92,7 @@ Además de las macros de módulo definidas, las siguientes macros están disponi
  • _plugin_parameters_: Parámetros del plugin del módulo.
  • _policy_: Nombre de la política a la que pertenece el módulo (si aplica).
  • _prevdata_: Dato previo antes de disparase la alerta.
  • +
  • _rca_: Cadena de análasis de causa raíz (sólo para servicios).
  • _server_ip_: Ip del servidor al que el agente está asignado.
  • _server_name_: Nombre del servidor al que el agente está asignado.
  • _target_ip_: Dirección IP del objetivo del módulo.
  • diff --git a/pandora_console/include/help/es/help_alert_macros.php b/pandora_console/include/help/es/help_alert_macros.php index fec55d7175..2817b32abb 100644 --- a/pandora_console/include/help/es/help_alert_macros.php +++ b/pandora_console/include/help/es/help_alert_macros.php @@ -75,6 +75,7 @@ Además de las macros de módulo definidas, las siguientes macros están disponi
  • _plugin_parameters_: Parámetros del plugin del módulo.
  • _policy_: Nombre de la política a la que pertenece el módulo (si aplica).
  • _prevdata_: Dato previo antes de disparase la alerta.
  • +
  • _rca_: Cadena de análasis de causa raíz (sólo para servicios).
  • _server_ip_: Ip del servidor al que el agente está asignado.
  • _server_name_: Nombre del servidor al que el agente está asignado.
  • _target_ip_: Dirección IP del objetivo del módulo.
  • diff --git a/pandora_console/include/help/ja/help_alert_config.php b/pandora_console/include/help/ja/help_alert_config.php index 870591f83a..d8dab9c2fa 100644 --- a/pandora_console/include/help/ja/help_alert_config.php +++ b/pandora_console/include/help/ja/help_alert_config.php @@ -91,6 +91,7 @@ email アクションを設定するには、_field1_ (送信先アドレス)、
  • _plugin_parameters_ : モジュールのプラグインパラメータ
  • _policy_ : モジュールが属するポリシー名 (存在する場合)
  • _prevdata_ : アラートを発報する前のモジュールデータ
  • +
  • _rca_: Root cause analysis chain (only for services).
  • _server_ip_ : エージェントが割り当てられているサーバ IP。
  • _server_name_ : エージェントが割り当てられているサーバ名。
  • _target_ip_ : モジュールの対象IPアドレス
  • diff --git a/pandora_console/include/help/ja/help_alert_macros.php b/pandora_console/include/help/ja/help_alert_macros.php index 85b1de7c46..1a7fd69680 100644 --- a/pandora_console/include/help/ja/help_alert_macros.php +++ b/pandora_console/include/help/ja/help_alert_macros.php @@ -75,6 +75,7 @@
  • _plugin_parameters_ : モジュールのプラグインパラメータ
  • _policy_ : モジュールが属するポリシー名 (存在する場合)
  • _prevdata_ : アラートを発報する前のモジュールデータ
  • +
  • _rca_: Root cause analysis chain (only for services).
  • _server_ip_ : エージェントが割り当てられているサーバ IP。
  • _server_name_ : エージェントが割り当てられているサーバ名。
  • _target_ip_ : モジュールの対象IPアドレス
  • From 98025188cb187576cfd32534bc608ce96f1d8bc4 Mon Sep 17 00:00:00 2001 From: artica Date: Fri, 13 Jul 2018 00:01:29 +0200 Subject: [PATCH 30/79] Auto-updated build strings. --- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 2 +- pandora_agents/unix/pandora_agent.spec | 2 +- pandora_agents/unix/pandora_agent_installer | 2 +- pandora_agents/win32/installer/pandora.mpi | 2 +- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 2 +- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.spec | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index a17e946413..c22eaa00ec 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.724-180712 +Version: 7.0NG.724-180713 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 9c139130ae..bd6ab97f85 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.724-180712" +pandora_version="7.0NG.724-180713" 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 68d6ab4cbe..6fff2a3ad8 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.724'; -use constant AGENT_BUILD => '180712'; +use constant AGENT_BUILD => '180713'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index e9440ca228..e1e378e65c 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.724 -%define release 180712 +%define release 180713 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 9bc625ad1b..448ee0e23b 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.724 -%define release 180712 +%define release 180713 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 e5f802ef23..d1a42cad6d 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.724" -PI_BUILD="180712" +PI_BUILD="180713" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index c7e29843dc..7a239ab9ae 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{180712} +{180713} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 33aa297e5f..72a23732a0 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.724(Build 180712)") +#define PANDORA_VERSION ("7.0NG.724(Build 180713)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 5a78131972..d2bb33041a 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.724(Build 180712))" + VALUE "ProductVersion", "(7.0NG.724(Build 180713))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index bf5aec9c6c..c56087e2cc 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.724-180712 +Version: 7.0NG.724-180713 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 3ba88d22d1..dca7be265b 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.724-180712" +pandora_version="7.0NG.724-180713" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 6da4c2295a..c1b249a0d5 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -22,7 +22,7 @@ /** * Pandora build version and version */ -$build_version = 'PC180712'; +$build_version = 'PC180713'; $pandora_version = 'v7.0NG.724'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index ff16f52b65..658aa2e2a0 100755 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -71,7 +71,7 @@
    [ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 8ff30d402c..4299e2be44 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.724 -%define release 180712 +%define release 180713 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 63fdd89991..f29ee49bb9 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.724 -%define release 180712 +%define release 180713 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 1005ff738a..a8d33dfdd8 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.724" -PI_BUILD="180712" +PI_BUILD="180713" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 3967ee3f62..e1fe70978d 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -34,7 +34,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.724 PS180712"; +my $version = "7.0NG.724 PS180713"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 48d9d27c23..678d15512c 100644 --- 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.724 PS180712"; +my $version = "7.0NG.724 PS180713"; # save program name for logging my $progname = basename($0); From d0b6c9775fead3e68cd95bf1bd067bf8f177753f Mon Sep 17 00:00:00 2001 From: fermin831 Date: Fri, 13 Jul 2018 11:56:37 +0200 Subject: [PATCH 31/79] Addapted modules edition to metaconsole --- pandora_console/godmode/agentes/module_manager.php | 9 ++++----- .../godmode/agentes/module_manager_editor_common.php | 7 ++++--- .../godmode/agentes/module_manager_editor_network.php | 6 +++--- .../modules/manage_network_components_form_common.php | 2 +- pandora_console/include/functions_snmp_browser.php | 2 +- pandora_console/operation/agentes/networkmap.dinamic.php | 6 ++---- 6 files changed, 15 insertions(+), 17 deletions(-) diff --git a/pandora_console/godmode/agentes/module_manager.php b/pandora_console/godmode/agentes/module_manager.php index 02698e3326..91e7700d27 100644 --- a/pandora_console/godmode/agentes/module_manager.php +++ b/pandora_console/godmode/agentes/module_manager.php @@ -23,9 +23,9 @@ else { enterprise_include ('godmode/agentes/module_manager.php'); $isFunctionPolicies = enterprise_include_once ('include/functions_policies.php'); -require_once ('include/functions_modules.php'); -require_once ('include/functions_agents.php'); -require_once ('include/functions_servers.php'); +require_once ($config['homedir'] . '/include/functions_modules.php'); +require_once ($config['homedir'] . '/include/functions_agents.php'); +require_once ($config['homedir'] . '/include/functions_servers.php'); $search_string = io_safe_output(urldecode(trim(get_parameter ("search_string", "")))); @@ -35,7 +35,6 @@ if (!isset($policy_page)) $policy_page = false; // Search string filter form -//echo '
    '; if (($policy_page) || (isset($agent))) echo ''; else @@ -67,7 +66,7 @@ $prediction_available = db_get_sql ("SELECT count(*) WHERE server_type = 5"); //POSTGRESQL AND ORACLE COMPATIBLE // Development mode to use all servers -if ($develop_bypass) { +if ($develop_bypass || is_metaconsole()) { $network_available = 1; $wmi_available = 1; $plugin_available = 1; diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index db77af000b..727e6348f7 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -14,10 +14,11 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -include_once("include/functions_modules.php"); -include_once("include/functions_categories.php"); +include_once($config['homedir'] . "/include/functions_modules.php"); +include_once($config['homedir'] . "/include/functions_categories.php"); +include_once($config['homedir'] . "/include/graphs/functions_d3.php"); -echo "" . "\n"; +include_javascript_d3(); function prepend_table_simple ($row, $id = false) { global $table_simple; diff --git a/pandora_console/godmode/agentes/module_manager_editor_network.php b/pandora_console/godmode/agentes/module_manager_editor_network.php index 557b17f388..53a816a26e 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_network.php +++ b/pandora_console/godmode/agentes/module_manager_editor_network.php @@ -16,9 +16,9 @@ global $config; require_once($config['homedir'] . "/include/functions_snmp_browser.php"); -?> - -"; //This line does not run with the dinamic loader editor in policies. //ui_require_javascript_file ('pandora_snmp_browser'); 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 fd6744c283..c8ac72ade0 100644 --- a/pandora_console/godmode/modules/manage_network_components_form_common.php +++ b/pandora_console/godmode/modules/manage_network_components_form_common.php @@ -22,7 +22,7 @@ if (! check_acl ($config['id_user'], 0, "PM")) { return; } -echo "" . "\n"; +include_javascript_d3(); function push_table_row ($row, $id = false) { global $table; diff --git a/pandora_console/include/functions_snmp_browser.php b/pandora_console/include/functions_snmp_browser.php index c6698d70cd..e24f0119c5 100644 --- a/pandora_console/include/functions_snmp_browser.php +++ b/pandora_console/include/functions_snmp_browser.php @@ -36,7 +36,7 @@ function snmp_browser_print_tree ($tree, $id = 0, $depth = 0, $last = 0, $last_a // Get the base URL for images if ($url === false) { - $url = ui_get_full_url('operation/tree'); + $url = ui_get_full_url('operation/tree', false, false, false); } // Leaf diff --git a/pandora_console/operation/agentes/networkmap.dinamic.php b/pandora_console/operation/agentes/networkmap.dinamic.php index 5b7392b0f6..3100d03298 100644 --- a/pandora_console/operation/agentes/networkmap.dinamic.php +++ b/pandora_console/operation/agentes/networkmap.dinamic.php @@ -203,10 +203,8 @@ $zoom_default = file($config['homedir'] . '/images/zoom_default.svg');
    '; +include_javascript_d3(); + echo '
    '; ?>