Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Motherboard Temperature

by Bruce32903 (Scribe)
on Aug 05, 2006 at 15:00 UTC ( #565803=perlquestion: print w/ replies, xml ) Need Help??
Bruce32903 has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to develop the ability to read the temperature sensors on my motherboard with perl. I have been doing a lot of Googling and have learned quite a bit. But, I seem to be running out of time faster than I am running out of things to learn. Thus, I'm hoping someone out there has done something similar and can give me a little help.

Here are a few details of where I am at:

OS: The system has Win-XP on it. Thus, it would be nice to be able to use something like ActivePerl (www.activestate.com) and XP. I would prefer to use Linux, but it is an XP box so this has to be on my wish list. There will be times when I must be running XP and a live-CD will not always be an option.

LINUX can be run at times from a live CD. Damn Small Linux (www.damnsmalllinux.org) with its MyDSL system for adding packages looks very handy. The Damn Small Linux - Not (www.damnsmalllinux.org/dsl-n/) big brother looks even better.

MOTHERBOARD: Ampro LittleBoard 800 with a Pentium M processor.

The motherboard has an Intel 82810DB I/O controller hub "Northbridge" on the System Management Bus (SMBus) at $D800 as reported by SpeedFan.

The motherboard has an Analog Devices ADM1021 temperature chip on the SMBus at $4E as reported by SpeedFan.

The SpeedFan 4.29 package (www.almico.com/speedfan.php) found two temperature sensors on the motherboard and one in the hard drive. The motherboard sensors are accessed via the SMBus (www.smbus.org/specs/) and the hard drive sensor is accesses via the Self Monitoring Analysis and Reporting Technology System (SMART).

Included is a dump of the information available through SpeedFan. Most of it makes sense but I don't know how to get to it from perl. I don't know what is being referred to with the "sensors base address = $0C00" statement. This address doesn't match the SMBus or other sensor address given.

There are probably sensors or LMsensors packages available that will be helpful on the Linux operating system. I doubt that there is a similar resource available under Win-XP.

=== READINGS TAB of SpeedFan ===
Win9x:NO 64Bit:NO GiveIO:YES SpeedFan:YES
I/O properly initialized
Linked ISA BUS at $0290
Linked Intel 82801DB ICH4 SMBUS at $D800
Scanning ISA BUS at $0290...
SuperIO Chip=LPC47b27x
Sensor's Base Address : $0C00
Scanning Intel SMBus at $D800...
ADM1021 (ID=$00) found on SMBus at $4E
SMART Enabled for drive 0
Found HTC426060G9AT00 (60.0GB)
End of detection

=== REPORTED TEMPERATURES by SpeedFan ===
Local Temp: 28C
Remote Temp: 44C
HD0: 28C

=== INFO TAB of SpeedFan ===
Scanning SMBus at $D800...
Decoding DIMM #0
Memory type is DDR
Module Rows : 2
Levels : 2.5V
Parity : NO PARITY
Refresh Rate : 7.8us
Total Size : 1024MB

Bottom line ... I would like to read the two SMBus motherboard temperature sensors and the one SMART hard drive temperature sensor from perl. Linux is my preferred OS (live-CD would be used), XP is the OS that must be permanently on the box. Any ideas or suggestions would be appreciated.

Thank you,
Bruce

Comment on Motherboard Temperature
Re: Motherboard Temperature
by Joost (Canon) on Aug 05, 2006 at 15:48 UTC
Re: Motherboard Temperature
by idle (Pilgrim) on Aug 05, 2006 at 16:40 UTC
Re: Motherboard Temperature
by rodion (Chaplain) on Aug 05, 2006 at 16:59 UTC
    You may need a product such as TVicPort to get direct access to the hardwar IO ports, if the package included in the hardware down't already have a dll to do this. (In either case, you have to set up access from perl to the DLL.)

    Direct access to the serial IO ports is specially allowed in Win32. Access to the other IO addresses is generally restriced. Maybe another monk knows of a module to get around this and go direct to the hardware.

Re: Motherboard Temperature
by planetscape (Canon) on Aug 05, 2006 at 17:02 UTC

    Here is a Perl script that might be just what you are looking for (or might at least get you started):

    Computer Fan Information

    HTH,

    planetscape
Re: Motherboard Temperature
by Corion (Pope) on Aug 05, 2006 at 20:28 UTC

    Under Windows, the WMI supplies this information. I wrote a module, DBD::WMI, which makes access to the WMI via WQL possible:

    #!/usr/bin/perl -w package main; use strict; use DBI; my $dbh = DBI->connect('dbi:WMI:'); my $sth = $dbh->prepare(<<WQL); SELECT * FROM Win32_TemperatureInfo WQL $sth->execute(); while (defined (my $row = $sth->fetchrow_arrayref())) { my $temp = $row->[0]; print join "\t", $temp->Name, $temp->NominalReading, $temp->Curren +tReading; print "\n"; }

    According to the MSDN, this query should give you all readings from all sensors, but on my (Win2k) machine, no temperature probe is returned, so I don't know whether this is a problem with my program, with Win2k, or whether my mainboard doesn't have any supported temperature sensors.

    According to Google Groups, not all mainboard drivers support the WMI, so you might be out of luck there.

    The WMI provides lots of management information about Windows and Windows machines - it's well worth a look.

Re: Motherboard Temperature
by Bruce32903 (Scribe) on Aug 05, 2006 at 23:49 UTC
    Thanks for the help so far. I will try the suggestions as soon as I can.

    My goal is to be able to log temperature from the CPU, Northbridge, HDD and several additional temperature sensors. This logging will be done over hours as the equipment warms up. Thus, perl is not the only solution, but it is a good one.

    Thanks,
    Bruce
      MBM5 (http://mbm.livewiredev.com/) is the tool I use under XP. It provides a GUI to monitor temperatures, fan speeds and voltages. It also logs to various file formats, e. g. CSV, syslog or windows event monitor. Development has stopped in 2004, so you might get into trouble with newer hardware.

      I'd recommend not trying to reinvent the wheel with perl. The utilities section of all major freeware sites have programms similar to MBM5.

Re: Motherboard Temperature
by Moron (Curate) on Aug 07, 2006 at 11:27 UTC
    If you mean how do you capture output from such a tool into Perl, then where the rules of the "language" are simple enough, as in this case, the match operator can be used to detect and read the data.
    use strict; use warnings; use POSIX ":sys_wait_h"; my $pid = open my $filehandle, "| speedfan"; # or whatever command it is my ($ltemp, $rtemp, $hdo); while( <$filehandle> ) { #reads the line into predeclared $_ # per line loop of output e.g. ... /^Local Temp:\s(\d+)C/ and $ltemp = $1 and next; /^Remote Temp:\s(\d+)C/ and $rtemp = $1 and next; /^HDO:\s(\d+)C/ and $hdo = $1; } close $filehandle; waitpid $pid,0; # wait for subprocess to terminate # $ltemp, $rtemp and $hdo now contain the temperatures.
    In this case we assumed that the temperatures matched the expression \d+ (1 or more digits). A slightly more sophisticated expression is needed to match floating point data.

    -M

    Free your mind

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://565803]
Approved by socketdave
Front-paged by TStanley
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2014-08-30 07:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (291 votes), past polls