Linux-Unix

We will have a quick look on useful commands and scripts.

List of UNIX Standard Directory Names

wrk  →working files

tmp  →temporary files that can be removed once used

bin  →binary files and executable scripts

src  →source code for programs

lib  →libraries: data for other programs to use

adm  →Administrative files

etc  →for unix system data files

misc  →miscelaneous files

include  →header files to be included in C & C++ program

Mail  →Used by elm for handling mail

mail  →Used by pine for mail messages

usr  →Files need by users but owned by the system

→where we put home directories

var  →various variable administrative and temporary files

sbin  →shared binaries

share  →shared directories

VI editor commands:

Quitting from vi file

:x Exit, saving changes
:q Exit as long as there have been no changes
ZZ Exit and save changes if any have been made
:q! Exit and ignore any changes

Inserting the Text

i Insert before cursor
I Insert before line
a Append after cursor
A Append after line
o Open a new line after current line
O Open a new line before current line
r Replace one character
R Replace many characters

Moving in the vi file

h Move left
j Move down
k Move up
l Move right
w Move to next word
W Move to next blank delimited word
b Move to the beginning of the word
B Move to the beginning of blank delimted word
e Move to the end of the word
E Move to the end of Blank delimited word
( Move a sentence back
) Move a sentence forward
{ Move a paragraph back
} Move a paragraph forward
0 Move to the begining of the line
$ Move to the end of the line
1G Move to the first line of the file
G Move to the last line of the file
nG Move to nth line of the file
:n Move to nth line of the file
fc Move forward to c
Fc Move back to c
H Move to top of screen
M Move to middle of screen
L Move to botton of screen
% Move to associated ( ), { }, [ ]

Deleting the text

x Delete character to the right of cursor
X Delete character to the left of cursor
D Delete to the end of the line
dd Delete current line
:d Delete current line

Yanking the text

yy Yank the current line
:y Yank the current line

Changing the text

C Change to the end of the line
cc Change the whole line

Putting the text

p Put after the position or after the line
P Put before the poition or before the line

Search for strings

/string Search forward for string
?string Search back for string
n Search for next instance of string
N Search for previous instance of string

Replacing

The search and replace function is accomplished with the :s command. It is commonly used in combination with ranges or the :g command.
:s/pattern/string/flags Replace pattern with string according to flags.
g Flag – Replace all occurences of pattern
c Flag – Confirm replaces.
& Repeat last :s command
:s/search_string/replacement_string/g
example :s/sanjay /kumar /g   <== Will replace sanjay to kumar in whole file.

Regular Expressions

. (dot) Any single character except newline
* zero or more occurances of any character
[…] Any single character specified in the set
[^…] Any single character not specified in the set
^ Anchor – beginning of the line
$ Anchor – end of line
\< Anchor – begining of word
\> Anchor – end of word
\(…\) Grouping – usually used to group conditions
\n Contents of nth grouping

                                       How to use Setting options

[A-Z] The SET from Capital A to Capital Z
[a-z] The SET from lowercase a to lowercase z
[0-9] The SET from 0 to 9 (All numerals)
[./=+] The SET containing . (dot), / (slash), =, and +
[-A-F] The SET from Capital A to Capital F and the dash (dashes must be specified first)
[0-9 A-Z] The SET containing all capital letters and digits and a space
[A-Z][a-zA-Z] In the first position, the SET from Capital A to Capital Z
In the second character position, the SET containing all letters

                                       Regular Expressions

