You could adapt the code used for the executor status on the left of every page in Jenkins.
Note that slaves have a number of executors, and each of them can run a build. Additional executors can be created temporarily for light-weight jobs. Either your description is simplified, or you're writing this for a _very_ specific configuration.
> --
> You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
jenkinsci-de...@googlegroups.com.
> For more options, visit
https://groups.google.com/groups/opt_out.