<body><script type="text/javascript"> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener('load', function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } } </script> <div id="navbar-iframe-container"></div> <script type="text/javascript" src="https://apis.google.com/js/platform.js"></script> <script type="text/javascript"> gapi.load("gapi.iframes:gapi.iframes.style.bubble", function() { if (gapi.iframes && gapi.iframes.getContext) { gapi.iframes.getContext().openChild({ url: 'https://www.blogger.com/navbar.g?targetBlogID\x3d11356004\x26blogName\x3dxception\x26publishMode\x3dPUBLISH_MODE_BLOGSPOT\x26navbarType\x3dBLUE\x26layoutType\x3dCLASSIC\x26searchRoot\x3dhttps://openrent.blogspot.com/search\x26blogLocale\x3den_US\x26v\x3d2\x26homepageUrl\x3dhttp://openrent.blogspot.com/\x26vt\x3d-4655156434419967503', where: document.getElementById("navbar-iframe-container"), id: "navbar-iframe", messageHandlersFilter: gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER, messageHandlers: { 'blogger-ping': function() {} } }); } }); </script>

Jconsole and Tomcat 5

The latest version of Sun's JDK (5.0) includes a fantastic utility called Jconsole. This program makes use of JMX (Java Management Extensions) to let you keep tabs on your JVM's. When you pair this tool with the Tomcat servlet container, you get to peek inside what was previously a black box. You can watch (in real time or historically) exactly what the JVM that runs Tomcat is doing. And you can do it remotely from your workstation.

The only prerequisite is to have the latest JDK (1.5.0_08 as of this writing) installed on both the server and workstation. After you ensure Java is installed, here's how you set it up:

1) Open the /tomcat/bin/catalina.sh file and add the following directive:
CATALINA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8004 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"

These directives will enable JMX when the Tomcat JVM is started. It tells the daemon to listen on port 8004 and to not use SSL or authentication. (NOTE: if this server is connected to open Internet, it is best to enable SSL and authentication)

2) Start Tomcat normally. You should now see port 8004 listening for JMX connections:

# netstat -pantl|grep LISTEN | grep 8004
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:8004 0.0.0.0:* LISTEN 2544/java

3) From a remote Windows workstation, invoke jconsole:
Start/Run/cmd then type: C:\Documents and Settings\Jeffrey Costa>"c:\Program Files\Java\jdk1.5.0_08\bin\jconsole.exe

4) Once the agent connection dialog box comes up, choose the "Remote" tab, and enter the IP address of the remote machine and 8004 in the "Port" field. A username and password are not necessary here.


5) Jconsole will now begin showing you information about the Tomcat JVM:

Set NTP to listen only on eth0

Open the /etc/sysconfig/ntp file, and find the OPTIONS directive.

Inside the quotes of that directive, add the following: "-L"

The final product should look like this:
OPTIONS="-L"

This directs the NTP daemon to only listen on eth0 (not on other virtual IP's).

Set NTP to log to its own file

Open the /etc/sysconfig/ntp file, and find the OPTIONS directive.

Inside the quotes of that directive, add the following: "-l /var/log/ntp.log"

The final product should look like this:
OPTIONS="-l /var/log/ntp.log"

This will cause the NTP daemon to write to the /var/log/ntp.log file instead of syslog.

Get a Java thread dump

If you want to see the threads executing in a JVM, dump it via this command:

# kill -QUIT

...where process-ID is the process number of the JVM.

Add Dag Wieers repository to RHEL 4

I personally love the "htop" utility, but hate having to manually bring it down from Dag Wieer's repository each time I want to install it on a RHEL server. If you add the Dag Wieers repository to up2date's configuration file, you can automate this process (including getting future updates). Here's how:

1) Open the up2date sources file:
vi /etc/sysconfig/rhn/sources

2) Add the repository:
yum dag http://apt.sw.be/redhat/el$releasever/en/$basearch/dag

3) Import the Dag Wieers GPG key:
# rpm --import http://dag.wieers.com/packages/RPM-GPG-KEY.dag.txt

Now you can add the htop program with the "up2date -i htop" command.