/Hello/ Matches if the line contains the value Hello
/^TEST$/ Matches if the line contains TEST by itself
/^[a-zA-Z]/ Matches if the line starts with any letter
/^[a-z].*/ Matches if the first character of the line is a-z and there is at least one more of any character following it
/2134$/ Matches if line ends with 2134
/\(21|35\)/ Matches is the line contains 21 or 35
Note the use of ( ) with the pipe symbol to specify the ‘or’ condition
/[0-9]*/ Matches if there are zero or more numbers in the line
/^[^#]/ Matches if the first character is not a # in the line

                                        Notes:

1. Regular expressions are case sensitive
2. Regular expressions are to be used where pattern is specified

Counts

Nearly every command can be preceded by a number that specifies how many times it is to be performed. For example, 2dw will delete 2 words and 8fe will move the cursor forward to the 8rd occurence of the letter e. Even insertions may be repeated conveniently by using this method, For example to insert the same line 100 times.

Ranges

Ranges may precede most “colon” commands and cause them to be executed on a line or lines. For example :6,9d would delete lines 6-9. Ranges are commonly combined with the :s command to perform a replacement on several lines, as with :.,$s/pattern/string/g to make a replacement from the current line to the end of the file.
:a,b Range – Lines a-b
:. Range – Current line
:$ Range – Last line
:’c Range – Marker c
:% Range – All lines in file
:g/pattern/ Range – All lines that contain pattern

Files

:w file Write to file
:r file Read file in after line
:n Go to next file
:p Go to previos file
:e file Edit file
!!program Replace line with output from program

 

Unix: Files, Directories, Printing and Login

ls -a — lists all files, including the ones whose filenames begin in a dot, which you do not always want to see.

more filename — shows the first part of a file, just as much as will fit on one screen. Hit the space bar to see more or q to quit.

emacs filename — is an editor that lets you create and edit a file. See the

mv filename1 filename2 — moves a file (i.e. gives it a different name, or moves it into a different directory.

cp filename1 filename2 — copy a file

rm filename — removes a file. Better use the option rm -i, which will ask you for confirmation before actually deleting anything. Alternatively you can useAlias.

  • diff filename1 filename2 — compares files, and shows where they differ.
  • wc filename — tells you how many lines, words, and characters there are in a file.
  • chmod options filename — lets you change the read, write, and execute permissions on your files. The default is that only you can look at them and change them, but you may sometimes want to change these permissions. For example,
  • chmod o+r filename – will make the file readable for everyone, and
  • chmod o-r filename — will make it unreadable for others again.                                                                                                                             Note: that for someone to be able to actually look at the file the directories it is in need to be at least executable

File Compression

    • gzip filename — compresses files, so that they take up much less space.
    • gunzip filename — uncompresses files compressed by gzip.
    • gzcat filename — lets you look at a gzipped file without actually having to gunzip it (same as gunzip -c). You can even print it directly, using gzcat filename | lpr
  • printing
    • lpr filename — print. Use the -P option to specify the printer name if you want to use a printer other than your default printer. For example, if you want to print double-sided, use ‘lpr -Pvalkyr-d’, or if you’re at CSLI, you may want to use ‘lpr -Pcord115-d’.
    • lpq — check out the printer queue, e.g. to get the number needed for removal, or to see how many other files will be printed before yours will come out
    • lprm jobnumber — remove something from the printer queue. You can find the job number by using lpq. Theoretically you also have to specify a printer name, but this isn’t necessary as long as you use your default printer in the department.
    • genscript — converts plain text files into postscript for printing, and gives you some options for formatting. Consider making an alias like alias ecop ‘genscript -2 -r \!* | lpr -h -Pvalkyr’ to print two pages on one piece of paper.
    • dvips filename — print .dvi files (i.e. files produced by LaTeX). You can use dviselect to print only selected pages.

Directories

Directories, like folders on a Macintosh, are used to group files together in a hierarchical structure.

  • mkdir dirname — make a new directory.
  • cd dirname — change directory. You basically ‘go’ to another directory.
  • pwd — tells you where you currently are i.e. Present Working Directory.

Finding

  • ff — find files anywhere on the system. This can be extremely useful if you’ve forgotten in which directory you put a file, but do remember the name. In fact, if you use ff -p you don’t even need the full name, just the beginning.
  • grep string filename(s) — looks for the string in the files. This can be useful a lot of purposes, e.g. finding the right file among many, figuring out which is the right version of something, and even doing serious corpus work. grep comes in several varieties (grep, egrep, and fgrep) and has loads of flexible options.

About other people

  • w — tells you who’s logged in, and what they’re doing. Especially useful: the ‘idle’ part. This allows you to see whether they’re actually sitting there typing away at their keyboards right at the moment.
  • who — tells you who’s logged on, and where they’re coming from. Useful if you’re looking for someone who’s actually physically in the same building as you, or in some other particular location.
  • finger username — gives you lots of information about that user, e.g. when they last read their mail and whether they’re logged in. Often people put other practical information, such as phone numbers and addresses, in a file called .plan. This information is also displayed by ‘finger’.
  • last -1 username — tells you when the user last logged on and off and from where. Without any options, last will give you a list of everyone’s logins.
  • talk username — lets you have a (typed) conversation with another user
  • write username — lets you exchange one-line messages with another user
  • elm — lets you send e-mail messages to people around the world (and, of course, read them). It’s not the only mailer you can use, but the one we recommend.

About your login

  • whoami — returns your username.
  • passwd — lets you change your password.
  • ps -u yourusername — lists your processes. Contains lots of information about them, including the process ID, which you need if you have to kill a process.
  • ps -efl, because they’re root processes.
  • kill 3 PID — to generate the log. You may need the log before you kill any process.
  • Kill -9 PID —  to kill the process. If you have the right to do so.
  • quota -v — show what your disk quota details.
  • du filename — shows the disk usage of the files and directories in filename (without argument the current directory is used). du -s gives only a total.
  • last yourusername — lists your last logins. Can be a useful memory aid for when you were where, how long you’ve been working for, and keeping track of your phonebill if you’re making a non-local phonecall for dialling in.

Connecting out of the box

  • nn — allows you to read news. It will first let you read the news local to turing, and then the remote news. If you want to read only the local or remote news, you can use nnl or nnr, respectively. To learn more about nn typenn, then \tty{:man}, then \tty{=.*}, then \tty{Z}, then hit the space bar to step through the manual.
  • rlogin hostname — lets you connect to a remote host
  • telnet hostname —  lets you connect to a remote host.

Unix Sorting, Find, Shared Memory and file content conversion

1. How to sort based on column

$ ps -ef| grep LOCAL=NO| sort +5 sanjay 21148     1  0   May 01 ?       1886:04 oracleSanjay (LOCAL=NO) sanjay  4480     1  0   Apr 03 ?       145:05 oracleSanjay (LOCAL=NO) sanjay 1815     1  0   Apr 03 ?       305:34 oracleSanjay (LOCAL=NO) sanjay 4394     1  0   Apr 03 ?       413:50 oracleSanjay (LOCAL=NO)

2. Different options with ‘find’.

2.1 To find a file named “wherewere.you” under all sub-directories of /usr/oracle find /usr/oracle -name wherewere.you -print

2.2 To remove all the files under /usr/oracle which end with .tmp find /usr/oracle -name “*.tmp” -print -exec rm -f {} \;

2.3 To list all files under /usr/oracle which are older than a week. find /usr/oracle -mtime +7 -print

2.4 To list all files under /usr/oracle which are modified within a week. find /usr/oracle -mtime -7 -print

2.5 To compress all files which end with .dmp and are more than 2 MB. find /usr/oracle -size +2097152c -name “*.dmp” -print -exec compress {} \;

3. Shared memory segment sizes

ipcs -mb ipcs -b ipcrm -m       <== Use for the Shared Memory entry ipcrm -s       <== Use for the Semaphore entry

4. How to see the users logged in to the server and their IP address who -T

5. How to convert the contents of a text file to

A. UPPERCASE tr “[a-z]” “[A-Z]” < filename > newfilename

6. How to convert the contents of a text file to  lowercase. tr “[A-Z]” “[a-z]” < filename > newfilename

7. How to see lines 100 to 120 of a file head -120 filename | tail -20

8. How to see the versions of all Oracle products installed on the server. $ORACLE_HOME/orainst/inspdver

 

Unix: Commands for Solaris

1. How to collect explorer logs for solaris
# /opt/SUNWexplo/bin/explorer

run it on the box..

the output is available in:

cd /opt/SUNWexplo/output

2.How to check the memory size.

prtconf

3. prtdiag and prtdiag -v for
1. CPU status
2. Memory configuration
3. IO Cards
4. Environment status
a. system temperature.
b. Front panel status
c. Disk status
d. Fan status
e. Power suply
f.

prtdiag -v SAMPLE OUTPUT

prtdiag -v

[sk@sanjay01:/usr/sk] $ prtdiag -v
System Configuration: Sun Microsystems sun4u Sun Fire V490
System clock frequency: 150 MHz
Memory size: 8192 Megabytes

========================= CPUs ===============================================

Run E$ CPU CPU
Brd CPU MHz MB Impl. Mask
— —– —- —- ——- —-
A 0, 16 1500 32.0 US-IV+ 2.2
A 2, 18 1500 32.0 US-IV+ 2.2

========================= Memory Configuration ===============================

Logical Logical Logical
MC Bank Bank Bank DIMM Interleave Interleaved
Brd ID num size Status Size Factor with
— — —- —— ———– —— ———- ———–
A 0 0 1024MB no_status 512MB 8-way 0
A 0 1 1024MB no_status 512MB 8-way 0
A 0 2 1024MB no_status 512MB 8-way 0
A 0 3 1024MB no_status 512MB 8-way 0
A 2 0 1024MB no_status 512MB 8-way 0
A 2 1 1024MB no_status 512MB 8-way 0
A 2 2 1024MB no_status 512MB 8-way 0
A 2 3 1024MB no_status 512MB 8-way 0

========================= IO Cards =========================

Bus Max
IO Port Bus Freq Bus Dev,
Type ID Side Slot MHz Freq Func State Name Model
—- —- —- —- —- —- —- —– ——————————– ———————-
PCI 8 B 3 33 33 3,0 ok SUNW,XVR-100 SUNW,375-3290
PCI 8 B 5 33 33 5,0 ok scsi-pci1000,30.1000.10c0.8/disk+ LSI,1030
PCI 8 B 5 33 33 5,1 ok scsi-pci1000,30.1000.10c0.8/disk+ LSI,1030
PCI 8 A 0 66 66 1,0 ok SUNW,qlc-pci1077,2312.1077.149.2+
PCI 8 A 1 66 66 2,0 ok SUNW,qlc-pci1077,2312.1077.149.2+

========================= Environmental Status =========================

System Temperatures (Celsius):
——————————-
Device Temperature Status
—————————————
CPU0 48 OK
CPU2 50 OK
DBP0 23 OK

=================================

Front Status Panel:
——————-
Keyswitch position: NORMAL

System LED Status:

LOCATOR FAULT POWER
——- ——- ——-
[OFF] [OFF] [ ON]

=================================

Disk Status:
————
DISK 0: [NO_FAULT]
DISK 1: [NO_FAULT]

=================================

Fan Status:
———–

Fan Tray Fan RPM Status
———– —- —– ———-
FAN_TRAY_0 CPU0_FAN 5454 [NO_FAULT]
FAN_TRAY_0 CPU1_FAN 4054 [NO_FAULT]
FAN_TRAY_0 CPU2_FAN 3947 [NO_FAULT]
FAN_TRAY_1 IO0_FAN 4054 [NO_FAULT]
FAN_TRAY_1 IO1_FAN 4166 [NO_FAULT]

=================================

Power Supplies:
—————

Supply Status Fault Fan Fail Temp Fail
—— ———— ——– ——— ———
PS0 [NO_FAULT ] OFF OFF OFF
PS1 [NO_FAULT ] OFF OFF OFF

=================================

========================= HW Revisions =======================================

System PROM revisions:
———————-
OBP 4.18.1 2005/06/13 11:39

IO ASIC revisions:
——————
Port
Model ID Status Version
——– —- —— ——-
Schizo 8 ok 7
Schizo 9 ok 7
[sk@sanjay01:/usr/sk] $

4. to see file i/o

iostat -xtnM 5

show from time to time 2-3 procent %w , (for /var and /export)

The Database server is a V440 with 16 Gb ram / 4 x 1,3Ghz CPU Only 1 scsi bus

yesterday 1528 study / 92539 object arrive

sk@sanjay01:/usr/sk] $ prtconf
System Configuration: Sun Microsystems sun4u
Memory size: 16384 Megabytes
System Peripherals (Software Nodes):
/var/adm/messages
/etc/vfstab

5. How to check O.S level files.

/var/adm/messages

/var/opt/SUNWscor/oracle_server/messages.log.oracle

/var/opt/SUNWscor/oracle_listener/messages.log.listener

/var/opt/SUNWscor/oracle_listener

/var/opt/SUNWscor/oracle_server

/data/logs/oracle/bdump/alert_sk.log

6. Performance related commands:

Introduction to iostat , vmstat and netstat

This document is primarily written with reference to solaris performance monitoring and tuning but these tools are available in other unix variants also with slight syntax difference.

iostat , vmstat and netstat are three most commonly used tools for performance monitoring . These comes built in with the operating system and are easy to use .iostat stands for input output statistics and reports statistics for i/o devices such as disk drives . vmstat gives the statistics for virtual Memory and netstat gives the network statstics .

Following paragraphs describes these tools and their usage for performance monitoring.

Table of content :
1. Iostat
* Syntax
* example
* Result and Solutions

2. vmstat
* syntax
* example
* Result and Solutions

3. netstat
* syntax
* example
* Result and Solutions

Input Output statistics ( iostat )
iostat reports terminal and disk I/O activity and CPU utilization. The first line of output is for the time period since boot & each subsequent line is for the prior interval . Kernel maintains a number of counters to keep track of the values.

iostat’s activity class options default to tdc (terminal, disk, and CPU). If any other option/s are specified, this default is completely overridden i.e. iostat -d will report only statistics about the disks.

syntax:
Basic synctax is iostat interval count
option – let you specify the device for which information is needed like disk , cpu or terminal. (-d , -c , -t or -tdc ) . x options gives the extended statistics .

interval – is time period in seconds between two samples . iostat 4 will give data at each 4 seconds interval.

count – is the number of times the data is needed . iostat 4 5 will give data at 4 seconds interval 5 times

Example
$ iostat -xtc 10 5

extended disk statistics tty cpu
disk r/s w/s Kr/s Kw/s wait actv svc_t %w %b tin tout us sy wt id
sd0 2.6 3.0 20.7 22.7 0.1 0.2 59.2 6 19 0 84 3 85 11 0
sd1 4.2 1.0 33.5 8.0 0.0 0.2 47.2 2 23
sd2 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0 0
sd3 10.2 1.6 51.4 12.8 0.1 0.3 31.2 3 31

The fields have the following meanings:
disk name of the disk
r/s reads per second
w/s writes per second
Kr/s kilobytes read per second
Kw/s kilobytes written per second
wait average number of transactions waiting for service (Q length)
actv average number of transactions actively being serviced
(removed from the queue but not yet completed)
%w percent of time there are transactions waiting
for service (queue non-empty)
%b percent of time the disk is busy (transactions
in progress)
Results and Solutions
The values to look from the iostat output are:
* Reads/writes per second (r/s , w/s)
* Percentage busy (%b)
* Service time (svc_t)

If a disk shows consistently high reads/writes along with , the percentage busy (%b) of the disks is greater than 5 percent, and the average service time (svc_t) is greater than 30 milliseconds, then one of the following action needs to be taken

1.) Tune the application to use disk i/o more efficiently by modifying the disk queries and using available cache facilities of application servers .

