Script to monitor the process


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to monitor the process
# 1  
Old 04-01-2013
Script to monitor the process

Hi,

I need help to monitoring a process using the shell script
The same output is below

oracle 32578 32577 0 Feb27 ? 00:06:47 java -cp .:lib/ant.jar:lib/ojdbc5.jar:lib/log4j-1.2.17.jar:/ORACLE_HOME/server/lib/wlfullclient.jar:/ORACLE _HOME/server/lib/weblogic.jar:Alerts.jar com.alert.wrapper.AlertPullWrapper


I am trying the below script, will keep you updated incase of any help, thanks again!

Code:
[#!/bin/ksh
pid=""
pid='ps -ef | grep "<process string>" | awk ' {print $2}''
echo $pid
if [ "$pid"="" ]
then 
echo "process not running"
rsh <mail server> mailx -s "<etc etc process not running>" <mail.id>
else
echo service is ok
pid=""
fi
]

Thanks much in advance

Last edited by DukeNuke2; 04-02-2013 at 03:01 AM..
# 2  
Old 04-01-2013
By monitor, what are you expecting the script to do?

--ahamed
# 3  
Old 04-01-2013
The script will monitor the process and should send an email if the process is stopped or killed

---------- Post updated at 05:18 PM ---------- Previous update was at 05:07 PM ----------

Hi I tried the above one
Code:
ps -ef | grep "AlertPullWrapper" | awk '{print $2}'
20031
20032
24474


It gives 3 PID's , I need to validate only with the second one 20032, how can I do that?

Last edited by Franklin52; 04-02-2013 at 08:49 AM.. Reason: Please use code tags
# 4  
Old 04-01-2013
I would suggest to use pgrep instead which is tailor made for similar requirement:
Code:
pgrep AlertPullWrapper

# 5  
Old 04-01-2013
Hi,

Thanks for your reply
I tried pgrep "AlertPullWrapper" , but it did not give any results
# 6  
Old 04-01-2013
pgrep works on the process name, here the process is java.

Can you paste the output of ps -eaf | grep AlertPullWrapper

The 1 PID is probably that of grep, but not sure about the other one.

--ahamed
# 7  
Old 04-01-2013
Hi Please find below

# ps -eaf | grep AlertPullWrapper
oracle 20031 1 0 Jan21 ? 00:00:00 bash AlertPullWrapper.sh
oracle 20032 20031 0 Jan21 ? 00:25:19 java -cp .:lib/ant.jar:lib/ojdbc5.jar:lib/log4j-1.2.17.jar:/ORACLE_HOME/server/lib/wlfullclient.jar:/ORACLE_HOME/server/lib/weblogic.jar:Alerts.jar com.alert.wrapper.AlertPullWrapper
oracle 24741 24025 0 17:28 pts/1 00:00:00 grep AlertPullWrapper
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Powershell script to monitor windows process

Hello Friend, I am not expert in power shell scripting. I nee custom powershell script which check if given process is running on windows machine or not. will use it in nagios to monitor that process. (0 Replies)
Discussion started by: ghpradeep
0 Replies

2. Shell Programming and Scripting

Monitor log when Process comes UP

Hi, I need to grep a pattern in the log file of a process and send a mail if pattern found.But I am not able to figure out how do I detect when the process comes UP,it is started several times a day and each time it is started I need to perform this action. Please suggest something. (3 Replies)
Discussion started by: vishal bhargava
3 Replies

3. Shell Programming and Scripting

Shell script to monitor process with high CPU

Hi, Linux redhat 5.5 I need to write a kshell script that shows all the process that consume 100% CPU (or more. strange but there are time that top shows higger value that 100) and they are active more than 5 minute. The top command shows all the relevat information: The PID of the cpu ,... (0 Replies)
Discussion started by: yoavbe
0 Replies

4. Shell Programming and Scripting

Script to Monitor windows process

Hi Guys, I'm looking for a script( preferably perl script) which should monitor a application service and alert me when it goes down. application is installed in windows NT. Scenario: I have remedy ARS 6.1 installed in windows platform and need some script to monitor its service and alert me... (2 Replies)
Discussion started by: user__user3110
2 Replies

5. Shell Programming and Scripting

Script to monitor a process and track status in a file

i have a scenario where i need a script that monitors a process "Monitor" based on process id... there can be any number of instances of this running... i start this across 4 servers in NFS. Now i need a file which has the process ids of the process that are currently in execution at any... (9 Replies)
Discussion started by: niteesh_!7
9 Replies

6. Shell Programming and Scripting

Script to Monitor a Process with Top.

Hi, I have written a script to monitor a Process with the help of top command. This is my script. ====================== #!/bin/sh DATE=`date +%Y%m%d%H%M%S` HOME=/home/xmp/testing/xmp_report RADIUS_PID=`xms -xmp sh pr | grep "RADIUS.iamsp02ldv" |awk '{ print $3 }'` PSE_PID=`xms -xmp sh... (5 Replies)
Discussion started by: Siddheshk
5 Replies

7. Shell Programming and Scripting

script to monitor the process system when a process from user takes longer than 15 min run.

get email notification from from system when a process from XXXX user takes longer than 15 min run.Let me know the time estimation for the same. hi ,any one please tell me , how to write a script to get email notification from system when a process from as mentioned above a xxxx user takes... (1 Reply)
Discussion started by: kirankrishna3
1 Replies

8. Shell Programming and Scripting

script to monitor process running on server and posting a mail if any process is dead

Hello all, I would be happy if any one could help me with a shell script that would determine all the processes running on a Unix server and post a mail if any of the process is not running or aborted. Thanks in advance Regards, pradeep kulkarni. :mad: (13 Replies)
Discussion started by: pradeepmacha
13 Replies

9. Shell Programming and Scripting

not able to monitor the process

hi all I am running a script monitor using source command. the shell script monitor is used to execute a pl/sql procedure. when i do source monitor and then ps -ef | grep <procedure name> i do not get any info but when i do sh monitor and then ps -ef | grep <procedure name> i... (8 Replies)
Discussion started by: infyanurag
8 Replies

10. Programming

How to monitor if a process is running

I would like to know if i can monitor if a process is running. I have one program wich is running all the time, called oliba, but sometimes it goes down, and I have to launch it again. Is there a way to monitor the pid of the program, and if the program goes down, to lauch it again? Can you give... (3 Replies)
Discussion started by: Pedro Tavares
3 Replies
Login or Register to Ask a Question