Process Monitoring Script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Process Monitoring Script
# 1  
Old 11-25-2008
Process Monitoring Script

I need a script on Solaris 10 OS to monitor 3 seperate processes running. Each process has 3 of the same processes running a total of 9 processes and I need the ability to know if all of processes for each process is running and to email me if they aren't running. I'm new to Unix programming and need some expert help.

Here is my test script. I need some syntax assistance. Need someone to look at script and tell me where my errors are and how it could be written better. thx

#!/bin/ksh
while true;
do
isRunning=`ps -ef | grep -v grep | grep FAME | wc -l`
if [ $isRunning -eq 3 ]
then
echo "running"
else
echo "not running"
mailx -s "<Fame process not running correctly>" unixteam@xxx.com < /dev/null
isRunning1=`ps -ef | grep -v grep | grep exx | wc -l`
if [ $isRunning1 -eq 4 ]
then
echo "running"
else
echo "not running"
mailx -s "<exx process not running correctly>" unixteam@xxx.com < /dev/null
isRunning2=`ps -ef | grep -v grep | grep history | wc -l`
if [ $isRunning2-eq 3 ]
then
echo "running"
else
echo "not running""
mailx -s "<History process not running correctly>" unixteam@xxx.com < /dev/null
fi
done.

Last edited by soupbone38; 11-25-2008 at 02:13 PM..
# 2  
Old 11-25-2008
You left out a few 'fi' statements and had one too many double quotes on one of the echo commands:

Code:
#!/bin/ksh
while true ; do
  isRunning=`ps -ef | grep -v grep | grep FAME | wc -l`
  if [ $isRunning -eq 3 ]
    then
      echo "running"
    else
      echo "not running"
      mailx -s "Fame process not running correctly" unixteam@xxx.com < /dev/null
  fi

  isRunning1=`ps -ef | grep -v grep | grep exx | wc -l`
  if [ $isRunning1 -eq 4 ]
    then
      echo "running"
    else
      echo "not running"
      mailx -s "exx process not running correctly" unixteam@xxx.com < /dev/null
  fi

  isRunning2=`ps -ef | grep -v grep | grep history | wc -l`
  if [ $isRunning2 -eq 3 ]
    then
      echo "running"
    else
      echo "not running"
      mailx -s "History process not running correctly" unixteam@xxx.com < /dev/null
  fi
done

Otherwise, it should work, but not tested.
# 3  
Old 11-25-2008
Works Great now! Thanks for you assistance!
# 4  
Old 11-25-2008
No problem. For future reference, run 'ksh -n scriptname.sh' to check your scripts for syntax errors. Same option works for bash shell too.

Cheers,
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Monitoring processes in parallel and process log file after process exits

I am writing a script to kick off a process to gather logs on multiple nodes in parallel using "&". These processes create individual log files. Which I would like to filter and convert in CSV format after they are complete. I am facing following issues: 1. Monitor all Processes parallelly.... (5 Replies)
Discussion started by: shunya
5 Replies

2. Shell Programming and Scripting

Need help with my process monitoring script

GM everyone, I have this script that goes to multiple servers and monitor a certain process and send the output to a file on servers1, the script looks like this Code: exec < server.listwhile read SERVER do ssh $SERVER "ps -ef | grep process_name" >> /tmp/reportdone can someone help me... (2 Replies)
Discussion started by: baders
2 Replies

3. Shell Programming and Scripting

need help with a process monitoring script

GM everyone, I have this script that goes to multiple servers and monitor a certain process and send the output to a file on servers1, the script looks like this exec < server.list while read SERVER do ssh $SERVER "ps -ef | grep process_name" >> /tmp/report done can someone help ad... (0 Replies)
Discussion started by: baders
0 Replies

4. Shell Programming and Scripting

Shell script for process monitoring

Im having a bit of troble coming up with a script that does this monitors processes to see if they die, if they do die, restart the process and write out to a log file that the process was restarted with the new PID and the date and time the new process was launched. Any suggestions? (1 Reply)
Discussion started by: jspinal
1 Replies

5. Shell Programming and Scripting

Help on Process Monitoring Script

Hi All, I have a Java application running in the background which process looks like this. java -DMyService=Y -DWorkingDir And I have a monitoring script which looks like this; count_service=`ps -aef | grep MyService | wc -l` if ; then echo "Service_Stopped on `date`" >>... (6 Replies)
Discussion started by: swmk
6 Replies

6. Shell Programming and Scripting

Error in script to automate the daily monitoring process of UNIX server and it's proc

hi friends, I am trying to automate the daily monitoring process of UNIX server and it's processes. the script are below i executed the above script using ksh -x monitortest1.sh in root login . It shows error at some lines . 1. i logged in using root ,but it... (8 Replies)
Discussion started by: rdhaprakasam
8 Replies

7. Shell Programming and Scripting

process monitoring

hi all, i would like to write the shell script to monitoring the processing, but if i passing the parameter the number of process is incorrect how to slove it? many thx got the correct number of process as following script: ===========================================================... (3 Replies)
Discussion started by: eric_wong_ch
3 Replies

8. Shell Programming and Scripting

Process Monitoring Script Help

I have a shell script which runs from 7AM to 3AM every day. The script performs certain monitoring functions and if it has a problem it may need to email someone about it. The problem is that the notification process was never modified to handle running past midnight (from 23:59:59 till 3AM). ... (0 Replies)
Discussion started by: rdc69
0 Replies

9. UNIX for Dummies Questions & Answers

Monitoring ftp process

I have an ftp process using vpn, my box is receiving data hit and miss from the host system. Any tool that can be used within unix (ksh) to monitor that ftp process? (2 Replies)
Discussion started by: arkhewit
2 Replies
Login or Register to Ask a Question