O'Reilly logo

Linux Shell Scripting with Bash by Ken O. Burtch

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required