mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-27 23:54:18 +02:00
enh(varnish): add compatibility 6.6.x version (#2827)
This commit is contained in:
parent
0df833b21e
commit
c077ad700a
@ -167,8 +167,7 @@ sub custom_output_second {
|
|||||||
|
|
||||||
my $label = $self->{label};
|
my $label = $self->{label};
|
||||||
$label =~ s/-/_/g;
|
$label =~ s/-/_/g;
|
||||||
my $msg = sprintf('%s: %.2f/s', $self->{result_values}->{$label . '_description'}, $self->{result_values}->{$label});
|
return sprintf('%s: %.2f/s', $self->{result_values}->{$label . '_description'}, $self->{result_values}->{$label});
|
||||||
return $msg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub custom_output {
|
sub custom_output {
|
||||||
@ -176,8 +175,7 @@ sub custom_output {
|
|||||||
|
|
||||||
my $label = $self->{label};
|
my $label = $self->{label};
|
||||||
$label =~ s/-/_/g;
|
$label =~ s/-/_/g;
|
||||||
my $msg = sprintf('%s: %s', $self->{result_values}->{$label . '_description'}, $self->{result_values}->{$label });
|
return sprintf('%s: %s', $self->{result_values}->{$label . '_description'}, $self->{result_values}->{$label});
|
||||||
return $msg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub set_counters {
|
sub set_counters {
|
||||||
@ -238,7 +236,9 @@ sub check_varnish_old {
|
|||||||
sub check_varnish_new {
|
sub check_varnish_new {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
return if (!defined($options{json}->{'MAIN.uptime'}));
|
my $counters = $options{json};
|
||||||
|
$counters = $counters->{counters} if (defined($counters->{counters})); # since varnish 6.6.x
|
||||||
|
return if (!defined($counters->{'MAIN.uptime'}));
|
||||||
|
|
||||||
# "MAIN.cache_hit": {"type": "MAIN", "value": 18437, "flag": "a", "description": "Cache hits"},
|
# "MAIN.cache_hit": {"type": "MAIN", "value": 18437, "flag": "a", "description": "Cache hits"},
|
||||||
# "MAIN.cache_hitpass": {"type": "MAIN", "value": 3488, "flag": "a", "description": "Cache hits for pass"},
|
# "MAIN.cache_hitpass": {"type": "MAIN", "value": 3488, "flag": "a", "description": "Cache hits for pass"},
|
||||||
@ -246,9 +246,9 @@ sub check_varnish_new {
|
|||||||
# "SMA.s0.g_space": { "description": "Bytes available", "flag": "g", "format": "B", "value": 4244053932 },
|
# "SMA.s0.g_space": { "description": "Bytes available", "flag": "g", "format": "B", "value": 4244053932 },
|
||||||
foreach (@{$self->{varnish_stats}}) {
|
foreach (@{$self->{varnish_stats}}) {
|
||||||
my $category = defined($_->{category}) ? $_->{category} : 'MAIN';
|
my $category = defined($_->{category}) ? $_->{category} : 'MAIN';
|
||||||
next if (!defined($options{json}->{$category . '.' . $_->{entry}}));
|
next if (!defined($counters->{ $category . '.' . $_->{entry} }));
|
||||||
$self->{global}->{$_->{entry}} = $options{json}->{$category . '.' . $_->{entry}}->{value};
|
$self->{global}->{$_->{entry}} = $counters->{ $category . '.' . $_->{entry} }->{value};
|
||||||
$self->{global}->{$_->{entry} . '_description'} = $options{json}->{$category . '.' . $_->{entry}}->{description};
|
$self->{global}->{$_->{entry} . '_description'} = $counters->{ $category . '.' . $_->{entry} }->{description};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,12 +30,11 @@ sub new {
|
|||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$self->{version} = '0.1';
|
$self->{version} = '0.1';
|
||||||
%{$self->{modes}} = (
|
$self->{modes} = {
|
||||||
'stats' => 'apps::varnish::local::mode::stats',
|
'stats' => 'apps::varnish::local::mode::stats'
|
||||||
);
|
};
|
||||||
|
|
||||||
$self->{custom_modes}->{cli} = 'centreon::plugins::script_custom::cli';
|
$self->{custom_modes}->{cli} = 'centreon::plugins::script_custom::cli';
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user