Sometimes, MSP IT admins must get a head count of devices/agents of each customer policy. This would mean going through each policy and keeping a running total of all devices per customer. This can end up being tedious with child policies, but what if there was a way to automate this? In this article is a custom Python script that will help automate this process. The script will print out the policy structure of the whole organization with the amount of devices per policy and the total amount of devices for the whole organization.
Note: Python must be installed to execute this script.
Table of Contents
Setup Process
This article will go over how to set up the script locally. This is the preferred method as the script will require sensitive information (API Keys). In this case, you can download the script attached to the bottom of this article, and open it up on your favorite text editor.
The script has two major requirements before being ready to run. The first is to own or create an API Key in the Addigy organization you want to get the device counts for. You can create a new API key by going to Account > Integrations and then clicking on the Add API button in the top right. If you are unfamiliar with the process, please refer to our KB article on generating API client IDs and client Secrets.
The next step is to fill out the two variables clientID and clientSecret at the beginning of the script. Fill the two variables with the client ID and client Secret you generated from the previous step or with preexisting ones. Ensure the filled client ID and client Secret data are wrapped in quotations. It should look similar to this:
clientID = "Your_Client_ID"
clientSecret = "Your_Client_Secret"
After filling in these variables, you can save the script and it is ready to run!
How To Run
To run the script locally, open up terminal and cd to the directory where you saved your script. Then, run the command python agentExport.py.
Sample Output
Below is a piece of sample output. We can see that each policy contains its name and the amount of devices in that policy. Also, notice some indentations help represent the policy hierarchy. Where each tab represents a child policy. Multiple tabs would indicate the policy is a child policy of a child policy. There is also a policy listed in the output as "No Policy" which shows the devices that are not in a policy.