Sunday, March 9, 2014

Generate a Date Range in MySQL

Set @i:=0;

SELECT DATE(DATE_ADD( '2014-03-01' - INTERVAL 1 DAY, INTERVAL @i:=@i+1 DAY ) ) AS datesSeries
FROM `CS3_Statistics`.`HC_Report`, (SELECT @i:=0) r
where @i < DATEDIFF( '2014-03-07' + INTERVAL 1 DAY, '2014-03-01' )
;


Thursday, October 10, 2013

Java 7 IP 6 to 4

Java 7 is using IP6 for its connectivity by default, to disable it and use IP4 the following setting can be set in windows or unix environment to override it

_JAVA_OPTIONS -Djava.net.preferIPv4Stack=true


Saturday, September 21, 2013

TCL Expect Script Directory

These are expect parameter to work with command line options:

puts $argc     # number of argument passed to script
puts $argv    # array list of arguement, script name not included
puts $argv0  # the name of script include path of calling e.g. ./test.sh

set path [file dirname $argv0]    # obtain script directory
cd $path      # Change directory to script directory



# Find script path through links as well
set originalPath [pwd]
set scriptPath   $::argv0
set workingPath  [file dirname $::argv0]
while {![catch {file readlink $scriptPath} result]} {
    cd $workingPath
    set scriptPath  [file join [pwd] $result]
    set workingPath [file dirname $scriptPath]
}
cd [file dirname $scriptPath]
set scriptPath [pwd]
cd $originalPath

Wednesday, August 28, 2013

Read and Clear big wtmpx

Read
/usr/lib/acct/fwtmp < wtmpx


Clear
cd /var/adm
gzip -c wtmpx > wtmpx-2013.gz
> wtmpx

Friday, June 28, 2013

Adding New Xml Encoding Alias to Xerces

Recently I developed an xmlrpc application that failed on testing from an existing client (the stupid one). That client set its request encoding in xml header as "UTF8" (the standard IANA is "UTF-8"). It result in rejecting the request immediately in xmlroc server (I deployed in Jboss EAP 6.1) by following exception.

Invalid encoding name "UTF8"

So after searching I found the EncodingMap class of xerces that allow add new alias for encoding names. So first add xercesImpl dependency in maven file, an then statically add the desired encoding name as follow:

EncodingMap.putIANA2JavaMapping( "UTF8", "UTF8" );

EncodingMap.putJava2IANAMapping( "UTF8", "UTF8" );


Saturday, June 8, 2013

Create Solaris 10 IPMP

Requirement:
2 connected interface
3 IP addresses (1 for active, 2 for interface tests)

It is probe based IPMP (testing destination IP)

Update /etc/hosts
10.132.174.144    hostaddress

10.132.174.146    host-testaddr0
10.132.174.146    host-testaddr1

ifconfig intf0 host-testaddr0 deprecated -failover netmask + broadcast + group host_g0 up
ifconfig intf0 addif hostaddress netmask + broadcast + up

ifconfig intf1 host-testaddr1 deprecated -failover netmask + broadcast + group host_g0 up

Make it permanent by /etc/hostname.intfx

Tuesday, May 28, 2013

Netra T2000 PCIEX Fault

After installing new Solaris (u11 01/13) I got hardware fault for PCIEX as follow:
  ID Time              FRU               Fault
   6 JAN 01 02:08:21   IOBD              Host detected fault, MSGID: PCIEX-8000-DJ  UUID: 598ad722-6e4c-4335-f86a-ec627b5c2b3c
   7 JAN 01 02:08:21   MB                Host detected fault, MSGID: PCIEX-8000-DJ  UUID: 598ad722-6e4c-4335-f86a-ec627b5c2b3c

Finally found in server product notes a trick for /etc/system to config system to fix it

/etc/system
set pcie:pcie_aer_ce_mask=0x1
set segkmem_lpsize=0x400000

Also found some other config that may relate to improve performance for other things

set ip:ip_soft_rings_cnt=0
set pcie:pcie_aer_ce_mask=0x1
forceload: sys/shmsys
forceload: sys/semsys
set semsys:seminfo_semmni=20
set semsys:seminfo_semmsl=100
set semsys:seminfo_semmns=2000
set semsys:seminfo_semmnu=2000
set shmsys:shminfo_shmmax=0x140000000