(plugin) network::h3c::snmp - mode hardware snmp management
This commit is contained in:
parent
24d3c2f6ac
commit
4d10095e90
|
@ -31,7 +31,6 @@ sub set_system {
|
||||||
|
|
||||||
$self->{regexp_threshold_numeric_check_section_option} = '^(temperature)$';
|
$self->{regexp_threshold_numeric_check_section_option} = '^(temperature)$';
|
||||||
|
|
||||||
$self->{cb_hook1} = 'init_cache';
|
|
||||||
$self->{cb_hook2} = 'snmp_execute';
|
$self->{cb_hook2} = 'snmp_execute';
|
||||||
|
|
||||||
$self->{thresholds} = {
|
$self->{thresholds} = {
|
||||||
|
@ -40,81 +39,83 @@ sub set_system {
|
||||||
['normal', 'OK'],
|
['normal', 'OK'],
|
||||||
['entityAbsent', 'OK'],
|
['entityAbsent', 'OK'],
|
||||||
['psuError', 'CRITICAL'],
|
['psuError', 'CRITICAL'],
|
||||||
['hardwareFaulty', 'CRITICAL'],
|
['hardwareFaulty', 'CRITICAL']
|
||||||
],
|
],
|
||||||
fan => [
|
fan => [
|
||||||
['notSupported', 'WARNING'],
|
['notSupported', 'WARNING'],
|
||||||
['normal', 'OK'],
|
['normal', 'OK'],
|
||||||
['entityAbsent', 'OK'],
|
['entityAbsent', 'OK'],
|
||||||
['fanError', 'CRITICAL'],
|
['fanError', 'CRITICAL'],
|
||||||
['hardwareFaulty', 'CRITICAL'],
|
['hardwareFaulty', 'CRITICAL']
|
||||||
],
|
],
|
||||||
sensor => [
|
sensor => [
|
||||||
['notSupported', 'WARNING'],
|
['notSupported', 'WARNING'],
|
||||||
['normal', 'OK'],
|
['normal', 'OK'],
|
||||||
['entityAbsent', 'OK'],
|
['entityAbsent', 'OK'],
|
||||||
['sensorError', 'CRITICAL'],
|
['sensorError', 'CRITICAL'],
|
||||||
['hardwareFaulty', 'CRITICAL'],
|
['hardwareFaulty', 'CRITICAL']
|
||||||
],
|
],
|
||||||
other => [
|
other => [
|
||||||
['notSupported', 'WARNING'],
|
['notSupported', 'WARNING'],
|
||||||
['normal', 'OK'],
|
['normal', 'OK'],
|
||||||
['entityAbsent', 'OK'],
|
['entityAbsent', 'OK'],
|
||||||
['hardwareFaulty', 'CRITICAL'],
|
['hardwareFaulty', 'CRITICAL']
|
||||||
],
|
],
|
||||||
unknown => [
|
unknown => [
|
||||||
['notSupported', 'WARNING'],
|
['notSupported', 'WARNING'],
|
||||||
['normal', 'OK'],
|
['normal', 'OK'],
|
||||||
['entityAbsent', 'OK'],
|
['entityAbsent', 'OK'],
|
||||||
['hardwareFaulty', 'CRITICAL'],
|
['hardwareFaulty', 'CRITICAL']
|
||||||
],
|
],
|
||||||
chassis => [
|
chassis => [
|
||||||
['notSupported', 'WARNING'],
|
['notSupported', 'WARNING'],
|
||||||
['normal', 'OK'],
|
['normal', 'OK'],
|
||||||
['entityAbsent', 'OK'],
|
['entityAbsent', 'OK'],
|
||||||
['hardwareFaulty', 'CRITICAL'],
|
['hardwareFaulty', 'CRITICAL']
|
||||||
],
|
],
|
||||||
backplane => [
|
backplane => [
|
||||||
['notSupported', 'WARNING'],
|
['notSupported', 'WARNING'],
|
||||||
['normal', 'OK'],
|
['normal', 'OK'],
|
||||||
['entityAbsent', 'OK'],
|
['entityAbsent', 'OK'],
|
||||||
['hardwareFaulty', 'CRITICAL'],
|
['hardwareFaulty', 'CRITICAL']
|
||||||
],
|
],
|
||||||
container => [
|
container => [
|
||||||
['notSupported', 'WARNING'],
|
['notSupported', 'WARNING'],
|
||||||
['normal', 'OK'],
|
['normal', 'OK'],
|
||||||
['entityAbsent', 'OK'],
|
['entityAbsent', 'OK'],
|
||||||
['hardwareFaulty', 'CRITICAL'],
|
['hardwareFaulty', 'CRITICAL']
|
||||||
],
|
],
|
||||||
module => [
|
module => [
|
||||||
['notSupported', 'WARNING'],
|
['notSupported', 'WARNING'],
|
||||||
['normal', 'OK'],
|
['normal', 'OK'],
|
||||||
['entityAbsent', 'OK'],
|
['entityAbsent', 'OK'],
|
||||||
['hardwareFaulty', 'CRITICAL'],
|
['hardwareFaulty', 'CRITICAL']
|
||||||
],
|
],
|
||||||
port => [
|
port => [
|
||||||
['notSupported', 'WARNING'],
|
['notSupported', 'WARNING'],
|
||||||
['normal', 'OK'],
|
['normal', 'OK'],
|
||||||
['entityAbsent', 'OK'],
|
['entityAbsent', 'OK'],
|
||||||
['hardwareFaulty', 'CRITICAL'],
|
['hardwareFaulty', 'CRITICAL']
|
||||||
],
|
],
|
||||||
stack => [
|
stack => [
|
||||||
['notSupported', 'WARNING'],
|
['notSupported', 'WARNING'],
|
||||||
['normal', 'OK'],
|
['normal', 'OK'],
|
||||||
['entityAbsent', 'OK'],
|
['entityAbsent', 'OK'],
|
||||||
['hardwareFaulty', 'CRITICAL'],
|
['hardwareFaulty', 'CRITICAL']
|
||||||
],
|
],
|
||||||
cpu => [
|
cpu => [
|
||||||
['notSupported', 'WARNING'],
|
['notSupported', 'WARNING'],
|
||||||
['normal', 'OK'],
|
['normal', 'OK'],
|
||||||
['entityAbsent', 'OK'],
|
['entityAbsent', 'OK'],
|
||||||
['hardwareFaulty', 'CRITICAL'],
|
['hardwareFaulty', 'CRITICAL']
|
||||||
],
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
$self->{components_path} = 'centreon::common::h3c::snmp::mode::components';
|
$self->{components_path} = 'centreon::common::h3c::snmp::mode::components';
|
||||||
$self->{components_module} = ['chassis', 'backplane', 'container', 'psu', 'fan', 'sensor',
|
$self->{components_module} = [
|
||||||
'module', 'port', 'stack', 'cpu', 'other', 'unknown'];
|
'chassis', 'backplane', 'container', 'psu', 'fan', 'sensor',
|
||||||
|
'module', 'port', 'stack', 'cpu', 'other', 'unknown'
|
||||||
|
];
|
||||||
|
|
||||||
$self->{mapping_name} = {
|
$self->{mapping_name} = {
|
||||||
1 => 'other', 2 => 'unknown', 3 => 'chassis', 4 => 'backplane', 5 => 'container', 6 => 'psu',
|
1 => 'other', 2 => 'unknown', 3 => 'chassis', 4 => 'backplane', 5 => 'container', 6 => 'psu',
|
||||||
|
@ -134,9 +135,13 @@ my $oid_hh3cEntityExtErrorStatus = '.1.3.6.1.4.1.25506.2.6.1.1.1.1.19';
|
||||||
sub snmp_execute {
|
sub snmp_execute {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
push @{$self->{request}},
|
||||||
|
{ oid => $oid_h3cEntityExtErrorStatus },
|
||||||
|
{ oid => $oid_hh3cEntityExtErrorStatus };
|
||||||
|
|
||||||
$self->{snmp} = $options{snmp};
|
$self->{snmp} = $options{snmp};
|
||||||
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
|
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
|
||||||
$self->write_cache();
|
$self->get_physical();
|
||||||
|
|
||||||
$self->{branch} = $oid_hh3cEntityExtStateEntry;
|
$self->{branch} = $oid_hh3cEntityExtStateEntry;
|
||||||
if (defined($self->{results}->{$oid_h3cEntityExtErrorStatus}) && scalar(keys %{$self->{results}->{$oid_h3cEntityExtErrorStatus}}) > 0) {
|
if (defined($self->{results}->{$oid_h3cEntityExtErrorStatus}) && scalar(keys %{$self->{results}->{$oid_h3cEntityExtErrorStatus}}) > 0) {
|
||||||
|
@ -144,26 +149,15 @@ sub snmp_execute {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub init_cache {
|
|
||||||
my ($self, %options) = @_;
|
|
||||||
|
|
||||||
$self->{request} = [
|
|
||||||
{ oid => $oid_h3cEntityExtErrorStatus },
|
|
||||||
{ oid => $oid_hh3cEntityExtErrorStatus },
|
|
||||||
];
|
|
||||||
$self->check_cache(%options);
|
|
||||||
}
|
|
||||||
|
|
||||||
sub new {
|
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 => {
|
||||||
{
|
'reload-cache-time:s' => { name => 'reload_cache_time', default => 180 },
|
||||||
"reload-cache-time:s" => { name => 'reload_cache_time', default => 180 },
|
'short-name' => { name => 'short_name' }
|
||||||
"short-name" => { name => 'short_name' },
|
});
|
||||||
});
|
|
||||||
|
|
||||||
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
|
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
|
||||||
return $self;
|
return $self;
|
||||||
|
@ -184,27 +178,23 @@ my $oid_entPhysicalContainedIn = '.1.3.6.1.2.1.47.1.1.1.1.4';
|
||||||
my $oid_entPhysicalClass = '.1.3.6.1.2.1.47.1.1.1.1.5';
|
my $oid_entPhysicalClass = '.1.3.6.1.2.1.47.1.1.1.1.5';
|
||||||
my $oid_entPhysicalName = '.1.3.6.1.2.1.47.1.1.1.1.7';
|
my $oid_entPhysicalName = '.1.3.6.1.2.1.47.1.1.1.1.7';
|
||||||
|
|
||||||
sub check_cache {
|
sub get_physical {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{hostname} = $options{snmp}->get_hostname();
|
|
||||||
$self->{snmp_port} = $options{snmp}->get_port();
|
|
||||||
|
|
||||||
# init cache file
|
# init cache file
|
||||||
$self->{write_cache} = 0;
|
my $has_cache_file = $self->{statefile_cache}->read(statefile => 'cache_h3c_entity_' . $self->{snmp}->get_hostname() . '_' . $self->{snmp}->get_port());
|
||||||
my $has_cache_file = $self->{statefile_cache}->read(statefile => 'cache_h3c_entity_' . $self->{hostname} . '_' . $self->{snmp_port});
|
|
||||||
my $timestamp_cache = $self->{statefile_cache}->get(name => 'last_timestamp');
|
my $timestamp_cache = $self->{statefile_cache}->get(name => 'last_timestamp');
|
||||||
if ($has_cache_file == 0 ||
|
if ($has_cache_file == 0 ||
|
||||||
!defined($timestamp_cache) || ((time() - $timestamp_cache) > (($self->{option_results}->{reload_cache_time}) * 60)) && $self->{option_results}->{reload_cache_time} != '-1') {
|
!defined($timestamp_cache) || ((time() - $timestamp_cache) > (($self->{option_results}->{reload_cache_time}) * 60)) && $self->{option_results}->{reload_cache_time} != '-1') {
|
||||||
push @{$self->{request}}, { oid => $oid_entPhysicalEntry, start => $oid_entPhysicalDescr, end => $oid_entPhysicalName };
|
$self->{results}->{$oid_entPhysicalEntry} = $self->{snmp}->get_multiple_table(
|
||||||
$self->{write_cache} = 1;
|
oids => [
|
||||||
}
|
{ oid => $oid_entPhysicalDescr },
|
||||||
}
|
{ oid => $oid_entPhysicalContainedIn },
|
||||||
|
{ oid => $oid_entPhysicalClass },
|
||||||
sub write_cache {
|
{ oid => $oid_entPhysicalName }
|
||||||
my ($self, %options) = @_;
|
],
|
||||||
|
return_type => 1
|
||||||
if ($self->{write_cache} == 1) {
|
);
|
||||||
my $datas = {};
|
my $datas = {};
|
||||||
$datas->{last_timestamp} = time();
|
$datas->{last_timestamp} = time();
|
||||||
$datas->{oids} = $self->{results}->{$oid_entPhysicalEntry};
|
$datas->{oids} = $self->{results}->{$oid_entPhysicalEntry};
|
||||||
|
@ -256,8 +246,10 @@ sub load_components {
|
||||||
foreach (keys %{$self->{mapping_name}}) {
|
foreach (keys %{$self->{mapping_name}}) {
|
||||||
if ($self->{mapping_name}->{$_} =~ /$self->{option_results}->{component}/) {
|
if ($self->{mapping_name}->{$_} =~ /$self->{option_results}->{component}/) {
|
||||||
my $mod_name = $self->{components_path} . "::" . $self->{mapping_component}->{$_};
|
my $mod_name = $self->{components_path} . "::" . $self->{mapping_component}->{$_};
|
||||||
centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $mod_name,
|
centreon::plugins::misc::mymodule_load(
|
||||||
error_msg => "Cannot load module '$mod_name'.");
|
output => $self->{output}, module => $mod_name,
|
||||||
|
error_msg => "Cannot load module '$mod_name'."
|
||||||
|
);
|
||||||
$self->{loaded} = 1;
|
$self->{loaded} = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue