O'Reilly logo

Linux® Command Line and Shell Scripting Bible, Second Edition by Christine Bresnahan, Richard Blum

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

Chapter 27

Advanced Shell Scripts

In This Chapter

  • Monitoring system statistics
  • Problem-tracking database

In this chapter, we will look at more advanced methods to use in shell scripts. These techniques enable you to work with scripts on your system in a variety of different ways.

Monitoring System Statistics

There are many utilities in the bash shell to help you keep an eye on Linux system performance and resource usage. Unfortunately, it is difficult to find the time to use them, especially when you have several systems to manage. Creating a few shell scripts to create reports using the output from these utilities can be an excellent use of your time.

This section will take you through the creation of some advanced shell scripts to assist you in monitoring various system performance statistics.

System Snapshot Report

A nice way to stay informed about your system's performance and resource usage is via a snapshot report. A snapshot report is a picture of a system's statistics at a certain point in time. A report of this kind is an “executive summary” of a system's health.

The script to create this snapshot report can be run as many times a day as you want a picture. Even better, the script will send you the report via e-mail.

The Required Functions

You will need to use four different bash shell commands to create the snapshot report: uptime, df, free, and ps. These various commands will give you the statistics needed.

Up Time

The first command, uptime, is the most basic system ...

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