From 9ad6d8b1b33f1f78f555d7f60273afaf48957c24 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Mon, 18 Oct 2021 12:18:37 +0200 Subject: [PATCH] Small fixes in elasticsearch scripts --- zabbix_scripts/check_elasticsearch | 7 ++++--- zabbix_scripts/disco_elasticsearch | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/zabbix_scripts/check_elasticsearch b/zabbix_scripts/check_elasticsearch index 6f28b04..3851102 100644 --- a/zabbix_scripts/check_elasticsearch +++ b/zabbix_scripts/check_elasticsearch @@ -22,8 +22,8 @@ my $pretty = 0; my $json = {}; GetOptions ( - 'user=s' => \$user, - 'password|p=s' => \$pass, + 'user:s' => \$user, + 'password:s' => \$pass, 'url=s' => \$url, 'cert-check!' => \$certcheck, 'cluster' => \$cluster, @@ -61,6 +61,7 @@ if (not $certcheck){ my $ua = LWP::UserAgent->new( ssl_opts => $sslopts ); +$ua->env_proxy; if ($cluster){ $json = make_request('/_cluster/stats'); @@ -76,7 +77,7 @@ sub make_request { my $path = shift; my $req_url = $url . $path; my $req = GET $req_url; - if (defined $user and defined $pass){ + if (defined $user and $user ne '' and defined $pass and $pass ne ''){ $req->authorization_basic($user, $pass); } my $resp = $ua->request($req); diff --git a/zabbix_scripts/disco_elasticsearch b/zabbix_scripts/disco_elasticsearch index e4ef2f1..bae9227 100644 --- a/zabbix_scripts/disco_elasticsearch +++ b/zabbix_scripts/disco_elasticsearch @@ -21,8 +21,8 @@ my $pretty = 0; my $json = []; GetOptions ( - 'user=s' => \$user, - 'password|p=s' => \$pass, + 'user:s' => \$user, + 'password:s' => \$pass, 'url=s' => \$url, 'cert-check!' => \$certcheck, 'nodes' => \$nodes, @@ -57,6 +57,7 @@ if (not $certcheck){ my $ua = LWP::UserAgent->new( ssl_opts => $sslopts ); +$ua->env_proxy; if ($nodes){ foreach (@{make_request('/_cat/nodes?format=json')}){ @@ -81,7 +82,7 @@ sub make_request { my $path = shift; my $req_url = $url . $path; my $req = GET $req_url; - if (defined $user and defined $pass){ + if (defined $user and $user ne '' and defined $pass and $pass ne ''){ $req->authorization_basic($user, $pass); } my $resp = $ua->request($req);