Created
January 9, 2019 19:09
-
-
Save jbdrvl/b57db19b86288c19c02f8db843d9bf7b to your computer and use it in GitHub Desktop.
Prints some information about the system: battery level, disk/mem/swap usage and CPU temperature
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env sh | |
| # Jan 9, 2019 | |
| # Debian 4.17 | |
| echo Battery Status: | |
| awk "BEGIN {printf \"%.1f%%\n\n\", 100*$(cat /sys/class/power_supply/BAT0/energy_now)/$(cat /sys/class/power_supply/BAT0/energy_full)}" | |
| echo 'CPU Temperature (Celsius):' | |
| echo "$(($(cat /sys/class/thermal/thermal_zone0/temp)/1000)) C\n" | |
| echo Memory Usage: | |
| awk "BEGIN {printf \"%.1f%%\n\n\", 100*(1-($(head -n 3 /proc/meminfo | tail -n 1 | egrep -o '[0-9]+')/$(head -n 1 /proc/meminfo | egrep -o '[0-9]+')))}" | |
| echo SWAP Usage: | |
| tail -n +2 /proc/swaps | awk '{printf "%s %.1f%%\n", $1, $4/$3}' | |
| echo | |
| echo Disk Usage: | |
| df | awk '{if ($6=="/"){print $1,$5}}' |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
temperatureone does not always work, since the file (/sys/class/thermal/thermal_zone0/temp) might not be there on all systems (for example in some VMs)