Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    How to: Get CPU temp

    Scheduled Pinned Locked Moved 2.0-RC Snapshot Feedback and Problems - RETIRED
    140 Posts 24 Posters 115.8k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      RedRep
      last edited by

      I've got pfSense running on an Intel Atom N270 and I was kinda worried about CPU temps because the CPU is passively cooled.  I tried adding the mbmon package but it couldn't find any sensors to read.

      [2.0-RC3][root@pfsense.ph.cox.net]/boot/kernel(48): mbmon
      No Hardware Monitor found!!
      InitMBInfo: Unknown error: 0
      [2.0-RC3][root@pfsense.ph.cox.net]/boot/kernel(52): mbmon -A
      InitMBInfo: Unknown error: 0
      This program needs "setuid root"!!
      
      

      Kinda bummed me out and through searching I couldn't really find a way to check temps.  I noticed someone said you could just check the acpi stats for temp.  Well, no go on my motherboard for that one too.  I came across one post telling you to add coretemp_load="YES" to loader.conf so I went ahead and did that.  No go, couldn't figure out why.

      Well, after reading a post by jimp:

      If you have a modern AMD or Intel chip, the amdtemp/coretemp modules help, but we don't build them on pfSense (grab them from a FreeBSD 8.1 install).

      I went ahead and vboxed a FreeBSD 8.1 install and copied the coretemp.ko module to my pfsense RC2 box and ran kldload coretemp.
      This popped up in my pfSense system log: :)

      kernel: coretemp0: <cpu on-die="" thermal="" sensors="">on cpu0
      kernel: coretemp1: <cpu on-die="" thermal="" sensors="">on cpu1</cpu></cpu> 
      

      Success.

      [2.0-RC3][root@pfsense.ph.cox.net]/boot/kernel(53): sysctl -a | grep temperature
      dev.cpu.0.temperature: 64.0C
      dev.cpu.1.temperature: 64.0C
      

      Hope this helps someone else.

      EDIT:Thank you PTT for hosting the following files :)

      Cliffnotes:

      cd /boot/kernel
      pkg_add -r wget
      pkg_add -r unzip
      rehash
      wget http://ptt.4mg.com/pfSense/coretemp32.zip //if you are on i386
      wget http://ptt.4mg.com/pfSense/coretemp64.zip //if you are on AMD64
      unzip coretemp32.zip (or coretemp64.zip)
      kldload coretemp
      sysctl -a | grep temperature
      

      If you would like to change the text to have a degree symbol:
      1.  Change line 240 in /usr/local/www/widgets/widgets/system_information.widget.php
      from

      " />
      

      to

      " />
      

      Also, to help anyone else out that stumbled across this problem after they copied a coretemp.ko they either found on the internet or copied from an existing FreeBSD install.

      [2.0-RC3][root@pfsense.ph.cox.net]/boot/kernel(29): ls | grep core
      coretemp.ko
      [2.0-RC3][root@pfsense.ph.cox.net]/boot/kernel(26): kldload coretemp
      kldload: can't load coretemp: No such file or directory
      
      

      or

      kernel: KLD coretemp.ko: depends on kernel - not available or version mismatch
      

      I came across this error because I tried to get someone in ##freebsd to send me their coretemp.ko file.  Turns out that they were on FreeBSD 8.2 and the kernel module wasn't compatible with 8.1.

      1 Reply Last reply Reply Quote 0
      • stephenw10S
        stephenw10 Netgate Administrator
        last edited by

        Nice post!  :)

        Steve

        1 Reply Last reply Reply Quote 0
        • A
          ariyako
          last edited by

          thanks! nice post!

          1 Reply Last reply Reply Quote 0
          • G
            GoldServe
            last edited by

            How does one get this module loaded on every boot?

            I found that the system information widget almost has temperature built in.

            Edit the following files:

            /usr/local/www/includes/functions.inc.php

            
            function has_temp() {
            
            	/* no known temp monitors available at present */
            
            	/* should only reach here if there is no hardware monitor */
            	return true;
            }
            
            function get_temp() {
            	$temp_out = "";
            	exec("/sbin/sysctl dev.cpu.0.temperature | /usr/bin/awk '{ print $2 }' | /usr/bin/cut -d 'C' -f 1", $dfout);
            	$temp_out = trim($dfout[0]);
            
            	return $temp_out;
            }
            
            
            1 Reply Last reply Reply Quote 0
            • stephenw10S
              stephenw10 Netgate Administrator
              last edited by

              @GoldServe:

              How does one get this module loaded on every boot?

              Add the line:
              coretemp_load="yes"

              to /boot/loader.conf.local
              Create the file if necessary. That file is copied across a firmware update, however the kernel module will not be (i think).

              Steve

              Edit: corrected syntax

              1 Reply Last reply Reply Quote 0
              • R
                RedRep
                last edited by

                @GoldServe:

                How does one get this module loaded on every boot?

                I found that the system information widget almost has temperature built in.

                Edit the following files:

                /usr/local/www/includes/functions.inc.php

                That's pretty cool! :)

                1 Reply Last reply Reply Quote 0
                • A
                  asterix
                  last edited by

                  Can we get this functionality added to future snapshots.. especially amd64 ?

                  1 Reply Last reply Reply Quote 0
                  • C
                    Cino
                    last edited by

                    @asterix  I agree, this is nice little feature!! if yoru hardware supports it

                    @RedRep and i thought my box was hot at 52c

                    I noticed coretemp reads 52 but my IPMI sensor show 57… Who is correct? I wonder if the BIOS screen would read something different

                    but either case, its good to to have on the dash...

                    1 Reply Last reply Reply Quote 0
                    • stephenw10S
                      stephenw10 Netgate Administrator
                      last edited by

                      There's surely some reason that isn't included already?
                      What happens if coretemp isn't loaded?

                      Steve

                      1 Reply Last reply Reply Quote 0
                      • C
                        Cino
                        last edited by

                        @stephenw10:

                        There's surely some reason that isn't included already?
                        What happens if coretemp isn't loaded?

                        Steve

                        let see, i ran kldunload coretemp then looked at the dash… its in the dash but only reads C

                        I loaded it up and it showed on the dash without refreshing the page :-)

                        1 Reply Last reply Reply Quote 0
                        • stephenw10S
                          stephenw10 Netgate Administrator
                          last edited by

                          Right, so it needs some code to stop it showing "temperature C" if you don't have the right hardware/driver installed.

                          Steve

                          Edit: Should be °C if you ask me.  ;)

                          1 Reply Last reply Reply Quote 0
                          • R
                            RedRep
                            last edited by

                            @stephenw10:

                            Right, so it needs some code to stop it showing "temperature C" if you don't have the right hardware/driver installed.

                            Steve

                            Edit: Should be °C if you ask me.  ;)

                            There is a function in functions.inc.php for that; I will add that functionality tonight after work. I also grabbed the coretemp module for the amd release which I will upload somewhere as well.  On an iPad right now though. :(

                            @Cino:

                            @RedRep and i thought my box was hot at 52c

                            It is completely fanless. :)

                            1 Reply Last reply Reply Quote 0
                            • A
                              asterix
                              last edited by

                              Eagerly waiting for the amd64 coretemp module !!  ;D

                              Keeping myself ready for the change.. I am getting the below error.

                              [2.0-RC3][admin@pfsense.localdomain]/boot/kernel(5): pkg_add -r wget
                              Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-8.1-release/Latest/wget.tbz… Done.
                              Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-8.1-release/All/libiconv-1.13.1_1.tbz... Done.
                              Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-8.1-release/All/gettext-0.18_1.tbz... Done.
                              [2.0-RC3][admin@pfsense.localdomain]/boot/kernel(6): wget http://encodable.com/uploaddemo/files/pfsense/coretemp.ko
                              wget: Command not found.

                              Not sure why my wget command isin't working? Is this too 32/64 bit sensitive? I have amd64 installed.

                              Maybe "fetch" would work.. but not sure what would be the precise syntax for it to download the coretemp.ko file.

                              Edit:
                              Nevermind.. I used File Manager to upload the file for testing. Doesn't work..lol. Will wait for the amd64 version.

                              1 Reply Last reply Reply Quote 0
                              • stephenw10S
                                stephenw10 Netgate Administrator
                                last edited by

                                You have to issue a rehash after you've added a package so Freebsd knows where to find it. Or reboot.

                                [2.0-RC3][root@pfsense.fire.box]/root(1): rehash
                                

                                Steve

                                1 Reply Last reply Reply Quote 0
                                • A
                                  asterix
                                  last edited by

                                  Aah I see. Thanks for the info. Not much of a FreeBSD user so learning every day.

                                  Can't wait to try the amd64 coretemp.

                                  1 Reply Last reply Reply Quote 0
                                  • G
                                    GoldServe
                                    last edited by

                                    My N270 is 52-55C in a totally passively cooled solution (Lanner netapp).

                                    1 Reply Last reply Reply Quote 0
                                    • R
                                      RedRep
                                      last edited by

                                      http://encodable.com/uploaddemo/files/pfsense/coretemp.ko-amd64
                                      AMD64 version

                                      1 Reply Last reply Reply Quote 0
                                      • A
                                        asterix
                                        last edited by

                                        Thank you !!

                                        1 Reply Last reply Reply Quote 0
                                        • A
                                          asterix
                                          last edited by

                                          It's working !!

                                          [2.0-RC3][admin@pfsense.localdomain]/root(1): sysctl -a | grep temperature
                                          dev.cpu.0.temperature: 59.0C
                                          dev.cpu.1.temperature: 54.0C
                                          dev.cpu.2.temperature: 57.0C
                                          dev.cpu.3.temperature: 51.0C

                                          Added to local.conf to auto load at boot.. yeehaa !!!

                                          Now how do I make the temp show up at the main system information for all 4 cores?

                                          1 Reply Last reply Reply Quote 0
                                          • C
                                            Cino
                                            last edited by

                                            @stephenw10:

                                            Right, so it needs some code to stop it showing "temperature C" if you don't have the right hardware/driver installed.

                                            Steve

                                            Edit: Should be °C if you ask me.  ;)

                                            agreed…. I did try to add ° but it didn't like it.... Figure we need ANSI code or something for it to display in the widget

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post
                                            Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.