enhance alcatel omniswitch

This commit is contained in:
garnier-quentin 2019-03-20 16:04:52 +01:00
parent 1f43f20342
commit 5545642282
4 changed files with 130 additions and 63 deletions

View File

@ -31,11 +31,10 @@ sub new {
bless $self, $class; bless $self, $class;
$self->{version} = '1.0'; $self->{version} = '1.0';
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {
{ "warning:s" => { name => 'warning', default => '' },
"warning:s" => { name => 'warning', default => '' }, "critical:s" => { name => 'critical', default => '' },
"critical:s" => { name => 'critical', default => '' }, });
});
return $self; return $self;
} }
@ -68,13 +67,20 @@ sub check_options {
sub check_cpu { sub check_cpu {
my ($self, %options) = @_; my ($self, %options) = @_;
my $exit1 = $self->{perfdata}->threshold_check(value => $options{'1min'}, threshold => [ { label => 'crit1m', exit_litteral => 'critical' }, my $exit1 = $self->{perfdata}->threshold_check(
{ label => 'warn1m', exit_litteral => 'warning' }, value => $options{'1min'},
]); threshold => [
{ label => 'crit1m', exit_litteral => 'critical' },
my $exit2 = $self->{perfdata}->threshold_check(value => $options{'1hour'}, threshold => [ { label => 'crit1h', exit_litteral => 'critical' }, { label => 'warn1m', exit_litteral => 'warning' },
{ label => 'warn1h', exit_litteral => 'warning' }, ]
]); );
my $exit2 = $self->{perfdata}->threshold_check(
value => $options{'1hour'},
threshold => [
{ label => 'crit1h', exit_litteral => 'critical' },
{ label => 'warn1h', exit_litteral => 'warning' },
]
);
my $exit = $self->{output}->get_most_critical(status => [ $exit1, $exit2 ]); my $exit = $self->{output}->get_most_critical(status => [ $exit1, $exit2 ]);
@ -95,28 +101,60 @@ sub check_cpu {
sub run { sub run {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
my $oid_healthDeviceCpu1MinAvg = '.1.3.6.1.4.1.6486.800.1.2.1.16.1.1.1.14'; # it's '.0' but it's for walk multiple my $mapping = {
my $oid_healthDeviceCpu1HrAvg = '.1.3.6.1.4.1.6486.800.1.2.1.16.1.1.1.15'; # it's '.0' but it's for walk multiple aos6 => {
my $oid_healthModuleCpu1MinAvg = '.1.3.6.1.4.1.6486.800.1.2.1.16.1.1.2.1.1.15'; entry_device => '.1.3.6.1.4.1.6486.800.1.2.1.16.1.1.1',
my $oid_healthModuleCpu1HrAvg = '.1.3.6.1.4.1.6486.800.1.2.1.16.1.1.2.1.1.16'; entry_module => '.1.3.6.1.4.1.6486.800.1.2.1.16.1.1.2.1.1',
device => {
healthDeviceCpu1MinAvg => { oid => '.1.3.6.1.4.1.6486.800.1.2.1.16.1.1.1.14' },
healthDeviceCpu1HrAvg => { oid => '.1.3.6.1.4.1.6486.800.1.2.1.16.1.1.1.15' },
},
module => {
healthModuleCpu1MinAvg => { oid => '.1.3.6.1.4.1.6486.800.1.2.1.16.1.1.2.1.1.15' },
healthModuleCpu1HrAvg => { oid => '.1.3.6.1.4.1.6486.800.1.2.1.16.1.1.2.1.1.16' },
},
},
aos7 => {
entry_module => '.1.3.6.1.4.1.6486.801.1.2.1.16.1.1.1.1.1',
module => {
healthModuleCpu1MinAvg => { oid => '.1.3.6.1.4.1.6486.801.1.2.1.16.1.1.1.1.1.11' },
healthModuleCpu1HrAvg => { oid => '.1.3.6.1.4.1.6486.801.1.2.1.16.1.1.1.1.1.12' },
},
},
};
my $result = $self->{snmp}->get_multiple_table(oids => [ my $snmp_result = $options{snmp}->get_multiple_table(oids => [
{ oid => $oid_healthDeviceCpu1MinAvg }, { oid => $mapping->{aos6}->{entry_device}, start => $mapping->{aos6}->{device}->{healthDeviceCpu1MinAvg}->{oid}, end => $mapping->{aos6}->{device}->{healthDeviceCpu1HrAvg}->{oid} },
{ oid => $oid_healthDeviceCpu1HrAvg }, { oid => $mapping->{aos6}->{entry_module}, start => $mapping->{aos6}->{module}->{healthModuleCpu1MinAvg}->{oid}, end => $mapping->{aos6}->{module}->{healthModuleCpu1HrAvg}->{oid} },
{ oid => $oid_healthModuleCpu1MinAvg }, { oid => $mapping->{aos7}->{entry_module}, start => $mapping->{aos7}->{module}->{healthModuleCpu1MinAvg}->{oid}, end => $mapping->{aos7}->{module}->{healthModuleCpu1HrAvg}->{oid} },
{ oid => $oid_healthModuleCpu1HrAvg }, ], nothing_quit => 1);
], nothing_quit => 1);
$self->check_cpu(name => 'Device cpu', perf_label => '_device', my $type = 'aos6';
'1min' => $result->{$oid_healthDeviceCpu1MinAvg}->{$oid_healthDeviceCpu1MinAvg . '.' . 0}, if (scalar(keys %{$snmp_result->{ $mapping->{aos7}->{entry_module} }}) > 0) {
'1hour' => $result->{$oid_healthDeviceCpu1HrAvg}->{$oid_healthDeviceCpu1HrAvg . '.' . 0}); $type = 'aos7';
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$result->{$oid_healthModuleCpu1MinAvg}})) { }
$oid =~ /^$oid_healthModuleCpu1MinAvg\.(.*)$/;
$self->check_cpu(name => "Module cpu '$1'", perf_label => "_module_$1", if (defined($mapping->{$type}->{device})) {
'1min' => $result->{$oid_healthModuleCpu1MinAvg}->{$oid_healthModuleCpu1MinAvg . '.' . $1}, my $result = $options{snmp}->map_instance(mapping => $mapping->{$type}->{device}, results => $snmp_result->{ $mapping->{$type}->{entry_device} }, instance => '0');
'1hour' => $result->{$oid_healthModuleCpu1HrAvg}->{$oid_healthModuleCpu1HrAvg . '.' . $1}); $self->check_cpu(
name => 'Device cpu',
perf_label => '_device',
'1min' => $result->{healthDeviceCpu1MinAvg},
'1hour' => $result->{healthDeviceCpu1HrAvg}
);
}
foreach my $oid ($options{snmp}->oid_lex_sort(keys %{$snmp_result->{ $mapping->{$type}->{entry_module} }})) {
next if ($oid !~ /^$snmp_result->{$oid}->{healthModuleCpu1MinAvg}\.(.*)$/);
my $result = $options{snmp}->map_instance(mapping => $mapping->{$type}->{module}, results => $snmp_result->{ $mapping->{$type}->{entry_module} }, instance => $1);
$self->check_cpu(
name => "Module cpu '$1'",
perf_label => "_module_$1",
'1min' => $result->{healthModuleCpu1MinAvg},
'1hour' => $result->{healthModuleCpu1HrAvg}
);
} }
$self->{output}->display(); $self->{output}->display();

View File

@ -31,11 +31,10 @@ sub new {
bless $self, $class; bless $self, $class;
$self->{version} = '1.0'; $self->{version} = '1.0';
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {
{ "warning:s" => { name => 'warning' },
"warning:s" => { name => 'warning' }, "critical:s" => { name => 'critical' },
"critical:s" => { name => 'critical' }, });
});
return $self; return $self;
} }

