Sometimes it's necessary for MSP IT admins to 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 I will share 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.
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 a 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 then clicking on the Add API button in the top right. If you are unfamiliar with the process, I would advise referring to our KB article on generating API client IDs and client Secrets.
The next step is to fill the two variables clientID and clientSecret in 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 is encased in quotations. It should look like 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, and run the command python agentExport.py.
Sample Output
Below is a piece of sample output. We can see that each policy contains it's name and the amount of devices in that policy. Also notice there are indentations that 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.