From 94d628095dea4598f32cabfc628e30451c47db6a Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Wed, 10 Jun 2020 08:35:01 +0200 Subject: [PATCH] Added option for get the agent status --- pandora_server/util/pandora_manage.pl | 37 ++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 856f5ee22e..db3f1a052a 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -121,6 +121,7 @@ sub help_screen{ help_screen_line('--get_agent_group', ' []', 'Get the group name of an agent'); help_screen_line('--get_agent_group_id', ' []', 'Get the group ID of an agent'); help_screen_line('--get_agent_modules', ' []', 'Get the modules of an agent'); + help_screen_line('--get_agent_status', ' []', 'Get the status of an agent'); help_screen_line('--get_agents_id_name_by_alias', '', '[]', 'List id and alias of agents mathing given alias'); help_screen_line('--get_agents', '[ ]', "Get \n\t list of agents with optative filter parameters"); help_screen_line('--delete_conf_file', ' []', 'Delete a local conf of a given agent'); @@ -784,7 +785,7 @@ sub pandora_get_agent_status ($$) { return 'normal' unless $normal == 0; return 'normal' unless $normal == 0; - return ''; + return 'not_init'; } ########################################################################## @@ -4849,6 +4850,36 @@ sub cli_get_agent_modules() { } } +############################################################################## +# Show the status of an agent +# Related option: --get_agent_status +############################################################################## + +sub cli_get_agent_status() { + my ($agent_name,$use_alias) = @ARGV[2..3]; + + my @id_agents; + my $id_agent; + + if (defined $use_alias and $use_alias eq 'use_alias') { + @id_agents = get_agent_ids_from_alias($dbh,$agent_name); + + foreach my $id (@id_agents) { + exist_check($id->{'id_agente'},'agent',$agent_name); + + my $agent_status = pandora_get_agent_status($dbh,$id->{'id_agente'}); + + print pandora_get_agent_status($dbh,$id->{'id_agente'})."\n"; + } + } else { + $id_agent = get_agent_id($dbh,$agent_name); + exist_check($id_agent,'agent',$agent_name); + + print pandora_get_agent_status($dbh,$id_agent)."\n"; + } +} + + ############################################################################## # Show id, name and id_server of an agent given alias # Related option: --get_agents_id_name_by_alias @@ -7469,6 +7500,10 @@ sub pandora_manage_main ($$$) { param_check($ltotal, 2, 1); cli_get_agent_modules(); } + elsif ($param eq '--get_agent_status') { + param_check($ltotal, 2, 1); + cli_get_agent_status(); + } elsif ($param eq '--get_agents_id_name_by_alias') { param_check($ltotal, 2,1); cli_get_agents_id_name_by_alias();