Question: Write a Python script that automates the following checks on a list of servers: 1 . Check if the server's CPU usage is above 8

Write a Python script that automates the following checks on a list of servers:
1. Check if the server's CPU usage is above 80%. If it is, print a warning message:
'High CPU usage on {server_name}'.
2. Check if the server's disk space is below 10%. If it is, print: 'Low disk space on
{server_name}'.
3. Check if the server is reachable. If it is unreachable, print: 'Server {server_name}
is unreachable'.
4. If a server is named 'critical_server', stop all further checks and print 'Critical
server found. Stopping checks.'
5. After checking all servers, print a summary of the number of servers that had
high CPU usage, low disk space, and were unreachable.
Iterate over the servers and handle the conditions as outlined.
Input Data:
servers =[
{'name': 'server1', 'cpu': 85, 'disk': 20, 'reachable': True},
{'name': 'server2', 'cpu': 70, 'disk': 5, 'reachable': False},
{'name': 'critical_server', 'cpu': 90, 'disk': 15, 'reachable': True},
{'name': 'server4', 'cpu': 60, 'disk': 50, 'reachable': True}
]
Note that this input data will not be provided at the terminal. You may copy and paste
the above inputs into your code and work with it.

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 Programming Questions!