Total Hit Counter

Wednesday, August 17, 2016

Wifi not getting up after suspend in ubuntu 16.04

Hi Friends,

Before couple of days I have upgraded my laptop from Ubuntu 14.04 to Ubuntu 16.04. After upgrade I was facing some misbehavior issues.

One of them was when I wake my laptop after suspend, it was unable to connect to any of wifi devices.

Here, I am going to give solution for the same. I figured it out that after suspend it was not able to start wifi again.


You just follow below steps and it will be done.

Step 1: To verify before applying this solution by executing below command after wake up from suspend, you check whether it will work for you or not.
$ sudo systemctl restart network-manager.service
Now if it works then further you apply below is permanent solution.

Step2: Create a file with name wifi-reset.service in /etc/systemd/system/ directory with below content:

[Unit]
Description=Restart networkmanager at resume
After=suspend.target
After=hibernate.target
After=hybrid-sleep.target
[Service]
Type=oneshot
ExecStart=/bin/systemctl restart network-manager.service
[Install]
WantedBy=suspend.target
WantedBy=hibernate.target
WantedBy=hybrid-sleep.target
Step3: Now enable service at boot time, wakeup time and hibernet time using following command: 
systemctl enable wifi-resume.service
That's it, you are done now.
Please check after suspend again....................





Wednesday, June 8, 2016

Getting started with Docker Container service

Hi Guys,

Below are the steps to install docker container and start working on it. As I have installed docker on Centos Server, below are the steps to install on it.

System Requirement:
1) Kernel must be 3.10 or more then that.
2) device-mapper-libs must be installed on it.

Steps are as below:

Step1: Installation of latest kernel.
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh http://www.elrepo.org/elrepo-release-6-6.el6.elrepo.noarch.rpm
yum -y --enablerepo=elrepo-kernel install kernel-lt
yum -y install device-mapper-libs
vim /etc/grub.conf and chnage default kernel to 0
reboot
uname -a

Step2: Installation of Docker packge repository
sudo tee /etc/yum.repos.d/docker.repo <<-'EOF'
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/$releasever/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
EOF

Step3: Installation and Start docker service.
yum install docker-engine
service docker restart

you can check logs by executing below command


tail -f /var/log/docker

Now Press CTRL+C

Step4: Start your hello-word container.
docker run hello-world
docker ps -a
You will see there will be 1 container running on your server with named hello-world


Example of Nginx Server: 

docker pull nginx
docker run --name docker-nginx -p 80:80 nginx
mkdir -p ~/docker-nginx/html
cd ~/docker-nginx/html
vim index.html

docker ps -a
docker stop docker-nginx
docker ps -a
docker rm docker-nginx
docker run --name docker-nginx -p 80:80 -d -v ~/docker-nginx/html:/usr/share/nginx/html nginx

Login to docker on bash shell:


docker exec -i -t 2f9f1cacb645 /bin/bash

Now you can check nginx service is running on it.
Also check ip address using below command
ip add

Now Browse the same ip in your server you will see sample page you have created.

That's it.................

Tuesday, January 5, 2016

Bootstrap Node in Chef-server

Now you need to bootstrap a node with your chef-server.

Please execute below command for the same.

knife bootstrap xxx.xxx.xxx.xxx --ssh-user root --ssh-password 'password' --run-list 'recipe[init-setup]'

Thursday, December 10, 2015

Chef Server install and configure


To get started with installation you must have below things ready.

  • Centos 6.5 installed.
  • Internet connection
  • Stop iptables and selinux.


Step1: Download latest rpm from chef website.

https://downloads.chef.io/chef-server/redhat/

I downloaded chef-server-core-12.3.1-1.el6.x86_64.rpm.

Step2: Now install chef rpm. Execute below command to install chef rpm





Step3: Edit /etc/hosts file and add chef-server fqdn to get it resolved. Chef server fqdn must be resolved from anywhere in you network.

127.0.0.1 chef-server.cignex.com

Create file /etc/opscode/chef-server.rb with below content

server_name = "chef-server.cignex.com"api_fqdn server_namebookshelf['vip'] = server_namenginx['url'] = "https://#{server_name}"nginx['server_name'] = server_namenginx['ssl_certificate'] = "/var/opt/opscode/nginx/ca/#{server_name}.crt"nginx['ssl_certificate_key'] = "/var/opt/opscode/nginx/ca/#{server_name}.key"


Step4: Now configure chef server by executing below command
chef-server-ctl reconfigure
At the last you will get message like Chef Server Reconfigured! 


Step5: To start with web console you have to install it.

chef-server-ctl install opscode-manage
 If above command fails then enable yum repo in this file /etc/yum.repos.d/chef-stable.repo
Then install opscode-manage manually and execute above command again.
chef-server-ctl reconfigureopscode-manage-ctl reconfigure
 Now execute below command for installing reporting tool.

chef-server-ctl install opscode-reporting
 If above command fails then enable yum repo in this file /etc/yum.repos.d/chef-stable.repo
Then install opscode-reporting manually and execute above command again.
chef-server-ctl reconfigureopscode-reporting-ctl reconfigure


Step 6: Now restart chef service. by executing below command.
/opt/opscode/bin/chef-server-ctl restart

Step 7:  Create Admin user for login into web console

Command:
chef-server-ctl user-create ADMIN_USER_NAME ADMIN_FIRST_NAME ADMIN_LAST_NAME ADMIN_EMAIL ADMIN_PASSWORD --filename ADMIN_USER_NAME.pem
Example:
[root@chef-server ~]# chef-server-ctl user-create shankar Shankar Patel shankar.patel@cignex.com Cignex --filename Cignex.pem
Reset password for created user
[root@chef-server ~]#  chef-server-ctl password shankar
         
Step 8:  Create Organization to manage nodes under a single roof

Command:
chef-server-ctl org-create ORG_SHORT_NAME "ORG_LONG_NAME" --association_user ADMIN_USER_NAME
Example:
[root@chef-server ~]# chef-server-ctl org-create cignex 'CIGNEX Datamatics Pvt Ltd' --association_user shankar 
You must define organization name in small leters, otherwise it will not create any organization.



Thats it!

You are done now.

Now you can browse URL to login in console

https://chef-server.cignex.com/login



Monday, May 18, 2015

Openldap pass-through authentication with active directory @CIGNEX Datamatics


1. Install cyrus-sasl, openldap servers and clients
yum install openldap-servers openldap-client* *cyrus*sasl*

2. Edit /etc/sysconfig/saslauthd as below
[root@localhost ~]# vim /etc/sysconfig/saslauthd 
[root@localhost ~]# cat /etc/sysconfig/saslauthd
SOCKETDIR=/run/saslauthd
MECH=ldap
FLAGS='-O /etc/saslauthd.conf'

3. Create /etc/saslauthd.conf and paste below content (AD details)
[root@localhost ~]# vim /etc/saslauthd.conf
[root@localhost ~]# cat /etc/saslauthd.conf
ldap_servers: ldap://172.16.197.138
ldap_search_base: CN=Users,dc=myad,dc=com
ldap_timeout: 10
ldap_filter: sAMAccountName=%U
ldap_bind_dn: CN=Administrator,CN=Users,dc=myad,dc=com
ldap_password: Test1234
ldap_deref: never
ldap_restart: yes
ldap_scope: sub
ldap_use_sasl: no
ldap_start_tls: no
ldap_version: 3
ldap_auth_method: bind

4. Create file /usr/lib64/sasl2/slapd.conf with below content.
[root@localhost ~]# vim /usr/lib64/sasl2/slapd.conf
[root@localhost ~]# cat /usr/lib64/sasl2/slapd.conf
pwcheck_method: saslauthd
saslauthd_path: /run/saslauthd/mux

5. Edit /etc/openldap/ldap.conf and add below lines.
sasl-host localhost
sasl-secprops none
BASE dc=myad,dc=com
URI ldap://localhost
[root@localhost ~]# tail -5 /etc/openldap/ldap.conf
sasl-host localhost
sasl-secprops none
BASE dc=myad,dc=com
URI ldap://localhost

6. Restart saslauthd and slapd service and test as below
/usr/sbin/testsaslauthd -u administrator -p Test123

8. Execute commands as below: 
cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG 
chown ldap. /var/lib/ldap/DB_CONFIG 
service slapd restart

9. Get encrypted password using slappasswd command
[root@localhost ~]# slappasswd 
New password: 
Re-enter new password: 
{SSHA}rSzjUq/YAVYjnybwN01AsHYs3jHTeZam


10. create chrootpw.ldif as below content. Replase {SSHA}xxxxxxxxxxxxxxxxxxxxxx with output of above command.
[root@localhost ~]# vim chrootpw.ldif
[root@localhost ~]# cat chrootpw.ldif 
dn: olcDatabase={0}config,cn=config
changetype: modify
add: olcRootPW
olcRootPW: {SSHA}rSzjUq/YAVYjnybwN01AsHYs3jHTeZam

[root@localhost ~]# ldapadd -Y EXTERNAL -H ldapi:/// -f chrootpw.ldif 
SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
modifying entry "olcDatabase={0}config,cn=config"


13. Execute below commands and get again encrypted password for your admin account using slappasswd command
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/nis.ldif 
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/cosine.ldif 
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/inetorgperson.ldif 

[root@localhost ~]# slappasswd 
New password: 
Re-enter new password: 
{SSHA}HBRqaFKHvhq6EFF5T+MK9/oUN7WQB7Ov


14. Create chdomain.ldif as below. Replase {SSHA}xxxxxxxxxxxxxxxxxxxxxx with output of above command.
[root@localhost ~]# vim chdomain.ldif
[root@localhost ~]# cat chdomain.ldif
dn: olcDatabase={1}monitor,cn=config
changetype: modify
replace: olcAccess
olcAccess: {0}to * by dn.base="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth"
 read by dn.base="cn=Manager,dc=myad,dc=com" read by * none

dn: olcDatabase={2}hdb,cn=config
changetype: modify
replace: olcSuffix
olcSuffix: dc=myad,dc=com

dn: olcDatabase={2}hdb,cn=config
changetype: modify
replace: olcRootDN
olcRootDN: cn=Manager,dc=myad,dc=com

dn: olcDatabase={2}hdb,cn=config
changetype: modify
add: olcRootPW
olcRootPW: {SSHA}HBRqaFKHvhq6EFF5T+MK9/oUN7WQB7Ov

dn: olcDatabase={2}hdb,cn=config
changetype: modify
add: olcAccess
olcAccess: {0}to attrs=userPassword,shadowLastChange by
 dn="cn=Manager,dc=myad,dc=com" write by anonymous auth by self write by * none
olcAccess: {1}to dn.base="" by * read
olcAccess: {2}to * by dn="cn=Manager,dc=myad,dc=com" write by * read




15. Execute below command. 

[root@localhost ~]# ldapmodify -Y EXTERNAL -H ldapi:/// -f chdomain.ldif 
SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
modifying entry "olcDatabase={1}monitor,cn=config"

modifying entry "olcDatabase={2}hdb,cn=config"

modifying entry "olcDatabase={2}hdb,cn=config"

modifying entry "olcDatabase={2}hdb,cn=config"

modifying entry "olcDatabase={2}hdb,cn=config"




16. Create basedomain.ldif with below content.

[root@localhost ~]# cat basedomain.ldif 
dn: dc=myad,dc=com
objectClass: top
objectClass: dcObject
objectclass: organization
o: Myad Com
dc: myad

dn: cn=Manager,dc=myad,dc=com
objectClass: organizationalRole
cn: Manager
description: Directory Manager

dn: ou=People,dc=myad,dc=com
objectClass: organizationalUnit
ou: People

dn: ou=Group,dc=myad,dc=com
objectClass: organizationalUnit
ou: Group


17. Execute below command. 

[root@localhost ~]# ldapadd -x -D cn=Manager,dc=myad,dc=com -W -f basedomain.ldif 
Enter LDAP Password: 
adding new entry "dc=myad,dc=com"

adding new entry "cn=Manager,dc=myad,dc=com"

