enh(athonet/epc): change packets counters + license expiration (#2722)
This commit is contained in:
parent
8ea8c2b7cb
commit
c5cbe70905
|
@ -34,19 +34,21 @@ sub set_counters {
|
|||
];
|
||||
|
||||
$self->{maps_counters}->{global} = [
|
||||
{ label => 'packets-in', nlabel => 'aggregate.packets.in.count', set => {
|
||||
key_values => [ { name => 'packets_in', diff => 1 } ],
|
||||
output_template => 'packets in: %s',
|
||||
{ label => 'traffic-in', nlabel => 'aggregate.traffic.in.bytespersecond', set => {
|
||||
key_values => [ { name => 'traffic_in', per_second => 1 } ],
|
||||
output_template => 'traffic in: %.2f %s/s',
|
||||
output_change_bytes => 1,
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0 }
|
||||
{ template => '%s', unit => 'B/s', min => 0 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'packets-out', nlabel => 'aggregate.packets.out.count', set => {
|
||||
key_values => [ { name => 'packets_out', diff => 1 } ],
|
||||
output_template => 'packets out: %s',
|
||||
{ label => 'traffic-out', nlabel => 'aggregate.traffic.out.bytespersecond', set => {
|
||||
key_values => [ { name => 'traffic_out', per_second => 1 } ],
|
||||
output_template => 'traffic out: %.2f %s/s',
|
||||
output_change_bytes => 1,
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0 }
|
||||
{ template => '%s', unit => 'B/s', min => 0 }
|
||||
]
|
||||
}
|
||||
},
|
||||
|
@ -89,8 +91,8 @@ sub new {
|
|||
}
|
||||
|
||||
my $mapping = {
|
||||
packets_in => { oid => '.1.3.6.1.4.1.35805.10.2.99.5' }, # loadPktInGi
|
||||
packets_out => { oid => '.1.3.6.1.4.1.35805.10.2.99.6' }, # loadPktOutGi
|
||||
traffic_in => { oid => '.1.3.6.1.4.1.35805.10.2.99.5' }, # loadPktInGi
|
||||
traffic_out => { oid => '.1.3.6.1.4.1.35805.10.2.99.6' }, # loadPktOutGi
|
||||
roaming_users => { oid => '.1.3.6.1.4.1.35805.10.2.99.8' }, # hssRoamingUsers
|
||||
auth_req => { oid => '.1.3.6.1.4.1.35805.10.2.99.9' }, # hssAuthenticationRequests
|
||||
location_updates => { oid => '.1.3.6.1.4.1.35805.10.2.99.10' } # hssLocationUpdates
|
||||
|
@ -126,7 +128,7 @@ Example: --filter-counters='roaming'
|
|||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds.
|
||||
Can be: 'packets-in', 'packets-out',
|
||||
Can be: 'traffic-in', 'traffic-out',
|
||||
'users-roaming-connected', 'requests-authentication', 'location-updates'.
|
||||
|
||||
=back
|
||||
|
|
|
@ -49,7 +49,7 @@ sub prefix_traffic_output {
|
|||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{
|
||||
name => 'apns', type => 3, cb_prefix_output => 'prefix_apn_output', cb_long_output => 'apn_long_output',
|
||||
|
@ -63,7 +63,7 @@ sub set_counters {
|
|||
|
||||
$self->{maps_counters}->{traffic} = [
|
||||
{ label => 'traffic-in', nlabel => 'apn.traffic.in.bytespersecond', set => {
|
||||
key_values => [ { name => 'traffic_in' } ],
|
||||
key_values => [ { name => 'traffic_in', per_second => 1 } ],
|
||||
output_template => 'in: %.2f %s/s',
|
||||
output_change_bytes => 1,
|
||||
perfdatas => [
|
||||
|
@ -72,7 +72,7 @@ sub set_counters {
|
|||
}
|
||||
},
|
||||
{ label => 'traffic-out', nlabel => 'apn.traffic.out.bytespersecond', set => {
|
||||
key_values => [ { name => 'traffic_out' } ],
|
||||
key_values => [ { name => 'traffic_out', per_second => 1 } ],
|
||||
output_template => 'out: %.2f %s/s',
|
||||
output_change_bytes => 1,
|
||||
perfdatas => [
|
||||
|
@ -84,7 +84,7 @@ sub set_counters {
|
|||
|
||||
$self->{maps_counters}->{pdp} = [
|
||||
{ label => 'pdp-contexts', nlabel => 'apn.pdp_contexts.count', set => {
|
||||
key_values => [ { name => 'contexts', diff => 1 } ],
|
||||
key_values => [ { name => 'contexts' } ],
|
||||
output_template => 'pdp contexts: %s',
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0, label_extra_instance => 1 }
|
||||
|
|
|
@ -151,19 +151,21 @@ sub set_counters {
|
|||
];
|
||||
|
||||
$self->{maps_counters}->{global_traffic} = [
|
||||
{ label => 'packets-in', nlabel => 'lte.interface.packets.in.count', set => {
|
||||
key_values => [ { name => 'packets_in', diff => 1 } ],
|
||||
output_template => 'packets in: %s',
|
||||
{ label => 'traffic-in', nlabel => 'lte.interface.traffic.in.bytespersecond', set => {
|
||||
key_values => [ { name => 'traffic_in', per_second => 1 } ],
|
||||
output_template => 'traffic in: %.2f %s/s',
|
||||
output_change_bytes => 1,
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0, label_extra_instance => 1 }
|
||||
{ template => '%.2f', unit => 'B/s', min => 0, label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'packets-out', nlabel => 'lte.interface.packets.out.count', set => {
|
||||
key_values => [ { name => 'packets_out', diff => 1 } ],
|
||||
output_template => 'packets out: %s',
|
||||
{ label => 'traffic-out', nlabel => 'lte.interface.traffic.out.bytespersecond', set => {
|
||||
key_values => [ { name => 'traffic_out', per_second => 1 } ],
|
||||
output_template => 'traffic out: %.2f %s/s',
|
||||
output_change_bytes => 1,
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0, label_extra_instance => 1 }
|
||||
{ template => '%.2f', unit => 'B/s', min => 0, label_extra_instance => 1 }
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -304,8 +306,8 @@ my $map_status = { 0 => 'down', 1 => 'up' };
|
|||
my $mapping = {
|
||||
sctp_status => { oid => '.1.3.6.1.4.1.35805.10.2.2.99.1.3', map => $map_status }, # iLteSCTPState
|
||||
s1ap_status => { oid => '.1.3.6.1.4.1.35805.10.2.2.99.1.4', map => $map_status }, # iLteS1APState
|
||||
packets_in => { oid => '.1.3.6.1.4.1.35805.10.2.2.99.1.5' }, # iLteLoadPktIn
|
||||
packets_out => { oid => '.1.3.6.1.4.1.35805.10.2.2.99.1.6' }, # iLteLoadPktOut
|
||||
traffic_in => { oid => '.1.3.6.1.4.1.35805.10.2.2.99.1.5' }, # iLteLoadPktIn
|
||||
traffic_out => { oid => '.1.3.6.1.4.1.35805.10.2.2.99.1.6' }, # iLteLoadPktOut
|
||||
users_connected => { oid => '.1.3.6.1.4.1.35805.10.2.2.99.1.7' }, # iLteConnectedUsers
|
||||
users_idle => { oid => '.1.3.6.1.4.1.35805.10.2.2.99.1.8' }, # iLteIdleUsers
|
||||
sessions_active => { oid => '.1.3.6.1.4.1.35805.10.2.2.99.1.9' }, # iLteActiveSessions
|
||||
|
@ -445,7 +447,7 @@ Can used special variables like: %{sctp_status}, %{s1ap_status}, %{name}
|
|||
|
||||
Thresholds.
|
||||
Can be: 'total', 'users-connected', 'users-idle', 'sessions-active',
|
||||
'packets-in', 'packets-out',
|
||||
'traffic-in', 'traffic-out',
|
||||
'requests-ue-context-release-total', 'requests-ue-context-release-radio-lost',
|
||||
'requests-attach-success', 'requests-attach-success-prct',
|
||||
'requests-pdn-context-activation', 'requests-pdn-context-activation-prct',
|
||||
|
|
|
@ -26,8 +26,38 @@ use strict;
|
|||
use warnings;
|
||||
use centreon::plugins::misc;
|
||||
use DateTime;
|
||||
use POSIX;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||
|
||||
my $unitdiv = { s => 1, w => 604800, d => 86400, h => 3600, m => 60 };
|
||||
my $unitdiv_long = { s => 'seconds', w => 'weeks', d => 'days', h => 'hours', m => 'minutes' };
|
||||
|
||||
sub custom_expires_perfdata {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => $self->{nlabel} . '.' . $unitdiv_long->{ $self->{instance_mode}->{option_results}->{unit} },
|
||||
unit => $self->{instance_mode}->{option_results}->{unit},
|
||||
value => floor($self->{result_values}->{expires_seconds} / $unitdiv->{ $self->{instance_mode}->{option_results}->{unit} }),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}),
|
||||
min => 0
|
||||
);
|
||||
}
|
||||
|
||||
sub custom_expires_threshold {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return $self->{perfdata}->threshold_check(
|
||||
value => floor($self->{result_values}->{expires_seconds} / $unitdiv->{ $self->{instance_mode}->{option_results}->{unit} }),
|
||||
threshold => [
|
||||
{ label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' },
|
||||
{ label => 'warning-'. $self->{thlabel}, exit_litteral => 'warning' },
|
||||
{ label => 'unknown-'. $self->{thlabel}, exit_litteral => 'unknown' }
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
sub custom_status_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -111,13 +141,12 @@ sub set_counters {
|
|||
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||
}
|
||||
},
|
||||
{ label => 'expires-seconds', nlabel => 'license.expires.seconds', set => {
|
||||
{ label => 'expires', nlabel => 'license.expires', set => {
|
||||
key_values => [ { name => 'expires_seconds' }, { name => 'expires_human' } ],
|
||||
output_template => 'expires in %s',
|
||||
output_use => 'expires_human',
|
||||
perfdatas => [
|
||||
{ template => '%d', min => 0, unit => 's' }
|
||||
]
|
||||
closure_custom_perfdata => $self->can('custom_expires_perfdata'),
|
||||
closure_custom_threshold_check => $self->can('custom_expires_threshold')
|
||||
}
|
||||
}
|
||||
];
|
||||
|
@ -210,11 +239,21 @@ sub new {
|
|||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'unit:s' => { name => 'unit', default => 'd' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
if ($self->{option_results}->{unit} eq '' || !defined($unitdiv->{$self->{option_results}->{unit}})) {
|
||||
$self->{option_results}->{unit} = 'd';
|
||||
}
|
||||
}
|
||||
|
||||
my $map_status = { 0 => 'ok', 1 => 'expired', 2 => 'invalid' };
|
||||
|
||||
my $mapping = {
|
||||
|
@ -247,16 +286,20 @@ sub manage_selection {
|
|||
usim => {}
|
||||
}
|
||||
};
|
||||
#2035-3-30,7:43:58.0,+0:0
|
||||
if ($result->{expire_time} =~ /^\s*(\d+)-(\d+)-(\d+),(\d+):(\d+):(\d+)\.(\d+),(.*)/) {
|
||||
if (defined($result->{expire_time})) {
|
||||
my @date = unpack('n C6 a C2', $result->{expire_time});
|
||||
my $tz;
|
||||
if (defined($date[7])) {
|
||||
$tz = sprintf("%s%02d%02d", $date[7], $date[8], $date[9]);
|
||||
}
|
||||
my $dt = DateTime->new(
|
||||
year => $1,
|
||||
month => $2,
|
||||
day => $3,
|
||||
hour => $4,
|
||||
minute => $5,
|
||||
second => $6,
|
||||
time_zone => $7
|
||||
year => $date[0],
|
||||
month => $date[1],
|
||||
day => $date[2],
|
||||
hour => $date[3],
|
||||
minute => $date[4],
|
||||
second => $date[5],
|
||||
time_zone => $tz
|
||||
);
|
||||
$self->{license}->{global}->{expire}->{expires_seconds} = $dt->epoch() - time();
|
||||
$self->{license}->{global}->{expire}->{expires_human} = centreon::plugins::misc::change_seconds(
|
||||
|
@ -308,10 +351,15 @@ Can use special variables like: %{status}
|
|||
Set critical threshold for status (Default: '%{status} =~ /expired|invalid/i').
|
||||
Can use special variables like: %{status}
|
||||
|
||||
=item B<--unit>
|
||||
|
||||
Select the unit for expires threshold. May be 's' for seconds, 'm' for minutes,
|
||||
'h' for hours, 'd' for days, 'w' for weeks. Default is days.
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds.
|
||||
Can be: 'expires-seconds', 'license-users-usage', 'license-users-free', 'license-users-usage-prct',
|
||||
Can be: 'expires', 'license-users-usage', 'license-users-free', 'license-users-usage-prct',
|
||||
'license-sessions-usage', 'license-sessions-free', 'license-sessions-usage-prct',
|
||||
'license-usim-usage', 'license-usim-free', 'license-usim-usage-prct'.
|
||||
|
||||
|
|
|
@ -118,19 +118,21 @@ sub set_counters {
|
|||
];
|
||||
|
||||
$self->{maps_counters}->{global_traffic} = [
|
||||
{ label => 'packets-in', nlabel => 'lte.packets.in.count', set => {
|
||||
key_values => [ { name => 'packets_in', diff => 1 } ],
|
||||
output_template => 'packets in: %s',
|
||||
{ label => 'traffic-in', nlabel => 'lte.traffic.in.bytespersecond', set => {
|
||||
key_values => [ { name => 'traffic_in', per_second => 1 } ],
|
||||
output_template => 'traffic in: %.2f %s/s',
|
||||
output_change_bytes => 1,
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0 }
|
||||
{ template => '%s', unit => 'B/s', min => 0 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'packets-out', nlabel => 'lte.packets.out.count', set => {
|
||||
key_values => [ { name => 'packets_out', diff => 1 } ],
|
||||
output_template => 'packets out: %s',
|
||||
{ label => 'traffic-out', nlabel => 'lte.traffic.out.bytespersecond', set => {
|
||||
key_values => [ { name => 'traffic_out', per_second => 1 } ],
|
||||
output_template => 'traffic out: %.2f %s/s',
|
||||
output_change_bytes => 1,
|
||||
perfdatas => [
|
||||
{ template => '%s', min => 0 }
|
||||
{ template => '%s', unit => 'B/s', min => 0 }
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -269,8 +271,8 @@ my $mapping = {
|
|||
users_connected => { oid => '.1.3.6.1.4.1.35805.10.2.2.1' }, # lteUsersConnected
|
||||
users_idle => { oid => '.1.3.6.1.4.1.35805.10.2.2.2' }, # lteUsersIdle
|
||||
sessions_active => { oid => '.1.3.6.1.4.1.35805.10.2.2.4' }, # lteActiveConnections
|
||||
packets_in => { oid => '.1.3.6.1.4.1.35805.10.2.2.5' }, # lteLoadPktInGi
|
||||
packets_out => { oid => '.1.3.6.1.4.1.35805.10.2.2.6' }, # lteLoadPktOutGi
|
||||
traffic_in => { oid => '.1.3.6.1.4.1.35805.10.2.2.5' }, # lteLoadPktInGi
|
||||
traffic_out => { oid => '.1.3.6.1.4.1.35805.10.2.2.6' }, # lteLoadPktOutGi
|
||||
attach_req_total => { oid => '.1.3.6.1.4.1.35805.10.2.2.7' }, # lteTotalAttachReq
|
||||
attach_req_success => { oid => '.1.3.6.1.4.1.35805.10.2.2.8' }, # lteSuccesfullAttach
|
||||
pdn_context_total => { oid => '.1.3.6.1.4.1.35805.10.2.2.10' }, # lteTotalPDNActReq
|
||||
|
@ -341,7 +343,7 @@ Example: --filter-counters='users'
|
|||
|
||||
Thresholds.
|
||||
Can be: 'users-connected', 'users-idle', 'sessions-active',
|
||||
'packets-in', 'packets-out',
|
||||
'traffic-in', 'traffic-out',
|
||||
'requests-ue-context-release-total', 'requests-ue-context-release-radio-lost',
|
||||
'requests-attach-success', 'requests-attach-success-prct',
|
||||
'requests-pdn-context-activation', 'requests-pdn-context-activation-prct',
|
||||
|
|
Loading…
Reference in New Issue