0

I'm new here and to UNIX and Gnu/Linux scripts, I need help to build a script that modifies the lm-sensors output.
When I use the command sensors this is the current output

mint@desktop:~$ sensors
amdgpu-pci-0100
Adapter: PCI adapter
vddgfx:       +0.72 V
fan1:        1245 RPM  (min =    0 RPM, max = 2400 RPM)
edge:         +37.0°C  (crit = +94.0°C, hyst = -273.1°C)
power1:       34.26 W  (cap = 145.00 W)
coretemp-isa-0000
Adapter: ISA adapter
Package id 0:  +39.0°C  (high = +85.0°C, crit = +105.0°C)
Core 0:        +36.0°C  (high = +85.0°C, crit = +105.0°C)
Core 1:        +40.0°C  (high = +85.0°C, crit = +105.0°C)
Core 2:        +35.0°C  (high = +85.0°C, crit = +105.0°C)
Core 3:        +37.0°C  (high = +85.0°C, crit = +105.0°C)

I'm coming from Windows and I used to have HWMonitor to see in real time stuff like usage and temps but it's hard to get this task on linux, my script idea is to make something that takes the sensors information and translates a friendly output to something like this:

amdgpu-pci-0100
Voltage:     +0.72 V 
Fans Speed:  1248 RPM ( Percentage %% )
Temperature: +36.0°C  ( Percentage %% )
Power:       34.22 W  ( Percentage %% )
GPU Usage:   Percentage %%
VRAM Usage:  1GB / 8GB ( Percentage %% )

Can you help me? I'm not asking the full script just any advice that you might have for a newbie, is this script possible to be made?

Btw, I have tried PSensor but it doesn't show amdgpu module and RadeonTop dont show temps and VRAM.

5
  • Please edit your question and show us the exact output of sensors so we know what to look for. Use the formatting tools to format it as code. That said, this really is a bit too broad for us. Of course the script can be written, start looking into some basic "bash scripting" and also look at the command grep. Also, there are loads of tools that do this sort of thing (of course, sensors is one of them), have a look at conky, for example, but I'm sure there are GUI tools as well. Have you tried searching?
    – terdon
    Apr 2, 2020 at 14:16
  • Hello @terdon I included the entire sensors output formated as code, I'll take a look into the basic bash scripting and grep. I have searched through the web for days looking for a HWMonitor replacement, all my research showed that there are GUI tools but they only work well on Nvidia cards because of their driver, its being super difficult to find a complete hardware monitor for amdgpu so I'm trying to build my own. Apr 2, 2020 at 14:35
  • @terdon thank you for fixing the post I didn't noticed the mistakes Apr 2, 2020 at 14:44
  • Does Ksysguard do what you need. It is a graphical system monitor. It is also customizable. Apr 2, 2020 at 15:02
  • Hello @ctrl-alt-delor I've tried but it doesn't provide information about GPU Apr 2, 2020 at 15:23

1 Answer 1

0

For AMD gpus, you can access all of this data as a simple user from /sys/class/drm/card0/device/

What you're looking for is /sys/class/drm/card0/device/gpu_busy_percent
It could be different from card0 (depending how many gpus you have)

In this directory you'll have everything your need as GPU/VRAM usage, temperature, tension and so on..

Most of files are safe to cat however NEVER cat /sys/class/drm/card0/device/remove and if you do, just reboot.

I strongly recommend to you to read this, the following is just a summary:
https://dri.freedesktop.org/docs/drm/gpu/amdgpu.html#gpu-power-thermal-controls-and-monitoring

This is a list of file which are safe to cat.
/sys/class/drm/card0/device/gpu_busy_percent GPU Core usage in %
/sys/class/drm/card0/device/mem_busy_percent GPU Mem usage in %

All files prefixed with pp_ are readable except pp_table.
pp_dpm_* are related to GPU core and memory clocks
pp_dpm_sclk is for the GPU core
pp_dpm_mclk is for the GPU memory
The current state is marqued with a *

Under the directory hwmon you will have another directory corresponding to your hardward monitor for me it is named hwmon0, here are

/sys/class/drm/card0/device/hwmon/hwmon0/fan* GPU Fan current/min/max
/sys/class/drm/card0/device/hwmon/hwmon0/in* GPU mV and label
/sys/class/drm/card0/device/hwmon/hwmon0/power* GPU Watt current/min/max
/sys/class/drm/card0/device/hwmon/hwmon0/pwm* GPU PWM current/min/max/
/sys/class/drm/card0/device/hwmon/hwmon0/temp* GPU temp current/min/max

4
  • Hello I found good information there but I'm afraid to damage my gpu because I cant "cat" or "ls" anything there without sudo, watch command is not allowed either. I moved from Linux Mint now I'm using Debian. Apr 18, 2020 at 16:25
  • You will not damage your GPU while you are not trying to overide it's configuration. Cat will display the content of the file without modifying it, however there are two file you should avoid to cat remove and rescan. I'll add more info in my answer
    – Fractalyse
    Apr 19, 2020 at 17:11
  • Wow thank you so much for that update, I was playing with cat on every file I found, your answer is exactly what I needed Apr 20, 2020 at 18:10
  • You're welcome :)
    – Fractalyse
    Apr 20, 2020 at 20:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.