Using DTrace to understand mpstat and vmstat output
Observing I/O Behavior With The DTraceToolkit
Thursday, March 18, 2010
Tuesday, March 16, 2010
How to get the latest file from the directory
#
way 1:
$ ls -lrt | awk '{ f=$NF }; END{ print f }'
#
#The above awk is to print the last argument of the last line
#
way 2:
$ ls -t1 | head -n
REFERENCE: bash - parameter expansion, i.e. http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_06_02
outputs the file base and extension respectively ("data" and "txt").
${variable#pattern} is similar to "echo $variable |sed 's/^pattern//'"
but the pattern matching isn't "greedy" unless you double the #.
Likewise ${variable%pattern} is similar to
"echo $variable | sed 's/pattern$//'"
way 1:
$ ls -lrt | awk '{ f=$NF }; END{ print f }'
#
#The above awk is to print the last argument of the last line
#
way 2:
$ ls -t1 | head -n
REFERENCE: bash - parameter expansion, i.e. http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_06_02
file=data.txt echo ${file%.*} echo ${file#*.}
outputs the file base and extension respectively ("data" and "txt").
${variable#pattern} is similar to "echo $variable |sed 's/^pattern//'"
but the pattern matching isn't "greedy" unless you double the #.
Likewise ${variable%pattern} is similar to
"echo $variable | sed 's/pattern$//'"
Thursday, March 4, 2010
Read file writting strings into array
declare -a ARRAY
count=0
while read line; do
echo $line
ARRAY[$count]=$line
let count=count+1
echo $count
done < ips.tmp
echo ${ARRAY[1]}
echo ${#ARRAY[@]}
count=0
while read line; do
echo $line
ARRAY[$count]=$line
let count=count+1
echo $count
done < ips.tmp
echo ${ARRAY[1]}
echo ${#ARRAY[@]}
Wednesday, March 3, 2010
Friday, February 12, 2010
Wednesday, February 10, 2010
How to find out the symlink source (without readlink)
$ cat basher
#!/usr/local/bin/bash
string="lrwxr-xr-x 1 mmmm users 66 Sep 4 09:58 LINK_SEND -> /apps/aaa/home/mmmm/FFFFF/Apps/RRRRRR/unit_tests/TARGET_SEND"
echo $string
string=${string##* }
echo $string
string=${string%/*}
echo $string
exit 0
$
$
$ ./basher
lrwxr-xr-x 1 mmmm users 66 Sep 4 09:58 LINK_SEND -> /apps/aaa/home/mmmm/FFFFF/Apps/RRRRRR/unit_tests/TARGET_SEND
/apps/aaa/home/mmmm/FFFFF/Apps/RRRRRR/unit_tests/TARGET_SEND
/apps/aaa/home/mmmm/FFFFF/Apps/RRRRRR/unit_tests
$
source
#!/usr/local/bin/bash
string="lrwxr-xr-x 1 mmmm users 66 Sep 4 09:58 LINK_SEND -> /apps/aaa/home/mmmm/FFFFF/Apps/RRRRRR/unit_tests/TARGET_SEND"
echo $string
string=${string##* }
echo $string
string=${string%/*}
echo $string
exit 0
$
$
$ ./basher
lrwxr-xr-x 1 mmmm users 66 Sep 4 09:58 LINK_SEND -> /apps/aaa/home/mmmm/FFFFF/Apps/RRRRRR/unit_tests/TARGET_SEND
/apps/aaa/home/mmmm/FFFFF/Apps/RRRRRR/unit_tests/TARGET_SEND
/apps/aaa/home/mmmm/FFFFF/Apps/RRRRRR/unit_tests
$
source
Wednesday, January 27, 2010
How to check Kernel default values
echo "vx_bc_bufhwm/D" | adb -k /dev/ksyms /dev/mem
echo "ncsize/D" | adb -k /dev/ksyms /dev/mem
echo "vxfs_ninode/D" | adb -k /dev/ksyms /dev/mem
http://seer.entsupport.symantec.com/docs/196721.htm
echo "ncsize/D" | adb -k /dev/ksyms /dev/mem
echo "vxfs_ninode/D" | adb -k /dev/ksyms /dev/mem
http://seer.entsupport.symantec.com/docs/196721.htm
Wednesday, January 6, 2010
How to see the full command line in ps?
[root@hostname ~]#/usr/ucb/ps -auxwww | grep -i java
nobody 4589 0.1 4.228480842528 ? S 14:26:35 0:21 /usr/java1.4/bin/java -Djava.awt.headless=true -Xms200m -Xmx300m org.apache.jserv.JServ /jserv/etc/jserv.properties
nobody 4589 0.1 4.228480842528 ? S 14:26:35 0:21 /usr/java1.4/bin/java -Djava.awt.headless=true -Xms200m -Xmx300m org.apache.jserv.JServ /jserv/etc/jserv.properties
Thursday, November 19, 2009
Get application pid listening on a network port in Solaris (aka netstat -npl in Solaris?)
Source link
#!/bin/bash
# Get the process which listens on port
# $1 is the port we are looking for
if [ $# -lt 1 ]; then
echo "Please provide a port number parameter for this script"
echo "e.g. $0 22"
exit
fi
echo "Greping for your port, please be patient (CTRL+C breaks) ... "
for i in `ls /proc` ; do
pfiles $i | grep AF_INET | grep $1
if [ $? -eq 0 ] ; then
echo Is owned by pid $i
fi
done
To research: In comments to the original post somebody offers to use lsof.
#!/bin/bash
# Get the process which listens on port
# $1 is the port we are looking for
if [ $# -lt 1 ]; then
echo "Please provide a port number parameter for this script"
echo "e.g. $0 22"
exit
fi
echo "Greping for your port, please be patient (CTRL+C breaks) ... "
for i in `ls /proc` ; do
pfiles $i | grep AF_INET | grep $1
if [ $? -eq 0 ] ; then
echo Is owned by pid $i
fi
done
To research: In comments to the original post somebody offers to use lsof.
Wednesday, November 18, 2009
How do I know my global zone nodename from a non-global zone ?
That's what I found on the Web.
Taken from here:
http://blogs.sun.com/apatoki/entry/how_do_i_know_my
I did not try this yet, I have no appropriate Solaris box by hand. But that could be useful.
For Solaris Zones, the method I use is the one devised by Menno Lageman (http://blogs.sun.com/menno). Mount the global zone's /etc/nodename using a read-only LOFS mount on /etc/chassis in the non-global zone. It automatically changes whenever the nodename of the global zone changes, whether it is because the name of the global zone is modified or because the zone is moved to another physical host using zoneadm detach/attach. Just do this:
# zonecfg -z zone
zonecfg:zone> add fs
zonecfg:zone:fs> set dir=/etc/chassis
zonecfg:zone:fs> set special=/etc/nodename
zonecfg:zone:fs> set type=lofs
zonecfg:zone:fs> add options ro
zonecfg:zone:fs> end
Taken from here:
http://blogs.sun.com/apatoki/entry/how_do_i_know_my
I did not try this yet, I have no appropriate Solaris box by hand. But that could be useful.
Subscribe to:
Posts (Atom)