Chapter 19: Create a Linux Health Monitoring Script in Bash
In this chapter, you'll build a complete Linux health-check script that checks the system status, services, disk space, memory usage, open ports, and recent errors.
Welcome to Day 7.
In Chapter 18, you learned the basics of Bash, which included variables, command substitution, conditionals, loops, and functions. You then used them together to create sysinfo.sh, a small but useful script.
Now, we are going to create something more practical using those Bash scripting basic skills.
In this chapter, you will create a server health-check script that collects useful information about your Linux server, including:
- Hostname and Linux distribution
- Kernel version and uptime
- Logged-in users
- CPU load
- Memory and swap usage
- Disk usage
- Failed services
- Listening ports
- Recent system errors
Each check will be placed inside its own function, where the script will run these functions one by one, show the results on the screen, and save the same information to a report file with the current date.