The code will return something like this. Keep in mind the question mark has a value that is passed in with the command. I do not know how to strip out the binary around it so I choose to exclude it so I can at least get the SQL commands executed. For me this told me that the application was doing a nice SQL statement to start with then doing a not so friendly one after. I was able to go back to the developer and ask him to chase this down.

October 20, 2008

I have had the need to monitor Java webapps. There are two ways of doing this. One is via SNMP into the JVM and the other is via JMX. Once you make the configuration changes you will need to restart tomcat. Once tomcat is restarted you will want to make sure those ports were opened and are currently being listened on by java. Run “sudo /usr/sbin/lsof | grep :” then look for your port numbers you chose to bind SNMP/JMX to. If they are not listed then they did not bind and you are going to want to simplify your JAVA_OPTS down to just the bare basics + the port commands. Keep in mind applying these configuration to JAVA_OPTS means it will try to do these are start/stop of the JVM which will result in an error in your logs saying something like “the port is already bound”

Add this to your “/etc/sysconfig/tomcat5”. Comment out any JAVA_OPTS (if they are redundant to what is below) you have uncommented and move them to this one if you have extra values. Exclude the all after the snmp line if you only want SNMP monitoring.

# Disable SSL support (I have not played with getting it setup yet) (options: true/false)

-Dcom.sun.management.jmxremote.ssl=false

# Specify the JMX management port

-Dcom.sun.management.jmxremote.port=

# Enable local jmx management from the localhost

-Dcom.sun.management.jmxremote

# Suppose to enable headless connection where X is required…aka forward jconsole from the server to your X server.

-Djava.awt.headless=true

# Used to enable SNMP access to the JVM interface. If you use this you will need to enable the snmp.acl as well to set the community/access control

-Dcom.sun.management.snmp.port=

# /usr/java/jdk1.6.0_03/jre/lib/management/snmp.acl (you should already have a smp.acl.template installed as a part of your JDK) (chmod 600, chown user/group ). IF YOU HAVE A DIFFERENT JDK AND/OR LOCATION KEEP THAT IN MIND!!!

# Need to add a proxy line so snmp proxy will hit the JMX snmp port when we query the server for the SNMP info. Get system and JMX info in one query.proxy -v 2c -c cotssnmp localhost:9004 .1.3.6.1.4.1.42

#
# Trouble shooting
#
A good set of tools to have are same JMX server/client java tools that you can run outside your tomcat JVM containers to make sure your system is accessable.

October 14, 2008

This is how to add a index to a table. Adding this single index for syslog data added about a index (idx) file of about 12% of the size of the sys_log table data size. alter table sys_log add index (timestamp);

Rename the original “sys_log” table to a new name “syslog_backup_table” and rename your temp syslog table (sys_tmp) to the orignal name syslog table name “sys_log”;rename table sys_log TO syslog_backup_table, sys_tmp to sys_log;

insert data into sys_log from “syslog_backup_table” where the timestamp field is greater than x time.insert into sys_log select * from syslog_backup_table where timestamp > 1220227200000;