| 1 |
# |
| 2 |
# Copyright 2024 Centreon (http://www.centreon.com/) |
| 3 |
# |
| 4 |
# Centreon is a full-fledged industry-strength solution that meets |
| 5 |
# the needs in IT infrastructure and application monitoring for |
| 6 |
# service performance. |
| 7 |
# |
| 8 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 |
# you may not use this file except in compliance with the License. |
| 10 |
# You may obtain a copy of the License at |
| 11 |
# |
| 12 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 13 |
# |
| 14 |
# Unless required by applicable law or agreed to in writing, software |
| 15 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 16 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 |
# See the License for the specific language governing permissions and |
| 18 |
# limitations under the License. |
| 19 |
# |
| 20 |
|
| 21 |
package network::infoblox::snmp::mode::services; |
| 22 |
|
| 23 |
use base qw(centreon::plugins::templates::hardware); |
| 24 |
|
| 25 |
use strict; |
| 26 |
use warnings; |
| 27 |
|
| 28 |
sub set_system { |
| 29 |
my ($self, %options) = @_; |
| 30 |
|
| 31 |
$self->{cb_hook2} = 'snmp_execute'; |
| 32 |
|
| 33 |
$self->{thresholds} = { |
| 34 |
default => [ |
| 35 |
['unknown', 'OK'], |
| 36 |
['working', 'OK'], |
| 37 |
['inactive', 'OK'], |
| 38 |
['warning', 'WARNING'], |
| 39 |
['failed', 'CRITICAL'] |
| 40 |
] |
| 41 |
}; |
| 42 |
|
| 43 |
$self->{components_path} = 'network::infoblox::snmp::mode::components'; |
| 44 |
$self->{components_module} = ['service']; |
| 45 |
} |
| 46 |
|
| 47 |
sub new { |
| 48 |
my ($class, %options) = @_; |
| 49 |
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, no_load_components => 1, force_new_perfdata => 1); |
| 50 |
bless $self, $class; |
| 51 |
|
| 52 |
$options{options}->add_options(arguments => {}); |
| 53 |
|
| 54 |
return $self; |
| 55 |
} |
| 56 |
|
| 57 |
sub snmp_execute { |
| 58 |
my ($self, %options) = @_; |
| 59 |
|
| 60 |
$self->{snmp} = $options{snmp}; |
| 61 |
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); |
| 62 |
} |
| 63 |
|
| 64 |
1; |
| 65 |
|
| 66 |
=head1 MODE |
| 67 |
|
| 68 |
Check physical service status. |
| 69 |
|
| 70 |
=over 8 |
| 71 |
|
| 72 |
=item B<--component> |
| 73 |
|
| 74 |
Which component to check (default: '.*'). |
| 75 |
Can be: 'service'. |
| 76 |
|
| 77 |
=item B<--filter> |
| 78 |
|
| 79 |
Filter component instances (syntax: component,regexp_filter). Component instances are excluded if matching regexp_filter. |
| 80 |
E.g: --filter=service,fan1 |
| 81 |
|
| 82 |
=item B<--no-component> |
| 83 |
|
| 84 |
Define the expected status if no components are found (default: critical). |
| 85 |
|
| 86 |
|
| 87 |
=item B<--threshold-overload> |
| 88 |
|
| 89 |
Use this option to override the status returned by the plugin when the status label matches a regular expression (syntax: section,[instance,]status,regexp). |
| 90 |
Example: --threshold-overload='service,OK,warning' |
| 91 |
|
| 92 |
=back |
| 93 |
|
| 94 |
=cut |
| 95 |
|
| 96 |
package network::infoblox::snmp::mode::components::service; |
| 97 |
|
| 98 |
use strict; |
| 99 |
use warnings; |
| 100 |
|
| 101 |
my %map_service_status = ( |
| 102 |
1 => 'working', 2 => 'warning', |
| 103 |
3 => 'failed', 4 => 'inactive', 5 => 'unknown' |
| 104 |
); |
| 105 |
my %map_service_name = ( |
| 106 |
1 => 'dhcp', 2 => 'dns', 3 => 'ntp', 4 => 'tftp', 5 => 'http-file-dist', |
| 107 |
6 => 'ftp', 7 => 'bloxtools-move', 8 => 'bloxtools', 9 => 'node-status', |
| 108 |
10 => 'disk-usage', 11 => 'enet-lan', 12 => 'enet-lan2', 13 => 'enet-ha', |
| 109 |
14 => 'enet-mgmt', 15 => 'lcd', 16 => 'memory', 17 => 'replication', 18 => 'db-object', |
| 110 |
19 => 'raid-summary', 20 => 'raid-disk1', 21 => 'raid-disk2', 22 => 'raid-disk3', |
| 111 |
23 => 'raid-disk4', 24 => 'raid-disk5', 25 => 'raid-disk6', 26 => 'raid-disk7', |
| 112 |
27 => 'raid-disk8', 28 => 'fan1', 29 => 'fan2', 30 => 'fan3', 31 => 'fan4', |
| 113 |
32 => 'fan5', 33 => 'fan6', 34 => 'fan7', 35 => 'fan8', 36 => 'power-supply1', |
| 114 |
37 => 'power-supply2', 38 => 'ntp-sync', 39 => 'cpu1-temp', 40 => 'cpu2-temp', |
| 115 |
41 => 'sys-temp', 42 => 'raid-battery', 43 => 'cpu-usage', 44 => 'ospf', |
| 116 |
45 => 'bgp', 46 => 'mgm-service', 47 => 'subgrid-conn', 48 => 'network-capacity', |
| 117 |
49 => 'reporting', 50 => 'dns-cache-acceleration', 51 => 'ospf6', |
| 118 |
52 => 'swap-usage', 53 => 'discovery-consolidator', 54 => 'discovery-collector', |
| 119 |
55 => 'discovery-capacity', 56 => 'threat-protection', 57 => 'cloud-api', |
| 120 |
58 => 'threat-analytics', 59 => 'taxii', 60 => 'bfd', 61 => 'outbound' |
| 121 |
); |
| 122 |
|
| 123 |
my $mapping = { |
| 124 |
ibNodeServiceName => { oid => '.1.3.6.1.4.1.7779.3.1.1.2.1.10.1.1', map => \%map_service_name }, |
| 125 |
ibNodeServiceStatus => { oid => '.1.3.6.1.4.1.7779.3.1.1.2.1.10.1.2', map => \%map_service_status } |
| 126 |
}; |
| 127 |
my $oid_ibMemberNodeServiceStatusEntry = '.1.3.6.1.4.1.7779.3.1.1.2.1.10.1'; |
| 128 |
|
| 129 |
sub load { |
| 130 |
my ($self) = @_; |
| 131 |
|
| 132 |
push @{$self->{request}}, { oid => $oid_ibMemberNodeServiceStatusEntry, end => $mapping->{ibNodeServiceStatus}->{oid} }; |
| 133 |
} |
| 134 |
|
| 135 |
sub check { |
| 136 |
my ($self) = @_; |
| 137 |
|
| 138 |
$self->{output}->output_add(long_msg => "Checking services"); |
| 139 |
$self->{components}->{service} = {name => 'services', total => 0, skip => 0}; |
| 140 |
return if ($self->check_filter(section => 'service')); |
| 141 |
|
| 142 |
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_ibMemberNodeServiceStatusEntry}})) { |
| 143 |
next if ($oid !~ /^$mapping->{ibNodeServiceName}->{oid}\.(.*)$/); |
| 144 |
my $instance = $1; |
| 145 |
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_ibMemberNodeServiceStatusEntry}, instance => $instance); |
| 146 |
|
| 147 |
next if ($self->check_filter(section => 'service', instance => $result->{ibNodeServiceName})); |
| 148 |
|
| 149 |
$self->{components}->{service}->{total}++; |
| 150 |
$self->{output}->output_add( |
| 151 |
long_msg => sprintf( |
| 152 |
"service '%s' status is '%s' [instance = %s]", |
| 153 |
$result->{ibNodeServiceName}, $result->{ibNodeServiceStatus}, $result->{ibNodeServiceName} |
| 154 |
) |
| 155 |
); |
| 156 |
my $exit = $self->get_severity(label => 'default', section => 'service', instance => $result->{ibNodeServiceName}, value => $result->{ibNodeServiceStatus}); |
| 157 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 158 |
$self->{output}->output_add( |
| 159 |
severity => $exit, |
| 160 |
short_msg => sprintf("Service '%s' status is '%s'", $result->{ibNodeServiceName}, $result->{ibNodeServiceStatus}) |
| 161 |
); |
| 162 |
} |
| 163 |
} |
| 164 |
} |
| 165 |
|
| 166 |
1; |