This commit is contained in:
qgarnier 2021-04-19 13:15:05 +02:00 committed by GitHub
parent 29ab3091b8
commit 9ba7a25ab4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 246 additions and 309 deletions

View File

@ -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 = 'status : ' . $self->{result_values}->{status}; return 'status : ' . $self->{result_values}->{status};
return $msg;
} }
sub custom_status_calc { sub custom_status_calc {
@ -41,49 +40,56 @@ sub custom_status_calc {
return 0; return 0;
} }
sub prefix_ccm_output {
my ($self, %options) = @_;
return "CCM '" . $options{instance_value}->{ccmName} . "' ";
}
sub set_counters { sub set_counters {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{maps_counters_type} = [ $self->{maps_counters_type} = [
{ name => 'global', type => 0 }, { name => 'global', type => 0 },
{ name => 'ccm', type => 1, cb_prefix_output => 'prefix_ccm_output', message_multiple => 'All CCM are ok' }, { name => 'ccm', type => 1, cb_prefix_output => 'prefix_ccm_output', message_multiple => 'All CCM are ok' }
]; ];
$self->{maps_counters}->{ccm} = [ $self->{maps_counters}->{ccm} = [
{ label => 'status', threshold => 0, set => { { label => 'status', type => 2, critical_default => '%{status} !~ /up/', set => {
key_values => [ { name => 'ccmStatus' }, { name => 'ccmName' } ], key_values => [ { name => 'ccmStatus' }, { name => 'ccmName' } ],
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
} }
}, }
]; ];
my @map = ( my @map = (
['phones-registered', 'Phones Registered : %s', 'ccmRegisteredPhones'], ['phones-registered', 'Phones Registered : %s', 'ccmRegisteredPhones', 'phones.registered.count'],
['phones-unregistered', 'Phones Unregistered : %s', 'ccmUnregisteredPhones'], ['phones-unregistered', 'Phones Unregistered : %s', 'ccmUnregisteredPhones', 'phones.unregistered.count'],
['phones-rejected', 'Phones Rejected : %s', 'ccmRejectedPhones'], ['phones-rejected', 'Phones Rejected : %s', 'ccmRejectedPhones', 'phones.rejected.count'],
['gateways-registered', 'Gateways Registered : %s', 'ccmRegisteredPhones'], ['gateways-registered', 'Gateways Registered : %s', 'ccmRegisteredGateways', 'gateways.registered.count'],
['gateways-unregistered', 'Gateways Unregistered : %s', 'ccmUnregisteredGateways'], ['gateways-unregistered', 'Gateways Unregistered : %s', 'ccmUnregisteredGateways', 'gateways.unregistered.count'],
['gateways-rejected', 'Gateways Rejected : %s', 'ccmRejectedGateways'], ['gateways-rejected', 'Gateways Rejected : %s', 'ccmRejectedGateways', 'gateways.rejected.count'],
['mediadevices-registered', 'Media Devices Registered : %s', 'ccmRegisteredMediaDevices'], ['mediadevices-registered', 'Media Devices Registered : %s', 'ccmRegisteredMediaDevices', 'media_devices.registered.count'],
['mediadevices-unregistered', 'Media Devices Unregistered : %s', 'ccmUnregisteredMediaDevices'], ['mediadevices-unregistered', 'Media Devices Unregistered : %s', 'ccmUnregisteredMediaDevices', 'media_devices.unregistered.count'],
['mediadevices-rejected', 'Media Devices Rejected : %s', 'ccmRejectedMediaDevices'], ['mediadevices-rejected', 'Media Devices Rejected : %s', 'ccmRejectedMediaDevices', 'media_devices.rejected.count']
); );
$self->{maps_counters}->{global} = []; $self->{maps_counters}->{global} = [];
foreach (@map) { foreach (@map) {
my $label = $_->[0]; my $label = $_->[0];
$label =~ tr/-/_/; $label =~ tr/-/_/;
push @{$self->{maps_counters}->{global}}, { label => $_->[0], set => { push @{$self->{maps_counters}->{global}}, {
label => $_->[0], nlabel => $_->[3], set => {
key_values => [ { name => $_->[2] } ], key_values => [ { name => $_->[2] } ],
output_template => $_->[1], output_template => $_->[1],
perfdatas => [ perfdatas => [
{ label => $label, value => $_->[2] , template => '%s', min => 0 }, { label => $label, value => $_->[2] , template => '%s', min => 0 }
], ]
} }
}, };
} }
} }
@ -92,28 +98,12 @@ 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 => {
{ });
"warning-status:s" => { name => 'warning_status', default => '' },
"critical-status:s" => { name => 'critical_status', default => '%{status} !~ /up/' },
});
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_ccm_output {
my ($self, %options) = @_;
return "CCM '" . $options{instance_value}->{ccmName} . "' ";
}
my %mapping_status = (1 => 'unknown', 2 => 'up', 3 => 'down'); my %mapping_status = (1 => 'unknown', 2 => 'up', 3 => 'down');
my $mapping = { my $mapping = {
@ -125,11 +115,11 @@ my $mapping = {
ccmRejectedGateways => { oid => '.1.3.6.1.4.1.9.9.156.1.5.10' }, ccmRejectedGateways => { oid => '.1.3.6.1.4.1.9.9.156.1.5.10' },
ccmRegisteredMediaDevices => { oid => '.1.3.6.1.4.1.9.9.156.1.5.11' }, ccmRegisteredMediaDevices => { oid => '.1.3.6.1.4.1.9.9.156.1.5.11' },
ccmUnregisteredMediaDevices => { oid => '.1.3.6.1.4.1.9.9.156.1.5.12' }, ccmUnregisteredMediaDevices => { oid => '.1.3.6.1.4.1.9.9.156.1.5.12' },
ccmRejectedMediaDevices => { oid => '.1.3.6.1.4.1.9.9.156.1.5.13' }, ccmRejectedMediaDevices => { oid => '.1.3.6.1.4.1.9.9.156.1.5.13' }
}; };
my $mapping2 = { my $mapping2 = {
ccmName => { oid => '.1.3.6.1.4.1.9.9.156.1.1.2.1.2' }, ccmName => { oid => '.1.3.6.1.4.1.9.9.156.1.1.2.1.2' },
ccmStatus => { oid => '.1.3.6.1.4.1.9.9.156.1.1.2.1.5', map => \%mapping_status }, ccmStatus => { oid => '.1.3.6.1.4.1.9.9.156.1.1.2.1.5', map => \%mapping_status }
}; };
my $oid_ccmGlobalInfo = '.1.3.6.1.4.1.9.9.156.1.5'; my $oid_ccmGlobalInfo = '.1.3.6.1.4.1.9.9.156.1.5';
@ -138,12 +128,15 @@ my $oid_ccmEntry = '.1.3.6.1.4.1.9.9.156.1.1.2.1';
sub manage_selection { sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;
my $snmp_result = $options{snmp}->get_multiple_table(oids => [ my $snmp_result = $options{snmp}->get_multiple_table(
oids => [
{ oid => $oid_ccmGlobalInfo, end => $mapping->{ccmRejectedMediaDevices}->{oid} }, { oid => $oid_ccmGlobalInfo, end => $mapping->{ccmRejectedMediaDevices}->{oid} },
{ oid => $oid_ccmEntry, end => $mapping2->{ccmStatus}->{oid} }, { oid => $oid_ccmEntry, end => $mapping2->{ccmStatus}->{oid} }
], nothing_quit => 1); ],
nothing_quit => 1
);
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result->{$oid_ccmGlobalInfo}, instance => '0'); my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result->{$oid_ccmGlobalInfo}, instance => '0');
$self->{global} = { %$result }; $self->{global} = $result;
$self->{ccm} = {}; $self->{ccm} = {};
foreach my $oid (keys %{$snmp_result->{$oid_ccmEntry}}) { foreach my $oid (keys %{$snmp_result->{$oid_ccmEntry}}) {
@ -151,7 +144,7 @@ sub manage_selection {
my $instance = $1; my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping2, results => $snmp_result->{$oid_ccmEntry}, instance => $instance); my $result = $options{snmp}->map_instance(mapping => $mapping2, results => $snmp_result->{$oid_ccmEntry}, instance => $instance);
$self->{ccm}->{$instance} = { %$result }; $self->{ccm}->{$instance} = $result;
} }
} }
@ -180,13 +173,9 @@ Can used special variables like: %{status}, %{display}
Set critical threshold for status (Default: '%{status} !~ /up/'). Set critical threshold for status (Default: '%{status} !~ /up/').
Can used special variables like: %{status}, %{display} Can used special variables like: %{status}, %{display}
=item B<--warning-*> =item B<--warning-*> B<--critical-*>
Threshold warning. Thresholds.
=item B<--critical-*>
Threshold critical.
Can be: 'phones-registered', 'phones-unregistered', 'phones-rejected', Can be: 'phones-registered', 'phones-unregistered', 'phones-rejected',
'gateways-registered', 'gateways-unregistered', 'gateways-rejected', 'gateways-registered', 'gateways-unregistered', 'gateways-rejected',

