Script help

Hello Experts,
I am having an issue whereby multiple instances of Tomcat are starting on one of the servers I monitor.

Could a script be written that would return a count of how many instances of Tomcat are running? Is there a way to get a "count" of number of tomcat processes running in system?

Basically I need a lua script for use with Intellipool that will go run a script on the remote web server, and tell me how many instances of tomcat are running. That way if more than 1 Tomcat process is running it will throw up and error so that I can go resolve the issue.

Thanks in Advance!

What executable does tomcat run? java, javac, jdb or something like that?

If you know the executable (substitute it below), you can get a list of processes and count them like this:

ps -C executable --no-heading | wc -l