mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-04-07 20:35:27 +02:00
(plugin) network::teltonika::snmp - handle new mib (#4579)
This commit is contained in:
parent
77a7fd9e84
commit
c43b8ae476
180
src/network/teltonika/snmp/mode/interfaces.pm
Normal file
180
src/network/teltonika/snmp/mode/interfaces.pm
Normal file
@ -0,0 +1,180 @@
|
||||
#
|
||||
# Copyright 2023 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::teltonika::snmp::mode::interfaces;
|
||||
|
||||
use base qw(snmp_standard::mode::interfaces);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check interfaces.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--add-global>
|
||||
|
||||
Check global port statistics (By default if no --add-* option is set).
|
||||
|
||||
=item B<--add-status>
|
||||
|
||||
Check interface status.
|
||||
|
||||
=item B<--add-duplex-status>
|
||||
|
||||
Check duplex status (with --warning-status and --critical-status).
|
||||
|
||||
=item B<--add-traffic>
|
||||
|
||||
Check interface traffic.
|
||||
|
||||
=item B<--add-errors>
|
||||
|
||||
Check interface errors.
|
||||
|
||||
=item B<--add-cast>
|
||||
|
||||
Check interface cast.
|
||||
|
||||
=item B<--add-speed>
|
||||
|
||||
Check interface speed.
|
||||
|
||||
=item B<--add-volume>
|
||||
|
||||
Check interface data volume between two checks (not supposed to be graphed, useful for BI reporting).
|
||||
|
||||
=item B<--check-metrics>
|
||||
|
||||
If the expression is true, metrics are checked (Default: '%{opstatus} eq "up"').
|
||||
|
||||
=item B<--warning-status>
|
||||
|
||||
Define the conditions to match for the status to be WARNING.
|
||||
You can use the following variables: %{admstatus}, %{opstatus}, %{duplexstatus}, %{display}
|
||||
|
||||
=item B<--critical-status>
|
||||
|
||||
Define the conditions to match for the status to be CRITICAL (Default: '%{admstatus} eq "up" and %{opstatus} ne "up"').
|
||||
You can use the following variables: %{admstatus}, %{opstatus}, %{duplexstatus}, %{display}
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds.
|
||||
Can be: 'total-port', 'total-admin-up', 'total-admin-down', 'total-oper-up', 'total-oper-down',
|
||||
'in-traffic', 'out-traffic', 'in-error', 'in-discard', 'out-error', 'out-discard',
|
||||
'in-ucast', 'in-bcast', 'in-mcast', 'out-ucast', 'out-bcast', 'out-mcast',
|
||||
'speed' (b/s).
|
||||
|
||||
=item B<--units-traffic>
|
||||
|
||||
Units of thresholds for the traffic (Default: 'percent_delta') ('percent_delta', 'bps', 'counter').
|
||||
|
||||
=item B<--units-errors>
|
||||
|
||||
Units of thresholds for errors/discards (Default: 'percent_delta') ('percent_delta', 'percent', 'delta', 'deltaps', 'counter').
|
||||
|
||||
=item B<--units-cast>
|
||||
|
||||
Units of thresholds for communication types (Default: 'percent_delta') ('percent_delta', 'percent', 'delta', 'deltaps', 'counter').
|
||||
|
||||
=item B<--nagvis-perfdata>
|
||||
|
||||
Display traffic perfdata to be compatible with nagvis widget.
|
||||
|
||||
=item B<--interface>
|
||||
|
||||
Set the interface (number expected) ex: 1,2,... (empty means 'check all interfaces').
|
||||
|
||||
=item B<--name>
|
||||
|
||||
Allows you to define the interface (in option --interface) by name instead of OID index. The name matching mode supports regular expressions.
|
||||
|
||||
=item B<--speed>
|
||||
|
||||
Set interface speed for incoming/outgoing traffic (in Mb).
|
||||
|
||||
=item B<--speed-in>
|
||||
|
||||
Set interface speed for incoming traffic (in Mb).
|
||||
|
||||
=item B<--speed-out>
|
||||
|
||||
Set interface speed for outgoing traffic (in Mb).
|
||||
|
||||
=item B<--map-speed-dsl>
|
||||
|
||||
Get interface speed configuration for interface type 'adsl' and 'vdsl2'.
|
||||
|
||||
Syntax: --map-speed-dsl=interface-src-name,interface-dsl-name
|
||||
|
||||
E.g: --map-speed-dsl=Et0.835,Et0-vdsl2
|
||||
|
||||
=item B<--force-counters64>
|
||||
|
||||
Force to use 64 bits counters only. Can be used to improve performance.
|
||||
|
||||
=item B<--force-counters32>
|
||||
|
||||
Force to use 32 bits counters (even in snmp v2c and v3). Should be used when 64 bits counters are buggy.
|
||||
|
||||
=item B<--reload-cache-time>
|
||||
|
||||
Time in minutes before reloading cache file (default: 180).
|
||||
|
||||
=item B<--oid-filter>
|
||||
|
||||
Define the OID to be used to filter interfaces (default: ifName) (values: ifDesc, ifAlias, ifName, IpAddr).
|
||||
|
||||
=item B<--oid-display>
|
||||
|
||||
Define the OID that will be used to name the interfaces (default: ifName) (values: ifDesc, ifAlias, ifName, IpAddr).
|
||||
|
||||
=item B<--oid-extra-display>
|
||||
|
||||
Add an OID to display.
|
||||
|
||||
=item B<--display-transform-src> B<--display-transform-dst>
|
||||
|
||||
Modify the interface name displayed by using a regular expression.
|
||||
|
||||
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
|
||||
|
||||
=item B<--show-cache>
|
||||
|
||||
Display cache interface datas.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
315
src/network/teltonika/snmp/mode/modem.pm
Normal file
315
src/network/teltonika/snmp/mode/modem.pm
Normal file
@ -0,0 +1,315 @@
|
||||
#
|
||||
# Copyright 2018 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::teltonika::snmp::mode::modem;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||
use Digest::MD5 qw(md5_hex);
|
||||
|
||||
sub custom_status_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
"connection state is '%s' [pin state: '%s'] [net state: '%s'][sim state: '%s']",
|
||||
$self->{result_values}->{connectionState},
|
||||
$self->{result_values}->{pinState},
|
||||
$self->{result_values}->{netState},
|
||||
$self->{result_values}->{simState}
|
||||
);
|
||||
}
|
||||
|
||||
sub prefix_modem_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
"modem imsi '%s' [operator: %s] ",
|
||||
$options{instance_value}->{imsi},
|
||||
$options{instance_value}->{operator}
|
||||
);
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'modems', type => 1, cb_prefix_output => 'prefix_modem_output', message_multiple => 'All modems are ok', skipped_code => { -10 => 1, -11 => 1 } }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{modems} = [
|
||||
{ label => 'status', type => 2, critical_default => '%{connectionState} !~ /connected/i', set => {
|
||||
key_values => [ { name => 'simState' }, { name => 'pinState' }, { name => 'netState' }, { name => 'connectionState' } ],
|
||||
closure_custom_output => $self->can('custom_status_output'),
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||
}
|
||||
},
|
||||
{ label => 'signal-strength', nlabel => 'modem.signal.strength.dbm', display_ok => 0, set => {
|
||||
key_values => [ { name => 'signal' }, { name => 'imsi' }, { name => 'operator' } ],
|
||||
output_template => 'signal strength: %s dBm',
|
||||
closure_custom_perfdata => sub {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => $self->{nlabel},
|
||||
unit => 'dBm',
|
||||
instances => [$self->{result_values}->{imsi}, $self->{result_values}->{operator}],
|
||||
value => sprintf('%s', $self->{result_values}->{signal}),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel})
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
{ label => 'temperature', nlabel => 'modem.temperature.celsius', display_ok => 0, set => {
|
||||
key_values => [ { name => 'temperature' }, { name => 'imsi' }, { name => 'operator' } ],
|
||||
output_template => 'temperature: %s C',
|
||||
closure_custom_perfdata => sub {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => $self->{nlabel},
|
||||
unit => 'C',
|
||||
instances => [$self->{result_values}->{imsi}, $self->{result_values}->{operator}],
|
||||
value => sprintf('%s', $self->{result_values}->{temperature}),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}),
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
{ label => 'traffic-in', nlabel => 'modem.traffic.in.bitspersecond', display_ok => 0, set => {
|
||||
key_values => [ { name => 'received', per_second => 1 }, { name => 'imsi' }, { name => 'operator' } ],
|
||||
output_template => 'traffic in: %s %s/s',
|
||||
output_change_bytes => 2,
|
||||
closure_custom_perfdata => sub {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => $self->{nlabel},
|
||||
unit => 'b/s',
|
||||
instances => [$self->{result_values}->{imsi}, $self->{result_values}->{operator}],
|
||||
value => sprintf('%s', $self->{result_values}->{received}),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}),
|
||||
min => 0
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
{ label => 'traffic-out', nlabel => 'modem.traffic.out.bitspersecond', display_ok => 0, set => {
|
||||
key_values => [ { name => 'sent', per_second => 1 }, { name => 'imsi' }, { name => 'operator' } ],
|
||||
output_template => 'traffic out: %s %s/s',
|
||||
output_change_bytes => 2,
|
||||
closure_custom_perfdata => sub {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => $self->{nlabel},
|
||||
unit => 'b/s',
|
||||
instances => [$self->{result_values}->{imsi}, $self->{result_values}->{operator}],
|
||||
value => sprintf('%s', $self->{result_values}->{sent}),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}),
|
||||
min => 0
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
{ label => 'signal-receive-power', nlabel => 'modem.signal.receive.power.dbm', display_ok => 0, set => {
|
||||
key_values => [ { name => 'rsrp' }, { name => 'imsi' }, { name => 'operator' } ],
|
||||
output_template => 'signal receive power: %s dBm',
|
||||
closure_custom_perfdata => sub {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => $self->{nlabel},
|
||||
unit => 'dBm',
|
||||
instances => [$self->{result_values}->{imsi}, $self->{result_values}->{operator}],
|
||||
value => sprintf('%s', $self->{result_values}->{rsrp}),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel})
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
{ label => 'signal-receive-quality', nlabel => 'modem.signal.receive.quality.dbm', display_ok => 0, set => {
|
||||
key_values => [ { name => 'rsrq' }, { name => 'imsi' }, { name => 'operator' } ],
|
||||
output_template => 'signal receive quality: %s dBm',
|
||||
closure_custom_perfdata => sub {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => $self->{nlabel},
|
||||
unit => 'dBm',
|
||||
instances => [$self->{result_values}->{imsi}, $self->{result_values}->{operator}],
|
||||
value => sprintf('%s', $self->{result_values}->{rsrq}),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel})
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
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 => {});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub teltonika_legacy {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $mapping = {
|
||||
imsi => { oid => '.1.3.6.1.4.1.48690.1.6' },
|
||||
simState => { oid => '.1.3.6.1.4.1.48690.2.1' },
|
||||
pinState => { oid => '.1.3.6.1.4.1.48690.2.2' },
|
||||
netState => { oid => '.1.3.6.1.4.1.48690.2.3' },
|
||||
signal => { oid => '.1.3.6.1.4.1.48690.2.4' },
|
||||
operator => { oid => '.1.3.6.1.4.1.48690.2.5' },
|
||||
connectionState => { oid => '.1.3.6.1.4.1.48690.2.7' },
|
||||
temperature => { oid => '.1.3.6.1.4.1.48690.2.9' },
|
||||
sent => { oid => '.1.3.6.1.4.1.48690.2.19' },
|
||||
received => { oid => '.1.3.6.1.4.1.48690.2.20' },
|
||||
rsrp => { oid => '.1.3.6.1.4.1.48690.2.23' },
|
||||
rsrq => { oid => '.1.3.6.1.4.1.48690.2.24' }
|
||||
};
|
||||
|
||||
my $snmp_result = $options{snmp}->get_leef(
|
||||
oids => [ map($_->{oid} . '.0', values(%$mapping)) ],
|
||||
nothing_quit => 1
|
||||
);
|
||||
|
||||
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => 0);
|
||||
$result->{simState} = defined($result->{simState}) ? $result->{simState} : '-';
|
||||
$result->{pinState} = defined($result->{pinState}) ? $result->{pinState} : '-';
|
||||
$result->{netState} = defined($result->{netState}) ? $result->{netState} : '-';
|
||||
$result->{temperature} = $result->{temperature} / 10;
|
||||
$result->{sent} = $result->{sent} * 8;
|
||||
$result->{received} = $result->{received} * 8;
|
||||
|
||||
$self->{modems} = { 0 => $result };
|
||||
}
|
||||
|
||||
sub teltonika_trb14x {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $mapping = {
|
||||
imsi => { oid => '.1.3.6.1.4.1.48690.2.2.1.8' },
|
||||
simState => { oid => '.1.3.6.1.4.1.48690.2.2.1.9' },
|
||||
pinState => { oid => '.1.3.6.1.4.1.48690.2.2.1.10' },
|
||||
netState => { oid => '.1.3.6.1.4.1.48690.2.2.1.11' },
|
||||
signal => { oid => '.1.3.6.1.4.1.48690.2.2.1.12' },
|
||||
operator => { oid => '.1.3.6.1.4.1.48690.2.2.1.13' },
|
||||
connectionState => { oid => '.1.3.6.1.4.1.48690.2.2.1.15' },
|
||||
temperature => { oid => '.1.3.6.1.4.1.48690.2.2.1.17' },
|
||||
rsrp => { oid => '.1.3.6.1.4.1.48690.2.2.1.20' },
|
||||
rsrq => { oid => '.1.3.6.1.4.1.48690.2.2.1.21' },
|
||||
sent => { oid => '.1.3.6.1.4.1.48690.2.2.1.22' },
|
||||
received => { oid => '.1.3.6.1.4.1.48690.2.2.1.23' }
|
||||
};
|
||||
|
||||
my $oid_modemEntry = '.1.3.6.1.4.1.48690.2.2.1';
|
||||
my $snmp_result = $options{snmp}->get_table(
|
||||
oid => $oid_modemEntry,
|
||||
nothing_quit => 1
|
||||
);
|
||||
|
||||
$self->{modems} = {};
|
||||
foreach my $oid (keys %$snmp_result) {
|
||||
next if ($oid !~ /^$mapping->{imsi}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
|
||||
|
||||
$result->{simState} = defined($result->{simState}) ? $result->{simState} : '-';
|
||||
$result->{pinState} = defined($result->{pinState}) ? $result->{pinState} : '-';
|
||||
$result->{netState} = defined($result->{netState}) ? $result->{netState} : '-';
|
||||
$result->{temperature} = $result->{temperature} / 10;
|
||||
$result->{sent} = $result->{sent} * 8;
|
||||
$result->{received} = $result->{received} * 8;
|
||||
|
||||
$self->{modems}->{$instance} = $result;
|
||||
}
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $oid_hardwareRevision = '.1.3.6.1.4.1.48690.1.10.0'; # legacy
|
||||
my $oid_fwVersion = '.1.3.6.1.4.1.48690.1.6.0';
|
||||
|
||||
my $snmp_result = $options{snmp}->get_leef(
|
||||
oids => [ $oid_hardwareRevision, $oid_fwVersion ],
|
||||
nothing_quit => 1
|
||||
);
|
||||
|
||||
if (defined($snmp_result->{$oid_hardwareRevision})) {
|
||||
$self->teltonika_legacy(snmp => $options{snmp});
|
||||
} else {
|
||||
$self->teltonika_trb14x(snmp => $options{snmp});
|
||||
}
|
||||
|
||||
$self->{cache_name} = 'teltonika_' . $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'));
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check modem.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--filter-counters>
|
||||
|
||||
Only display some counters (regexp can be used).
|
||||
Example: --filter-counters='status'
|
||||
|
||||
=item B<--warning-status>
|
||||
|
||||
Define the conditions to match for the status to be WARNING.
|
||||
You can use the following variables: %{simState}, %{pinState}, %{netState}, %{connectionState}
|
||||
|
||||
=item B<--critical-status>
|
||||
|
||||
Define the conditions to match for the status to be CRITICAL (default: '%{connectionState} !~ /connected/i').
|
||||
You can use the following variables: %{simState}, %{pinState}, %{netState}, %{connectionState}
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds.
|
||||
Can be: 'signal-strength', 'temperature', 'traffic-in', 'traffic-out'
|
||||
'signal-receive-power', 'signal-receive-quality'.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
@ -1,202 +0,0 @@
|
||||
#
|
||||
# Copyright 2018 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::teltonika::snmp::mode::system;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc);
|
||||
use Digest::MD5 qw(md5_hex);
|
||||
|
||||
sub custom_status_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $msg = sprintf("connection state is '%s' [pin state: '%s'] [net state: '%s'][sim state: '%s']",
|
||||
$self->{result_values}->{connection_state},
|
||||
$self->{result_values}->{pin_state},
|
||||
$self->{result_values}->{net_state},
|
||||
$self->{result_values}->{sim_state},
|
||||
);
|
||||
return $msg;
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0, skipped_code => { -10 => 1 } },
|
||||
];
|
||||
$self->{maps_counters}->{global} = [
|
||||
{ label => 'status', threshold => 0, set => {
|
||||
key_values => [ { name => 'sim_state' }, { name => 'pin_state' }, { name => 'net_state' }, { name => 'connection_state' } ],
|
||||
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,
|
||||
}
|
||||
},
|
||||
{ label => 'signal-strength', nlabel => 'system.signal.strength.dbm', display_ok => 0, set => {
|
||||
key_values => [ { name => 'signal' } ],
|
||||
output_template => 'signal strength: %s Dbm',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0 , unit => 'Dbm' },
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'temperature', nlabel => 'system.temperature.celsius', display_ok => 0, set => {
|
||||
key_values => [ { name => 'temperature' } ],
|
||||
output_template => 'temperature: %s C',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0 , unit => 'C' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'traffic-in', nlabel => 'system.traffic.in.bitspersecond', display_ok => 0, set => {
|
||||
key_values => [ { name => 'traffic_in', per_second => 1 } ],
|
||||
output_template => 'traffic in: %s %s/s',
|
||||
output_change_bytes => 2,
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0, unit => 'b/s' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'traffic-out', nlabel => 'system.traffic.out.bitspersecond', display_ok => 0, set => {
|
||||
key_values => [ { name => 'traffic_out', per_second => 1 } ],
|
||||
output_template => 'traffic out: %s %s/s',
|
||||
output_change_bytes => 2,
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0, unit => 'b/s' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'signal-receive-power', nlabel => 'system.signal.receive.power.dbm', display_ok => 0, set => {
|
||||
key_values => [ { name => 'rsrp' } ],
|
||||
output_template => 'signal receive power: %s Dbm',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0 , unit => 'Dbm' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'signal-receive-quality', nlabel => 'system.signal.receive.quality.dbm', display_ok => 0, set => {
|
||||
key_values => [ { name => 'rsrq' } ],
|
||||
output_template => 'signal receive quality: %s Dbm',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0 , unit => 'Dbm' },
|
||||
],
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
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 => {
|
||||
'warning-status:s' => { name => 'warning_status', default => '' },
|
||||
'critical-status:s' => { name => 'critical_status', default => '%{connection_state} !~ /connected/i' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
$self->change_macros(macros => ['warning_status', 'critical_status']);
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $oid_SimState = '.1.3.6.1.4.1.48690.2.1.0';
|
||||
my $oid_PinState = '.1.3.6.1.4.1.48690.2.2.0';
|
||||
my $oid_NetState = '.1.3.6.1.4.1.48690.2.3.0';
|
||||
my $oid_Signal = '.1.3.6.1.4.1.48690.2.4.0';
|
||||
my $oid_ConnectionState = '.1.3.6.1.4.1.48690.2.7.0';
|
||||
my $oid_Temperature = '.1.3.6.1.4.1.48690.2.9.0';
|
||||
my $oid_Sent = '.1.3.6.1.4.1.48690.2.19.0';
|
||||
my $oid_Received = '.1.3.6.1.4.1.48690.2.20.0';
|
||||
my $oid_RSRP = '.1.3.6.1.4.1.48690.2.23.0';
|
||||
my $oid_RSRQ = '.1.3.6.1.4.1.48690.2.24.0';
|
||||
my $result = $options{snmp}->get_leef(
|
||||
oids => [
|
||||
$oid_SimState, $oid_PinState, $oid_NetState, $oid_ConnectionState,
|
||||
$oid_Signal, $oid_Temperature, $oid_Sent, $oid_Received,
|
||||
$oid_RSRP, $oid_RSRQ
|
||||
],
|
||||
nothing_quit => 1
|
||||
);
|
||||
|
||||
$self->{cache_name} = "teltonika_" . $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'));
|
||||
|
||||
$self->{global} = {
|
||||
sim_state => defined($result->{$oid_SimState}) ? $result->{$oid_SimState} : '-',
|
||||
pin_state => defined($result->{$oid_PinState}) ? $result->{$oid_PinState} : '-',
|
||||
net_state => defined($result->{$oid_NetState}) ? $result->{$oid_NetState} : '-',
|
||||
connection_state => $result->{$oid_ConnectionState},
|
||||
signal => $result->{$oid_Signal},
|
||||
temperature => $result->{$oid_Temperature} / 10,
|
||||
traffic_in => $result->{$oid_Received} * 8,
|
||||
traffic_out => $result->{$oid_Sent} * 8,
|
||||
rsrp => $result->{$oid_RSRP},
|
||||
rsrq => $result->{$oid_RSRQ},
|
||||
};
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check system.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--filter-counters>
|
||||
|
||||
Only display some counters (regexp can be used).
|
||||
Example: --filter-counters='status'
|
||||
|
||||
=item B<--warning-status>
|
||||
|
||||
Define the conditions to match for the status to be WARNING (Default: '').
|
||||
You can use the following variables: %{sim_state}, %{pin_state}, %{net_state}, %{connection_state}
|
||||
|
||||
=item B<--critical-status>
|
||||
|
||||
Define the conditions to match for the status to be CRITICAL (Default: '%{connection_state} !~ /connected/i').
|
||||
You can use the following variables: %{sim_state}, %{pin_state}, %{net_state}, %{connection_state}
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds.
|
||||
Can be: 'signal-strength', 'temperature', 'traffic-in', 'traffic-out'
|
||||
'signal-receive-power', 'signal-receive-quality'.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
@ -29,12 +29,11 @@ sub new {
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
%{$self->{modes}} = (
|
||||
'interfaces' => 'snmp_standard::mode::interfaces',
|
||||
$self->{modes} = {
|
||||
'interfaces' => 'network::teltonika::snmp::mode::interfaces',
|
||||
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
|
||||
'system' => 'network::teltonika::snmp::mode::system',
|
||||
);
|
||||
'modem' => 'network::teltonika::snmp::mode::modem'
|
||||
};
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user