Merge branch 'develop' of https://github.com/pandorafms/pandorafms into develop
This commit is contained in:
commit
6b5df1983b
|
@ -68,91 +68,92 @@ if ($update) {
|
|||
$success = 0;
|
||||
$count = 0;
|
||||
|
||||
if ($agents_ == false) {
|
||||
if ($agents_ == false)
|
||||
$agents_ = array();
|
||||
}
|
||||
|
||||
// If the option to select all of one group or module type is checked
|
||||
if ($force) {
|
||||
if ($force == 'type') {
|
||||
$condition = '';
|
||||
$type_condition = '';
|
||||
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) {
|
||||
$module_name = db_get_all_rows_filter('tagente_modulo',
|
||||
array('id_agente' => $id_agent,
|
||||
'id_tipo_modulo' => $module_type,
|
||||
'delete_pending' => 0),
|
||||
'nombre');
|
||||
$filter = array(
|
||||
'id_agente' => $id_agent,
|
||||
'delete_pending' => 0
|
||||
);
|
||||
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();
|
||||
}
|
||||
|
||||
foreach ($module_name as $mod_name) {
|
||||
$result = process_manage_edit($mod_name['nombre'],
|
||||
$id_agent['id_agente']);
|
||||
$result = process_manage_edit($mod_name['nombre'], $id_agent);
|
||||
$count++;
|
||||
$success += (int)$result;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ($force == 'group') {
|
||||
$agents_ = array_keys(agents_get_group_agents($group_select,
|
||||
false, "none"));
|
||||
$agents_ = array_keys(agents_get_group_agents($group_select, false, 'none'));
|
||||
|
||||
foreach ($agents_ as $id_agent) {
|
||||
$module_name = db_get_all_rows_filter('tagente_modulo',
|
||||
array('id_agente' => $id_agent),'nombre');
|
||||
if ($module_name == false) {
|
||||
$filter = array('id_agente' => $id_agent);
|
||||
$module_name = db_get_all_rows_filter('tagente_modulo', $filter, 'nombre');
|
||||
if ($module_name === false)
|
||||
$module_name = array();
|
||||
}
|
||||
|
||||
foreach($module_name as $mod_name) {
|
||||
$result = process_manage_edit($mod_name['nombre'],
|
||||
$id_agent);
|
||||
$count ++;
|
||||
$result = process_manage_edit($mod_name['nombre'], $id_agent);
|
||||
$count++;
|
||||
$success += (int)$result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We empty the agents array to skip the standard procedure
|
||||
$agents_ = array();
|
||||
}
|
||||
|
||||
|
||||
|
||||
else {
|
||||
// Standard procedure
|
||||
foreach ($agents_ as $agent_) {
|
||||
|
||||
if ($modules_ == false) {
|
||||
if ($modules_ == false)
|
||||
$modules_ = array();
|
||||
}
|
||||
|
||||
foreach ($modules_ as $module_) {
|
||||
$result = process_manage_edit ($module_, $agents_);
|
||||
$count ++;
|
||||
$count++;
|
||||
$success += (int)$result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ui_print_result_message ($success > 0,
|
||||
__('Successfully updated') .
|
||||
"(" . $success . "/" . $count . ")",
|
||||
__('Successfully updated') . "(" . $success . "/" . $count . ")",
|
||||
__('Could not be updated'));
|
||||
|
||||
$info = 'Modules: ' . json_encode($modules_) .
|
||||
' Agents: ' . json_encode($agents_);
|
||||
if ($success > 0) {
|
||||
db_pandora_audit("Massive management", "Edit module", false,
|
||||
false, $info);
|
||||
db_pandora_audit("Massive management", "Edit module", false, false, $info);
|
||||
}
|
||||
else {
|
||||
db_pandora_audit("Massive management",
|
||||
"Fail try to edit module", false, false, $info);
|
||||
db_pandora_audit("Massive management", "Fail try to edit module", false, false, $info);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2436,4 +2436,29 @@ function array2XML($data, $root = null, $xml = NULL) {
|
|||
|
||||
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);
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -648,6 +648,11 @@ function config_process_config () {
|
|||
exit;
|
||||
}
|
||||
|
||||
$is_windows = false;
|
||||
if (substr(strtolower(PHP_OS), 0, 3) === 'win') {
|
||||
$is_windows = true;
|
||||
}
|
||||
|
||||
/* Compatibility fix */
|
||||
foreach ($configs as $c) {
|
||||
$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'])) {
|
||||
config_update_value ('date_format', 'F j, Y, g:i a');
|
||||
}
|
||||
|
@ -821,7 +835,12 @@ function config_process_config () {
|
|||
}
|
||||
|
||||
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"])) {
|
||||
|
@ -963,7 +982,12 @@ function config_process_config () {
|
|||
}
|
||||
|
||||
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'])) {
|
||||
|
|
|
@ -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_lastalerts','1');
|
||||
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_color2', '#FFFF00');
|
||||
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 ('date_format', 'F j, Y, g:i a');
|
||||
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 ('prominent_time', 'comparation');
|
||||
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_warning', 'include/sounds/negativebeep.wav');
|
||||
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_url', ' ');
|
||||
INSERT INTO tconfig (token, value) VALUES ('netflow_path', '/var/spool/pandora/data_in/netflow');
|
||||
INSERT INTO tconfig (token, value) VALUES ('integria_url', '');
|
||||
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_nfdump', '/usr/bin/nfdump');
|
||||
|
|
|
@ -55,7 +55,6 @@ INSERT INTO "tconfig" ("token", "value") VALUES
|
|||
('show_unknown','0'),
|
||||
('show_lastalerts','1'),
|
||||
('style','pandora'),
|
||||
('remote_config', '/var/spool/pandora/data_in'),
|
||||
('graph_color1', '#38B800'),
|
||||
('graph_color2', '#FFFF00'),
|
||||
('graph_color3', '#FF6600'),
|
||||
|
@ -91,7 +90,6 @@ INSERT INTO "tconfig" ("token", "value") VALUES
|
|||
('integria_api_password', ''),
|
||||
('integria_inventory', '0'),
|
||||
('integria_url', ''),
|
||||
('netflow_path', '/var/spool/pandora/data_in/netflow'),
|
||||
('netflow_interval', '3600'),
|
||||
('netflow_daemon', '/usr/bin/nfcapd'),
|
||||
('netflow_nfdump', '/usr/bin/nfdump'),
|
||||
|
|
|
@ -42,7 +42,6 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES
|
|||
('show_unknown','0'),
|
||||
('show_lastalerts','1'),
|
||||
('style','pandora'),
|
||||
('remote_config', '/var/spool/pandora/data_in'),
|
||||
('graph_color1', '#99dd00'),
|
||||
('graph_color2', '#336600'),
|
||||
('graph_color3', '#3399cc'),
|
||||
|
@ -77,7 +76,6 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES
|
|||
('integria_api_password', ''),
|
||||
('integria_inventory', '0'),
|
||||
('integria_url', ''),
|
||||
('netflow_path', '/var/spool/pandora/data_in/netflow'),
|
||||
('netflow_interval', '3600'),
|
||||
('netflow_daemon', '/usr/bin/nfcapd'),
|
||||
('netflow_nfdump', '/usr/bin/nfdump'),
|
||||
|
|
Loading…
Reference in New Issue