Extract setenv.sh memory settings in Tomcat


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Extract setenv.sh memory settings in Tomcat
# 1  
Old 02-26-2015
Extract setenv.sh memory settings in Tomcat

**newbie**

I need to review all of our Tomcat setenv.sh jvm heap settings to ensure they are properly set. I attempted to pull the memory configs with an awk - but this was an issue because each file is slightly different, and the position of the memory config is different in each file.

Does anyone have any advice on how to accomplish this (besides manually reviewing each file)?

Ideally, I would like to pull the jvm heap settings & the jvm directory that they are in.

For example, I have /opt/dir1/dir2/dir3 - where dir3 is the specific jvm
and the setenv.sh is in /opt/dir1/dir2/dir3/tomcat/bin/

I would like results along the lines of:

dir3 -Xms1536m -Xmx1536m

Is this possible? Smilie

Last edited by kgolli; 02-26-2015 at 01:45 PM..
# 2  
Old 02-26-2015
A quick and dirty solution could be something like:
Code:
for appname in A B C
do
   jvm_args=$(grep JAVA_OPTS /opt/dir1/dir2/${appname}/tomcat/bin/setenv.sh | tr ' ' '\n' | grep -E "Xmx|Xms" | tr '\n' ' ')
   echo "${appname} ${jvm_args}"
done

# 3  
Old 02-26-2015
Quote:
Originally Posted by CarloM
A quick and dirty solution could be something like:
Code:
for appname in A B C
do
   jvm_args=$(grep JAVA_OPTS /opt/dir1/dir2/${appname}/tomcat/bin/setenv.sh | tr ' ' '\n' | grep -E "Xmx|Xms" | tr '\n' ' ')
   echo "${appname} ${jvm_args}"
done

Thank you. I tried this and my output was only appname, no jvm args. For example:

dir3a
dir3b
dir3c
# 4  
Old 02-26-2015
Post your setenv file (sanitised if necessary).
# 5  
Old 02-26-2015
Well, part of the problem is that we have several jvms running, each with their own setenv, so each file can be slightly different, and the placement of the args is different. For example:

setenv1 could look like
CATALINA_OPTS='-Dtarget.env=bcp -server -Xms1024m -Xmx1024m -XX:NewRatio=2 -XX:MaxPermSize=170m

setenv2
CATALINA_OPTS='-server -Xms1536m -Xmx1536m -XX:NewRatio=2 -XX:MaxPermSize=170m'

setenv3
JAVA_OPTS="-Djsse.enableSNIExtension=false"
CATALINA_OPTS='-server -Xms6000m -Xmx6000m -XX:NewRatio=2 -XX:MaxPermSize=1512m
# 6  
Old 02-27-2015
You can just change the grep:
Code:
jvm_args=$(grep -E "JAVA_OPTS|CATALINA_OPTS" /opt/dir1/dir2/${appname}/tomcat/bin/setenv.sh | tr ' ' '\n' | grep -E "Xmx|Xms" | tr '\n' ' ')

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Tomcat..Unable to deploy application remotely in tomcat

Hi, We have upgrade tomcat from 5.0.20 to 7.0.33 and made changes to server.xml file according to newer version.. how ever the upgrade went fine and now i am unable to deploy application remotely.. it is giving 403 access denied error.. we have seperate appbase directory mentioned in server.xml..... (0 Replies)
Discussion started by: phani4u
0 Replies

2. Solaris

jvm memory settings

When i changed jvm memory settings from 3048 to 3548, appsserver could not start. if no change , it was normal. How do we change .otherwise i had a out of swap space error appeared after 3hrs period when do the monitoring of java application. (1 Reply)
Discussion started by: vijill
1 Replies

3. UNIX for Dummies Questions & Answers

Extract monitor model from nvidia-settings

Hi all, not sure where to put this post, so here will do. I have posted this question before in this thread but after getting the huge quantity of very helpful answers I did (lol?), I have looked at the problem again. A basic rundown is that I need to extract monitor information about connected... (2 Replies)
Discussion started by: mpcengineering
2 Replies

4. UNIX for Advanced & Expert Users

setenv.

helllo every body .. hope you are having good time programming in unix . here is a little problem faced me : setenv("myvar","bla bla",1); system("myvar=$(grep....)); printf("%s\n", getenv("myvar")); will print : bla bla .. how can i get the value of grep into my program ? ... (7 Replies)
Discussion started by: max_475
7 Replies

5. Shell Programming and Scripting

setenv error

I am having the following environment setup script. $cat dbenv.sh #! /bin/csh # set history=32 stty sane setenv ORACLE_HOME=/dboracle/orabase/product/10.1.0.3 set ORACLE_BASE=/dboracle/orabase set... (2 Replies)
Discussion started by: rahulrathod
2 Replies

6. Shell Programming and Scripting

how can i extract only the Memory line from top command ?

Hello all i need in csh to extract only the Memory line from the out put of the top command how can it easily done (1 Reply)
Discussion started by: umen
1 Replies

7. Shell Programming and Scripting

setenv in script

Is it possible to set environement variable in a script (for example, perl script) so that the variable will be set after exiting the script - in a father shell. (2 Replies)
Discussion started by: kosta_mirkin
2 Replies

8. Shell Programming and Scripting

What 's setenv?

Hi Is someone know about "setenv"? where can i find out this one? Regards Myoe (2 Replies)
Discussion started by: myoeminn
2 Replies

9. UNIX for Dummies Questions & Answers

set, setenv

Well first of all I am a real Unix newbie. I am taking a course on it in University. I kind of understand set and setenv but, I think it si something that I should really understand. So I thought that I would try a forum out and see how good you guys really are. The question: Execute the... (1 Reply)
Discussion started by: w6u6f
1 Replies

10. UNIX for Dummies Questions & Answers

setenv Question

I want to add paths to a CLASSPATH variable but if I use the : setenv CLASSPATH /opt all previous entries are erased. How do I append additional entries to a system variable without overwriting the original value. Thanx (3 Replies)
Discussion started by: ianf
3 Replies
Login or Register to Ask a Question