user10345651
user10345651

Reputation: 21

How to check a Jenkins slave connection status from the slave itself?

I am building a system that monitors whether a Jenkins slave is connected or not using only data collected from the slave itself, meaning no API call from master.

What I want to ask is if this is possible or not and if possible, how should I approach it. Jenkins is mostly installed as a service on these machines but there are instances where it is run ad-hoc. I figure if I can check for node availability from master, there must be a way they are communicating so I tried checking for packets sending to master but to no avail.

Upvotes: 1

Views: 2621

Answers (1)

Shlomi Bazel
Shlomi Bazel

Reputation: 359

I've researched a little bit and checked what was going on when the Agent was on and when the Agent was off.

Basically, when the agent is connected, there's a port for the connection between the Agent and the Master. When I click ctrl+c to stop the Agent then it closes right away.

So the easiest solution you can to check whether the Agent is connected or not is by using

netstat | findstr MasterComputerName

So if my master computer name is "SHLOMI-BAZEL" it would be netstat | findstr SHLOMI-BAZEL

If it returns an empty line, then it means the Agent has no active connection to the master, else - the connection is active.

Upvotes: 4

Related Questions