From e270776a01011015ccdca34de347a6a9e95ce27d Mon Sep 17 00:00:00 2001 From: marcos Date: Wed, 3 Jun 2020 15:56:19 +0200 Subject: [PATCH] create new api/cli function to set event on progress --- pandora_console/include/functions_api.php | 8 ++++---- pandora_server/util/pandora_manage.pl | 24 ++++++++++++++++++++++- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 82538fa1ee..f5fb12ee1d 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -16027,12 +16027,12 @@ function api_get_event_mcid($server_id, $console_event_id, $trash2, $returnType) * Function to set events in progress status. * * @param [int] $event_id Id event (Node or Meta). - * @param [int] $server_id Id node event in tmetaconsole_event. + * @param [int] $server_id Id node event in tmetaconsole_event (optional). * @param [string] $trash2 don't use. * @param [string] $returnType * * Example - * http://172.17.0.1/pandora_console/include/api.php?op=set&op2=event_in_progress&return_type=json&id=0&id2=0&apipass=1234&user=admin&pass=pandora + * http://127.0.0.1/pandora_console/include/api.php?op=set&op2=event_in_progress&return_type=json&id=0&id2=0&apipass=1234&user=admin&pass=pandora * * @return void */ @@ -16045,8 +16045,8 @@ function api_set_event_in_progress($event_id, $server_id, $trash2, $returnType) 'tmetaconsole_event', ['estado' => 2], [ - 'id_source_event' => $event_id, - 'server_id' => $server_id, + 'server_id' => $server_id, + 'id_evento' => $event_id, ] ); if ($event !== false) { diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 839d937db3..ee7ea1586b 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -243,6 +243,8 @@ sub help_screen{ help_screen_line('--duplicate_visual_console', ' []', 'Duplicate a visual console'); help_screen_line('--export_json_visual_console', ' [] []', 'Creates a json with the visual console elements information'); + print "\nEVENTS\n\n" unless $param ne ''; + help_screen_line('--event_in_progress', ' ', 'Set event in progress'); print "\n"; exit; @@ -254,7 +256,7 @@ sub help_screen{ sub api_call($$$;$$$$) { my ($pa_config, $op, $op2, $id, $id2, $other, $return_type) = @_; my $content = undef; - + eval { # Set the parameters for the POST request. my $params = {}; @@ -7676,6 +7678,9 @@ sub pandora_manage_main ($$$) { elsif ($param eq '--reset_agent_counts') { param_check($ltotal, 1, 0); cli_reset_agent_counts(); + }elsif ($param eq '--event_in_progress') { + param_check($ltotal, 2, 0); + cli_event_in_progress(); } else { print_log "[ERROR] Invalid option '$param'.\n\n"; @@ -8325,3 +8330,20 @@ sub cli_reset_agent_counts() { print "$result \n\n "; } + + +############################################################################## +# Set an event in progress. +# Related option: --event_in_progress +############################################################################## + +sub cli_event_in_progress() { + my ($event_id, $server_id) = @ARGV[2..3]; + + # Call the API. + my $result = api_call( + $conf, 'set', 'event_in_progress', $event_id, $server_id + ); + + print "\n$result\n"; +} \ No newline at end of file