Afficher des informations sur le matériel de la machine (occupation CPU et mémoire) dans la ligne d’état de screen
. Ça peut aider à diagnostiquer rapidement pourquoi la machine ne vous rend pas la main par exemple (est-elle occupée ou est-ce une panne réseau ?).
Screen can display a permanent status line with various informations. It might look like this (with various colors) :
3 <hostname> Load: 0,88 0,21 0,08 Mem: 1 / 3 G 2024-06-05 10:44
Here is how to get this :
$ vi ~/.screenrc
Add the following lines in the file (that might not exist before and can contain other useful settings) :
# backtick id lifespan autorefresh cmd args...
backtick 1 2 2 /bin/bash -c 'a=$(uptime | awk '\''{print $3" "$4}'\'' | sed s/,//); echo ${a}'
backtick 2 2 2 /bin/bash -c 'a=$(uptime | awk '\''{print $10" "$11" "$12}'\''); echo ${a}'
backtick 3 2 2 /bin/bash -c 'a=$(free -g | grep Mem |awk '\''{print $3"/"$2}'\'');echo "${a} G"' (1)
hardstatus alwayslastline (2)
hardstatus string '%{wk} %n %H %= %{Yk} up: %1` load: %2` %{Mk} mem: %3` %{wk} %Y-%m-%d %c ' (3)
1 | This creates a new replacement token for the status line definition. Here it’s a shell oneliner to extract the current RAM usage from the free command |
2 | Here we tell screen to display the status line, and to do it on the bottom of the screen . |
3 | Here we define what to display in the status line :
|
To test this settings you can start a new screen session or reload the settings of your current session via : CTRL+A : source ~/.screenrc
To finish, it exists at least screen-cpu-mem and rainbarf to create better backtick
tokens for your status line with graphical levels or charts of CPU and memory usage.