add vsx mode for checkpoint
This commit is contained in:
parent
a8f121e960
commit
18aa9e68a6
|
@ -24,22 +24,16 @@ use base qw(centreon::plugins::templates::counter);
|
|||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc);
|
||||
|
||||
sub custom_status_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $msg = "HA State: '" . $self->{result_values}->{hastate} . "' ";
|
||||
$msg .= "Role: '" . $self->{result_values}->{role} . "' ";
|
||||
return $msg;
|
||||
}
|
||||
|
||||
sub custom_status_calc {
|
||||
my ($self, %options) = @_;
|
||||
$self->{result_values}->{hastate} = $options{new_datas}->{$self->{instance} . '_hastate'};
|
||||
$self->{result_values}->{role} = $options{new_datas}->{$self->{instance} . '_role'};
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -49,12 +43,12 @@ sub set_counters {
|
|||
$self->{maps_counters}->{high_availability} = [
|
||||
{ label => 'status', threshold => 0, set => {
|
||||
key_values => [ { name => 'hastate' }, { name => 'role' } ],
|
||||
closure_custom_calc => $self->can('custom_status_calc'),
|
||||
closure_custom_calc => \&catalog_status_calc,
|
||||
closure_custom_output => $self->can('custom_status_output'),
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&catalog_status_threshold,
|
||||
closure_custom_threshold_check => \&catalog_status_threshold
|
||||
}
|
||||
},
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -63,12 +57,11 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"warning-status:s" => { name => 'warning_status', default => '' },
|
||||
"critical-status:s" => { name => 'critical_status', default => '%{hastate} !~ /(UP|working)/' },
|
||||
"no-ha-status:s" => { name => 'no_ha_status', default => 'UNKNOWN' },
|
||||
});
|
||||
$options{options}->add_options(arguments => {
|
||||
'warning-status:s' => { name => 'warning_status', default => '' },
|
||||
'critical-status:s' => { name => 'critical_status', default => '%{hastate} !~ /(UP|working)/' },
|
||||
'no-ha-status:s' => { name => 'no_ha_status', default => 'UNKNOWN' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
@ -96,20 +89,27 @@ sub manage_selection {
|
|||
|
||||
$self->{high_availability} = {};
|
||||
|
||||
my $result = $options{snmp}->get_leef(oids => [$oid_haInstalled, $oid_haState, $oid_haStatCode, $oid_haStarted],
|
||||
nothing_quit => 1);
|
||||
my $result = $options{snmp}->get_leef(
|
||||
oids => [$oid_haInstalled, $oid_haState, $oid_haStatCode, $oid_haStarted],
|
||||
nothing_quit => 1
|
||||
);
|
||||
|
||||
if ($result->{$oid_haInstalled} < 1 or $result->{$oid_haStarted} eq "no") {
|
||||
$self->{output}->output_add(severity => $self->{option_results}->{no_ha_status},
|
||||
short_msg => sprintf("Looks like HA is not started, or not installed .."),
|
||||
long_msg => sprintf("HA Installed : '%u' HA Started : '%s'",
|
||||
$result->{$oid_haInstalled}, $result->{$oid_haStarted}),
|
||||
);
|
||||
$self->{output}->output_add(
|
||||
severity => $self->{option_results}->{no_ha_status},
|
||||
short_msg => sprintf("Looks like HA is not started, or not installed .."),
|
||||
long_msg => sprintf(
|
||||
"HA Installed : '%u' HA Started : '%s'",
|
||||
$result->{$oid_haInstalled}, $result->{$oid_haStarted}
|
||||
),
|
||||
);
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
$self->{high_availability} = { hastate => $map_status{$result->{$oid_haStatCode}},
|
||||
role => $result->{$oid_haState} };
|
||||
$self->{high_availability} = {
|
||||
hastate => $map_status{$result->{$oid_haStatCode}},
|
||||
role => $result->{$oid_haState}
|
||||
};
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -33,11 +33,12 @@ sub custom_usage_output {
|
|||
my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute});
|
||||
my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute});
|
||||
|
||||
my $msg = sprintf("Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
|
||||
$total_size_value . " " . $total_size_unit,
|
||||
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used_absolute},
|
||||
$total_free_value . " " . $total_free_unit, 100 - $self->{result_values}->{prct_used_absolute});
|
||||
return $msg;
|
||||
return sprintf(
|
||||
'Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)',
|
||||
$total_size_value . " " . $total_size_unit,
|
||||
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used_absolute},
|
||||
$total_free_value . " " . $total_free_unit, 100 - $self->{result_values}->{prct_used_absolute}
|
||||
);
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
|
@ -61,6 +62,7 @@ sub set_counters {
|
|||
}
|
||||
},
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{swap} = [
|
||||
{ label => 'swap', set => {
|
||||
key_values => [ { name => 'prct_used' }, { name => 'used' }, { name => 'free' }, { name => 'total' } ],
|
||||
|
@ -73,6 +75,7 @@ sub set_counters {
|
|||
}
|
||||
},
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{malloc} = [
|
||||
{ label => 'failed-malloc', set => {
|
||||
key_values => [ { name => 'failed_mallocs', diff => 1 } ],
|
||||
|
@ -103,9 +106,8 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
});
|
||||
$options{options}->add_options(arguments => {
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
|
|
@ -127,14 +127,14 @@ sub manage_selection {
|
|||
$self->{output}->output_add(long_msg => "skipping '" . $result->{tunnelPeerObjName} . "': no matching filter.", debug => 1);
|
||||
next;
|
||||
}
|
||||
|
||||
|
||||
$self->{vpn}->{$instance} = {
|
||||
display => $result->{tunnelPeerObjName},
|
||||
status => $result->{tunnelState},
|
||||
type => $result->{tunnelType}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
if (scalar(keys %{$self->{vpn}}) <= 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "No vpn found.");
|
||||
$self->{output}->option_exit();
|
||||
|
|
|
@ -0,0 +1,242 @@
|
|||
#
|
||||
# Copyright 2020 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package network::checkpoint::snmp::mode::vsx;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Digest::MD5 qw(md5_hex);
|
||||
|
||||
sub vsx_long_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "checking virtual system '" . $options{instance_value}->{display} . "'";
|
||||
}
|
||||
|
||||
sub prefix_vsx_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "virtual system '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub prefix_cpu_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return 'cpu usage: ';
|
||||
}
|
||||
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'vsx', type => 3, cb_prefix_output => 'prefix_vsx_output', cb_long_output => 'vsx_long_output',
|
||||
indent_long_output => ' ', message_multiple => 'All virtual systems are ok',
|
||||
group => [
|
||||
{ name => 'vsx_cpu', type => 0, cb_prefix_output => 'prefix_cpu_output', skipped_code => { -10 => 1 } },
|
||||
{ name => 'vsx_memory', type => 0, skipped_code => { -10 => 1 } },
|
||||
{ name => 'vsx_connection', type => 0, skipped_code => { -10 => 1 } },
|
||||
{ name => 'vsx_traffic', type => 0, skipped_code => { -10 => 1 } }
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{vsx_cpu} = [
|
||||
{ label => 'cpu-utilization-1hour', nlabel => 'virtualsystem.cpu.utilization.1hour.percentage', set => {
|
||||
key_values => [ { name => 'cpu_1hour' }, { name => 'display' } ],
|
||||
output_template => '%.2f%% (1hour)',
|
||||
perfdatas => [
|
||||
{ value => 'cpu_1hour_absolute', template => '%.2f', unit => '%', min => 0, max => 100,
|
||||
label_extra_instance => 1, instance_use => 'display_absolute' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'cpu-utilization-1min', nlabel => 'virtualsystem.cpu.utilization.1min.percentage', set => {
|
||||
key_values => [ { name => 'cpu_1min' }, { name => 'display' } ],
|
||||
output_template => '%.2f%% (1min)',
|
||||
perfdatas => [
|
||||
{ value => 'cpu_1min_absolute', template => '%.2f', unit => '%', min => 0, max => 100,
|
||||
label_extra_instance => 1, instance_use => 'display_absolute' }
|
||||
]
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{vsx_memory} = [
|
||||
{ label => 'memory-usage', nlabel => 'virtualsystem.memory.usage.bytes', set => {
|
||||
key_values => [ { name => 'memory_used' }, { name => 'display' } ],
|
||||
output_template => 'memory used: %s%s',
|
||||
output_change_bytes => 1,
|
||||
perfdatas => [
|
||||
{ value => 'memory_used_absolute', template => '%s', min => 0,
|
||||
unit => 'B', label_extra_instance => 1, instance_use => 'display_absolute' }
|
||||
]
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{vsx_connection} = [
|
||||
{ label => 'connections-active', nlabel => 'virtualsystem.connections.active.count', set => {
|
||||
key_values => [ { name => 'active_connections' }, { name => 'display' } ],
|
||||
output_template => 'active connections: %d',
|
||||
perfdatas => [
|
||||
{ value => 'active_connections_absolute', template => '%d',
|
||||
min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }
|
||||
]
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{vsx_traffic} = [
|
||||
{ label => 'traffic-accepted', nlabel => 'virtualsystem.traffic.accepted.bitspersecond', set => {
|
||||
key_values => [ { name => 'traffic_accepted', diff => 1 }, { name => 'display' } ],
|
||||
output_template => 'traffic accepted: %s%s/s',
|
||||
per_second => 1, output_change_bytes => 2,
|
||||
perfdatas => [
|
||||
{ value => 'traffic_accepted_per_second', template => '%s',
|
||||
min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'traffic-dropped', nlabel => 'virtualsystem.traffic.dropped.bitspersecond', set => {
|
||||
key_values => [ { name => 'traffic_dropped', diff => 1 }, { name => 'display' } ],
|
||||
output_template => 'traffic dropped: %s%s/s',
|
||||
per_second => 1, output_change_bytes => 2,
|
||||
perfdatas => [
|
||||
{ value => 'traffic_dropped_per_second', template => '%s',
|
||||
min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'traffic-rejected', nlabel => 'virtualsystem.traffic.rejected.bitspersecond', set => {
|
||||
key_values => [ { name => 'traffic_rejected', diff => 1 }, { name => 'display' } ],
|
||||
output_template => 'traffic rejected: %s%s/s',
|
||||
per_second => 1, output_change_bytes => 2,
|
||||
perfdatas => [
|
||||
{ value => 'traffic_rejected_per_second', template => '%s',
|
||||
min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }
|
||||
]
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'filter-vsx:s' => { name => 'filter_vsx' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
my $mapping = {
|
||||
cpu_1min => { oid => '.1.3.6.1.4.1.2620.1.16.22.2.1.3' }, # vsxStatusCPUUsage1min
|
||||
cpu_1hour => { oid => '.1.3.6.1.4.1.2620.1.16.22.2.1.4' }, # vsxStatusCPUUsage1hr
|
||||
memory_used => { oid => '.1.3.6.1.4.1.2620.1.16.22.3.1.3' }, # vsxStatusMemoryUsage (KB)
|
||||
active_connections => { oid => '.1.3.6.1.4.1.2620.1.16.23.1.1.2' }, # vsxCountersConnNum
|
||||
traffic_accepted => { oid => '.1.3.6.1.4.1.2620.1.16.23.1.1.9' }, # vsxCountersBytesAcceptedTotal
|
||||
traffic_dropped => { oid => '.1.3.6.1.4.1.2620.1.16.23.1.1.10' }, # vsxCountersBytesDroppedTotal
|
||||
traffic_rejected => { oid => '.1.3.6.1.4.1.2620.1.16.23.1.1.11' } # vsxCountersBytesRejectedTotal
|
||||
};
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $oid_vsxStatusVsName = '.1.3.6.1.4.1.2620.1.16.22.1.1.3';
|
||||
my $snmp_result = $options{snmp}->get_table(
|
||||
oid => $oid_vsxStatusVsName,
|
||||
nothing_quit => 1
|
||||
);
|
||||
|
||||
$self->{vsx} = {};
|
||||
foreach (keys %$snmp_result) {
|
||||
/^$oid_vsxStatusVsName\.(.*)/;
|
||||
my $instance = $1;
|
||||
my $name = $snmp_result->{$_};
|
||||
|
||||
if (defined($self->{option_results}->{filter_vsx}) && $self->{option_results}->{filter_vsx} ne '' &&
|
||||
$name !~ /$self->{option_results}->{filter_vsx}/) {
|
||||
$self->{output}->output_add(long_msg => "skipping virtual system '" . $name . "'.", debug => 1);
|
||||
next;
|
||||
}
|
||||
|
||||
$self->{vsx}->{$instance} = {
|
||||
display => $name,
|
||||
vsx_cpu => { display => $name },
|
||||
vsx_memory => { display => $name },
|
||||
vsx_connection => { display => $name },
|
||||
vsx_traffic => { display => $name }
|
||||
};
|
||||
}
|
||||
|
||||
return if (scalar(keys %{$self->{vsx}}) <= 0);
|
||||
|
||||
$options{snmp}->load(
|
||||
oids => [ map($_->{oid}, values(%$mapping)) ],
|
||||
instances => [ keys %{$self->{vsx}} ],
|
||||
instance_regexp => '^(.*)$'
|
||||
);
|
||||
$snmp_result = $options{snmp}->get_leef();
|
||||
foreach (keys %{$self->{vsx}}) {
|
||||
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $_);
|
||||
$self->{vsx}->{$_}->{vsx_cpu}->{cpu_1min} = $result->{cpu_1min};
|
||||
$self->{vsx}->{$_}->{vsx_cpu}->{cpu_1hour} = $result->{cpu_1hour};
|
||||
$self->{vsx}->{$_}->{vsx_memory}->{memory_used} = $result->{memory_used} * 1024;
|
||||
$self->{vsx}->{$_}->{vsx_connection}->{active_connections} = $result->{active_connections};
|
||||
$self->{vsx}->{$_}->{vsx_traffic}->{traffic_accepted} = $result->{traffic_accepted} * 8;
|
||||
$self->{vsx}->{$_}->{vsx_traffic}->{traffic_dropped} = $result->{traffic_dropped} * 8;
|
||||
$self->{vsx}->{$_}->{vsx_traffic}->{traffic_rejected} = $result->{traffic_rejected} * 8;
|
||||
}
|
||||
|
||||
$self->{cache_name} = 'checkpoint_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
|
||||
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' .
|
||||
(defined($self->{option_results}->{filter_vsx}) ? md5_hex($self->{option_results}->{filter_vsx}) : md5_hex('all'));
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check virtual systems.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--filter-vsx>
|
||||
|
||||
Filter by virtual system name (can be a regexp).
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds.
|
||||
Can be: 'cpu-utilization', 'sessions-active', 'session-rate',
|
||||
'memory-usage-prct', 'license-usage', 'license-free',
|
||||
'license-usage-prct', 'traffic-in', 'traffic-out', 'policies-active'.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -31,16 +31,17 @@ sub new {
|
|||
|
||||
$self->{version} = '0.5';
|
||||
%{$self->{modes}} = (
|
||||
'connections' => 'network::checkpoint::snmp::mode::connections',
|
||||
'cpu' => 'network::checkpoint::snmp::mode::cpu',
|
||||
'hardware' => 'network::checkpoint::snmp::mode::hardware',
|
||||
'hastate' => 'network::checkpoint::snmp::mode::hastate',
|
||||
'interfaces' => 'snmp_standard::mode::interfaces',
|
||||
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
|
||||
'memory' => 'network::checkpoint::snmp::mode::memory',
|
||||
'uptime' => 'snmp_standard::mode::uptime',
|
||||
'vpn-status' => 'network::checkpoint::snmp::mode::vpnstatus',
|
||||
'vrrp-status' => 'snmp_standard::mode::vrrp',
|
||||
'connections' => 'network::checkpoint::snmp::mode::connections',
|
||||
'cpu' => 'network::checkpoint::snmp::mode::cpu',
|
||||
'hardware' => 'network::checkpoint::snmp::mode::hardware',
|
||||
'hastate' => 'network::checkpoint::snmp::mode::hastate',
|
||||
'interfaces' => 'snmp_standard::mode::interfaces',
|
||||
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
|
||||
'memory' => 'network::checkpoint::snmp::mode::memory',
|
||||
'uptime' => 'snmp_standard::mode::uptime',
|
||||
'vpn-status' => 'network::checkpoint::snmp::mode::vpnstatus',
|
||||
'vrrp-status' => 'snmp_standard::mode::vrrp',
|
||||
'vsx' => 'network::checkpoint::snmp::mode::vsx',
|
||||
);
|
||||
|
||||
return $self;
|
||||
|
|
Loading…
Reference in New Issue