Monday, November 30, 2009

Proxy Java System properties

Networking Properties
Documentation Contents
Java Properties

java.net.preferIPv4Stack (default: false)
If IPv6 is available on the operating system the underlying native socket will be an IPv6 socket. This allows Java(tm) applications to connect too, and accept connections from, both IPv4 and IPv6 hosts.

If an application has a preference to only use IPv4 sockets then this property can be set to true. The implication is that the application will not be able to communicate with IPv6 hosts.

java.net.preferIPv6Addresses (default: false)
If IPv6 is available on the operating system the default preference is to prefer an IPv4-mapped address over an IPv6 address. This is for backward compatibility reasons - for example applications that depend on access to an IPv4 only service or applications that depend on the %d.%d.%d.%d representation of an IP address. This property can be set to try to change the preferences to use IPv6 addresses over IPv4 addresses. This allows applications to be tested and deployed in environments where the application is expected to connect to IPv6 services.

networkaddress.cache.ttl (default: -1)
Specified in java.security to indicate the caching policy for successful name lookups from the name service.. The value is specified as as integer to indicate the number of seconds to cache the successful lookup.

A value of -1 indicates "cache forever".

networkaddress.cache.negative.ttl (default: 10)
Specified in java.security to indicate the caching policy for un-successful name lookups from the name service.. The value is specified as as integer to indicate the number of seconds to cache the failure for un-successful lookups.

A value of 0 indicates "never cache". A value of -1 indicates "cache forever".

http.proxyHost (default: )
http.proxyPort (default: 80 if http.proxyHost specified)
http.nonProxyHosts (default:

ftp.proxyHost (default: )
ftp.proxyPort (default: 80 if ftp.proxyHost specified)
ftp.nonProxyHosts (default: )
http.proxyHost and http.proxyPort indicate the proxy server and port that the http protocol handler will use.

http.nonProxyHosts indicates the hosts which should be connected too directly and not through the proxy server. The value can be a list of hosts, each seperated by a |, and in addition a wildcard character (*) can be used for matching. For example: -Dhttp.nonProxyHosts="*.foo.com|localhost".

ftp.proxyHost and ftp.proxyPort indicate the proxy server and port that the ftp protocol handler will use. ftp.nonProxyHosts is similiar to http.nonProxyHosts and indicates the hosts that should be connected too directly and not through the proxy server.

http.agent (default: Java1.4.0)


Indicates the User-Agent request header sent in http requests.

http.auth.digest.validateServer (default: false)
http.auth.digest.validateProxy (default: false)
http.auth.digest.cnonceRepeat (default: 5)
These system properties modify the behavior of the HTTP digest authentication mechanism. Digest authentication provides a limited ability for the server to authenticate itself to the client (ie. by proving that it knows the users password). However, not all servers support this capability and by default the check is switched off. The first two properties above can be set to true, to enforce this check, for either authentication with an origin, or a proxy server respectively.

It is not normally necessary to set the third property (http.auth.digest.cnonceRepeat). This determines how many times a cnonce value is reused. This can be useful when the MD5-sess algorithm is being used. Increasing the value reduces the computational overhead on both the client and the server by reducing the amount of material that has to be hashed for each HTTP request.

http.auth.ntlm.domain:

NTLM authentication is supported on Windows platforms only (due to licensing restrictions). Similar to other HTTP authentication schemes, NTLM uses the java.net.Authenticator class to acquire usernames and passwords when they are needed. However, NTLM also needs the NT domain name. There are three options for specifying the domain:

1. Do not specify it. In some environments, the domain is not actually required and the application need not specify it.
2. The domain name can be encoded within the username by prefixing the domain name followed by a back-slash '\' before the username. With this method, existing applications that use the Authenticator class do not need to be modified, so long as users are made aware that this notation must be used.
3. If a domain name is not specified as in method 2) and the system property "http.auth.ntlm.domain" is defined, then the value of this property will be used as the domain name.

http.keepAlive (default: true)
Indicates if keep alive (persistent) connections should be supported. Persistent connections improve performance by allowing the underlying socket connection be reused for multiple http requests.

The default is true and thus persistent connections will be used with http 1.1 servers. Set to 'false' to disable the use of persistent connections.

http.maxConnections (default: 5)
If HTTP keep-alive is enabled, this value is the number of idle connections that will be simultaneously kept alive, per-destination.

SOCKS protocol support settings

The SOCKS username and password are acquired in the following way. First, if the application has registered a java.net.Authenticator default instance, then this will be queried with the protocol set to the string "SOCKS5", and the prompt set to to the string "SOCKS authentication". If the authenticator does not return a username/password or if no authenticator is registered then the system checks for the user preferences "java.net.socks.username" and "java.net.socks.password". If these preferences do not exist, then the system property "user.name" is checked for a username. In this case, no password is supplied.

socksProxyHost
socksProxyPort (default: 1080)

Indicates the name of the SOCKS proxy server and the port number that will be used by the SOCKS protocol layer. If socksProxyHost is specified then all TCP sockets will use the SOCKS proxy server to establish a connection or accept one. The SOCKS proxy server can either be a SOCKS v4 or v5 server and it has to allow for unauthenticated connections.

Sun implementation-specific properties

These properties may not be supported in future releases.

sun.net.inetaddr.ttl

This is a sun private system property which corresponds to networkaddress.cache.ttl. It takes the same value and has the same meaning, but can be set as a command-line option. However, the preferred way is to use the security property mentioned above.

sun.net.inetaddr.negative.ttl

This is a sun private system property which corresponds to networkaddress.cache.negative.ttl. It takes the same value and has the same meaning, but can be set as a command-line option. However, the preferred way is to use the security property mentioned above.

sun.net.client.defaultConnectTimeout (default: -1)
sun.net.client.defaultReadTimeout (default: -1)

These properties specify the default connect and read timeout (resp.) for the protocol handler used by java.net.URLConnection.

sun.net.client.defaultConnectTimeout specifies the timeout (in milliseconds) to establish the connection to the host. For example for http connections it is the timeout when establishing the connection to the http server. For ftp connection it is the timeout when establishing the connection to ftp servers.

sun.net.client.defaultReadTimeout specifies the timeout (in milliseconds) when reading from input stream when a connection is established to a resource.

JNDI DNS service provider settings

These properties may not be supported in future releases.

sun.net.spi.nameservice.provider.=

Specifies the name service provider that you can use. By default, Java will use the system configured name lookup mechanism, such as file, nis, etc. You can specify your own by setting this option. takes the value of a positive number, it indicates the precedence order with a small number takes higher precendence over a bigger number. In J2SETM 1.4, we have provided one DNS name service provider through JNDI, which is called "dns,sun".

sun.net.spi.nameservice.nameservers=
You can specify a comma separated list of IP addresses that point to the DNS servers you want to use. If the sun.net.spi.nameservice.nameservers property is not defined, then the provider will use any name servers already configured in the platform DNS configuration.

sun.net.spi.nameservice.domain=
This property specifies the default DNS domain name, for instance, eng.sun.com. If the sun.net.spi.nameservice.domain property is not defined then the provider will use any domain or domain search list configured in the platform DNS configuration.

Copyright © 2002 Sun Microsystems, Inc. All Rights Reserved.
Sun Microsystems, Inc

commons-logging properties simplelog

The commons-logging.properties can configure build-in logging. I always loose track of the properties. Here the
link

commons-logging.properties or simplelog.properties
priority=1
org.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.LogFactoryImpl
org.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog
org.apache.commons.logging.simplelog.defaultlog=debug


SimpleLog sends all (enabled) log messages, for all defined loggers, to System.err. The following system properties are supported to configure the behavior of this logger:

* org.apache.commons.logging.simplelog.defaultlog - Default logging detail level for all instances of SimpleLog. Must be one of:
o trace
o debug
o info
o warn
o error
o fatal
If not specified, defaults to info.
* org.apache.commons.logging.simplelog.log.xxxxx - Logging detail level for a SimpleLog instance named "xxxxx". Must be one of:
o trace
o debug
o info
o warn
o error
o fatal
If not specified, the default logging detail level is used.
* org.apache.commons.logging.simplelog.showlogname - Set to true if you want the Log instance name to be included in output messages. Defaults to false.
* org.apache.commons.logging.simplelog.showShortLogname - Set to true if you want the last component of the name to be included in output messages. Defaults to true.
* org.apache.commons.logging.simplelog.showdatetime - Set to true if you want the current date and time to be included in output messages. Default is false.
* org.apache.commons.logging.simplelog.dateTimeFormat - The date and time format to be used in the output messages. The pattern describing the date and time format is the same that is used in java.text.SimpleDateFormat. If the format is not specified or is invalid, the default format is used. The default format is yyyy/MM/dd HH:mm:ss:SSS zzz.

In addition to looking for system properties with the names specified above, this implementation also checks for a class loader resource named "simplelog.properties", and includes any matching definitions from this resource (if it exists).

Monday, November 23, 2009

perl: print EOF blocks syntax

Double quotes indicate that the text will be interpolated using exactly the same rules as normal double quoted strings.

Double quotes indicate that the text will be interpolated using exactly the same rules as normal double quoted strings.

print << EOF; The price is $Price.

EOF

print << "EOF"; # same as above

The price is $Price.

EOF

IF you need printf then to the following:
print <<EOF;
    ${foo}AAAAAAAA${foo}BBBBBBBB";
EOF
Here's another way to do it using printf:
printf <<EOF, $foo, $foo;
   %dAAAAA%dBBBBBBB 
EOF

Friday, November 20, 2009

Detecting Running a VMWare Clone Linux

Detecting if your OS is running on a vmware machine

( grep -i vmware /proc/scsi/scsi || /sbin/lspci | grep -i vmware ) && echo This is a Virtual Machine

Friday, October 16, 2009

Cygwin wmaker failures on the wmaker.inst

Removing the errors that occur on the wmaker.inst directory not found ... change the Documents And Settings to the Docume~1 (8 char) notation in the .bashrc


export HOME="/cygdrive/c/Docume~1/MyUserName"

Removing lines context based with -pe

Removing lines with the -pe option.

perl -i -pe '
s/true/false/g;
s/^.+user-preferred.+$//g;
s/^.*(<\/cluster>.*)$/$1 xsi:nil="true">$2/g;
s/^.*(<\/machine>.*)$/$1 xsi:nil="true">$2/g;

if ($_ =~ // ) {
$ssl='on';
}
if ($_ =~ /listen-port/ and $ssl) {
$_ = undef;
$ssl= undef;
}
if ($_ =~ /
}

if ($_ =~ /<\/jta-migrat/ ) { $m = undef; $_ = undef; } ' spa/qas/config/config.xml vi spa/qas/config/config.xml

Wednesday, October 7, 2009

Setting Terminal Column and Rows Setting

export COLUMNS=80;export ROWS=24;stty rows 24 cols 80

Cygwin Bell Elimination On Backspace

echo set bell-style none >> $HOME/.inputrc

Oracle: Listing All Invalid PLSQL Packages

SELECT count(*) 
FROM ALL_OBJECTS 
WHERE owner = 'MYAPP'
  and  OBJECT_TYPE like  'PACKAGE\%'
  and status = 'INVALID'; ";

Showing CLOB information for Oracle

SELECT  dbms_lob.substr(a.user_data.payload, 3000,1)
FROM vmsut.tms_queue_table a

Perl And Capturing remote stdout and strerr streams

The script opens the systemout.log of the nodeagent and finds the references to the incident streams and shows them on the screen. Helpfull for troubleshooting WebSphere startup problems.

#!/usr/bin/perl

open (CMD, "( /usr/bin/ssh foouser\@host1 'cd pf/logs/nodeagent/;cat systemout.log | grep resetIncidentStream | cut -b152-') |")
or die "ERROR: $!";
while () {
print $_, "\n";
open (CMD2, "( /usr/bin/ssh foouser\@host2 'grep -i exception $_') |");
while () {
print "$_";
}
}
close (CMD);

DBIx Statement Debugging

Export the variable and the SQL statements will be echo'ed.

export DBIX_CLASS_STORAGE_DBI_DEBUG=1

Eclipse over XWindows

Running and rendering the remote XWin session of eclipse.
61  set | grep SSH
[me@remote ~]$ set | grep SSH
SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
SSH_CLIENT='172.18.153.150 49238 22'
SSH_CONNECTION='172.18.153.150 49238 10.10.10.3 22'
SSH_TTY=/dev/pts/3
Use the SSH_CONNECTION ip listed on local to export
60  xhost +  
70  ssh -X foouser@ip_remote_host 'export DISPLAY=172.18.153.150:0;/opt/eclipse-3.3.1.1-europa/eclipse/eclipse'
Do not use the hostname or worse alias for the remote but use the remote ip address in our example 10.10.10.3 When you do not have a local Xserver running you might see this:... if thats the case change your myhostnameasalias to the network IP address of the remote host, 10.10.10.3..
me@local $ ssh -X 'me@myhostnameasalias' 'export DISPLAY=172.18.153.150:0;java -Xmx1536m -Xms1024m -jar myjar.jar '
Warning: untrusted X11 forwarding setup failed: xauth key data not generated
Warning: No xauth data; using fake authentication data for X11 forwarding.
Jun 21, 2012 12:01:18 PM java.util.prefs.FileSystemPreferences$2 run
INFO: Created user preferences directory.
Exception occurred in main() of MyProgram
java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11GraphicsEnvironment
 at java.lang.Class.forName0(Native Method)
 at java.lang.Class.forName(Class.java:169)
 at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:68)
 at sun.awt.X11.XToolkit.(XToolkit.java:89)
 at java.lang.Class.forName0(Native Method)
 at java.lang.Class.forName(Class.java:169)
 at java.awt.Toolkit$2.run(Toolkit.java:834)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:826)
 at sun.swing.SwingUtilities2$AATextInfo.getAATextInfo(SwingUtilities2.java:120)
 at javax.swing.plaf.metal.MetalLookAndFeel.initComponentDefaults(MetalLookAndFeel.java:1556)
 at javax.swing.plaf.basic.BasicLookAndFeel.getDefaults(BasicLookAndFeel.java:130)
 at javax.swing.plaf.metal.MetalLookAndFeel.getDefaults(MetalLookAndFeel.java:1591)
 at javax.swing.UIManager.setLookAndFeel(UIManager.java:514)
 at javax.swing.UIManager.setLookAndFeel(UIManager.java:554)
To solve this ....

Adding User for CVS

Adding a linux user to have access to CVS repository

515 adduser -s /bin/bash pgattamaneni
531 usermod -G cvs pgattamaneni
532 passwd pgattamaneni

Reset Root password MySQL

Steps for the resetting root password of the MySQL database user.

# /etc/init.d/mysql stop
# /usr/bin/mysqld_safe --skip-grant-tables --user=root
# mysql -u root
update mysql.user SET password=PASSWORD('newpasswd') where User='root';
flush privileges;

# kill `cat /var/run/mysqld/mysqld.pid`
# /etc/init.d/mysql restart
# mysql -u root -p

Execute remote command on multiple boxes oneliner

You'll have to have password less logon with ssh setup for these commands. In this case the blue command is creating symlinks and x has a list of user@host's

[cmbuild3@pghpscmbldl01 ~]$ cat x | xargs -i{} -t ssh {} '[ ! -e wad ] && ln -s /opt/g/ad/stat/wls/ad/; [ ! -e logs ] && ln -s /var/g/ad/logs/wls/ad/ logs '
[cm@pgh ~]$ cat x
adqas@qpada01
adqas@qpada02
adqas@qpada03
adqas@qpada04
etc

/bin/bash infinite loop oneliner

How to run a command in a loop as a one liner. I always get confused with the semi-colons and dones...
while (true) do curl  http://sspq1/cgi-bin/spologin.pl -d "username=x-1&password=fxxx&login=LOGIN"; done;

while (true) do perl msdash.pl -e QAS -a PDI-Cluster -r gss 2> /dev/null | grep get; done;
For a for in do loop the syntax for the one liner looks like this with an extra semi colon after the for statement declaration.
for i in {1..15}; do wget http://www.hairuwear.com/sites/all/themes/hairuwear/images/slide$i.jpg; done;

WebLogic JRockit jrcmd diagnostics

JRockit Diagnostic Commands

Here is a list of other jrockit commands that can be used for performance tuning .


22 export JAVA_HOME=/opt/bea/java/jrockit-R27.1.0-jdk1.5.0_08/
23 export PATH=$PATH:$JAVA_HOME/bin
26 jrcmd `ps auxww | grep -v grep | grep gbrServer | awk '{ print $2 }'` print_threads

Finding Classes In Multiple Jars or Directories

Very simple find with xargs as the icing on top, in this example we are looking for the package webservices.
find . -name '*.jar' | xargs -i{} -t jar tfv {} | grep -i webservices
If you have a problem and do not have access to the jar utility an alternative could be and also ITS BLAZINGLY FASTER
$ find . -name '*.jar' | xargs -i{} -t unzip -l {} | grep -i sun.awt.X11GraphicsEnvironment

SSH Password less logon


$ pwd
/home/foouser
$ cd ..
$ ls -rtl
total 32
drwxrwsrwx 2 foouser 0 8192 Jan 23 13:57 foouser
$ chown akaan akaan
$ chmod 700 AKAAN
$ ls -rtl
total 32
drwxr-sr-x 2 foouser 0 8192 Jan 23 13:57 foouser
$ cd foouser
$ mkdir .ssh
$ chmod 700 .ssh
$ cd .ssh
$ vi authorized_keys
~authorized_keys" [New file] 1 line, 218 characters
$ chmod 600 *
$ ls -lrt
total 16
-rw------- 1 foouser 0 217 Jan 23 14:02 authorized_keys

Perl Substitution and Write Oneliner

Always looking for the proper syntax:

bash-3.2$ perl -i -pe 's/751818/akaan/' andre

-i = takes the first argument as a file
-e = execute command
-p = runs command surrounding while (<FILE>) { }

Cygwin Xwin startx

Default installation of cygwin and Xwindows
There are two ways of starting up:
  1. opening a bash-shell window and run startx
  2. opening explorer and run startxwin.bat from /usr/bin
regarding 1)
  • create ~/.bash_profile
export HOME="C:/Docume~1/[uid]
  • create ~/.xserverrc
X :0 -clipboard -silent-dup-error
  • create ~/.xinitrc
exec wmaker
regarding 2)