adding new entry "ou=People,dc=myad,dc=com"

adding new entry "ou=Group,dc=myad,dc=com"


18. Create new user in ldap to map with AD. Create new file as below content

[root@localhost ~]# cat user.ldif 
dn: uid=user01,ou=People,dc=myad,dc=com
uid: user01
cn: user01
loginShell: /bin/bash
uidNumber: 2055
gidNumber: 100
sn: user01
homeDirectory: /home/o/user01
objectClass: inetOrgPerson
objectClass: organizationalPerson
objectClass: posixAccount
objectClass: top
userPassword: {SASL}india@myad.com

19. ldapadd -x -D cn=Manager,dc=myad,dc=com -W -f user.ldif -v


ldapsearch -H ldap://172.16.197.152:389 -x -D "uid=user01,ou=People,dc=myad,dc=com" -W -b "uid=user01,ou=People,dc=myad,dc=com" -s sub -a always -z 1000 "(objectClass=*)" "objectClass"  | grep -v ^# | grep -v ^$

Tuesday, April 28, 2015

Lifray 6.2 authentication with Active Directory and Open Ldap @CIGNEX

Configure Liferay authentication with Active Directory OR OpenLDAP

Hi Guys,
I am working as Sr. Consultant - MCS ( Manage Cloud Service) in CIGNEX Datamatics Pvt. Ltd. We often used to do Liferay authentication with different different Directory server, Like Active Directory, Open LDAP, etc.. We can implement multiple directory servers' authentication in liferay also we can use active directory and openldap same time in multiple directory servers' authentication.
Today I am going to write here how we can implement Liferay 6.2 authentication with Active directory and open ldap. 
After Below exercise you will have liferay working with authentication with openldap and active directory using email id. You will have all users' imported in liferay. If you dont want to import in liferay you can stop by disabling import properties.


Important note:
Before Going to start please be confirm following things:
  1. AD/OpenLdap server should be accessible from your machine on 389 port.
  2. All users’ must have values in given fields: sAMAccountName, userPassword, userPrincipalName, givenName, sn  
  3. None of users have '@' or '_' ind of extra character in sAMAccountName or UID. if any user containing these special characters then those users' will not be authenticated or imported.
  4. You must have java installed in your machine with version 1.7.0 or latest
  5. JAVA_HOME must be set
  6. PATH must be set  to be accessible java bin directory.
  7. iptables and selinux should be off.

Step 1: Download liferay zip file and put in /opt directory
root@shankarpatel:~# cd /opt
Step 2: Extract it.
root@shankarpatel:/opt# unzip liferay-portal-tomcat-6.2-ce-ga2-20140319114139101.zip
Step 3 : rename to liferay directory and change to liferay directory
root@shankarpatel:/opt# mv liferay-portal-6.2-ce-ga2 liferay
root@shankarpatel:/opt# cd liferay
Step 4: Create portal-ext.properties file
root@shankarpatel:/opt/liferay# vim portal-ext.properties


Step 5: now paste below content in the file


#################################################
# Below properties are basic properties to connect with database and use mysql driver
#################################################
# Use mysql connector
jdbc.default.driverClassName=com.mysql.jdbc.Driver
# connect to localhost’s mysql server
jdbc.default.url=jdbc:mysql://localhost/lportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
# database credentials
jdbc.default.username=root
jdbc.default.password=redhat


####
#   Common properties to Configuration for users import from ldap in liferay
#######
ldap.auth.enabled=true
ldap.import.user.password.enabled=true
ldap.import.enabled=true
ldap.import.on.startup=true
ldap.import.interval=5
Context.REFERRAL=follow


####
#   Configuration for authenticating with Active directory.
#######
ldap.base.provider.url.0=ldap://192.168.1.1:389
ldap.base.dn.0=dc=server,dc=com
ldap.security.principal.0=user1
ldap.security.credentials.0=Test1234
ldap.user.mappings.0=screenName=sAMAccountName\npassword=userPassword\nemailAddress=userPrincipalName\nfirstName=givenName\nlastName=sn\njobTitle=title
ldap.import.user.search.filter.0=(objectClass=person)
# If you want to set login using SCREEN NAME enable below line
#ldap.auth.search.filter.0=(sAMAccountName=@screen_name@)
# If you want to set login using email address enable below line
#ldap.auth.search.filter.1=(userPrincipalName=@email_address@)



# you can have multiple AD or 1 AD and 1 OpenLdap
# if you want to configure authentication with open ldap put below configuration



####
#   Configuration for authenticating with OPEN LDAP.
#######
ldap.base.provider.url.1=ldap://localhost:389
ldap.base.dn.1=dc=server,dc=com
ldap.security.principal.1=cn=shankar,ou=People,dc=server,dc=com
ldap.security.credentials.1=Test1234
ldap.user.mappings.1=screenName=uid\npassword=userPassword\nemailAddress=mail\nfirstName=givenName\nlastName=sn\njobTitle=title
ldap.import.user.search.filter.1=(objectClass=person)
# If you want to set login using SCREEN NAME enable below line
#ldap.auth.search.filter.0=(cn=@screen_name@)
# If you want to set login using email address enable below line
#ldap.auth.search.filter.1=(mail=@email_address@)


Before applying above settings please change below parameters with your credentials.
jdbc.default.url = Change hostname localhost to your db server 
jdbc.default.username= Change username as you have for database 
jdbc.default.password= Change password as you have for above user

ldap.base.provider.url.0=ldap://<your Active Directory Server name or IP>
ldap.base.dn.0=dc=your,dc=domain
ldap.security.principal.0=Active Directory Admin Username
ldap.security.credentials.0= Password of above user

ldap.base.provider.url.1=ldap://<your OpenLDAP Server name or IP>
ldap.base.dn.1=dc=OPENLDAP,dc=domainname
ldap.security.principal.1=Active Directory Admin Username
ldap.security.credentials.1= Password of above user




Now Start your liferay it will be able to authenticated with open ldap and active directory users.
Enjoy..............

Friday, September 26, 2014

Major vulnerability in bash

Hello Guys,

I read some blogs and according to it bash susceptible to environment variables code injection attack.
I think we should update our bash with latest patch of bash available.
my old bash version for centos 6.5 is 
[root@centos-test ~]# rpm -q bash
bash-4.1.2-15.el6_4.x86_64
[root@centos-test ~]# env x='() { :;}; echo problem' bash -c /bin/true
problem
if you gets output as a problem that means your bash version needs to be updated with latest patch.

