Resolution
First, Node Monitoring can be configured at Manage Jenkins/Manage Nodes/Configure. The default Free Space Threshold is set to 1GB which means that nodes are not allocated if the amount of Free Space is under 1GB. This is a setup for all agents.
A way to monitor a specific thread is to use Managing build agents with Nodes Plus plugin. A probe command can be specified to decide whether or not a node is able to accept tasks. If the command returns an exit code other than 0, the agent cannot accept tasks. The best way to use this feature is to create a script on the agent machine and launch it as a probe command.
Example
I want to prevent my unix node from being allocated if the Disk Usage is over 80%.
The following command gives me the file system usage on the machine:
my-agent:~$ df -h Filesystem Size Used Avail Use% Mounted on /dev/disk1 233G 138G 96G 60% /
My $AGENT_HOME is located on /dev/disk1
so I can workout a command like the following to grab the usage value (Use%
is the fifth value in the line) of this disk:
my-agent:~$ df -h | grep /dev/disk1 | awk '{print $5}' | sed 's/%//g' 60
I can then create a probe.sh located under $AGENT_HOME to exit with error code -1 when my disk usage is over 80%:
#!/bin/bash CURRENT=$(df -h | grep /dev/disk1 | awk '{print $5}' | sed 's/%//g') THRESHOLD=80 if [ $CURRENT -gt $THRESHOLD ]; then exit -1 fi
I configure my node with the probe as following:
