Merge branch 'develop' of https://github.com/pandorafms/pandorafms into develop

This commit is contained in:
m-lopez-f 2015-07-06 17:11:11 +02:00
commit 6b5df1983b
6 changed files with 104 additions and 60 deletions

View File

@ -68,91 +68,92 @@ if ($update) {
$success = 0; $success = 0;
$count = 0; $count = 0;
if ($agents_ == false) { if ($agents_ == false)
$agents_ = array(); $agents_ = array();
}
// If the option to select all of one group or module type is checked // If the option to select all of one group or module type is checked
if ($force) { if ($force) {
if ($force == 'type') { if ($force == 'type') {
$condition = ''; $type_condition = '';
if ($module_type != 0) if ($module_type != 0)
$condition = ' AND t2.id_tipo_modulo = ' . $module_type; $type_condition = "AND tam.id_tipo_modulo = $module_type";
$sql = "SELECT ta.id_agente
FROM tagente ta
INNER JOIN tagente_modulo tam
ON ta.id_agente = tam.id_agente
AND tam.delete_pending = 0
$type_condition
GROUP BY ta.id_agente";
$agents_ = db_get_all_rows_sql($sql);
if ($agents_ === false)
$agents_ = array();
// Create an array of agent ids
$agents_ = extract_column($agents_, 'id_agente');
$agents_ = db_get_all_rows_sql('
SELECT DISTINCT(t1.id_agente)
FROM tagente t1, tagente_modulo t2
WHERE t1.id_agente = t2.id_agente
AND t2.delete_pending = 0 ' . $condition);
foreach ($agents_ as $id_agent) { foreach ($agents_ as $id_agent) {
$module_name = db_get_all_rows_filter('tagente_modulo', $filter = array(
array('id_agente' => $id_agent, 'id_agente' => $id_agent,
'id_tipo_modulo' => $module_type, 'delete_pending' => 0
'delete_pending' => 0), );
'nombre'); if ($module_type != 0)
$filter['id_tipo_modulo'] = $module_type;
if ($module_name == false) { $module_name = db_get_all_rows_filter('tagente_modulo', $filter, 'nombre');
if ($module_name === false)
$module_name = array(); $module_name = array();
}
foreach ($module_name as $mod_name) { foreach ($module_name as $mod_name) {
$result = process_manage_edit($mod_name['nombre'], $result = process_manage_edit($mod_name['nombre'], $id_agent);
$id_agent['id_agente']);
$count++; $count++;
$success += (int)$result; $success += (int)$result;
} }
} }
} }
else if ($force == 'group') { else if ($force == 'group') {
$agents_ = array_keys(agents_get_group_agents($group_select, $agents_ = array_keys(agents_get_group_agents($group_select, false, 'none'));
false, "none"));
foreach ($agents_ as $id_agent) { foreach ($agents_ as $id_agent) {
$module_name = db_get_all_rows_filter('tagente_modulo', $filter = array('id_agente' => $id_agent);
array('id_agente' => $id_agent),'nombre'); $module_name = db_get_all_rows_filter('tagente_modulo', $filter, 'nombre');
if ($module_name == false) { if ($module_name === false)
$module_name = array(); $module_name = array();
}
foreach($module_name as $mod_name) { foreach($module_name as $mod_name) {
$result = process_manage_edit($mod_name['nombre'], $result = process_manage_edit($mod_name['nombre'], $id_agent);
$id_agent); $count++;
$count ++;
$success += (int)$result; $success += (int)$result;
} }
} }
} }
// We empty the agents array to skip the standard procedure
$agents_ = array();
} }
else {
// Standard procedure
foreach ($agents_ as $agent_) {
foreach ($agents_ as $agent_) {
if ($modules_ == false)
if ($modules_ == false) { $modules_ = array();
$modules_ = array();
} foreach ($modules_ as $module_) {
$result = process_manage_edit ($module_, $agents_);
foreach ($modules_ as $module_) { $count++;
$result = process_manage_edit ($module_, $agents_); $success += (int)$result;
$count ++; }
$success += (int)$result;
} }
} }
ui_print_result_message ($success > 0, ui_print_result_message ($success > 0,
__('Successfully updated') . __('Successfully updated') . "(" . $success . "/" . $count . ")",
"(" . $success . "/" . $count . ")",
__('Could not be updated')); __('Could not be updated'));
$info = 'Modules: ' . json_encode($modules_) . $info = 'Modules: ' . json_encode($modules_) .
' Agents: ' . json_encode($agents_); ' Agents: ' . json_encode($agents_);
if ($success > 0) { if ($success > 0) {
db_pandora_audit("Massive management", "Edit module", false, db_pandora_audit("Massive management", "Edit module", false, false, $info);
false, $info);
} }
else { else {
db_pandora_audit("Massive management", db_pandora_audit("Massive management", "Fail try to edit module", false, false, $info);
"Fail try to edit module", false, false, $info);
} }
} }

View File

@ -2436,4 +2436,29 @@ function array2XML($data, $root = null, $xml = NULL) {
return html_entity_decode($xml->asXML()); return html_entity_decode($xml->asXML());
} }
/**
* Returns an array by extracting a column or columns.
*
* @param array Array
* @param mixed (string/array) Column name/s
*
* @return array Array formed by the extracted columns of every array iteration.
*/
function extract_column ($array, $column) {
$column_is_arr = is_array($column);
return array_map(function($item) {
if ($column_is_arr) {
return array_reduce($column, function($carry, $col) use ($item) {
$carry[$col] = $item[$col];
return $item[$col];
}, array());
}
else {
return $item[$column];
}
}, $array);
}
?> ?>

View File

@ -648,6 +648,11 @@ function config_process_config () {
exit; exit;
} }
$is_windows = false;
if (substr(strtolower(PHP_OS), 0, 3) === 'win') {
$is_windows = true;
}
/* Compatibility fix */ /* Compatibility fix */
foreach ($configs as $c) { foreach ($configs as $c) {
$config[$c['token']] = $c['value']; $config[$c['token']] = $c['value'];
@ -663,6 +668,15 @@ function config_process_config () {
} }
} }
if (!isset ($config['remote_config'])) {
if ($is_windows)
$default = 'C:\\PandoraFMS\\Pandora_Server\\data_in';
else
$default = '/var/spool/pandora/data_in';
config_update_value ('remote_config', $default);
}
if (!isset ($config['date_format'])) { if (!isset ($config['date_format'])) {
config_update_value ('date_format', 'F j, Y, g:i a'); config_update_value ('date_format', 'F j, Y, g:i a');
} }
@ -821,7 +835,12 @@ function config_process_config () {
} }
if (!isset ($config["log_dir"])) { if (!isset ($config["log_dir"])) {
config_update_value ('log_dir', '/var/spool/pandora/data_in/log'); if ($is_windows)
$default = 'C:\\PandoraFMS\\Pandora_Server\\data_in\\log';
else
$default = '/var/spool/pandora/data_in/log';
config_update_value ('log_dir', $default);
} }
if (!isset ($config["log_max_lifetime"])) { if (!isset ($config["log_max_lifetime"])) {
@ -963,7 +982,12 @@ function config_process_config () {
} }
if (!isset ($config['netflow_path'])) { if (!isset ($config['netflow_path'])) {
config_update_value ( 'netflow_path', '/var/spool/pandora/data_in/netflow'); if ($is_windows)
$default = 'C:\\PandoraFMS\\Pandora_Server\\data_in\\netflow';
else
$default = '/var/spool/pandora/data_in/netflow';
config_update_value ( 'netflow_path', $default);
} }
if (!isset ($config['netflow_interval'])) { if (!isset ($config['netflow_interval'])) {

View File

@ -68,7 +68,6 @@ INSERT INTO tconfig (token, value) VALUES ('db_scheme_build','PD110122');
INSERT INTO tconfig (token, value) VALUES ('show_unknown','0'); INSERT INTO tconfig (token, value) VALUES ('show_unknown','0');
INSERT INTO tconfig (token, value) VALUES ('show_lastalerts','1'); INSERT INTO tconfig (token, value) VALUES ('show_lastalerts','1');
INSERT INTO tconfig (token, value) VALUES ('style','pandora'); INSERT INTO tconfig (token, value) VALUES ('style','pandora');
INSERT INTO tconfig (token, value) VALUES ('remote_config', '/var/spool/pandora/data_in');
INSERT INTO tconfig (token, value) VALUES ('graph_color1', '#38B800'); INSERT INTO tconfig (token, value) VALUES ('graph_color1', '#38B800');
INSERT INTO tconfig (token, value) VALUES ('graph_color2', '#FFFF00'); INSERT INTO tconfig (token, value) VALUES ('graph_color2', '#FFFF00');
INSERT INTO tconfig (token, value) VALUES ('graph_color3', '#FF6600'); INSERT INTO tconfig (token, value) VALUES ('graph_color3', '#FF6600');
@ -82,7 +81,7 @@ INSERT INTO tconfig (token, value) VALUES ('graph_color10', '#6666FF');
INSERT INTO tconfig (token, value) VALUES ('trap2agent', '0'); INSERT INTO tconfig (token, value) VALUES ('trap2agent', '0');
INSERT INTO tconfig (token, value) VALUES ('date_format', 'F j, Y, g:i a'); INSERT INTO tconfig (token, value) VALUES ('date_format', 'F j, Y, g:i a');
INSERT INTO tconfig (token, value) VALUES ('event_view_hr', 8); INSERT INTO tconfig (token, value) VALUES ('event_view_hr', 8);
INSERT INTO tconfig (token, value) VALUES ('loginhash_pwd', ' '); INSERT INTO tconfig (token, value) VALUES ('loginhash_pwd', '');
INSERT INTO tconfig (token, value) VALUES ('trap2agent', 0); INSERT INTO tconfig (token, value) VALUES ('trap2agent', 0);
INSERT INTO tconfig (token, value) VALUES ('prominent_time', 'comparation'); INSERT INTO tconfig (token, value) VALUES ('prominent_time', 'comparation');
INSERT INTO tconfig (token, value) VALUES ('timesource', 'system'); INSERT INTO tconfig (token, value) VALUES ('timesource', 'system');
@ -100,10 +99,9 @@ INSERT INTO tconfig (token, value) VALUES ('sound_alert', 'include/sounds/air_sh
INSERT INTO tconfig (token, value) VALUES ('sound_critical', 'include/sounds/Star_Trek_emergency_simulation.wav'); INSERT INTO tconfig (token, value) VALUES ('sound_critical', 'include/sounds/Star_Trek_emergency_simulation.wav');
INSERT INTO tconfig (token, value) VALUES ('sound_warning', 'include/sounds/negativebeep.wav'); INSERT INTO tconfig (token, value) VALUES ('sound_warning', 'include/sounds/negativebeep.wav');
INSERT INTO tconfig (token, value) VALUES ('integria_enabled', '0'); INSERT INTO tconfig (token, value) VALUES ('integria_enabled', '0');
INSERT INTO tconfig (token, value) VALUES ('integria_api_password', ' '); INSERT INTO tconfig (token, value) VALUES ('integria_api_password', '');
INSERT INTO tconfig (token, value) VALUES ('integria_inventory', '0'); INSERT INTO tconfig (token, value) VALUES ('integria_inventory', '0');
INSERT INTO tconfig (token, value) VALUES ('integria_url', ' '); INSERT INTO tconfig (token, value) VALUES ('integria_url', '');
INSERT INTO tconfig (token, value) VALUES ('netflow_path', '/var/spool/pandora/data_in/netflow');
INSERT INTO tconfig (token, value) VALUES ('netflow_interval', '3600'); INSERT INTO tconfig (token, value) VALUES ('netflow_interval', '3600');
INSERT INTO tconfig (token, value) VALUES ('netflow_daemon', '/usr/bin/nfcapd'); INSERT INTO tconfig (token, value) VALUES ('netflow_daemon', '/usr/bin/nfcapd');
INSERT INTO tconfig (token, value) VALUES ('netflow_nfdump', '/usr/bin/nfdump'); INSERT INTO tconfig (token, value) VALUES ('netflow_nfdump', '/usr/bin/nfdump');

View File

@ -55,7 +55,6 @@ INSERT INTO "tconfig" ("token", "value") VALUES
('show_unknown','0'), ('show_unknown','0'),
('show_lastalerts','1'), ('show_lastalerts','1'),
('style','pandora'), ('style','pandora'),
('remote_config', '/var/spool/pandora/data_in'),
('graph_color1', '#38B800'), ('graph_color1', '#38B800'),
('graph_color2', '#FFFF00'), ('graph_color2', '#FFFF00'),
('graph_color3', '#FF6600'), ('graph_color3', '#FF6600'),
@ -91,7 +90,6 @@ INSERT INTO "tconfig" ("token", "value") VALUES
('integria_api_password', ''), ('integria_api_password', ''),
('integria_inventory', '0'), ('integria_inventory', '0'),
('integria_url', ''), ('integria_url', ''),
('netflow_path', '/var/spool/pandora/data_in/netflow'),
('netflow_interval', '3600'), ('netflow_interval', '3600'),
('netflow_daemon', '/usr/bin/nfcapd'), ('netflow_daemon', '/usr/bin/nfcapd'),
('netflow_nfdump', '/usr/bin/nfdump'), ('netflow_nfdump', '/usr/bin/nfdump'),

View File

@ -42,7 +42,6 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES
('show_unknown','0'), ('show_unknown','0'),
('show_lastalerts','1'), ('show_lastalerts','1'),
('style','pandora'), ('style','pandora'),
('remote_config', '/var/spool/pandora/data_in'),
('graph_color1', '#99dd00'), ('graph_color1', '#99dd00'),
('graph_color2', '#336600'), ('graph_color2', '#336600'),
('graph_color3', '#3399cc'), ('graph_color3', '#3399cc'),
@ -77,7 +76,6 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES
('integria_api_password', ''), ('integria_api_password', ''),
('integria_inventory', '0'), ('integria_inventory', '0'),
('integria_url', ''), ('integria_url', ''),
('netflow_path', '/var/spool/pandora/data_in/netflow'),
('netflow_interval', '3600'), ('netflow_interval', '3600'),
('netflow_daemon', '/usr/bin/nfcapd'), ('netflow_daemon', '/usr/bin/nfcapd'),
('netflow_nfdump', '/usr/bin/nfdump'), ('netflow_nfdump', '/usr/bin/nfdump'),