Appendix A. A Complete Example
Peek is a fun and useful example of what shell scripts can do. A resource monitoring and troubleshoot script, peek sleeps for 20 or 30 seconds. Upon waking, it checks (or “peeks at”) system statistics using commands such as free and vmstat, and draws graphs representing the computer activity. Across the top of the display is the time of the last update, and the actual CPU and memory usage. Below the graphs, warnings appear about potential problems or bottlenecks.
Because the format of commands such as vmstat changes over time, the script might have to be modified for certain distributions. This version was designed for Red Hat 7.3. Figure A.1 shows peek in action.
Figure A.1. peek.sh.
The full source code appears in ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access