The author created a system monitoring tool entirely in pure Bash to test its limits. This tool, named system-monitor, provides combined information typically found in commands like top, free, and df. It displays CPU load, RAM usage, disk space, network I/O, and process count. The script evolved from a few lines to over 250, incorporating features such as command-line arguments, colorized output, and a continuous monitoring mode. It also includes safe shutdown capabilities using signal trapping. A brief, machine-readable mode is available for integration with other scripts or logging systems. The author highlighted code snippets for color management, CPU load detection using awk and bc, and network metric retrieval. Key learnings emphasized the importance of patient coding, meticulous quoting, understanding awkโs behavior, and the benefits of visual feedback. The tool is also packaged for the Arch User Repository (AUR). Ultimately, the project provided a deep understanding of Bash, practical experience with system files and awk, and a strong appreciation for well-designed command-line interfaces. The author encourages others to build their own utilities, regardless of initial messiness, as the learning and satisfaction are rewarding.
dev.to
dev.to
Create attached notes ...
