automatic restart for mx daily

jOMeraki2
Getting noticed

automatic restart for mx daily

hi all i need to write script for an automatic restart for mx daily evry day in spesfic time and how to use it

3 Replies 3
alemabrahao
Kind of a big deal
Kind of a big deal

It's a old discussion but maybe it will help you.

 

https://community.meraki.com/t5/Security-SD-WAN/Combined-Network-of-MR33-and-MX65-I-have-multiple-ne...

I am not a Cisco Meraki employee. My suggestions are based on documentation of Meraki best practices and day-to-day experience.

Please, if this post was useful, leave your kudos and mark it as solved.
rhbirkelund
Kind of a big deal
Kind of a big deal

 

#! /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.
PhilipDAth
Kind of a big deal
Kind of a big deal

I've never used it, but Splash Access make a Meraki device reboot app available for free.  It mentions "scheduled" on their web site.

https://www.splashaccess.com/meraki-rebooted-app-released/ 

Get notified when there are additional replies to this discussion.