Script To Audit Active Agents

Hi Everyone,

I'm new to using TeamCity.  Sorry if this is  a little basic.

I would like to write a script which will verify the correct number of agents are available.  Put another way, there are 48 agents in my environment.  How can I verify (using a test or script, etc) that all of them are active.  If we do not have 48 agents active, we would need to notify the admins.

Can anyone point me to an example that would get me started?

Thanks,
-T

2 comments
Comment actions Permalink

Hi

You can use REST API for that.
A query to http://teamcity/httpAuth/app/rest/agents retutns a list of registered build agents.
Details can be requested by queries like http://teamcity/httpAuth/app/rest/agents/id:1

Enumerating 50 agents individually can be inconvenient.
You can make two calls
http://teamcity/httpAuth/app/rest/agents?includeDisconnected=true
http://teamcity/httpAuth/app/rest/agents?includeDisconnected=false
and count the difference.

Michael

0
Comment actions Permalink

Perfect! Thanks.

-T

0

Please sign in to leave a comment.