From e0698406f4d5fa376fb33f5511f584151e54c807 Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Mon, 14 May 2018 14:25:01 +0000 Subject: [PATCH] enhance quadstor vtltapeusage mode (#987) * enhance quadstor vtltapeusage mode * init counter to 0 --- .../quadstor/local/mode/vtltapeusage.pm | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/apps/backup/quadstor/local/mode/vtltapeusage.pm b/apps/backup/quadstor/local/mode/vtltapeusage.pm index 66fbf27bf..1f87a20d3 100644 --- a/apps/backup/quadstor/local/mode/vtltapeusage.pm +++ b/apps/backup/quadstor/local/mode/vtltapeusage.pm @@ -41,7 +41,7 @@ sub custom_status_threshold { eval "$instance_mode->{option_results}->{critical_status}") { $status = 'critical'; } elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' && - eval "$instance_mode->{option_results}->{warning_status}") { + eval "$instance_mode->{option_results}->{warning_status}") { $status = 'warning'; } }; @@ -136,8 +136,21 @@ sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ + { name => 'global', type => 0 }, { name => 'tape', type => 1, cb_prefix_output => 'prefix_tape_output', message_multiple => 'All tapes are ok' } ]; + + $self->{maps_counters}->{global} = [ + { label => 'count', set => { + key_values => [ { name => 'count' } ], + output_template => 'Number of tapes : %s', + perfdatas => [ + { label => 'count', value => 'count_absolute', template => '%s', + unit => 'tapes', min => 0 }, + ], + } + }, + ]; $self->{maps_counters}->{tape} = [ { label => 'status', threshold => 0, set => { @@ -227,7 +240,8 @@ sub manage_selection { sudo => $self->{option_results}->{sudo}, command => $self->{option_results}->{command}, command_path => $self->{option_results}->{command_path}, - command_options => $self->{option_results}->{command_options}); + command_options => $self->{option_results}->{command_options}); + $self->{global}->{count} = 0; $self->{tape} = {}; #Pool Label Element Address Vtype WORM Size Used% Status #Default 701862L2 Unknown 0 LTO 2 200GB No 200 99 Vaulted @@ -257,6 +271,7 @@ sub manage_selection { used_prct => $used_prct, status => $status, }; + $self->{global}->{count}++; } if (scalar(keys %{$self->{tape}}) == 0) { @@ -345,12 +360,12 @@ Can used special variables like: %{status}, %{display} =item B<--warning-*> Threshold warning. -Can be: 'usage'. +Can be: 'count', 'usage'. =item B<--critical-*> Threshold critical. -Can be: 'usage'. +Can be: 'count', 'usage'. =back