My team uses Ansible Tower (the RedHat licensed product) and we track the license usage change day-to-day with this python script. We have two environments, so the system will use the LOGIN_INFO dictionary to login and record each sites current instances. There’s also an example how to call it from a crontab. The script does send data to the screen (stdout) as well as the CSV file - in the future I might update this to be an option to disable for crontab usage.
If you have a single instance, update the “envs” variable to just note “Prod” like this:
envs = {'Prod', 'Sandbox', 'Total'}
and remove the corresponding LOGIN_INFO entry.
If you have three or more sites, add them to the envs:
envs = {'Prod', 'Sandbox', 'Lab', 'DMZ', 'Total'}
and add additional LOGIN_INFO entries.
I'd love feedback if this works to monitor server counts in the AWX project too.
Code is supplied "**AS-IS, NO WARRANTY**" but it should be safe enough once you've reviewed it for yourself.
`
#!/usr/bin/env python