enh(broadcom/fastpath): new metric labels (#3041)
This commit is contained in:
parent
cab1094136
commit
d14888a0f9
|
@ -30,7 +30,7 @@ my %map_fan_status = (
|
||||||
|
|
||||||
my $mapping = {
|
my $mapping = {
|
||||||
boxServicesFanItemState => { oid => '.1.3.6.1.4.1.4413.1.1.43.1.6.1.3', map => \%map_fan_status },
|
boxServicesFanItemState => { oid => '.1.3.6.1.4.1.4413.1.1.43.1.6.1.3', map => \%map_fan_status },
|
||||||
boxServicesFanSpeed => { oid => '.1.3.6.1.4.1.4413.1.1.43.1.6.1.4' },
|
boxServicesFanSpeed => { oid => '.1.3.6.1.4.1.4413.1.1.43.1.6.1.4' }
|
||||||
};
|
};
|
||||||
my $oid_boxServicesFansEntry = '.1.3.6.1.4.1.4413.1.1.43.1.6.1';
|
my $oid_boxServicesFansEntry = '.1.3.6.1.4.1.4413.1.1.43.1.6.1';
|
||||||
|
|
||||||
|
@ -60,24 +60,32 @@ sub check {
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{components}->{fan}->{total}++;
|
$self->{components}->{fan}->{total}++;
|
||||||
$self->{output}->output_add(long_msg => sprintf("fan '%s' status is '%s' [instance = %s, speed = %s]",
|
$self->{output}->output_add(
|
||||||
$instance, $result->{boxServicesFanItemState}, $instance, defined($result->{boxServicesFanSpeed}) ? $result->{boxServicesFanSpeed} : 'unknown'));
|
long_msg => sprintf(
|
||||||
|
"fan '%s' status is '%s' [instance = %s, speed = %s]",
|
||||||
|
$instance, $result->{boxServicesFanItemState}, $instance, defined($result->{boxServicesFanSpeed}) ? $result->{boxServicesFanSpeed} : 'unknown'
|
||||||
|
)
|
||||||
|
);
|
||||||
$exit = $self->get_severity(label => 'default', section => 'fan', value => $result->{boxServicesFanItemState});
|
$exit = $self->get_severity(label => 'default', section => 'fan', value => $result->{boxServicesFanItemState});
|
||||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||||
$self->{output}->output_add(severity => $exit,
|
$self->{output}->output_add(
|
||||||
short_msg => sprintf("Fan '%s' status is '%s'", $instance, $result->{boxServicesFanItemState}));
|
severity => $exit,
|
||||||
|
short_msg => sprintf("Fan '%s' status is '%s'", $instance, $result->{boxServicesFanItemState})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
next if (!defined($result->{boxServicesFanSpeed}) || $result->{boxServicesFanSpeed} !~ /[0-9]+/);
|
next if (!defined($result->{boxServicesFanSpeed}) || $result->{boxServicesFanSpeed} !~ /[0-9]+/);
|
||||||
|
|
||||||
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fan', instance => $instance, value => $result->{boxServicesFanSpeed});
|
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fan', instance => $instance, value => $result->{boxServicesFanSpeed});
|
||||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||||
$self->{output}->output_add(severity => $exit,
|
$self->{output}->output_add(
|
||||||
short_msg => sprintf("Fan '%s' is '%s' rpm", $instance, $result->{boxServicesFanSpeed}));
|
severity => $exit,
|
||||||
|
short_msg => sprintf("Fan '%s' is '%s' rpm", $instance, $result->{boxServicesFanSpeed})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$self->{output}->perfdata_add(
|
$self->{output}->perfdata_add(
|
||||||
label => 'fan', unit => 'rpm',
|
|
||||||
nlabel => 'hardware.fan.speed.rpm',
|
nlabel => 'hardware.fan.speed.rpm',
|
||||||
|
unit => 'rpm',
|
||||||
instances => $instance,
|
instances => $instance,
|
||||||
value => $result->{boxServicesFanSpeed},
|
value => $result->{boxServicesFanSpeed},
|
||||||
warning => $warn,
|
warning => $warn,
|
||||||
|
|
|
@ -58,12 +58,18 @@ sub check {
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{components}->{psu}->{total}++;
|
$self->{components}->{psu}->{total}++;
|
||||||
$self->{output}->output_add(long_msg => sprintf("power supply '%s' status is '%s' [instance = %s]",
|
$self->{output}->output_add(
|
||||||
$instance, $result->{boxServicesPowSupplyItemState}, $instance));
|
long_msg => sprintf(
|
||||||
|
"power supply '%s' status is '%s' [instance = %s]",
|
||||||
|
$instance, $result->{boxServicesPowSupplyItemState}, $instance
|
||||||
|
)
|
||||||
|
);
|
||||||
$exit = $self->get_severity(label => 'default', section => 'psu', value => $result->{boxServicesPowSupplyItemState});
|
$exit = $self->get_severity(label => 'default', section => 'psu', value => $result->{boxServicesPowSupplyItemState});
|
||||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||||
$self->{output}->output_add(severity => $exit,
|
$self->{output}->output_add(
|
||||||
short_msg => sprintf("Power supply '%s' status is '%s'", $instance, $result->{boxServicesPowSupplyItemState}));
|
severity => $exit,
|
||||||
|
short_msg => sprintf("Power supply '%s' status is '%s'", $instance, $result->{boxServicesPowSupplyItemState})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,12 +25,12 @@ use warnings;
|
||||||
|
|
||||||
my %map_temp_status = (
|
my %map_temp_status = (
|
||||||
0 => 'low', 1 => 'normal', 2 => 'warning', 3 => 'critical',
|
0 => 'low', 1 => 'normal', 2 => 'warning', 3 => 'critical',
|
||||||
4 => 'shutdown', 5 => 'notpresent', 6 => 'notoperational',
|
4 => 'shutdown', 5 => 'notpresent', 6 => 'notoperational'
|
||||||
);
|
);
|
||||||
|
|
||||||
my $mapping = {
|
my $mapping = {
|
||||||
boxServicesTempSensorState => { oid => '.1.3.6.1.4.1.4413.1.1.43.1.8.1.4', map => \%map_temp_status },
|
boxServicesTempSensorState => { oid => '.1.3.6.1.4.1.4413.1.1.43.1.8.1.4', map => \%map_temp_status },
|
||||||
boxServicesTempSensorTemperature => { oid => '.1.3.6.1.4.1.4413.1.1.43.1.8.1.5' },
|
boxServicesTempSensorTemperature => { oid => '.1.3.6.1.4.1.4413.1.1.43.1.8.1.5' }
|
||||||
};
|
};
|
||||||
my $oid_boxServicesTempSensorsEntry = '.1.3.6.1.4.1.4413.1.1.43.1.8.1';
|
my $oid_boxServicesTempSensorsEntry = '.1.3.6.1.4.1.4413.1.1.43.1.8.1';
|
||||||
|
|
||||||
|
@ -60,28 +60,36 @@ sub check {
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{components}->{temperature}->{total}++;
|
$self->{components}->{temperature}->{total}++;
|
||||||
$self->{output}->output_add(long_msg => sprintf("temperature '%s' status is '%s' [instance = %s, temperature = %s]",
|
$self->{output}->output_add(
|
||||||
$instance, $result->{boxServicesTempSensorState}, $instance, defined($result->{boxServicesTempSensorTemperature}) ? $result->{boxServicesTempSensorTemperature} : 'unknown'));
|
long_msg => sprintf(
|
||||||
|
"temperature '%s' status is '%s' [instance = %s, temperature = %s]",
|
||||||
|
$instance, $result->{boxServicesTempSensorState}, $instance, defined($result->{boxServicesTempSensorTemperature}) ? $result->{boxServicesTempSensorTemperature} : 'unknown'
|
||||||
|
)
|
||||||
|
);
|
||||||
$exit = $self->get_severity(section => 'temperature', value => $result->{boxServicesTempSensorState});
|
$exit = $self->get_severity(section => 'temperature', value => $result->{boxServicesTempSensorState});
|
||||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||||
$self->{output}->output_add(severity => $exit,
|
$self->{output}->output_add(
|
||||||
short_msg => sprintf("Temperature '%s' status is '%s'", $instance, $result->{boxServicesTempSensorState}));
|
severity => $exit,
|
||||||
|
short_msg => sprintf("Temperature '%s' status is '%s'", $instance, $result->{boxServicesTempSensorState})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
next if (!defined($result->{boxServicesTempSensorTemperature}) || $result->{boxServicesTempSensorTemperature} !~ /[0-9]+/);
|
next if (!defined($result->{boxServicesTempSensorTemperature}) || $result->{boxServicesTempSensorTemperature} !~ /[0-9]+/);
|
||||||
|
|
||||||
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{boxServicesTempSensorTemperature});
|
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{boxServicesTempSensorTemperature});
|
||||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||||
$self->{output}->output_add(severity => $exit,
|
$self->{output}->output_add(
|
||||||
short_msg => sprintf("Temperature '%s' is '%s' rpm", $instance, $result->{boxServicesTempSensorTemperature}));
|
severity => $exit,
|
||||||
|
short_msg => sprintf("Temperature '%s' is '%s' rpm", $instance, $result->{boxServicesTempSensorTemperature})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$self->{output}->perfdata_add(
|
$self->{output}->perfdata_add(
|
||||||
label => 'temp', unit => 'C',
|
|
||||||
nlabel => 'hardware.temperature.celsius',
|
nlabel => 'hardware.temperature.celsius',
|
||||||
|
unit => 'C',
|
||||||
instances => $instance,
|
instances => $instance,
|
||||||
value => $result->{boxServicesTempSensorTemperature},
|
value => $result->{boxServicesTempSensorTemperature},
|
||||||
warning => $warn,
|
warning => $warn,
|
||||||
critical => $crit,
|
critical => $crit
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,12 @@ use base qw(centreon::plugins::templates::counter);
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
|
sub prefix_cpu_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return 'CPU ';
|
||||||
|
}
|
||||||
|
|
||||||
sub set_counters {
|
sub set_counters {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
@ -33,50 +39,39 @@ sub set_counters {
|
||||||
];
|
];
|
||||||
|
|
||||||
$self->{maps_counters}->{global} = [
|
$self->{maps_counters}->{global} = [
|
||||||
{ label => '5s', set => {
|
{ label => '5s', nlabel => 'cpu.utilization.5s.percentage', set => {
|
||||||
key_values => [ { name => 'usage_5s' } ],
|
key_values => [ { name => 'usage_5s' } ],
|
||||||
output_template => '%.2f %% (5sec)', output_error_template => "%s (5sec)",
|
output_template => '%.2f %% (5sec)', output_error_template => "%s (5sec)",
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'cpu_5s', value => 'usage_5s', template => '%.2f',
|
{ template => '%.2f', unit => '%', min => 0, max => 100 }
|
||||||
unit => '%', min => 0, max => 100 },
|
]
|
||||||
],
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => '1m', set => {
|
{ label => '1m', nlabel => 'cpu.utilization.1m.percentage', set => {
|
||||||
key_values => [ { name => 'usage_1m' } ],
|
key_values => [ { name => 'usage_1m' } ],
|
||||||
output_template => '%.2f %% (1m)', output_error_template => "%s (1min)",
|
output_template => '%.2f %% (1m)', output_error_template => "%s (1min)",
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'cpu_1m', value => 'usage_1m', template => '%.2f',
|
{ template => '%.2f', unit => '%', min => 0, max => 100 }
|
||||||
unit => '%', min => 0, max => 100 },
|
]
|
||||||
],
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => '5m', set => {
|
{ label => '5m', nlabel => 'cpu.utilization.5m.percentage', set => {
|
||||||
key_values => [ { name => 'usage_5m' } ],
|
key_values => [ { name => 'usage_5m' } ],
|
||||||
output_template => '%.2f %% (5min)', output_error_template => "%s (5min)",
|
output_template => '%.2f %% (5min)', output_error_template => "%s (5min)",
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'cpu_5m', value => 'usage_5m', template => '%.2f',
|
{ template => '%.2f', unit => '%', min => 0, max => 100 }
|
||||||
unit => '%', min => 0, max => 100 },
|
]
|
||||||
],
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
sub prefix_cpu_output {
|
|
||||||
my ($self, %options) = @_;
|
|
||||||
|
|
||||||
return "CPU ";
|
|
||||||
}
|
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ($class, %options) = @_;
|
my ($class, %options) = @_;
|
||||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments =>
|
$options{options}->add_options(arguments => {});
|
||||||
{
|
|
||||||
});
|
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ sub set_system {
|
||||||
['notpowering', 'WARNING'],
|
['notpowering', 'WARNING'],
|
||||||
['powering', 'OK'],
|
['powering', 'OK'],
|
||||||
['nopower', 'OK'],
|
['nopower', 'OK'],
|
||||||
['incompatible', 'WARNING'],
|
['incompatible', 'WARNING']
|
||||||
],
|
],
|
||||||
temperature => [
|
temperature => [
|
||||||
['low', 'OK'],
|
['low', 'OK'],
|
||||||
|
@ -49,8 +49,8 @@ sub set_system {
|
||||||
['critical', 'CRITICAL'],
|
['critical', 'CRITICAL'],
|
||||||
['notpresent', 'OK'],
|
['notpresent', 'OK'],
|
||||||
['shutdown', 'OK'],
|
['shutdown', 'OK'],
|
||||||
['notoperational', 'WARNING'],
|
['notoperational', 'WARNING']
|
||||||
],
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
$self->{components_path} = 'centreon::common::broadcom::fastpath::snmp::mode::components';
|
$self->{components_path} = 'centreon::common::broadcom::fastpath::snmp::mode::components';
|
||||||
|
@ -66,7 +66,7 @@ sub snmp_execute {
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ($class, %options) = @_;
|
my ($class, %options) = @_;
|
||||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
|
|
|
@ -28,17 +28,23 @@ use warnings;
|
||||||
sub custom_usage_perfdata {
|
sub custom_usage_perfdata {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{output}->perfdata_add(label => 'used', unit => 'B',
|
$self->{output}->perfdata_add(
|
||||||
|
nlabel => 'memory.usage.bytes',
|
||||||
|
unit => 'B',
|
||||||
value => $self->{result_values}->{used},
|
value => $self->{result_values}->{used},
|
||||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, total => $self->{result_values}->{total}, cast_int => 1),
|
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, 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),
|
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}, total => $self->{result_values}->{total}, cast_int => 1),
|
||||||
min => 0, max => $self->{result_values}->{total});
|
min => 0, max => $self->{result_values}->{total}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub custom_usage_threshold {
|
sub custom_usage_threshold {
|
||||||
my ($self, %options) = @_;
|
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' } ]);
|
my $exit = $self->{perfdata}->threshold_check(
|
||||||
|
value => $self->{result_values}->{prct_used},
|
||||||
|
threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' } ]
|
||||||
|
);
|
||||||
return $exit;
|
return $exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,11 +55,12 @@ sub custom_usage_output {
|
||||||
my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used});
|
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 ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free});
|
||||||
|
|
||||||
my $msg = sprintf("Memory Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
|
return sprintf(
|
||||||
|
"Memory Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
|
||||||
$total_size_value . " " . $total_size_unit,
|
$total_size_value . " " . $total_size_unit,
|
||||||
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used},
|
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used},
|
||||||
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free});
|
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free}
|
||||||
return $msg;
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub custom_usage_calc {
|
sub custom_usage_calc {
|
||||||
|
@ -82,20 +89,18 @@ sub set_counters {
|
||||||
closure_custom_calc => $self->can('custom_usage_calc'),
|
closure_custom_calc => $self->can('custom_usage_calc'),
|
||||||
closure_custom_output => $self->can('custom_usage_output'),
|
closure_custom_output => $self->can('custom_usage_output'),
|
||||||
closure_custom_perfdata => $self->can('custom_usage_perfdata'),
|
closure_custom_perfdata => $self->can('custom_usage_perfdata'),
|
||||||
closure_custom_threshold_check => $self->can('custom_usage_threshold'),
|
closure_custom_threshold_check => $self->can('custom_usage_threshold')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ($class, %options) = @_;
|
my ($class, %options) = @_;
|
||||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments =>
|
$options{options}->add_options(arguments =>{ });
|
||||||
{
|
|
||||||
});
|
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
@ -110,7 +115,7 @@ sub manage_selection {
|
||||||
my $total = $snmp_result->{$oid_agentSwitchCpuProcessMemAvailable} * 1024;
|
my $total = $snmp_result->{$oid_agentSwitchCpuProcessMemAvailable} * 1024;
|
||||||
$self->{memory} = {
|
$self->{memory} = {
|
||||||
prct_used => ($total - $snmp_result->{$oid_agentSwitchCpuProcessMemFree} * 1024) * 100 / $total,
|
prct_used => ($total - $snmp_result->{$oid_agentSwitchCpuProcessMemFree} * 1024) * 100 / $total,
|
||||||
total => $total,
|
total => $total
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue