AMD - Poor Man's System Monitor

A small shell function I use to watch my system’s usage and temperatures. This only works for AMD CPUS and GPUS. It’s also somewhat specific to my system but I can help folks out get it working correctly with theirs if there are issues.

Copy this function to your shell rc file and reload the shell, run sens to start, use Ctrl-c to stop. You’ll be prompted for a password to read files in /sys/kernel.

sens() # read sensor data from system, requires root
{
	ncores=$(awk 'BEGIN{ i = 0 } /cpu MHz/ { i++ } END{ print i / 2 }' /proc/cpuinfo)

	sudo watch -n 1 -t "sensors -A 'k10temp-pci-*' |
		awk '!/Chipset|Tsensor|k10temp/' &&
		awk -v j=$ncores 'BEGIN{ s = \"\"; i = 0} /cpu MHz/ {
			if (i == j || i == j / 2 || i == j + (j / 2))
				s=s\"\\n\"
			if (s != \"\" && i != j && i != j / 2 && i != j + (j / 2))
				s=s\" | \"int(\$4)\"MHz\"
			else
				s=s\"\"int(\$4)\"MHz\"
			i++
		} END{print s}' /proc/cpuinfo &&
		echo &&
		sensors -A 'amdgpu-pci-*' | awk '!/emerg|amdgpu|fan1/ {
				gsub(/\\s*\\(.*\\)$/, \"\")
				print
			}' &&
		awk '/MHz|%|GPU Load/ {
				sub(/^\s*/, \"\")
				print
			}' /sys/kernel/debug/dri/0/amdgpu_pm_info &&
		awk '/ram usage:/ {
				gsub(/ram usage:/, \"Vram Used: \")
				gsub(/,/, \"\")
				print \$4, \$5, \$6
			}' /sys/kernel/debug/dri/0/amdgpu_vram_mm &&
		echo &&
		cat /sys/class/drm/card0/device/pp_dpm_sclk &&
		echo &&
		cat /sys/class/drm/card0/device/pp_dpm_mclk"
}

Yes it’s crude and that’s the point, here’s what to expect

9 Likes

Very nice. You definitely have more sensors on your board.

1 Like

With my board I have to install asus-wmi-sensors.git so the sensors read properly. it8665 chip

or m in /sys/class/hwmon/* ; do echo -n "$m = " ; cat $m/name ; done
/sys/class/hwmon/hwmon0 = nouveau
/sys/class/hwmon/hwmon1 = k10temp
/sys/class/hwmon/hwmon2 = asus
/sys/class/hwmon/hwmon3 = asuswmisensors 


2 Likes

I’ve had the same issue with a similar chip, I had the same driver and actually contributed the patch for X470-PRO support, lately I don’t have the need for the extra info. The driver was also merged into mainline kernel as of 5.17 and just needs to be enabled.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/hwmon/asus_wmi_sensors.c?h=v5.17

Here’s the oldest version I have that used asuswmi (not much different)

sens() # read sensor data from system, requires root
{
	ncores=$(awk 'BEGIN{ i = 0 } /cpu MHz/ { i++ } END{ print i / 2 }' /proc/cpuinfo)

	sudo watch -n 1 -t "sensors -A 'asuswmisensors-isa-*' 'k10temp-pci-*' |
		awk '!/Chipset|Tsensor|asuswmi|k10temp/' &&
		awk -v j=$ncores 'BEGIN{ s = \"\"; i = 0} /cpu MHz/ {
			if (i == j || i == j / 2 || i == j + (j / 2))
				s=s\"\\n\"
			if (s != \"\" && i != j && i != j / 2 && i != j + (j / 2))
				s=s\" | \"int(\$4)\"MHz\"
			else
				s=s\"\"int(\$4)\"MHz\"
			i++
		} END{print s}' /proc/cpuinfo &&
		echo &&
		sensors -A 'amdgpu-pci-*' | awk '!/emerg|amdgpu|fan1/ {
				gsub(/\\s*\\(.*\\)$/, \"\")
				print
			}' &&
		awk '/MHz|%|GPU Load/ {
				sub(/^\s*/, \"\")
				print
			}' /sys/kernel/debug/dri/0/amdgpu_pm_info &&
		awk '/ram usage:/ {
				gsub(/ram usage:/, \"Vram Used: \")
				gsub(/,/, \"\")
				print \$4, \$5, \$6
			}' /sys/kernel/debug/dri/0/amdgpu_vram_mm &&
		echo &&
		cat /sys/class/drm/card0/device/pp_dpm_sclk &&
		echo &&
		cat /sys/class/drm/card0/device/pp_dpm_mclk"
}

And here’s my sensors config for X570-PRO

# vim:ft=sensors

chip "nct6798-isa-0290"

	### Voltages
    label  in0   "Vcore"
    label  in1   "PCH"
    label  in2   "AVSB +3.3V"
    label  in3   "3VCC +3.3V"
    ignore in4   # ??
    ignore in5   # ??
    ignore in6   # ??
    ignore in7   # 3VSB +3.3V
    ignore in8   # VBAT +3V
    label  in9   "CPU VTT"
    ignore in10  # ??
    ignore in11  # ??
    ignore in12  # ??
    ignore in13  # ??
    ignore in14  # ??

    ignore fan5 # unused by me
    ignore fan6 # unused by me
    ignore fan7 # unused by me

    ignore intrusion0  # trash
    ignore intrusion1  # trash
    ignore beep_enable # trash

	# adjust voltage min/max
    # set in2_min  3.3 * 0.90
    # set in2_max  3.3 * 1.10
    # set in3_min  3.3 * 0.90
    # set in3_max  3.3 * 1.10
    # set in7_min  3.3 * 0.90
    # set in7_max  3.3 * 1.10
    # set in8_min  3.0 * 0.90
    # set in8_max  3.3 * 1.10


	# Vcore min/max
    # set in0_min 0.54
    # set in0_max 1.45


    label fan1 "Cha Fan 3"
    label fan2 "CPU Fan 1"
    label fan3 "CPU Fan 2"
    label fan4 "Cha Fan 1"
    label fan5 "Cha Fan 2"

    ignore temp3  # AUXTIN0
    ignore temp4  # AUXTIN1
    ignore temp5  # AUXTIN2
    ignore temp6  # AUXTIN3
    ignore temp7  # PECI Agent 0 Calibration
    ignore temp8  # PCH_CHIP_CPU_MAX_TEMP
    ignore temp9  # PCH_CHIP_TEMP
    ignore temp10 # PCH_CPU_TEMP
1 Like

Thanks for the info it8665 modules and 5.17 kernel do mean by {enabled} adding asus-wmi-sensors.conf to etc/modules-load.d folder with asus-wmi-sensors added to the file.

This is from your oldest version.

2 Likes