Skip to content

Instantly share code, notes, and snippets.

@thcipriani
Created November 26, 2018 16:52
Show Gist options
  • Save thcipriani/4a40d93337222f16e4e1dae1329f0487 to your computer and use it in GitHub Desktop.
Save thcipriani/4a40d93337222f16e4e1dae1329f0487 to your computer and use it in GitHub Desktop.
Quick groovy script to check disk-space on a subset of integration machines via the script console.
import hudson.util.RemotingDiagnostics
def groovyScript = 'println "df -h /srv".execute().text'
def computerNamePrefix = 'integration-slave-'
for (slave in hudson.model.Hudson.instance.slaves) {
def computer = slave.computer
def computerName = computer.getName()
// Only check nodes that are named like integration-agents
if (!computerName.startsWith(computerNamePrefix)) {
continue
}
println "Checking ${computerName}..."
if (computer.isOffline()) {
println "${computerName} Offline..."
continue
}
println RemotingDiagnostics.executeGroovy(
groovyScript,
computer.getChannel()
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment