enhance indent + netbotz mib v5 managed
This commit is contained in:
parent
befbae4c8c
commit
c7c0ac0b21
|
@ -22,56 +22,79 @@ package hardware::sensors::netbotz::snmp::mode::components::airflow;
|
|||
|
||||
use strict;
|
||||
use warnings;
|
||||
use hardware::sensors::netbotz::snmp::mode::components::resources qw(%map_status);
|
||||
|
||||
my $mapping = {
|
||||
airFlowSensorId => { oid => '.1.3.6.1.4.1.5528.100.4.1.5.1.1' },
|
||||
airFlowSensorValue => { oid => '.1.3.6.1.4.1.5528.100.4.1.5.1.2' },
|
||||
airFlowSensorErrorStatus => { oid => '.1.3.6.1.4.1.5528.100.4.1.5.1.3', map => \%map_status },
|
||||
airFlowSensorLabel => { oid => '.1.3.6.1.4.1.5528.100.4.1.5.1.4' },
|
||||
};
|
||||
|
||||
my $oid_airFlowSensorEntry = '.1.3.6.1.4.1.5528.100.4.1.5.1';
|
||||
use hardware::sensors::netbotz::snmp::mode::components::resources qw($map_status);
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$self->{request}}, { oid => $oid_airFlowSensorEntry };
|
||||
|
||||
$self->{mapping_airflow} = {
|
||||
airFlowSensorId => { oid => '.1.3.6.1.4.1.' . $self->{netbotz_branch} . '.4.1.5.1.1' },
|
||||
airFlowSensorValue => { oid => '.1.3.6.1.4.1.' . $self->{netbotz_branch} . '.4.1.5.1.2' },
|
||||
airFlowSensorErrorStatus => { oid => '.1.3.6.1.4.1.' . $self->{netbotz_branch} . '.4.1.5.1.3', map => $map_status },
|
||||
airFlowSensorLabel => { oid => '.1.3.6.1.4.1.' . $self->{netbotz_branch} . '.4.1.5.1.4' }
|
||||
};
|
||||
$self->{oid_airFlowSensorEntry} = '.1.3.6.1.4.1.' . $self->{netbotz_branch} . '.4.1.5.1';
|
||||
push @{$self->{request}}, {
|
||||
oid => $self->{oid_airFlowSensorEntry},
|
||||
end => $self->{mapping_airflow}->{airFlowSensorLabel}->{oid}
|
||||
};
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking air flows");
|
||||
$self->{components}->{airflow} = {name => 'air flows', total => 0, skip => 0};
|
||||
$self->{components}->{airflow} = { name => 'air flows', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'airflow'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_airFlowSensorEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{airFlowSensorErrorStatus}->{oid}\.(.*)$/);
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{ $self->{oid_airFlowSensorEntry} }})) {
|
||||
next if ($oid !~ /^$self->{mapping_airflow}->{airFlowSensorErrorStatus}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_airFlowSensorEntry}, instance => $instance);
|
||||
|
||||
my $result = $self->{snmp}->map_instance(
|
||||
mapping => $self->{mapping_airflow},
|
||||
results => $self->{results}->{ $self->{oid_airFlowSensorEntry} },
|
||||
instance => $instance
|
||||
);
|
||||
|
||||
next if ($self->check_filter(section => 'airflow', instance => $instance));
|
||||
$self->{components}->{airflow}->{total}++;
|
||||
|
||||
|
||||
$result->{airFlowSensorValue} *= 0.1;
|
||||
my $label = defined($result->{airFlowSensorLabel}) && $result->{airFlowSensorLabel} ne '' ? $result->{airFlowSensorLabel} : $result->{airFlowSensorId};
|
||||
$self->{output}->output_add(long_msg => sprintf("air flow '%s' status is '%s' [instance = %s] [value = %s]",
|
||||
$label, $result->{airFlowSensorErrorStatus}, $instance,
|
||||
$result->{airFlowSensorValue}));
|
||||
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"air flow '%s' status is '%s' [instance = %s] [value = %s]",
|
||||
$label,
|
||||
$result->{airFlowSensorErrorStatus},
|
||||
$instance,
|
||||
$result->{airFlowSensorValue}
|
||||
)
|
||||
);
|
||||
|
||||
my $exit = $self->get_severity(label => 'default', section => 'airflow', value => $result->{airFlowSensorErrorStatus});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Air flow '%s' status is '%s'", $label, $result->{airFlowSensorErrorStatus}));
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"Air flow '%s' status is '%s'",
|
||||
$label,
|
||||
$result->{airFlowSensorErrorStatus}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'airflow', instance => $instance, value => $result->{airFlowSensorValue});
|
||||
|
||||
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit2,
|
||||
short_msg => sprintf("Air flow '%s' is %s m/min", $label, $result->{airFlowSensorValue}));
|
||||
$self->{output}->output_add(
|
||||
severity => $exit2,
|
||||
short_msg => sprintf(
|
||||
"Air flow '%s' is %s m/min",
|
||||
$label,
|
||||
$result->{airFlowSensorValue}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
label => 'airflow', unit => 'm/min',
|
||||
nlabel => 'hardware.sensor.airflow.cubicmeterperminute',
|
||||
|
|
|
@ -22,49 +22,66 @@ package hardware::sensors::netbotz::snmp::mode::components::camera;
|
|||
|
||||
use strict;
|
||||
use warnings;
|
||||
use hardware::sensors::netbotz::snmp::mode::components::resources qw(%map_status %map_camera_value);
|
||||
|
||||
my $mapping = {
|
||||
cameraMotionSensorId => { oid => '.1.3.6.1.4.1.5528.100.4.2.3.1.1' },
|
||||
cameraMotionSensorValue => { oid => '.1.3.6.1.4.1.5528.100.4.2.3.1.2', map => \%map_camera_value },
|
||||
cameraMotionSensorErrorStatus => { oid => '.1.3.6.1.4.1.5528.100.4.2.3.1.3', map => \%map_status },
|
||||
cameraMotionSensorLabel => { oid => '.1.3.6.1.4.1.5528.100.4.2.3.1.4' },
|
||||
};
|
||||
|
||||
my $oid_cameraMotionSensorEntry = '.1.3.6.1.4.1.5528.100.4.2.3.1';
|
||||
use hardware::sensors::netbotz::snmp::mode::components::resources qw($map_status $map_camera_value);
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$self->{request}}, { oid => $oid_cameraMotionSensorEntry };
|
||||
|
||||
$self->{mapping_camera} = {
|
||||
cameraMotionSensorId => { oid => '.1.3.6.1.4.1.' . $self->{netbotz_branch} . '.4.2.3.1.1' },
|
||||
cameraMotionSensorValue => { oid => '.1.3.6.1.4.1.' . $self->{netbotz_branch} . '.4.2.3.1.2', map => $map_camera_value },
|
||||
cameraMotionSensorErrorStatus => { oid => '.1.3.6.1.4.1.' . $self->{netbotz_branch} . '.4.2.3.1.3', map => $map_status },
|
||||
cameraMotionSensorLabel => { oid => '.1.3.6.1.4.1.' . $self->{netbotz_branch} . '.4.2.3.1.4' }
|
||||
};
|
||||
$self->{oid_cameraMotionSensorEntry} = '.1.3.6.1.4.1.' . $self->{netbotz_branch} . '.4.2.3.1';
|
||||
push @{$self->{request}}, {
|
||||
oid => $self->{oid_cameraMotionSensorEntry},
|
||||
end => $self->{mapping_camera}->{cameraMotionSensorLabel}->{oid}
|
||||
};
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking cameras");
|
||||
$self->{components}->{camera} = {name => 'cameras', total => 0, skip => 0};
|
||||
$self->{components}->{camera} = { name => 'cameras', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'camera'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cameraMotionSensorEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{cameraMotionSensorErrorStatus}->{oid}\.(.*)$/);
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{ $self->{oid_cameraMotionSensorEntry} }})) {
|
||||
next if ($oid !~ /^$self->{mapping_camera}->{cameraMotionSensorErrorStatus}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cameraMotionSensorEntry}, instance => $instance);
|
||||
|
||||
my $result = $self->{snmp}->map_instance(
|
||||
mapping => $self->{mapping_camera},
|
||||
results => $self->{results}->{ $self->{oid_cameraMotionSensorEntry} },
|
||||
instance => $instance
|
||||
);
|
||||
|
||||
next if ($self->check_filter(section => 'camera', instance => $instance));
|
||||
$self->{components}->{camera}->{total}++;
|
||||
|
||||
|
||||
my $label = defined($result->{cameraMotionSensorLabel}) && $result->{cameraMotionSensorLabel} ne '' ? $result->{cameraMotionSensorLabel} : $result->{cameraMotionSensorId};
|
||||
$self->{output}->output_add(long_msg => sprintf("camera motion '%s' status is '%s' [instance = %s] [value = %s]",
|
||||
$label, $result->{cameraMotionSensorErrorStatus}, $instance,
|
||||
$result->{cameraMotionSensorValue}));
|
||||
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"camera motion '%s' status is '%s' [instance = %s] [value = %s]",
|
||||
$label,
|
||||
$result->{cameraMotionSensorErrorStatus},
|
||||
$instance,
|
||||
$result->{cameraMotionSensorValue}
|
||||
)
|
||||
);
|
||||
|
||||
my $exit = $self->get_severity(label => 'default', section => 'camera', value => $result->{cameraMotionSensorErrorStatus});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Camera motion '%s' status is '%s'", $label, $result->{cameraMotionSensorErrorStatus}));
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"Camera motion '%s' status is '%s'",
|
||||
$label,
|
||||
$result->{cameraMotionSensorErrorStatus}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
1;
|
||||
|
|
|
@ -22,56 +22,79 @@ package hardware::sensors::netbotz::snmp::mode::components::dewpoint;
|
|||
|
||||
use strict;
|
||||
use warnings;
|
||||
use hardware::sensors::netbotz::snmp::mode::components::resources qw(%map_status);
|
||||
|
||||
my $mapping = {
|
||||
dewPointSensorId => { oid => '.1.3.6.1.4.1.5528.100.4.1.3.1.1' },
|
||||
dewPointSensorValue => { oid => '.1.3.6.1.4.1.5528.100.4.1.3.1.2' },
|
||||
dewPointSensorErrorStatus => { oid => '.1.3.6.1.4.1.5528.100.4.1.3.1.3', map => \%map_status },
|
||||
dewPointSensorLabel => { oid => '.1.3.6.1.4.1.5528.100.4.1.3.1.4' },
|
||||
};
|
||||
|
||||
my $oid_dewPointSensorEntry = '.1.3.6.1.4.1.5528.100.4.1.3.1';
|
||||
use hardware::sensors::netbotz::snmp::mode::components::resources qw($map_status);
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$self->{request}}, { oid => $oid_dewPointSensorEntry };
|
||||
|
||||
$self->{mapping_dewpoint} = {
|
||||
dewPointSensorId => { oid => '.1.3.6.1.4.1.' . $self->{netbotz_branch} . '.4.1.3.1.1' },
|
||||
dewPointSensorValue => { oid => '.1.3.6.1.4.1.' . $self->{netbotz_branch} . '.4.1.3.1.2' },
|
||||
dewPointSensorErrorStatus => { oid => '.1.3.6.1.4.1.' . $self->{netbotz_branch} . '.4.1.3.1.3', map => $map_status },
|
||||
dewPointSensorLabel => { oid => '.1.3.6.1.4.1.' . $self->{netbotz_branch} . '.4.1.3.1.4' }
|
||||
};
|
||||
$self->{oid_dewPointSensorEntry} = '.1.3.6.1.4.1.' . $self->{netbotz_branch} . '.4.1.3.1';
|
||||
push @{$self->{request}}, {
|
||||
oid => $self->{oid_dewPointSensorEntry},
|
||||
end => $self->{mapping_dewpoint}->{dewPointSensorLabel}->{oid}
|
||||
};
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking dew points");
|
||||
$self->{components}->{dewpoint} = {name => 'dew points', total => 0, skip => 0};
|
||||
$self->{components}->{dewpoint} = { name => 'dew points', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'dewpoint'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_dewPointSensorEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{dewPointSensorErrorStatus}->{oid}\.(.*)$/);
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{ $self->{oid_dewPointSensorEntry} }})) {
|
||||
next if ($oid !~ /^$self->{mapping_dewpoint}->{dewPointSensorErrorStatus}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_dewPointSensorEntry}, instance => $instance);
|
||||
|
||||
my $result = $self->{snmp}->map_instance(
|
||||
mapping => $self->{mapping_dewpoint},
|
||||
results => $self->{results}->{ $self->{oid_dewPointSensorEntry} },
|
||||
instance => $instance
|
||||
);
|
||||
|
||||
next if ($self->check_filter(section => 'dewpoint', instance => $instance));
|
||||
$self->{components}->{dewpoint}->{total}++;
|
||||
|
||||
|
||||
$result->{dewPointSensorValue} *= 0.1;
|
||||
my $label = defined($result->{dewPointSensorLabel}) && $result->{dewPointSensorLabel} ne '' ? $result->{dewPointSensorLabel} : $result->{dewPointSensorId};
|
||||
$self->{output}->output_add(long_msg => sprintf("dew point '%s' status is '%s' [instance = %s] [value = %s]",
|
||||
$label, $result->{dewPointSensorErrorStatus}, $instance,
|
||||
$result->{dewPointSensorValue}));
|
||||
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"dew point '%s' status is '%s' [instance = %s] [value = %s]",
|
||||
$label,
|
||||
$result->{dewPointSensorErrorStatus},
|
||||
$instance,
|
||||
$result->{dewPointSensorValue}
|
||||
)
|
||||
);
|
||||
|
||||
my $exit = $self->get_severity(label => 'default', section => 'dewpoint', value => $result->{dewPointSensorErrorStatus});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Dew point '%s' status is '%s'", $label, $result->{dewPointSensorErrorStatus}));
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"Dew point '%s' status is '%s'",
|
||||
$label,
|
||||
$result->{dewPointSensorErrorStatus}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'dewpoint', instance => $instance, value => $result->{dewPointSensorValue});
|
||||
|
||||
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit2,
|
||||
short_msg => sprintf("Dew point '%s' is %s C", $label, $result->{dewPointSensorValue}));
|
||||
$self->{output}->output_add(
|
||||
severity => $exit2,
|
||||
short_msg => sprintf(
|
||||
"Dew point '%s' is %s C",
|
||||
$label,
|
||||
$result->{dewPointSensorValue}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
label => 'dewpoint', unit => 'C',
|
||||
nlabel => 'hardware.sensor.dewpoint.celsius',
|
||||
|
|
|
@ -22,49 +22,66 @@ package hardware::sensors::netbotz::snmp::mode::components::doorswitch;
|
|||
|
||||
use strict;
|
||||
use warnings;
|
||||
use hardware::sensors::netbotz::snmp::mode::components::resources qw(%map_status %map_door_value);
|
||||
|
||||
my $mapping = {
|
||||
doorSwitchSensorId => { oid => '.1.3.6.1.4.1.5528.100.4.2.2.1.1' },
|
||||
doorSwitchSensorValue => { oid => '.1.3.6.1.4.1.5528.100.4.2.2.1.2', map => \%map_door_value },
|
||||
doorSwitchSensorErrorStatus => { oid => '.1.3.6.1.4.1.5528.100.4.2.2.1.3', map => \%map_status },
|
||||
doorSwitchSensorLabel => { oid => '.1.3.6.1.4.1.5528.100.4.2.2.1.4' },
|
||||
};
|
||||
|
||||
my $oid_doorSwitchSensorEntry = '.1.3.6.1.4.1.5528.100.4.2.2.1';
|
||||
use hardware::sensors::netbotz::snmp::mode::components::resources qw($map_status $map_door_value);
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$self->{request}}, { oid => $oid_doorSwitchSensorEntry };
|
||||
|
||||
$self->{mapping_doorswitch} = {
|
||||
doorSwitchSensorId => { oid => '.1.3.6.1.4.1.' . $self->{netbotz_branch} . '.4.2.2.1.1' },
|
||||
doorSwitchSensorValue => { oid => '.1.3.6.1.4.1.' . $self->{netbotz_branch} . '.4.2.2.1.2', map => $map_door_value },
|
||||
doorSwitchSensorErrorStatus => { oid => '.1.3.6.1.4.1.' . $self->{netbotz_branch} . '.4.2.2.1.3', map => $map_status },
|
||||
doorSwitchSensorLabel => { oid => '.1.3.6.1.4.1.' . $self->{netbotz_branch} . '.4.2.2.1.4' }
|
||||
};
|
||||
$self->{oid_doorSwitchSensorEntry} = '.1.3.6.1.4.1.' . $self->{netbotz_branch} . '.4.2.2.1';
|
||||
push @{$self->{request}}, {
|
||||
oid => $self->{oid_doorSwitchSensorEntry},
|
||||
end => $self->{mapping_doorswitch}->{doorSwitchSensorLabel}->{oid}
|
||||
};
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking door switches");
|
||||
$self->{components}->{doorswitch} = {name => 'door switches', total => 0, skip => 0};
|
||||
$self->{components}->{doorswitch} = { name => 'door switches', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'doorswitch'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_doorSwitchSensorEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{doorSwitchSensorErrorStatus}->{oid}\.(.*)$/);
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{ $self->{oid_doorSwitchSensorEntry} }})) {
|
||||
next if ($oid !~ /^$self->{mapping_doorswitch}->{doorSwitchSensorErrorStatus}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_doorSwitchSensorEntry}, instance => $instance);
|
||||
|
||||
my $result = $self->{snmp}->map_instance(
|
||||
mapping => $self->{mapping_doorswitch},
|
||||
results => $self->{results}->{ $self->{oid_doorSwitchSensorEntry} },
|
||||
instance => $instance
|
||||
);
|
||||
|
||||
next if ($self->check_filter(section => 'doorswitch', instance => $instance));
|
||||
$self->{components}->{doorswitch}->{total}++;
|
||||
|
||||
|
||||
my $label = defined($result->{doorSwitchSensorLabel}) && $result->{doorSwitchSensorLabel} ne '' ? $result->{doorSwitchSensorLabel} : $result->{doorSwitchSensorId};
|
||||
$self->{output}->output_add(long_msg => sprintf("door switch '%s' status is '%s' [instance = %s] [value = %s]",
|
||||
$label, $result->{doorSwitchSensorErrorStatus}, $instance,
|
||||
$result->{doorSwitchSensorValue}));
|
||||
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"door switch '%s' status is '%s' [instance = %s] [value = %s]",
|
||||
$label,
|
||||
$result->{doorSwitchSensorErrorStatus},
|
||||
$instance,
|
||||
$result->{doorSwitchSensorValue}
|
||||
)
|
||||
);
|
||||
|
||||
my $exit = $self->get_severity(label => 'default', section => 'doorswitch', value => $result->{doorSwitchSensorErrorStatus});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Door switch '%s' status is '%s'", $label, $result->{doorSwitchSensorErrorStatus}));
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"Door switch '%s' status is '%s'",
|
||||
$label,
|
||||
$result->{doorSwitchSensorErrorStatus}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
1;
|
||||
|
|
|
@ -22,56 +22,79 @@ package hardware::sensors::netbotz::snmp::mode::components::humidity;
|
|||
|
||||
use strict;
|
||||
use warnings;
|
||||
use hardware::sensors::netbotz::snmp::mode::components::resources qw(%map_status);
|
||||
|
||||
my $mapping = {
|
||||
humiSensorId => { oid => '.1.3.6.1.4.1.5528.100.4.1.2.1.1' },
|
||||
humiSensorValue => { oid => '.1.3.6.1.4.1.5528.100.4.1.2.1.2' },
|
||||
humiSensorErrorStatus => { oid => '.1.3.6.1.4.1.5528.100.4.1.2.1.3', map => \%map_status },
|
||||
humiSensorLabel => { oid => '.1.3.6.1.4.1.5528.100.4.1.2.1.4' },
|
||||
};
|
||||
|
||||
my $oid_humiSensorEntry = '.1.3.6.1.4.1.5528.100.4.1.2.1';
|
||||
use hardware::sensors::netbotz::snmp::mode::components::resources qw($map_status);
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$self->{request}}, { oid => $oid_humiSensorEntry };
|
||||
|
||||
$self->{mapping_humidity} = {
|
||||
humiSensorId => { oid => '.1.3.6.1.4.1.' . $self->{netbotz_branch} . '.4.1.2.1.1' },
|
||||
humiSensorValue => { oid => '.1.3.6.1.4.1.' . $self->{netbotz_branch} . '.4.1.2.1.2' },
|
||||
humiSensorErrorStatus => { oid => '.1.3.6.1.4.1.' . $self->{netbotz_branch} . '.4.1.2.1.3', map => $map_status },
|
||||
humiSensorLabel => { oid => '.1.3.6.1.4.1.' . $self->{netbotz_branch} . '.4.1.2.1.4' }
|
||||
};
|
||||
$self->{oid_humiSensorEntry} = '.1.3.6.1.4.1.' . $self->{netbotz_branch} . '.4.1.2.1';
|
||||
push @{$self->{request}}, {
|
||||
oid => $self->{oid_humiSensorEntry},
|
||||
end => $self->{mapping_humidity}->{humiSensorLabel}->{oid}
|
||||
};
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking humidities");
|
||||
$self->{components}->{humidity} = {name => 'humidity', total => 0, skip => 0};
|
||||
$self->{components}->{humidity} = { name => 'humidity', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'humidity'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_humiSensorEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{humiSensorErrorStatus}->{oid}\.(.*)$/);
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{ $self->{oid_humiSensorEntry} }})) {
|
||||
next if ($oid !~ /^$self->{mapping_humidity}->{humiSensorErrorStatus}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_humiSensorEntry}, instance => $instance);
|
||||
|
||||
my $result = $self->{snmp}->map_instance(
|
||||
mapping => $self->{mapping_humidity},
|
||||
results => $self->{results}->{ $self->{oid_humiSensorEntry} },
|
||||
instance => $instance
|
||||
);
|
||||
|
||||
next if ($self->check_filter(section => 'humidity', instance => $instance));
|
||||
$self->{components}->{humidity}->{total}++;
|
||||
|
||||
|
||||
$result->{humiSensorValue} *= 0.1;
|
||||
my $label = defined($result->{humiSensorLabel}) && $result->{humiSensorLabel} ne '' ? $result->{humiSensorLabel} : $result->{humiSensorId};
|
||||
$self->{output}->output_add(long_msg => sprintf("humidity '%s' status is '%s' [instance = %s] [value = %s]",
|
||||
$label, $result->{humiSensorErrorStatus}, $instance,
|
||||
$result->{humiSensorValue}));
|
||||
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"humidity '%s' status is '%s' [instance = %s] [value = %s]",
|
||||
$label,
|
||||
$result->{humiSensorErrorStatus},
|
||||
$instance,
|
||||
$result->{humiSensorValue}
|
||||
)
|
||||
);
|
||||
|
||||
my $exit = $self->get_severity(label => 'default', section => 'humidity', value => $result->{humiSensorErrorStatus});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Humidity '%s' status is '%s'", $label, $result->{humiSensorErrorStatus}));
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"Humidity '%s' status is '%s'",
|
||||
$label,
|
||||
$result->{humiSensorErrorStatus}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'humidity', instance => $instance, value => $result->{humiSensorValue});
|
||||
|
||||
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit2,
|
||||
short_msg => sprintf("Humidity '%s' is %s %%", $label, $result->{humiSensorValue}));
|
||||
$self->{output}->output_add(
|
||||
severity => $exit2,
|
||||
short_msg => sprintf(
|
||||
"Humidity '%s' is %s %%",
|
||||
$label,
|
||||
$result->{humiSensorValue}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
label => 'humidity', unit => '%',
|
||||
nlabel => 'hardware.sensor.humidity.percentage',
|
||||
|
|
|
@ -22,49 +22,63 @@ package hardware::sensors::netbotz::snmp::mode::components::otherstate;
|
|||
|
||||
use strict;
|
||||
use warnings;
|
||||
use hardware::sensors::netbotz::snmp::mode::components::resources qw(%map_status);
|
||||
|
||||
my $mapping = {
|
||||
otherStateSensorId => { oid => '.1.3.6.1.4.1.5528.100.4.2.10.1.1' },
|
||||
otherStateSensorErrorStatus => { oid => '.1.3.6.1.4.1.5528.100.4.2.10.1.3', map => \%map_status },
|
||||
otherStateSensorLabel => { oid => '.1.3.6.1.4.1.5528.100.4.2.10.1.4' },
|
||||
otherStateSensorValueStr => { oid => '.1.3.6.1.4.1.5528.100.4.2.10.1.7' },
|
||||
};
|
||||
|
||||
my $oid_otherStateSensorEntry = '.1.3.6.1.4.1.5528.100.4.2.10.1';
|
||||
use hardware::sensors::netbotz::snmp::mode::components::resources qw($map_status);
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$self->{request}}, { oid => $oid_otherStateSensorEntry };
|
||||
|
||||
$self->{mapping_otherstate} = {
|
||||
otherStateSensorId => { oid => '.1.3.6.1.4.1.' . $self->{netbotz_branch} . '.4.2.10.1.1' },
|
||||
otherStateSensorErrorStatus => { oid => '.1.3.6.1.4.1.' . $self->{netbotz_branch} . '.4.2.10.1.3', map => $map_status },
|
||||
otherStateSensorLabel => { oid => '.1.3.6.1.4.1.' . $self->{netbotz_branch} . '.4.2.10.1.4' },
|
||||
otherStateSensorValueStr => { oid => '.1.3.6.1.4.1.' . $self->{netbotz_branch} . '.4.2.10.1.7' }
|
||||
};
|
||||
$self->{oid_otherStateSensorEntry} = '.1.3.6.1.4.1.' . $self->{netbotz_branch} . '.4.2.10.1';
|
||||
push @{$self->{request}}, { oid => $self->{oid_otherStateSensorEntry} };
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking other state");
|
||||
$self->{components}->{otherstate} = {name => 'other state', total => 0, skip => 0};
|
||||
$self->{components}->{otherstate} = { name => 'other state', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'otherstate'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_otherStateSensorEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{otherStateSensorErrorStatus}->{oid}\.(.*)$/);
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{ $self->{oid_otherStateSensorEntry} }})) {
|
||||
next if ($oid !~ /^$self->{mapping_otherstate}->{otherStateSensorErrorStatus}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_otherStateSensorEntry}, instance => $instance);
|
||||
|
||||
my $result = $self->{snmp}->map_instance(
|
||||
mapping => $self->{mapping_otherstate},
|
||||
results => $self->{results}->{ $self->{oid_otherStateSensorEntry} },
|
||||
instance => $instance
|
||||
);
|
||||
|
||||
next if ($self->check_filter(section => 'otherstate', instance => $instance));
|
||||
$self->{components}->{otherstate}->{total}++;
|
||||
|
||||
|
||||
my $label = defined($result->{otherStateSensorLabel}) && $result->{otherStateSensorLabel} ne '' ? $result->{otherStateSensorLabel} : $result->{otherStateSensorId};
|
||||
$self->{output}->output_add(long_msg => sprintf("other state '%s' status is '%s' [instance = %s] [value = %s]",
|
||||
$label, $result->{otherStateSensorErrorStatus}, $instance,
|
||||
$result->{otherStateSensorValueStr}));
|
||||
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"other state '%s' status is '%s' [instance = %s] [value = %s]",
|
||||
$label,
|
||||
$result->{otherStateSensorErrorStatus},
|
||||
$instance,
|
||||
$result->{otherStateSensorValueStr}
|
||||
)
|
||||
);
|
||||
|
||||
my $exit = $self->get_severity(label => 'default', section => 'otherstate', value => $result->{otherStateSensorErrorStatus});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Other state '%s' status is '%s'", $label, $result->{otherStateSensorErrorStatus}));
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"Other state '%s' status is '%s'",
|
||||
$label,
|
||||
$result->{otherStateSensorErrorStatus}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
1;
|
||||
|
|
|
@ -24,32 +24,32 @@ use strict;
|
|||
use warnings;
|
||||
use Exporter;
|
||||
|
||||
our %map_status;
|
||||
our %map_door_value;
|
||||
our %map_camera_value;
|
||||
our $map_status;
|
||||
our $map_door_value;
|
||||
our $map_camera_value;
|
||||
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT_OK = qw(%map_status %map_door_value %map_camera_value);
|
||||
our @EXPORT_OK = qw($map_status $map_door_value $map_camera_value);
|
||||
|
||||
%map_status = (
|
||||
$map_status = {
|
||||
0 => 'normal',
|
||||
1 => 'info',
|
||||
2 => 'warning',
|
||||
3 => 'error',
|
||||
4 => 'critical',
|
||||
5 => 'failure',
|
||||
);
|
||||
1 => 'info',
|
||||
2 => 'warning',
|
||||
3 => 'error',
|
||||
4 => 'critical',
|
||||
5 => 'failure'
|
||||
};
|
||||
|
||||
%map_door_value = (
|
||||
-1 => 'null',
|
||||
0 => 'open',
|
||||
1 => 'closed',
|
||||
);
|
||||
$map_door_value = {
|
||||
-1 => 'null',
|
||||
0 => 'open',
|
||||
1 => 'closed'
|
||||
};
|
||||
|
||||
%map_camera_value = (
|
||||
-1 => 'null',
|
||||
0 => 'noMotion',
|
||||
1 => 'motionDetected',
|
||||
);
|
||||
$map_camera_value = {
|
||||
-1 => 'null',
|
||||
0 => 'noMotion',
|
||||
1 => 'motionDetected'
|
||||
};
|
||||
|
||||
1;
|
||||
1;
|
||||
|
|
|
@ -22,55 +22,78 @@ package hardware::sensors::netbotz::snmp::mode::components::temperature;
|
|||
|
||||
use strict;
|
||||
use warnings;
|
||||
use hardware::sensors::netbotz::snmp::mode::components::resources qw(%map_status);
|
||||
|
||||
my $mapping = {
|
||||
tempSensorId => { oid => '.1.3.6.1.4.1.5528.100.4.1.1.1.1' },
|
||||
tempSensorValue => { oid => '.1.3.6.1.4.1.5528.100.4.1.1.1.2' },
|
||||
tempSensorErrorStatus => { oid => '.1.3.6.1.4.1.5528.100.4.1.1.1.3', map => \%map_status },
|
||||
tempSensorLabel => { oid => '.1.3.6.1.4.1.5528.100.4.1.1.1.4' },
|
||||
};
|
||||
|
||||
my $oid_tempSensorEntry = '.1.3.6.1.4.1.5528.100.4.1.1.1';
|
||||
use hardware::sensors::netbotz::snmp::mode::components::resources qw($map_status);
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$self->{request}}, { oid => $oid_tempSensorEntry };
|
||||
|
||||
$self->{mapping_temperature} = {
|
||||
tempSensorId => { oid => '.1.3.6.1.4.1.' . $self->{netbotz_branch} . '.4.1.1.1.1' },
|
||||
tempSensorValue => { oid => '.1.3.6.1.4.1.' . $self->{netbotz_branch} . '.4.1.1.1.2' },
|
||||
tempSensorErrorStatus => { oid => '.1.3.6.1.4.1.' . $self->{netbotz_branch} . '.4.1.1.1.3', map => $map_status },
|
||||
tempSensorLabel => { oid => '.1.3.6.1.4.1.' . $self->{netbotz_branch} . '.4.1.1.1.4' },
|
||||
};
|
||||
$self->{oid_tempSensorEntry} = '.1.3.6.1.4.1.' . $self->{netbotz_branch} . '.4.1.1.1';
|
||||
push @{$self->{request}}, {
|
||||
oid => $self->{oid_tempSensorEntry},
|
||||
end => $self->{mapping_temperature}->{tempSensorLabel}->{oid}
|
||||
};
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking temperatures");
|
||||
$self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0};
|
||||
$self->{components}->{temperature} = { name => 'temperatures', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'temperature'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_tempSensorEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{tempSensorErrorStatus}->{oid}\.(.*)$/);
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{ $self->{oid_tempSensorEntry} }})) {
|
||||
next if ($oid !~ /^$self->{mapping_temperature}->{tempSensorErrorStatus}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_tempSensorEntry}, instance => $instance);
|
||||
|
||||
my $result = $self->{snmp}->map_instance(
|
||||
mapping => $self->{mapping_temperature},
|
||||
results => $self->{results}->{ $self->{oid_tempSensorEntry} },
|
||||
instance => $instance
|
||||
);
|
||||
|
||||
next if ($self->check_filter(section => 'temperature', instance => $instance));
|
||||
$self->{components}->{temperature}->{total}++;
|
||||
|
||||
|
||||
$result->{tempSensorValue} *= 0.1;
|
||||
my $label = defined($result->{tempSensorLabel}) && $result->{tempSensorLabel} ne '' ? $result->{tempSensorLabel} : $result->{tempSensorId};
|
||||
$self->{output}->output_add(long_msg => sprintf("temperature '%s' status is '%s' [instance = %s] [value = %s]",
|
||||
$label, $result->{tempSensorErrorStatus}, $instance,
|
||||
$result->{tempSensorValue}));
|
||||
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"temperature '%s' status is '%s' [instance = %s] [value = %s]",
|
||||
$label,
|
||||
$result->{tempSensorErrorStatus},
|
||||
$instance,
|
||||
$result->{tempSensorValue}
|
||||
)
|
||||
);
|
||||
|
||||
my $exit = $self->get_severity(label => 'default', section => 'temperature', value => $result->{tempSensorErrorStatus});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Temperature '%s' status is '%s'", $label, $result->{tempSensorErrorStatus}));
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"Temperature '%s' status is '%s'",
|
||||
$label,
|
||||
$result->{tempSensorErrorStatus}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{tempSensorValue});
|
||||
|
||||
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit2,
|
||||
short_msg => sprintf("Temperature '%s' is %s C", $label, $result->{tempSensorValue}));
|
||||
$self->{output}->output_add(
|
||||
severity => $exit2,
|
||||
short_msg => sprintf(
|
||||
"Temperature '%s' is %s C",
|
||||
$label,
|
||||
$result->{tempSensorValue}
|
||||
)
|
||||
);
|
||||
}
|
||||
$self->{output}->perfdata_add(
|
||||
label => 'temperature', unit => 'C',
|
||||
|
|
|
@ -27,12 +27,13 @@ use warnings;
|
|||
|
||||
sub set_system {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
||||
$self->{regexp_threshold_overload_check_section_option} = '^(temperature|humidity|dewpoint|airflow|doorswitch|camera|otherstate)$';
|
||||
$self->{regexp_threshold_numeric_check_section_option} = '^(temperature|humidity|dewpoint|airflow)$';
|
||||
|
||||
|
||||
$self->{cb_hook1} = 'get_version';
|
||||
$self->{cb_hook2} = 'snmp_execute';
|
||||
|
||||
|
||||
$self->{thresholds} = {
|
||||
default => [
|
||||
['normal', 'OK'],
|
||||
|
@ -43,15 +44,37 @@ sub set_system {
|
|||
['failure', 'CRITICAL'],
|
||||
],
|
||||
};
|
||||
|
||||
|
||||
$self->{components_path} = 'hardware::sensors::netbotz::snmp::mode::components';
|
||||
$self->{components_module} = ['temperature', 'humidity', 'dewpoint', 'airflow',
|
||||
'doorswitch', 'camera', 'otherstate'];
|
||||
$self->{components_module} = [
|
||||
'temperature', 'humidity', 'dewpoint', 'airflow',
|
||||
'doorswitch', 'camera', 'otherstate'
|
||||
];
|
||||
}
|
||||
|
||||
sub get_version {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $v1_netBotzErrorStatus = '.1.3.6.1.4.1.5528.100.100';
|
||||
my $v5_netBotzErrorStatus = '.1.3.6.1.4.1.52674.500.100.0';
|
||||
my $result = $options{snmp}->get_leef(
|
||||
oids => [$v1_netBotzErrorStatus, $v1_netBotzErrorStatus . '.0', $v5_netBotzErrorStatus]
|
||||
);
|
||||
|
||||
$self->{is_v5} = 0;
|
||||
$self->{netbotz_branch} = '5528.100';
|
||||
if (defined($result->{$v5_netBotzErrorStatus})) {
|
||||
$self->{is_v5} = 1;
|
||||
$self->{netbotz_branch} = '52674.500';
|
||||
} elsif (!defined($result->{$v1_netBotzErrorStatus}) && !defined($result->{$v1_netBotzErrorStatus . '.0'})) {
|
||||
$self->{output}->add_option_msg(short_msg => 'cannot find netbotz version');
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
sub snmp_execute {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
||||
$self->{snmp} = $options{snmp};
|
||||
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
|
||||
}
|
||||
|
@ -60,11 +83,10 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
});
|
||||
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
@ -112,4 +134,4 @@ Example: --warning='temperature,.*,50'
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
=cut
|
||||
|
|
Loading…
Reference in New Issue