Ask Ubuntu Asked by Estatistics on January 11, 2021
Is there a Terminal command to show a summary of memory used, temperature degrees, and GPU use in a single screen, in a simple way?
I want in terminal to give me information in a summary fashion of Memory used (not swap etc.), GPU Use (as a percentage), and temperature degrees – how hot is getting CPU?
Right now, I must use three different terminal commands:
watch free -m # For Memory use
watch sensors # For Temperature
watch ndivia-smi # For GPU use
Is there a way to display such information in a single screen?
These commands produce a lot of information that someone may not need it rightaway.
The first line may show the memory use.
The second line may show GPU use.
The third line may display Temperatures.
I want from free -m
"available". I want from nvidia-smi
"Volatile GPU-Util" and from sensors
all the temperatures in percentage without showing their limits (from that to that), for example
Available memory 5500000
Volatile GPU-Util 20%
CPUtemp1 40oC
Fantemp1 41oC
FanTemp2 42oC
etc...
Is that possible?
Sample outputs:
free -m
output
$ free -m
total used free shared buff/cache available
Mem: 7815 1938 3548 188 2328 5391
Swap: 2047 57 1990
nvidia-smi
output
$ nvidia-smi
Fri Jul 31 18:35:45 2020
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 390.138 Driver Version: 390.138 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 GeForce GT 1030 Off | 00000000:01:00.0 On | N/A |
| 32% 44C P8 N/A / 30W | 220MiB / 1998MiB | 1% Default |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| 0 1770 G /usr/lib/xorg/Xorg 82MiB |
| 0 8182 G /usr/bin/krunner 6MiB |
| 0 8184 G /usr/bin/plasmashell 55MiB |
| 0 26370 G ...AAAAAAAAAAAACAAAAAAAAAA= --shared-files 74MiB |
+-----------------------------------------------------------------------------+
sensors
output
$ sensors
it8620-isa-0a30
Adapter: ISA adapter
in0: +0.01 V (min = +0.00 V, max = +3.06 V) ALARM
in1: +2.05 V (min = +0.00 V, max = +3.06 V)
in2: +2.00 V (min = +0.00 V, max = +3.06 V)
in3: +2.02 V (min = +0.00 V, max = +3.06 V)
in4: +0.01 V (min = +0.00 V, max = +3.06 V)
in5: +1.74 V (min = +0.00 V, max = +3.06 V)
in6: +1.50 V (min = +0.00 V, max = +3.06 V)
3VSB: +3.38 V (min = +0.00 V, max = +6.12 V)
Vbat: +3.05 V
fan1: 2986 RPM (min = 0 RPM)
fan2: 0 RPM (min = 0 RPM)
fan3: 0 RPM (min = 0 RPM)
temp1: +47.0°C (low = +127.0°C, high = +127.0°C) sensor = thermistor
temp2: -128.0°C (low = +127.0°C, high = +127.0°C) sensor = disabled
temp3: +35.0°C (low = +127.0°C, high = +127.0°C) sensor = Intel PECI
temp4: +45.0°C
temp5: +42.0°C
temp6: +45.0°C
intrusion0: ALARM
acpitz-virtual-0
Adapter: Virtual device
temp1: +27.8°C (crit = +97.0°C)
temp2: +29.8°C (crit = +97.0°C)
coretemp-isa-0000
Adapter: ISA adapter
Package id 0: +45.0°C (high = +86.0°C, crit = +92.0°C)
Core 0: +43.0°C (high = +86.0°C, crit = +92.0°C)
Core 1: +44.0°C (high = +86.0°C, crit = +92.0°C)
Core 2: +42.0°C (high = +86.0°C, crit = +92.0°C)
Core 3: +40.0°C (high = +86.0°C, crit = +92.0°C)
You can easily extract the specific parts of interest from the long outputs by using various command-line utilities, e.g. awk
.
You're interested in showing only the 'available' memory from the output of free -m
. Note that this number appears as the 7th string in the 2nd line of the output of free -m
. So you can use the following command to extract this number
free -m | awk '{if (NR == 2) {print $7}}'
To "watch
" the output, you can use the following
watch 'free -m | awk '''{if (NR == 2) {print $7}}''
Similarly, it seems you want to extract the 2nd string from the 9th line from the output of the nvidia-smi
command (32%
as per the output you added to the question). So you can extract this value by the following command
nvidia-smi | awk '{if (NR == 9) {print $2}}'
and watch
it using
watch 'nvidia-smi | awk '''{if (NR == 9) {print $2}}''
From the output of sensors
I believe you're trying to extract the 2nd string from line numbers 15 to 20 (which report temp1
to temp6
). So you can use
sensors | awk '{if (NR>=15&&NR<=20) {print $2}}'
and to watch
watch 'sensors | awk '''{if (NR>=15&&NR<=20) {print $2}}''
To watch
all three at the same time, you can use the following command
watch 'free -m | awk '''{if (NR == 2) {print $7}}'''; nvidia-smi | awk '''{if (NR == 9) {print $2}}'''; sensors | awk '''{if (NR>=15&&NR<=20) {print $2}}''
Correct answer by pomsky on January 11, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP