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 120.0k 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.
    • stephenw10S
      stephenw10 Netgate Administrator
      last edited by

      Using something like:

      function get_temp() {
      	$temp_out = "";
      	exec("/usr/local/bin/mbmon -I -c1 -T3", $dfout);
      	$temp_out = (trim($dfout[0]).'°');
      
      	return $temp_out;
      }
      

      Would be better except that the above code only correctly returns ° when it it called from the system widget php code. When it's called from the javascript update function it just shows °.  :-\

      Steve

      1 Reply Last reply Reply Quote 0
      • jimpJ
        jimp Rebel Alliance Developer Netgate
        last edited by

        Needs a semicolon after that, it's "°"

        Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

        Need help fast? Netgate Global Support!

        Do not Chat/PM for help!

        1 Reply Last reply Reply Quote 0
        • S
          seh2000
          last edited by

          @stephenw10:

          I would think it would be better to have the get_temp function return a value including the ° symbol.
          E.g. 45.2°
          That way only one file has to be altered.

          @jimp:

          You should really use °, don't hardcode such a symbol directly in html/js

          I agree. I was surprised it worked actually. I probably depends on what your viewing it on.

          Steve

          Steve and jimp,
          Sorry for been slow, but what you say is I should not really add the ° symbol to the ajax.js file? But could I add the ASCII code there or better not at all? As I mentioned I am not a good programmer :(
          Steen

          1 Reply Last reply Reply Quote 0
          • CNLiberalC
            CNLiberal
            last edited by

            Yeah, this still isn't working for me.  I'm just going to wait until a package is released.

            pfSense 2.7.2-RELEASE

            Dell R210 II
            Intel E3-1340 v2
            8GB RAM
            SSD ZFS Mirror
            Intel X520-DA2, RJ45 SFP+ (WAN) and 10Gb SFP+ DAC (LAN)
            1 x Cisco 3850 12XS-S (Core Switch)
            2 x Cisco 3750X PoE Gig Switch (Access Stack)
            3 x Cisco 2802i APs (Mobility Express)

            1 Reply Last reply Reply Quote 0
            • jimpJ
              jimp Rebel Alliance Developer Netgate
              last edited by

              It's bad form (invalid html/js/etc) to put in a symbol instead of the html entity. It may work, but it's not guaranteed to do so.

              http://www.w3schools.com/tags/ref_entities.asp

              Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

              Need help fast? Netgate Global Support!

              Do not Chat/PM for help!

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

                Nope.   ???
                Same as before, using:

                
                unction get_temp() {
                	$temp_out = "";
                	exec("/usr/local/bin/mbmon -I -c1 -T3", $dfout);
                	$temp_out = (trim($dfout[0]).'°');
                
                	return $temp_out;
                }
                
                

                Results in initially correct ° then 46.5°C
                Hmm.

                Steve

                1 Reply Last reply Reply Quote 0
                • jimpJ
                  jimp Rebel Alliance Developer Netgate
                  last edited by

                  It may be getting run through htmlentities somewhere in there then. Might be safe to leave the symbol in there if that is the case.

                  Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

                  Need help fast? Netgate Global Support!

                  Do not Chat/PM for help!

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

                    Unfortunately using:

                    
                    function get_temp() {
                    	$temp_out = "";
                    	exec("/usr/local/bin/mbmon -I -c1 -T3", $dfout);
                    	$temp_out = (trim($dfout[0]).'°');
                    
                    	return $temp_out;
                    }
                    
                    

                    Results in the attached image.

                    Perhaps the character set is being restricted somewhere?

                    tempwidget.jpg
                    tempwidget.jpg_thumb

                    1 Reply Last reply Reply Quote 0
                    • jimpJ
                      jimp Rebel Alliance Developer Netgate
                      last edited by

                      That's a unicode degree symbol, try a standard ascii one, º

                      Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

                      Need help fast? Netgate Global Support!

                      Do not Chat/PM for help!

                      1 Reply Last reply Reply Quote 0
                      • S
                        seh2000
                        last edited by

                        @jimp:

                        It's bad form (invalid html/js/etc) to put in a symbol instead of the html entity. It may work, but it's not guaranteed to do so.

                        http://www.w3schools.com/tags/ref_entities.asp

                        OK, got you, yes correct…
                        Cheers Steen

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

                          No different. I entered both º and ° and both result in ��.  :-\

                          Steve

                          1 Reply Last reply Reply Quote 0
                          • jimpJ
                            jimp Rebel Alliance Developer Netgate
                            last edited by

                            I'd just leave it out.

                            (Or convert to Kelvin, no symbol there! ;-)

                            Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

                            Need help fast? Netgate Global Support!

                            Do not Chat/PM for help!

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

                              Kelvin nice!  :D

                              I'll stick with the nasty ° addition to ajax.js. I'm clueless about js, how would one enter that as an ascii code instead? Using ° is not working.

                              Steve

                              1 Reply Last reply Reply Quote 0
                              • S
                                seh2000
                                last edited by

                                @jimp:

                                I'd just leave it out.

                                (Or convert to Kelvin, no symbol there! ;-)

                                Kelvin - LoL can core temp convert the output?

                                1 Reply Last reply Reply Quote 0
                                • S
                                  stramato
                                  last edited by

                                  This is awesome. My i3-540 reads 29C, 29C, 36C, 36C lol.

                                  Will this be included in future snapshots? Or should we go ahead and modify it ourselves?

                                  1 Reply Last reply Reply Quote 0
                                  • S
                                    seh2000
                                    last edited by

                                    @stramato:

                                    This is awesome. My i3-540 reads 29C, 29C, 36C, 36C lol.

                                    Will this be included in future snapshots? Or should we go ahead and modify it ourselves?

                                    That is cool, which type of case/box you use? I get 54C with an Atom D510 that sits in a Jetway Motherboard that is in a passive cooled M-350 box.
                                    Cheers Steen

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

                                      Though this is 2.0 RC feedback section, but since the topic is on coretemp, I wanted to see if there is a pfsense 1.2.3 compatible 32-bit coretemp file out there that I can use. Moved to 1.2.3 last night as 64-bit snapshot snort is broken since weeks and I don't have the patience to wait any longer.

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

                                        @asterix:

                                        Though this is 2.0 RC feedback section, but since the topic is on coretemp, I wanted to see if there is a pfsense 1.2.3 compatible 32-bit coretemp file out there that I can use. Moved to 1.2.3 last night as 64-bit snapshot snort is broken since weeks and I don't have the patience to wait any longer.

                                        Pull the file from a FreeBSD 7.2 install CD.

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

                                          I am not a FreeBSD user.

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

                                            @asterix:

                                            I am not a FreeBSD user.

                                            you don't have to be a FreeBSD user to copy a file off the install CD.

                                            download a copy of 7.1 Install ISO.. Mount the ISO with your favorite Virtual CD program, like MagicISO… Then copy the files from cddrive/boot/kernel

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