Search This Blog

Thursday 30 June 2011

ssh tunnel set up

server:
edit the file /etc/ssh/sshd_config

check that port-forwarding has not been disabled server-wide in /etc/ssh/sshd_config verify that
AllowTcpForwarding is set to yes (default setting is yes)

client:
use the following syntax
ssh -L localPort:remoteHost:RemoteHostPort sshServerHost

Monday 20 June 2011

JVM monitoring

this is an example of how to monitoring the execution of a JVM running JBoss 4.2.3 GA under Solaris OS:

1. set the following Java options in run.conf (if you are on Windows, set them in run.bat)
JAVA_OPTS="....... -XX:+HeapDumpOnOutOfMemoryError -Dcom.sun.management.jmxremote.port=9999 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djboss.platform.mbeanserver -Djavax.management.builder.initial=org.jboss.system.server.jmx.MBeanServerBuilderImpl -Djava.rmi.server.hostname= ............"
2. use jvisualvm.exe in your JDK to attach to the remote JBoss: Remote -> Add Remote Host -> add JMX connection -> :9999
3. run the following script on the server, to get memory utilization percentages:

pid=`/bin/jps -l | grep Main | awk {'print $1'
}`
/bin/jstat -gcutil $pid 2000

Thursday 16 June 2011

extract Java stack traces from log4j logs

here is described a solution to retrieve from a Windows machine any errors and stack traces in log4j log files saved on a Solaris machine.
Results are filtered out by a given date, in this example 2011-06-16

1. download plink.exe and put in a new folder
2. in the same folder create a batch file with the following content

@echo off
plink.exe -v -ssh 127.0.0.1 -P 24 -l username -pw password -m cmd.txt > output.txt

3. in the same folder create the file cmd.txt with the following content

for file in `find logFolder -name "logfile.log*" -print`
do
echo $file
awk '{ if(($1 == "2011-06-16") && ($4 == "ERROR")){print $0; gl = getline row; while(gl > 0 && row !~ /^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]/){print row; gl = getline row;}} }' $file
done

Wednesday 15 June 2011

Oracle, table size

The following query (to be run as sys user) is useful to calculate the space used by all tables


SELECT OWNER,
OBJECT_NAME,
OBJECT_TYPE,
TABLESPACE_NAME,
NUM_ROWS,
SUM(KBYTES) KBYTES,
TO_CHAR(DECODE(NUM_ROWS, 0, 0, SUM(KBYTES) / (NUM_ROWS)), '9999.99') KB_ROW
FROM (SELECT LO.OWNER,
LO.TABLE_NAME AS OBJECT_NAME,
EX.SEGMENT_TYPE AS OBJECT_TYPE,
EX.TABLESPACE_NAME,
TS.NUM_ROWS AS NUM_ROWS,
ROUND((SUM(EX.BYTES) / 1024)) AS KBYTES
FROM DBA_EXTENTS EX
JOIN DBA_LOBS LO ON (EX.OWNER = LO.OWNER AND
EX.SEGMENT_NAME = LO.SEGMENT_NAME)
JOIN DBA_TAB_STATISTICS TS ON (LO.OWNER = TS.OWNER AND
LO.TABLE_NAME = TS.TABLE_NAME)
GROUP BY LO.OWNER,
LO.TABLE_NAME,
LO.COLUMN_NAME,
EX.SEGMENT_NAME,
EX.SEGMENT_TYPE,
EX.TABLESPACE_NAME,
TS.NUM_ROWS
UNION ALL
SELECT EX.OWNER,
EX.SEGMENT_NAME AS OBJECT_NAME,
EX.SEGMENT_TYPE AS OBJECT_TYPE,
EX.TABLESPACE_NAME,
TS.NUM_ROWS,
ROUND((SUM(EX.BYTES) / 1024)) AS KBYTES
FROM DBA_EXTENTS EX
LEFT JOIN DBA_LOBS LO ON EX.OWNER = LO.OWNER
AND EX.SEGMENT_NAME = LO.SEGMENT_NAME
JOIN DBA_TAB_STATISTICS TS ON EX.OWNER = TS.OWNER
AND EX.SEGMENT_NAME = TS.TABLE_NAME
GROUP BY EX.OWNER,
EX.SEGMENT_NAME,
EX.SEGMENT_TYPE,
EX.TABLESPACE_NAME,
TS.NUM_ROWS)
WHERE OWNER LIKE 'CF%'
GROUP BY OWNER, OBJECT_NAME, OBJECT_TYPE, TABLESPACE_NAME, NUM_ROWS
ORDER BY KBYTES DESC;