View File

@ -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 = 'status : ' . $self->{result_values}->{status}; return 'status: ' . $self->{result_values}->{status};
return $msg;
} }
sub custom_status_calc { sub custom_status_calc {
@ -41,67 +40,6 @@ sub custom_status_calc {
return 0; return 0;
} }
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' },
{ name => 'cti', type => 1, cb_prefix_output => 'prefix_cti_output', message_multiple => 'All ctis are ok' },
];
$self->{maps_counters}->{cti} = [
{ label => 'status', threshold => 0, set => {
key_values => [ { name => 'ccmCTIDeviceStatus' }, { name => 'ccmCTIDeviceName' } ],
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
];
my @map = (
['total-registered', 'Registered : %s', 'registered'],
['total-unregistered', 'Unregistered : %s', 'unregistered'],
['total-rejected', 'Rejected : %s', 'rejected'],
['total-unknown', 'Unknown : %s', 'unknown'],
['total-partiallyregistered', 'Partially Registered : %s', 'partiallyregistered'],
);
$self->{maps_counters}->{global} = [];
foreach (@map) {
push @{$self->{maps_counters}->{global}}, { label => $_->[0], nlabel => 'cti.devices.total.' . $_->[2] . '.count', set => {
key_values => [ { name => $_->[2] } ],
output_template => $_->[1],
perfdatas => [
{ value => $_->[2] , template => '%s', min => 0 },
],
}
},
}
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments => {
'warning-status:s' => { name => 'warning_status', default => '' },
'critical-status:s' => { name => 'critical_status', default => '%{status} !~ /^registered/' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$self->change_macros(macros => ['warning_status', 'critical_status']);
}
sub prefix_cti_output { sub prefix_cti_output {
my ($self, %options) = @_; my ($self, %options) = @_;
@ -111,17 +49,70 @@ sub prefix_cti_output {
sub prefix_global_output { sub prefix_global_output {
my ($self, %options) = @_; my ($self, %options) = @_;
return "Total "; return 'Total ';
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' },
{ name => 'cti', type => 1, cb_prefix_output => 'prefix_cti_output', message_multiple => 'All ctis are ok' }
];
$self->{maps_counters}->{cti} = [
{ label => 'status', type => 2, critical_default => '%{status} !~ /^registered/', set => {
key_values => [ { name => 'ccmCTIDeviceStatus' }, { name => 'ccmCTIDeviceName' } ],
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold_ng
}
}
];
my @map = (
['total-registered', 'registered: %s', 'registered'],
['total-unregistered', 'unregistered: %s', 'unregistered'],
['total-rejected', 'rejected: %s', 'rejected'],
['total-unknown', 'unknown: %s', 'unknown'],
['total-partiallyregistered', 'partially registered: %s', 'partiallyregistered']
);
$self->{maps_counters}->{global} = [];
foreach (@map) {
push @{$self->{maps_counters}->{global}}, {
label => $_->[0], nlabel => 'cti.devices.total.' . $_->[2] . '.count', set => {
key_values => [ { name => $_->[2] } ],
output_template => $_->[1],
perfdatas => [
{ value => $_->[2] , template => '%s', min => 0 }
]
}
};
}
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments => {
});
return $self;
} }
my %mapping_status = ( my %mapping_status = (
1 => 'unknown', 2 => 'registered', 3 => 'unregistered', 1 => 'unknown', 2 => 'registered', 3 => 'unregistered',
4 => 'rejected', 5 => 'partiallyregistered', 4 => 'rejected', 5 => 'partiallyregistered'
); );
my $mapping = { my $mapping = {
ccmCTIDeviceName => { oid => '.1.3.6.1.4.1.9.9.156.1.8.1.1.2' }, ccmCTIDeviceName => { oid => '.1.3.6.1.4.1.9.9.156.1.8.1.1.2' },
ccmCTIDeviceStatus => { oid => '.1.3.6.1.4.1.9.9.156.1.8.1.1.5', map => \%mapping_status }, ccmCTIDeviceStatus => { oid => '.1.3.6.1.4.1.9.9.156.1.8.1.1.5', map => \%mapping_status }
}; };
my $oid_ccmCtiEntry = '.1.3.6.1.4.1.9.9.156.1.8.1.1'; my $oid_ccmCtiEntry = '.1.3.6.1.4.1.9.9.156.1.8.1.1';
@ -143,7 +134,7 @@ sub manage_selection {
my $instance = $1; my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
$self->{phone}->{$instance} = { %$result }; $self->{phone}->{$instance} = $result;
$self->{global}->{$result->{ccmCTIDeviceStatus}}++; $self->{global}->{$result->{ccmCTIDeviceStatus}}++;
} }
} }

View File

@ -24,21 +24,24 @@ 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 = 'status : ' . $self->{result_values}->{status}; return 'status: ' . $self->{result_values}->{status};
return $msg;
} }
sub custom_status_calc { sub prefix_gateway_output {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_ccmGatewayStatus'}; return "Gateway '" . $options{instance_value}->{display} . "' ";
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_ccmGatewayName'}; }
return 0;
sub prefix_global_output {
my ($self, %options) = @_;
return 'Total ';
} }
sub set_counters { sub set_counters {
@ -46,40 +49,40 @@ sub set_counters {
$self->{maps_counters_type} = [ $self->{maps_counters_type} = [
{ name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' }, { name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' },
{ name => 'gateway', type => 1, cb_prefix_output => 'prefix_gateway_output', message_multiple => 'All gateways are ok' }, { name => 'gateway', type => 1, cb_prefix_output => 'prefix_gateway_output', message_multiple => 'All gateways are ok' }
]; ];
$self->{maps_counters}->{gateway} = [ $self->{maps_counters}->{gateway} = [
{ label => 'status', threshold => 0, set => { { label => 'status', type => 2, critical_default => '%{status} !~ /^registered/', set => {
key_values => [ { name => 'ccmGatewayStatus' }, { name => 'ccmGatewayName' } ], key_values => [ { name => 'status' }, { name => 'display' } ],
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
} }
}, }
]; ];
my @map = ( my @map = (
['total-registered', 'Registered : %s', 'registered'], ['total-registered', 'registered: %s', 'registered', 'gateways.registered.count'],
['total-unregistered', 'Unregistered : %s', 'unregistered'], ['total-unregistered', 'unregistered: %s', 'unregistered', 'gateways.unregistered.count'],
['total-rejected', 'Rejected : %s', 'rejected'], ['total-rejected', 'rejected: %s', 'rejected', 'gateways.rejected.count'],
['total-unknown', 'Unknown : %s', 'unknown'], ['total-unknown', 'unknown: %s', 'unknown', 'gateways.unknown.count'],
['total-partiallyregistered', 'Partially Registered : %s', 'partiallyregistered'], ['total-partiallyregistered', 'partially registered: %s', 'partiallyregistered', 'gateways.partially_registered.count']
); );
$self->{maps_counters}->{global} = []; $self->{maps_counters}->{global} = [];
foreach (@map) { foreach (@map) {
my $label = $_->[0]; my $label = $_->[0];
$label =~ tr/-/_/; $label =~ tr/-/_/;
push @{$self->{maps_counters}->{global}}, { label => $_->[0], set => { push @{$self->{maps_counters}->{global}}, {
label => $_->[0], nlabel => $_->[3], set => {
key_values => [ { name => $_->[2] } ], key_values => [ { name => $_->[2] } ],
output_template => $_->[1], output_template => $_->[1],
perfdatas => [ perfdatas => [
{ label => $label, value => $_->[2] , template => '%s', min => 0 }, { label => $label, value => $_->[2] , template => '%s', min => 0 }
], ]
} }
}, };
} }
} }
@ -88,60 +91,42 @@ 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 => {
{ });
"warning-status:s" => { name => 'warning_status', default => '' },
"critical-status:s" => { name => 'critical_status', default => '%{status} !~ /^registered/' },
});
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_gateway_output {
my ($self, %options) = @_;
return "Gateway '" . $options{instance_value}->{ccmGatewayName} . "' ";
}
sub prefix_global_output {
my ($self, %options) = @_;
return "Total ";
}
my %mapping_status = ( my %mapping_status = (
1 => 'unknown', 2 => 'registered', 3 => 'unregistered', 1 => 'unknown', 2 => 'registered', 3 => 'unregistered',
4 => 'rejected', 5 => 'partiallyregistered', 4 => 'rejected', 5 => 'partiallyregistered'
); );
my $mapping = { my $mapping = {
ccmGatewayName => { oid => '.1.3.6.1.4.1.9.9.156.1.3.1.1.2' }, display => { oid => '.1.3.6.1.4.1.9.9.156.1.3.1.1.2' }, # ccmGatewayName
ccmGatewayStatus => { oid => '.1.3.6.1.4.1.9.9.156.1.3.1.1.5', map => \%mapping_status }, status => { oid => '.1.3.6.1.4.1.9.9.156.1.3.1.1.5', map => \%mapping_status } # ccmGatewayStatus
}; };
my $oid_ccmGatewayEntry = '.1.3.6.1.4.1.9.9.156.1.3.1.1'; my $oid_ccmGatewayEntry = '.1.3.6.1.4.1.9.9.156.1.3.1.1';
sub manage_selection { sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;
my $snmp_result = $options{snmp}->get_table(oid => $oid_ccmGatewayEntry, start => $mapping->{ccmGatewayName}->{oid}, end => $mapping->{ccmGatewayStatus}->{oid}, nothing_quit => 1); my $snmp_result = $options{snmp}->get_table(
oid => $oid_ccmGatewayEntry,
start => $mapping->{display}->{oid},
end => $mapping->{status}->{oid},
nothing_quit => 1
);
$self->{phone} = {}; $self->{phone} = {};
$self->{global} = { unknown => 0, registered => 0, unregistered => 0, rejected => 0, partiallyregistered => 0 }; $self->{global} = { unknown => 0, registered => 0, unregistered => 0, rejected => 0, partiallyregistered => 0 };
foreach my $oid (keys %$snmp_result) { foreach my $oid (keys %$snmp_result) {
next if ($oid !~ /^$mapping->{ccmGatewayStatus}->{oid}\.(.*)/); next if ($oid !~ /^$mapping->{status}->{oid}\.(.*)/);
my $instance = $1; my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
$self->{phone}->{$instance} = { %$result }; $self->{phone}->{$instance} = $result;
$self->{global}->{$result->{ccmGatewayStatus}}++; $self->{global}->{ $result->{status} }++;
} }
} }

View File

@ -24,21 +24,24 @@ 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 = 'status : ' . $self->{result_values}->{status}; return 'status: ' . $self->{result_values}->{status};
return $msg;
} }
sub custom_status_calc { sub prefix_md_output {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_ccmMediaDeviceStatus'}; return "Media device '" . $options{instance_value}->{display} . "' ";
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_ccmMediaDeviceName'}; }
return 0;
sub prefix_global_output {
my ($self, %options) = @_;
return 'Total ';
} }
sub set_counters { sub set_counters {
@ -46,40 +49,40 @@ sub set_counters {
$self->{maps_counters_type} = [ $self->{maps_counters_type} = [
{ name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' }, { name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' },
{ name => 'md', type => 1, cb_prefix_output => 'prefix_md_output', message_multiple => 'All media devices are ok' }, { name => 'md', type => 1, cb_prefix_output => 'prefix_md_output', message_multiple => 'All media devices are ok' }
]; ];
$self->{maps_counters}->{md} = [ $self->{maps_counters}->{md} = [
{ label => 'status', threshold => 0, set => { { label => 'status', type => 2, critical_default => '%{status} !~ /^registered/', set => {
key_values => [ { name => 'ccmMediaDeviceStatus' }, { name => 'ccmMediaDeviceName' } ], key_values => [ { name => 'status' }, { name => 'display' } ],
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
} }
}, }
]; ];
my @map = ( my @map = (
['total-registered', 'Registered : %s', 'registered'], ['total-registered', 'registered: %s', 'registered', 'media_devices.registered.count'],
['total-unregistered', 'Unregistered : %s', 'unregistered'], ['total-unregistered', 'unregistered: %s', 'unregistered', 'media_devices.unregistered.count'],
['total-rejected', 'Rejected : %s', 'rejected'], ['total-rejected', 'rejected: %s', 'rejected', 'media_devices.rejected.count'],
['total-unknown', 'Unknown : %s', 'unknown'], ['total-unknown', 'unknown: %s', 'unknown', 'media_devices.unknown.count'],
['total-partiallyregistered', 'Partially Registered : %s', 'partiallyregistered'], ['total-partiallyregistered', 'partially registered: %s', 'partiallyregistered', 'media_devices.partially_registered.count']
); );
$self->{maps_counters}->{global} = []; $self->{maps_counters}->{global} = [];
foreach (@map) { foreach (@map) {
my $label = $_->[0]; my $label = $_->[0];
$label =~ tr/-/_/; $label =~ tr/-/_/;
push @{$self->{maps_counters}->{global}}, { label => $_->[0], set => { push @{$self->{maps_counters}->{global}}, {
label => $_->[0], nlabel => $_->[3], set => {
key_values => [ { name => $_->[2] } ], key_values => [ { name => $_->[2] } ],
output_template => $_->[1], output_template => $_->[1],
perfdatas => [ perfdatas => [
{ label => $label, value => $_->[2] , template => '%s', min => 0 }, { label => $label, value => $_->[2] , template => '%s', min => 0 }
], ]
} }
}, };
} }
} }
@ -88,60 +91,42 @@ 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 => {
{ });
"warning-status:s" => { name => 'warning_status', default => '' },
"critical-status:s" => { name => 'critical_status', default => '%{status} !~ /^registered/' },
});
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_md_output {
my ($self, %options) = @_;
return "Media device '" . $options{instance_value}->{ccmMediaDeviceName} . "' ";
}
sub prefix_global_output {
my ($self, %options) = @_;
return "Total ";
}
my %mapping_status = ( my %mapping_status = (
1 => 'unknown', 2 => 'registered', 3 => 'unregistered', 1 => 'unknown', 2 => 'registered', 3 => 'unregistered',
4 => 'rejected', 5 => 'partiallyregistered', 4 => 'rejected', 5 => 'partiallyregistered'
); );
my $mapping = { my $mapping = {
ccmMediaDeviceName => { oid => '.1.3.6.1.4.1.9.9.156.1.6.1.1.2' }, display => { oid => '.1.3.6.1.4.1.9.9.156.1.6.1.1.2' }, # ccmMediaDeviceName
ccmMediaDeviceStatus => { oid => '.1.3.6.1.4.1.9.9.156.1.6.1.1.5', map => \%mapping_status }, status => { oid => '.1.3.6.1.4.1.9.9.156.1.6.1.1.5', map => \%mapping_status } # ccmMediaDeviceStatus
}; };
my $oid_ccmMediaDeviceEntry = '.1.3.6.1.4.1.9.9.156.1.6.1.1'; my $oid_ccmMediaDeviceEntry = '.1.3.6.1.4.1.9.9.156.1.6.1.1';
sub manage_selection { sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;
my $snmp_result = $options{snmp}->get_table(oid => $oid_ccmMediaDeviceEntry, start => $mapping->{ccmMediaDeviceName}->{oid}, end => $mapping->{ccmMediaDeviceStatus}->{oid}, nothing_quit => 1); my $snmp_result = $options{snmp}->get_table(
oid => $oid_ccmMediaDeviceEntry,
start => $mapping->{display}->{oid},
end => $mapping->{status}->{oid},
nothing_quit => 1
);
$self->{md} = {}; $self->{md} = {};
$self->{global} = { unknown => 0, registered => 0, unregistered => 0, rejected => 0, partiallyregistered => 0 }; $self->{global} = { unknown => 0, registered => 0, unregistered => 0, rejected => 0, partiallyregistered => 0 };
foreach my $oid (keys %$snmp_result) { foreach my $oid (keys %$snmp_result) {
next if ($oid !~ /^$mapping->{ccmMediaDeviceStatus}->{oid}\.(.*)/); next if ($oid !~ /^$mapping->{status}->{oid}\.(.*)/);
my $instance = $1; my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
$self->{md}->{$instance} = { %$result }; $self->{md}->{$instance} = { %$result };
$self->{global}->{$result->{ccmMediaDeviceStatus}}++; $self->{global}->{ $result->{status} }++;
} }
} }

View File

@ -29,7 +29,7 @@ use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_
sub custom_status_output { sub custom_status_output {
my ($self, %options) = @_; my ($self, %options) = @_;
my $msg = 'status : ' . $self->{result_values}->{status}; my $msg = 'status: ' . $self->{result_values}->{status};
$msg .= ' [description: ' . $self->{result_values}->{description} . ']' if (defined($self->{result_values}->{description}) && $self->{result_values}->{description} ne ''); $msg .= ' [description: ' . $self->{result_values}->{description} . ']' if (defined($self->{result_values}->{description}) && $self->{result_values}->{description} ne '');
return $msg; return $msg;
} }
@ -43,7 +43,7 @@ sub prefix_phone_output {
sub prefix_global_output { sub prefix_global_output {
my ($self, %options) = @_; my ($self, %options) = @_;
return "Total "; return 'Total ';
} }
sub set_counters { sub set_counters {
@ -65,18 +65,19 @@ sub set_counters {
]; ];
my @map = ( my @map = (
['total-registered', 'registered: %s', 'registered'], ['total-registered', 'registered: %s', 'registered', 'phones.registered.count'],
['total-unregistered', 'unregistered: %s', 'unregistered'], ['total-unregistered', 'unregistered: %s', 'unregistered', 'phones.unregistered.count'],
['total-rejected', 'rejected: %s', 'rejected'], ['total-rejected', 'rejected: %s', 'rejected', 'phones.rejected.count'],
['total-unknown', 'unknown: %s', 'unknown'], ['total-unknown', 'unknown: %s', 'unknown', 'phones.unknown.count'],
['total-partiallyregistered', 'partially registered: %s', 'partiallyregistered'] ['total-partiallyregistered', 'partially registered: %s', 'partiallyregistered', 'phones.partially_registered.count']
); );
$self->{maps_counters}->{global} = []; $self->{maps_counters}->{global} = [];
foreach (@map) { foreach (@map) {
my $label = $_->[0]; my $label = $_->[0];
$label =~ tr/-/_/; $label =~ tr/-/_/;
push @{$self->{maps_counters}->{global}}, { label => $_->[0], set => { push @{$self->{maps_counters}->{global}}, {
label => $_->[0], nlabel => $_->[3], set => {
key_values => [ { name => $_->[2] } ], key_values => [ { name => $_->[2] } ],
output_template => $_->[1], output_template => $_->[1],
perfdatas => [ perfdatas => [

View File

@ -24,21 +24,24 @@ 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 = 'status : ' . $self->{result_values}->{status}; return 'status: ' . $self->{result_values}->{status};
return $msg;
} }
sub custom_status_calc { sub prefix_voicemail_output {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_ccmVMailDevStatus'}; return "Voicemail '" . $options{instance_value}->{display} . "' ";
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_ccmVMailDevName'}; }
return 0;
sub prefix_global_output {
my ($self, %options) = @_;
return 'Total ';
} }
sub set_counters { sub set_counters {
@ -46,38 +49,38 @@ sub set_counters {
$self->{maps_counters_type} = [ $self->{maps_counters_type} = [
{ name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' }, { name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' },
{ name => 'voicemail', type => 1, cb_prefix_output => 'prefix_voicemail_output', message_multiple => 'All voicemails are ok' }, { name => 'voicemail', type => 1, cb_prefix_output => 'prefix_voicemail_output', message_multiple => 'All voicemails are ok' }
]; ];
$self->{maps_counters}->{voicemail} = [ $self->{maps_counters}->{voicemail} = [
{ label => 'status', threshold => 0, set => { { label => 'status', type => 2, critical_default => '%{status} !~ /^registered/', set => {
key_values => [ { name => 'ccmVMailDevStatus' }, { name => 'ccmVMailDevName' } ], key_values => [ { name => 'status' }, { name => 'display' } ],
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
} }
}, }
]; ];
my @map = ( my @map = (
['total-registered', 'Registered : %s', 'registered'], ['total-registered', 'registered: %s', 'registered'],
['total-unregistered', 'Unregistered : %s', 'unregistered'], ['total-unregistered', 'unregistered: %s', 'unregistered'],
['total-rejected', 'Rejected : %s', 'rejected'], ['total-rejected', 'rejected: %s', 'rejected'],
['total-unknown', 'Unknown : %s', 'unknown'], ['total-unknown', 'unknown: %s', 'unknown'],
['total-partiallyregistered', 'Partially Registered : %s', 'partiallyregistered'], ['total-partiallyregistered', 'partially registered: %s', 'partiallyregistered']
); );
$self->{maps_counters}->{global} = []; $self->{maps_counters}->{global} = [];
foreach (@map) { foreach (@map) {
push @{$self->{maps_counters}->{global}}, { label => $_->[0], nlabel => 'voicemail.devices.total.' . $_->[2] . '.count', set => { push @{$self->{maps_counters}->{global}}, {
label => $_->[0], nlabel => 'voicemail.devices.total.' . $_->[2] . '.count', set => {
key_values => [ { name => $_->[2] } ], key_values => [ { name => $_->[2] } ],
output_template => $_->[1], output_template => $_->[1],
perfdatas => [ perfdatas => [
{ value => $_->[2] , template => '%s', min => 0 }, { value => $_->[2] , template => '%s', min => 0 }
], ]
} }
}, };
} }
} }
@ -88,59 +91,42 @@ sub new {
$self->{version} = '1.0'; $self->{version} = '1.0';
$options{options}->add_options(arguments => { $options{options}->add_options(arguments => {
'warning-status:s' => { name => 'warning_status', default => '' },
'critical-status:s' => { name => 'critical_status', default => '%{status} !~ /^registered/' },
}); });
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_voicemail_output {
my ($self, %options) = @_;
return "Voicemail '" . $options{instance_value}->{ccmVMailDevName} . "' ";
}
sub prefix_global_output {
my ($self, %options) = @_;
return "Total ";
}
my %mapping_status = ( my %mapping_status = (
1 => 'unknown', 2 => 'registered', 3 => 'unregistered', 1 => 'unknown', 2 => 'registered', 3 => 'unregistered',
4 => 'rejected', 5 => 'partiallyregistered', 4 => 'rejected', 5 => 'partiallyregistered'
); );
my $mapping = { my $mapping = {
ccmVMailDevDescription => { oid => '.1.3.6.1.4.1.9.9.156.1.12.1.1.4' }, display => { oid => '.1.3.6.1.4.1.9.9.156.1.12.1.1.2' }, # ccmVMailDevName
ccmVMailDevName => { oid => '.1.3.6.1.4.1.9.9.156.1.12.1.1.2' }, description => { oid => '.1.3.6.1.4.1.9.9.156.1.12.1.1.4' }, # ccmVMailDevDescription
ccmVMailDevStatus => { oid => '.1.3.6.1.4.1.9.9.156.1.12.1.1.5', map => \%mapping_status }, status => { oid => '.1.3.6.1.4.1.9.9.156.1.12.1.1.5', map => \%mapping_status } # ccmVMailDevStatus
}; };
my $oid_ccmVoicemailEntry = '.1.3.6.1.4.1.9.9.156.1.12.1.1'; my $oid_ccmVoicemailEntry = '.1.3.6.1.4.1.9.9.156.1.12.1.1';
sub manage_selection { sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;
my $snmp_result = $options{snmp}->get_table(oid => $oid_ccmVoicemailEntry, start => $mapping->{ccmVMailDevName}->{oid}, end => $mapping->{ccmVMailDevStatus}->{oid}, nothing_quit => 1); my $snmp_result = $options{snmp}->get_table(
oid => $oid_ccmVoicemailEntry,
start => $mapping->{display}->{oid},
end => $mapping->{status}->{oid},
nothing_quit => 1
);
$self->{phone} = {}; $self->{phone} = {};
$self->{global} = { unknown => 0, registered => 0, unregistered => 0, rejected => 0, partiallyregistered => 0 }; $self->{global} = { unknown => 0, registered => 0, unregistered => 0, rejected => 0, partiallyregistered => 0 };
foreach my $oid (keys %$snmp_result) { foreach my $oid (keys %$snmp_result) {
next if ($oid !~ /^$mapping->{ccmVMailDevStatus}->{oid}\.(.*)/); next if ($oid !~ /^$mapping->{status}->{oid}\.(.*)/);
my $instance = $1; my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
$self->{phone}->{$instance} = { %$result }; $self->{phone}->{$instance} = $result;
$self->{global}->{$result->{ccmVMailDevStatus}}++; $self->{global}->{ $result->{status} }++;
} }
} }
@ -161,7 +147,7 @@ Example: --filter-counters='status'
=item B<--warning-status> =item B<--warning-status>
Set warning threshold for status (Default: ''). Set warning threshold for status.
Can used special variables like: %{status}, %{display} Can used special variables like: %{status}, %{display}
=item B<--critical-status> =item B<--critical-status>

View File

@ -30,14 +30,14 @@ sub new {
bless $self, $class; bless $self, $class;
$self->{version} = '1.0'; $self->{version} = '1.0';
%{$self->{modes}} = ( $self->{modes} = {
'ccm-usage' => 'network::cisco::callmanager::snmp::mode::ccmusage', 'ccm-usage' => 'network::cisco::callmanager::snmp::mode::ccmusage',
'cti-usage' => 'network::cisco::callmanager::snmp::mode::ctiusage', 'cti-usage' => 'network::cisco::callmanager::snmp::mode::ctiusage',
'gateway-usage' => 'network::cisco::callmanager::snmp::mode::gatewayusage', 'gateway-usage' => 'network::cisco::callmanager::snmp::mode::gatewayusage',
'mediadevice-usage' => 'network::cisco::callmanager::snmp::mode::mediadeviceusage', 'mediadevice-usage' => 'network::cisco::callmanager::snmp::mode::mediadeviceusage',
'phone-usage' => 'network::cisco::callmanager::snmp::mode::phoneusage', 'phone-usage' => 'network::cisco::callmanager::snmp::mode::phoneusage',
'voicemail-usage' => 'network::cisco::callmanager::snmp::mode::voicemailusage', 'voicemail-usage' => 'network::cisco::callmanager::snmp::mode::voicemailusage'
); };
return $self; return $self;
} }