When a machine comes online I currently have a script that runs in the Task Scheduler that prods the server to do a adhoc health check. I’d like to make this less heavy duty and just set the status to online, but I can’t seem to do it in the API/OctoClient. Every time I set the Status or HealthStatus it reverts on saving back to Octopus.
My ultimate aim is to have tasks on Startup and Shutdown to take the tentacle on/offline in Octopus, which will let me do the health checks less often.
It looks like I sent a half reply by mistake! Below is the edited full reply.
Thanks for getting in touch! I have some thoughts which could help here.
I may need to get a look at your current API script to get an idea of what could be going on here. A common issue we see with using the API to update such settings in Octopus is not putting the entire modified object back into Octopus.
For example, if I was changing
Machines-141 to Disabled. I would get the entire object for
/machines/machines-141 from the api, edit the
Status to Disabled, then send the entire
/mahcines/machines-141 object back.
I’m wondering if you could also look into creating a custom health check script and apply the Machine Policy to the targets you need it on. Our documentation has more details on this.
Let me know how you go here. I would be happy to look at your API script for disabling/enabling the target if my above advice does not help.
Thanks for getting back to me. I’m doing roughly what you said, except I am not setting disabled, but the Status side of things:
$machine = $repository.Machines.Get(“Machines-1”)
$machine.HealthStatus = [Octopus.Client.Model.MachineModelHealthStatus]::Unhealthy
$machine.Status = [Octopus.Client.Model.MachineModelStatus]::Offline
And when the repo sends the machine object back, it’s still set to Online and Healthy.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.