Sponsored Content
Top Forums Shell Programming and Scripting Monitoring Tomcat Instance using shell script Post 302472517 by Scrutinizer on Wednesday 17th of November 2010 10:35:10 AM
Old 11-17-2010
or use the POSIX builtin:
Code:
i=$(( i+1 ))

or use:
Code:
$(( i+=1 ))

Code:
cnt=0
..
echo "Application Server Tomcat$((cnt+=1)) is running fine on marsvcp1

---------- Post updated at 16:35 ---------- Previous update was at 16:13 ----------

Alternatively you could do something like this:
shell code:
  1. tomcat_running() {
  2.   ps -eaf | grep -qi [j]dk160_05_$1
  3. }
  4.  
  5. for i in 1 2 3 4 5 6
  6. do
  7.   if tomcat_running $i; then
  8.     echo "Application Server Tomcat$i is running fine on marsvcp1 @ $(date)" >>/root/home/root/tomcatstatus.txt
  9.   else
  10.     echo "Application Server Tomcat$i is down on marsvcp1" | mailx -s "tomcatserver $i of marsvcp1 is down" $email
  11.   fi
  12. done
Note: be careful if the number of instance becomes larger than 9 then the i=1 matches jdk160_05_1 as well as jdk160_05_10

or, more efficient:
shell code:
  1. PS_STRING=$(ps -eaf | grep -i [j]dk160_05_)
  2.  
  3. for i in 1 2 3 4 5 6
  4. do
  5.   case $PS_STRING in
  6.     *"jdk160_05_$i"*)
  7.         echo "Application Server Tomcat$i is running fine on marsvcp1 @ $(date)" >>/root/home/root/tomcatstatus.txt ;;
  8.     *)  
  9.         echo "Application Server Tomcat$i is down on marsvcp1" | mailx -s "tomcatserver $i of marsvcp1 is down" $email ;;
  10.   esac
  11. done

Last edited by Scrutinizer; 11-17-2010 at 03:47 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Single Instance of a Shell Script

Hi, I have a shell script. What should I do to allow only single instance of the script to be run by a user at a time. That is, Only one user can run that script at a given point of time. Please help.. Its very important for my project Thanks in advance (4 Replies)
Discussion started by: pathanjalireddy
4 Replies

2. Shell Programming and Scripting

fetch hostname and instance name using shell script

Hi All, Requirement is to fetch hostname and instance name using shell script from all configuration files on a server R12 on IBM AIX... could anyone please share such an experience encountered before.Is there such a script available in this forum or any other site.. Thanks for your time!... (0 Replies)
Discussion started by: a1_win
0 Replies

3. UNIX for Advanced & Expert Users

Multiple Instance of Unix Shell Script

Hi All, I have a problem mentioned below. I have a script which performs line by line operations on several files. I have a temp_file storing the list of names of the file to be validated. Right not in while loop i validate these files one by one. Is there anyway that i can modify... (1 Reply)
Discussion started by: amitaryans
1 Replies

4. Shell Programming and Scripting

Need help in writing a shell Script to connect to oracle instance

Please help me in writing a shell script which connects to a Oracle instance and tables to get the required information...:wall: (1 Reply)
Discussion started by: Dpu
1 Replies

5. 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

6. Shell Programming and Scripting

Multiple instance in tomcat

I need to install a tomcat6 with multiple instances like instance1,instance2 and instance3 in a server. I came to know that for that we need to install tomcat6,apache2.0,mod_jk1.2 and jre with tools.jar installed.And we need to create multiple instances with same web.xml and difference... (0 Replies)
Discussion started by: tuxslonik
0 Replies

7. Shell Programming and Scripting

Tomcat Monitoring log file

Hi, I ned to monitor the tomcat log file called "catalina.out" for "OutOfMemory" ,"java.sql.SQLException" and "Error" error. the script should monitor this file (catalina.out) and send us the mail as soon as it finds the string "Out of memory" or "java.sql.SQLException" or "Error" in the... (2 Replies)
Discussion started by: mnmonu
2 Replies

8. Shell Programming and Scripting

Monitoring Tomcat Service with shell script

Hello Forum, I have prepared script to monitor the tomcat status. Following is the script which will monitor tomcat instance. I need little modifcation in the script. My script will grep for process, the output of grep command will analyze by if condition under for loop and will send... (2 Replies)
Discussion started by: ooilinlove
2 Replies

9. Shell Programming and Scripting

Shell Monitoring Script

Hi guys, I didn't understand this monitoring script request - I don't ask for the script result. If you understand the request, I'm just asking an explanation to simplify it for me. THE Script Request: Our organization keeps various files in directories structured as... (2 Replies)
Discussion started by: moshesa
2 Replies

10. UNIX for Beginners Questions & Answers

Server monitoring using shell script

I want to write a shell script which is used in cron job and it runs every 4 hours to check whether tomcat servers are running or not . If servers are not running , one email should be triggered like alert notification. if servers are Running then no need to print anything. This is what i want... (5 Replies)
Discussion started by: kk123
5 Replies
All times are GMT -4. The time now is 03:11 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy