improve redis restapi

This commit is contained in:
Colin GAGNAIRE 2017-12-28 16:52:36 +01:00
parent 849d950696
commit da72ccdd8e
5 changed files with 25 additions and 34 deletions

View File

@ -42,6 +42,7 @@ sub new {
if (!defined($options{noptions})) { if (!defined($options{noptions})) {
$options{options}->add_options(arguments => $options{options}->add_options(arguments =>
{ {
"interval:s@" => { name => 'interval' },
"hostname:s@" => { name => 'hostname' }, "hostname:s@" => { name => 'hostname' },
"port:s@" => { name => 'port' }, "port:s@" => { name => 'port' },
"proto:s@" => { name => 'proto' }, "proto:s@" => { name => 'proto' },
@ -95,6 +96,7 @@ sub check_options {
$self->{timeout} = (defined($self->{option_results}->{timeout})) ? shift(@{$self->{option_results}->{timeout}}) : 10; $self->{timeout} = (defined($self->{option_results}->{timeout})) ? shift(@{$self->{option_results}->{timeout}}) : 10;
$self->{proxyurl} = (defined($self->{option_results}->{proxyurl})) ? shift(@{$self->{option_results}->{proxyurl}}) : undef; $self->{proxyurl} = (defined($self->{option_results}->{proxyurl})) ? shift(@{$self->{option_results}->{proxyurl}}) : undef;
$self->{ssl} = (defined($self->{option_results}->{ssl})) ? shift(@{$self->{option_results}->{ssl}}) : 'tlsv1'; $self->{ssl} = (defined($self->{option_results}->{ssl})) ? shift(@{$self->{option_results}->{ssl}}) : 'tlsv1';
$self->{interval} = (defined($self->{option_results}->{interval})) ? shift(@{$self->{option_results}->{interval}}) : '15min';
if (!defined($self->{hostname})) { if (!defined($self->{hostname})) {
$self->{output}->add_option_msg(short_msg => "Need to specify hostname option."); $self->{output}->add_option_msg(short_msg => "Need to specify hostname option.");
@ -105,6 +107,7 @@ sub check_options {
scalar(@{$self->{option_results}->{hostname}}) == 0) { scalar(@{$self->{option_results}->{hostname}}) == 0) {
return 0; return 0;
} }
return 1; return 1;
} }
@ -137,6 +140,12 @@ sub get_connection_info {
return $self->{hostname} . ":" . $self->{port}; return $self->{hostname} . ":" . $self->{port};
} }
sub get_interval {
my ($self, %options) = @_;
return $self->{interval};
}
sub get { sub get {
my ($self, %options) = @_; my ($self, %options) = @_;
@ -189,6 +198,12 @@ RedisLabs Enterprise Cluster Rest API custom mode
=over 8 =over 8
=item B<--interval>
Time interval from which to retrieve statistics (Default: '15min').
Can be : '1sec', '10sec', '5min', '15min',
'1hour', '12hour', '1week'.
=item B<--hostname> =item B<--hostname>
Cluster hostname. Cluster hostname.
@ -217,6 +232,10 @@ Proxy URL if any
Set HTTP timeout Set HTTP timeout
=item B<--ssl>
SSL version (Default: tlsv1)
=back =back
=head1 DESCRIPTION =head1 DESCRIPTION

View File

@ -226,7 +226,6 @@ sub new {
$self->{version} = '1.0'; $self->{version} = '1.0';
$options{options}->add_options(arguments => $options{options}->add_options(arguments =>
{ {
"interval:s" => { name => 'interval', default => '15min' },
"units:s" => { name => 'units', default => '%' }, "units:s" => { name => 'units', default => '%' },
"free" => { name => 'free' }, "free" => { name => 'free' },
}); });
@ -244,7 +243,7 @@ sub check_options {
sub manage_selection { sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;
my $result = $options{custom}->get(path => '/v1/cluster/stats/last?interval='.$instance_mode->{option_results}->{interval}); my $result = $options{custom}->get(path => '/v1/cluster/stats/last?interval='.$options{custom}->get_interval());
my $result2 = $options{custom}->get(path => '/v1/cluster'); my $result2 = $options{custom}->get(path => '/v1/cluster');
my $result3 = $options{custom}->get(path => '/v1/nodes'); my $result3 = $options{custom}->get(path => '/v1/nodes');
@ -304,12 +303,6 @@ Check RedisLabs Enterprise Cluster statistics.
Only display some counters (regexp can be used). Only display some counters (regexp can be used).
Example: --filter-counters='^cpu' Example: --filter-counters='^cpu'
=item B<--interval>
Time interval from which to retrieve statistics (Default: '15min').
Can be : '1sec', '10sec', '5min', '15min',
'1hour', '12hour', '1week'
=item B<--units> =item B<--units>
Units of thresholds (Default: '%') ('%', 'B'). Units of thresholds (Default: '%') ('%', 'B').

View File

@ -441,7 +441,6 @@ sub new {
$self->{version} = '1.0'; $self->{version} = '1.0';
$options{options}->add_options(arguments => $options{options}->add_options(arguments =>
{ {
"interval:s" => { name => 'interval', default => '15min' },
"filter-database:s" => { name => 'filter_database' }, "filter-database:s" => { name => 'filter_database' },
"units:s" => { name => 'units', default => '%' }, "units:s" => { name => 'units', default => '%' },
"free" => { name => 'free' }, "free" => { name => 'free' },
@ -474,7 +473,7 @@ sub change_macros {
sub manage_selection { sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;
my $result = $options{custom}->get(path => '/v1/bdbs/stats/last?interval='.$instance_mode->{option_results}->{interval}); my $result = $options{custom}->get(path => '/v1/bdbs/stats/last?interval='.$options{custom}->get_interval());
my $result2 = $options{custom}->get(path => '/v1/bdbs'); my $result2 = $options{custom}->get(path => '/v1/bdbs');
foreach my $database (keys $result) { foreach my $database (keys $result) {
@ -556,12 +555,6 @@ Check RedisLabs Enterprise Cluster databases statistics.
Only display some counters (regexp can be used). Only display some counters (regexp can be used).
Example: --filter-counters='rate|latency' Example: --filter-counters='rate|latency'
=item B<--interval>
Time interval from which to retrieve statistics (Default: '15min').
Can be : '1sec', '10sec', '5min', '15min',
'1hour', '12hour', '1week'
=item B<--warning-status> =item B<--warning-status>
Set warning threshold for status. Set warning threshold for status.

View File

@ -299,12 +299,11 @@ sub new {
$self->{version} = '1.0'; $self->{version} = '1.0';
$options{options}->add_options(arguments => $options{options}->add_options(arguments =>
{ {
"interval:s" => { name => 'interval', default => '15min' },
"filter-node:s" => { name => 'filter_node' }, "filter-node:s" => { name => 'filter_node' },
"units:s" => { name => 'units', default => '%' }, "units:s" => { name => 'units', default => '%' },
"free" => { name => 'free' }, "free" => { name => 'free' },
"warning-status:s" => { name => 'warning_status', default => '' }, "warning-status:s" => { name => 'warning_status', default => '' },
"critical-status:s" => { name => 'critical_status', default => '%{status} !~ /down/i' }, "critical-status:s" => { name => 'critical_status', default => '%{status} =~ /down/i' },
}); });
return $self; return $self;
@ -331,7 +330,7 @@ sub change_macros {
sub manage_selection { sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;
my $result = $options{custom}->get(path => '/v1/nodes/stats/last?interval='.$instance_mode->{option_results}->{interval}); my $result = $options{custom}->get(path => '/v1/nodes/stats/last?interval='.$options{custom}->get_interval());
my $result2 = $options{custom}->get(path => '/v1/nodes'); my $result2 = $options{custom}->get(path => '/v1/nodes');
foreach my $node (keys $result) { foreach my $node (keys $result) {
@ -399,12 +398,6 @@ Check RedisLabs Enterprise Cluster nodes statistics.
Only display some counters (regexp can be used). Only display some counters (regexp can be used).
Example: --filter-counters='^cpu' Example: --filter-counters='^cpu'
=item B<--interval>
Time interval from which to retrieve statistics (Default: '15min').
Can be : '1sec', '10sec', '5min', '15min',
'1hour', '12hour', '1week'
=item B<--units> =item B<--units>
Units of thresholds (Default: '%') ('%', 'B'). Units of thresholds (Default: '%') ('%', 'B').
@ -423,7 +416,7 @@ Can used special variables like: %{status}, %{shard_list},
=item B<--critical-status> =item B<--critical-status>
Set critical threshold for status (Default: '%{status} !~ /down/i'). Set critical threshold for status (Default: '%{status} =~ /down/i').
Can used special variables like: %{status}, %{shard_list}, Can used special variables like: %{status}, %{shard_list},
%{int_addr}, %{ext_addr}. %{int_addr}, %{ext_addr}.
'status' can be: 'active', 'going_offline', 'offline', 'status' can be: 'active', 'going_offline', 'offline',

View File

@ -324,7 +324,6 @@ sub new {
$self->{version} = '1.0'; $self->{version} = '1.0';
$options{options}->add_options(arguments => $options{options}->add_options(arguments =>
{ {
"interval:s" => { name => 'interval', default => '15min' },
"filter-shard:s" => { name => 'filter_shard' }, "filter-shard:s" => { name => 'filter_shard' },
"warning-status:s" => { name => 'warning_status', default => '' }, "warning-status:s" => { name => 'warning_status', default => '' },
"critical-status:s" => { name => 'critical_status', default => '%{status} =~ /inactive/i | %{backup} =~ /failed/i | "critical-status:s" => { name => 'critical_status', default => '%{status} =~ /inactive/i | %{backup} =~ /failed/i |
@ -355,7 +354,7 @@ sub change_macros {
sub manage_selection { sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;
my $result = $options{custom}->get(path => '/v1/shards/stats/last?interval='.$instance_mode->{option_results}->{interval}); my $result = $options{custom}->get(path => '/v1/shards/stats/last?interval='.$options{custom}->get_interval());
my $result2 = $options{custom}->get(path => '/v1/shards'); my $result2 = $options{custom}->get(path => '/v1/shards');
foreach my $shard (keys $result) { foreach my $shard (keys $result) {
@ -419,12 +418,6 @@ Check RedisLabs Enterprise Cluster shards statistics.
Only display some counters (regexp can be used). Only display some counters (regexp can be used).
Example: --filter-counters='clients' Example: --filter-counters='clients'
=item B<--interval>
Time interval from which to retrieve statistics (Default: '15min').
Can be : '1sec', '10sec', '5min', '15min',
'1hour', '12hour', '1week'
=item B<--warning-status> =item B<--warning-status>
Set warning threshold for status. Set warning threshold for status.