Skip to content

Commit

Permalink
Merge pull request #515 from EdwinHoksberg/feature/add-opensearch-opt…
Browse files Browse the repository at this point in the history
…ions

Add secure(-S) and disable hostname validation(-i) options for opensearch script
  • Loading branch information
VVelox authored May 6, 2024
2 parents 3990c53 + 1760c4e commit 877a6f3
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions snmp/opensearch
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ Supported command line options are as below.
Default: 127.0.0.1
-p <port> The port to use.
Default: 9200
-S Use https instead of http.
-I Do not verify hostname (when used with -S).
-P Pretty print.
-S Use HTTPS.
Expand Down Expand Up @@ -65,17 +67,19 @@ sub main::HELP_MESSAGE {
. " Default: 127.0.0.1\n"
. "-p <port> The port to use.\n"
. " Default: 9200\n"
. "-P Pretty print.\n"
. "-S Use HTTPS.\n";
. "-S Use https instead of http.\n"
. "-I Do not verify hostname (when used with -S).\n"
. "-P Pretty print.\n";
}

my $protocol = 'http';
my $host = '127.0.0.1';
my $port = 9200;
my $schema = 'http';

#gets the options
my %opts;
getopts( 'a:c:h:p:P:S', \%opts );
getopts( 'a:c:h:p:PIS', \%opts );
if ( defined( $opts{h} ) ) {
$host = $opts{h};
}
Expand Down Expand Up @@ -112,6 +116,12 @@ if ( $opts{P} ) {

my $ua = LWP::UserAgent->new( timeout => 10 );

if ( $opts{I} ) {
$ua->ssl_opts( verify_hostname => 0, SSL_verify_mode => 0x00 );
}

my $stats_response = $ua->get($stats_url);

if ( defined( $opts{c} ) ) {
# set ca file
$ua->ssl_opts( SSL_ca_file => $opts{c});
Expand Down

0 comments on commit 877a6f3

Please sign in to comment.