Merge pull request #1752 from tanguyvda/master

fix compilation when fatpacked and date regex issue
This commit is contained in:
qgarnier 2019-11-27 17:37:12 +01:00 committed by GitHub
commit 0b99a9a6ad
2 changed files with 53 additions and 53 deletions

View File

@ -29,7 +29,7 @@ use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold)
sub custom_status_output { sub custom_status_output {
my ($self, %options) = @_; my ($self, %options) = @_;
my $msg = sprintf("Status is '%s' [State: %s], Duration: %s, Percent complete: %s%%", my $msg = sprintf("Status is '%s' [State: %s], Duration: %s, Percent complete: %s%%",
$self->{result_values}->{status}, $self->{result_values}->{state}, $self->{result_values}->{status}, $self->{result_values}->{state},
centreon::plugins::misc::change_seconds(value => $self->{result_values}->{duration}), centreon::plugins::misc::change_seconds(value => $self->{result_values}->{duration}),
@ -39,7 +39,7 @@ sub custom_status_output {
sub custom_status_calc { sub custom_status_calc {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'}; $self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'};
$self->{result_values}->{state} = $options{new_datas}->{$self->{instance} . '_state'}; $self->{result_values}->{state} = $options{new_datas}->{$self->{instance} . '_state'};
$self->{result_values}->{start_time} = $options{new_datas}->{$self->{instance} . '_start_time'}; $self->{result_values}->{start_time} = $options{new_datas}->{$self->{instance} . '_start_time'};
@ -48,10 +48,10 @@ sub custom_status_calc {
my ($start, $end); my ($start, $end);
my %months = ("Jan" => 1, "Feb" => 2, "Mar" => 3, "Apr" => 4, "May" => 5, "Jun" => 6, "Jul" => 7, "Aug" => 8, "Sep" => 9, "Oct" => 10, "Nov" => 11, "Dec" => 12); my %months = ("Jan" => 1, "Feb" => 2, "Mar" => 3, "Apr" => 4, "May" => 5, "Jun" => 6, "Jul" => 7, "Aug" => 8, "Sep" => 9, "Oct" => 10, "Nov" => 11, "Dec" => 12);
if (defined($self->{result_values}->{start_time}) && $self->{result_values}->{start_time} =~ /^(\w+)\s(\w+)\s(\d+)\s(\d+):(\d+):(\d+)\s(\d+)$/) { # Mon Jan 01 13:01:23 2018 if (defined($self->{result_values}->{start_time}) && $self->{result_values}->{start_time} =~ /^(\w+)\s(\w+)\s+(\d+)\s(\d+):(\d+):(\d+)\s(\d+)$/) { # Mon Jan 1 13:01:23 2018 or Mon Jan 15 13:01:23
$start = DateTime->new(year => $7, month => $months{$2}, day => $3, hour => $4, minute => $5, second => $6); $start = DateTime->new(year => $7, month => $months{$2}, day => $3, hour => $4, minute => $5, second => $6);
} }
if (defined($self->{result_values}->{completion_time}) && $self->{result_values}->{completion_time} =~ /^(\w+)\s(\w+)\s(\d+)\s(\d+):(\d+):(\d+)\s(\d+)$/) { if (defined($self->{result_values}->{completion_time}) && $self->{result_values}->{completion_time} =~ /^(\w+)\s(\w+)\s+(\d+)\s(\d+):(\d+):(\d+)\s(\d+)$/) {
$end = DateTime->new(year => $7, month => $months{$2}, day => $3, hour => $4, minute => $5, second => $6); $end = DateTime->new(year => $7, month => $months{$2}, day => $3, hour => $4, minute => $5, second => $6);
} }
@ -70,11 +70,11 @@ sub prefix_output {
sub set_counters { sub set_counters {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{maps_counters_type} = [ $self->{maps_counters_type} = [
{ name => 'global', type => 1, cb_prefix_output => 'prefix_output', message_multiple => 'All NAS deduplication are ok', message_separator => ' - ' }, { name => 'global', type => 1, cb_prefix_output => 'prefix_output', message_multiple => 'All NAS deduplication are ok', message_separator => ' - ' },
]; ];
$self->{maps_counters}->{global} = [ $self->{maps_counters}->{global} = [
{ label => 'status', threshold => 0, set => { { label => 'status', threshold => 0, set => {
key_values => [ { name => 'status' }, { name => 'state' }, { name => 'start_time' }, key_values => [ { name => 'status' }, { name => 'state' }, { name => 'start_time' },
@ -112,9 +112,9 @@ sub new {
my ($class, %options) = @_; my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => $options{options}->add_options(arguments =>
{ {
"hostname:s" => { name => 'hostname' }, "hostname:s" => { name => 'hostname' },
"ssh-option:s@" => { name => 'ssh_option' }, "ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' }, "ssh-path:s" => { name => 'ssh_path' },
@ -127,7 +127,7 @@ sub new {
"warning-status:s" => { name => 'warning_status', default => '%{state} !~ /Enabled/i' }, "warning-status:s" => { name => 'warning_status', default => '%{state} !~ /Enabled/i' },
"critical-status:s" => { name => 'critical_status', default => '' }, "critical-status:s" => { name => 'critical_status', default => '' },
}); });
return $self; return $self;
} }

View File

@ -48,10 +48,10 @@
my ($start, $end); my ($start, $end);
my %months = ("Jan" => 1, "Feb" => 2, "Mar" => 3, "Apr" => 4, "May" => 5, "Jun" => 6, "Jul" => 7, "Aug" => 8, "Sep" => 9, "Oct" => 10, "Nov" => 11, "Dec" => 12); my %months = ("Jan" => 1, "Feb" => 2, "Mar" => 3, "Apr" => 4, "May" => 5, "Jun" => 6, "Jul" => 7, "Aug" => 8, "Sep" => 9, "Oct" => 10, "Nov" => 11, "Dec" => 12);
if (defined($self->{result_values}->{start_time}) && $self->{result_values}->{start_time} =~ /^(\w+)\s(\w+)\s(\d+)\s(\d+):(\d+):(\d+)\s(\d+)$/) { # Mon Jan 01 13:01:23 2018 if (defined($self->{result_values}->{start_time}) && $self->{result_values}->{start_time} =~ /^(\w+)\s(\w+)\s+(\d+)\s(\d+):(\d+):(\d+)\s(\d+)$/) { # Mon Jan 1 13:01:23 2018 or Mon Jan 15 13:01:23
$start = DateTime->new(year => $7, month => $months{$2}, day => $3, hour => $4, minute => $5, second => $6); $start = DateTime->new(year => $7, month => $months{$2}, day => $3, hour => $4, minute => $5, second => $6);
} }
if (defined($self->{result_values}->{completion_time}) && $self->{result_values}->{completion_time} =~ /^(\w+)\s(\w+)\s(\d+)\s(\d+):(\d+):(\d+)\s(\d+)$/) { if (defined($self->{result_values}->{completion_time}) && $self->{result_values}->{completion_time} =~ /^(\w+)\s(\w+)\s+(\d+)\s(\d+):(\d+):(\d+)\s(\d+)$/) {
$end = DateTime->new(year => $7, month => $months{$2}, day => $3, hour => $4, minute => $5, second => $6); $end = DateTime->new(year => $7, month => $months{$2}, day => $3, hour => $4, minute => $5, second => $6);
} }
@ -64,7 +64,7 @@
sub prefix_output { sub prefix_output {
my ($self, %options) = @_; my ($self, %options) = @_;
return "VTL deduplication '" . $options{instance_value}->{name} . "' "; return "VTL deduplication '" . $options{instance_value}->{name} . "' ";
} }
@ -203,77 +203,77 @@
} }
} }
1; 1;
__END__ __END__
=head1 MODE
Check deduped VTL on source. =head1 MODE
=over 8 Check deduped VTL on source.
=item B<--hostname> =over 8
Hostname to query. =item B<--hostname>
=item B<--filter-counters> Hostname to query.
Only display some counters (regexp can be used). =item B<--filter-counters>
Example: --filter-counters='status'
=item B<--warning-status> Only display some counters (regexp can be used).
Example: --filter-counters='status'
Set warning threshold for status (Default: '%{state} !~ /Enabled/i'). =item B<--warning-status>
Can used special variables like: %{status}, %{state}, %{duration}, %{percent_complete}.
=item B<--critical-status> Set warning threshold for status (Default: '%{state} !~ /Enabled/i').
Can used special variables like: %{status}, %{state}, %{duration}, %{percent_complete}.
Set critical threshold for status (Default: ''). =item B<--critical-status>
Can used special variables like: %{status}, %{state}, %{duration}, %{percent_complete}.
=item B<--warning-*> Set critical threshold for status (Default: '').
Can used special variables like: %{status}, %{state}, %{duration}, %{percent_complete}.
Threshold warning. =item B<--warning-*>
Can be: 'original-data-size', 'sent-data-size'.
=item B<--critical-*> Threshold warning.
Can be: 'original-data-size', 'sent-data-size'.
Threshold critical. =item B<--critical-*>
Can be: 'original-data-size', 'sent-data-size'.
=item B<--ssh-option> Threshold critical.
Can be: 'original-data-size', 'sent-data-size'.
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52'). =item B<--ssh-option>
=item B<--ssh-path> Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
Specify ssh command path (default: none) =item B<--ssh-path>
=item B<--ssh-command> Specify ssh command path (default: none)
Specify ssh command (default: 'ssh'). Useful to use 'plink'. =item B<--ssh-command>
=item B<--timeout> Specify ssh command (default: 'ssh'). Useful to use 'plink'.
Timeout in seconds for the command (Default: 30). =item B<--timeout>
=item B<--sudo> Timeout in seconds for the command (Default: 30).
Use 'sudo' to execute the command. =item B<--sudo>
=item B<--command> Use 'sudo' to execute the command.
Command to get information (Default: 'syscli'). =item B<--command>
=item B<--command-path> Command to get information (Default: 'syscli').
Command path. =item B<--command-path>
=item B<--command-options> Command path.
Command options (Default: '--list dedupvtl'). =item B<--command-options>
=back Command options (Default: '--list dedupvtl').
=cut =back
=cut