fix the order of magnitude in the values collected #159

This commit is contained in:
Jordi Sanfeliu 2016-10-05 18:21:52 +02:00
parent eb20c7d077
commit 23a3574baa
3 changed files with 14 additions and 3 deletions

View File

@ -143,12 +143,14 @@ sub gensens_update {
if($gensens->{desc}->{$str}) {
if(open(IN, $gensens->{desc}->{$str})) {
my $unit;
my $c;
$val = <IN>;
$val = trim($val);
$unit = $gensens->{unit}->{$str} || 0;
$val /= $unit if $unit > 1;
$val *= $unit if $unit > 0 && $unit < 1;
$c = () = $unit =~ /0/g;
$val /= 10**$c if $unit > 1;
$val *= 10**$c if $unit > 0 && $unit < 1;
close(IN);
} else {
logger("$myself: ERROR: unable to open '$gensens->{desc}->{$str}'.");

View File

@ -827,7 +827,7 @@ In this option you must associate the complete pathname of the file from where t
.RE
.BI unit
.RS
With this option you can define the order of magnitude associated to a specific value. This is normally used only in temperatures because these sensors tend to give the value in 1000ths of degrees Celsius. Therefore you can define something like this:
With this option you can define the order of magnitude associated to a specific value. This is used in both temperatures and CPU frequencies, since this kind of temperature sensors tend to give the value in 1000ths of degrees Celsius. In the case of CPU frequencies the values come in Mhz which means that they need to be converted to Hz by multiplying them by 1000. Therefore you can define something like this:
.P
.RS
<unit>
@ -835,6 +835,14 @@ With this option you can define the order of magnitude associated to a specific
temp0 = 1000
.br
temp1 = 1000
.br
cpu0 = 0.001
.br
cpu1 = 0.001
.br
cpu2 = 0.001
.br
cpu3 = 0.001
.br
</unit>
.RE

View File

@ -211,6 +211,7 @@ secure_log_date_format = %b %e
</desc>
<unit>
temp0 = 1000
cpu0 = 0.001
</unit>
<map>
temp0 = Temperature Zone 0