Help with Monitoring script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with Monitoring script
# 1  
Old 05-18-2010
Help with Monitoring script

Hi Gurus,

Currently I am learning UNIX through online forums and unix blogs. I have the below requirement.

I need to write a script to monitor server processes. For example, there are 3 processes currently running on the server.(java, pmrepagent, pmserver). If any of the process goes down, then i need to send out an email to the user.I am trying to achieve this by using ps -ef | grep info command. when I execute this command, i get the information about the above processes. Now I need to look for the above 3 processes and if any of the process is not displayed in the information which i got from the command, then it should send out an email. I need to run this scrip in every 10 mins. I have started writing the script then I am not able to complete the script. Please help me with this.

Code:
#!/bin/ksh
get_process=`ps -ef | grep info > process.out`


Below is the output from process.out

Code:
informat  3340     1  1 Apr23 ?        11:14:25 /apps/informatica/product/pc860/FIN/info-dev-02/java/jre/bin/java -Djava.awt.headless=true -Duser.dir=/apps/informatica/product/pc860/FIN/info-dev-02/server/tomcat/bin -DINFA_HOME=/apps/informatica/product/pc860/FIN/info-dev-02 -DINFA_DEV_LOG_DIR= -DINFA_DOMAINS_FILE=/apps/informatica/product/pc860/FIN/info-dev-02/domains.infa -Djava.endorsed.dirs=/apps/informatica/product/pc860/FIN/info-dev-02/server/tomcat/common/endorsed -classpath :/apps/informatica/product/pc860/FIN/info-dev-02/server/tomcat/bin/bootstrap.jar:/apps/informatica/product/pc860/FIN/info-dev-02/server/tomcat/bin/commons-logging-api.jar -Dcatalina.base=/apps/informatica/product/pc860/FIN/info-dev-02/server/tomcat -Dcatalina.home=/apps/informatica/product/pc860/FIN/info-dev-02/server/tomcat -Djava.io.tmpdir=/apps/informatica/product/pc860/FIN/info-dev-02/server/tomcat/temp -Dinfa.masterUpdateTimeInterval=30000 org.apache.catalina.startup.Bootstrap start
informat  3652  3340  0 Apr23 ?        01:10:22 /apps/informatica/product/pc860/FIN/info-dev-02/server/bin/pmrepagent - RG9tYWluX2luZm8tZGV2LTAy RUFfRklOX0RFVl84NjA= bm9kZTAxX2luZm8tZGV2LTAy aHR0cDovL2luZm8tZGV2LTAyOjcwMDU= d2h2ZnZVUURyT0FwaEJwSm9Sc0p6ZGR0N2IwcTZXbW10S0M2TUp2cFZjNjl1N2NxZkc1OS9LY0d3dG5Ca0wrL3dxVWVUNmkrbGZxb1NKb2l0YStndzFMMnBWK094czNhb3c0cjVSU3VxVS9tVWpuWnhLSFI2SVVVam1rL0trQU9jbVhxS2JBZWs5TWxoY016MHE4Z2R2SHhRN2lLK296ZTdwaDF6UFY1TThIdUJRUmtrMXJxeXhCZjZWbmlEMnc1UjdzUXFBbFZPZ2JvZTNxVEVwUmhKQT09 MTI3MjA0MTg5NDEzOQ==
informat  3693  3340  0 Apr23 ?        00:14:51 /apps/informatica/product/pc860/FIN/info-dev-02/server/bin/pmserver RG9tYWluX2luZm8tZGV2LTAy RUFfRklOX0RFVl84NjBfSW50ZWdyYXRpb25fU2VydmljZQ== bm9kZTAxX2luZm8tZGV2LTAy aHR0cDovL2luZm8tZGV2LTAyOjcwMDU= d2h2ZnZVUURyT0FwaEJwSm9Sc0p6ZGR0N2IwcTZXbW10S0M2TUp2cFZjNjl1N2NxZkc1OS9LY0d3dG5Ca0wrL3dxVWVUNmkrbGZxb1NKb2l0YStndzFMMnBWK094czNhb3c0cjVSU3VxVS9tVWpuWnhLSFI2SVVVam1rL0trQU9jbVhxS2JBZWs5TWxoY016MHE4Z2R2SHhRN2lLK296ZTdwaDF6UFY1TThIdUJRUmtrMXJxeXhCZjZWbmlEMnc1UjdzUXFBbFZPZ2JvZTNxVEVwUmhKQT09 MTI3MjA0MTg5NDEzOQ==
informat  3909  3340  0 Apr23 ?        00:00:00 /bin/sh /apps/informatica/product/pc860/FIN/info-dev-02/server/tomcat/jboss/bin/run.sh -c informatica
informat  3930  3909  0 Apr23 ?        00:37:55 /apps/informatica/product/pc860/FIN/info-dev-02/java/bin/java -Dprogram.name=run.sh -server -DINFA_HOME=/apps/informatica/product/pc860/FIN/info-dev-02 -Dfile.encoding=UTF-8 -Xms128m -Xmx512m -XX:MaxPermSize=256m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djava.net.preferIPv4Stack=true -Djava.awt.headless=true -Djava.endorsed.dirs=/apps/informatica/product/pc860/FIN/info-dev-02/server/tomcat/jboss/lib/endorsed -classpath /apps/informatica/product/pc860/FIN/info-dev-02/server/tomcat/jboss/bin/run.jar:/apps/informatica/product/pc860/FIN/info-dev-02/java/lib/tools.jar org.jboss.Main -c informatica

Thanks in advance,
Sam

Last edited by pludi; 05-19-2010 at 02:11 AM.. Reason: code tags, please...
# 2  
Old 05-19-2010
the way which you are following is error prone.

try to use monit which is more promising than your current method.
# 3  
Old 05-19-2010
Currently we are not looking to use any tool to monitor the server. we would rather prefer to develop the program to do the same. Can someone help me on this?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with a monitoring script

I currently have a shellscript to check the size of a filesystem and email me if the size is over a certain percentage (80%). I have this script on crontab and executes the shell every 10 mins. I have the above in place on 8 servers. It so happens that a file system on one of the servers is... (1 Reply)
Discussion started by: goddevil
1 Replies

2. Shell Programming and Scripting

Monitoring Script

Hello All, I have written a script which will grep for error codes in a file and if the count for the same is about 500 it will send and smpp alert. Here is my code. #!/bin/bash #########################################################################################################... (3 Replies)
Discussion started by: Siddheshk
3 Replies

3. UNIX for Advanced & Expert Users

ldapsearch in monitoring script without bind password written in script

Hi I do a very simple monitoring of our OpenLDAP (runs in cronjob and generate alerts if unsuccessfull) $ ldapsearch -h hostname.domain -D "cn=monitor_user,ou=People,dc=organisation" -w "password" -b "dc=organisation" -x "(&(cn=monitor_user)(ou=People))" dn | grep -v version dn:... (4 Replies)
Discussion started by: slashdotweenie
4 Replies

4. Red Hat

monitoring script

Hi, I ned to monitor the memory for the red-hat machine,when its reaches a threshold value like 2GB then a mail should be sent as soon as it finds the the value is met can you suggest me which is the best way to do this? (2 Replies)
Discussion started by: sriniv666
2 Replies

5. Shell Programming and Scripting

Monitoring script

Hi, I want to write script that monitors particular ports in a server. I completed the script but.... If the server is restarted i need manually start the script.. Is there any way i can make the script start by it self after the server reboot........ Thanks, Firestar (4 Replies)
Discussion started by: firestar
4 Replies

6. Shell Programming and Scripting

Archivelog monitoring Script

Could anyone please help? I have written a small program that's actually working fine for me and extracting all the details I required. What code does is, it goes to all archivelog directories and see if archivelog backup was failed or successful <<CODE>> ... (2 Replies)
Discussion started by: anjum.suri
2 Replies

7. Shell Programming and Scripting

IP Monitoring Script

Dear All, I am new to Shell Programming, but I need a script which will monitor the different IP's in the live logs. Condition:- The script will monitor the logs continously and should print only those IP's which exists more than 3 times per day. Please do help me. Thanks and... (1 Reply)
Discussion started by: akhtar.bhat
1 Replies

8. Solaris

Monitoring Script

Hi, I want to write a script that will monitor cpu,mem usage and disk usage for entire day and data will be redirected to file, (4 Replies)
Discussion started by: manoj.solaris
4 Replies

9. UNIX for Advanced & Expert Users

monitoring script

i have a unix batch written in c, dealing with really time-consuming database operations i want to write a ksh script to monitor its performance. which items i should monitor? do you have any suggestions? 1)cputime 2)swap area 3)pmem 4) 5) what else? (1 Reply)
Discussion started by: gfhgfnhhn
1 Replies

10. UNIX for Dummies Questions & Answers

monitoring script

hi can someone help me to write a script to monitor the growth of the directory running at 5 hours interval and then pipe it to a file :(? i only know the manual command "du -sk" and the worst i dun know anything about script. (3 Replies)
Discussion started by: legato
3 Replies
Login or Register to Ask a Question