manage v18 mibs for sophos xg (#2295)

This commit is contained in:
qgarnier 2020-10-28 11:08:08 +01:00 committed by GitHub
parent 0f57dd010f
commit 3c0110a5d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 262 additions and 188 deletions

View File

@ -23,39 +23,66 @@ package network::cyberoam::snmp::mode::components::service;
use strict;
use warnings;
my $map_status = {
my $map_v17_status = {
1 => 'untouched', 2 => 'stopped', 3 => 'initializing', 4 => 'running', 5 => 'exiting',
6 => 'dead', 7 => 'unregistered',
6 => 'dead', 7 => 'unregistered'
};
my $map_v18_status = {
0 => 'untouched', 1 => 'stopped', 2 => 'initializing', 3 => 'running',
4 => 'exiting', 5 => 'dead', 6 => 'frozen', 7 => 'unregistered'
};
my $mapping = {
pop3Service => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.1', map => $map_status, type => 'pop3' },
imap4Service => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.2', map => $map_status, type => 'imap4' },
smtpService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.3', map => $map_status, type => 'smtp' },
ftpService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.4', map => $map_status, type => 'ftp' },
httpService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.5', map => $map_status, type => 'http' },
avService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.6', map => $map_status, type => 'av' },
asService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.7', map => $map_status, type => 'as' },
dnsService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.8', map => $map_status, type => 'dns' },
haService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.9', map => $map_status, type => 'ha' },
idpService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.10', map => $map_status, type => 'idp' },
apacheService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.11', map => $map_status, type => 'apache' },
ntpService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.12', map => $map_status, type => 'ntp' },
tomcatService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.13', map => $map_status, type => 'tomcat' },
sslvpnService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.14', map => $map_status, type => 'sslvpn' },
DataBaseService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.15', map => $map_status, type => 'database' },
networkService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.16', map => $map_status, type => 'network' },
garnerService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.17', map => $map_status, type => 'garner' },
droutingService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.18', map => $map_status, type => 'drouting' },
sshdService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.19', map => $map_status, type => 'sshd' },
dgdService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.20', map => $map_status, type => 'dgd' },
pop3Service => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.1', map => $map_v17_status, type => 'pop3' },
imap4Service => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.2', map => $map_v17_status, type => 'imap4' },
smtpService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.3', map => $map_v17_status, type => 'smtp' },
ftpService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.4', map => $map_v17_status, type => 'ftp' },
httpService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.5', map => $map_v17_status, type => 'http' },
avService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.6', map => $map_v17_status, type => 'av' },
asService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.7', map => $map_v17_status, type => 'as' },
dnsService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.8', map => $map_v17_status, type => 'dns' },
haService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.9', map => $map_v17_status, type => 'ha' },
idpService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.10', map => $map_v17_status, type => 'idp' },
apacheService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.11', map => $map_v17_status, type => 'apache' },
ntpService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.12', map => $map_v17_status, type => 'ntp' },
tomcatService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.13', map => $map_v17_status, type => 'tomcat' },
sslvpnService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.14', map => $map_v17_status, type => 'sslvpn' },
DataBaseService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.15', map => $map_v17_status, type => 'database' },
networkService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.16', map => $map_v17_status, type => 'network' },
garnerService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.17', map => $map_v17_status, type => 'garner' },
droutingService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.18', map => $map_v17_status, type => 'drouting' },
sshdService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.19', map => $map_v17_status, type => 'sshd' },
dgdService => { oid => '.1.3.6.1.4.1.21067.2.1.2.10.20', map => $map_v17_status, type => 'dgd' },
sfosPoP3Service => { oid => '.1.3.6.1.4.1.2604.5.1.3.1', map => $map_v18_status, type => 'pop3' },
sfosImap4Service => { oid => '.1.3.6.1.4.1.2604.5.1.3.2', map => $map_v18_status, type => 'imap4' },
sfosSmtpService => { oid => '.1.3.6.1.4.1.2604.5.1.3.3', map => $map_v18_status, type => 'smtp' },
sfosFtpService => { oid => '.1.3.6.1.4.1.2604.5.1.3.4', map => $map_v18_status, type => 'ftp' },
sfosHttpService => { oid => '.1.3.6.1.4.1.2604.5.1.3.5', map => $map_v18_status, type => 'http' },
sfosAVService => { oid => '.1.3.6.1.4.1.2604.5.1.3.6', map => $map_v18_status, type => 'av' },
sfosASService => { oid => '.1.3.6.1.4.1.2604.5.1.3.7', map => $map_v18_status, type => 'as' },
sfosDNSService => { oid => '.1.3.6.1.4.1.2604.5.1.3.8', map => $map_v18_status, type => 'dns' },
sfosHAService => { oid => '.1.3.6.1.4.1.2604.5.1.3.9', map => $map_v18_status, type => 'ha' },
sfosIPSService => { oid => '.1.3.6.1.4.1.2604.5.1.3.10', map => $map_v18_status, type => 'ips' },
sfosApacheService => { oid => '.1.3.6.1.4.1.2604.5.1.3.11', map => $map_v18_status, type => 'apache' },
sfosNtpService => { oid => '.1.3.6.1.4.1.2604.5.1.3.12', map => $map_v18_status, type => 'ntp' },
sfosTomcatService => { oid => '.1.3.6.1.4.1.2604.5.1.3.13', map => $map_v18_status, type => 'tomcat' },
sfosSSLVpnService => { oid => '.1.3.6.1.4.1.2604.5.1.3.14', map => $map_v18_status, type => 'sslvpn' },
sfosIPSecVpnService => { oid => '.1.3.6.1.4.1.2604.5.1.3.15', map => $map_v18_status, type => 'ipsecvpn' },
sfosDatabaseservice => { oid => '.1.3.6.1.4.1.2604.5.1.3.16', map => $map_v18_status, type => 'database' },
sfosNetworkService => { oid => '.1.3.6.1.4.1.2604.5.1.3.17', map => $map_v18_status, type => 'network' },
sfosGarnerService => { oid => '.1.3.6.1.4.1.2604.5.1.3.18', map => $map_v18_status, type => 'garner' },
sfosDroutingService => { oid => '.1.3.6.1.4.1.2604.5.1.3.19', map => $map_v18_status, type => 'drouting' },
sfosSSHdService => { oid => '.1.3.6.1.4.1.2604.5.1.3.20', map => $map_v18_status, type => 'sshd' },
sfosDgdService => { oid => '.1.3.6.1.4.1.2604.5.1.3.21', map => $map_v18_status, type => 'dgd' }
};
my $oid_serviceStats = '.1.3.6.1.4.1.21067.2.1.2.10';
my $oid_sfosXGServiceStatus = '.1.3.6.1.4.1.2604.5.1.3';
sub load {
my ($self) = @_;
push @{$self->{request}}, { oid => $oid_serviceStats };
push @{$self->{request}}, { oid => $oid_serviceStats }, { oid => $oid_sfosXGServiceStatus };
}
sub check {
@ -65,9 +92,9 @@ sub check {
$self->{components}->{service} = {name => 'services', total => 0, skip => 0};
return if ($self->check_filter(section => 'service'));
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_serviceStats}, instance => '0');
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => 0);
foreach (keys %{$mapping}) {
foreach (keys %$mapping) {
next if (!defined($result->{$_}));
next if ($self->check_filter(section => 'service', instance => $mapping->{$_}->{type}));

View File

@ -29,12 +29,11 @@ sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' },
});
$options{options}->add_options(arguments => {
'warning:s' => { name => 'warning' },
'critical:s' => { name => 'critical' }
});
return $self;
}
@ -64,12 +63,14 @@ sub run {
threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("CPU Usage : %.2f %%", $result->{$oid_cpuPercentUsage}));
$self->{output}->perfdata_add(label => "cpu", unit => '%',
value => sprintf("%.2f", $result->{$oid_cpuPercentUsage}),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
min => 0);
$self->{output}->perfdata_add(
label => "cpu", unit => '%',
value => sprintf("%.2f", $result->{$oid_cpuPercentUsage}),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
min => 0
);
$self->{output}->display();
$self->{output}->exit();
}
@ -95,4 +96,4 @@ Threshold critical.
=back
=cut

View File

@ -28,18 +28,13 @@ use warnings;
sub custom_usage_perfdata {
my ($self, %options) = @_;
$self->{output}->perfdata_add(label => $self->{result_values}->{label} . '_used', unit => 'B',
value => $self->{result_values}->{used},
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, total => $self->{result_values}->{total}, cast_int => 1),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, total => $self->{result_values}->{total}, cast_int => 1),
min => 0, max => $self->{result_values}->{total});
}
sub custom_usage_threshold {
my ($self, %options) = @_;
my $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{prct_used}, threshold => [ { label => 'critical-' . $self->{result_values}->{label} . '-usage', exit_litteral => 'critical' }, { label => 'warning-' . $self->{result_values}->{label} . '-usage', exit_litteral => 'warning' } ]);
return $exit;
$self->{output}->perfdata_add(
label => $self->{result_values}->{label} . '_used', unit => 'B',
value => $self->{result_values}->{used},
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, total => $self->{result_values}->{total}, cast_int => 1),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, total => $self->{result_values}->{total}, cast_int => 1),
min => 0, max => $self->{result_values}->{total}
);
}
sub custom_usage_output {
@ -49,11 +44,12 @@ sub custom_usage_output {
my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used});
my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free});
my $msg = sprintf("Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
$total_size_value . " " . $total_size_unit,
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used},
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free});
return $msg;
return sprintf(
"Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
$total_size_value . " " . $total_size_unit,
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used},
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free}
);
}
sub custom_usage_calc {
@ -68,6 +64,18 @@ sub custom_usage_calc {
return 0;
}
sub prefix_memory_output {
my ($self, %options) = @_;
return "Physical memory ";
}
sub prefix_swap_output {
my ($self, %options) = @_;
return "Swap memory ";
}
sub set_counters {
my ($self, %options) = @_;
@ -82,68 +90,77 @@ sub set_counters {
closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_calc_extra_options => { label_ref => 'physical' },
closure_custom_output => $self->can('custom_usage_output'),
closure_custom_perfdata => $self->can('custom_usage_perfdata'),
closure_custom_threshold_check => $self->can('custom_usage_threshold'),
threshold_use => 'prct_used'
}
},
}
];
$self->{maps_counters}->{swap} = [
{ label => 'swap-usage', set => {
key_values => [ { name => 'free' }, { name => 'used' } ],
closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_calc_extra_options => { label_ref => 'swap' },
closure_custom_output => $self->can('custom_usage_output'),
closure_custom_perfdata => $self->can('custom_usage_perfdata'),
closure_custom_threshold_check => $self->can('custom_usage_threshold'),
threshold_use => 'prct_used'
}
},
}
];
}
sub prefix_memory_output {
my ($self, %options) = @_;
return "Physical memory ";
}
sub prefix_swap_output {
my ($self, %options) = @_;
return "Swap memory ";
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"filter-counters:s" => { name => 'filter_counters' },
});
$options{options}->add_options(arguments => {});
return $self;
}
sub add_counters {
my ($self, %options) = @_;
return if (!defined($options{result}->{memory_total}));
my $memory_used = $options{result}->{memory_used_prct} * $options{result}->{memory_total} * 1024 * 1024 / 100;
my $swap_used = $options{result}->{swap_used_prct} * $options{result}->{swap_total} * 1024 * 1024 / 100;
$self->{memory} = {
free => $options{result}->{memory_total} * 1024 * 1024 - $memory_used,
used => $memory_used
};
$self->{swap} = {
free => $options{result}->{swap_total} * 1024 * 1024 - $swap_used,
used => $swap_used
};
}
sub manage_selection {
my ($self, %options) = @_;
my $oid_memoryCapacity = '.1.3.6.1.4.1.21067.2.1.2.4.1.0'; # in MB
my $oid_memoryPercentUsage = '.1.3.6.1.4.1.21067.2.1.2.4.2.0';
my $oid_swapCapacity = '.1.3.6.1.4.1.21067.2.1.2.4.3.0'; # in MB
my $oid_swapPercentUsage = '.1.3.6.1.4.1.21067.2.1.2.4.4.0';
my $result = $options{snmp}->get_leef(oids => [$oid_memoryCapacity, $oid_memoryPercentUsage,
$oid_swapCapacity, $oid_swapPercentUsage],
nothing_quit => 1);
my $memory_used = $result->{$oid_memoryPercentUsage} * $result->{$oid_memoryCapacity} * 1024 * 1024 / 100;
my $swap_used = $result->{$oid_swapPercentUsage} * $result->{$oid_swapCapacity} * 1024 * 1024 / 100;
$self->{memory} = {
free => $result->{$oid_memoryCapacity} * 1024 * 1024 - $memory_used,
used => $memory_used,
};
$self->{swap} = {
free => $result->{$oid_swapCapacity} * 1024 * 1024 - $swap_used,
used => $swap_used,
my $mapping = {
v17 => {
memory_total => { oid => '.1.3.6.1.4.1.21067.2.1.2.4.1' }, # memoryCapacity - MB
memory_used_prct => { oid => '.1.3.6.1.4.1.21067.2.1.2.4.2' }, # memoryPercentUsage
swap_total => { oid => '.1.3.6.1.4.1.21067.2.1.2.4.3' }, # swapCapacity - MB
swap_used_prct => { oid => '.1.3.6.1.4.1.21067.2.1.2.4.4' } # swapPercentUsage
},
v18 => {
memory_total => { oid => '.1.3.6.1.4.1.2604.5.1.2.5.1' }, # sfosMemoryCapacity - MB
memory_used_prct => { oid => '.1.3.6.1.4.1.2604.5.1.2.5.2' }, # sfosMemoryPercentUsage
swap_total => { oid => '.1.3.6.1.4.1.2604.5.1.2.5.3' }, # sfosSwapCapacity - MB
swap_used_prct => { oid => '.1.3.6.1.4.1.2604.5.1.2.5.4' } # sfosSwapPercentUsage
}
};
my $snmp_result = $options{snmp}->get_leef(
oids => [ map($_->{oid} . '.0', values(%{$mapping->{v17}}), values(%{$mapping->{v18}})) ],
nothing_quit => 1
);
my $result = $options{snmp}->map_instance(mapping => $mapping->{v17}, results => $snmp_result, instance => 0);
$self->add_counters(result => $result);
$result = $options{snmp}->map_instance(mapping => $mapping->{v18}, results => $snmp_result, instance => 0);
$self->add_counters(result => $result);
}
1;
@ -161,14 +178,9 @@ Check memory usages.
Only display some counters (regexp can be used).
Example : --filter-counters='^physical-usage$'
=item B<--warning-*>
=item B<--warning-*> B<--critical-*>
Threshold warning.
Can be: 'physical-usage' (%), 'swap-usage' (%).
=item B<--critical-*>
Threshold critical.
Thresholds.
Can be: 'physical-usage' (%), 'swap-usage' (%).
=back

View File

@ -30,64 +30,65 @@ sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0, cb_prefix_output => 'prefix_output' },
{ name => 'global', type => 0, cb_prefix_output => 'prefix_output' }
];
$self->{maps_counters}->{global} = [
{ label => 'live-users', set => {
key_values => [ { name => 'live_users' } ],
output_template => 'live users = %s',
output_template => 'live users: %s',
perfdatas => [
{ label => 'live_users', value => 'live_users', template => '%s', min => 0 },
],
{ label => 'live_users', template => '%s', min => 0 }
]
}
},
{ label => 'http-hits', set => {
key_values => [ { name => 'http_hits', diff => 1 } ],
output_template => 'http hits = %s',
output_template => 'http hits: %s',
perfdatas => [
{ label => 'http_hits', value => 'http_hits', template => '%s', min => 0 },
],
{ label => 'http_hits', template => '%s', min => 0 }
]
}
},
{ label => 'ftp-hits', set => {
key_values => [ { name => 'ftp_hits', diff => 1 } ],
output_template => 'ftp hits = %s',
output_template => 'ftp hits: %s',
perfdatas => [
{ label => 'ftp_hits', value => 'ftp_hits', template => '%s', min => 0 },
],
{ label => 'ftp_hits', template => '%s', min => 0 }
]
}
},
{ label => 'pop3-hits', set => {
key_values => [ { name => 'pop3_hits', diff => 1 } ],
output_template => 'pop3 hits = %s',
output_template => 'pop3 hits: %s',
perfdatas => [
{ label => 'pop3_hits', value => 'pop3_hits', template => '%s', min => 0 },
],
{ label => 'pop3_hits', template => '%s', min => 0 }
]
}
},
{ label => 'imap-hits', set => {
key_values => [ { name => 'imap_hits', diff => 1 } ],
output_template => 'imap hits = %s',
output_template => 'imap hits: %s',
perfdatas => [
{ label => 'imap_hits', value => 'imap_hits', template => '%s', min => 0 },
],
{ label => 'imap_hits', template => '%s', min => 0 }
]
}
},
{ label => 'smtp-hits', set => {
key_values => [ { name => 'smtp_hits', diff => 1 } ],
output_template => 'smtp hits = %s',
output_template => 'smtp hits: %s',
perfdatas => [
{ label => 'smtp_hits', value => 'smtp_hits', template => '%s', min => 0 },
],
{ label => 'smtp_hits', template => '%s', min => 0 }
]
}
},
}
];
}
sub prefix_output {
my ($self, %options) = @_;
return "Requests: ";
return 'Requests ';
}
sub new {
@ -101,39 +102,53 @@ sub new {
return $self;
}
sub add_counters {
my ($self, %options) = @_;
return if (!defined($options{result}->{live_users}));
$self->{global} = { %{$options{result}} };
}
sub manage_selection {
my ($self, %options) = @_;
if ($options{snmp}->is_snmpv1()) {
$self->{output}->add_option_msg(short_msg => "Need to use SNMP v2c or v3.");
$self->{output}->add_option_msg(short_msg => 'Need to use SNMP v2c or v3.');
$self->{output}->option_exit();
}
my $oid_liveUsers = '.1.3.6.1.4.1.21067.2.1.2.6.0';
my $oid_httpHits = '.1.3.6.1.4.1.21067.2.1.2.7.0';
my $oid_ftpHits = '.1.3.6.1.4.1.21067.2.1.2.8.0';
my $oid_pop3Hits = '.1.3.6.1.4.1.21067.2.1.2.9.1.0';
my $oid_imapHits = '.1.3.6.1.4.1.21067.2.1.2.9.2.0';
my $oid_smtpHits = '.1.3.6.1.4.1.21067.2.1.2.9.3.0';
my $result = $options{snmp}->get_leef(
oids => [
$oid_liveUsers, $oid_httpHits, $oid_ftpHits, $oid_pop3Hits,
$oid_imapHits, $oid_smtpHits
],
my $mapping = {
v17 => {
live_users => { oid => '.1.3.6.1.4.1.21067.2.1.2.6' }, # liveUsers
http_hits => { oid => '.1.3.6.1.4.1.21067.2.1.2.7' }, # httpHits
ftp_hits => { oid => '.1.3.6.1.4.1.21067.2.1.2.8' }, # ftpHits
pop3_hits => { oid => '.1.3.6.1.4.1.21067.2.1.2.9.1' }, # pop3Hits
imap_hits => { oid => '.1.3.6.1.4.1.21067.2.1.2.9.2' }, # imapHits
smtp_hits => { oid => '.1.3.6.1.4.1.21067.2.1.2.9.3' } # smtpHits
},
v18 => {
live_users => { oid => '.1.3.6.1.4.1.2604.5.1.2.6' }, # sfosLiveUsersCount
http_hits => { oid => '.1.3.6.1.4.1.2604.5.1.2.7' }, # sfosHTTPHits
ftp_hits => { oid => '.1.3.6.1.4.1.2604.5.1.2.8' }, # sfosFTPHits
pop3_hits => { oid => '.1.3.6.1.4.1.2604.5.1.2.9.1' }, # sfosPOP3Hits
imap_hits => { oid => '.1.3.6.1.4.1.2604.5.1.2.9.2' }, # sfosImapHits
smtp_hits => { oid => '.1.3.6.1.4.1.2604.5.1.2.9.3' } # sfosSmtpHits
}
};
my $snmp_result = $options{snmp}->get_leef(
oids => [ map($_->{oid} . '.0', values(%{$mapping->{v17}}), values(%{$mapping->{v18}})) ],
nothing_quit => 1
);
$self->{cache_name} = "cyberoam_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
my $result = $options{snmp}->map_instance(mapping => $mapping->{v17}, results => $snmp_result, instance => 0);
$self->add_counters(result => $result);
$result = $options{snmp}->map_instance(mapping => $mapping->{v18}, results => $snmp_result, instance => 0);
$self->add_counters(result => $result);
$self->{global} = {
live_users => $result->{$oid_liveUsers},
http_hits => $result->{$oid_httpHits},
ftp_hits => $result->{$oid_ftpHits},
pop3_hits => $result->{$oid_pop3Hits},
imap_hits => $result->{$oid_imapHits},
smtp_hits => $result->{$oid_smtpHits}
};
$self->{cache_name} = 'cyberoam_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
}
1;
@ -151,14 +166,9 @@ Check request statistics.
Only display some counters (regexp can be used).
Example: --filter-counters='http-hits'
=item B<--warning-*>
=item B<--warning-*> B<--critical-*>
Threshold warning.
Can be: live-users, http-hits, ftp-hits, pop3-hits, imap-hits, smtp-hits.
=item B<--critical-*>
Threshold critical.
Thresholds.
Can be: live-users, http-hits, ftp-hits, pop3-hits, imap-hits, smtp-hits.
=back

View File

@ -38,7 +38,8 @@ sub set_system {
['running', 'OK'],
['exiting', 'CRITICAL'],
['dead', 'CRITICAL'],
['unregistered', 'OK']
['unregistered', 'OK'],
['frozen', 'CRITICAL']
]
};
@ -50,12 +51,15 @@ sub snmp_execute {
my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
$self->{results} = $self->{snmp}->get_multiple_table(
oids => $self->{request},
return_type => 1
);
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, no_performance => 1);
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, no_performance => 1, force_new_perfdata => 1);
bless $self, $class;
$options{options}->add_options(arguments => {});

