| 1 |
# |
| 2 |
# Copyright 2024 Centreon (http://www.centreon.com/) |
| 3 |
# |
| 4 |
# Centreon is a full-fledged industry-strength solution that meets |
| 5 |
# the needs in IT infrastructure and application monitoring for |
| 6 |
# service performance. |
| 7 |
# |
| 8 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 |
# you may not use this file except in compliance with the License. |
| 10 |
# You may obtain a copy of the License at |
| 11 |
# |
| 12 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 13 |
# |
| 14 |
# Unless required by applicable law or agreed to in writing, software |
| 15 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 16 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 |
# See the License for the specific language governing permissions and |
| 18 |
# limitations under the License. |
| 19 |
# |
| 20 |
|
| 21 |
package centreon::common::fortinet::fortigate::snmp::mode::signatures; |
| 22 |
|
| 23 |
use base qw(centreon::plugins::templates::counter); |
| 24 |
|
| 25 |
use strict; |
| 26 |
use warnings; |
| 27 |
use POSIX qw(mktime floor); |
| 28 |
|
| 29 |
sub set_counters { |
| 30 |
my ($self, %options) = @_; |
| 31 |
|
| 32 |
$self->{maps_counters_type} = [ |
| 33 |
{ name => 'av', type => 0, cb_prefix_output => 'prefix_av_output' }, |
| 34 |
{ name => 'avet', type => 0, cb_prefix_output => 'prefix_avet_output' }, |
| 35 |
{ name => 'ips', type => 0, cb_prefix_output => 'prefix_ips_output' }, |
| 36 |
{ name => 'ipset', type => 0, cb_prefix_output => 'prefix_ipset_output' } |
| 37 |
]; |
| 38 |
|
| 39 |
$self->{maps_counters}->{av} = [ |
| 40 |
{ label => 'av', set => { |
| 41 |
key_values => [ { name => 'human' }, { name => 'value' } ], |
| 42 |
threshold_use => 'value', |
| 43 |
output_template => "last refresh is: '%s'", |
| 44 |
perfdatas => [ |
| 45 |
{ label => 'av_update', value => 'value', |
| 46 |
template => '%d', min => 0, unit => 's' } |
| 47 |
] |
| 48 |
} |
| 49 |
} |
| 50 |
]; |
| 51 |
|
| 52 |
$self->{maps_counters}->{avet} = [ |
| 53 |
{ label => 'avet', set => { |
| 54 |
key_values => [ { name => 'human' }, { name => 'value' } ], |
| 55 |
threshold_use => 'value', |
| 56 |
output_template => "last refresh is: '%s'", |
| 57 |
perfdatas => [ |
| 58 |
{ label => 'avet_update', value => 'value', |
| 59 |
template => '%d', min => 0, unit => 's' } |
| 60 |
] |
| 61 |
} |
| 62 |
} |
| 63 |
]; |
| 64 |
|
| 65 |
$self->{maps_counters}->{ips} = [ |
| 66 |
{ label => 'ips', set => { |
| 67 |
key_values => [ { name => 'human' }, { name => 'value' } ], |
| 68 |
threshold_use => 'value', |
| 69 |
output_template => "last refresh is: '%s'", |
| 70 |
perfdatas => [ |
| 71 |
{ label => 'ips_update', value => 'value', |
| 72 |
template => '%d', min => 0, unit => 's' } |
| 73 |
] |
| 74 |
} |
| 75 |
} |
| 76 |
]; |
| 77 |
|
| 78 |
$self->{maps_counters}->{ipset} = [ |
| 79 |
{ label => 'ipset', set => { |
| 80 |
key_values => [ { name => 'human' }, { name => 'value' } ], |
| 81 |
threshold_use => 'value', |
| 82 |
output_template => "last refresh is: '%s'", |
| 83 |
perfdatas => [ |
| 84 |
{ label => 'ipset_update', value => 'value', |
| 85 |
template => '%d', min => 0, unit => 's' } |
| 86 |
] |
| 87 |
} |
| 88 |
} |
| 89 |
]; |
| 90 |
} |
| 91 |
|
| 92 |
sub prefix_av_output { |
| 93 |
my ($self, %options) = @_; |
| 94 |
|
| 95 |
return 'AV Signature '; |
| 96 |
} |
| 97 |
|
| 98 |
sub prefix_avet_output { |
| 99 |
my ($self, %options) = @_; |
| 100 |
|
| 101 |
return 'AV Extended Signature '; |
| 102 |
} |
| 103 |
|
| 104 |
sub prefix_ips_output { |
| 105 |
my ($self, %options) = @_; |
| 106 |
|
| 107 |
return 'IPS Signature '; |
| 108 |
} |
| 109 |
|
| 110 |
sub prefix_ipset_output { |
| 111 |
my ($self, %options) = @_; |
| 112 |
|
| 113 |
return 'IPS Extended Signature '; |
| 114 |
} |
| 115 |
|
| 116 |
sub new { |
| 117 |
my ($class, %options) = @_; |
| 118 |
my $self = $class->SUPER::new(package => __PACKAGE__, %options); |
| 119 |
bless $self, $class; |
| 120 |
|
| 121 |
$options{options}->add_options(arguments => { |
| 122 |
}); |
| 123 |
|
| 124 |
return $self; |
| 125 |
} |
| 126 |
|
| 127 |
sub get_epoch_from_signature { |
| 128 |
my ($self, %options) = @_; |
| 129 |
$options{date} =~ /\((\d{4})-(\d{2})-(\d{2})\s(\d{2}):(\d{2})\)/; |
| 130 |
my ($YYYY,$MM,$DD,$hh,$mm)=($1,$2,$3,$4,$5); |
| 131 |
return mktime (0, $mm, $hh, $DD, $MM - 1, $YYYY - 1900); |
| 132 |
} |
| 133 |
|
| 134 |
sub manage_selection { |
| 135 |
my ($self, %options) = @_; |
| 136 |
|
| 137 |
my $oid_fgSysVersionAv = '.1.3.6.1.4.1.12356.101.4.2.1.0'; |
| 138 |
my $oid_fgSysVersionIps = '.1.3.6.1.4.1.12356.101.4.2.2.0'; |
| 139 |
my $oid_fgSysVersionAvEt = '.1.3.6.1.4.1.12356.101.4.2.3.0'; |
| 140 |
my $oid_fgSysVersionIpsEt = '.1.3.6.1.4.1.12356.101.4.2.4.0'; |
| 141 |
|
| 142 |
my $result = $options{snmp}->get_leef(oids => [$oid_fgSysVersionAv, $oid_fgSysVersionIps, $oid_fgSysVersionAvEt, $oid_fgSysVersionIpsEt], nothing_quit => 1); |
| 143 |
|
| 144 |
my $av_epoch = $self->get_epoch_from_signature(date => $result->{$oid_fgSysVersionAv}); |
| 145 |
my $ips_epoch = $self->get_epoch_from_signature(date => $result->{$oid_fgSysVersionIps}); |
| 146 |
my $avet_epoch = $self->get_epoch_from_signature(date => $result->{$oid_fgSysVersionAvEt}); |
| 147 |
my $ipset_epoch = $self->get_epoch_from_signature(date => $result->{$oid_fgSysVersionIpsEt}); |
| 148 |
|
| 149 |
my $now = time(); |
| 150 |
|
| 151 |
my $av_diff = $now - $av_epoch; |
| 152 |
my $ips_diff = $now - $ips_epoch; |
| 153 |
my $avet_diff = $now - $avet_epoch; |
| 154 |
my $ipset_diff = $now - $ipset_epoch; |
| 155 |
|
| 156 |
$self->{av} = { |
| 157 |
human => centreon::plugins::misc::change_seconds(value => $av_diff, start => 'h'), |
| 158 |
value => $av_diff |
| 159 |
}; |
| 160 |
$self->{ips} = { |
| 161 |
human => centreon::plugins::misc::change_seconds(value => $ips_diff, start => 'h'), |
| 162 |
value => $ips_diff |
| 163 |
}; |
| 164 |
$self->{avet} = { |
| 165 |
human => centreon::plugins::misc::change_seconds(value => $avet_diff, start => 'h'), |
| 166 |
value => $avet_diff |
| 167 |
}; |
| 168 |
$self->{ipset} = { |
| 169 |
human => centreon::plugins::misc::change_seconds(value => $ipset_diff, start => 'h'), |
| 170 |
value => $ipset_diff |
| 171 |
}; |
| 172 |
} |
| 173 |
|
| 174 |
1; |
| 175 |
|
| 176 |
__END__ |
| 177 |
|
| 178 |
=head1 MODE |
| 179 |
|
| 180 |
Check last update/refresh of av and ips signatures |
| 181 |
|
| 182 |
=over 8 |
| 183 |
|
| 184 |
=item B<--filter-counters> |
| 185 |
|
| 186 |
Only display some counters (regexp can be used). |
| 187 |
Example: --filter-counters='^av$' |
| 188 |
|
| 189 |
=item B<--warning-*> B<--critical-*> |
| 190 |
|
| 191 |
Thresholds (in seconds). |
| 192 |
Can be: 'av', 'ips', 'avet', ipset'. |
| 193 |
|
| 194 |
=back |
| 195 |
|
| 196 |
=cut |