first release
This commit is contained in:
parent
236a8b434f
commit
abcf57b235
|
@ -47,6 +47,11 @@ my %states = (
|
|||
4 => ['red', 'CRITICAL'],
|
||||
);
|
||||
|
||||
my $oid_hmLEDRSPowerSupply = '.1.3.6.1.4.1.248.14.1.1.35.1.1.0';
|
||||
my $oid_hmLEDRStandby = '.1.3.6.1.4.1.248.14.1.1.35.1.2.0';
|
||||
my $oid_hmLEDRSRedundancyManager = '.1.3.6.1.4.1.248.14.1.1.35.1.3.0';
|
||||
my $oid_hmLEDRSFault = '.1.3.6.1.4.1.248.14.1.1.35.1.4.0';
|
||||
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
|
@ -72,6 +77,9 @@ sub run {
|
|||
# $options{snmp} = snmp object
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
$self->{results} = $self->{snmp}->get_leef(oids => [$oid_hmLEDRSPowerSupply, $oid_hmLEDRStandby, $oid_hmLEDRSRedundancyManager, $oid_hmLEDRSFault],
|
||||
nothing_quit => 1);
|
||||
|
||||
$self->{led_psu} = 0;
|
||||
$self->{led_standby} = 0;
|
||||
$self->{led_redundancy} = 0;
|
||||
|
@ -96,12 +104,7 @@ sub check_led_psu {
|
|||
$self->{output}->output_add(long_msg => "Checking PSU led");
|
||||
return if ($self->check_exclude('led_psu'));
|
||||
|
||||
my $oid_hmLEDRSPowerSupply = '.1.3.6.1.4.1.248.14.1.1.35.1.1';
|
||||
|
||||
my $result = $self->{snmp}->get_leef(oids => [$oid_hmLEDRSPowerSupply],
|
||||
nothing_quit => 1);
|
||||
|
||||
my $led_psu_state = $result->{ $oid_hmLEDRSPowerSupply };
|
||||
my $led_psu_state = $self->{results}->{ $oid_hmLEDRSPowerSupply };
|
||||
|
||||
$self->{led_psu}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("PSU led state is %s.",
|
||||
|
@ -118,12 +121,7 @@ sub check_led_standby {
|
|||
$self->{output}->output_add(long_msg => "Checking Standby led");
|
||||
return if ($self->check_exclude('led_standby'));
|
||||
|
||||
my $oid_hmLEDRStandby = '.1.3.6.1.4.1.248.14.1.1.35.1.2';
|
||||
|
||||
my $result = $self->{snmp}->get_leef(oids => [$oid_hmLEDRStandby],
|
||||
nothing_quit => 1);
|
||||
|
||||
my $led_standby_state = $result->{ $oid_hmLEDRStandby };
|
||||
my $led_standby_state = $self->{results}->{ $oid_hmLEDRStandby };
|
||||
|
||||
$self->{led_standby}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Standby led state is %s.",
|
||||
|
@ -140,12 +138,7 @@ sub check_led_redundancy {
|
|||
$self->{output}->output_add(long_msg => "Checking Redundancy led");
|
||||
return if ($self->check_exclude('led_redundancy'));
|
||||
|
||||
my $oid_hmLEDRSRedundancyManager = '.1.3.6.1.4.1.248.14.1.1.35.1.3';
|
||||
|
||||
my $result = $self->{snmp}->get_leef(oids => [$oid_hmLEDRSRedundancyManager],
|
||||
nothing_quit => 1);
|
||||
|
||||
my $led_redundancy_state = $result->{ $oid_hmLEDRSRedundancyManager };
|
||||
my $led_redundancy_state = $self->{results}->{ $oid_hmLEDRSRedundancyManager };
|
||||
|
||||
$self->{led_redundancy}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Redundancy led state is %s.",
|
||||
|
@ -162,12 +155,7 @@ sub check_led_fault {
|
|||
$self->{output}->output_add(long_msg => "Checking Fault led");
|
||||
return if ($self->check_exclude('led_fault'));
|
||||
|
||||
my $oid_hmLEDRSFault = '.1.3.6.1.4.1.248.14.1.1.35.1.4';
|
||||
|
||||
my $result = $self->{snmp}->get_leef(oids => [$oid_hmLEDRSFault],
|
||||
nothing_quit => 1);
|
||||
|
||||
my $led_fault_state = $result->{ $oid_hmLEDRSFault };
|
||||
my $led_fault_state = $self->{results}->{ $oid_hmLEDRSFault };
|
||||
|
||||
$self->{led_fault}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Fault led state is %s.",
|
||||
|
|
|
@ -73,7 +73,7 @@ sub run {
|
|||
# $options{snmp} = snmp object
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
my $oid_hmCpuUtilization = '.1.3.6.1.4.1.248.14.2.15.2.1'; # in %
|
||||
my $oid_hmCpuUtilization = '.1.3.6.1.4.1.248.14.2.15.2.1.0'; # in %
|
||||
|
||||
my $result = $self->{snmp}->get_leef(oids => [$oid_hmCpuUtilization],
|
||||
nothing_quit => 1);
|
||||
|
@ -85,7 +85,7 @@ sub run {
|
|||
short_msg => sprintf("CPU Usage is %d%%", $cpu));
|
||||
|
||||
$self->{output}->perfdata_add(label => "cpu", unit => '%',
|
||||
value => $temp,
|
||||
value => $cpu,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
|
||||
min =>0, max => 100);
|
||||
|
@ -101,6 +101,7 @@ __END__
|
|||
=head1 MODE
|
||||
|
||||
Check CPU usage.
|
||||
hmEnableMeasurement must be activated (value = 1).
|
||||
|
||||
=over 8
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ my %psu_states = (
|
|||
2 => ['failed', 'CRITICAL'],
|
||||
3 => ['notInstalled', 'UNKNOWN'],
|
||||
4 => ['unknown', 'UNKNOWN'],
|
||||
)
|
||||
);
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
|
@ -63,6 +63,7 @@ sub new {
|
|||
"exclude:s" => { name => 'exclude' },
|
||||
});
|
||||
|
||||
$self->{components} = {};
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
@ -76,17 +77,15 @@ sub run {
|
|||
# $options{snmp} = snmp object
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
$self->{components_fans} = 0;
|
||||
$self->{components_psus} = 0;
|
||||
$self->{components}->{fan} = {name => 'fans', total => 0, skip => 0};
|
||||
|
||||
$self->get_type();
|
||||
$self->check_fans();
|
||||
$self->check_psus();
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => sprintf("All %d components [%d fans, %d power supplies] are ok",
|
||||
($self->{components_fans} + $self->{components_psus}),
|
||||
$self->{components_fans}, $self->{components_psus}));
|
||||
($self->{components}->{psu}->{total} + $self->{components}->{fan}->{total}),
|
||||
$self->{components}->{fan}->{total}, $self->{components}->{psu}->{total}));
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
|
@ -96,7 +95,7 @@ sub check_fans {
|
|||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking fans");
|
||||
return if ($self->check_exclude('fans'));
|
||||
return if ($self->check_exclude(section => 'fan'));
|
||||
|
||||
my $oid_hmFanTable = '.1.3.6.1.4.1.248.14.1.3';
|
||||
my $oid_hmFanState = '.1.3.6.1.4.1.248.14.1.3.1.3';
|
||||
|
@ -110,12 +109,14 @@ sub check_fans {
|
|||
my $fan_id = $1;
|
||||
my $instance = $2;
|
||||
|
||||
my $psu_state = $result->{ $oid_hmFanState. '.' . $fan_id};
|
||||
my $fan_state = $result->{ $oid_hmFanState. '.' . $fan_id};
|
||||
|
||||
$self->{components_fans}++;
|
||||
next if ($self->check_exclude(section => 'fan', instance => $instance));
|
||||
|
||||
$self->{components}->{fan}->{total}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Fan '%s' state is %s.",
|
||||
$instance, ${$fan_states{$fan_state}}[0]));
|
||||
if (${$states{$fan_state}}[1] ne 'OK') {
|
||||
if (${$fan_states{$fan_state}}[1] ne 'OK') {
|
||||
$self->{output}->output_add(severity => ${$fan_states{$fan_state}}[1],
|
||||
short_msg => sprintf("Fan '%s' state is %s.", $instance, ${$fan_states{$fan_state}}[0]));
|
||||
}
|
||||
|
@ -126,7 +127,7 @@ sub check_psus {
|
|||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking power supplies");
|
||||
return if ($self->check_exclude('psu'));
|
||||
return if ($self->check_exclude(section => 'psu'));
|
||||
|
||||
my $oid_hmPSTable = '.1.3.6.1.4.1.248.14.1.2';
|
||||
my $oid_hmPSState = '.1.3.6.1.4.1.248.14.1.2.1.3';
|
||||
|
@ -142,7 +143,9 @@ sub check_psus {
|
|||
|
||||
my $psu_state = $result->{ $oid_hmPSState. '.' . $psu_id};
|
||||
|
||||
$self->{components_psus}++;
|
||||
next if ($self->check_exclude(section => 'psu', instance => $instance));
|
||||
|
||||
$self->{components}->{psu}->{total}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Power Supply '%s' state is %s.",
|
||||
$instance, ${$psu_states{$psu_state}}[0]));
|
||||
if (${$psu_states{$psu_state}}[1] ne 'OK') {
|
||||
|
@ -152,16 +155,34 @@ sub check_psus {
|
|||
}
|
||||
}
|
||||
|
||||
sub check_exclude {
|
||||
my ($self, $section) = @_;
|
||||
#sub check_exclude {
|
||||
# my ($self, $section) = @_;
|
||||
#
|
||||
# if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$section(\s|,|$)/) {
|
||||
# $self->{output}->output_add(long_msg => sprintf("Skipping $section section."));
|
||||
# return 1;
|
||||
# }
|
||||
# return 0;
|
||||
#}
|
||||
|
||||
if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$section(\s|,|$)/) {
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping $section section."));
|
||||
sub check_exclude {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
if (defined($options{instance})) {
|
||||
if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) {
|
||||
$self->{components}->{$options{section}}->{skip}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance."));
|
||||
return 1;
|
||||
}
|
||||
} elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) {
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section."));
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
@ -174,7 +195,8 @@ Check Environment monitor (Fans, Power Supplies).
|
|||
|
||||
=item B<--exclude>
|
||||
|
||||
Exclude some parts (comma seperated list) (Example: --exclude=psu).
|
||||
Exclude some parts (comma seperated list) (Example: --exclude=psu)
|
||||
Can also exclude specific instance: --exclude='psu#3.3#'
|
||||
|
||||
=back
|
||||
|
||||
|
|
|
@ -73,15 +73,15 @@ sub run {
|
|||
# $options{snmp} = snmp object
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
my $oid_hmMemoryFree = '.1.3.6.1.4.1.248.14.2.15.3.2'; # in KBytes
|
||||
my $oid_hmMemoryAllocated = '1.3.6.1.4.1.248.14.2.15.3.1' # in KBytes
|
||||
my $oid_hmMemoryFree = '.1.3.6.1.4.1.248.14.2.15.3.2.0'; # in KBytes
|
||||
my $oid_hmMemoryAllocated = '.1.3.6.1.4.1.248.14.2.15.3.1.0'; # in KBytes
|
||||
|
||||
my $oids = [$oid_hmMemoryFree, $oid_hmMemoryAllocated];
|
||||
|
||||
my $result = $self->{snmp}->get_leef(oids => [$oids],
|
||||
my $result = $self->{snmp}->get_leef(oids => $oids,
|
||||
nothing_quit => 1);
|
||||
my $mem_free = $result->{$oid_hmMemoryFree};
|
||||
my $mem_allocated = $result->{$oid_hmMemoryAllocated};
|
||||
my $mem_free = $result->{$oid_hmMemoryFree} * 1024;
|
||||
my $mem_allocated = $result->{$oid_hmMemoryAllocated} * 1024;
|
||||
|
||||
my $mem_total = $mem_allocated + $mem_free;
|
||||
|
||||
|
@ -91,17 +91,15 @@ sub run {
|
|||
|
||||
my ($mem_allocated_value, $mem_allocated_unit) = $self->{perfdata}->change_bytes(value => $mem_allocated);
|
||||
|
||||
|
||||
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Memory used %s (%.2f%%)",
|
||||
$mem_allocated_value . " " . $mem_allocated_unit, $mem_percent_used));
|
||||
|
||||
$self->{output}->perfdata_add(label => "used", unit => 'B',
|
||||
value => $mem_allocated_value,
|
||||
value => $mem_allocated,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $mem_total, cast_int => 1),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical' total => $mem_total, cast_int => 1),
|
||||
min => 0, max => $mem_total);
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $mem_total, cast_int => 1),
|
||||
min => 0, max => $mem_total,
|
||||
);
|
||||
|
||||
$self->{output}->display();
|
||||
|
@ -115,6 +113,7 @@ __END__
|
|||
=head1 MODE
|
||||
|
||||
Check Memory usage.
|
||||
hmEnableMeasurement must be activated (value = 1).
|
||||
|
||||
=over 8
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ sub run {
|
|||
# $options{snmp} = snmp object
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
my $oid_hmCpuRunningProcesses = '.1.3.6.1.4.1.248.14.2.15.2.3';
|
||||
my $oid_hmCpuRunningProcesses = '.1.3.6.1.4.1.248.14.2.15.2.3.0';
|
||||
|
||||
my $result = $self->{snmp}->get_leef(oids => [$oid_hmCpuRunningProcesses],
|
||||
nothing_quit => 1);
|
||||
|
@ -85,7 +85,7 @@ sub run {
|
|||
short_msg => sprintf("Number of current processes running: %d", $processcount));
|
||||
|
||||
$self->{output}->perfdata_add(label => "nbproc",
|
||||
value => $temp,
|
||||
value => $processcount,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
|
||||
min => 0);
|
||||
|
@ -101,6 +101,7 @@ __END__
|
|||
=head1 MODE
|
||||
|
||||
Check number of processes.
|
||||
hmEnableMeasurement must be activated (value = 1).
|
||||
|
||||
=over 8
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#
|
||||
####################################################################################
|
||||
|
||||
package network::hirschmann::mode::common::temperature;
|
||||
package network::hirschmann::common::mode::temperature;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
|
@ -73,7 +73,7 @@ sub run {
|
|||
# $options{snmp} = snmp object
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
my $oid_hmTemperature = '.1.3.6.1.4.1.248.14.2.5.1'; # in Celsius
|
||||
my $oid_hmTemperature = '.1.3.6.1.4.1.248.14.2.5.1.0'; # in Celsius
|
||||
|
||||
my $result = $self->{snmp}->get_leef(oids => [$oid_hmTemperature],
|
||||
nothing_quit => 1);
|
||||
|
|
|
@ -52,6 +52,7 @@ sub new {
|
|||
'led' => 'network::hirschmann::RS::mode::led',
|
||||
'memory' => 'network::hirschmann::common::mode::memory',
|
||||
'processcount' => 'network::hirschmann::common::mode::processcount',
|
||||
'temperature' => 'network::hirschmann::common::mode::temperature',
|
||||
'traffic' => 'snmp_standard::mode::traffic',
|
||||
);
|
||||
|
||||
|
@ -65,6 +66,5 @@ __END__
|
|||
=head1 PLUGIN DESCRIPTION
|
||||
|
||||
Check Hirschmann in SNMP (HMPRIV-MGMT-SNMP-MIB).
|
||||
hmEnableMeasurement must be activated (value = 1).
|
||||
|
||||
=cut
|
||||
|
|
Loading…
Reference in New Issue