This commit is contained in:
garnier-quentin 2013-12-15 22:53:23 +01:00
parent 6b9bd382d8
commit 577ee23fb9
9 changed files with 25 additions and 11 deletions

View File

@ -591,6 +591,12 @@ sub get_hostname {
return $host;
}
sub get_port {
my ($self) = @_;
return $self->{snmp_params}->{RemotePort};
}
sub oid_lex_sort {
my $self = shift;

View File

@ -88,13 +88,14 @@ sub run {
# $options{snmp} = snmp object
$self->{snmp} = $options{snmp};
$self->{hostname} = $self->{snmp}->get_hostname();
$self->{snmp_port} = $self->{snmp}->get_port();
if ($self->{snmp}->is_snmpv1()) {
$self->{output}->add_option_msg(short_msg => "Need to use SNMP v2c or v3.");
$self->{output}->option_exit();
}
$self->{statefile_value}->read(statefile => 'bluecoat_' . $self->{hostname} . '_' . $self->{mode});
$self->{statefile_value}->read(statefile => 'bluecoat_' . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode});
my $result = $self->{snmp}->get_leef(oids => ['.1.3.6.1.4.1.3417.2.11.3.1.1.1.0',
'.1.3.6.1.4.1.3417.2.11.3.1.1.2.0',
'.1.3.6.1.4.1.3417.2.11.3.1.1.3.0',

View File

@ -88,13 +88,14 @@ sub run {
# $options{snmp} = snmp object
$self->{snmp} = $options{snmp};
$self->{hostname} = $self->{snmp}->get_hostname();
$self->{snmp_port} = $self->{snmp}->get_port();
if ($self->{snmp}->is_snmpv1()) {
$self->{output}->add_option_msg(short_msg => "Need to use SNMP v2c or v3.");
$self->{output}->option_exit();
}
$self->{statefile_value}->read(statefile => 'bluecoat_' . $self->{hostname} . '_' . $self->{mode});
$self->{statefile_value}->read(statefile => 'bluecoat_' . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode});
my $result = $self->{snmp}->get_leef(oids => ['.1.3.6.1.4.1.3417.2.11.3.1.1.9.0',
'.1.3.6.1.4.1.3417.2.11.3.1.1.10.0'], nothing_quit => 1);

View File

@ -78,6 +78,7 @@ sub run {
# $options{snmp} = snmp object
$self->{snmp} = $options{snmp};
$self->{hostname} = $self->{snmp}->get_hostname();
$self->{snmp_port} = $self->{snmp}->get_port();
if ($self->{snmp}->is_snmpv1()) {
$self->{output}->add_option_msg(short_msg => "Need to use SNMP v2c or v3.");
@ -87,7 +88,7 @@ sub run {
my $new_datas = {};
my $old_timestamp = undef;
$self->{statefile_value}->read(statefile => 'bluecoat_' . $self->{hostname} . '_' . $self->{mode});
$self->{statefile_value}->read(statefile => 'bluecoat_' . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode});
my $result = $self->{snmp}->get_table(oid => '.1.3.6.1.4.1.3417.2.11.2.4.1', nothing_quit => 1);
$old_timestamp = $self->{statefile_value}->get(name => 'last_timestamp');

View File

@ -98,6 +98,7 @@ sub run {
my ($self, %options) = @_;
# $options{snmp} = snmp object
$self->{snmp} = $options{snmp};
$self->{snmp_port} = $self->{snmp}->get_port();
if ($self->{snmp}->is_snmpv1()) {
$self->{output}->add_option_msg(short_msg => "Need to use SNMP v2c or v3.");
@ -113,7 +114,7 @@ sub run {
my $oid_diskIONWrittenX = '.1.3.6.1.4.1.2021.13.15.1.1.13'; # in B
my $new_datas = {};
$self->{statefile_value}->read(statefile => "snmpstandard_" . $self->{hostname} . '_' . $self->{mode} . '_' . (defined($self->{option_results}->{device}) ? md5_hex($self->{option_results}->{device}) : md5_hex('all')));
$self->{statefile_value}->read(statefile => "snmpstandard_" . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode} . '_' . (defined($self->{option_results}->{device}) ? md5_hex($self->{option_results}->{device}) : md5_hex('all')));
$self->{snmp}->load(oids => [$oid_diskIONReadX, $oid_diskIONWrittenX],
instances => $self->{device_id_selected});
@ -229,7 +230,7 @@ sub manage_selection {
my ($self, %options) = @_;
# init cache file
my $has_cache_file = $self->{statefile_cache}->read(statefile => 'cache_snmpstandard_' . $self->{hostname} . '_' . $self->{mode});
my $has_cache_file = $self->{statefile_cache}->read(statefile => 'cache_snmpstandard_' . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode});
if (defined($self->{option_results}->{show_cache})) {
$self->{output}->add_option_msg(long_msg => $self->{statefile_cache}->get_string_content());
$self->{output}->option_exit();

View File

@ -103,6 +103,7 @@ sub run {
# $options{snmp} = snmp object
$self->{snmp} = $options{snmp};
$self->{hostname} = $self->{snmp}->get_hostname();
$self->{snmp_port} = $self->{snmp}->get_port();
my $result = $self->{snmp}->get_leef(oids => [$self->{option_results}->{oid}], nothing_quit => 1);
my $value = $result->{$self->{option_results}->{oid}};
@ -110,7 +111,7 @@ sub run {
if ($self->{option_results}->{oid_type} =~ /^counter$/i) {
my $datas = {};
$self->{statefile_cache}->read(statefile => "snmpstandard_" . $self->{hostname} . '_' . $self->{mode} . '_' . md5_hex($self->{option_results}->{oid}));
$self->{statefile_cache}->read(statefile => "snmpstandard_" . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode} . '_' . md5_hex($self->{option_results}->{oid}));
my $old_timestamp = $self->{statefile_cache}->get(name => 'timestamp');
my $old_value = $self->{statefile_cache}->get(name => 'value');

View File

@ -145,6 +145,7 @@ sub run {
# $options{snmp} = snmp object
$self->{snmp} = $options{snmp};
$self->{hostname} = $self->{snmp}->get_hostname();
$self->{snmp_port} = $self->{snmp}->get_port();
$self->manage_selection();
@ -174,7 +175,7 @@ sub run {
my $oid_ifOutErrors = '.1.3.6.1.2.1.2.2.1.20';
my $new_datas = {};
$self->{statefile_value}->read(statefile => "snmpstandard_" . $self->{hostname} . '_' . $self->{mode} . '_' . (defined($self->{option_results}->{interface}) ? md5_hex($self->{option_results}->{interface}) : md5_hex('all')));
$self->{statefile_value}->read(statefile => "snmpstandard_" . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode} . '_' . (defined($self->{option_results}->{interface}) ? md5_hex($self->{option_results}->{interface}) : md5_hex('all')));
foreach (@{$self->{interface_id_selected}}) {
$self->{snmp}->load(oids => [$oid_adminstatus . "." . $_, $oid_operstatus . "." . $_,
@ -384,7 +385,7 @@ sub manage_selection {
my ($self, %options) = @_;
# init cache file
my $has_cache_file = $self->{statefile_cache}->read(statefile => 'cache_snmpstandard_' . $self->{hostname} . '_' . $self->{mode});
my $has_cache_file = $self->{statefile_cache}->read(statefile => 'cache_snmpstandard_' . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode});
if (defined($self->{option_results}->{show_cache})) {
$self->{output}->add_option_msg(long_msg => $self->{statefile_cache}->get_string_content());
$self->{output}->option_exit();

View File

@ -114,6 +114,7 @@ sub run {
# $options{snmp} = snmp object
$self->{snmp} = $options{snmp};
$self->{hostname} = $self->{snmp}->get_hostname();
$self->{snmp_port} = $self->{snmp}->get_port();
$self->manage_selection();
@ -243,7 +244,7 @@ sub manage_selection {
my ($self, %options) = @_;
# init cache file
my $has_cache_file = $self->{statefile_cache}->read(statefile => 'cache_snmpstandard_' . $self->{hostname} . '_' . $self->{mode});
my $has_cache_file = $self->{statefile_cache}->read(statefile => 'cache_snmpstandard_' . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode});
if (defined($self->{option_results}->{show_cache})) {
$self->{output}->add_option_msg(long_msg => $self->{statefile_cache}->get_string_content());
$self->{output}->option_exit();

View File

@ -122,6 +122,7 @@ sub run {
# $options{snmp} = snmp object
$self->{snmp} = $options{snmp};
$self->{hostname} = $self->{snmp}->get_hostname();
$self->{snmp_port} = $self->{snmp}->get_port();
$self->manage_selection();
@ -135,7 +136,7 @@ sub run {
my $oid_out64 = '.1.3.6.1.2.1.31.1.1.1.10'; # in B
my $new_datas = {};
$self->{statefile_value}->read(statefile => "snmpstandard_" . $self->{hostname} . '_' . $self->{mode} . '_' . (defined($self->{option_results}->{interface}) ? md5_hex($self->{option_results}->{interface}) : md5_hex('all')));
$self->{statefile_value}->read(statefile => "snmpstandard_" . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode} . '_' . (defined($self->{option_results}->{interface}) ? md5_hex($self->{option_results}->{interface}) : md5_hex('all')));
foreach (@{$self->{interface_id_selected}}) {
$self->{snmp}->load(oids => [$oid_adminstatus . "." . $_, $oid_operstatus . "." . $_, $oid_in32 . "." . $_, $oid_out32 . "." . $_]);
@ -327,7 +328,7 @@ sub manage_selection {
my ($self, %options) = @_;
# init cache file
my $has_cache_file = $self->{statefile_cache}->read(statefile => 'cache_snmpstandard_' . $self->{hostname} . '_' . $self->{mode});
my $has_cache_file = $self->{statefile_cache}->read(statefile => 'cache_snmpstandard_' . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode});
if (defined($self->{option_results}->{show_cache})) {
$self->{output}->add_option_msg(long_msg => $self->{statefile_cache}->get_string_content());
$self->{output}->option_exit();