Wednesday, 2 November 2016

10 steps to Upgrade CentOS from 6.6 to 6.8

Steps to Upgrade CentOS from 6.6 to 6.8

Step 1: 
          # Log on to the server

Step 2:
          # Take the required backup like DB backup,scripts etc.

Step 3:
          # verfiy the current version
               $ cat /etc/issue
                    CentOS release 6.6 (Final)
                    Kernel \r on an \m
              $ cat /etc/redhat-release
                   CentOS release 6.6 (Final)

Step 4:
          # Verify the current kernal version
               $ uname -a
                    Linux xxx 2.6.32-504.el6.x86_64 #1 SMP Wed Oct 15 04:27:16 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

Step 5: 
          # check for the updates and do clean
                $ yum check-update
                $ yum list updates
                $ yum clean all

Step 6:
          # Do the required package upgrade
                $ yum update glibc* yum* rpm* python*

Step 7:
          # Now Upgrade from 6.6 to 6.8 
               $ yum update
                   The above command will update all the yum files and along with kernel file.
Installed:
  kernel.x86_64 0:2.6.32-642.4.2.el6                                                                                                                                         
Complete!

Step 8:
          # Reboot the machine
          Once the upgrade completed,do the reboot
               $ sudo reboot

Step 9:
          # Verify the upgrade by checking the OS version
                $ cat /etc/issue
                     CentOS release 6.8 (Final)
                     Kernel \r on an \m

Step 10:
          # verify the kernel version
                $ uname -r
                     2.6.32-642.4.2.el6.x86_64

You can verify the centos kernel version in below link
https://access.redhat.com/articles/3078

Now you have successfully upgraded centos 6.6 to 6.8

Installation and Basic Docker commands on ubuntu

Installation and Basic Docker commands on ubuntu

What is Docker?

     Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and ship it all out as one package. By doing so, thanks to the container, the developer can rest assured that the application will run on any other Linux machine regardless of any customized settings that machine might have that could differ from the machine used for writing and testing the code.

In a way, Docker is a bit like a virtual machine. But unlike a virtual machine, rather than creating a whole virtual operating system, Docker allows applications to use the same Linux kernel as the system that they're running on and only requires applications be shipped with things not already running on the host computer. This gives a significant performance boost and reduces the size of the application.

And importantly, Docker is open source. This means that anyone can contribute to Docker and extend it to meet their own needs if they need additional features that aren't available out of the box.


Docker Installation Step

# sudo apt-get install -y docker.io

Reading package lists... Done
Building dependency tree    
Reading state information... Done
The following packages were automatically installed and are no longer required:
  account-plugin-windows-live imagemagick-common libfftw3-double3 libilmbase6
  liblqr-1-0 libmagickcore5 libmagickcore5-extra libmagickwand5 libnetpbm10
  libopenexr6 libsdl-image1.2 libserf-1-1 libsvn1 libupstart1 nagios-images
  netpbm
Use 'apt-get autoremove' to remove them.
Suggested packages:
  btrfs-tools debootstrap lxc rinse
The following packages will be REMOVED:
  docker-engine
The following NEW packages will be installed:
  docker.io
0 upgraded, 1 newly installed, 1 to remove and 298 not upgraded.
Need to get 4,749 kB of archives.
After this operation, 72.1 MB disk space will be freed.
Get:1 http://in.archive.ubuntu.com/ubuntu/ trusty-updates/universe docker.io amd64 1.6.2~dfsg1-1ubuntu4~14.04.1 [4,749 kB]
6% [1 docker.io 270 kB/4,749 kB 6%]                                          
Get:2 http://in.archive.ubuntu.com/ubuntu/ trusty-updates/universe docker.io amd64 1.6.2~dfsg1-1ubuntu4~14.04.1 [4,749 kB]
Fetched 4,478 kB in 2min 9s (34.6 kB/s)                                      
(Reading database ... 205032 files and directories currently installed.)
Removing docker-engine (1.12.0-0~trusty) ...
docker stop/waiting
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Selecting previously unselected package docker.io.
(Reading database ... 204909 files and directories currently installed.)
Preparing to unpack .../docker.io_1.6.2~dfsg1-1ubuntu4~14.04.1_amd64.deb ...
Unpacking docker.io (1.6.2~dfsg1-1ubuntu4~14.04.1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Processing triggers for ureadahead (0.100.0-16) ...
ureadahead will be reprofiled on next reboot
Setting up docker.io (1.6.2~dfsg1-1ubuntu4~14.04.1) ...
Installing new version of config file /etc/init.d/docker ...
Installing new version of config file /etc/bash_completion.d/docker ...
Installing new version of config file /etc/default/docker ...
Installing new version of config file /etc/init/docker.conf ...
addgroup: The group `docker' already exists as a system group. Exiting.
docker start/running, process 12267
Processing triggers for ureadahead (0.100.0-16) ...

Basic Commands

1. To list the containers:
 $ sudo docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

2. To check the docker version:
$ docker --version
Docker version 1.6.2, build 7c8fca2

3. Very first command in docker:
$ sudo docker run busybox echo hello world
Unable to find image 'busybox:latest' locally
latest: Pulling from busybox
4185ddbe03f8: Pull complete 
b05baf071fd5: Pull complete 
Digest: sha256:65ce39ce3eb0997074a460adfb568d0b9f0f6a4392d97b6035630c9d7bf92402
Status: Downloaded newer image for busybox:latest
hello world

4. Listing container: 
$ sudo docker ps -a
CONTAINER ID        IMAGE               COMMAND              CREATED             STATUS                      PORTS               NAMES
8f4a32c35516        busybox:latest      "echo hello world"   30 seconds ago      Exited (0) 29 seconds ago                       silly_mcclintock    

5. Listing Images: 
$ sudo docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
busybox             latest              b05baf071fd5        3 months ago        1.093 MB

6. Removing container: 
$ sudo docker rm 8f4a32c35516
   8f4a32c35516

7. Listing docker images: 
$ sudo docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
busybox             latest              b05baf071fd5        3 months ago        1.093 MB

8. Ensure: 
$ sudo docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

9. Removing docker images: 
$ sudo docker rmi busybox
Untagged: busybox:latest
Deleted: b05baf071fd542c3146f08e5f20ad63e76fa4b4bd91f274c4838ddc41f3409f8
Deleted: 4185ddbe03f83877b631b5e271a02f6f232de744ae4bfc48ce44216c706cb7fd

10. To create ubuntu container: 
$ sudo docker run -t -i ubuntu:14.04 /bin/bash
Unable to find image 'ubuntu:14.04' locally
14.04: Pulling from ubuntu
bb04ed60c038: Pull complete 
0812a82a4eba: Pull complete 
f6662ef795ac: Pull complete 
39a955bdc1e1: Pull complete 
348ae5f2350a: Pull complete 
35b394a6f7a2: Pull complete 
Digest: sha256:1fcd5a92f26ef71ae47c6ee7894cea5c854461b63f2d391d1fc068438d847aa5
Status: Downloaded newer image for ubuntu:14.04
root@f462ca19e571:/# ls               
bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var

'dmesg’ Command for Troubleshooting Kernel level issues


What is Dmesg:

     Dmesg is the command in linux which allows us to debug the kernel level errors.This will print or control the kernel ring buffer.

Kernel Ring Buffer:

     Kernel Ring Buffer is the data structure that records the data related to kernel.Ring Buffer is the special buffer that stores the data temporary and removes the old messages when new message arrives.

These dmesg will very helpful for debug the system issues in kernel level ( device drivers ).

1. List the sample results in dmesg:

     we can load the dmesg results with the help of text manipulation tools like more,less,tail etc.

Command:  # sudo dmesg | more
                     # sudo dmesg | less

Sample Output:


2. Check all detected drives:

                   # sudo dmesg | grep sda

Sample output:


3. Search for the particular string:

                       # sudo dmesg | grep -i "memory" 
                       # sudo dmesg | grep -i "dma"
                       # sudo dmesg | grep -i "usb"

Sample output:


4. To clear the dmesg logs:

                      # sudo dmesg -c 

This will clear the dmesg ring buffer.log which stored will get flushed.

5. To print the raw message:

                      # sudo dmesg -r 

6.Difference Between Dmesg and /var/log/messages

dmesg : dmesg is an (display or driver) message. It is used to examine or control the kernel ring buffer.
messages : It contains global system messages, including the messages that are logged during system startup. There are several things that are logged in /var/log/messages including mail, cron, daemon, kern, auth, etc.

Alternatively you can even troubleshoot the kernel level using multipath command.

Friday, 23 September 2016

Keypairing and Keychain - Linux


What is Key paring:

     Normally we used to login to the respective linux system with their username and credentials.Consider if we have around 50 systems,we can't able to login with username and password every login,this will be somewhat boring.In order to make it simple we go for key paring.

How we can do key paring:


  •    Generate a key in your local machine from the respective user and copy the key to the dest server by using below command
                     ssh-keygen
                     ssh-copy-id user@server _ip_address or hostname
  • After the public key is transferred to the server, you can now go and disable password logon via SSH.Next, logon to the server and open the configuration file for SSH. To do that, run the commands below.
                    vi /etc/ssh/sshd_config
  • Then make sure these lines are uncomment and value are set as shown below.
                   PubkeyAuthentication yes
                  AuthorizedKeyFile    .ssh/authorized_keys
                  PasswordAuthentication no
  • Restart the ssh server once your are done 
                  /etc/init.d/ssh restart

What is Keychain:

    keychain is a special bash script designed to make key-based authentication incredibly convenient and flexible. It offers various security benefits over passphrase-free keys.
keychain is a manager for ssh-agent, typically run from your local ~/.bash_profile.By Default,If you run longer scripts like DB snapshot may your ssh login will get broke off.

     But with the help of keychain we can allows our shells and cron jobs to share a single ssh-agent process.By default,the ssh-agent started by keychain is long-running and will continue to run, even after you have logged out from the system.

Where Keychain helps us as in security:

     If attacker broken into server with passphrase-free keys, all other servers / workstation linked with your keys are also under security risk (they can be easily breached). With keychain or ssh-agent attacker won’t able to touch your remote systems(servers) without breaking your passphrase. 

     Another example, if your laptop or hard disk stolen, an attacker can simply copy your key and use it anywhere as it is not protected by a passphrase.

How to set up keychain:  

Install Keychain on CentOS / RHEL / Fedora Linux
     # yum install keychain

Install Keychain on Debian / Ubuntu Linux
     # apt-get update && apt-get install keychain

Install Keychain on FreeBSD
     # portsnap fetch update
     # cd /usr/ports/security/keychain
     # make install clean

How Do I Use Keychain:

     Once OpenSSH keys are configured with a pass phrase, Do the keyparing to the remote server. Login and verify.Once you are fine.Then update your local $HOME/.bash_profile file which is your personal initialization file, executed for login BASH shells:

# vi $HOME/.bash_profile or $ vi $HOME/.bashrc

Append the following code:

     ### START-Keychain ###
     # Let  re-use ssh-agent and/or gpg-agent between logins
     /usr/bin/keychain $HOME/.ssh/id_dsa
     source $HOME/.keychain/$HOSTNAME-sh
     ### End-Keychain ###

Now you’ve keychanin configured to call keychain tool every login. Just log out and log back in to server from your desktop to test your setup:

$ ssh root@xxx.yyy.in

Sample output:

 * keychain 2.7.1 ~ http://www.funtoo.org
 * Found existing ssh-agent: 10017
 * Found existing gpg-agent: 20605
 * Known ssh key: /home/techops/.ssh/id_rsa
[root@xxx.yyy.in ~]#

Testing the keychain:

Once logged in and verfied.Remove the local id_rsa file in your local system and try to login.Yeah you can able to login into the server without your id_rsa pass phrase file.Now you are protected.

So crackers can't able to penetrate to your remote servers with your passphrase keys.

How to Delete/Clear the ssh-agent's key:

Then how to clear the ssh-key which you generated,here is the command you can execute in your local.

# keychain --clear


Thursday, 22 September 2016

Removing unwanted spaces using tr cmd in linux

     Everyone will like to get a pearl in an ocean but it's not so easy.Same way grepping a exact string from the selected content is a tricky task. I spent much time to get the exact command in internet ,so i am sharing the information here that it might helpful for all of you.


Example:

   Suppose I would like to get the exact domain from the system information using below command.While i use awk or cut command it will provide the result but it will also includes the extra spaces along the result to us.It might not helpful to us while passing such result into scripts like perl/shell etc.

      So trimming the space here is much more important to us.To achieve this we can follow final command which given here.

Commands:

1.Grepping domain name from your system:

# facter domain - xxx.yyyyyy.com

2.Need to get the xxx value from the above domain name:

# facter domain | cut -d "." -f 1 - xxx ( partial success ) this result will provide unwanted space along with this

3.Finally By using below command we can remove unwanted spaces:

# facter domain | cut -d "." -f 1 | tr -d '[:space:]' -- xxx

Brief Explanation of above command:


What is Facter:

     Facter is small program that gathers system information such as hardware details, network settings, virtualisation type and kernel/OS information. Facter was created for Puppet to gather system information, but is also available as a standalone command.

Cut:

Cut will perform cut operation,d - used as a delimiter, f - field

tr:

translate or delete characters, d - delete, [:space:] - all horizontal or vertical spaces.

Tuesday, 20 September 2016

Configuring Network Alias IP in centos


1.What is IP Alias:

     IP alias / IP aliasing is associating more than one IP address to a physical network interface. With this, one node on a network can have multiple connections to a network, each serving a different purpose.Alias network interface is configured on top of existing physical network interface.

2.What needs to IP alias:
Physical Network Interface Connectivity in server.
Available Multiple IP Addresses

Limitations of IP alias:
Subnet Aliasing (alias network interface IP address is preffered to be in the same network subnet as physical network interface below – if not proper network infrastructure configuration is needed)
DHCP (alias interfaces do not support DHCP)
Example: If physical network interface is named eth0, alias interfaces on top of this one are named eth0:0, eth0:1, … and if physical network interface is named eth1, alias interfaces on top of this one are names eth1:0, eth1:1 … and so on.


IP Alias Network Interface

2. Non-Persistent IP Alias Configuration

Non-persistent IP aliases do not survive linux server reboot. This means IP alias is only configured for the time the server is up and running and will dissapear if our linux server is rebooted. The following is the linux command line syntax to configure non-persistent alias network interface where X numbers the configured physical network interface, Y numbers the desired alias interface starting with 0 and IPADDRESS is the IP address we want to assign to our alias network interface:

[root@foo1 ~]# ifconfig ethX:Y IPADDRESS up


We can check if alias network interface is up and running with the following linux command (look for the ethX:Y interface):

[root@foo1 ~]# ifconfig


Example: In the following example a physical interface eth0 is properly configured with tested network connectivity and has an IP address 192.168.1.100. We can configure an alias network interface called eth0:0 and IP address 192.168.1.101 with the following command:

[root@foo1 ~]# ifconfig eth0:0 192.168.1.101 up


We can check if alias network interface is up with ifconfig, looking for the eth0:0 and IP address 192.168.1.101:

[root@foo1 ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:A9:01:61
          inet addr:192.168.1.100  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fea9:161/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4726 errors:0 dropped:0 overruns:0 frame:0
          TX packets:732 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:542695 (529.9 KiB)  TX bytes:115702 (112.9 KiB)

eth0:0    Link encap:Ethernet  HWaddr 08:00:27:A9:01:61
          inet addr:192.168.1.101  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:140 errors:0 dropped:0 overruns:0 frame:0
          TX packets:140 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:11760 (11.4 KiB)  TX bytes:11760 (11.4 KiB)

3. Persistent IP Alias Configuration

Persistent IP aliases survive linux server reboot and are configured in alias network configuration file. Network configuration files are stored in /etc/sysconfig/network-scripts/ directory and are named ifcfg-ethX, where X is a number of the physical network interface. Alias network configuration files are named ifcfg-ethX:Y, where X is the number of the physical network interface and Y is the number of the alias network interface.



The quickest and easiest way to create alias network interface configuration file is to copy an existing physical network interface configuration file with working network connectivity by running the following command:

[root@foo1 ~]# cp /etc/sysconfig/network-scripts/ifcfg-ethX /etc/sysconfig/network-scripts/ifcfg-ethX:Y


…where X is the number of the physical network interface and Y is the number of the alias network interface.

Next we need to edit the newly created file /etc/sysconfig/network-scripts/ifcfg-ethX:Y with the preferred file editor and replace the following physical network interface (ethX) entries with the desired new alias network interface (ethX:Y) entries.

Replace:

DEVICE=ethX
With:

DEVICE=ethX:Y
Find the IPADDR line of your ethX physical network interface:

IPADDR=XXX.XXX.XXX.XXX
And replace it with the desired alias network interface IP address:

IPADDR=YYY.YYY.YYY.YYY
When alias network interface configuration file is configured, we can bring the alias network interface up by running the following command:

[root@foo1 ~]# ifup ethX:Y


We can check if alias network interface is up with ifconfig command (look for the ethX:Y interface):

[root@foo1 ~]# ifconfig


Example: This is a working example of the physical network interface configuration file (eth0:0):

/etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=none
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1


And a working example of the alias network interface (eth0:0) on top of physical network interface (eth0):

/etc/sysconfig/network-scripts/ifcfg-eth0:0

DEVICE=eth0:0
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=none
IPADDR=192.168.1.149
NETMASK=255.255.255.0
GATEWAY=192.168.1.1


By running ifup command, we bring alias network interface up and running:

[root@foo1 ~]# ifup eth0:0


Checking for alias network interface eth0:0 with the IP address 192.168.1.101 with ifconfig command:

[root@foo1 ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:A9:01:61
          inet addr:192.168.1.100  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fea9:161/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4726 errors:0 dropped:0 overruns:0 frame:0
          TX packets:732 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:542695 (529.9 KiB)  TX bytes:115702 (112.9 KiB)

eth0:0    Link encap:Ethernet  HWaddr 08:00:27:A9:01:61
          inet addr:192.168.1.101  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:140 errors:0 dropped:0 overruns:0 frame:0
          TX packets:140 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:11760 (11.4 KiB)  TX bytes:11760 (11.4 KiB)

Tuesday, 13 September 2016

step by step installation for NRPE and PNP4nagios

NRPE allows you to remotely execute Nagios plugins on other Linux/Unix machines. This allows you to monitor remote machine metrics (disk usage, CPU load, etc.). NRPE can also communicate with Windows agent addons like NSClient++, so you can check metrics on remote Windows machines as well.

Download the required plugin from the below url’s,
Download link for NRPE : 
http://exchange.nagios.org/directory/Addons/Monitoring-Agents/NRPE--2D-Nagios-Remote-Plugin-Executor/details

Download link for Nagios plugins:
http://www.nagios.org/download/plugins

NRPE INSTALLATION STEPS

1. To install Nagios plugins

Nagios user is needed for every end system so that the nagios server will prompt the end systems to execute the commands/plugins as the nagios user, 

Note:  Please  follow the below steps as a root user 
         #sudo su (or) su - root 
# useradd nagios  
# passwd nagios 

ssl libraries are required as a dependency to nrpe addon, and we can install it by providing the below command

# yum install openssl openssl-devel

Traverse to the downloaded plugin directory, and follow the steps

# cd nagios-plugins-2.*/
# ./configure
# make
# make install

# chown nagios:nagios /usr/local/nagios
# chown nagios:nagios /usr/local/nagios/libexec/ -R
# yum install xinetd

2. To Install NRPE addon

Traverse to the downloaded nrpe directory, and follow the steps

# cd nrpe-2.15
# ./configure

# make all
# make install-plugin
# make install-daemon
# make install-daemon-config
# make install-xinetd

Open the below file and add the nagios server ip to allow the nrpe request:

# vim /etc/xinetd.d/nrpe 

Add the following entry for the NRPE daemon to the /etc/services file:

nrpe 5666/tcp # NRPE

Restart the xinetd service:
# service xinetd restart (or) /etc/init.d/xinetd restart

check whether the nrpe port (5666) is listening 
# netstat -at | grep nrpe 

Verify the NRPE add-on it should provide output like below:

# /usr/local/nagios/libexec/check_nrpe -H 127.0.0.1
NRPE v2.15

After all that,  configure your own scripts to monitor the instances or download the checks from nagios exchange

After Downloading and editing the scripts, you can edit /usr/local/nagios/etc/nrpe.cfg file to add monitoring for the services


PNP4NAGIOS INSTALLATION STEPS

PNP is an addon to nagios which analyzes performance data provided by plugins and stores them automatically into RRD-databases.

Prerequisites:

# yum -y install rrdtool rrdtool-perl php-gd

Downloading and compiling pnp4nagios:

# cd ~/Downloads
# wget http://sourceforge.net/projects/pnp4nagios/files/PNP-0.6/pnp4nagios-0.6.21.tar.gz

Installation of pnp4nagios:

# tar -zxvf pnp4nagios-0.6.21.tar.gz
# cd pnp4nagios-0.6.21
# ./configure

# ./configure --with-rrdtool=/usr/local/rrdtool/bin/rrdtool --with-perl_lib_path=/usr/local/rrdtool/lib/perl/5.10.1/x86_64-linux-thread-multi

# make all
# make install
# make install-webconf
# make install-config


Change the Main Configuration file nagios.cfg to work with pnp4nagios:

# vim /usr/local/nagios/etc/nagios.cfg

1.Add the below lines in nagios.cfg

process_performance_data=1
#
# service performance data
#
service_perfdata_file=/usr/local/pnp4nagios/var/service-perfdata
service_perfdata_file_template=DATATYPE::SERVICEPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tSERVICEDESC::$SERVICEDESC$\tSERVICEPERFDATA::$SERVICEPERFDATA$\tSERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$\tSERVICESTATE::$SERVICESTATE$\tSERVICESTATETYPE::$SERVICESTATETYPE$
service_perfdata_file_mode=a
service_perfdata_file_processing_interval=15
service_perfdata_file_processing_command=process-service-perfdata-file

#
# host performance data starting with Nagios 3.x
#
host_perfdata_file=/usr/local/pnp4nagios/var/host-perfdata
host_perfdata_file_template=DATATYPE::HOSTPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tHOSTPERFDATA::$HOSTPERFDATA$\tHOSTCHECKCOMMAND::$HOSTCHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$
host_perfdata_file_mode=a
host_perfdata_file_processing_interval=15
host_perfdata_file_processing_command=process-host-perfdata-file




2.Add commands in object configuration.

# vim usr/local/nagios/etc/objects/commands.cfg


define command{
command_name process-service-perfdata-file
command_line /bin/mv /usr/local/pnp4nagios/var/service-perfdata /usr/local/pnp4nagios/var/spool/service-perfdata.$TIMET$
}


define command{
command_name process-host-perfdata-file
command_line /bin/mv /usr/local/pnp4nagios/var/host-perfdata /usr/local/pnp4nagios/var/spool/host-perfdata.$TIMET$
}


To create shortcut for pnp near host with popup  in Web UI

Prerequisites:
PNP is installed
Copy the file status-header.ssi from the contrib/ssi/ folder of the PNP package to /usr/local/nagios/share/ssi/.
Attention: This file must NOT be executable. Otherwise it will be treated as a CGI which will result in an error.

Add action_url directive to the templates

# vim /usr/local/nagios/etc/objects/templates.cfg

For Host templates:

action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_'class='tips'rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=_HOST_

For Service Templates:

action_url
/pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$'class='tips'rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=$SERVICEDESC$

Run the below command to collect the data:

/usr/local/pnp4nagios/bin/npcd -d -f /usr/local/pnp4nagios/etc/npcd.cfg

Restart apache and nagios to run with new changes:

# /etc/init.d/nagios restart
# /etc/init.d/httpd restart

Open pnp4nagios web page by entering

http://localhost/pnp4nagios/

After your environment passed all requirements . You need to delete install.php file.

# rm -rf /usr/local/pnp4nagios/share/install.php

You have successfully installed NRPE addon and PNP4Nagios.