2.) Spread the file system of the disk on to two or more disk using disk striping feature of volume manager /disksuite etc.

3.) Increase the system parameter values for inode cache , ufs_ninode , which is Number of inodes to be held in memory. Inodes are cached globally (for UFS), not on a per-file system basis

4.) Move the file system to another faster disk /controller or replace existing disk/controller to a faster one.
Virtual Memory Statistics ( vmstat )

vmstat – vmstat reports virtual memory statistics of process, virtual memory, disk, trap, and CPU activity.

On multicpu systems , vmstat averages the number of CPUs into the output. For per-process statistics .Without options, vmstat displays a one-line summary of the virtual memory activity since the system was booted.

syntax
Basic synctax is vmstat interval count

option – let you specify the type of information needed such as paging -p , cache -c ,.interrupt -i etc.

if no option is specified information about process , memory , paging , disk ,interrupts & cpu is displayed .

interval – is time period in seconds between two samples . vmstat 4 will give data at each 4 seconds interval.

count – is the number of times the data is needed . vmstat 4 5 will give data at 4 seconds interval 5 times.

Example
The following command displays a summary of what the system
is doing every five seconds.

# vmstat 5

procs memory page disk faults cpu
r b w swap free re mf pi p fr de sr s0 s1 s2 s3 in sy cs us sy id
0 0 0 11456 4120 1 41 19 1 3 0 2 0 4 0 0 48 112 130 4 14 82
0 0 1 10132 4280 0 4 44 0 0 0 0 0 23 0 0 211 230 144 3 35 62
0 0 1 10132 4616 0 0 20 0 0 0 0 0 19 0 0 150 172 146 3 33 64
0 0 1 10132 5292 0 0 9 0 0 0 0 0 21 0 0 165 105 130 1 21 78

