Linux System Usage Information Script
Copyright © 2020 Teal Dulcet
Script to quickly output system usage information on Linux, including:
- Processor (CPU) usage
- CPU Sockets/Cores/Threads
- CPU Thread usage
- Load average (1, 5, 15 minutes)
- ‡Pressure Stall (PSI) average (10 seconds, 1, 5 minutes)
- PSI Some CPU
- PSI Some RAM
- PSI Some IO
- *Temperature(es)
- Memory (RAM) usage
- Swap space usage
- Users logged in (number of)
- Idle time (last activity)
- Processes/Threads
- Disk space usage
- Disk IO usage (read/write)
- Network usage (receive/transmit)
- †Graphics Processor (GPU) usage
- GPU Memory (RAM) usage
- GPU Temperature(es)
- *Battery (percentage charged and status)
- Uptime
- Hostname (FQDN)
- Private IP address(es)
- ^Public IP address(es)
- ^Weather
* If present
^ Optional
† Requires Nvidia GPU(s)
‡ Requires Linux kernel ≥ 4.20
RAM, swap space, disk and network usage is output in both IEC (powers of 1024) and SI (powers of 1000) units, but with more precision then the numfmt command from GNU Coreutils. Uses terminal colors and formatting to output the information to the console. For the colors, green means good, yellow means warning and red means critical.
Requires at least Bash 4+. Compared to similar programs, this script outputs much more information. Useful for displaying a message of the day (motd) upon login on Linux. All the values are saved to variables, which makes this easy to incorporate into larger scripts.
To monitor the status of one or more servers, please see the Remote Servers Status Monitoring script.
❤️ Please visit tealdulcet.com to support this script and my other software development.
Also see the Linux System Information script.
Supports all modern Linux distributions and the Windows Subsystem for Linux (WSL).
See Help below for full usage information.
wget -qO - https://raw.github.com/tdulcet/System-Usage-Information/master/usage.sh | bash -s --
curl -sL https://raw.github.com/tdulcet/System-Usage-Information/master/usage.sh | bash -s --
- Download the script (usage.sh). Run:
wget https://raw.github.com/tdulcet/System-Usage-Information/master/usage.sh
. - There are some variables at the top of the script users can set to change the output, including the thresholds for the colors.
- Install the script. Run:
sudo mv usage.sh /usr/local/bin/usage
andsudo chmod +x /usr/local/bin/usage
. - Create a new script in the
/etc/update-motd.d/
directory that runs Linux System Usage Information script, for example called50-sys-usage-info
:
#!/bin/sh
usage -sw
- Execute the new script once to make sure there are no errors. For example, run:
sudo chmod +x /etc/update-motd.d/50-sys-usage-info
and/etc/update-motd.d/50-sys-usage-info
.
See here for more information.
$ usage -h
Usage: usage [OPTION(S)]...
Options:
-p Show Public IP addresses and hostnames
Requires internet connection.
-w Show current Weather
Requires internet connection.
-s Shorten output
Do not show CPU Thread usage and PSI averages. Useful for displaying a message of the day (motd).
-u Use Unicode usage bars
-h Display this help and exit
-v Output version information and exit
Examples:
Output everything
$ usage -pw
Pull requests welcome! Ideas for contributions:
- Add more system usage information
- Show Wi-Fi signal quality without using the deprecated Wireless tools or
/proc/net/wireless
file. - Show total Disk IO and Network usage.
- Show power/energy usage.
- Show Wi-Fi signal quality without using the deprecated Wireless tools or
- Add more examples
- Improve the performance
- Support more GPUs
- Port to C/C++ or Rust