Question: You will create a shell script for this project to automate the management and monitoring of server resources. You will be given a scenario in

You will create a shell script for this project to automate the management and monitoring of server
resources. You will be given a scenario in which you must write a script to carry out various server resource
management and monitoring duties. (10 Marks)
Scenario Description:
Imagine you are a system administrator responsible for managing a group of Linux servers. Your task is to
create a shell script that will help you perform the following tasks:
1. Disk Usage Monitoring: The script should check the disk usage of the server and send an alert if
the usage exceeds a certain threshold (e.g.,30%).
2. CPU Usage Monitoring: Monitor CPU usage and send an alert if the CPU usage exceeds a specified
threshold (e.g.,30%).
3. Memory Usage Monitoring: Monitor memory (RAM) usage and send an alert if the available
memory falls below a specified threshold (e.g.,10% free).
4. Log Rotation: Implement log rotation for a specified log file, ensuring that it does not grow beyond
a certain size (e.g.,10MB).
Requirements:
1. Create a shell script named server_monitor.sh.
2. Implement the tasks mentioned in the scenario.
3. The script should log all activities and alerts to a log file.
4. You should use conditional statements (if-else) to check thresholds and generate alerts.
5. Use appropriate commands and tools (e.g., df, top, ps, tar, logrotate, etc.) to achieve the tasks.
6. Ensure that your script is well-commented to explain the purpose of each section.
7. Include error handling to gracefully handle any potential issues that may arise during script
execution.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!