Skip to content
Snippets Groups Projects
Commit ed903e97 authored by Eric Sproul's avatar Eric Sproul
Browse files

Allow escaped commas in config parameters. Update Core::SMART docs and stop...

Allow escaped commas in config parameters.  Update Core::SMART docs and stop prefixing metrics with the disk name, as Resmon already uses check_name in the final metric output.
parent a911b45c
No related branches found
No related tags found
No related merge requests found
......@@ -16,7 +16,7 @@ Core::SMART - pulls SMART values from disk drives
=head1 SYNOPSIS
Core::SMART {
sda : smartctl_cmd => /usr/sbin/smartctl , smartctl_args => -d sat
sda : smartctl_cmd => /usr/sbin/smartctl , smartctl_args => -d sat\,12
}
=head1 DESCRIPTION
......@@ -46,14 +46,17 @@ Optional list of additional arguments that will be passed to smartctl.
The default arguments are "-i -A". Any arguments specified here will be
added to this list.
If the argument contains a comma, it must be escaped with a backslash.
=back
=head1 METRICS
Each of the following metric names will be prefixed with the disk name.
The SMART attribute data is highly vendor-specific. Each attribute will produce
two metrics, one with the normalized value and one with the raw value.
The SMART attribute data is highly vendor-specific. Post-processing may be
desirable in specific cases, such as when the value as hex has special meaning.
Post-processing may be desirable in specific cases, such as when the value as
hex has special meaning.
=over
......@@ -71,8 +74,7 @@ Device firmware version as reported in the information section.
=item (attribute)
Each attribute reported in the data section will be returned by name. The value
will be the normalized value and is expected to be an integer.
The normalized value of the attribute, expected to be an integer.
=item (attribute)_raw
......@@ -82,18 +84,6 @@ The raw value of the attribute, expected to be an integer.
=cut
sub new {
# This is only needed if you have initialization code. Most of the time,
# you can skip the new method and just implement a handler method.
my ($class, $check_name, $config) = @_;
my $self = $class->SUPER::new($check_name, $config);
# Add initialization code here
bless($self, $class);
return $self;
}
sub handler {
my $self = shift;
my $config = $self->{config};
......@@ -109,18 +99,18 @@ sub handler {
foreach my $line (split(/\n/, $output)) {
if ($line =~ /^Device Model:\s+(.+)$/) {
$smartdata->{"$self->{check_name}_model"} = [$1, "s"];
$smartdata->{"model"} = [$1, "s"];
}
elsif ($line =~ /^Serial Number:\s+(.+)$/) {
$smartdata->{"$self->{check_name}_serial"} = [$1, "s"];
$smartdata->{"serial"} = [$1, "s"];
}
elsif ($line =~ /^Firmware Version:\s+(.+)$/) {
$smartdata->{"$self->{check_name}_fw"} = [$1, "s"];
$smartdata->{"fw"} = [$1, "s"];
}
# Capture attribute_name, value, raw_value (columns 2,4,10)
elsif ($line =~ /^\s*\d+\s(\S+)\s+\S+\s+(\S+)\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+(\S+)/) {
$smartdata->{"$self->{check_name}_$1"} = [$2, "i"];
$smartdata->{"$self->{check_name}_$1_raw"} = [$3, "i"];
$smartdata->{"$1"} = [$2, "i"];
$smartdata->{"$1_raw"} = [$3, "i"];
}
}
......
......@@ -62,7 +62,8 @@ sub new {
next if $current eq "BAD_MODULE";
my $kvs = {};
my $check_name = $1;
my @params = split(/,/, $2);
my @params = split(/(?<!\\),/, $2);
grep { s/\\(.)/$1/ } @params;
grep { $kvs->{$1} = $2 if /^\s*(\S+)\s*=>\s*(\S(?:.*\S)?)\s*$/ }
@params;
my $object;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment