How to determine if a Unix/Linux application is running

Article:HOWTO3728  |  Created: 2006-06-01  |  Updated: 2006-08-29  |  Article URL http://www.symantec.com/docs/HOWTO3728
Article Type
How To



Question
How do I determine if a Unix/Linux application is running?

Answer

Below is a shell script that will check for a process running. All you would need to modify the proc_name variable below.

If you were using this in Monitor Solution, use a command metric that leverages the command=”” below.

If you are using this via custom inventory, use a custom inventory script that dumps the entire process list then reports on any instance that includes the Weblogic command.


###################################################################################
# A simple shell script that can be used to tell if a process is running on a     #
# UNIX/Linux computer. The working directory, process name are provided on the    #
# first two lines of the script below.                                            #
###################################################################################

proc_name="WEBLOGIC_PROC_NAME"
command=`ps aux|grep $proc_name | grep -v grep | awk '{print $11}'`
if [ -z "$command" ]; then
echo "The process ($proc_name) is NOT running (failure)"
# YOU COULD INSERT CODE HERE THAT IS EXECUTED WHEN THE PROCESS IS FOUND
# NOT TO BE RUNNING.  E.G. A COMMAND LINE THAT WOULD START THE PROCESS
# AGAIN.

else
echo "The process ($proc_name) is already running (success)"
# AGAIN YOU COULD ADD ADDITIONAL CODE HERE THAT IS EXECUTED WHEN THE PROCESS
# IS FOUND TO BE RUNNING SUCCESSFULLY.
fi


Legacy ID



23114


Article URL http://www.symantec.com/docs/HOWTO3728


Terms of use for this information are found in Legal Notices