Archive | Linux RSS for this section

Monitoring Network Performance on Solaris using nicstat

To Monitor your Network performance on Linux or Solaris, you can use nicstat. It can provide data like packet per second, Kb per second, and utilization.

bash-3.00$ nicstat -i mac 1
Time       Int   rKb/s   wKb/s   rPk/s   wPk/s    rAvs    wAvs   %Util     Sat
09:29:51   mac   43.40   29.09  215.73  187.62  206.01  158.76    0.06    0.00
09:29:52   mac  912.04 1027.16 7157.00 7097.00  130.49  148.20    1.59    0.00
09:29:53   mac 1010.37 1133.48 7912.00 7829.00  130.77  148.25    1.76    0.00
09:29:54   mac  925.65 1044.82 7287.00 7197.00  130.08  148.66    1.61    0.00
09:29:55   mac 1018.24 1140.09 7978.00 7901.00  130.69  147.76    1.77    0.00
09:29:56   mac  962.31 1081.12 7542.00 7463.00  130.66  148.34    1.67    0.00
09:29:57   mac 1008.47 1130.27 7907.00 7835.00  130.60  147.72    1.75    0.00

To install nicstat:

  1. Download nicstat from here or here.
  2. Extract the zip file (if you download the zip file).
  3. Compile the nicstat.c using gcc
    /usr/sfw/bin/gcc nicstat.c -o nicstat -lkstat -lgen -lsocket -lrt
  4. it will create nicstat (executable) in the current directory.
  5. now you can start using nicstat. Just set your PATH environment variable to the nicstat directory.


Memory usage by process

The Solaris pmap command will provide the total memory usage of each process.

The following shell script prints the memory usage of each process, sorted by ascending memory usage.
/usr/bin/printf "%-6s %-9s %s\n" "PID" "Total" "Command"
/usr/bin/printf "%-6s %-9s %s\n" "---" "-----" "-------"
for PID in `/usr/bin/ps -e | /usr/bin/awk '$1 ~ /[0-9]+/ { print $1 }'`
CMD=`/usr/bin/ps -o comm -p $PID | /usr/bin/tail -1`
# Avoid "pmap: cannot examine 0: system process"-type errors
# by redirecting STDERR to /dev/null
TOTAL=`/usr/bin/pmap $PID 2>/dev/null | /usr/bin/tail -1 | \
/usr/bin/awk '{ print $2 }'`
[ -n "$TOTAL" ] && /usr/bin/printf "%-6s %-9s %s\n" "$PID" "$TOTAL" "$CMD"
done | /usr/bin/sort -n -k2

Example output:

PID Total Command
--- ----- -------
10214 1552K tee
10216 1552K tee
10431 1552K tee
10433 1552K tee
10430 1648K /bin/sh
10213 1728K /bin/sh
10436 1776K /bin/sh
10432 1792K /bin/sh
10215 1816K /bin/sh
1526 3912K /bin/sh
22547 3912K /bin/sh
22551 3912K /bin/sh
12384 4016K /bin/sh
1370 4032K /bin/sh
22462 4216K -csh
16458 4280K -csh
175 4920K vi
22468 5680K bash
16500 5744K bash
22460 9512K /usr/lib/ssh/sshd
22550 10872K /usr/bin/sort
10292 180360K /oracle/jrrt-3.1.2-1.6.0/bin/sparcv9/java
1532 750400K /oracle/jrrt-3.1.2-1.6.0/bin/sparcv9/java
1392 1056824K /oracle/jrrt-3.1.2-1.6.0/bin/sparcv9/java
12406 1160120K /oracle/jrrt-3.1.2-1.6.0/bin/sparcv9/java
10498 1233680K /oracle/jrrt-3.1.2-1.6.0/bin/sparcv9/java


Get PID from port number

To get which PID binding some specific port on Solaris 10, use this script:

pids=$(/usr/bin/ps -ef | sed 1d | awk '{print $2}')
if [ $# -eq 0 ]; then
read ans?"Enter port you would like to know pid for: "
for f in $pids
/usr/proc/bin/pfiles $f 2>/dev/null | /usr/xpg4/bin/grep -q "port: $ans"
if [ $? -eq 0 ]; then
echo $line
echo "Port: $ans is being used by PID:\c"
/usr/bin/ps -ef -o pid -o args | egrep -v "grep|pfiles" | grep $f
exit 0


Solaris10 Network Interface on vmware

If you are using vmware to install your Solaris 10 x86 operating system, the network interface sometimes doesn’t up automatically. You need to check if there is a vmware network interface on your system. You can issue this command:
# grep -i net /etc/path_to_inst
"/pci@0,0/pci1022,2000@11" 0 "vmxnet"
# dladm show-dev
vmxnet0 link: unknown speed: 0 Mbps duplex: unknown

You should’ve found vmxnet network interface. Issue this command to bring this interface up:
# ifconfig vmxnet0 plumb

Use this command to set ip for this interface:
ifconfig vmxnet netmask

rcp – copy files between different machine without password

Tu use rcp on your system, you have to do these steps:

  1. Install rsh-server
    rpm -Uhv rsh-server-xxxxx.rpm
  2. Activate rlogin and rsh
    chkconfig rlogin on
    chkconfig rsh on
  3. Edit ~/.rhosts file and add the hostname that can rcp to this system.
    hostname1 username
    hostname2 username

    If the file doesn’t exist, create one and add the lines above.
  4. try tp rcp file to the other system.
    rcp [filename] [hostname]:[filename]
    rcp test rac2:test1

when I try rcp on my system (RHEL4) I get this error.


Then I use /usr/bin/rcp instead of rcp command and it worked.

/usr/bin/rcp test rac2:test1

Then I do this:

# su -

# which rsh

# mv /usr/kerberos/bin/rsh /usr/kerberos/bin/rsh.original
# mv /usr/kerberos/bin/rcp /usr/kerberos/bin/rcp.original
# mv /usr/kerberos/bin/rlogin /usr/kerberos/bin/rlogin.original

# which rsh

Now I can use rcp command directly.

Using rlwrap to get command history of Oracle sqlplus and RMAN

These are what I’m using:

  • VMware Workstation 5.5
    host: Windows XP
    guest: Red Hat Advanced Server 2.1
    using Shared folder to exchange data between host and guest.
  • Oracle 9i

By default, Oracle sqlplus and RMAN don’t have command history under Linux OS. You have to type the same command over and over again. But you can use rlwrap to get command history for sqlplus and RMAN. Follow these steps:

  1. Download rlwrap (use browser downloader, cannot use download software).
  2. Extract the .tar.gz file.
  3. Login as root user.
  4. From root home, run the configure file.
    [root@eric root]# /mnt/hgfs/Share/rlwrap-0.30/configure
    [root@eric root]# make install
  5. now you can connect to sqlplus and RMAN using rlwrap:
    $ rlwrap sqlplus / as sysdba
    $ rlwrap rman target /
  6. Now you can use your previous command history by pressing up or down arrow.

Have fun…

How to Install Red Hat Advanced Server 2 in VMware Workstation 5.5

red_hat_logo_bigLast week I tried to install Red Hat Advanced Server 2.1 on my VMware Workstation 5.5 to try Oracle 9i installation. This is a very old version of RedHat but I need it for the project I’ll working with. After installation of Red Hat, I cannot use the desktop. I can only use the command line terminal. There are errors with the X Window caused by the VMware code. After struggling with the code, I finally can use the desktop. I just wanna share what I have done during the installation as detail as possible with image caption. You can download the pdf from following link.

How to Install Red Hat Advanced Server 2 in VMware Workstation 5.5

Now I’m trying to install Oracle 9i on it. I’ll post it as soon as I succeed the installation.

Good luck for you and for me too…

God bless…

Mount USB at VMware Red Hat

  1. Plug your USB to the computer.
  2. At the VMware, click VM -> Removable Devices -> USB Devices
  3. Click on the USB Devices until it is checked.
  4. Go to your Red Hat terminal.
  5. Login as root.
  6. Create the usb mount point
    # mkdir /mnt/myusb
  7. Mount the USB to the existing mount point.
    # mount -t vfat -o rw,users /dev/sda1 /mnt/myusb
    if /dev/sda1 is busy, you can use /dev/sdb1
  8. Check your USB
    # dir /mnt/myusb
  9. To unplug the USB, you have to umount the USB first.
    # umount /mnt/myusb
  10. Now you can unplug your USB.