The fields of vmstat’s display are
procs
r in run queue
b blocked for resources I/O, paging etc.
w swapped
memory (in Kbytes)
swap – amount of swap space currently available
free – size of the free list

page ( in units per second).
re page reclaims – see -S option for how this
field is modified.
mf minor faults – see -S option for how this
field is modified.
pi kilobytes paged in
po kilobytes paged out
fr kilobytes freed
de anticipated short-term memory shortfall (Kbytes)
sr pages scanned by clock algorithm
disk ( operations per second )
There are slots for up to four disks,
labeled with a single letter and number.
The letter indicates the type of disk
(s = SCSI, i = IPI, etc).
The number is the logical unit number.

faults
in (non clock) device interrupts
sy system calls
cs CPU context switches

cpu – breakdown of percentage usage of CPU time.
On multiprocessors this is an a
average across all processors.
us user time
sy system time
id idle time
Results and Solution from iostat

A. CPU issues
Following columns has to be watched to determine if there is any cpu issue

1. Processes in the run queue (procs r)
2. User time (cpu us)
3. System time (cpu sy)
4. Idle time (cpu id)

procs cpu
r b w us sy id
0 0 0 4 14 82
0 0 1 3 35 62
0 0 1 3 33 64
0 0 1 1 21 78
Problem symptoms

A.) Number of processes in run queue
1.) If the number of processes in run queue (procs r) are consistently greater than the number of CPUs on the system it will slow down system as there are more processes then available CPUs .
2.) if this number is more than four times the number of available CPUs in the system then system is facing shortage of cpu power and will greatly slow down the processess on the system.
3.) If the idle time (cpu id) is consistently 0 and if the system time (cpu sy) is double the user time (cpu us) system is facing shortage of CPU resources.

Resolution
Resolution to these kind of issues involves tuning of application procedures to make efficient use of cpu and as a last resort increasing the cpu power or adding more cpu to the system.

B. Memory Issues
Memory bottlenecks are determined by the scan rate (sr) . The scan rate is the pages scanned by the clock algorithm per second. If the scan rate (sr) is continuously over 200 pages per second then there is a memory shortage.

Resolution
1. Tune the applications & servers to make efficient use of memory and cache.
2. Increase system memory .
3. Implement priority paging in s in pre solaris 8 versions by adding line “set priority paging=1? in
/etc/system. Remove this line if upgrading from Solaris 7 to 8 & retaining old /etc/system file.
7. Network Statistics (netstat)

netstat displays the contents of various network-related data structures in depending on the options selected.

Syntax

netstat
multiple options can be given at one time.

Options
-a – displays the state of all sockets.
-r – shows the system routing tables
-i – gives statistics on a per-interface basis.
-m – displays information from the network memory buffers. On Solaris, this shows statistics
for STREAMS
-p [proto] – retrieves statistics for the specified protocol
-s – shows per-protocol statistics. (some implementations allow -ss to remove fileds with a value of 0 (zero) from the display.)
-D – display the status of DHCP configured interfaces.
-n do not lookup hostnames, display only IP addresses.
-d (with -i) displays dropped packets per interface.
-I [interface] retrieve information about only the specified interface.
-v be verbose

