From 87fa7a7125088741f6cab43c46a6385611e26c5f Mon Sep 17 00:00:00 2001 From: fermin831 Date: Tue, 25 Sep 2018 13:42:29 +0200 Subject: [PATCH] Added --set_disabled_and_standby to CLI --- pandora_server/lib/PandoraFMS/Tools.pm | 1 + pandora_server/util/pandora_manage.pl | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index 1758d79459..5e5f58c4a8 100755 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -28,6 +28,7 @@ use Socket qw(inet_ntoa inet_aton); use Sys::Syslog; use Scalar::Util qw(looks_like_number); use LWP::UserAgent; +use threads; # New in 3.2. Used to sendmail internally, without external scripts # use Module::Loaded; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 8314db7273..ccf9294af2 100644 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -136,6 +136,7 @@ sub help_screen{ help_screen_line('--delete_cluster_agent', ' ', 'Deleting cluster agent'); help_screen_line('--delete_cluster_item', '', 'Deleting cluster item'); help_screen_line('--get_cluster_status', '', 'Getting cluster status'); + help_screen_line('--set_disabled_and_standby', ' ', 'Overwrite and disable and standby status'); print "\nMODULES:\n\n" unless $param ne ''; help_screen_line('--create_data_module', " [ \n\t \n\t \n\t \n\t \n\t ]", 'Add data server module to agent'); help_screen_line('--create_web_module', " [ \n\t \n\t \n\t \n\t \n\t \n\t ].\n\t The valid data types are web_data, web_proc, web_content_data or web_content_string", 'Add web server module to agent'); @@ -6125,6 +6126,10 @@ sub pandora_manage_main ($$$) { param_check($ltotal, 1, 0); cli_migration_agent(); } + elsif ($param eq '--set_disabled_and_standby') { + param_check($ltotal, 3, 1); + cli_set_disabled_and_standby(); + } else { print_log "[ERROR] Invalid option '$param'.\n\n"; $param = ''; @@ -6709,4 +6714,23 @@ sub cli_get_cluster_status() { else{ print "\n0\n"; } +} + +############################################################################## +# Set an agent disabled and with standby. +# Related option: --set_disabled_and_standby +############################################################################## + +sub cli_set_disabled_and_standby() { + my ($id, $id_node, $value) = @ARGV[2..4]; + $id_node = 0 unless defined($id_node); + $value = 1 unless defined($value); #Set to disabled by default + + # Call the API. + my $result = api_call( + $conf, 'set', 'disabled_and_standby', $id, $id_node, $value + ); + + my $exit_code = (defined($result) && "$result" eq "1") ? "1" : "0"; + print "\n$exit_code\n"; } \ No newline at end of file