View File

@ -79,9 +79,8 @@ sub new {
bless $self, $class; bless $self, $class;
$self->{version} = '1.0'; $self->{version} = '1.0';
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {
{ });
});
return $self; return $self;
} }

View File

@ -31,11 +31,10 @@ sub new {
bless $self, $class; bless $self, $class;
$self->{version} = '1.0'; $self->{version} = '1.0';
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {
{ "warning:s" => { name => 'warning', default => '' },
"warning:s" => { name => 'warning', default => '' }, "critical:s" => { name => 'critical', default => '' },
"critical:s" => { name => 'critical', default => '' }, });
});
return $self; return $self;
} }
@ -95,28 +94,60 @@ sub check_memory {
sub run { sub run {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
my $oid_healthDeviceMemory1MinAvg = '.1.3.6.1.4.1.6486.800.1.2.1.16.1.1.1.10'; # it's '.0' but it's for walk multiple my $mapping = {
my $oid_healthDeviceMemory1HrAvg = '.1.3.6.1.4.1.6486.800.1.2.1.16.1.1.1.11'; # it's '.0' but it's for walk multiple aos6 => {
my $oid_healthModuleMemory1MinAvg = '.1.3.6.1.4.1.6486.800.1.2.1.16.1.1.2.1.1.11'; entry_device => '.1.3.6.1.4.1.6486.800.1.2.1.16.1.1.1',
my $oid_healthModuleMemory1HrAvg = '.1.3.6.1.4.1.6486.800.1.2.1.16.1.1.2.1.1.12'; entry_module => '.1.3.6.1.4.1.6486.800.1.2.1.16.1.1.2.1.1',
device => {
healthDeviceMemory1MinAvg => { oid => '.1.3.6.1.4.1.6486.800.1.2.1.16.1.1.1.10' },
healthDeviceMemory1HrAvg => { oid => '.1.3.6.1.4.1.6486.800.1.2.1.16.1.1.1.11' },
},
module => {
healthModuleMemory1MinAvg => { oid => '.1.3.6.1.4.1.6486.800.1.2.1.16.1.1.2.1.1.11' },
healthModuleMemory1HrAvg => { oid => '.1.3.6.1.4.1.6486.800.1.2.1.16.1.1.2.1.1.12' },
},
},
aos7 => {
entry_module => '.1.3.6.1.4.1.6486.800.1.2.1.16.1.1.1.1.1',
module => {
healthModuleMemory1MinAvg => { oid => '.1.3.6.1.4.1.6486.800.1.2.1.16.1.1.1.1.1.8' },
healthModuleMemory1HrAvg => { oid => '.1.3.6.1.4.1.6486.800.1.2.1.16.1.1.1.1.1.9' },
},
},
};
my $result = $self->{snmp}->get_multiple_table(oids => [ my $snmp_result = $options{snmp}->get_multiple_table(oids => [
{ oid => $oid_healthDeviceMemory1MinAvg }, { oid => $mapping->{aos6}->{entry_device}, start => $mapping->{aos6}->{device}->{healthDeviceMemory1MinAvg}->{oid}, end => $mapping->{aos6}->{device}->{healthDeviceMemory1HrAvg}->{oid} },
{ oid => $oid_healthDeviceMemory1HrAvg }, { oid => $mapping->{aos6}->{entry_module}, start => $mapping->{aos6}->{module}->{healthModuleMemory1MinAvg}->{oid}, end => $mapping->{aos6}->{module}->{healthModuleMemory1HrAvg}->{oid} },
{ oid => $oid_healthModuleMemory1MinAvg }, { oid => $mapping->{aos7}->{entry_module}, start => $mapping->{aos7}->{module}->{healthModuleMemory1MinAvg}->{oid}, end => $mapping->{aos7}->{module}->{healthModuleMemory1HrAvg}->{oid} },
{ oid => $oid_healthModuleMemory1HrAvg }, ], nothing_quit => 1);
], nothing_quit => 1);
my $type = 'aos6';
if (scalar(keys %{$snmp_result->{ $mapping->{aos7}->{entry_module} }}) > 0) {
$type = 'aos7';
}
$self->check_memory(name => 'Device memory', perf_label => '_device', if (defined($mapping->{$type}->{device})) {
'1min' => $result->{$oid_healthDeviceMemory1MinAvg}->{$oid_healthDeviceMemory1MinAvg . '.' . 0}, my $result = $options{snmp}->map_instance(mapping => $mapping->{$type}->{device}, results => $snmp_result->{ $mapping->{$type}->{entry_device} }, instance => '0');
'1hour' => $result->{$oid_healthDeviceMemory1HrAvg}->{$oid_healthDeviceMemory1HrAvg . '.' . 0}); $self->check_memory(
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$result->{$oid_healthModuleMemory1MinAvg}})) { name => 'Device memory',
$oid =~ /^$oid_healthModuleMemory1MinAvg\.(.*)$/; perf_label => '_device',
$self->check_memory(name => "Module memory '$1'", perf_label => "_module_$1", '1min' => $result->{healthDeviceMemory1MinAvg},
'1min' => $result->{$oid_healthModuleMemory1MinAvg}->{$oid_healthModuleMemory1MinAvg . '.' . $1}, '1hour' => $result->{healthDeviceMemory1HrAvg}
'1hour' => $result->{$oid_healthModuleMemory1HrAvg}->{$oid_healthModuleMemory1HrAvg . '.' . $1}); );
}
foreach my $oid ($options{snmp}->oid_lex_sort(keys %{$snmp_result->{ $mapping->{$type}->{entry_module} }})) {
next if ($oid !~ /^$snmp_result->{$oid}->{healthModuleMemory1MinAvg}\.(.*)$/);
my $result = $options{snmp}->map_instance(mapping => $mapping->{$type}->{module}, results => $snmp_result->{ $mapping->{$type}->{entry_module} }, instance => $1);
$self->check_memory(
name => "Module memory '$1'",
perf_label => "_module_$1",
'1min' => $result->{healthModuleMemory1MinAvg},
'1hour' => $result->{healthModuleMemory1HrAvg}
);
} }
$self->{output}->display(); $self->{output}->display();