Is there is API to check if TeamCity Agent is idle?

Answered

Good Morning,

I would like to check via API or another way if Teamcity Agent is idle to shut down such an agent if idle for a longer time (agent in the public cloud).

Any suggestions?

0
2 comments
Hello,
The REST API has a field for the agent that is idleSinceTime, that will return if the agent is idle, or will be empty if the agent is running a build.
As an example, you could use:
  • http://<TEAMCITYSERVER>/app/rest/agents?&fields=agent(id,name,idleSinceTime)
You can also return all the agent properties using * instead of the fields, as in the following example:
  • http://<TEAMCITYSERVER>/app/rest/agents?&fields=agent(*)
You can read more about the agent properties that you can use here:
However there is a simpler way to achieve what you want to do. You can use instead the Cloud Profile Configuration , where you can set the time in minutes after which idle instances will be terminated automatically. 
 
Thank you very much,
 
Guilherme
0

Please sign in to leave a comment.