enh juniper junos hardware
This commit is contained in:
parent
24a0ab3643
commit
d278dbbbf1
|
@ -74,45 +74,54 @@ sub check {
|
|||
|
||||
my $mapping = {
|
||||
jnxFruState => { oid => '.1.3.6.1.4.1.2636.3.1.15.1.8', map => \%map_fru_states },
|
||||
jnxFruTemp => { oid => '.1.3.6.1.4.1.2636.3.1.15.1.9' },
|
||||
jnxFruOfflineReason => { oid => '.1.3.6.1.4.1.2636.3.1.15.1.10', map => \%map_fru_offline },
|
||||
};
|
||||
|
||||
my $results = $self->{snmp}->get_table(oid => $self->{oids_fru}->{jnxFruEntry}, start => $mapping->{jnxFruState}->{oid}, end => $mapping->{jnxFruOfflineReason}->{oid});
|
||||
my $results = $self->{snmp}->get_table(
|
||||
oid => $self->{oids_fru}->{jnxFruEntry},
|
||||
start => $mapping->{jnxFruState}->{oid},
|
||||
end => $mapping->{jnxFruOfflineReason}->{oid}
|
||||
);
|
||||
|
||||
foreach my $instance (sort $self->get_instances(oid_entry => $self->{oids_fru}->{jnxFruEntry}, oid_name => $self->{oids_fru}->{jnxFruName})) {
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $results, instance => $instance);
|
||||
my $name = $self->get_cache(oid_entry => $self->{oids_fru}->{jnxFruEntry}, oid_name => $self->{oids_fru}->{jnxFruName}, instance => $instance);
|
||||
foreach my $instance (sort $self->get_instances(oid_entry => $self->{oids_fru}->{jnxFruEntry},
|
||||
oid_name => $self->{oids_fru}->{jnxFruName})) {
|
||||
my $result = $self->{snmp}->map_instance(
|
||||
mapping => $mapping,
|
||||
results => $results,
|
||||
instance => $instance
|
||||
);
|
||||
my $name = $self->get_cache(
|
||||
oid_entry => $self->{oids_fru}->{jnxFruEntry},
|
||||
oid_name => $self->{oids_fru}->{jnxFruName},
|
||||
instance => $instance
|
||||
);
|
||||
|
||||
next if ($self->check_filter(section => 'fru', instance => $instance, name => $name));
|
||||
next if ($result->{jnxFruState} =~ /empty/i &&
|
||||
$self->absent_problem(section => 'fru', instance => $instance, name => $name));
|
||||
$self->{components}->{fru}->{total}++;
|
||||
|
||||
my $type = $self->get_cache(oid_entry => $self->{oids_fru}->{jnxFruEntry}, oid_name => $self->{oids_fru}->{jnxFruType}, instance => $instance);
|
||||
$self->{output}->output_add(long_msg => sprintf("fru '%s' state is %s [instance: %s, type: %s, offline reason: %s]",
|
||||
$name, $result->{jnxFruState},
|
||||
$instance, $map_fru_type{$type}, $result->{jnxFruOfflineReason}));
|
||||
my $type = $self->get_cache(
|
||||
oid_entry => $self->{oids_fru}->{jnxFruEntry},
|
||||
oid_name => $self->{oids_fru}->{jnxFruType},
|
||||
instance => $instance
|
||||
);
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf("fru '%s' state is %s [instance: %s, type: %s, offline reason: %s]",
|
||||
$name,
|
||||
$result->{jnxFruState},
|
||||
$instance,
|
||||
$map_fru_type{$type},
|
||||
$result->{jnxFruOfflineReason})
|
||||
);
|
||||
my $exit = $self->get_severity(section => 'fru', instance => $instance, value => $result->{jnxFruState});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Fru '%s' state is %s [offline reason: %s]", $name, $result->{jnxFruState},
|
||||
$result->{jnxFruOfflineReason}));
|
||||
}
|
||||
|
||||
if (defined($result->{jnxFruTemp}) && $result->{jnxFruTemp} != 0) {
|
||||
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fru-temperature', instance => $instance, name => $name, value => $result->{jnxFruTemp});
|
||||
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit2,
|
||||
short_msg => sprintf("Fru '%s' temperature is %s degree centigrade", $name, $result->{jnxFruTemp}));
|
||||
}
|
||||
$self->{output}->perfdata_add(
|
||||
label => "temp", unit => 'C',
|
||||
nlabel => 'hardware.temperature.celsius',
|
||||
instances => $name,
|
||||
value => $result->{jnxFruTemp},
|
||||
warning => $warn,
|
||||
critical => $crit
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf("Fru '%s' state is %s [offline reason: %s]",
|
||||
$name,
|
||||
$result->{jnxFruState},
|
||||
$result->{jnxFruOfflineReason})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,28 +42,146 @@ sub check {
|
|||
|
||||
my $mapping = {
|
||||
jnxOperatingState => { oid => '.1.3.6.1.4.1.2636.3.1.13.1.6', map => \%map_operating_states },
|
||||
jnxOperatingTemp => { oid => '.1.3.6.1.4.1.2636.3.1.13.1.7' },
|
||||
jnxOperatingCPU => { oid => '.1.3.6.1.4.1.2636.3.1.13.1.8' },
|
||||
jnxOperatingBuffer => { oid => '.1.3.6.1.4.1.2636.3.1.13.1.11' },
|
||||
jnxOperatingHeap => { oid => '.1.3.6.1.4.1.2636.3.1.13.1.12' },
|
||||
};
|
||||
|
||||
my $results = $self->{snmp}->get_table(oid => $self->{oids_operating}->{jnxOperatingEntry},
|
||||
start => $mapping->{jnxOperatingState}->{oid}, end => $mapping->{jnxOperatingState}->{oid});
|
||||
my $results = $self->{snmp}->get_table(
|
||||
oid => $self->{oids_operating}->{jnxOperatingEntry},
|
||||
start => $mapping->{jnxOperatingState}->{oid},
|
||||
end => $mapping->{jnxOperatingHeap}->{oid}
|
||||
);
|
||||
|
||||
foreach my $instance (sort $self->get_instances(oid_entry => $self->{oids_operating}->{jnxOperatingEntry},
|
||||
oid_name => $self->{oids_operating}->{jnxOperatingDescr})) {
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $results, instance => $instance);
|
||||
my $desc = $self->get_cache(oid_entry => $self->{oids_operating}->{jnxOperatingEntry},
|
||||
oid_name => $self->{oids_operating}->{jnxOperatingDescr}, instance => $instance);
|
||||
my $result = $self->{snmp}->map_instance(
|
||||
mapping => $mapping,
|
||||
results => $results,
|
||||
instance => $instance
|
||||
);
|
||||
my $description = $self->get_cache(
|
||||
oid_entry => $self->{oids_operating}->{jnxOperatingEntry},
|
||||
oid_name => $self->{oids_operating}->{jnxOperatingDescr},
|
||||
instance => $instance
|
||||
);
|
||||
|
||||
next if ($self->check_filter(section => 'operating', instance => $instance, name => $desc));
|
||||
next if ($self->check_filter(section => 'operating', instance => $instance, name => $description));
|
||||
$self->{components}->{operating}->{total}++;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("operating '%s' state is %s [instance: %s]",
|
||||
$desc, $result->{jnxOperatingState}, $instance));
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf("operating '%s' state is %s [instance: %s]",
|
||||
$description,
|
||||
$result->{jnxOperatingState},
|
||||
$instance)
|
||||
);
|
||||
my $exit = $self->get_severity(section => 'operating', instance => $instance,
|
||||
value => $result->{jnxOperatingState});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Operating '%s' state is %s",
|
||||
$desc, $result->{jnxOperatingState}));
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf("Operating '%s' state is %s",
|
||||
$description,
|
||||
$result->{jnxOperatingState})
|
||||
);
|
||||
}
|
||||
|
||||
if (defined($result->{jnxOperatingTemp}) && $result->{jnxOperatingTemp} != 0) {
|
||||
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(
|
||||
section => 'operating-temperature',
|
||||
instance => $instance,
|
||||
name => $description,
|
||||
value => $result->{jnxOperatingTemp}
|
||||
);
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf("Operating '%s' temperature is %s degree centigrade",
|
||||
$description,
|
||||
$result->{jnxOperatingTemp})
|
||||
);
|
||||
}
|
||||
$self->{output}->perfdata_add(
|
||||
label => "temp", unit => 'C',
|
||||
nlabel => 'hardware.temperature.celsius',
|
||||
instances => $description,
|
||||
value => $result->{jnxOperatingTemp},
|
||||
warning => $warn,
|
||||
critical => $crit
|
||||
);
|
||||
}
|
||||
if (defined($result->{jnxOperatingCPU}) && $result->{jnxOperatingCPU} != 0) {
|
||||
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(
|
||||
section => 'operating-cpu',
|
||||
instance => $instance,
|
||||
name => $description,
|
||||
value => $result->{jnxOperatingCPU}
|
||||
);
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf("Operating '%s' CPU utilization is %s%%",
|
||||
$description,
|
||||
$result->{jnxOperatingCPU})
|
||||
);
|
||||
}
|
||||
$self->{output}->perfdata_add(
|
||||
label => "cpu_utilization", unit => '%',
|
||||
nlabel => 'hardware.cpu.utilization.percentage',
|
||||
instances => $description,
|
||||
value => $result->{jnxOperatingCPU},
|
||||
warning => $warn,
|
||||
critical => $crit
|
||||
);
|
||||
}
|
||||
if (defined($result->{jnxOperatingBuffer}) && $result->{jnxOperatingBuffer} != 0) {
|
||||
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(
|
||||
section => 'operating-buffer',
|
||||
instance => $instance,
|
||||
name => $description,
|
||||
value => $result->{jnxOperatingBuffer}
|
||||
);
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf("Operating '%s' buffer usage is %s%%",
|
||||
$description,
|
||||
$result->{jnxOperatingBuffer})
|
||||
);
|
||||
}
|
||||
$self->{output}->perfdata_add(
|
||||
label => "buffer_usage", unit => '%',
|
||||
nlabel => 'hardware.buffer.usage.percentage',
|
||||
instances => $description,
|
||||
value => $result->{jnxOperatingBuffer},
|
||||
warning => $warn,
|
||||
critical => $crit
|
||||
);
|
||||
}
|
||||
if (defined($result->{jnxOperatingHeap}) && $result->{jnxOperatingHeap} != 0) {
|
||||
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(
|
||||
section => 'operating-heap',
|
||||
instance => $instance,
|
||||
name => $description,
|
||||
value => $result->{jnxOperatingHeap}
|
||||
);
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf("Operating '%s' heap usage is %s%%",
|
||||
$description,
|
||||
$result->{jnxOperatingHeap})
|
||||
);
|
||||
}
|
||||
$self->{output}->perfdata_add(
|
||||
label => "heap_usage", unit => '%',
|
||||
nlabel => 'hardware.heap.usage.percentage',
|
||||
instances => $description,
|
||||
value => $result->{jnxOperatingHeap},
|
||||
warning => $warn,
|
||||
critical => $crit
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ sub set_system {
|
|||
my ($self, %options) = @_;
|
||||
|
||||
$self->{regexp_threshold_overload_check_section_option} = '^(fru|operating|alarm)$';
|
||||
$self->{regexp_threshold_numeric_check_section_option} = '^(fru-temperature)$';
|
||||
$self->{regexp_threshold_numeric_check_section_option} = '^(operating-temperature|operating-cpu|operating-buffer|operating-heap)$';
|
||||
|
||||
$self->{cb_hook1} = 'init_cache';
|
||||
$self->{cb_hook2} = 'snmp_execute';
|
||||
|
|
Loading…
Reference in New Issue