minor changes
This commit is contained in:
parent
884a7cabf7
commit
e43e9f1239
|
@ -147,7 +147,7 @@ function agents_locate_agent(string $field)
|
|||
*
|
||||
* @param string $alias Agent alias.
|
||||
*
|
||||
* @return integer Id from the agent.
|
||||
* @return array|boolean Agents ids or false if error.
|
||||
*/
|
||||
function agents_get_agent_id_by_alias($alias)
|
||||
{
|
||||
|
|
|
@ -6867,115 +6867,6 @@ function api_set_planned_downtimes_additem($id, $thrash1, $other, $thrash3)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add data module to policy. And return id from new module.
|
||||
*
|
||||
* @param string $id Id of the target policy.
|
||||
* @param $thrash1 Don't use.
|
||||
* @param array $other it's array, $other as param is <module_name>;<id_module_type>;<description>;
|
||||
* <id_module_group>;<min>;<max>;<post_process>;<module_interval>;<min_warning>;<max_warning>;<str_warning>;
|
||||
* <min_critical>;<max_critical>;<str_critical>;<history_data>;<configuration_data>;
|
||||
* <disabled_types_event>;<module_macros>;<ff_threshold>;<each_ff>;<ff_threshold_normal>;
|
||||
* <ff_threshold_warning>;<ff_threshold_critical>;<ff_timeout> in this order
|
||||
* and separator char (after text ; ) and separator (pass in param othermode as othermode=url_encode_separator_<separator>)
|
||||
* example:
|
||||
*
|
||||
* example:
|
||||
*
|
||||
* api.php?op=set&op2=add_data_module_policy&id=1&other=data_module_policy_example_name~2~data%20module%20created%20by%20Api~2~0~0~50.00~10~20~180~~21~35~~1~module_begin%0dmodule_name%20pandora_process%0dmodule_type%20generic_data%0dmodule_exec%20ps%20aux%20|%20grep%20pandora%20|%20wc%20-l%0dmodule_end&other_mode=url_encode_separator_~
|
||||
*
|
||||
* @param $thrash3 Don't use
|
||||
*/
|
||||
function api_set_add_data_module_policy($id, $thrash1, $other, $thrash3)
|
||||
{
|
||||
if (defined('METACONSOLE')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($id == '') {
|
||||
returnError('error_add_data_module_policy', __('Error adding data module to policy. Id_policy cannot be left blank.'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (enterprise_hook('policies_check_user_policy', [$id]) === false) {
|
||||
returnError('forbidden', 'string');
|
||||
return;
|
||||
}
|
||||
|
||||
if ($other['data'][0] == '') {
|
||||
returnError('error_add_data_module_policy', __('Error adding data module to policy. Module_name cannot be left blank.'));
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if the module is already in the policy
|
||||
$name_module_policy = enterprise_hook('policies_get_modules', [$id, ['name' => $other['data'][0]], 'name']);
|
||||
|
||||
if ($name_module_policy === ENTERPRISE_NOT_HOOK) {
|
||||
returnError('error_add_data_module_policy', __('Error adding data module to policy.'));
|
||||
return;
|
||||
}
|
||||
|
||||
$disabled_types_event = [];
|
||||
$disabled_types_event[EVENTS_GOING_UNKNOWN] = (int) !$other['data'][16];
|
||||
$disabled_types_event = json_encode($disabled_types_event);
|
||||
|
||||
$values = [];
|
||||
$values['id_tipo_modulo'] = $other['data'][1];
|
||||
$values['description'] = $other['data'][2];
|
||||
$values['id_module_group'] = $other['data'][3];
|
||||
$values['min'] = $other['data'][4];
|
||||
$values['max'] = $other['data'][5];
|
||||
$values['post_process'] = $other['data'][6];
|
||||
$values['module_interval'] = $other['data'][7];
|
||||
$values['min_warning'] = $other['data'][8];
|
||||
$values['max_warning'] = $other['data'][9];
|
||||
$values['str_warning'] = $other['data'][10];
|
||||
$values['min_critical'] = $other['data'][11];
|
||||
$values['max_critical'] = $other['data'][12];
|
||||
$values['str_critical'] = $other['data'][13];
|
||||
$values['history_data'] = $other['data'][14];
|
||||
$values['configuration_data'] = $other['data'][15];
|
||||
$values['disabled_types_event'] = $disabled_types_event;
|
||||
$values['module_macros'] = $other['data'][17];
|
||||
$values['min_ff_event'] = $other['data'][18];
|
||||
$values['each_ff'] = $other['data'][19];
|
||||
$values['min_ff_event_normal'] = $other['data'][20];
|
||||
$values['min_ff_event_warning'] = $other['data'][21];
|
||||
$values['min_ff_event_critical'] = $other['data'][22];
|
||||
$values['ff_timeout'] = $other['data'][23];
|
||||
$values['ff_type'] = $other['data'][24];
|
||||
|
||||
if ($name_module_policy !== false) {
|
||||
if ($name_module_policy[0]['name'] == $other['data'][0]) {
|
||||
returnError(
|
||||
'error_add_data_module_policy',
|
||||
__('Error adding data module to policy. The module is already in the policy.')
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$success = enterprise_hook(
|
||||
'policies_create_module',
|
||||
[
|
||||
$other['data'][0],
|
||||
$id,
|
||||
1,
|
||||
$values,
|
||||
false,
|
||||
]
|
||||
);
|
||||
|
||||
if ($success) {
|
||||
// returnData('string', array('type' => 'string', 'data' => __('Data module added to policy. Is necessary to apply the policy in order to changes take effect.')));
|
||||
returnData('string', ['type' => 'string', 'data' => $success]);
|
||||
} else {
|
||||
returnError('error_add_data_module_policy', 'Error adding data module to policy.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update data module in policy. And return id from new module.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue