add global counters to fortigate cluster status mode

This commit is contained in:
Colin Gagnaire 2019-02-04 15:14:50 +01:00
parent 47fa3a1218
commit b909e620a9
1 changed files with 41 additions and 1 deletions

View File

@ -76,13 +76,39 @@ sub prefix_status_output {
return "Node '" . $options{instance_value}->{serial} . "' ";
}
sub prefix_global_output {
my ($self, %options) = @_;
return "Nodes ";
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' },
{ name => 'nodes', type => 1, cb_prefix_output => 'prefix_status_output', message_multiple => 'All cluster nodes status are ok' },
];
$self->{maps_counters}->{global} = [
{ label => 'synchronized', set => {
key_values => [ { name => 'synchronized' } ],
output_template => 'Synchronized: %d',
perfdatas => [
{ label => 'synchronized_nodes', value => 'synchronized_absolute', template => '%d',
min => 0 },
],
}
},
{ label => 'not-synchronized', set => {
key_values => [ { name => 'not_synchronized' } ],
output_template => 'Not Synchronized: %d',
perfdatas => [
{ label => 'not_synchronized_nodes', value => 'not_synchronized_absolute', template => '%d',
min => 0 },
],
}
},
];
$self->{maps_counters}->{nodes} = [
{ label => 'node', threshold => 0, set => {
key_values => [ { name => 'serial' }, { name => 'hostname' }, { name => 'sync_status' }, { name => 'role' } ],
@ -156,6 +182,8 @@ sub manage_selection {
$self->{results} = $options{snmp}->get_table(oid => $oid_fgHaStatsEntry,
nothing_quit => 1);
$self->{global} = { synchronized => 0, not_synchronized => 0 };
foreach my $oid (keys %{$self->{results}}) {
next if ($oid !~ /^$mapping->{fgHaStatsSerial}->{oid}\.(.*)$/);
my $instance = $1;
@ -168,6 +196,8 @@ sub manage_selection {
sync_status => $result->{fgHaStatsSyncStatus},
role => ($result->{fgHaStatsMasterSerial} eq '' || $result->{fgHaStatsMasterSerial} =~ /$result->{fgHaStatsSerial}/) ? "master" : "slave",
};
$result->{fgHaStatsSyncStatus} =~ s/ /_/;
$self->{global}->{$result->{fgHaStatsSyncStatus}}++;
}
if (scalar(keys %{$self->{nodes}}) <= 0) {
@ -186,6 +216,16 @@ Check cluster status (FORTINET-FORTIGATE-MIB).
=over 8
=item B<--warning-*>
Set warning thresholds.
Can be: 'synchronized', 'not-synchronized'
=item B<--critical-*>
Set critical thresholds.
Can be: 'synchronized', 'not-synchronized'
=item B<--warning-status>
Set warning threshold for status (Default: '').