-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
24 lines (18 loc) · 686 Bytes
/
main.py
File metadata and controls
24 lines (18 loc) · 686 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import boto3
import schedule
import time
ec2_client = boto3.client('ec2', region_name="eu-west-3")
def check_instance_status():
statuses = ec2_client.describe_instance_status(
IncludeAllInstances=True
)
for status in statuses['InstanceStatuses']:
ins_status = status['InstanceStatus']['Status']
sys_status = status['SystemStatus']['Status']
state = status['InstanceState']['Name']
print(f"Instance {status['InstanceId']} is {state} with instance status is {ins_status} and system status {sys_status}")
print("###############################\n")
schedule.every(2).seconds.do(check_instance_status)
while True:
schedule.run_pending()
time.sleep(1)