Centos6.7 installation of Naigos tutorial, centos6.7naigos
Centos6.7 installing Naigos tutorial
Reference: https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/quickstart-fedora.html
Blog: http://www.cnblogs.com/caoguo
1. Install the dependency package
[root@Nagios ~]# yum install -y httpd php[root@Nagios ~]# yum install -y gcc glibc glibc-common[root@Nagios ~]# yum install -y gd gd-devel[root@Nagios ~]# yum install -y perl ntp unzip[root@Nagios ~]# yum install -y openssl-devel[root@Nagios ~]# /etc/init.d/ntpd start[root@Nagios ~]# chkconfig ntpd on[root@Nagios ~]# /usr/sbin/useradd -m nagios[root@Nagios ~]# passwd nagios[root@Nagios ~]# /usr/sbin/groupadd nagcmd[root@Nagios ~]# /usr/sbin/usermod -a -G nagcmd nagios[root@Nagios ~]# /usr/sbin/usermod -a -G nagcmd apache[root@Nagios ~]# id nagiosuid=500(nagios) gid=500(nagios) groups=500(nagios),501(nagcmd)[root@Nagios ~]# id apacheuid=48(apache) gid=48(apache) groups=48(apache),501(nagcmd)
Ii. nagios Installation
[root@Nagios ~]# cd /usr/local/src[root@Nagios src]# wget http://nagios-plugins.org/download/nagios-plugins-2.1.1.tar.gz[root@Nagios src]# wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.1.1.tar.gz[root@Nagios src]# tar zxvf nagios-4.1.1.tar.gz[root@Nagios src]# cd nagios-4.1.1[root@Nagios nagios-4.1.1]# ./configure --prefix=/usr/local/nagios --with-comand-group=nagcmd[root@Nagios nagios-4.1.1]# make all[root@Nagios nagios-4.1.1]# make install[root@Nagios nagios-4.1.1]# make install-init[root@Nagios nagios-4.1.1]# make install-config[root@Nagios nagios-4.1.1]# make install-commandmode[root@Nagios nagios-4.1.1]# make install-webconf[root@Nagios nagios-4.1.1]# cp -rf contrib/eventhandlers /usr/local/nagios/libexec/[root@Nagios nagios-4.1.1]# chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
3. Install nagios plugins
[root@Nagios src]# tar xzf nagios-plugins-2.1.1.tar.gz [root@Nagios src]# cd nagios-plugins-2.1.1[root@Nagios nagios-plugins-2.1.1]# ./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios[root@Nagios nagios-plugins-2.1.1]# make && make install
Iv. nrpe plug-in Installation
[Root @ Nagios src] # wget javassrc] # tar zxf nrpe-2.15.tar.gz [root @ Nagios src] # cd nrpe-2.15 [root @ Nagios nrpe-2.15] #. /configure -- prefix =/usr/local/nagios [root @ Nagios nrpe-2.15] # make all [root @ Nagios nrpe-2.15] # make install-plugin [root @ Nagios nrpe-2.15] # make install -daemon [root @ Nagios nrpe-2.15] # make install -Daemon-config # Test start #/usr/local/nagios/bin/nrpe-c/usr/local/nagios/etc/nrpe. cfg-d # Comes with the boot script [root @ Nagios nrpe-2.15] # cp-rf init-script.in/etc/init. d/nrpe [root @ Nagios nrpe-2.15] # chmod a + x/etc/init. d/nrpe [root @ Nagios ~] #/Etc/init. d/nrpe start
Note: In fact, nagios obtains information through the/usr/local/nagios/libexec/check_nrpe script.
5. Configure and start the service
[Root @ Nagios ~] # Vi/usr/local/nagios/etc/objects/contacts. includefine contact {contact_name nagiosadmin use generic-contact alias Nagios Admin email ca0gu0@126.com} [root @ Nagios ~] # Vi/usr/local/nagios/etc/objects/commands. cfg define command {command_name check_nrpe command_line $ USER1 $/check_nrpe-H "$ HOSTADDRESS $"-c "$ ARG1 $"} [root @ Nagios ~] # Htpasswd-c/usr/local/nagios/etc/htpasswd. users nagiosadmin # Check whether the configuration file is correct [root @ Nagios ~] #/Usr/local/nagios/bin/nagios-v/usr/local/nagios/etc/nagios. cfg [root @ Nagios ~] # Chkconfig nagios on [root @ Nagios ~] # Service nagios start [root @ Nagios ~] # Chkconfig nrpe on [root @ Nagios ~] #/Etc/init. d/nrpe start [root @ Nagios ~] # Chkconfig httpd on [root @ Nagios ~] # Service httpd start [root @ Nagios ~] # Touch/var/www/html/index.html
6. Configure email sending
[Root @ Nagios ~] # Yum-y install mailx [root @ Nagios ~] # Echo "mail test" | mail-s test ca0gu0@126.com # If mail is not configured. by default, rc will use the local postfix to send an email # email send tools # nano/etc/mail. rc # set from = s0lence@126.com smtp = smtp.126.com # set smtp-auth-user = xx @ oo smtp-auth-password = xxoo # set smtp-auth = login
End !!!!!