Closed acranox closed 9 years ago
Wouldn't be more readable the code inserting the 190 if
right before the 194 if
as an standalone condition?
This way the code flux would be; try first to see if there is the 190, if not, then try with 194, and if not, then try with Current Drive Temperature
, (in fallback order).
Just like this:
if(/^ 5/ && /Reallocated_Sector_Ct/) {
my @tmp = split(' ', $_);
$smart1 = $tmp[9];
chomp($smart1);
}
if(/^190/ && /Airflow_Temperature_Cel/) {
my @tmp = split(' ', $_);
$temp = $tmp[9];
chomp($temp);
}
if(/^194/ && /Temperature_Celsius/) {
my @tmp = split(' ', $_);
$temp = $tmp[9];
chomp($temp);
}
if(/^197/ && /Current_Pending_Sector/) {
my @tmp = split(' ', $_);
$smart2 = $tmp[9];
chomp($smart2);
}
if(/^Current Drive Temperature: /) {
my @tmp = split(' ', $_);
$temp = $tmp[3] unless $temp;
chomp($temp);
}
What do you think?
I'm guessing value 194 is the preferred value, so maybe 190 can be the first fallback, and then Current Drive Temperature (although i'm not sure where that comes from.) I'm not really sure if there's a norm around which manufacturers use which SMART fields.
if(/^ 5/ && /Reallocated_Sector_Ct/) {
my @tmp = split(' ', $_);
$smart1 = $tmp[9];
chomp($smart1);
}
if(/^194/ && /Temperature_Celsius/) {
my @tmp = split(' ', $_);
$temp = $tmp[9];
chomp($temp);
}
if(/^190/ && /Airflow_Temperature_Cel/) {
my @tmp = split(' ', $_);
$temp = $tmp[9] unless $temp;
chomp($temp);
}
if(/^197/ && /Current_Pending_Sector/) {
my @tmp = split(' ', $_);
$smart2 = $tmp[9];
chomp($smart2);
}
if(/^Current Drive Temperature: /) {
my @tmp = split(' ', $_);
$temp = $tmp[3] unless $temp;
chomp($temp);
}
I'm not sure if manufacturers follow all standards ;)
Anyway, it's fine for me, no problem to have 190 as the first fallback, so remove your current pull request and do a new one with this schema and I'll be glad to merge it.
Thanks.
Thanks.
I replaced a spinning disk with a new SSD, and apparently it reports the temperature on smart ID 190 instead of 194.
190 Airflow_Temperature_Cel 0x0032 068 058 000 Old_age Always - 32
So monitorix isn't picking this up. Can some logic be added to use this value instead of what's in 194 if it's not available?