Monitoring important server infrastructure

In this recipe, we will use a small script that will monitor the available filesystem's disk space periodically using cron, and if it exceeds a certain percentage threshold the script will send out a mail with a warning message.

Getting ready

To complete this recipe, you will require a working installation of the CentOS 7 operating system with root privileges and a console-based text editor of your choice. You should have read the Scheduling tasks with cron recipe to have a basic understanding of the principles behind the cron system.

How to do it...

  1. To begin this recipe, log in as root and create the following file that will contain our monitoring script:
    vi /etc/cron.daily/monitor_disk_space.sh
    
  2. Now, put ...

Get CentOS 7 Linux Server Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.