View File

@ -28,18 +28,13 @@ use warnings;
sub custom_usage_perfdata {
my ($self, %options) = @_;
$self->{output}->perfdata_add(label => 'used', unit => 'B',
value => $self->{result_values}->{used},
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, total => $self->{result_values}->{total}, cast_int => 1),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, total => $self->{result_values}->{total}, cast_int => 1),
min => 0, max => $self->{result_values}->{total});
}
sub custom_usage_threshold {
my ($self, %options) = @_;
my $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{prct_used}, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]);
return $exit;
$self->{output}->perfdata_add(
label => 'used', unit => 'B',
value => $self->{result_values}->{used},
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, total => $self->{result_values}->{total}, cast_int => 1),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, total => $self->{result_values}->{total}, cast_int => 1),
min => 0, max => $self->{result_values}->{total}
);
}
sub custom_usage_output {
@ -49,11 +44,12 @@ sub custom_usage_output {
my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used});
my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free});
my $msg = sprintf("Storage Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
$total_size_value . " " . $total_size_unit,
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used},
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free});
return $msg;
return sprintf(
"Storage Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
$total_size_value . " " . $total_size_unit,
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used},
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free}
);
}
sub custom_usage_calc {
@ -80,9 +76,9 @@ sub set_counters {
closure_custom_calc => $self->can('custom_usage_calc'),
closure_custom_output => $self->can('custom_usage_output'),
closure_custom_perfdata => $self->can('custom_usage_perfdata'),
closure_custom_threshold_check => $self->can('custom_usage_threshold'),
threshold_use => 'prct_used'
}
},
}
];
}
@ -90,23 +86,47 @@ sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
});
$options{options}->add_options(arguments => {
});
return $self;
}
sub add_counters {
my ($self, %options) = @_;
return if (!defined($options{result}->{disk_total}));
$self->{storage} = {
used => $options{result}->{disk_used_prct} * $options{result}->{disk_total} * 1024 * 1024 / 100,
total => $options{result}->{disk_total} * 1024 * 1024
};
}
sub manage_selection {
my ($self, %options) = @_;
my $oid_diskCapacity = '.1.3.6.1.4.1.21067.2.1.2.3.1.0'; # in MB
my $oid_diskPercentUsage = '.1.3.6.1.4.1.21067.2.1.2.3.2.0';
my $result = $options{snmp}->get_leef(oids => [$oid_diskCapacity, $oid_diskPercentUsage],
nothing_quit => 1);
$self->{storage} = { used => $result->{$oid_diskPercentUsage} * $result->{$oid_diskCapacity} * 1024 * 1024 / 100,
total => $result->{$oid_diskCapacity} * 1024 * 1024 };
my $mapping = {
v17 => {
disk_total => { oid => '.1.3.6.1.4.1.21067.2.1.2.3.1' }, # diskCapacity - MB
disk_used_prct => { oid => '.1.3.6.1.4.1.21067.2.1.2.3.2' } # diskPercentUsage
},
v18 => {
disk_total => { oid => '.1.3.6.1.4.1.2604.5.1.2.4.1' }, # sfosDiskCapacity - MB
disk_used_prct => { oid => '.1.3.6.1.4.1.2604.5.1.2.4.2' } # sfosDiskPercentUsage
}
};
my $snmp_result = $options{snmp}->get_leef(
oids => [ map($_->{oid} . '.0', values(%{$mapping->{v17}}), values(%{$mapping->{v18}})) ],
nothing_quit => 1
);
my $result = $options{snmp}->map_instance(mapping => $mapping->{v17}, results => $snmp_result, instance => 0);
$self->add_counters(result => $result);
$result = $options{snmp}->map_instance(mapping => $mapping->{v18}, results => $snmp_result, instance => 0);
$self->add_counters(result => $result);
}
1;
@ -129,4 +149,4 @@ Threshold critical (in percent).
=back
=cut
=cut

View File

@ -30,15 +30,15 @@ sub new {
bless $self, $class;
$self->{version} = '0.1';
%{$self->{modes}} = (
$self->{modes} = {
'cpu' => 'network::cyberoam::snmp::mode::cpu',
'interfaces' => 'snmp_standard::mode::interfaces',
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
'memory' => 'network::cyberoam::snmp::mode::memory',
'requests' => 'network::cyberoam::snmp::mode::requests',
'services' => 'network::cyberoam::snmp::mode::services',
'storage' => 'network::cyberoam::snmp::mode::storage',
);
'storage' => 'network::cyberoam::snmp::mode::storage'
};
return $self;
}