Merge branch '6219_Comprobacion_Paradas_planificadas_CLI_2' into 'develop'
Added check for the creation of planned downtimes by pandora manage See merge request artica/pandorafms!1936
This commit is contained in:
commit
c7a54182a3
|
@ -5411,7 +5411,8 @@ function api_set_planned_downtimes_created ($id, $thrash1, $other, $thrash3) {
|
|||
'periodically_day_to' => $other['data'][14],
|
||||
'type_downtime' => $other['data'][15],
|
||||
'type_execution' => $other['data'][16],
|
||||
'type_periodicity' => $other['data'][17]
|
||||
'type_periodicity' => $other['data'][17],
|
||||
'id_user' => $other['data'][18]
|
||||
);
|
||||
|
||||
$returned = planned_downtimes_created($values);
|
||||
|
|
|
@ -666,6 +666,7 @@ function planned_downtimes_stop ($downtime) {
|
|||
function planned_downtimes_created ($values) {
|
||||
global $config;
|
||||
|
||||
$check_id_user = (bool) db_get_value ('id_user', 'tusuario', 'id_user', $values['id_user']);
|
||||
$check_group = (bool) db_get_value ('id_grupo', 'tgrupo', 'id_grupo', $values['id_group']);
|
||||
$check = (bool) db_get_value ('name', 'tplanned_downtime', 'name', $values['name']);
|
||||
|
||||
|
@ -703,6 +704,26 @@ function planned_downtimes_created ($values) {
|
|||
'message' => __('Not created. Error inserting data') . ". "
|
||||
. __('The end day must be higher than the start day'));
|
||||
}
|
||||
else if ($values['type_downtime'] !== 'quiet' && $values['type_downtime'] !== 'disable_agents' && $values['type_downtime'] !== 'disable_agents_alerts') {
|
||||
return array('return' => false,
|
||||
'message' => __('Not created. Error inserting data') . ". "
|
||||
. __('The downtime must be quiet, disable_agents or disable_agents_alerts'));
|
||||
}
|
||||
else if ($values['type_execution'] !== 'periodically' && $values['type_execution'] !== 'once' ) {
|
||||
return array('return' => false,
|
||||
'message' => __('Not created. Error inserting data') . ". "
|
||||
. __('The execution must be once or periodically'));
|
||||
}
|
||||
else if ($values['type_periodicity'] !== 'weekly' && $values['type_periodicity'] !== 'monthly' ) {
|
||||
return array('return' => false,
|
||||
'message' => __('Not created. Error inserting data') . ". "
|
||||
. __('The periodicity must be weekly or monthly'));
|
||||
}
|
||||
else if (!$check_id_user){
|
||||
return array('return' => false,
|
||||
'message' => __('Not created. Error inserting data') . ". "
|
||||
. __('User not exist'));
|
||||
}
|
||||
else if (!$check_group && $values['id_group'] != 0) {
|
||||
return array('return' => false,
|
||||
'message' => __('Not created. Error inserting data') . ". "
|
||||
|
|
|
@ -112,7 +112,7 @@ sub help_screen{
|
|||
help_screen_line('--delete_group', '<group_name>', 'Delete an agent group');
|
||||
help_screen_line('--update_group', '<group_id>','[<group_name> <parent_group_name> <icon> <description>]', 'Update an agent group');
|
||||
help_screen_line('--stop_downtime', '<downtime_name>', 'Stop a planned downtime');
|
||||
help_screen_line('--create_downtime', "<downtime_name> <description> <date_from> <date_to> <id_group> <monday> <tuesday>\n\t <wednesday> <thursday> <friday> <saturday> <sunday> <periodically_time_from>\n\t <periodically_time_to> <periodically_day_from> <periodically_day_to> <type_downtime> <type_execution> <type_periodicity>", 'Create a planned downtime');
|
||||
help_screen_line('--create_downtime', "<downtime_name> <description> <date_from> <date_to> <id_group> <monday> <tuesday>\n\t <wednesday> <thursday> <friday> <saturday> <sunday> <periodically_time_from>\n\t <periodically_time_to> <periodically_day_from> <periodically_day_to> <type_downtime> <type_execution> <type_periodicity> <id_user>", 'Create a planned downtime');
|
||||
help_screen_line('--add_item_planned_downtime', "<id_downtime> <id_agente1,id_agente2,id_agente3...id_agenteN> <name_module1,name_module2,name_module3...name_moduleN> ", 'Add a items planned downtime');
|
||||
help_screen_line('--get_all_planned_downtimes', '<name> [<id_group> <type_downtime> <type_execution> <type_periodicity>]', 'Get all planned downtime');
|
||||
help_screen_line('--get_planned_downtimes_items', '<name> [<id_group> <type_downtime> <type_execution> <type_periodicity>]', 'Get all items of planned downtimes');
|
||||
|
@ -4095,7 +4095,7 @@ sub cli_policy_add_agent() {
|
|||
|
||||
sub cli_create_planned_downtime() {
|
||||
my $name = @ARGV[2];
|
||||
my @todo = @ARGV[3..20];
|
||||
my @todo = @ARGV[3..21];
|
||||
my $other = join('|', @todo);
|
||||
|
||||
my $result = api_call(\%conf,'set', 'planned_downtimes_created', $name, undef, "$other");
|
||||
|
@ -6035,7 +6035,7 @@ sub pandora_manage_main ($$$) {
|
|||
cli_add_tag_to_module();
|
||||
}
|
||||
elsif ($param eq '--create_downtime') {
|
||||
param_check($ltotal, 19);
|
||||
param_check($ltotal, 20);
|
||||
cli_create_planned_downtime();
|
||||
}
|
||||
elsif ($param eq '--add_item_downtime') {
|
||||
|
|
Loading…
Reference in New Issue