|
|
@ -21,8 +21,8 @@ my $pretty = 0; |
|
|
|
my $json = []; |
|
|
|
my $json = []; |
|
|
|
|
|
|
|
|
|
|
|
GetOptions ( |
|
|
|
GetOptions ( |
|
|
|
'user=s' => \$user, |
|
|
|
'user:s' => \$user, |
|
|
|
'password|p=s' => \$pass, |
|
|
|
'password:s' => \$pass, |
|
|
|
'url=s' => \$url, |
|
|
|
'url=s' => \$url, |
|
|
|
'cert-check!' => \$certcheck, |
|
|
|
'cert-check!' => \$certcheck, |
|
|
|
'nodes' => \$nodes, |
|
|
|
'nodes' => \$nodes, |
|
|
@ -57,6 +57,7 @@ if (not $certcheck){ |
|
|
|
my $ua = LWP::UserAgent->new( |
|
|
|
my $ua = LWP::UserAgent->new( |
|
|
|
ssl_opts => $sslopts |
|
|
|
ssl_opts => $sslopts |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
$ua->env_proxy; |
|
|
|
|
|
|
|
|
|
|
|
if ($nodes){ |
|
|
|
if ($nodes){ |
|
|
|
foreach (@{make_request('/_cat/nodes?format=json')}){ |
|
|
|
foreach (@{make_request('/_cat/nodes?format=json')}){ |
|
|
@ -81,7 +82,7 @@ sub make_request { |
|
|
|
my $path = shift; |
|
|
|
my $path = shift; |
|
|
|
my $req_url = $url . $path; |
|
|
|
my $req_url = $url . $path; |
|
|
|
my $req = GET $req_url; |
|
|
|
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); |
|
|
|
$req->authorization_basic($user, $pass); |
|
|
|
} |
|
|
|
} |
|
|
|
my $resp = $ua->request($req); |
|
|
|
my $resp = $ua->request($req); |
|
|
|