interval – number for continuous display of statictics.

Example

$netstat -rn

Routing Table: IPv4
Destination Gateway Flags Ref Use Interface
——————– ——————– —– —– —— ———
192.168.1.0 192.168.1.11 U 1 1444 le0
224.0.0.0 192.168.1.11 U 1 0 le0
default 192.168.1.1 UG 1 68276
127.0.0.1 127.0.0.1 UH 1 10497 lo0
This shows the output on a Solaris machine who’s IP address is 192.168.1.11 with a default router at 192.168.1.1

Results and Solutions

A.) Network availability
The command as above is mostly useful in troubleshooting network accessibility issues . When outside network is not accessible from a machine check the following

1. if the default router ip address is correct
2. you can ping it from your machine.
3. If router address is incorrect it can be changed with route add command. See man route for more information.

route command examples
$route add default
$route add 192.0.2.32

If the router address is correct but still you can’t ping it there may be some network cable /hub/switch problem and you have to try and eliminate the faulty component .

B.) Network Response
$ netstat -i

Name Mtu Net/Dest Address Ipkts Ierrs Opkts Oerrs Collis Queue
lo0 8232 loopback localhost 77814 0 77814 0 0 0
hme0 1500 server1 server1 10658 3 48325 0 279257 0
This option is used to diagnose the network problems when the connectivity is there but it is slow in response .

