From 23a3574baaf5ff2a1bcfc6ff15e7d7f71450bf80 Mon Sep 17 00:00:00 2001 From: Jordi Sanfeliu Date: Wed, 5 Oct 2016 18:21:52 +0200 Subject: [PATCH] fix the order of magnitude in the values collected #159 --- lib/gensens.pm | 6 ++++-- man/man5/monitorix.conf.5 | 10 +++++++++- monitorix.conf | 1 + 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/gensens.pm b/lib/gensens.pm index 9010bd6..e6e675d 100644 --- a/lib/gensens.pm +++ b/lib/gensens.pm @@ -143,12 +143,14 @@ sub gensens_update { if($gensens->{desc}->{$str}) { if(open(IN, $gensens->{desc}->{$str})) { my $unit; + my $c; $val = ; $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}'."); diff --git a/man/man5/monitorix.conf.5 b/man/man5/monitorix.conf.5 index 484bd14..a1853c2 100644 --- a/man/man5/monitorix.conf.5 +++ b/man/man5/monitorix.conf.5 @@ -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 @@ -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 .RE diff --git a/monitorix.conf b/monitorix.conf index 3d9c786..29e1390 100644 --- a/monitorix.conf +++ b/monitorix.conf @@ -211,6 +211,7 @@ secure_log_date_format = %b %e temp0 = 1000 + cpu0 = 0.001 temp0 = Temperature Zone 0