This Python script is designed to periodically track and record the status of devices in a Cisco Meraki organization. It fetches the number of online devices in the organization and saves this data to both CSV and JSON files.
- Jorge Banegas
- Meraki
In order to use the Meraki API, you need to enable the API for your organization first. After enabling API access, you can generate an API key. Follow these instructions to enable API access and generate an API key:
- Login to the Meraki dashboard
- In the left-hand menu, navigate to
Organization > Settings > Dashboard API access
- Click on
Enable access to the Cisco Meraki Dashboard API
- Go to
My Profile > API access
- Under API access, click on
Generate API key
- Save the API key in a safe place. The API key will only be shown once for security purposes, so it is very important to take note of the key then. In case you lose the key, then you have to revoke the key and a generate a new key. Moreover, there is a limit of only two API keys per profile.
For more information on how to generate an API key, please click here.
Note: You can add your account as Full Organization Admin to your organizations by following the instructions here.
-
Clone this repository with
git clone [repository name]
. -
In the cloned repository, you'll find a
.env
file. Open this file and fill in your Meraki API key and Organization ID:MERAKI_API_KEY=your_api_key_here MERAKI_ORG_ID=your_organization_id_here
Remember to keep your API key confidential and ensure not to commit or share your
.env
file with others.If you do not know your Meraki ORG ID you can run the script meraki_orgs.py to it will print out all the organizations associated with the MERAKI_API_KEY provided.
-
Set up a Python virtual environment. Ensure Python 3 is installed in your environment. If not, download Python here. Activate the virtual environment following the instructions found here.
-
Install the required packages with
pip3 install -r requirements.txt
.
- Scheduled Script (
meraki_device_tracker.py
): Runs automatically at specified intervals. ModifySCHEDULE_INTERVAL
andSCHEDULE_UNIT
in the script to adjust the frequency. - Manual Script (
meraki_device_tracker_manual.py
): For manual execution.
To run the script, use the command:
$ python3 meraki_device_tracker.py # For the scheduled script
$ python3 meraki_device_tracker_manual.py # For the manual
Provided under Cisco Sample Code License, for details see LICENSE
Our code of conduct is available here
See our contributing guidelines here
Please note: This script is meant for demo purposes only. All tools/ scripts in this repo are released for use "AS IS" without any warranties of any kind, including, but not limited to their installation, use, or performance. Any use of these scripts and tools is at your own risk. There is no guarantee that they have been through thorough testing in a comparable environment and we are not responsible for any damage or data loss incurred with their use. You are responsible for reviewing and testing any scripts you run thoroughly before use in any non-testing environment.