How to get the number of workers in a machine or cluster node?

In a distributed program, how do you programmatically obtain the number of workers on the node of a cluster where a code is running?

For example, if there were 6 workers launched using addprocs ([(“machine1", 4), (“machine2", 2)]), a code on machine1 would receive 4 as a result, while a code on machine2 would receive 2.

try length(procs(myid()))