You are on page 1of 16

CHECKING AND MONITORING

SYSTEM PERFORMANCE
The commands discussed below are some of the
most basic commands when it comes to checking and
monitoring system performance including the utilization
of the hard disk,memory or RAM,CPU,the running
processes and the network traffic.

top - Process Monitoring Command

The top program provides a dynamic real-time view of a


running system i.e. actual process activity. By default, it
displays the most CPU-intensive tasks running on the
server and updates the list every five seconds.

Syntax:
#top
The top command used to display all the running and
active real-time processes in ordered list and updates it
regularly. It display CPU usage, Memory usage, Swap
Memory,
Cache Size, Buffer Size, Process PID, User,
Commands and much more. It also shows high memory
and cpu utilization of a running processes. The top
command is much useful for system administrator to
monitor and take correct action when required
ps - Displays The Processes

ps command will report a snapshot of the current


processes.ie, the ps will provide you a list of processes
currently running.
Exam
ple:
#ps
PPI C STIME TIME
UID PID D TTY CMD
Dec22 00:00:03
root 1 0 0? init
Dec22 00:00:00
root 2 1 0? [keventd]

The ps command shows who owns the process, process


ID, parent process ID, CPU usage (in percent),start time of
date if the process has been running long enough, tty
associated with the process, cumulitive CPU usage (total
amount of CPU time is has used while running).
To select all processes use the -A or -e option:
# ps –A

free - Memory Usage

The command free displays the total amount of free


and used physical and swap memory in the system, as
well as the buffers used by the kernel.
#free

vmstat - System Activity, Hardware and System


Information
The command vmstat display statistics of about
virtual memory, kernerl threads, disks, system
processes, I/O blocks, interrupts, CPU activity
Syntax:
#vmstat

To get Information About Active / Inactive Memory


Pages use:
# vmstat -a
By default vmstat command is not available under
Linux systems you need to install a package called
sysstat that includes a vmstat program

iostat - Average CPU Load, Disk Activity


The command iostat report Central Processing
Unit (CPU) statistics and input/output statistics for
devices, partitions and network filesystems (NFS).ie,
The iostat will display the current CPU load average and
disk I/O information.
# iostat uptime - Tell How Long The System Has
Been Running
The uptime command can be used to see how long
the server has been running. The current time, how long
the system has been running, how many users are
currently logged on, and the system load averages for
the past 1, 5, and 15 minutes.
# uptime

who
The easiest way to see who is on the system is to do a
who or w. The who is a simple tool that lists out who is
logged on the system and what port or terminal they are
logged on at.
w - Find Out Who Is Logged on And What They Are
Doing
w command displays information about the users
currently on the machine, and their processes.
# w username

w displays information about the users currently on the


machine, and their processes. The header shows, in this order,
the current time, how long the system has been running, how
many users are currently logged on, and the system load
averages for the past 1, 5, and 15 minutes.

OPTIONS
-h :Don't print the header.
-s :Use the short format. Don't print the login time,
JCPU or PCPU times.
-V :Display version information.
user :Show information about the specified user only

netstat - Network Statistics


The command netstat displays network connections,
routing tables, interface statistics, and multicast
memberships.
Netstat is a command line tool for monitoring
incoming and outgoing network packets statistics.It is
very useful tool for every system administrator to
monitor network performance and troubleshoot network
related problems.

df - Monitoring the Hard Disk Space


The df command is used to show the amount of disk
space that is free on file systems.
Syntax:
df [OPTION]... [FILE]...

options:
-a : include dummy file systems

-i : list inode information

instead of block usage -T :

print file system type

-l : limit listing to local file systems


Getting System Information With uname,
host name

UNAME:
Print name of current system. Get name and information
about current kernel.

Syntax:
uname [-a] [-i] [-m] [-n] [-p] [-r] [-s] [-v] [-X] [-S
systemname]
Print basic information currently available
-a from the system.
Print the name of the hardware
-i implementation (platform).
Print the machine hardware name (class). Use
-m of this option is discouraged;
use uname -p instead.
Print the nodename (the nodename is the name
-n by which the system is
known to a communications network).
-p Print the current host's ISA or processor type.
-r Print the operating system release level.
Print the name of the operating system. This is
-s the default.
-v Print the operating system version.
Print expanded system information, one
-X information
element per line, as expected by SCO Unix.
The
displayed information includes:
system name, node, release, version,
 machine, and number of CPUs.

 BusType, Serial, and Users (set to


"unknown" in Solaris)
 OEM# and Origin# (set to 0 and 1,
respectively)

The nodename may be changed by specifying


-S a system name argument. The
systemn system name argument is restricted to
ame SYS_NMLN characters. SYS_NMLN
is an implementation specific value defined in
<sys/utsname.h>. Only the
super-user is allowed
this capability.

Examples
Uname -arv
List the basic system information, OS release, and OS
version as shown below.
SunOS hope 5.7 Generic_106541-08 sun4m sparc
SUNW,SPARCstation-10
Uname -p
Display the Linux platform.

5 uname Examples
1. A basic example
By default the uname command prints just the kernel
name.
For example :
$ uname
Output: Linux
2. Get the kernel name using -s option
Through -s option too, the name of the kernel can be
displayed in output.
For example :
$ uname -s
Output: Linux
3. Get the network node host name using -n option
Name of your host as a network node can be displayed in
output through -n option.
For example :
$ uname -n
Output: himanshu-laptop
4. Get kernel release information using the -r option
For example :
$ uname -r
Output: 2.6.32-21-generic5. Get maximum
information through -a option
For example :
$ uname –a

Output: Linux himanshu-laptop 2.6.32-21-generic


#32-Ubuntu SMP Fri Apr 16 08:09:38 UTC 2010 x86_64
GNU/Linux

HOSTNAME:

The hostname command is used to show or set a


computer's host name and domain name. It is one of the
most basic of the network administrative utilities. A host
name is a name that is assigned to a host (i.e., a computer
connected to the network) that uniquely identifies it on a
network and thus allows it to be addressed without using
its full IP address. Domain names are user-friendly
substitutes for numeric IP addresses. The basic syntax for
the hostname command is:
hostname [options] [new_host_name]

When a name is provided as an argument, it becomes the new


host name. A change in the host name can only be performed by
the root (i.e., administrative) account, which can be accessed
using the su (i.e., substitute user) command. For
example, to change the host name to computer_01,
the following would be used:
hostname computer_01

The -F option changes the host and domain names to that


written in a plain text file whose name is provided after
this option as an argument. Comments (i.e., lines starting
with a pound sign) in the file are ignored. Thus, for
example, if a file named name_1 were created that
contained a line that consisted of morgan.localdomain,
then following would change the hostname to
morgan.localdomain:
hostname -F name_1

The -s option displays the short host name, which is the


part of the name to the left of the first dot (e.g., localhost
or morgan in the above examples) i.e.,
hostname -s

Likewise, the -d option displays only the domain name,


i.e., the section to the right of the final dot (localdomain
in the above examples). The -a option displays any
aliases (i.e., substitute names) that are used for the host
name. The -i option displays the IP address(es) of the
host, which by default is 127.0.0.1.

The -v (verbose) option provides additional information.


The -V (upper case V) option displays version
information, and the -h option displays a brief help
message.

Choosing a hostname: There are different schemes and


conventions for choosing a hostname. Some take a
structured approach, for example if the system is their third
mail server, they might choose the name mail3, smtp3, or
something along those lines. Others will pick a name based
on a theme, for example at my workplace, there are
systems named mercury, neptune, orion, posiden, triton,
and venus, after classical gods. At one time, the
Massachusettes Institute of Technology had all of its name
servers named after breakfast cereals, for example
wheaties.mit.edu, cheerios.mit.edu, asnd
frootloops.mit.edu. Be creative, be utilitarian, be random...
it's completely up to you. The only limitations are:

 It cannot be longer than 64 characters


 It can only contain letters, numbers, and dashes

The only recommendations that I will make are that the


hostname you choose should be unique among the
systems that you're in charge of naming, and it should be
easy to type, because you will type it a lot over the
lifetime of the system.

USERS
/etc/passwd file contains one line for each user
account, with seven fields delimited by colons. This is a
text file. You can easily list users using the cat
command as follows:
$ cat /etc/passwd
a] $USER - Current user name.

b] $USERNAME - Current user name.


c] id command - Current user name.
Syntax

To get the current user name, type:


echo"$USER"

Get the current user name and store to a shell variable


called $u:
u="$USER"
echo"User
name $u"

The syntax for id command is:


id -u -n

To print numeric UID, run:


id -u

KERNEL
The Linux kernel is the operating system kernel used by
the Linux family of Unix-like operating systems. It is a
prominent example of free and open source software.
The Linux kernel is released under the GNU General
Public License version 2 (GPLv2) (plus some firmware
images with various non-free licenses), and is developed
by contributors worldwide. Linux rapidly accumulated
developers and users who adapted code from other free
software projects for use with the new operating system.
The Linux kernel has received contributions from
thousands of programmers. All Linux distributions
released have been based upon the Linux kernel. Kernel
abstracts the hardware to the upper layers. The kernel
presents the same view of hardware even if the underlying
hardware is different. It mediates and controls access to
system resources.
Kernel is hart of Linux O/S. It manages resource of Linux
O/S. Resources means facilities available in Linux. For eg.
Facility to store data, print data on printer, memory, file
management etc . Kernel decides who will use this
resource, for how long and when. It runs your programs (or
set up to execute binary files) It's Memory resident portion
of Linux. It performance following task:-
l I/O management
l Process management
l Device management
l File
management
l Memory management
The heart of the linux system is called kernel. The kernel
provides the interface between you (and the program you
run) and the hardware(hard disks, RAM, network cards
etc).Using the /proc file system, you can find out a lot of
information about your kernel, by simply displaying the
content of /proc file.
Cpuinfo: Tells you the type of CPU in your computer, the
speed, the CPU family and other information related to
your computer‘s processor.
Devices: Displays the character and block devices
currently being used on your computer along with their
major device numbers.
ioports: Shows the I/O port addresses for the devices on
your computer.
Meminfo: Contains information about memory usage and
swap space usage. You can see the total amounts of
memory and the how much is currently being used.
Modules: Shows a list of modules that are currently
installed in the system
Mounts: Displays the file systems that are currently
mounted in the system.
Partitions: Partition related information.
Pci: Lists the PCI devices.
Swaps: Shows the swap partition that are currently
mounted on your system. Net/dev: Displays content
of net/dev file to see your active network interfaces.

You might also like