[Solution]Is there an hddtemp fork that reads NVMe drives?
FedoraForum.org - Fedora Support Forums and Community
Results 1 to 8 of 8
  1. #1
    Join Date
    Sep 2009
    Posts
    2,194
    Linux (Fedora) Firefox 64.0

    [Solution]Is there an hddtemp fork that reads NVMe drives?

    The title says it all. I've checked copr, poked around in github, and googled with no luck. The nvme command can grab the temperature, but doing shell commands in a conky script uses a lot of resources.

    dd_wizard

    EDIT - Solution is in post #8. Thread moved to guides and solutions. Thanks dd_wizard!

  2. #2
    Join Date
    Jun 2005
    Location
    Montreal, Que, Canada
    Posts
    5,618
    Linux (Android 9) Chrome 71.0.3578.99

    Re: Is there an hddtemp fork that reads NVMe drives?

    Would the drives be registered with SMART?

    Try smartctl -a your_drive. Generally, these drives run so cool that the drive will only note the temp of the surroundings.
    Leslie in Montreal

    Interesting web sites list
    http://forums.fedoraforum.org/showth...40#post1697840

  3. #3
    Join Date
    Dec 2013
    Location
    United Kingdom
    Posts
    6,706
    Linux Chrome 71.0.3578.98

    Re: Is there an hddtemp fork that reads NVMe drives?

    Quote Originally Posted by lsatenstein
    Would the drives be registered with SMART?

    Try smartctl -a your_drive. Generally, these drives run so cool that the drive will only note the temp of the surroundings.
    actually like high performance RAM modules, nvme drives get hot in use, if not cooled properly they will throttle back to reduce temperature. that's why some motherboards come with nvme heat spreaders and it's useful to know the current temperature of them initially when you build a system and put it through it's paces to know that the nvme has sufficient airflow to keep optimal performance.

  4. #4
    Join Date
    Sep 2009
    Posts
    2,194
    Linux (Fedora) Firefox 64.0

    Re: Is there an hddtemp fork that reads NVMe drives?

    Sadly, hddtemp hasn't been updated in years. However, the udisks project is working on temperature reporting for NVMe drives in the future. In the mean time, I wrote a systemd daemon that puts the NVMe temperature in a file in /tmp for access by conky. Trying to read it directly with conky spams the logs with sudo requests and has a detectable performance hit.

    dd_wizard

  5. #5
    Join Date
    Dec 2013
    Location
    United Kingdom
    Posts
    6,706
    Linux Chrome 71.0.3578.98

    Re: Is there an hddtemp fork that reads NVMe drives?

    sounds very handy, please could you write up how to do this?

  6. #6
    Join Date
    Sep 2009
    Posts
    2,194
    Linux (Fedora) Firefox 64.0

    Re: Is there an hddtemp fork that reads NVMe drives?

    Should I put it in guides or this thread?

    dd_wizard

  7. #7
    Join Date
    Dec 2013
    Location
    United Kingdom
    Posts
    6,706
    Linux Chrome 71.0.3578.98

    Re: Is there an hddtemp fork that reads NVMe drives?

    i can make this into a guide thread if you want to add the information here

  8. #8
    Join Date
    Sep 2009
    Posts
    2,194
    Linux (Fedora) Firefox 64.0

    Re: Is there an hddtemp fork that reads NVMe drives?

    The smartctl command can get the temperature of an NVMe drive, but it takes twice as long as the nvme command. For this reason, I recommend installing nvme-cli and using the nvme command in the daemon shell script.

    $ time sudo smartctl -a /dev/nvme0
    ...
    real 0m0.100s
    user 0m0.026s

    $ time sudo nvme smart-log /dev/nvme0
    ...
    real 0m0.046s
    user 0m0.015s

    Conky can execute a shell command from within the .conkyrc file, but the developers recommend against it for efficiency reasons. Also, since you must run nvme or smartctl as root, you get sudo spam in the logs. So this post describes a very short shell script and systemd unit file that put the temperature in a file in /tmp that is world readable for conky to use. If the daemon dies for some reason, the file in /tmp is deleted. Otherwise, the last known temperature would be returned and you'd have no idea it was a fictitious reading.

    Instructions:

    Find your nvme drive with ll:
    Code:
    $ ll /dev/nvme*
    crw-------. 1 root root 239, 0 Jan 11 12:26 /dev/nvme0
    brw-rw----. 1 root disk 259, 0 Jan 11 12:26 /dev/nvme0n1
    brw-rw----. 1 root disk 259, 1 Jan 11 12:26 /dev/nvme0n1p1
    ...
    The character device is all that's needed to get the temperature, so I used nvme0-temp as the daemon name. Change it as appropriate for your system.

    Permissions and contents of /usr/local/bin/nvme0-temp:
    Code:
    $ ll /usr/local/bin/nvme0-temp
    
    -rwxr-xr-x. 1 root root 245 Jan 11 12:13 /usr/local/bin/nvme0-temp
    
    $ cat /usr/local/bin/nvme0-temp
    
    #!/bin/bash
    
    TEMPFILE="/tmp/nvme0-temp"
    
    trap "rm -f $TEMPFILE; exit" 0 1 2 3 13 15  # Exit, HUP, INT, QUIT, PIPE, TERM
    
    while true; do
        nvme smart-log /dev/nvme0 | sed -n 's/^[Tt]emperature *: *\([0-9]*\) C.*/\1/p' > "$TEMPFILE"
        sleep 5
    done
    Permissions and contents of /etc/systemd/system/nvme0-temp.service:
    Code:
    $ ll /etc/systemd/system/nvme0-temp.service
    
    -rw-r--r--. 1 root root 137 Jan 11 11:26 /etc/systemd/system/nvme0-temp.service
    
    $ cat /etc/systemd/system/nvme0-temp.service
    
    [Unit]
    Description=NVMe0 temperature monitor daemon
    
    [Service]
    ExecStart=/usr/local/bin/nvme0-temp
    
    [Install]
    WantedBy=multi-user.target
    Once those two files are set up, just run:
    Code:
    $ sudo systemctl --now enable nvme0-temp
    Created symlink /etc/systemd/system/multi-user.target.wants/nvme0-temp.service → /etc/systemd/system/nvme0-temp.service.
    Then you can see the temperature with:
    Code:
    $ cat /tmp/nvme0-temp
    33
    You need something like this in your .conkyrc file to display the temperature:
    Code:
    ${goto 825}${color0}NVMe: $color \
    ${if_existing /tmp/nvme0-temp}${tail /tmp/nvme0-temp 1 1}C${endif}\
    The tail command fails and conky aborts if the file doesn't exist, so the if_existing check keeps conky running with a blank temperature if the daemon stops for some reason.

    The board chokes on the .conkyrc file that generates the banner in the screen shot, so here is the text part of it:
    Code:
    conky.text = [[
    ${goto 8}${color0}BAT:$color ${battery_short BAT1} ${battery_time BAT1}\
    ${goto 445}${color0}CPU:$color $cpu%\
    ${goto 555}${color0}CPU:$color ${hwmon 0 temp 1}C\
    ${goto 675}${color0}Fan:$color ${hwmon 2 fan 1}rpm\
    ${goto 825}${color0}NVMe: $color \
    ${if_existing /tmp/nvme0-temp}${tail /tmp/nvme0-temp 1 1}C${endif}\
    ${goto 965}${color0}SSD: $color ${hddtemp /dev/sda}C\
    ${goto 1090}${color0}RAM:$color $memperc%\
    ${goto 1200}${color0}Down:$color ${downspeedf wlp3s0}KB/s\
      ${color0}Up:$color ${upspeedf wlp3s0}KB/s\
    ${alignr 2}${color0}${time %a}$color ${time %I:%M %p}
    ]]
    dd_wizard
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	Screenshot at 2019-01-11 16-27-49.jpg 
Views:	14 
Size:	206.0 KB 
ID:	29980  
    Last edited by dd_wizard; 14th January 2019 at 12:20 AM.

Similar Threads

  1. Issue installing F29 Silverblue on mix of NVME & physical drives?
    By joncr in forum Installation, Upgrades and Live Media
    Replies: 2
    Last Post: 6th December 2018, 01:17 PM
  2. Replies: 0
    Last Post: 8th July 2018, 10:42 PM
  3. iostat svctm and %busy numbers are wrong for NVME drives
    By bobx001 in forum Servers & Networking
    Replies: 2
    Last Post: 25th June 2018, 05:57 PM
  4. hddtemp
    By lsatenstein in forum Fedora Focus
    Replies: 0
    Last Post: 7th March 2018, 01:11 AM
  5. hddtemp
    By ferd in forum Using Fedora
    Replies: 21
    Last Post: 1st November 2005, 09:12 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •