java log files

So debugging java can be a mighty pain, a little few lines of ways to make it simpler.


# grep -m 1 -n '^2010-06-30 14:20:' catalina.out
11746233:2010-06-30 14:20:01,011 DEBUG com.beginning.of.line
# grep -m 1 -n '^2010-06-30 14:21:' catalina.out
11747788:2010-06-30 14:21:00,161 WARN org.apache.commons.httpclient.HttpMethodBase - Going to buffer response body of large or unknown size. Using getResponseBodyAsStream instead is recommended
# sed -n '11746233,11747788p' < catalina.out

This gives start line and end line between any two greps and then the body of the log file from those two lines.

Snow Leopard and the jvm


So in a startling case of “Apple knows best” they have gone and removed the 1.5 JVM – I know it’s pretty old and people were complaining about not having a 1.6 JVM for a long time – but really!

So the following post steps you through re-enabling the 1.5 VM and now semi-happy days

SNMP over SSH tunnels

Sometimes you just need to tunnel UDP based protocols – such as SNMP – and the easiest ways is to use socat


socat tcp4-listen:6667,reuseaddr,fork UDP:DESTINATION:161
socat udp4-listen:161,reuseaddr,fork tcp:localhost:6667

And in combination with your normal SSH tunnel


ssh -L6667:localhost:6667 BASTION_HOST

Smokeping and measuring SOAP requests

We’ve had an issue with performance of a SOAP interface, and here’s how you go about setting up smokeping to time it:-

extraargs = -H Content-Type:text/xml --data @/srv/scripts/soap_check/soap-test.xml
urlformat = http://server.name.com/url/soap_url

The only annoying problem is that the SOAP payload cannot be included as part of the command line, so any slaves would require the file manually copied into the same location

UTF-8 and MySQL databases

Nice bugs that no one seems to want to fix:-


mysql> create table test5 (
wibble varchar(500), PRIMARY KEY (wibble)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes


mysql> create table test5 (
wibble varchar(500), PRIMARY KEY (wibble)
) ENGINE=myisam DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
ERROR 1071 (42000): Specified key was too long; max key length is 1332 bytes

And even with MySQL 6.0.9 (using the Falcon engine which is still brand new)

mysql> create table test5 (
wibble varchar(500), PRIMARY KEY (wibble)
) ENGINE=falcon DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
ERROR 1071 (42000): Specified key was too long; max key length is 1100 bytes

securing wordpress

Notes on how to secure wordpress 2.7.1 (this is all pretty well documented, but I ran into a couple of dohs!)

o Remove the default admin user
o Create a user you want to login as
o Login as this new user
o Remove the ‘admin’ user – assign all posts to new user

o Force all admin features via HTTPS, edit wp-config.php

define('FORCE_SSL_ADMIN', true);

o Force logins via SSL, edit wp-config.php

define('FORCE_SSL_LOGIN', true);

Things I ran into was a cut and paste error inserting those annoying smart quotes, but once I did that everything’s golden.