#! /usr/bin/env python3
import meraki
TARGET_ORGANIZATION_ID = [""]
def RebootDevice(p_Dashboard,p_serial):
response = p_Dashboard.devices.rebootDevice(
p_serial
)
if response['success'] == "true":
return True
elif response['success'] == "false":
return False
else:
raise Exception(f"Unknown response {response}")
def main():
dashboard = meraki.DashboardAPI(
suppress_logging=True
)
for orgID in TARGET_ORGANIZATION_ID:
devices = dashboard.organizations.getOrganizationInventoryDevices(orgID,
total_pages='all',
productTypes=['appliance']
)
for device in devices:
response = RebootDevice(dashboard,device['serial'])
if response == True:
print(f"SUCCESS: Device {device['name']} successfully rebooted")
elif response == False:
print(f"FAILED Device {device['name']} not rebooted")
if __name__ == "__main__":
main()
Save the script to a file "RebootMX.py". Open your crontab file with "crontab -e", and add the line
0 0 * * * /usr/bin/python3 /path/to/file/RebootMX.py
To run the file every day at midnight.
LinkedIn :::
https://blog.rhbirkelund.dk/Like what you see? - Give a Kudo ## Did it answer your question? - Mark it as a Solution
🙂All code examples are provided as is. Responsibility for Code execution lies solely your own.