How to get jboss pid?

I am writing SSH (actually Python via SSH) commandline to get jboss PID from a remote machine (Redhat), how can I do it?

I usually have the patten like:

run('some_linux_command')

What should be 'some_linux_comand' be here?

I also tried a shell script (I found in internet) local on the machine

But it return nothing, while I used 'ps -ef | grep jboss' returned information with the PID.

Any idea?

PID=$(ps -ef | awk '/jbos/ {print $2}')
ssh <user>@<remote_host> 'pgrep -f jboss'

Thank you guys for your help. It works now!

---------- Post updated at 04:09 PM ---------- Previous update was at 11:51 AM ----------

Woops, I guess I should have tried more before I replied.

Now I have issues -

The command I used ps -ef | awk '/jbos[s]/ {print $2} some time return one number which is correct and I can kill the process using the number - that's what happened when I replied; but later I found that it sometime returned two numbers, the first one is not the right one so my program trying to kill the process failed and quit.

Then I logged on the remote machine and tried to get the jboss (ps -ef | grep jboss), I did see the output:

You can see that my program returned the right number (32261) in the first trial, but after jboss was restarted, the second run of my program failed because it returned 507 and 530 (530 is the right one but program failed trying to kill 507 first).

I am new Linux user and would like to know why is that, and how can I modify my program (or the command) to make it always work?

Thanks,
Peter