- sqlplus id/pwd@
- sqlplus id/pwd@server:port/service (service is schema that is given by DBA)
Friday, January 21, 2011
Oracle Net: TNS and EasyConnect
Thursday, December 23, 2010
cx_Oracle
Follow http://mostperfect.net/blog/2010/07/28/installing-cx_oracle-on-windows/,
A looking at cx_Oracle.pyd with dependency walker (from MS) will show it depends on OCI.dll.
As a result, we need to install Oracle Instant Client from here
As a result, we need to install Oracle Instant Client from here
Thursday, November 25, 2010
Customize the Nginx Server:Apache
- vi src/http/ngx_http_header_filter_module.c
- static char ngx_http_server_string[] = "Server: Apache" CRLF;
- static char ngx_http_server_full_string[] = "Server: Apache" CRLF;
- configure, make, make install.
Monday, November 8, 2010
how to change user-agent for chrome
C:\Users\vyang\AppData\Local\Google\Chrome\Application\chrome.exe -user-agent="Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)"
Wednesday, October 13, 2010
a smtp proxy server
http://code.activestate.com/recipes/577260-multi-threaded-smtp-proxy/
is useful for helping me to test my html email via outlook. This is due to the real MTA that can deliver to outlook is IP based, and my workstation is not allowed but as long as I run the server on the allowed IP, it works.
Tuesday, August 31, 2010
ldapsearch usage
For example,
In order to find the home directory for a certain user id.
ldapsearch -H "ldap://ldapserver/" -D -W -vvv -L -x -b 'OU=Users,DC=mycomp,DC=com' -z 0 uid=$1 Home
range(a..z): python generator expression for
In order to generate a..z with generator expression.
import string
for filter in ('uid='+x+'*' for x in string.lowercase):
print(filter)
Thursday, August 26, 2010
Play with TTL value with ping
Router will decrement TTL value within IP packet.
"ping" can be used to simulate how ICMP works in more complex tool such as "mtr", "traceroute".
Please try increasing ttl-value against any target machine is ICMP is enabled along the route.
on unix/linux: ping -t
on windows: ping -i target-ip
We can conduct an incremental testing with one ICMP packet each time:
ping -t 1 -c 1 www.yahoo.com
ping -t 2 -c 1 www.yahoo.com
...
ping -t 1 -c 1 www.yahoo.com
ping -t 2 -c 1 www.yahoo.com
...
how to find default IP TTL value of the remote system
TTL value is 1 byte within IP header.
- "ping
" will show ttl returned by the remote machine. - Find out how many hops between src and remote ip. traceroute/mtr
- Add the value from Step 1 and 2 will get the default TTL value of remote system
- For the curious, can look up http://www.binbert.com/blog/2009/12/default-time-to-live-ttl-values/ to take a guess what the remote system might be.
Thursday, August 19, 2010
Tuesday, August 17, 2010
winpcap 's dlls
There are two dlls with winpcap installation.
- wpcap.dll implements the libpcap API (plus some extensions) for Win32 systems.
- packet.dll, and the drivers for various Win32 operating systems, provide a Win32-specific raw link-layer packet
Monday, March 1, 2010
set up rsync daemon
start_rsyncd.sh
/usr/bin/rsync --daemon --config=rsyncd.conf
rsyncd.conf (server runs on port 9873)
pid file=/home/vic/opt/rsync/pid
log file=/home/vic/opt/rsync/log
lock file=/home/vic/rsync/lock
port=9873
address=192.168.1.100
timeout=600
[data]
path=/home/vic/tmp
use chroot=false
read only=no
transfer logging=yes
max connections=1
rsync client test
rsync -v foo rsync://192.168.1.100:9873/data
/usr/bin/rsync --daemon --config=rsyncd.conf
rsyncd.conf (server runs on port 9873)
pid file=/home/vic/opt/rsync/pid
log file=/home/vic/opt/rsync/log
lock file=/home/vic/rsync/lock
port=9873
address=192.168.1.100
timeout=600
[data]
path=/home/vic/tmp
use chroot=false
read only=no
transfer logging=yes
max connections=1
rsync client test
rsync -v foo rsync://192.168.1.100:9873/data
Thursday, January 14, 2010
How to build mod_wsgi,web.py with httpd and python from source code
It is best to compile everything from source code.
Version usedPython: 2.7 (with shared library)httpd 2.2.17 (with shared DSO support)WSGI (integrating with httpd): mod_wsgi 3.3
Web framework: web.py 0.34
Set up LD_LIBRARY_PATH so that running "python" would find its shared lib
export LD_LIBRARY_PATH=${python-lib}:$LD_LIBRARY_PATH
Compile (apache) httpd Add DSO support
./configure --prefix= --enable--module=module_so
Compile mod_wsgi
./configure --with-apxs=$APACHE_HOME/bin/apxs --with-python=$PYTHON_BIN/python
Configure httpd.conf for mod_wsgi
Version usedPython: 2.7 (with shared library)httpd 2.2.17 (with shared DSO support)WSGI (integrating with httpd): mod_wsgi 3.3
Web framework: web.py 0.34
Compile Python for shared lib
./configure --prefix= --enable-shared
./configure --prefix=
Set up LD_LIBRARY_PATH so that running "python" would find its shared lib
export LD_LIBRARY_PATH=$
Compile (apache) httpd Add DSO support
./configure --prefix= --enable--module=module_so
./configure --with-apxs=$APACHE_HOME/bin/apxs --with-python=$PYTHON_BIN/python
Configure httpd.conf for mod_wsgi
LoadModule wsgi_module modules/mod_wsgi.so
WSGIScriptAlias /wsgi/ /u/local/www/wsgi-scripts/
WSGIApplicationGroup admin-scripts
Order allow,deny
Allow from all
WSGIProcessGroup example1.com
WSGIDaemonProcess example1.com processes=2 threads=15 display-name=example1.com
Install a sample python code under /u/local/www/wsgi-scripts/sniff
import sys
def application(environ, start_response):
status = '200 OK'
output = 'sys.version= %s\nsys.prefix=%s\n' % (sys.version, sys.prefix)
output += 'sys.path= %s\n' % (sys.path)
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
Wednesday, December 2, 2009
Saturday, April 4, 2009
netstat + lsof = my friend
linux
- "netstat -anpt | grep -i listen | grep 8888" will find out the process id is running on that port.
- "/usr/sbin/lsof -p
" find out what file and sockets it opens. "lsof -P -n -i TCP" will list all the TCP sockets with unresolved (numeric) IP and port
Wednesday, March 4, 2009
Database connection pooling with firewall troubleshooting tip: Use Netcat
Database connection pooling is useful and common feature for performance. However there are some cavets.
Sometimes your sql query just got timed out, and you wonder why.
If you suspect the TCP connection between your application hosted in DMZ to the database (which is usually sits behind a firewall) got dropped by the firewall. It is very likely firewall has a policy to terminate any idle connection.
Let's go back to the basics to use Netcat.
Server(internal machine):
nc -v -l 9999
Client (DMZ machine):
nc 9999
Assuming port 9999 is allowd on the firewall.
Let's assume the firewall drops the connection after 30 minutes idle time, then the nc will be broken after 30 minutes.
Sometimes your sql query just got timed out, and you wonder why.
If you suspect the TCP connection between your application hosted in DMZ to the database (which is usually sits behind a firewall) got dropped by the firewall. It is very likely firewall has a policy to terminate any idle connection.
Let's go back to the basics to use Netcat.
Server(internal machine):
nc -v -l 9999
Client (DMZ machine):
nc
Assuming port 9999 is allowd on the firewall.
Let's assume the firewall drops the connection after 30 minutes idle time, then the nc will be broken after 30 minutes.
Tuesday, February 17, 2009
Remote disk space monitor
The following is a poor man's disk space monitor script.
"ssh id@host df -h " is the core of the script. It relies on SSH RSA authentication so that the remote "df" can work like local.
#!/bin/ksh
homedir=`dirname $0`
RUN_DATE_LONG=$(date +'%Y%m%d')
LOGFILE=${homedir}/diskmon_log.$RUN_DATE_LONG
HOSTS="192.168.1.1 192.168.1.2 192.168.1.3 192.168.1.4 "
alert=90
alert_email="admin@foo.com"
typeset -i email=0
function rdf
{
echo "$1 is sshing into $2 doing a df......." >> $LOGFILE
ssh $1@$2 df -hP | grep -vE '^Filesystem' | awk '{print $4 " " $5 " " $1 " " $2}' | while read line;
do
typeset -i used=$(echo $line | awk '{print $1}' | cut -d "%" -f 1)
if [[ $used -ge $alert ]]; then
email=1
echo $line >> $LOGFILE
fi
done
echo "ssh done......." >> $LOGFILE
}
for h in $HOSTS
do
rdf sshid $h
done
if [[ ${email} -eq 1 ]]; then
echo "alert email will be setnt" >> $LOGFILE
# put whatever mailer you use here
fi
"ssh id@host df -h " is the core of the script. It relies on SSH RSA authentication so that the remote "df" can work like local.
#!/bin/ksh
homedir=`dirname $0`
RUN_DATE_LONG=$(date +'%Y%m%d')
LOGFILE=${homedir}/diskmon_log.$RUN_DATE_LONG
HOSTS="192.168.1.1 192.168.1.2 192.168.1.3 192.168.1.4 "
alert=90
alert_email="admin@foo.com"
typeset -i email=0
function rdf
{
echo "$1 is sshing into $2 doing a df......." >> $LOGFILE
ssh $1@$2 df -hP | grep -vE '^Filesystem' | awk '{print $4 " " $5 " " $1 " " $2}' | while read line;
do
typeset -i used=$(echo $line | awk '{print $1}' | cut -d "%" -f 1)
if [[ $used -ge $alert ]]; then
email=1
echo $line >> $LOGFILE
fi
done
echo "ssh done......." >> $LOGFILE
}
for h in $HOSTS
do
rdf sshid $h
done
if [[ ${email} -eq 1 ]]; then
echo "alert email will be setnt" >> $LOGFILE
# put whatever mailer you use here
fi
Monday, February 9, 2009
Dtrace could be the secret weapon
I had this vision of setting up a high end consulting firm which only serves some hard problem such as performance. One of secret weapon is Dtrace.
DTrace for linux: http://www.crisp.demon.co.uk/tools.html
DTrace with Python: http://blogs.sun.com/levon/entry/python_and_dtrace_in_build
DTrace for linux: http://www.crisp.demon.co.uk/tools.html
DTrace with Python: http://blogs.sun.com/levon/entry/python_and_dtrace_in_build
Subscribe to:
Posts (Atom)