Values to look at:

* Collisions (Collis)
* Output packets (Opkts)
* Input errors (Ierrs)
* Input packets (Ipkts)

The above values will give information to workout

i. Network collision rate as follows :

Network collision rate = Output collision counts / Output packets

Network-wide collision rate greater than 10 percent will indicate

* Overloaded network,
* Poorly configured network,
* Hardware problems.

ii. Input packet error rate as follows :

Input Packet Error Rate = Ierrs / Ipkts.

If the input error rate is high (over 0.25 percent), the host is dropping packets. Hub/switch cables etc needs to be checked for potential problems.

C. Network socket & TCP Connection state

Netstat gives important information about network socket and tcp state . This is very useful in
finding out the open , closed and waiting network tcp connection .

Network states returned by netstat are following

CLOSED —- Closed. The socket is not being used.
LISTEN —- Listening for incoming connections.
SYN_SENT —- Actively trying to establish connection.
SYN_RECEIVED —- Initial synchronization of the connection under way.
ESTABLISHED —- Connection has been established.
CLOSE_WAIT —- Remote shut down; waiting for the socket to close.
FIN_WAIT_1 —- Socket closed; shutting down connection.
CLOSING —- Closed,
then remote shutdown; awaiting acknowledgement.
LAST_ACK —- Remote shut down, then closed ;awaiting acknowledgement.
FIN_WAIT_2 —- Socket closed; waiting for shutdown from remote.
TIME_WAIT —- Wait after close for remote shutdown retransmission..
Example
#netstat -a

Local Address Remote Address Swind Send-Q Rwind Recv-Q State
*.* *.* 0 0 24576 0 IDLE
*.22 *.* 0 0 24576 0 LISTEN
*.22 *.* 0 0 24576 0 LISTEN
*.* *.* 0 0 24576 0 IDLE
*.32771 *.* 0 0 24576 0 LISTEN
*.4045 *.* 0 0 24576 0 LISTEN
*.25 *.* 0 0 24576 0 LISTEN
*.5987 *.* 0 0 24576 0 LISTEN
*.898 *.* 0 0 24576 0 LISTEN
*.32772 *.* 0 0 24576 0 LISTEN
*.32775 *.* 0 0 24576 0 LISTEN
*.32776 *.* 0 0 24576 0 LISTEN
*.* *.* 0 0 24576 0 IDLE
192.168.1.184.22 192.168.1.186.50457 41992 0 24616 0 ESTABLISHED
192.168.1.184.22 192.168.1.186.56806 38912 0 24616 0 ESTABLISHED
192.168.1.184.22 192.168.1.183.58672 18048 0 24616 0 ESTABLISHED
if you see a lots of connections in FIN_WAIT state tcp/ip parameters have to be tuned because the
connections are not being closed and they gets accumulating . After some time system may run out of
resource . TCP parameter can be tuned to define a time out so that connections can be released and used by new connection.
8. CPU information

$ psrinfo
0 on-line since 04/20/2011 22:22:44
1 on-line since 04/20/2011 22:22:44
2 on-line since 04/20/2011 22:22:44
3 on-line since 04/20/2011 22:22:42
16 on-line since 04/20/2011 22:22:44
17 on-line since 04/20/2011 22:22:44
18 on-line since 04/20/2011 22:22:44
19 on-line since 04/20/2011 22:22:44
$ psrinfo -p
4
$
$ psrinfo -pv
The UltraSPARC-IV physical processor has 2 virtual processors (0, 16)
The UltraSPARC-IV physical processor has 2 virtual processors (1, 17)
The UltraSPARC-IV physical processor has 2 virtual processors (2, 18)
The UltraSPARC-IV physical processor has 2 virtual processors (3, 19)

Leave a Reply

You must be logged in to post a comment.