How to Setup NetHogs – Monitor Bandwidth Usage Per Process in Linux

NetHogs is a opensource tools to monitor network bandwidth that was used by the process and program in linux operating system. NetHogs does not rely on a special kernel module to be loaded. When you hit the high network traffic issue on your linux server, you can immediately find which PID is causing the issue. NetHogs will give you real time statistics of your network bandwidth of per process usage. Follow this steps to install NetHogs on linux CentOS 6.5 and the sample nethogs usage.

1. Prepare additional repository (EPEL repository).

2. Install nethogs :

[root@oss ~]# yum install nethogs -y

3. NetHogs utility :

[root@oss ~]# nethogs

Sample output :
setup nethogs -1

4. NetHogs command option :
There are a few commad options when using nethogs. Using ‘-d‘ to add a refresh rate. As an example, to set 5 seconds as your refresh rate, then type the command as.

[root@oss ~]# nethogs -d 5

Other options :

-d     delay for refresh rate.
-h     display available commands usage.
-p     sniff in promiscious mode (not recommended).
-t     tracemode.
-V     prints Version info.

5. Monitor specific device (eth0 or eth1) network bandwidth only :

a) Monitor eth0 bandwidth :

[root@oss ~]# nethogs eth0

a) Monitor eth0 and eth1 bandwidth :

[root@oss ~]# nethogs eth0 eth1

Reference :

How to Setup Collectl – Linux Performance Monitoring

Collectl is a linux performance monitoring tools that grabs as much detail as possible from the /proc filesystem and it does a lot more than most other tools. Compare to sar, collectl has some capabilities that sar does not have. Collectl can gather and post-process the performance data and also can save the performance data for later analysis. Please refer to below guide on how you can setup collectl on linux CentOS 6.5 and the sample usage of collectl :

1. Install collectl. Make sure additional repository (EPEL repository) has been installed :
a. For Red Hat based distro :

[root@oss ~]# yum install collectl -y

b. For debian bas distro :

[root@oss ~]# sudo apt-get install collectl -y

2. Display collectl command help :

[root@oss ~]# collectl -h
This is a subset of the most common switches and even the descriptions are
abbreviated.  To see all type 'collectl -x', to get started just type 'collectl'

usage: collectl [switches]
  -c, --count      count      collect this number of samples and exit
  -f, --filename   file       name of directory/file to write to
  -i, --interval   int        collection interval in seconds [default=1]
  -o, --options    options    misc formatting options, --showoptions for all
                                d|D - include date in output
                                  T - include time in output
                                  z - turn off compression of plot files
  -p, --playback   file       playback results from 'file' (be sure to quote
                              if wild carded) or the shell might mess it up
  -P, --plot                  generate output in 'plot' format
  -s, --subsys     subsys     specify one or more subsystems [default=cdn]
      --verbose               display output in verbose format (automatically
                              selected when brief doesn't make sense)

Various types of help
  -h, --help                  print this text
  -v, --version               print version
  -V, --showdefs              print operational defaults
  -x, --helpextend            extended help, more details descriptions too
  -X, --helpall               shows all help concatenated together

  --showoptions               show all the options
  --showsubsys                show all the subsystems
  --showsubopts               show all subsystem specific options
  --showtopopts               show --top options

  --showheader                show file header that 'would be' generated
  --showcolheaders            show column headers that 'would be' generated
  --showslabaliases           for SLUB allocator, show non-root aliases
  --showrootslabs             same as --showslabaliases but use 'root' names

Copyright 2003-2014 Hewlett-Packard Development Company, L.P.
collectl may be copied only under the terms of either the Artistic License
or the GNU General Public License, which may be found in the source kit

3. According to the man page, collectl identifies the following subsystems :

SUMMARY SUBSYSTEMS

OptionDescription
bBuddy information (memory fragmentation)
cCPU information
dDisk
fNFS information
iinode information
jInterrupts
lLustre
mMemory
nNetworks
sSockets
tTCP
xInterconnect
ySlabs

DETAIL SUBSYSTEMS

OptionDescription
CCPU
DDisk
EEnvironmentals via ipmitool
FNFS data
JInterrupts
MMemory node data (including numa)
NNetworks
TSixty-five TCP counters (only in plot format)
XInterconnect
YSlabs
ZProcesses

 

4. Monitor cpu subsystem :

[root@oss ~]# collectl -sc
waiting for 1 second sample...
#< --------CPU-------->
#cpu sys inter  ctxsw
   0   0    34     37
   0   0    56     40
   0   0    38     44
   0   0    31     35
   0   0    36     44
[root@oss ~]# collectl -sC
waiting for 1 second sample...

# SINGLE CPU STATISTICS
#   Cpu  User Nice  Sys Wait IRQ  Soft Steal Idle
      0     0    0    0    0    0    0     0  100
      1     0    0    0    0    0    0     0  100
      0     0    0    0    0    0    0     0  100
      1     0    0    0    0    0    0     0  100
      0     0    0    0    0    0    0     0  100
      1     0    0    0    0    0    0     0  100
      0     0    0    0    0    0    0     0  100
      1     0    0    0    0    0    0     0  100
      0     0    0    0    0    0    0     0  100
      1     0    0    0    4    0    0     0   96
      0     0    0    0    0    0    0     0   99
      1     0    0    0    0    0    0     0   99
      0     0    0    0    0    0    0     0  100
      1     0    0    0    0    0    0     0  100
      0     0    0    0    0    0    0     0  100
      1     1    0    0    0    0    0     0   99
      0     0    0    0    0    0    0     0  100
      1     0    0    0    0    0    0     0  100
      0     0    0    0    0    0    0     0  100
      1     0    0    0    0    0    0     0  100
      0     0    0    0    0    0    0     0  100
      1     0    0    0    0    0    0     0  100

5. Monitor memory subsystem :

[root@oss ~]# collectl -sm
waiting for 1 second sample...
#< -----------Memory----------->
#Free Buff Cach Inac Slab  Map
   3G  19M 166M  50M  36M  34M
   3G  19M 166M  50M  36M  34M
   3G  19M 166M  50M  36M  34M
   3G  19M 166M  50M  36M  34M
   3G  19M 166M  50M  36M  34M
   3G  19M 166M  50M  36M  34M
   3G  19M 166M  50M  36M  34M
   3G  19M 166M  50M  36M  34M
[root@oss ~]# collectl -sM
waiting for 1 second sample...

# MEMORY STATISTICS
# Node    Total     Used     Free     Slab   Mapped     Anon   Locked    Inact   Hit%
     0    4095M  565208K    3543M   37112K    9408K   25492K        0   51756K 100.00
     0    4095M  565208K    3543M   37112K    9408K   25492K        0   51756K 100.00
     0    4095M  565208K    3543M   37108K    9408K   25492K        0   51756K 100.00
     0    4095M  565208K    3543M   37108K    9408K   25492K        0   51756K 100.00
     0    4095M  565208K    3543M   37108K    9408K   25492K        0   51756K 100.00
     0    4095M  565208K    3543M   37108K    9408K   25492K        0   51760K 100.00
     0    4095M  565208K    3543M   37036K    9408K   25492K        0   51760K 100.00
     0    4095M  565184K    3543M   37028K    9408K   25492K        0   51760K 100.00
     0    4095M  565184K    3543M   37028K    9408K   25492K        0   51760K 100.00
     0    4095M  565184K    3543M   37024K    9408K   25492K        0   51760K 100.00
     0    4095M  565184K    3543M   37024K    9408K   25492K        0   51760K 100.00
     0    4095M  565184K    3543M   37016K    9408K   25492K        0   51760K 100.00
     0    4095M  565168K    3543M   36972K    9408K   25492K        0   51760K 100.00
     0    4095M  565168K    3543M   36972K    9408K   25492K        0   51760K 100.00
     0    4095M  565168K    3543M   36972K    9408K   25492K        0   51760K 100.00
     0    4095M  565168K    3543M   36968K    9408K   25492K        0   51760K 100.00
     0    4095M  565160K    3543M   36932K    9408K   25492K        0   51760K 100.00
     0    4095M  565160K    3543M   36932K    9408K   25492K        0   51760K 100.00
     0    4095M  565160K    3543M   36932K    9408K   25492K        0   51760K 100.00
     0    4095M  565160K    3543M   36900K    9408K   25492K        0   51760K 100.00
     0    4095M  565160K    3543M   36900K    9408K   25492K        0   51760K 100.00
     0    4095M  565160K    3543M   36900K    9408K   25492K        0   51760K 100.00

6. Monitor disk subsystem :

[root@oss ~]# collectl -sd
waiting for 1 second sample...
#< ----------Disks----------->
#KBRead  Reads KBWrit Writes
      0      0      0      0
      0      0      0      0
      0      0      0      0
      0      0      0      0
      0      0     16      3
      0      0      0      0
      0      0      0      0
      0      0      0      0
      0      0      0      0
      0      0      0      0
[root@oss ~]# collectl -sD
waiting for 1 second sample...

# DISK STATISTICS (/sec)
#           Pct
#Name       KBytes Merged  IOs Size  KBytes Merged  IOs Size  RWSize  QLen  Wait SvcTim Util
sda              0      0    0    0       0      0    0    0       0     0     0      0    0
sda              0      0    0    0       0      0    0    0       0     0     0      0    0
sda              0      0    0    0      16      1    3    5       5     1    13     10    3
sda              0      0    0    0       0      0    0    0       0     0     0      0    0
sda              0      0    0    0       0      0    0    0       0     0     0      0    0
sda              0      0    0    0       0      0    0    0       0     0     0      0    0
sda              0      0    0    0       0      0    0    0       0     0     0      0    0
sda              0      0    0    0       0      0    0    0       0     0     0      0    0
sda              0      0    0    0       0      0    0    0       0     0     0      0    0

7. collectl like iotop :

[root@oss ~]# collectl --top iokb

Sample output :

# TOP PROCESSES sorted by iokb (counters are /sec) 13:35:14
# PID  User     PR  PPID THRD S   VSZ   RSS CP  SysT  UsrT Pct  AccuTime  RKB  WKB MajF MinF Command
    1  root     20     0    0 S   18M    1M  0  0.00  0.00   0  00:01.13    0    0    0    0 /sbin/init
    2  root     20     0    0 S     0     0  0  0.00  0.00   0  00:00.02    0    0    0    0 kthreadd
    3  root     RT     2    0 S     0     0  0  0.00  0.00   0  00:00.04    0    0    0    0 migration/0
    4  root     20     2    0 S     0     0  0  0.00  0.00   0  00:00.09    0    0    0    0 ksoftirqd/0
    5  root     RT     2    0 S     0     0  0  0.00  0.00   0  00:00.00    0    0    0    0 migration/0
    6  root     RT     2    0 S     0     0  0  0.00  0.00   0  00:00.30    0    0    0    0 watchdog/0
    7  root     RT     2    0 S     0     0  1  0.00  0.00   0  00:00.38    0    0    0    0 migration/1
    8  root     RT     2    0 S     0     0  1  0.00  0.00   0  00:00.00    0    0    0    0 migration/1
    9  root     20     2    0 S     0     0  1  0.00  0.00   0  00:00.22    0    0    0    0 ksoftirqd/1
   10  root     RT     2    0 S     0     0  1  0.00  0.00   0  00:00.28    0    0    0    0 watchdog/1
   11  root     20     2    0 S     0     0  0  0.00  0.00   0  00:08.15    0    0    0    0 events/0
   12  root     20     2    0 S     0     0  1  0.00  0.00   0  01:21.61    0    0    0    0 events/1
   13  root     20     2    0 S     0     0  1  0.00  0.00   0  00:00.00    0    0    0    0 cgroup
   14  root     20     2    0 S     0     0  0  0.00  0.00   0  00:00.00    0    0    0    0 khelper
   15  root     20     2    0 S     0     0  1  0.00  0.00   0  00:00.00    0    0    0    0 netns
   16  root     20     2    0 S     0     0  0  0.00  0.00   0  00:00.00    0    0    0    0 async/mgr
   17  root     20     2    0 S     0     0  1  0.00  0.00   0  00:00.00    0    0    0    0 pm
   18  root     20     2    0 S     0     0  0  0.00  0.00   0  00:00.84    0    0    0    0 sync_supers
   19  root     20     2    0 S     0     0  0  0.00  0.00   0  00:00.82    0    0    0    0 bdi-default
   20  root     20     2    0 S     0     0  0  0.00  0.00   0  00:00.00    0    0    0    0 kintegrityd/0
   21  root     20     2    0 S     0     0  1  0.00  0.00   0  00:00.00    0    0    0    0 kintegrityd/1
   22  root     20     2    0 S     0     0  0  0.00  0.00   0  00:00.15    0    0    0    0 kblockd/0

Display only top 10 processes :

[root@oss ~]# collectl --top iokb,10

Sample output :

# TOP PROCESSES sorted by iokb (counters are /sec) 13:42:37
# PID  User     PR  PPID THRD S   VSZ   RSS CP  SysT  UsrT Pct  AccuTime  RKB  WKB MajF MinF Command
    1  root     20     0    0 S   18M    1M  0  0.00  0.00   0  00:01.13    0    0    0    0 /sbin/init
    2  root     20     0    0 S     0     0  0  0.00  0.00   0  00:00.02    0    0    0    0 kthreadd
    3  root     RT     2    0 S     0     0  0  0.00  0.00   0  00:00.04    0    0    0    0 migration/0
    4  root     20     2    0 S     0     0  0  0.00  0.00   0  00:00.09    0    0    0    0 ksoftirqd/0
    5  root     RT     2    0 S     0     0  0  0.00  0.00   0  00:00.00    0    0    0    0 migration/0
    6  root     RT     2    0 S     0     0  0  0.00  0.00   0  00:00.30    0    0    0    0 watchdog/0
    7  root     RT     2    0 S     0     0  1  0.00  0.00   0  00:00.39    0    0    0    0 migration/1
    8  root     RT     2    0 S     0     0  1  0.00  0.00   0  00:00.00    0    0    0    0 migration/1
    9  root     20     2    0 S     0     0  1  0.00  0.00   0  00:00.22    0    0    0    0 ksoftirqd/1
   10  root     RT     2    0 S     0     0  1  0.00  0.00   0  00:00.28    0    0    0    0 watchdog/1

Learn what fields the above list can be sorted :

[root@oss ~]# collectl --showtopopts
The following is a list of --top's sort types which apply to either
process or slab data.  In some cases you may be allowed to sort
by a field that is not part of the display if you so desire

TOP PROCESS SORT FIELDS

Memory
  vsz    virtual memory
  rss    resident (physical) memory

Time
  syst   system time
  usrt   user time
  time   total time
  accum  accumulated time

I/O
  rkb    KB read
  wkb    KB written
  iokb   total I/O KB

  rkbc   KB read from pagecache
  wkbc   KB written to pagecache
  iokbc  total pagecacge I/O
  ioall  total I/O KB (iokb+iokbc)

  rsys   read system calls
  wsys   write system calls
  iosys  total system calls

  iocncl Cancelled write bytes

Page Faults
  majf   major page faults
  minf   minor page faults
  flt    total page faults

Context Switches
  vctx   volunary context switches
  nctx   non-voluntary context switches

Miscellaneous (best when used with --procfilt)
  cpu    cpu number
  pid    process pid
  thread total process threads (not counting main)

TOP SLAB SORT FIELDS

  numobj    total number of slab objects
  actobj    active slab objects
  objsize   sizes of slab objects
  numslab   number of slabs
  objslab   number of objects in a slab
  totsize   total memory sizes taken by slabs
  totchg    change in memory sizes
  totpct    percent change in memory sizes
  name      slab names

8. collectl like top :

[root@oss ~]# collectl --top

Sample output :

# TOP PROCESSES sorted by time (counters are /sec) 13:45:00
# PID  User     PR  PPID THRD S   VSZ   RSS CP  SysT  UsrT Pct  AccuTime  RKB  WKB MajF MinF Command
 3266  root     20  2488    0 R  160M   21M  1  0.00  0.05   5  00:00.70    0    0    0   83 /usr/bin/perl
    1  root     20     0    0 S   18M    1M  0  0.00  0.00   0  00:01.13    0    0    0    0 /sbin/init
    2  root     20     0    0 S     0     0  0  0.00  0.00   0  00:00.02    0    0    0    0 kthreadd
    3  root     RT     2    0 S     0     0  0  0.00  0.00   0  00:00.04    0    0    0    0 migration/0
    4  root     20     2    0 S     0     0  0  0.00  0.00   0  00:00.09    0    0    0    0 ksoftirqd/0
    5  root     RT     2    0 S     0     0  0  0.00  0.00   0  00:00.00    0    0    0    0 migration/0
    6  root     RT     2    0 S     0     0  0  0.00  0.00   0  00:00.31    0    0    0    0 watchdog/0
    7  root     RT     2    0 S     0     0  1  0.00  0.00   0  00:00.39    0    0    0    0 migration/1
    8  root     RT     2    0 S     0     0  1  0.00  0.00   0  00:00.00    0    0    0    0 migration/1
    9  root     20     2    0 S     0     0  1  0.00  0.00   0  00:00.22    0    0    0    0 ksoftirqd/1
   10  root     RT     2    0 S     0     0  1  0.00  0.00   0  00:00.28    0    0    0    0 watchdog/1
   11  root     20     2    0 S     0     0  0  0.00  0.00   0  00:08.18    0    0    0    0 events/0
   12  root     20     2    0 S     0     0  1  0.00  0.00   0  01:21.97    0    0    0    0 events/1
   13  root     20     2    0 S     0     0  1  0.00  0.00   0  00:00.00    0    0    0    0 cgroup
   14  root     20     2    0 S     0     0  0  0.00  0.00   0  00:00.00    0    0    0    0 khelper
   15  root     20     2    0 S     0     0  1  0.00  0.00   0  00:00.00    0    0    0    0 netns
   16  root     20     2    0 S     0     0  0  0.00  0.00   0  00:00.00    0    0    0    0 async/mgr
   17  root     20     2    0 S     0     0  1  0.00  0.00   0  00:00.00    0    0    0    0 pm
   18  root     20     2    0 S     0     0  0  0.00  0.00   0  00:00.84    0    0    0    0 sync_supers
   19  root     20     2    0 S     0     0  0  0.00  0.00   0  00:00.83    0    0    0    0 bdi-default
   20  root     20     2    0 S     0     0  0  0.00  0.00   0  00:00.00    0    0    0    0 kintegrityd/0
   21  root     20     2    0 S     0     0  1  0.00  0.00   0  00:00.00    0    0    0    0 kintegrityd/1

More advance options can be found in the official collectl documentation :

How to Setup psacct or acct – Monitor User Activity in Linux

It is very important to know what are the activities for applications and users in linux operating system. This will very useful in later time or in case of problems. For this purpose, i would recommend psacct or acct tools to be install. psacct or acct is a free monitoring program to monitor users and applications activity on linux server. This program will display how long user accessing the server, what command are they issuing, how many processes and display logs for commands. psacct and acct are similar tool, psacct is for RPM based linux but acct is for Debian based.

1. If you are runninng Linux CentOS or Redhat, you should use the following command to install pssacct :

[root@oss ~]# yum install psacct -y

But if you are running debian such as Ubuntu, you should install acct package instead of psacct :

[root@oss ~]# sudo apt-get install acct

2. By default psacct is disabled on Linux. We should manually start it :

[root@oss ~]# /etc/init.d/psacct status
Process accounting is disabled.
[root@oss ~]# /etc/init.d/psacct start
Starting process accounting:                               [  OK  ]

Start acct on Debian :

[root@oss ~]# sudo service acct start

3. The psacct or acct package provides several features for monitoring process activities.

Other usage from that come in psacct or acct package :

ac command prints the statistics of user logins/logouts (connect time) in hours.
lastcomm command prints the information of previously executed commands of user.
accton commands is used to turn on/off process for accounting.
sa command summarizes information of previously executed commands.
last and lastb commands show listing of last logged in users.

4. Total Connect Time :

[root@oss ~]# ac
        total      103.61

5. Display the statistics for total login time :

[root@oss ~]# ac -d
Dec  7  total        4.15
Dec  8  total        0.01
Jul 18  total        0.01
Aug  5  total       13.19
Aug  7  total       39.29
Aug 10  total        3.33
Aug 11  total        6.41
Aug 12  total        1.84
Aug 13  total        0.22
Aug 16  total        3.30
Aug 17  total       16.56
Aug 18  total        1.99
Aug 19  total        2.77
Today   total       10.55

6. Total login statistics of each user :

[root@oss ~]# ac -p
        ehowstuff                            0.76
        root                               103.00
        total      103.76

7. Print the summary of commands that were executed by users :

[root@oss ~]# sa
     135   12652.06re       0.00cp    11052k
      12       3.32re       0.00cp    23715k   ***other*
       2       2.78re       0.00cp    27072k   bash
       2       0.00re       0.00cp    26576k   service
       2   12645.72re       0.00cp        0k   flush-8:0*
      29       0.00re       0.00cp     1018k   ac
      23       0.00re       0.00cp    10197k   bash*
      10       0.00re       0.00cp     9709k   id
       6       0.01re       0.00cp    29328k   crond*
       6       0.00re       0.00cp    25232k   basename
       6       0.00re       0.00cp     1642k   lastcomm
       5       0.01re       0.00cp    25248k   sadc
       5       0.00re       0.00cp      981k   consoletype
       3       0.00re       0.00cp     2076k   hostname
       3       0.00re       0.00cp     1595k   grep
       3       0.00re       0.00cp     1561k   tput
       3       0.00re       0.00cp     1020k   dircolors
       3       0.00re       0.00cp     1017k   tty
       2       0.15re       0.00cp    16992k   sshd*
       2       0.09re       0.00cp    25232k   tail
       2       0.00re       0.00cp    28928k   ls
       2       0.00re       0.00cp    26512k   service*
       2       0.00re       0.00cp    25216k   logger
       2       0.00re       0.00cp     1545k   sa

8. Prints the number of processes and the number of CPU minutes :

[root@oss ~]# sa -m
                                      136   12652.06re       0.00cp    10978k
root                                   94   12650.94re       0.00cp    12223k
ehowstuff                              40       0.97re       0.00cp     7752k
sshd                                    2       0.15re       0.00cp    16992k

9. Use command sa -u to display individual users activity :

[root@oss ~]# sa -u
root       0.00 cpu      981k mem accton
root       0.00 cpu    26288k mem touch
root       0.01 cpu    26576k mem psacct
root       0.00 cpu     1018k mem ac
root       0.00 cpu     1018k mem ac
root       0.00 cpu     1018k mem ac
root       0.00 cpu     1018k mem ac
root       0.00 cpu     1018k mem ac
root       0.00 cpu     1018k mem ac
root       0.00 cpu     1018k mem ac
root       0.00 cpu     1018k mem ac
root       0.00 cpu     1018k mem ac
sshd       0.00 cpu    16992k mem sshd             *
root       0.00 cpu     2604k mem id
root       0.00 cpu     2826k mem bash             *
root       0.00 cpu     2076k mem hostname
root       0.00 cpu     2826k mem bash             *
root       0.00 cpu     1017k mem tty
root       0.00 cpu     1561k mem tput
root       0.00 cpu     2826k mem bash             *
root       0.00 cpu     1020k mem dircolors
root       0.00 cpu     2826k mem bash             *
root       0.00 cpu     1595k mem grep
root       0.00 cpu      981k mem consoletype
root       0.00 cpu    27040k mem bash             *
root       0.00 cpu    26288k mem id
root       0.00 cpu    27040k mem bash             *
ehowstuf   0.00 cpu     2604k mem id
ehowstuf   0.00 cpu     2826k mem bash             *
ehowstuf   0.00 cpu     2076k mem hostname
ehowstuf   0.00 cpu     2826k mem bash             *
ehowstuf   0.00 cpu     2604k mem id
ehowstuf   0.00 cpu     2826k mem bash             *
ehowstuf   0.00 cpu     2604k mem id

10. Printing sort by percentage

The command sa -c will show you the highest percentage of users:

[root@oss ~]# sa -c
     233  100.00%   12652.90re  100.00%       0.00cp  100.00%    16512k
      22    9.44%       3.32re    0.03%       0.00cp   44.44%    19491k   ***other*
       2    0.86%       2.78re    0.02%       0.00cp   22.22%    27072k   bash
       3    1.29%   12646.53re   99.95%       0.00cp   11.11%        0k   flush-8:0*
       2    0.86%       0.00re    0.00%       0.00cp   11.11%    26576k   service
       8    3.43%       0.01re    0.00%       0.00cp    5.56%    25248k   sadc
       2    0.86%       0.00re    0.00%       0.00cp    5.56%    26512k   run-parts
      30   12.88%       0.00re    0.00%       0.00cp    0.00%    26512k   sh
      29   12.45%       0.00re    0.00%       0.00cp    0.00%     1018k   ac
      23    9.87%       0.00re    0.00%       0.00cp    0.00%    10197k   bash*
      17    7.30%       0.00re    0.00%       0.00cp    0.00%    25232k   cat
      12    5.15%       0.02re    0.00%       0.00cp    0.00%    29328k   crond*
      10    4.29%       0.00re    0.00%       0.00cp    0.00%     9709k   id
       8    3.43%       0.00re    0.00%       0.00cp    0.00%    25232k   basename
       7    3.00%       0.00re    0.00%       0.00cp    0.00%    29079k   ls
       6    2.58%       0.00re    0.00%       0.00cp    0.00%     1642k   lastcomm
       6    2.58%       0.00re    0.00%       0.00cp    0.00%     1457k   sa
       5    2.15%       0.00re    0.00%       0.00cp    0.00%      981k   consoletype
       4    1.72%       0.00re    0.00%       0.00cp    0.00%    28064k   find
       4    1.72%       0.00re    0.00%       0.00cp    0.00%    25216k   logger
       3    1.29%       0.00re    0.00%       0.00cp    0.00%    26512k   sh*
       3    1.29%       0.00re    0.00%       0.00cp    0.00%    26304k   date
       3    1.29%       0.00re    0.00%       0.00cp    0.00%     2076k   hostname
       3    1.29%       0.00re    0.00%       0.00cp    0.00%     1595k   grep
       3    1.29%       0.00re    0.00%       0.00cp    0.00%     1561k   tput
       3    1.29%       0.00re    0.00%       0.00cp    0.00%     1020k   dircolors
       3    1.29%       0.00re    0.00%       0.00cp    0.00%     1017k   tty
       2    0.86%       0.15re    0.00%       0.00cp    0.00%    16992k   sshd*
       2    0.86%       0.09re    0.00%       0.00cp    0.00%    25232k   tail
       2    0.86%       0.00re    0.00%       0.00cp    0.00%    26512k   0anacron
       2    0.86%       0.00re    0.00%       0.00cp    0.00%    26480k   awk
       2    0.86%       0.00re    0.00%       0.00cp    0.00%    26512k   service*
       2    0.86%       0.00re    0.00%       0.00cp    0.00%    26512k   run-parts*

11. Display last executed commands :
[root@oss ~]# lastcomm
sa                      root     pts/0      0.00 secs Thu Aug 21 00:16
sa                      ehowstuf pts/2      0.00 secs Thu Aug 21 00:14
sa                      root     pts/0      0.00 secs Thu Aug 21 00:12
crond             SF    root     __         0.00 secs Thu Aug 21 00:10
sadc              S     root     __         0.00 secs Thu Aug 21 00:10
anacron            F    root     __         0.00 secs Thu Aug 21 00:01
crond             SF    root     __         0.00 secs Thu Aug 21 00:01
run-parts               root     __         0.01 secs Thu Aug 21 00:01
logger                  root     __         0.00 secs Thu Aug 21 00:01
basename                root     __         0.00 secs Thu Aug 21 00:01
awk                     root     __         0.00 secs Thu Aug 21 00:01
0anacron                root     __         0.00 secs Thu Aug 21 00:01
anacron                 root     __         0.00 secs Thu Aug 21 00:01
date                    root     __         0.00 secs Thu Aug 21 00:01
cat                     root     __         0.00 secs Thu Aug 21 00:01
logger                  root     __         0.00 secs Thu Aug 21 00:01
basename                root     __         0.00 secs Thu Aug 21 00:01
run-parts          F    root     __         0.00 secs Thu Aug 21 00:01
sh                      nobody   __         0.00 secs Thu Aug 21 00:00
getconf                 nobody   __         0.00 secs Thu Aug 21 00:00
sh                      nobody   __         0.00 secs Thu Aug 21 00:00
uptime                  nobody   __         0.00 secs Thu Aug 21 00:00
sh                      nobody   __         0.00 secs Thu Aug 21 00:00
netstat                 nobody   __         0.00 secs Thu Aug 21 00:00
sh                      nobody   __         0.00 secs Thu Aug 21 00:00
cat                     nobody   __         0.00 secs Thu Aug 21 00:00
sh                      nobody   __         0.00 secs Thu Aug 21 00:00
mount                   nobody   __         0.00 secs Thu Aug 21 00:00
sh                      nobody   __         0.00 secs Thu Aug 21 00:00
df                      nobody   __         0.00 secs Thu Aug 21 00:00
sh                      nobody   __         0.00 secs Thu Aug 21 00:00
ifconfig                nobody   __         0.00 secs Thu Aug 21 00:00
sh                      nobody   __         0.00 secs Thu Aug 21 00:00
cat                     nobody   __         0.00 secs Thu Aug 21 00:00
sh                      nobody   __         0.00 secs Thu Aug 21 00:00
cat                     nobody   __         0.00 secs Thu Aug 21 00:00
sh                      nobody   __         0.00 secs Thu Aug 21 00:00
cat                     nobody   __         0.00 secs Thu Aug 21 00:00
sh                      nobody   __         0.00 secs Thu Aug 21 00:00
cat                     nobody   __         0.00 secs Thu Aug 21 00:00
sh                      nobody   __         0.00 secs Thu Aug 21 00:00
cat                     nobody   __         0.00 secs Thu Aug 21 00:00
sh                      nobody   __         0.00 secs Thu Aug 21 00:00
ls                      nobody   __         0.00 secs Thu Aug 21 00:00
sh                      nobody   __         0.00 secs Thu Aug 21 00:00
ls                      nobody   __         0.00 secs Thu Aug 21 00:00
sh                      nobody   __         0.00 secs Thu Aug 21 00:00
ls                      nobody   __         0.00 secs Thu Aug 21 00:00
sh                      nobody   __         0.00 secs Thu Aug 21 00:00
ls                      nobody   __         0.00 secs Thu Aug 21 00:00
sh                      nobody   __         0.00 secs Thu Aug 21 00:00
ls                      nobody   __         0.00 secs Thu Aug 21 00:00
sh                      nobody   __         0.00 secs Thu Aug 21 00:00
sh                 F    nobody   __         0.00 secs Thu Aug 21 00:00
sh                      nobody   __         0.00 secs Thu Aug 21 00:00
cat                     nobody   __         0.00 secs Thu Aug 21 00:00
sh                      nobody   __         0.00 secs Thu Aug 21 00:00
cat                     nobody   __         0.00 secs Thu Aug 21 00:00
sh                      nobody   __         0.00 secs Thu Aug 21 00:00
cat                     nobody   __         0.00 secs Thu Aug 21 00:00
sh                      nobody   __         0.00 secs Thu Aug 21 00:00
cat                     nobody   __         0.00 secs Thu Aug 21 00:00
sh                      nobody   __         0.00 secs Thu Aug 21 00:00
cat                     nobody   __         0.00 secs Thu Aug 21 00:00
sh                      nobody   __         0.00 secs Thu Aug 21 00:00
cat                     nobody   __         0.00 secs Thu Aug 21 00:00
sh                      nobody   __         0.00 secs Thu Aug 21 00:00
cat                     nobody   __         0.00 secs Thu Aug 21 00:00
sh                      nobody   __         0.00 secs Thu Aug 21 00:00
fdisk                   nobody   __         0.00 secs Thu Aug 21 00:00
sh                      nobody   __         0.00 secs Thu Aug 21 00:00
sh                 F    nobody   __         0.00 secs Thu Aug 21 00:00
sh                      nobody   __         0.00 secs Thu Aug 21 00:00
cat                     nobody   __         0.00 secs Thu Aug 21 00:00
crond             SF    nobody   __         0.00 secs Thu Aug 21 00:00
nmon                    nobody   __         0.00 secs Thu Aug 21 00:00
sh                      nobody   __         0.00 secs Thu Aug 21 00:00
sh                 F    nobody   __         0.00 secs Thu Aug 21 00:00
sh                      nobody   __         0.00 secs Thu Aug 21 00:00
cat                     nobody   __         0.00 secs Thu Aug 21 00:00
xargs                   nobody   __         0.00 secs Thu Aug 21 00:00
rm                      nobody   __         0.00 secs Thu Aug 21 00:00
find                    nobody   __         0.00 secs Thu Aug 21 00:00
crond             SF    root     __         0.00 secs Thu Aug 21 00:00
sadc              S     root     __         0.00 secs Thu Aug 21 00:00
pkill                   nobody   __         0.00 secs Thu Aug 21 00:00
flush-8:0          F    root     __         0.00 secs Wed Aug 20 23:25
crond             SF    root     __         0.00 secs Wed Aug 20 23:53
sa2                     root     __         0.00 secs Wed Aug 20 23:53
rmdir                   root     __         0.00 secs Wed Aug 20 23:53
find                    root     __         0.00 secs Wed Aug 20 23:53
find                    root     __         0.00 secs Wed Aug 20 23:53
find                    root     __         0.00 secs Wed Aug 20 23:53
sar                     root     __         0.02 secs Wed Aug 20 23:53
date                    root     __         0.00 secs Wed Aug 20 23:53
crond             SF    root     __         0.00 secs Wed Aug 20 23:50
sadc              S     root     __         0.01 secs Wed Aug 20 23:50
sa                      root     pts/0      0.00 secs Wed Aug 20 23:47
sa                      root     pts/0      0.00 secs Wed Aug 20 23:45
ac                      root     pts/0      0.00 secs Wed Aug 20 23:44
lastcomm                root     pts/0      0.00 secs Wed Aug 20 23:43
ac                      root     pts/0      0.00 secs Wed Aug 20 23:41
ac                      root     pts/0      0.00 secs Wed Aug 20 23:40
crond             SF    root     __         0.00 secs Wed Aug 20 23:40
sadc              S     root     __         0.00 secs Wed Aug 20 23:40
service                 root     pts/0      0.01 secs Wed Aug 20 23:39
basename                root     pts/0      0.00 secs Wed Aug 20 23:39
basename                root     pts/0      0.00 secs Wed Aug 20 23:39
service            F    root     pts/0      0.00 secs Wed Aug 20 23:39
consoletype             root     pts/0      0.00 secs Wed Aug 20 23:39
service                 root     pts/0      0.01 secs Wed Aug 20 23:39
basename                root     pts/0      0.00 secs Wed Aug 20 23:39
basename                root     pts/0      0.00 secs Wed Aug 20 23:39
service            F    root     pts/0      0.00 secs Wed Aug 20 23:39
consoletype             root     pts/0      0.00 secs Wed Aug 20 23:39
tail                  X root     pts/0      0.00 secs Wed Aug 20 23:39
bash               F    root     pts/0      0.00 secs Wed Aug 20 23:39
ls                      root     pts/0      0.00 secs Wed Aug 20 23:39
lastcomm                root     pts/0      0.00 secs Wed Aug 20 23:39
crond             SF    root     __         0.00 secs Wed Aug 20 23:30
sadc              S     root     __         0.00 secs Wed Aug 20 23:30
lastcomm                root     pts/0      0.00 secs Wed Aug 20 23:27
lastcomm                root     pts/0      0.00 secs Wed Aug 20 23:26
lastcomm                root     pts/0      0.00 secs Wed Aug 20 23:26
flush-8:0          F    root     __         0.00 secs Wed Aug 20 23:19
crond             SF    root     __         0.00 secs Wed Aug 20 23:20
sadc              S     root     __         0.00 secs Wed Aug 20 23:20
flush-8:0          F    root     __         0.02 secs Wed Aug 20 22:50
sa                      root     pts/0      0.00 secs Wed Aug 20 23:13
sa                      root     pts/0      0.00 secs Wed Aug 20 23:13
lastcomm                root     pts/0      0.00 secs Wed Aug 20 23:13
crond             SF    root     __         0.00 secs Wed Aug 20 23:10
sadc              S     root     __         0.00 secs Wed Aug 20 23:10
ac                      root     pts/0      0.00 secs Wed Aug 20 23:06
crond             SF    root     __         0.00 secs Wed Aug 20 23:01
run-parts               root     __         0.00 secs Wed Aug 20 23:01
logger                  root     __         0.00 secs Wed Aug 20 23:01
basename                root     __         0.00 secs Wed Aug 20 23:01
awk                     root     __         0.00 secs Wed Aug 20 23:01
0anacron                root     __         0.00 secs Wed Aug 20 23:01
date                    root     __         0.00 secs Wed Aug 20 23:01
cat                     root     __         0.00 secs Wed Aug 20 23:01
logger                  root     __         0.00 secs Wed Aug 20 23:01
basename                root     __         0.00 secs Wed Aug 20 23:01
run-parts          F    root     __         0.00 secs Wed Aug 20 23:01
crond             SF    root     __         0.00 secs Wed Aug 20 23:00
sadc              S     root     __         0.00 secs Wed Aug 20 23:00
ac                      root     pts/0      0.00 secs Wed Aug 20 22:59
ac                      root     pts/0      0.00 secs Wed Aug 20 22:59
ac                      root     pts/0      0.00 secs Wed Aug 20 22:59
sshd              S     root     __         0.05 secs Wed Aug 20 22:57
bash              S     root     pts/1      0.01 secs Wed Aug 20 22:57
su                S     root     pts/1      0.00 secs Wed Aug 20 22:57
bash              S     ehowstuf pts/1      0.03 secs Wed Aug 20 22:57
ac                      root     pts/0      0.00 secs Wed Aug 20 22:59
ac                      root     pts/0      0.00 secs Wed Aug 20 22:59
ac                      root     pts/0      0.00 secs Wed Aug 20 22:59
bash               F    ehowstuf pts/2      0.00 secs Wed Aug 20 22:59
id                      ehowstuf pts/2      0.00 secs Wed Aug 20 22:59
bash               F    ehowstuf pts/2      0.00 secs Wed Aug 20 22:59
consoletype             ehowstuf pts/2      0.00 secs Wed Aug 20 22:59
grep                    ehowstuf pts/2      0.00 secs Wed Aug 20 22:59
bash               F    ehowstuf pts/2      0.00 secs Wed Aug 20 22:59
dircolors               ehowstuf pts/2      0.00 secs Wed Aug 20 22:59
bash               F    ehowstuf pts/2      0.00 secs Wed Aug 20 22:59
tput                    ehowstuf pts/2      0.00 secs Wed Aug 20 22:59
tty                     ehowstuf pts/2      0.00 secs Wed Aug 20 22:59
bash               F    ehowstuf pts/2      0.00 secs Wed Aug 20 22:59
id                      ehowstuf pts/2      0.00 secs Wed Aug 20 22:59
bash               F    ehowstuf pts/2      0.00 secs Wed Aug 20 22:59
id                      ehowstuf pts/2      0.00 secs Wed Aug 20 22:59
bash               F    ehowstuf pts/2      0.00 secs Wed Aug 20 22:59
hostname                ehowstuf pts/2      0.00 secs Wed Aug 20 22:59
bash               F    ehowstuf pts/2      0.00 secs Wed Aug 20 22:59
id                      ehowstuf pts/2      0.00 secs Wed Aug 20 22:59
sshd              SF    sshd     __         0.00 secs Wed Aug 20 22:59
ac                      root     pts/0      0.00 secs Wed Aug 20 22:58
ac                      root     pts/0      0.00 secs Wed Aug 20 22:58
ac                      ehowstuf pts/1      0.00 secs Wed Aug 20 22:58
ac                      root     pts/0      0.00 secs Wed Aug 20 22:58
ac                      root     pts/0      0.00 secs Wed Aug 20 22:58
ac                      root     pts/0      0.00 secs Wed Aug 20 22:58
mkdir                   ehowstuf pts/1      0.00 secs Wed Aug 20 22:58
ls                      ehowstuf pts/1      0.00 secs Wed Aug 20 22:58
ac                      root     pts/0      0.00 secs Wed Aug 20 22:58
tail                  X root     pts/0      0.00 secs Wed Aug 20 22:58
ac                      root     pts/0      0.00 secs Wed Aug 20 22:58
ac                      root     pts/0      0.00 secs Wed Aug 20 22:58
ac                      root     pts/0      0.00 secs Wed Aug 20 22:58
bash               F    ehowstuf pts/1      0.00 secs Wed Aug 20 22:57
id                      ehowstuf pts/1      0.00 secs Wed Aug 20 22:57
bash               F    ehowstuf pts/1      0.00 secs Wed Aug 20 22:57
consoletype             ehowstuf pts/1      0.00 secs Wed Aug 20 22:57
grep                    ehowstuf pts/1      0.00 secs Wed Aug 20 22:57
bash               F    ehowstuf pts/1      0.00 secs Wed Aug 20 22:57
dircolors               ehowstuf pts/1      0.00 secs Wed Aug 20 22:57
bash               F    ehowstuf pts/1      0.00 secs Wed Aug 20 22:57
tput                    ehowstuf pts/1      0.00 secs Wed Aug 20 22:57
tty                     ehowstuf pts/1      0.00 secs Wed Aug 20 22:57
bash               F    ehowstuf pts/1      0.00 secs Wed Aug 20 22:57
id                      ehowstuf pts/1      0.00 secs Wed Aug 20 22:57
bash               F    ehowstuf pts/1      0.00 secs Wed Aug 20 22:57
id                      ehowstuf pts/1      0.00 secs Wed Aug 20 22:57
bash               F    ehowstuf pts/1      0.00 secs Wed Aug 20 22:57
hostname                ehowstuf pts/1      0.00 secs Wed Aug 20 22:57
bash               F    ehowstuf pts/1      0.00 secs Wed Aug 20 22:57
id                      ehowstuf pts/1      0.00 secs Wed Aug 20 22:57
bash               F    root     pts/1      0.00 secs Wed Aug 20 22:57
id                      root     pts/1      0.00 secs Wed Aug 20 22:57
bash               F    root     pts/1      0.00 secs Wed Aug 20 22:57
consoletype             root     pts/1      0.00 secs Wed Aug 20 22:57
grep                    root     pts/1      0.00 secs Wed Aug 20 22:57
bash               F    root     pts/1      0.00 secs Wed Aug 20 22:57
dircolors               root     pts/1      0.00 secs Wed Aug 20 22:57
bash               F    root     pts/1      0.00 secs Wed Aug 20 22:57
tput                    root     pts/1      0.00 secs Wed Aug 20 22:57
tty                     root     pts/1      0.00 secs Wed Aug 20 22:57
bash               F    root     pts/1      0.00 secs Wed Aug 20 22:57
hostname                root     pts/1      0.00 secs Wed Aug 20 22:57
bash               F    root     pts/1      0.00 secs Wed Aug 20 22:57
id                      root     pts/1      0.00 secs Wed Aug 20 22:57
sshd              SF    sshd     __         0.00 secs Wed Aug 20 22:57
ac                      root     pts/0      0.00 secs Wed Aug 20 22:57
ac                      root     pts/0      0.00 secs Wed Aug 20 22:57
ac                      root     pts/0      0.00 secs Wed Aug 20 22:57
ac                      root     pts/0      0.00 secs Wed Aug 20 22:57
ac                      root     pts/0      0.00 secs Wed Aug 20 22:57
ac                      root     pts/0      0.00 secs Wed Aug 20 22:57
ac                      root     pts/0      0.00 secs Wed Aug 20 22:56
ac                      root     pts/0      0.00 secs Wed Aug 20 22:56
ac                      root     pts/0      0.00 secs Wed Aug 20 22:56
psacct                  root     pts/0      0.01 secs Wed Aug 20 22:55
touch                   root     pts/0      0.00 secs Wed Aug 20 22:55
accton            S     root     pts/0      0.00 secs Wed Aug 20 22:55

12. Search Logs for Commands :

[root@oss ~]# lastcomm grep
grep                    ehowstuf pts/2      0.00 secs Wed Aug 20 22:59
grep                    ehowstuf pts/1      0.00 secs Wed Aug 20 22:57
grep                    root     pts/1      0.00 secs Wed Aug 20 22:57

How to Setup Sar (Sysstat) – Monitor Linux System Performance

Sysstat contains various utilities to collect and historize performance and monitor server activity on the linux. Sar is part of the sysstat package. by using sar, we can collect, report, or save system resource utilization information. It will help system administrator to troubleshoot performance issues, or to optimize performance. This post will show how to setup and the usage of sar on linux CentOS 6.5.

1. Install sar (systat) :

[root@oss ~]# yum install sysstat -y

2. Verify the sar version using “sar -V”

[root@oss ~]# sar -V
sysstat version 9.0.4
(C) Sebastien Godard (sysstat  orange.fr)

3. Sar usage examples :

a) Check swap usage :

[root@oss ~]# sar -W
Linux 2.6.32-431.el6.x86_64 (oss.ehowstuff.local)       08/18/2014      _x86_64_        (2 CPU)

11:10:01 PM  pswpin/s pswpout/s
11:20:01 PM      0.00      0.00
11:30:01 PM      0.00      0.00
11:40:01 PM      0.00      0.00
Average:         0.00      0.00

b) Check system load :

[root@oss ~]# sar -q
Linux 2.6.32-431.el6.x86_64 (oss.ehowstuff.local)       08/18/2014      _x86_64_        (2 CPU)

11:10:01 PM   runq-sz  plist-sz   ldavg-1   ldavg-5  ldavg-15
11:20:01 PM         0        86      0.00      0.00      0.00
11:30:01 PM         0        85      0.00      0.00      0.00
11:40:01 PM         0        85      0.00      0.00      0.00
Average:            0        85      0.00      0.00      0.00

c) Collect CPU statistics 3 times within 1 second interval :

[root@oss ~]# sar 1 3
Linux 2.6.32-431.el6.x86_64 (oss.ehowstuff.local)       08/18/2014      _x86_64_        (2 CPU)

11:46:55 PM     CPU     %user     %nice   %system   %iowait    %steal     %idle
11:46:56 PM     all      0.00      0.00      0.50      0.00      0.00     99.50
11:46:57 PM     all      0.00      0.00      0.00      0.00      0.00    100.00
11:46:58 PM     all      0.00      0.00      0.00      0.00      0.00    100.00
Average:        all      0.00      0.00      0.17      0.00      0.00     99.83

d) Displaying the RAM Load:

[root@oss ~]# sar -r
Linux 2.6.32-431.el6.x86_64 (oss.ehowstuff.local)       08/18/2014      _x86_64_        (2 CPU)

11:10:01 PM kbmemfree kbmemused  %memused kbbuffers  kbcached  kbcommit   %commit
11:20:01 PM   3670608    254080      6.47     11872    160172     67684      1.12
11:30:01 PM   3670616    254072      6.47     11892    160172     67684      1.12
11:40:01 PM   3670508    254180      6.48     11920    160180     67684      1.12
Average:      3670577    254111      6.47     11895    160175     67684      1.12

e) Display paging statistic :

[root@oss ~]# sar -B
Linux 2.6.32-431.el6.x86_64 (oss.ehowstuff.local)       08/18/2014      _x86_64_        (2 CPU)

11:10:01 PM  pgpgin/s pgpgout/s   fault/s  majflt/s  pgfree/s pgscank/s pgscand/s pgsteal/s    %vmeff
11:20:01 PM      0.00      0.23      8.21      0.00      4.36      0.00      0.00      0.00      0.00
11:30:01 PM      0.00      0.19      2.70      0.00      1.29      0.00      0.00      0.00      0.00
11:40:01 PM      0.00      0.14      3.75      0.00      1.62      0.00      0.00      0.00      0.00
11:50:01 PM      0.00      0.16      6.60      0.00      2.80      0.00      0.00      0.00      0.00
Average:         0.00      0.18      5.31      0.00      2.52      0.00      0.00      0.00      0.00

f) Display Swap space utilization statistics :

[root@oss ~]# sar -S
Linux 2.6.32-431.el6.x86_64 (oss.ehowstuff.local)       08/18/2014      _x86_64_        (2 CPU)

11:10:01 PM kbswpfree kbswpused  %swpused  kbswpcad   %swpcad
11:20:01 PM   2097144         0      0.00         0      0.00
11:30:01 PM   2097144         0      0.00         0      0.00
11:40:01 PM   2097144         0      0.00         0      0.00
11:50:01 PM   2097144         0      0.00         0      0.00
Average:      2097144         0      0.00         0      0.00

4. Monitor previous day sar statictics :

Every sar statictics by default stored in /var/log/sa. Es example :

[root@oss sa]# ls
sa18  sa19  sa20  sa21  sa22  sa23  sa24  sar18  sar19  sar20  sar23

a. Display cpu load on sa22 :

[root@oss sa]# sar -f /var/log/sa/sa22
Linux 2.6.32-431.el6.x86_64 (oss.ehowstuff.local)       08/22/2014      _x86_64_        (2 CPU)

12:00:01 AM     CPU     %user     %nice   %system   %iowait    %steal     %idle
12:10:01 AM     all      0.04      0.00      0.06      0.06      0.00     99.84
12:20:01 AM     all      0.03      0.00      0.05      0.07      0.00     99.85
12:30:01 AM     all      0.03      0.00      0.05      0.02      0.00     99.90
12:40:01 AM     all      0.34      0.00      0.71      0.02      0.00     98.93
12:50:01 AM     all      1.67      0.00      3.19      0.01      0.00     95.13
01:00:01 AM     all      0.64      0.00      0.83      0.74      0.00     97.79
01:10:01 AM     all      0.64      0.00      1.51      0.03      0.00     97.83
01:20:01 AM     all      0.35      0.00      0.71      0.13      0.00     98.81
01:30:01 AM     all      0.03      0.00      0.05      0.02      0.00     99.90
01:40:01 AM     all      0.03      0.00      0.05      0.02      0.00     99.90
01:50:01 AM     all      0.03      0.00      0.05      0.02      0.00     99.91
02:00:01 AM     all      0.03      0.00      0.05      0.02      0.00     99.90
02:10:01 AM     all      0.03      0.00      0.05      0.02      0.00     99.90
02:20:01 AM     all      0.03      0.00      0.04      0.02      0.00     99.91
02:30:01 AM     all      0.03      0.00      0.04      0.02      0.00     99.91
02:40:01 AM     all      0.03      0.00      0.04      0.02      0.00     99.91
02:50:01 AM     all      0.03      0.00      0.04      0.01      0.00     99.92
03:00:01 AM     all      0.03      0.00      0.04      0.02      0.00     99.92
03:10:01 AM     all      0.03      0.00      0.04      0.02      0.00     99.91
03:20:01 AM     all      0.03      0.00      0.04      0.01      0.00     99.92
03:30:01 AM     all      0.03      0.00      0.04      0.01      0.00     99.92
03:40:01 AM     all      0.03      0.00      0.05      0.02      0.00     99.91
03:50:01 AM     all      0.03      0.00      0.05      0.03      0.00     99.89
04:00:01 AM     all      0.03      0.00      0.04      0.02      0.00     99.91
04:10:01 AM     all      0.03      0.00      0.04      0.02      0.00     99.91
04:20:01 AM     all      0.03      0.00      0.04      0.02      0.00     99.92
04:30:01 AM     all      0.03      0.00      0.04      0.02      0.00     99.91
04:40:01 AM     all      0.03      0.00      0.04      0.02      0.00     99.91
04:50:01 AM     all      0.03      0.00      0.04      0.02      0.00     99.91
05:00:01 AM     all      0.03      0.00      0.04      0.02      0.00     99.92
05:10:01 AM     all      0.03      0.00      0.05      0.02      0.00     99.90
05:20:01 AM     all      0.03      0.00      0.05      0.02      0.00     99.91
05:30:01 AM     all      0.03      0.00      0.04      0.02      0.00     99.91

05:30:01 AM     CPU     %user     %nice   %system   %iowait    %steal     %idle
05:40:01 AM     all      0.03      0.00      0.05      0.01      0.00     99.91
05:50:01 AM     all      0.03      0.00      0.05      0.01      0.00     99.91
06:00:01 AM     all      0.03      0.00      0.05      0.02      0.00     99.91
06:10:01 AM     all      0.03      0.00      0.05      0.01      0.00     99.90
06:20:01 AM     all      0.03      0.00      0.05      0.01      0.00     99.91
06:30:01 AM     all      0.03      0.00      0.05      0.01      0.00     99.91
06:40:02 AM     all      0.03      0.00      0.05      0.01      0.00     99.92
06:50:01 AM     all      0.03      0.00      0.04      0.01      0.00     99.92
07:00:01 AM     all      0.03      0.00      0.05      0.01      0.00     99.91
07:10:01 AM     all      0.03      0.00      0.05      0.01      0.00     99.91
07:20:01 AM     all      0.03      0.00      0.05      0.01      0.00     99.92
07:30:01 AM     all      0.03      0.00      0.04      0.01      0.00     99.92
07:40:01 AM     all      0.03      0.00      0.05      0.01      0.00     99.91
07:50:01 AM     all      0.03      0.00      0.05      0.01      0.00     99.91
08:00:01 AM     all      0.03      0.00      0.05      0.01      0.00     99.91
08:10:01 AM     all      0.03      0.00      0.05      0.02      0.00     99.90
08:20:01 AM     all      0.03      0.00      0.05      0.01      0.00     99.91
Average:        all      0.10      0.00      0.18      0.03      0.00     99.69

b. Display RAM Load on sa22 :

[root@oss sa]# sar -f /var/log/sa/sa22 -r
Linux 2.6.32-431.el6.x86_64 (oss.ehowstuff.local)       08/22/2014      _x86_64_        (2 CPU)

12:00:01 AM kbmemfree kbmemused  %memused kbbuffers  kbcached  kbcommit   %commit
12:10:01 AM   3807336    117352      2.99      8252     32352     66920      1.11
12:20:01 AM   3804708    119980      3.06      8712     32812     71440      1.19
12:30:01 AM   3804584    120104      3.06      8744     32816     71592      1.19
12:40:01 AM   3799784    124904      3.18      8768     33124     72228      1.20
12:50:01 AM   3799668    125020      3.19      8800     33124     72228      1.20
01:00:01 AM   3723612    201076      5.12     10048    110608     71592      1.19
01:10:01 AM   3718804    205884      5.25     10232    111044     72228      1.20
01:20:01 AM   3711560    213128      5.43     10284    122396     71592      1.19
01:30:01 AM   3711684    213004      5.43     10324    122408     71592      1.19
01:40:01 AM   3711436    213252      5.43     10348    122408     71592      1.19
01:50:01 AM   3711436    213252      5.43     10372    122412     71592      1.19
02:00:01 AM   3711560    213128      5.43     10404    122416     71592      1.19
02:10:01 AM   3711576    213112      5.43     10444    122424     71592      1.19
02:20:01 AM   3711568    213120      5.43     10476    122428     71592      1.19
02:30:01 AM   3711444    213244      5.43     10516    122436     71592      1.19
02:40:01 AM   3711320    213368      5.44     10552    122436     71592      1.19
02:50:01 AM   3711320    213368      5.44     10580    122444     71592      1.19
03:00:01 AM   3711188    213500      5.44     10612    122448     71592      1.19
03:10:01 AM   3711180    213508      5.44     10652    122456     72168      1.20
03:20:01 AM   3711180    213508      5.44     10676    122456     72168      1.20
03:30:01 AM   3710932    213756      5.45     10708    122464     72168      1.20
03:40:01 AM   3710692    213996      5.45     10740    122464     72168      1.20
03:50:01 AM   3710700    213988      5.45     10928    122604     71592      1.19
04:00:01 AM   3710568    214120      5.46     10960    122608     71592      1.19
04:10:01 AM   3710816    213872      5.45     11000    122608     71592      1.19
04:20:01 AM   3710576    214112      5.46     11032    122616     71592      1.19
04:30:01 AM   3710576    214112      5.46     11068    122616     71592      1.19
04:40:01 AM   3710708    213980      5.45     11096    122624     71592      1.19
04:50:01 AM   3710452    214236      5.46     11128    122628     71592      1.19
05:00:01 AM   3710576    214112      5.46     11160    122636     71592      1.19
05:10:01 AM   3710452    214236      5.46     11200    122636     71592      1.19
05:20:01 AM   3710576    214112      5.46     11232    122644     71592      1.19
05:30:01 AM   3710708    213980      5.45     11268    122644     71592      1.19

05:30:01 AM kbmemfree kbmemused  %memused kbbuffers  kbcached  kbcommit   %commit
05:40:01 AM   3710320    214368      5.46     11296    122652     71592      1.19
05:50:01 AM   3710072    214616      5.47     11320    122652     71592      1.19
06:00:01 AM   3710204    214484      5.46     11364    122660     71592      1.19
06:10:01 AM   3710072    214616      5.47     11400    122664     71592      1.19
06:20:01 AM   3710204    214484      5.46     11424    122668     71592      1.19
06:30:01 AM   3710204    214484      5.46     11464    122676     71592      1.19
06:40:02 AM   3709948    214740      5.47     11488    122680     71592      1.19
06:50:01 AM   3710072    214616      5.47     11512    122680     71592      1.19
07:00:01 AM   3710204    214484      5.46     11552    122680     71592      1.19
07:10:01 AM   3709824    214864      5.47     11584    122692     71592      1.19
07:20:01 AM   3709948    214740      5.47     11612    122688     71592      1.19
07:30:01 AM   3709956    214732      5.47     11648    122700     71592      1.19
07:40:01 AM   3709956    214732      5.47     11680    122704     71592      1.19
07:50:01 AM   3709824    214864      5.47     11704    122708     71592      1.19
08:00:01 AM   3709832    214856      5.47     11744    122712     71592      1.19
08:10:01 AM   3709700    214988      5.48     11784    122724     71592      1.19
08:20:01 AM   3709700    214988      5.48     11812    122720     71592      1.19
Average:      3720306    204382      5.21     10794    113138     71580      1.19

5. Other sar options :

[root@oss ~]# sar -h
Usage: sar [ options ] [  [  ] ]
Main options and reports:
        -b      I/O and transfer rate statistics
        -B      Paging statistics
        -d      Block device statistics
        -I {  | SUM | ALL | XALL }
                Interrupts statistics
        -m      Power management statistics
        -n {  [,...] | ALL }
                Network statistics
                Keywords are:
                DEV     Network interfaces
                EDEV    Network interfaces (errors)
                NFS     NFS client
                NFSD    NFS server
                SOCK    Sockets (v4)
                IP      IP traffic      (v4)
                EIP     IP traffic      (v4) (errors)
                ICMP    ICMP traffic    (v4)
                EICMP   ICMP traffic    (v4) (errors)
                TCP     TCP traffic     (v4)
                ETCP    TCP traffic     (v4) (errors)
                UDP     UDP traffic     (v4)
                SOCK6   Sockets (v6)
                IP6     IP traffic      (v6)
                EIP6    IP traffic      (v6) (errors)
                ICMP6   ICMP traffic    (v6)
                EICMP6  ICMP traffic    (v6) (errors)
                UDP6    UDP traffic     (v6)
        -q      Queue length and load average statistics
        -r      Memory utilization statistics
        -R      Memory statistics
        -S      Swap space utilization statistics
        -u [ ALL ]
                CPU utilization statistics
        -v      Kernel table statistics
        -w      Task creation and system switching statistics
        -W      Swapping statistics
        -y      TTY device statistics

6. Other sysstat utilities:

sar collects and displays ALL system activities statistics.
sadc stands for “system activity data collector”. This is the sar backend tool that does the data collection.
sa1 stores system activities in binary data file. sa1 depends on sadc for this purpose. sa1 runs from cron.
sa2 creates daily summary of the collected statistics. sa2 runs from cron.
sadf can generate sar report in CSV, XML, and various other formats. Use this to integrate sar data with other tools.
iostat generates CPU, I/O statistics
mpstat displays CPU statistics.
pidstat reports statistics based on the process id (PID)
nfsiostat displays NFS I/O statistics.
cifsiostat generates CIFS statistics.

How to Setup nmon – Monitor Linux Performance

Nmon (Nigel’s Monitor) is a great performance monitoring tool for Linux operating system.

It was written initially for AIX to monitor system performance. nmon for Linux can be used to collect informations on CPU, memory, network, disk I/O, top processes etc.

System administrator can use nmon as a tuner or benchmark tool that will provide performance information in one go.

It can output the data on the screen or can be save the data into a comma separated file for analysis and longer term data capture.

Steps to setup nmon on linux operating system.

1. How to Add the RPMforge Repository on CentOS 6/RHEL 6 Linux Server

2. Rum yum command to install nmon :

# yum install nmon -y

3. Example of nmon command usage :

Type command :

# nmon

Sample output :
setup nmon

nmon keyboard shortcuts

q – To stop and exit nmon.
h – To see quick help (hint) screen and press h again to remove the hints.
Use the following command to turn on or off stats:
c – See cpu stats.
m – See memory stats.
d – See disk stats.
k – See kernel stats.
n – See network stats.
N – See NFS stats.
j – See file system stats.
t – See top process.
V – See virtual memory stats.
. – See only busy disks/procs.
v – Verbose mode (display as Ok/warning/danger on screen).

Sample outputs :
setup nmon

4. If you prefer to run nmon as a daemon in the background, run the below command, nmon will complete the data file collection and it will save in a file *.nmon file such as oss_140817_2359.nmon with the details of the command as below :

# nmon -f -s2 -c 30
-f : Start data collect mode and output in spreadsheet format.
-s 2 : Wait between 2 seconds or capture data every 2 seconds.
-c30 : Total number of refreshes (30).

How to Setup Monitorix – Network and System Monitoring Tool for Linux

Monitorix is an open source and lightweight system monitoring tool designed to monitor network and system resources in linux/UNIX operating system. Monitorix can collects network and system performce and also resources and then display the informations into graphs. it will help system adn network administrator to detect abnormal activities and detecting bottlenecks. This post will show to setup Monitorix on linux centOS 6.5.

1. Prepare additional repository (EPEL repository).
2. Install required packages :

[root@oss ~]# yum install rrdtool rrdtool-perl perl-libwww-perl perl-MailTools perl-MIME-Lite perl-CGI perl-DBI perl-XML-Simple perl-Config-General perl-HTTP-Server-Simple perl-IO-Socket-SSL -y

3. Install monitorix package :

[root@oss ~]# yum install monitorix -y

Once succesfully installed, please take a look into the configuration file /etc/monitorix.conf to fit your system and enable or disable graphs.

4. Start Monitorix with below command :

[root@oss ~]# service monitorix start

Once started, Monitorix will start gathering the system information based on the configuration set in monitorix.conf file:

5. After a few minutes you should be able to see graph from your browser :

http://IP-Address:8080/monitorix/

install-monitorx-1

install-monitorx-2

install-monitorx-3

How to Check Linux System Reboot Date and Time

Question : How to check when was my linux system last rebooted and how long was the system running ?

Answer : The are several command to check last system rebooted.

1. Check last rebooted using “who -b” command :

[root@server ~]# who -b
         system boot  2014-08-16 09:34

2. Check last rebooted using “last reboot” command :

[root@server ~]# last reboot
reboot   system boot  2.6.32-431.el6.x Sat Aug 16 09:34 - 01:11  (15:36)
reboot   system boot  2.6.32-431.el6.x Tue Aug 12 19:39 - 00:13  (04:33)
reboot   system boot  2.6.32-431.el6.x Mon Aug 11 23:08 - 23:59  (00:50)
reboot   system boot  2.6.32-431.el6.x Tue Aug  5 11:47 - 05:41 (5+17:54)
reboot   system boot  2.6.32-431.el6.x Tue Aug  5 09:03 - 11:18  (02:15)
reboot   system boot  2.6.32-431.el6.x Tue Aug  5 08:58 - 09:03  (00:04)
reboot   system boot  2.6.32-431.el6.x Fri Jul 18 00:47 - 00:51  (00:04)
reboot   system boot  2.6.32-431.el6.x Sun Dec  8 11:22 - 11:23  (00:01)
reboot   system boot  2.6.32-431.el6.x Sun Dec  8 10:28 - 10:30  (00:01)
reboot   system boot  2.6.32-431.el6.x Sat Dec  7 21:54 - 22:40  (00:46)
reboot   system boot  2.6.32-431.el6.x Sat Dec  7 19:46 - 21:54  (02:08)

wtmp begins Sat Dec  7 19:46:12 2013

3. Check how long was the system running using “uptime” command :

[root@server ~]# uptime
 01:13:34 up 15:38,  1 user,  load average: 0.04, 0.08, 0.04

Use uptime command to deduce last reboot time. The uptime command will show the current time and how long the system was running.

How to Install Zabbix 2.2 Server on CentOS 6.5

ZABBIX is an enterprise-class open source monitoring solution designed to monitor servers and various network services. Zabbix will perform simple checks can verify the availability and responsiveness of standard services. It was created by Alexei Vladishev. Follow this step to install zabbix 2.2 server on CentOS 6.5 :

1. Install httpd, php and MySQL :

[root@oss ~]# yum install php php-cli php-common php-devel php-pear php-gd php-mbstring php-mysql php-xml httpd httpd-devel mysql mysql-server -y

2. Zabbix package files are available at repo.zabbix.com :

[root@oss ~]# wget http://repo.zabbix.com/zabbix/2.2/rhel/6/x86_64/zabbix-release-2.2-1.el6.noarch.rpm
--2014-08-12 22:19:07--  http://repo.zabbix.com/zabbix/2.2/rhel/6/x86_64/zabbix-release-2.2-1.el6.noarch.rpm
Resolving repo.zabbix.com... 87.110.183.174
Connecting to repo.zabbix.com|87.110.183.174|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 11256 (11K) [application/x-redhat-package-manager]
Saving to: âzabbix-release-2.2-1.el6.noarch.rpmâ

100%[==========================================================>] 11,256      7.09K/s   in 1.6s

2014-08-12 22:19:09 (7.09 KB/s) - âzabbix-release-2.2-1.el6.noarch.rpmâ
[root@oss ~]# ls
anaconda-ks.cfg  install.log  install.log.syslog  zabbix-release-2.2-1.el6.noarch.rpm
[root@oss ~]# rpm -Uvh zabbix-release-2.2-1.el6.noarch.rpm
warning: zabbix-release-2.2-1.el6.noarch.rpm: Header V4 DSA/SHA1 Signature, key ID 79ea5ed4: NOKEY
Preparing...                ########################################### [100%]
   1:zabbix-release         ########################################### [100%]

3. Install Zabbix server :

[root@oss ~]# yum install zabbix-agent zabbix-web-mysql zabbix-server-mysql zabbix-java-gateway -y

4. Editing PHP configuration for Zabbix frontend

Apache configuration file for Zabbix frontend is located in /etc/httpd/conf.d/zabbix.conf. Some PHP settings are already configured.

    php_value max_execution_time 300
    php_value memory_limit 128M
    php_value post_max_size 16M
    php_value upload_max_filesize 2M
    php_value max_input_time 300
    php_value date.timezone Asia/Kuala_Lumpur

5. Restart zabbix and make zabbix start at boot :

[root@oss ~]# service zabbix-server start
Starting Zabbix server:                                    [  OK  ]
[root@oss ~]# chkconfig zabbix-server on

6. Setup Zabbix database :

mysql> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)

mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'password';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit

7. Import initial schema and data :

[root@oss ~]# cd /usr/share/doc/zabbix-server-mysql-2.2.5/create

[root@oss create]# mysql -u zabbix -p zabbix < schema.sql
Enter password:
[root@oss create]# mysql -u zabbix -p zabbix < images.sql
Enter password:
[root@oss create]# mysql -u zabbix -p zabbix < data.sql
Enter password:

8. Start zabbix installation wizard :

http://192.168.0.8/zabbix/setup.php
setup zabbix-1

setup zabbix-2

setup zabbix-3

setup zabbix-4

setup zabbix-5

setup zabbix-6

9. If the configuration file is not writable, manually edit database configuration in zabbix_server.conf as below :

# vi /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=password

10. Open required port at iptables :

[root@oss ~]# netstat -plunt | grep LISTEN
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1124/sshd
tcp        0      0 0.0.0.0:10051               0.0.0.0:*                   LISTEN      4190/zabbix_server
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      4074/mysqld
tcp        0      0 :::80                       :::*                        LISTEN      1417/httpd
tcp        0      0 :::22                       :::*                        LISTEN      1124/sshd
tcp        0      0 :::10051                    :::*                        LISTEN      4190/zabbix_server
[root@oss ~]# vi /etc/sysconfig/iptables
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 10051 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

Restart iptables :

[root@oss ~]# service iptables restart

11. Zabbix frontend is available at http://IP-address/zabbix in the browser.

The default username/password is Admin/zabbix.

setup zabbix-7

Zabbix server setup completed. You can start to setup zabbix agent now.

How to Secure MySQL Server on CentOS 6.5 / CentOS 6.6

MySQL is the world’s most popular open source database and its the world’s second most widely used open-source relational database management system (RDBMS). MySQL default installation is not securely configured. For the sake of security, we need to run mysql_secure_installation wizard manually in order to perform basic MYSQL hardening on Virtual private server (VPS). The following steps has been tested on MySQL Community Server 5.5.39 that was running on CentOS 6.5 and CentOS 6.6.

1. Run mysql_secure_installation wizard :

[root@vps ]# mysql_secure_installation




NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!


In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
 ... Success!

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...



All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

2. Set “bind-address” parameter within the “[mysqld]” section in /etc/my.conf. Configure this to your VPS local loopback network device, which is “127.0.0.1”. please make sure that you only perform this step if you confirm no other server will need to access the database on your VPS.

[root@vps ~]# vi /etc/my.cnf
[mysqld]
..
bind-address = 127.0.0.1
..

3. Restart your mysqld server :

[root@vps ~]# service mysqld restart

4. Verify the mysqld port listen to 127.0.0.1 only :

[root@vps ~]# netstat -plunt | grep 3306
tcp        0      0 127.0.0.1:3306              0.0.0.0:*                   LISTEN      8224/mysqld

How to Enable EPEL and Remi Repository into CentOS 6

EPEL stand for Extra Packages for Enterprise Linux. EPEL repository is a Fedora Special Interest Group that creates, maintains, and manages a high quality set of additional packages for Enterprise Linux, including, but not limited to, Red Hat Enterprise Linux (RHEL), CentOS and Scientific Linux (SL), Oracle Enterprise Linux(OEL). Remi repository is a yum repository maintained by a French dude – Remi Collet. This post describe the basic steps to prepare and install the additional CentOS packages with EPEL and Remi Repository into CentOS 6.

EPEL Repository

rpm --import https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6
rpm -Uvh https://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

Remi Repository

rpm --import http://rpms.famillecollet.com/RPM-GPG-KEY-remi
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

Example :

[root@centos6 ~]# rpm --import https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6
[root@centos6 ~]# rpm -Uvh https://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
Retrieving https://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
Preparing...                ########################################### [100%]
   1:epel-release           ########################################### [100%]
[root@centos6 ~]# rpm --import http://rpms.famillecollet.com/RPM-GPG-KEY-remi
[root@centos6 ~]# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
Retrieving http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
Preparing...                ########################################### [100%]
   1:remi-release           ########################################### [100%]

Example of EPEl and Remi repo usage :

[root@centos6 ~]# yum --enablerepo=epel install httpd -y
[root@centos6 ~]# yum --enablerepo=remi install httpd -y

How to Install Sendmail Service on CentOS 6.5

This post will show how to install sendmail smtp service on CentOS 6.5. By default only postfix smtp service included in CentOS 6.5. Due to some reasons you will to run sendmail service instead of postfix. But the purpose of both services still the same providing SMTP email transport service and running as an email relay on your linux system.

1. Install sendmail :

[root@centos6.5 ~]# yum install sendmail -y
..
..
..
..
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package sendmail.x86_64 0:8.14.4-8.el6 will be installed
--> Processing Dependency: procmail for package: sendmail-8.14.4-8.el6.x86_64
--> Processing Dependency: libhesiod.so.0()(64bit) for package: sendmail-8.14.4-8.el6.x86_64
--> Running transaction check
---> Package hesiod.x86_64 0:3.1.0-19.el6 will be installed
---> Package procmail.x86_64 0:3.22-25.1.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================
 Package                Arch                 Version                       Repository          Size
====================================================================================================
Installing:
 sendmail               x86_64               8.14.4-8.el6                  base               717 k
Installing for dependencies:
 hesiod                 x86_64               3.1.0-19.el6                  base                20 k
 procmail               x86_64               3.22-25.1.el6                 base               163 k

Transaction Summary
====================================================================================================
Install       3 Package(s)

Total download size: 900 k
Installed size: 1.9 M
Downloading Packages:
(1/3): hesiod-3.1.0-19.el6.x86_64.rpm                                        |  20 kB     00:00
(2/3): procmail-3.22-25.1.el6.x86_64.rpm                                     | 163 kB     00:00
(3/3): sendmail-8.14.4-8.el6.x86_64.rpm                                      | 717 kB     00:06
----------------------------------------------------------------------------------------------------
Total                                                               117 kB/s | 900 kB     00:07
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : procmail-3.22-25.1.el6.x86_64                                                    1/3
  Installing : hesiod-3.1.0-19.el6.x86_64                                                       2/3
  Installing : sendmail-8.14.4-8.el6.x86_64                                                     3/3
  Verifying  : hesiod-3.1.0-19.el6.x86_64                                                       1/3
  Verifying  : procmail-3.22-25.1.el6.x86_64                                                    2/3
  Verifying  : sendmail-8.14.4-8.el6.x86_64                                                     3/3

Installed:
  sendmail.x86_64 0:8.14.4-8.el6

Dependency Installed:
  hesiod.x86_64 0:3.1.0-19.el6                    procmail.x86_64 0:3.22-25.1.el6

Complete!

2. Start Sendmail service :

[root@centos6.5 ~]# service sendmail start
Starting sendmail:                                         [  OK  ]
Starting sm-client:                                        [  OK  ]

3. Test sendmail respond on port 25 :

[root@centos6.5 ~]# telnet localhost 25
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 centos6.5.ehowstuff.local ESMTP Sendmail 8.14.4/8.14.4; Sun, 10 Aug 2014 20:48:52 +0800

Red Hat to ditch MySQL for MariaDB in RHEL 7

In a surprise move, Red Hat has announced that version 7 of Red Hat Enterprise Linux (RHEL) will ship with the MariaDB database installed by default, in place of MySQL.

The announcement was made at the company’s Red Hat Summit, which wrapped up in Boston on Friday.

MariaDB is a fork of MySQL that was launched in 2009 by original MySQL coder Ulf Michael “Monty” Widenius. It’s meant to be a drop-in replacement, meaning any application that runs on MySQL should run unmodified on the MariaDB server. MariaDB does have one important characteristic that MySQL doesn’t share, however: MariaDB isn’t owned by Oracle.

Oracle acquired MySQL as part of its 2009 purchase of Sun Microsystems and almost immediately began tightening the reins, much to the consternation of MySQL’s fans. Support options were cut, and Oracle shifted to an “open core” development model in which the open source database server is sold alongside expensive, proprietary add-ons.

Widenius founded MariaDB largely as a reaction against these unwanted changes, and the project has steadily been gaining converts among the MySQL user community.

A number of popular community-driven Linux distributions have already begun shipping MariaDB in place of MySQL by default, including Arch Linux, OpenSuse, and Slackware. But for RHEL to do so is quite a coup indeed, and somewhat unexpected.

In May, the Fedora Project shipped a beta of Fedora 19 with MariaDB installed by default. But although Fedora is technically the upstream distribution for RHEL, and RHEL 7 will be based on Fedora 19, the actual software bundles that ship with the two distributions often differ significantly.

What’s more, last week Red Hat shipped the first beta of Red Hat Software Collections, an officially supported bundle of databases and programming languages for RHEL. But while that offering includes MariaDB, it also comes with MySQL and PostgreSQL, and Red Hat offers no preference among the three.

There is at least one good reason why Red Hat might be itching to move away from MySQL, though – namely, that there’s no love lost between Red Hat and Oracle, particularly since the database giant began offering Oracle Linux, a clone of the RHEL code base that lets Oracle keep all the money.

At Red Hat Summit, senior engineering manager Radek Vokál said that Red Hat also expected it would be easier to contribute certain patches and features to MariaDB than to MySQL. Apparently, Oracle has not been particularly amenable.

Vokál said that “some versions” of RHEL 7 will still ship with MySQL, but that MariaDB would be “the main thing” from now on.

The Reg reached out to Red Hat for further clarification, but a spokesperson did not respond by the time we pushed the big, red “Publish” button.

RHEL 7 is expected to ship with MariaDB sometime in the second half of 2013.

Click here for full Story