enh(asterisk): metrics v2 (#3272)
This commit is contained in:
parent
26413e6946
commit
55f4dacc8c
|
@ -34,38 +34,38 @@ sub set_counters {
|
||||||
];
|
];
|
||||||
|
|
||||||
$self->{maps_counters}->{global} = [
|
$self->{maps_counters}->{global} = [
|
||||||
{ label => 'channels-active', set => {
|
{ label => 'channels-active', nlabel => 'channels.active.count', set => {
|
||||||
key_values => [ { name => 'channels_active' } ],
|
key_values => [ { name => 'channels_active' } ],
|
||||||
output_template => 'Channels Active: %s',
|
output_template => 'channels active: %s',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'channels_active', value => 'channels_active', template => '%s', min => 0 },
|
{ label => 'channels_active', template => '%s', min => 0 }
|
||||||
],
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'calls-active', set => {
|
{ label => 'calls-active', nlabel => 'calls.active.count', set => {
|
||||||
key_values => [ { name => 'calls_active' } ],
|
key_values => [ { name => 'calls_active' } ],
|
||||||
output_template => 'Calls Active: %s',
|
output_template => 'calls active: %s',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'calls_active', value => 'calls_active', template => '%s', min => 0 },
|
{ label => 'calls_active', template => '%s', min => 0 }
|
||||||
],
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'extcalls-active', set => {
|
{ label => 'extcalls-active', nlabel => 'extcalls.active.count', set => {
|
||||||
key_values => [ { name => 'extcalls_active' } ],
|
key_values => [ { name => 'extcalls_active' } ],
|
||||||
output_template => 'External Calls Active: %s',
|
output_template => 'external calls active: %s',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'extcalls_active', value => 'extcalls_active', template => '%s', min => 0 },
|
{ label => 'extcalls_active', template => '%s', min => 0 }
|
||||||
],
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'calls-count', set => {
|
{ label => 'calls-count', nlabel => 'calls.processed.count', set => {
|
||||||
key_values => [ { name => 'calls_count', diff => 1 } ],
|
key_values => [ { name => 'calls_count', diff => 1 } ],
|
||||||
output_template => 'Calls Count: %s',
|
output_template => 'calls count: %s',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'calls_count', value => 'calls_count', template => '%s', min => 0 },
|
{ label => 'calls_count', template => '%s', min => 0 }
|
||||||
],
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,21 +24,18 @@ use base qw(centreon::plugins::templates::counter);
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
|
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||||
|
|
||||||
sub custom_status_output {
|
sub custom_status_output {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $msg = sprintf('status : %s', $self->{result_values}->{status});
|
return sprintf('status : %s', $self->{result_values}->{status});
|
||||||
return $msg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub custom_status_calc {
|
sub prefix_dahdi_output {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'};
|
return "Line '" . $options{instance_value}->{description} . "' ";
|
||||||
$self->{result_values}->{description} = $options{new_datas}->{$self->{instance} . '_description'};
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub set_counters {
|
sub set_counters {
|
||||||
|
@ -49,12 +46,16 @@ sub set_counters {
|
||||||
];
|
];
|
||||||
|
|
||||||
$self->{maps_counters}->{dahdi} = [
|
$self->{maps_counters}->{dahdi} = [
|
||||||
{ label => 'status', threshold => 0, set => {
|
{
|
||||||
|
label => 'status',
|
||||||
|
type => 2,
|
||||||
|
warning_default => '%{status} =~ /UNCONFIGURED|YEL|BLU/i',
|
||||||
|
critical_default => '%{status} =~ /RED/i',
|
||||||
|
set => {
|
||||||
key_values => [ { name => 'description' }, { name => 'status' } ],
|
key_values => [ { name => 'description' }, { name => 'status' } ],
|
||||||
closure_custom_calc => $self->can('custom_status_calc'),
|
|
||||||
closure_custom_output => $self->can('custom_status_output'),
|
closure_custom_output => $self->can('custom_status_output'),
|
||||||
closure_custom_perfdata => sub { return 0; },
|
closure_custom_perfdata => sub { return 0; },
|
||||||
closure_custom_threshold_check => \&catalog_status_threshold,
|
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
@ -65,29 +66,13 @@ sub new {
|
||||||
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 => {
|
||||||
{
|
"filter-description:s" => { name => 'filter_description' }
|
||||||
"filter-description:s" => { name => 'filter_description' },
|
|
||||||
"warning-status:s" => { name => 'warning_status', default => '%{status} =~ /UNCONFIGURED|YEL|BLU/i' },
|
|
||||||
"critical-status:s" => { name => 'critical_status', default => '%{status} =~ /RED/i' },
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check_options {
|
|
||||||
my ($self, %options) = @_;
|
|
||||||
$self->SUPER::check_options(%options);
|
|
||||||
|
|
||||||
$self->change_macros(macros => ['warning_status', 'critical_status']);
|
|
||||||
}
|
|
||||||
|
|
||||||
sub prefix_dahdi_output {
|
|
||||||
my ($self, %options) = @_;
|
|
||||||
|
|
||||||
return "Line '" . $options{instance_value}->{description} . "' ";
|
|
||||||
}
|
|
||||||
|
|
||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
|
|
@ -24,13 +24,12 @@ use base qw(centreon::plugins::templates::counter);
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
|
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||||
|
|
||||||
sub custom_status_output {
|
sub custom_status_output {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $msg = sprintf('status : %s', $self->{result_values}->{status});
|
return sprintf('status : %s', $self->{result_values}->{status});
|
||||||
return $msg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub custom_status_calc {
|
sub custom_status_calc {
|
||||||
|
@ -41,6 +40,12 @@ sub custom_status_calc {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub prefix_sip_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return "Peer '" . $options{instance_value}->{name} . "' ";
|
||||||
|
}
|
||||||
|
|
||||||
sub set_counters {
|
sub set_counters {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
@ -50,56 +55,61 @@ sub set_counters {
|
||||||
];
|
];
|
||||||
|
|
||||||
$self->{maps_counters}->{global} = [
|
$self->{maps_counters}->{global} = [
|
||||||
{ label => 'total-peers', set => {
|
{ label => 'total-peers', nlabel => 'sip.peers.total.count', set => {
|
||||||
key_values => [ { name => 'total_peers' } ],
|
key_values => [ { name => 'total_peers' } ],
|
||||||
output_template => 'Total Peers: %s',
|
output_template => 'total peers: %s',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'total_peers', value => 'total_peers', template => '%s', min => 0 },
|
{ label => 'total_peers', template => '%s', min => 0 }
|
||||||
],
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'monitor-online-peers', set => {
|
{ label => 'monitor-online-peers', nlabel => 'sip.peers.monitor.online.count', set => {
|
||||||
key_values => [ { name => 'monitor_online_peers' } ],
|
key_values => [ { name => 'monitor_online_peers' } ],
|
||||||
output_template => 'Monitor Online Peers: %s',
|
output_template => 'monitor online peers: %s',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'monitor_online_peers', value => 'monitor_online_peers', template => '%s', min => 0 },
|
{ label => 'monitor_online_peers', template => '%s', min => 0 }
|
||||||
],
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'monitor-offline-peers', set => {
|
{ label => 'monitor-offline-peers', nlabel => 'sip.peers.monitor.offline.count', set => {
|
||||||
key_values => [ { name => 'monitor_offline_peers' } ],
|
key_values => [ { name => 'monitor_offline_peers' } ],
|
||||||
output_template => 'Monitor Offline Peers: %s',
|
output_template => 'monitor offline peers: %s',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'monitor_offline_peers', value => 'monitor_offline_peers', template => '%s', min => 0 },
|
{ label => 'monitor_offline_peers', template => '%s', min => 0 }
|
||||||
],
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'unmonitor-online-peers', set => {
|
{ label => 'unmonitor-online-peers', nlabel => 'sip.peers.unmonitor.online.count', set => {
|
||||||
key_values => [ { name => 'unmonitor_online_peers' } ],
|
key_values => [ { name => 'unmonitor_online_peers' } ],
|
||||||
output_template => 'Unmonitor Online Peers: %s',
|
output_template => 'unmonitor online peers: %s',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'unmonitor_online_peers', value => 'unmonitor_online_peers', template => '%s', min => 0 },
|
{ label => 'unmonitor_online_peers', template => '%s', min => 0 }
|
||||||
],
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'unmonitor-offline-peers', set => {
|
{ label => 'unmonitor-offline-peers', nlabel => 'sip.peers.unmonitor.offline.count', set => {
|
||||||
key_values => [ { name => 'unmonitor_offline_peers' } ],
|
key_values => [ { name => 'unmonitor_offline_peers' } ],
|
||||||
output_template => 'Unmonitor Offline Peers: %s',
|
output_template => 'unmonitor offline peers: %s',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'unmonitor_offline_peers', value => 'unmonitor_offline_peers', template => '%s', min => 0 },
|
{ label => 'unmonitor_offline_peers', template => '%s', min => 0 }
|
||||||
],
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
];
|
];
|
||||||
$self->{maps_counters}->{sip} = [
|
$self->{maps_counters}->{sip} = [
|
||||||
{ label => 'status', threshold => 0, set => {
|
{
|
||||||
|
label => 'status',
|
||||||
|
type => 2,
|
||||||
|
warning_default => '%{status} =~ /LAGGED|UNKNOWN/i',
|
||||||
|
critical_default => '%{status} =~ /UNREACHABLE/i',
|
||||||
|
set => {
|
||||||
key_values => [ { name => 'name' }, { name => 'status' } ],
|
key_values => [ { name => 'name' }, { name => 'status' } ],
|
||||||
closure_custom_calc => $self->can('custom_status_calc'),
|
closure_custom_calc => $self->can('custom_status_calc'),
|
||||||
closure_custom_output => $self->can('custom_status_output'),
|
closure_custom_output => $self->can('custom_status_output'),
|
||||||
closure_custom_perfdata => sub { return 0; },
|
closure_custom_perfdata => sub { return 0; },
|
||||||
closure_custom_threshold_check => \&catalog_status_threshold,
|
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,29 +118,13 @@ sub new {
|
||||||
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 => {
|
||||||
{
|
"filter-name:s" => { name => 'filter_name' }
|
||||||
"filter-name:s" => { name => 'filter_name' },
|
|
||||||
"warning-status:s" => { name => 'warning_status', default => '%{status} =~ /LAGGED|UNKNOWN/i' },
|
|
||||||
"critical-status:s" => { name => 'critical_status', default => '%{status} =~ /UNREACHABLE/i' },
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check_options {
|
|
||||||
my ($self, %options) = @_;
|
|
||||||
$self->SUPER::check_options(%options);
|
|
||||||
|
|
||||||
$self->change_macros(macros => ['warning_status', 'critical_status']);
|
|
||||||
}
|
|
||||||
|
|
||||||
sub prefix_sip_output {
|
|
||||||
my ($self, %options) = @_;
|
|
||||||
|
|
||||||
return "Peer '" . $options{instance_value}->{name} . "' ";
|
|
||||||
}
|
|
||||||
|
|
||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
|
|
@ -30,11 +30,11 @@ sub new {
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$self->{version} = '1.0';
|
$self->{version} = '1.0';
|
||||||
%{$self->{modes}} = (
|
$self->{modes} = {
|
||||||
'channel-usage' => 'apps::voip::asterisk::ami::mode::channelusage',
|
'channel-usage' => 'apps::voip::asterisk::ami::mode::channelusage',
|
||||||
'dahdi-status' => 'apps::voip::asterisk::ami::mode::dahdistatus',
|
'dahdi-status' => 'apps::voip::asterisk::ami::mode::dahdistatus',
|
||||||
'sip-peers-usage' => 'apps::voip::asterisk::ami::mode::sippeersusage',
|
'sip-peers-usage' => 'apps::voip::asterisk::ami::mode::sippeersusage'
|
||||||
);
|
};
|
||||||
|
|
||||||
$self->{custom_modes}{api} = 'apps::voip::asterisk::ami::custom::api';
|
$self->{custom_modes}{api} = 'apps::voip::asterisk::ami::custom::api';
|
||||||
return $self;
|
return $self;
|
||||||
|
|
|
@ -33,30 +33,30 @@ sub set_counters {
|
||||||
{ name => 'global', type => 0 },
|
{ name => 'global', type => 0 },
|
||||||
];
|
];
|
||||||
$self->{maps_counters}->{global} = [
|
$self->{maps_counters}->{global} = [
|
||||||
{ label => 'channels-active', set => {
|
{ label => 'channels-active', nlabel => 'channels.active.count', set => {
|
||||||
key_values => [ { name => 'channels_active' } ],
|
key_values => [ { name => 'channels_active' } ],
|
||||||
output_template => 'Channels Active: %s',
|
output_template => 'channels active: %s',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'channels_active', value => 'channels_active', template => '%s', min => 0 },
|
{ label => 'channels_active', template => '%s', min => 0 }
|
||||||
],
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'calls-active', set => {
|
{ label => 'calls-active', nlabel => 'calls.active.count', set => {
|
||||||
key_values => [ { name => 'calls_active' } ],
|
key_values => [ { name => 'calls_active' } ],
|
||||||
output_template => 'Calls Active: %s',
|
output_template => 'calls active: %s',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'calls_active', value => 'calls_active', template => '%s', min => 0 },
|
{ label => 'calls_active', template => '%s', min => 0 }
|
||||||
],
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'calls-count', set => {
|
{ label => 'calls-count', nlabel => 'calls.processed.count', set => {
|
||||||
key_values => [ { name => 'calls_count', diff => 1 } ],
|
key_values => [ { name => 'calls_count', diff => 1 } ],
|
||||||
output_template => 'Calls Count: %s',
|
output_template => 'calls count: %s',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'calls_count', value => 'calls_count', template => '%s', min => 0 },
|
{ label => 'calls_count', template => '%s', min => 0 }
|
||||||
],
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,9 +31,9 @@ sub new {
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$self->{version} = '0.1';
|
$self->{version} = '0.1';
|
||||||
%{$self->{modes}} = (
|
$self->{modes} = {
|
||||||
'channel-usage' => 'apps::voip::asterisk::snmp::mode::channelusage',
|
'channel-usage' => 'apps::voip::asterisk::snmp::mode::channelusage'
|
||||||
);
|
};
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue