LM Sensors Monitoring Prooblem.

Post support questions that directly relate to Linux/Unix operating systems.

Moderators: Developers, Moderators

Post Reply
JabawokJayUK
Posts: 3
Joined: Wed Jul 21, 2004 7:41 am

LM Sensors Monitoring Prooblem.

Post by JabawokJayUK »

I am using the following script to monitor my lm sensors:

[root@nukleuz cacti]# cat scripts/check_sensors.pl
#!/usr/bin/perl

@sensoroutput=`/usr/bin/sensors`;

foreach(@sensoroutput) {
chomp();
split();
if ( "$_[0] Temp:" eq 'M/B Temp:' ) {
$temp1 = $_[2];
}
if ( "$_[0] Temp:" eq 'CPU Temp:' ) {
$temp2 = $_[2];
}
if ( $_[0] eq 'Temp3:' ) {
$temp3 = $_[1];
}
if ( $_[0] eq 'fan1:' ) {
$fan1 = $_[1];
}
if ( $_[0] eq 'fan2:' ) {
$fan2 = $_[1];
}
if ( $_[0] eq 'fan3:' ) {
$fan3 = $_[1];
}
}
$temp1 =~ s/\+//;
$temp1 =~ s/\°C//;
$temp2 =~ s/\+//;
$temp2 =~ s/\°C//;
$temp3 =~ s/\+//;
$temp3 =~ s/\°C//;

print "$fan1 $fan2 $fan3 $temp1 $temp2 $temp3\n";

I have created my Input Sources, Input methods & Graphs etc correctley, but my graphs contain no data.

if i run cmd.php from the cmd line this is what i get :

[root@nukleuz cacti]# php cmd.php
Content-type: text/html
X-Powered-By: PHP/4.3.6

command: perl /var/www/html/cacti/scripts/linux_memory.pl MemFree:, output: 477076
command: perl /var/www/html/cacti/scripts/linux_memory.pl SwapFree:, output: 2040244
MULTI command: perl /var/www/html/cacti/scripts/loadavg_multi.pl, output: 1min:0.00 5min:0.00 10min:0.00
MULTI expansion: found fieldid: 17, found rrdname: load_1min, value: 0.00
MULTI expansion: found fieldid: 18, found rrdname: load_5min, value: 0.00
MULTI expansion: found fieldid: 19, found rrdname: load_15min, value: 0.00
command: perl /var/www/html/cacti/scripts/unix_users.pl, output: 2
command: perl /var/www/html/cacti/scripts/unix_processes.pl, output: 78
command: perl /var/www/html/cacti/scripts/query_unix_partitions.pl get available /dev/sda2, output: 179400784
command: perl /var/www/html/cacti/scripts/query_unix_partitions.pl get used /dev/sda2, output: 45894084
command: perl /var/www/html/cacti/scripts/query_unix_partitions.pl get available /dev/sdb1, output: 46858876
command: perl /var/www/html/cacti/scripts/query_unix_partitions.pl get used /dev/sdb1, output: 182149508
MULTI command: perl /var/www/html/cacti/scripts/check_sensors.pl, output: 2220 1622 3308 39 32 41

MULTI command: perl /var/www/html/cacti/scripts/check_sensors.pl, output: 2220 1622 3308 39 32 41

MULTI command: perl /var/www/html/cacti/scripts/check_sensors.pl, output: 2220 1622 3308 39 32 41

MULTI command: perl /var/www/html/cacti/scripts/check_sensors.pl, output: 2220 1622 3308 39 32 41

MULTI command: perl /var/www/html/cacti/scripts/check_sensors.pl, output: 2220 1622 3308 39 32 41

MULTI command: perl /var/www/html/cacti/scripts/check_sensors.pl, output: 2220 1622 3308 39 32 41

update /var/www/html/cacti/rra/localhost_mem_buffers_3.rrd --template mem_buffers N:477076
update /var/www/html/cacti/rra/localhost_mem_swap_4.rrd --template mem_swap N:2040244
update /var/www/html/cacti/rra/localhost_load_1min_5.rrd --template load_1min:load_5min:load_15min N:0.00:0.00:0.00
update /var/www/html/cacti/rra/localhost_users_6.rrd --template users N:2
update /var/www/html/cacti/rra/localhost_proc_7.rrd --template proc N:78
update /var/www/html/cacti/rra/localhost_hdd_free_9.rrd --template hdd_free:hdd_used N:179400784:45894084
update /var/www/html/cacti/rra/localhost_hdd_free_10.rrd --template hdd_free:hdd_used N:46858876:182149508
time: 1

As you can see it is not updating the rra's for the lmsensors, but they do exist:

[root@nukleuz cacti]# ls -l rra/
total 920
-rw-r--r-- 1 root root 47836 Jul 21 13:30 fan1_19.rrd
-rw-r--r-- 1 root root 47836 Jul 21 11:40 localhost_fan1_12.rrd
-rw-r--r-- 1 root root 47836 Jul 21 11:40 localhost_fan2_13.rrd
-rw-r--r-- 1 root root 47836 Jul 21 12:50 localhost_fan2_18.rrd
-rw-r--r-- 1 root root 47836 Jul 21 11:40 localhost_fan3_14.rrd
-rw-r--r-- 1 root root 94660 Jul 21 13:46 localhost_hdd_free_10.rrd
-rw-r--r-- 1 root root 94660 Jul 21 13:46 localhost_hdd_free_9.rrd
-rw-r--r-- 1 root root 141484 Jul 21 13:46 localhost_load_1min_5.rrd
-rw-r--r-- 1 root root 47836 Jul 21 13:46 localhost_mem_buffers_3.rrd
-rw-r--r-- 1 root root 47836 Jul 21 13:46 localhost_mem_swap_4.rrd
-rw-r--r-- 1 root root 47836 Jul 21 13:46 localhost_proc_7.rrd
-rw-r--r-- 1 root root 47836 Jul 21 11:40 localhost_temp1_15.rrd
-rw-r--r-- 1 root root 47836 Jul 21 11:40 localhost_temp2_16.rrd
-rw-r--r-- 1 root root 47836 Jul 21 11:40 localhost_temp3_17.rrd
-rw-r--r-- 1 root root 47836 Jul 21 13:46 localhost_users_6.rrd

I am completeley stumped on this and would appreciate any help or advice that you can offer!!!
Guest

Re: LM Sensors Monitoring Prooblem.

Post by Guest »

JabawokJayUK wrote:I am using the following script to monitor my lm sensors:

[root@nukleuz cacti]# cat scripts/check_sensors.pl
#!/usr/bin/perl

@sensoroutput=`/usr/bin/sensors`;

[...]
print "$fan1 $fan2 $fan3 $temp1 $temp2 $temp3\n";
[...]
I use
print "rpm1:$fan1 rpm2:$fan2 rpm3:$fan3";
for
update fans.rrd --template rpm1:rpm2:rpm3 N:1000:2000:3000

and
print "temp1:$temp1 temp2:$temp2 temp3:$temp3";
for
update temps.rrd --template temp1:temp2:temp3 N:40:50:60
JabawokJayUK
Posts: 3
Joined: Wed Jul 21, 2004 7:41 am

Post by JabawokJayUK »

Ok i have changed my script to output this:

print "rpm1:$fan1 rpm2:$fan2 rpm3:$fan3 temp1:$temp1 temp2:$temp2 temp3:$temp3\n";

which gives this:

rpm1:2220 rpm2:1622 rpm3:3375 temp1:41 temp2:33 temp3:43

But how do i get the rrd update bit sorted?
JabawokJayUK
Posts: 3
Joined: Wed Jul 21, 2004 7:41 am

Post by JabawokJayUK »

ok, i have been playing and now i get this

[root@nukleuz scripts]# php ../cmd.php
Content-type: text/html
X-Powered-By: PHP/4.3.6

command: perl /var/www/html/cacti/scripts/linux_memory.pl SwapFree:, output: 2040244
MULTI command: perl /var/www/html/cacti/scripts/loadavg_multi.pl, output: 1min:0.07 5min:0.04 10min:0.00
MULTI expansion: found fieldid: 17, found rrdname: load_1min, value: 0.07
MULTI expansion: found fieldid: 18, found rrdname: load_5min, value: 0.04
MULTI expansion: found fieldid: 19, found rrdname: load_15min, value: 0.00
command: perl /var/www/html/cacti/scripts/unix_users.pl, output: 2
command: perl /var/www/html/cacti/scripts/unix_processes.pl, output: 79
command: perl /var/www/html/cacti/scripts/query_unix_partitions.pl get used /dev/sda2, output: 45901476
command: perl /var/www/html/cacti/scripts/query_unix_partitions.pl get available /dev/sda2, output: 179393392
command: perl /var/www/html/cacti/scripts/query_unix_partitions.pl get used /dev/sdb1, output: 182149508
command: perl /var/www/html/cacti/scripts/query_unix_partitions.pl get available /dev/sdb1, output: 46858876
command: perl /var/www/html/cacti/scripts/linux_memory.pl MemFree:, output: 455692
command: perl /var/www/html/cacti/scripts/check_sensors.pl, output: fan1:2220 fan2:1622 fan3:3308 temp1:41 temp2:34 temp3:43

update /var/www/html/cacti/rra/localhost_mem_swap_4.rrd --template mem_swap N:2040244
update /var/www/html/cacti/rra/localhost_load_1min_5.rrd --template load_1min:load_5min:load_15min N:0.07:0.04:0.00
update /var/www/html/cacti/rra/localhost_users_6.rrd --template users N:2
update /var/www/html/cacti/rra/localhost_proc_7.rrd --template proc N:79
update /var/www/html/cacti/rra/localhost_hdd_free_9.rrd --template hdd_used:hdd_free N:45901476:179393392
update /var/www/html/cacti/rra/localhost_hdd_free_10.rrd --template hdd_used:hdd_free N:182149508:46858876
update /var/www/html/cacti/rra/localhost_mem_buffers_20.rrd --template mem_buffers N:455692
update /var/www/html/cacti/rra/localhost_lmsensors_25.rrd --template temp1 N:fan1:2220 fan2:1622 fan3:3308 temp1:41 temp2:34 temp3:43
ERROR: expected 1 data source readings (got 2) from N:fan1:2220:...
time: 0

HELP!!!
wols
Posts: 4
Joined: Wed Jul 21, 2004 1:28 pm
Location: Germany

Post by wols »

JabawokJayUK wrote:ok, i have been playing and now i get this

[...]
update /var/www/html/cacti/rra/localhost_lmsensors_25.rrd --template temp1 N:fan1:2220 fan2:1622 fan3:3308 temp1:41 temp2:34 temp3:43
ERROR: expected 1 data source readings (got 2) from N:fan1:2220:...
time: 0

HELP!!!
You must make a RRD with all six datasources
in Cacti->Data Sources->Your Source
---8<-----8<-----
DS:fan1:GAUGE:600:0:U \
DS:fan2:GAUGE:600:0:U \
DS:fan3:GAUGE:600:0:U \
DS:temp1:GAUGE:600:0:U \
DS:temp2:GAUGE:600:0:U \
DS:temp3:GAUGE:600:0:U \
---8<-----8<-----
(not probed).

But a idea is fans and temperatures in two RRD's.

PS: At my first posting I was guest ;-)
With friendly greetings
*WOL* fgang *S* chricker
*HOME* http://www.wols.org/
Hab

Post by Hab »

Hy, I just done that, and suffer a lot to make it work :o))
So I really enjoy to share it !!

Anyway, here's how I did it:

I started with a scripts similar to yours and finally modified it to:

check_sensors.pl
  • @sensoroutput=`/usr/bin/sensors`;

    foreach(@sensoroutput) {
    chomp();
    split();
    if ( $_[0] eq 'Vcore:' ) {
    $Vcore = $_[1];
    }
    if ( $_[0] eq '3.3V:' ) {
    $V33V = $_[1];
    }
    if ( $_[0] eq '5V:' ) {
    $V5V = $_[1];
    }
    if ( $_[0] eq '12V:' ) {
    $V12V = $_[1];
    }
    if ( $_[0] eq 'CPU_Fan:' ) {
    $CPUFan = $_[1];
    }
    if ( $_[0] eq 'PWR_Fan:' ) {
    $PWRFan = $_[1];
    }
    if ( $_[0] eq 'SYS_Temp:' ) {
    $SYSTemp = $_[1];
    }
    if ( $_[0] eq 'CPU_Temp:' ) {
    $CPUTemp = $_[1];
    }
    }
    $CPUTemp =~ s/\+//;
    $CPUTemp =~ s/\°C//;
    $SYSTemp =~ s/\+//;
    $SYSTemp =~ s/\°C//;

    print "Vcore:$Vcore V33V:$V33V V5V:$V5V V12V:$V12V CPUFan:$CPUFan PWRFan:$PWRFan SYSTemp:$SYSTemp CPUTemp:$CPUTemp\n";
In the Data Input Methods, I created a new one with the Fields like this:

Data Input Methods [edit: Get LM Sensors]
Name: Get LM Sensors
Input Type: Scripts/Command
Input String: perl /usr/share/cacti/scripts/check_sensors.pl

Input Fields Add
Name Field Order Friendly Name
No Input Fields

Output Fields Add
Name Field Order Friendly Name Update RRA
V33V 0 (Not In Use) 3.3 V Selected
VCore 0 (Not In Use) Core Voltage Selected
V5V 0 (Not In Use) 5 V Selected
V12V 0 (Not In Use) 12 V Selected
CPUFan 0 (Not In Use) CPU Fan speed Selected
PWRFan 0 (Not In Use) Mobo Fan Speed Selected
SYSTemp 0 (Not In Use) Mobo Temperature Selected
CPUTemp 0 (Not In Use) CPU Temperature Selected

After that, it's the same as your's, the Data sources you created must have ont Data Source Item per mesurement, each one mapped on one output fields that is available.

I hope it will help you !!

If anyone have a trick so that I can convert this one to Template without losing the existing mesures, I could post the XML file there.
drywalldude
Posts: 11
Joined: Fri Jan 28, 2005 9:41 pm
Location: USA
Contact:

No Results when I run this script

Post by drywalldude »

Heres what I get

[root@linuxserver scripts]# perl check_sensors.pl
Vcore: V33V: V5V: V12V: CPUFan: PWRFan: SYSTemp: CPUTemp:
[root@linuxserver scripts]# sensors
eeprom-i2c-0-51
Adapter: SMBus Via Pro adapter at 0400
Memory type: DDR SDRAM DIMM
Memory size (MB): 512

w83697hf-isa-0290
Adapter: ISA adapter
VCore: +1.76 V (min = +1.71 V, max = +1.89 V)
+3.3V: +3.30 V (min = +3.14 V, max = +3.46 V)
+5V: +5.02 V (min = +4.74 V, max = +5.24 V)
+12V: +12.46 V (min = +10.83 V, max = +13.19 V)
-12V: -12.19 V (min = -13.16 V, max = -10.90 V)
-5V: -5.10 V (min = -5.26 V, max = -4.76 V)
V5SB: +5.54 V (min = +4.74 V, max = +5.24 V)
VBat: +3.41 V (min = +2.40 V, max = +3.60 V)
fan1: 4821 RPM (min = -1 RPM, div = 2)
fan2: 3409 RPM (min = -1 RPM, div = 2)
temp1: +30°C (high = +0°C, hyst = +16°C) sensor = thermistor
temp2: +39.0°C (high = +80°C, hyst = +75°C) sensor = thermistor
alarms:
beep_enable:
Sound alarm disabled

LM_Sensors works on the local machine but not being read through this script
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests