I have this unique requirement to check if the given node is running a job or not. I am thinking of using groovy as it looks easiest option.
I have found this answer
To get the name of the node, that is running the current build, just use System.getenv("NODE_NAME")
When a Jenkins job executes, it sets some environment variables..
You may find these variables very useful. Check this link