Then I updated it and now its
[root@centos-test ~]# rpm -q bash
bash-4.1.2-15.el6_5.1.x86_64
[root@centos-test ~]# env x='() { :;}; echo problem' bash -c /bin/true
bash: warning: x: ignoring function definition attempt
bash: error importing function definition for `x'

if you gets output as above that means your bash version is fine.

For more information read below blog.
http://www.linuxbsdos.com/2014/09/25/bash-susceptible-to-environment-variables-code-injection-attack/

Wednesday, April 23, 2014

PNP4Nagios installation and integration with Nagios @CIGNEX Datamatics

Hello guys,

I would like to share how to install PNP4Nagios and integrate with nagios to see graphs.
With nagios if you want to configure graphs for your any of the services you need performance data as part in output.

Performance Data: Plugins can return optional performance data in their output by sending the normal, human-readable text string that they usually would, followed by a pipe character (|), and then a string containing one or more performance data metrics. Let's take the check_ping plugin as an example and assume that it has been enhanced to return percent packet loss and average round trip time as performance data metrics. 

Sample output from the plugin might look like this:
PING ok - Packet loss = 0%, RTA = 0.80 ms | percent_packet_loss=0, rta=0.80

If you are new to performance data see below link for more information:
Performance Data

Installation and configuration of PNP4Nagios:

Step1: Install pnp4nagios and rrdtool-perl package
yum install pnp4nagios* rrdtool-perl

Step2: Change some parameters in nagios Configuration file 

Edit the performance data section of /usr/local/nagios/etc/nagios.cfg:
Enable performance data by adding following line
process_performance_data=1 

Define path where performance data files should be stored.
host_perfdata_file=/var/perfdatanagios/host-perfdata
service_perfdata_file=/var/perfdatanagios/service-perfdata

Create /var/perfdatanagios/ direcrtory and change permission.
mkdir /var/perfdatanagios/
chown nagios:apache /var/perfdatanagios/
chmod 775 /var/perfdatanagios 

Now add below performance data templates lines

host_perfdata_file_template=DATATYPE::HOSTPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tHOSTPERFDATA::$HOSTPERFDATA$\tHOSTCHECKCOMMAND::$HOSTCHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$\tHOSTOUTPUT::$HOSTOUTPUT$
service_perfdata_file_template=DATATYPE::SERVICEPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tSERVICEDESC::$SERVICEDESC$\tSERVICEPERFDATA::$SERVICEPERFDATA$\tSERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$\tSERVICESTATE::$SERVICESTATE$\tSERVICESTATETYPE::$SERVICESTATETYPE$\tSERVICEOUTPUT::$SERVICEOUTPUT$

Change below parameters
host_perfdata_file_mode=a 
service_perfdata_file_mode=a 

Change interval to process perfdata 

host_perfdata_file_processing_interval=15 
service_perfdata_file_processing_interval=15 

Add commands to check perfdata 
host_perfdata_file_processing_command=process-host-perfdata-file 
service_perfdata_file_processing_command=process-service-perfdata-file

Now create commands in commands.cfg file to process performance data as below:

define command {
        command_name    process-service-perfdata-file
        command_line    /usr/local/nagios/libexec/plugins/process_perfdata.pl --bulk=/var/perfdatanagios/service-perfdata
}
define command {
        command_name    process-host-perfdata-file
        command_line    /usr/local/nagios/libexec/plugins/process_perfdata.pl --bulk=/var/perfdatanagios/host-perfdata
}
Note: use your plugin directory path.

Download 
process_perfdata.pl
wget https://raw.github.com/willixix/WL-NagiosPlugins/master/graphing_templates/pnp4nagios/process_perfdata.pl

Change ownership and permissions as below.
chown nagios:nagios process_perfdata.pl
chmod +x  process_perfdata.pl

change conf array in process_perfdata.pl plugin according to your configuration in /etc/pnp4nagios/process_perfdata.cfg and /etc/pnp4nagios/config.php.

Change below parameters /etc/pnp4nagios/config.php
$conf['rrdtool'] = "/usr/bin/rrdtool";
$conf['rrdbase'] = "/var/perfdatanagios/";
$conf['page_dir'] = "/etc/pnp4nagios/pages/";

find below strings in process_perfdata.pl file and change its value according to your environment.
RRDPATH            => "/var/perfdatanagios/", 
RRA_CFG            => "/etc/pnp4nagios/rra.cfg",
STATS_DIR          => "/var/log/pnp4nagios/stats",
LOG_FILE           => "/var/log/pnp4nagios/perfdata.log",
ENCRYPTION         => 0,   


find below strings in process_perfdata.cfg file and change its value according to your environment.
RRDPATH = /var/perfdatanagios/ ## [ path of perfdata directory ]
RRA_CFG = /etc/pnp4nagios/rra.cfg ## [ path of rra.cfg file]
STATS_DIR = /var/log/pnp4nagios/stats ## [ create directory /var/log/pnp4nagios/stats ]
LOG_FILE = /var/log/pnp4nagios/pnp4nagios.log
Add below line 
ENCRYPTION=0

Move process_perfdata.pl plugin to you your plugin directory
mv process_perfdata.pl /usr/local/nagios/libexec/plugins/


Add below line in generic-host template in 
/etc/nagios/lconf/default-templates.cfg 
action_url /pnp4nagios/graph?host=$HOSTNAME$

Add below line in generic-service template in /etc/nagios/lconf/default-templates.cfg file
action_url /pnp4nagios/graph?host=$HOSTNAME$&srv=$SERVICEDESC$

Now Restart Nagios and Httpd service.
service nagios restart
service httpd restart

Now you can see new graph icon before service name in Nagios UI.