Checking running process status using "grep" on multiple servers in load sharing system.

Suppose i have 3 different servers say x,y and z.

Im running some process say ABC and 40 instances for the same is being created.
In load sharing suppose on
server x, 20 instances are running
server y, 10 instances are running
server z, 10 instances are running.

While checking the running status on server z, using command ps -ef | grep ABC |wc -l

it shows 10 instances. Is there any way to get the count of instances running on servers x and y on server z.

if i run command on server z

ps -ef | grep ABC | wc -l

it shows me 40 instances.

Thanx in advance.

Without seeing the unfiltered ps output, I cannot possibly say why it's matching 40 times.

You should be doing pgrep, not ps | grep, incidentally.