Here's a Groovy script that could do it. It needs to be in a "System Groovy Script" build step. The last line determines the script's return status, and a non-zero status will cause the script to return failure, which will fail the job.
import hudson.model.*
def requiredNodes = ['one','two','three'];
def status = 0;
for (node in requiredNodes) {
println "Searching for $node";
slave = Hudson.instance.slaves.find({it.name == node});
if (slave != null) {
computer = slave.getComputer();
if (computer.isOffline()) {
println "Error! $node is offline.";
status = 1;
}
else {
println "OK: $node is online";
}
}
else {
println "Slave $node not found!";
status = 1;
}
}
status;