Nagios Monitoring Installation II

Source: Internet
Author: User
Tags install perl pkill

Monitor 80-Port 3306-Port passwd file changes
Experiment Description: The environment is a host Linux CentOS release 6.5 (Final) 192.168.0.22 open httpd 80 port 3306 Port
One, prepare before starting the installation:
1. Installing Nagios Server Software
A,nagios-3.5.1.tar.gz
B,nagios-plugins-1.4.16.tar.gz
C,nrpe-2.12.tar.gz
2. Configure Environment variables:
[Email protected]]# echo ' Export lc_all=c ' >>/etc/profile
[Email protected]]# tail-1/etc/profile
Export Lc_all=c
[Email protected]]# Source/etc/profile
3, turn off firewall and SELinux
[[email protected]]#/etc/init.d/iptables stop
[Email protected]]#/etc/init.d/iptables status
Iptables:firewall is not running.
[Email protected]]# chkconfig iptables off
[Email protected]]# chkconfig--list iptables
Iptables 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[[email protected]] #sed –i ' s/selinux=enforce/selinux=disabled/g '/etc/sysconfig/selinux
4, solve the system time synchronization problem
[Email protected] ~]# yum-y install Ntpdate
[Email protected] ~]# CRONTAB-E
#time sync by Tony at 2018-01-29
/5 */usr/sbin/ntpdate pool.ntp.org >/dev/null 2>&1
Second, the official installation of Ngios
Need a lamp environment
[Email protected] ~]# yum-y install gcc glibc glibc-common
[Email protected] ~]# yum-y install GD gd-devel
[Email protected] ~]# yum-y install Mysql-server
[[email protected] ~]# yum-y install httpd php php-gd
Create the users and groups required on the Nagios server side
[Email protected] ~]#/usr/sbin/useradd Nagios
[Email protected] ~]#/usr/sbin/useradd apache-m-s/sbin/nologin
[Email protected] ~]#/usr/sbin/groupadd nagcmd
[Email protected] ~]#/usr/sbin/usermod-a-G nagcmd Nagios
[Email protected] ~]#/usr/sbin/usermod-a-G nagcmd Apache
Check if user creation is successful
[Email protected] ~]# id-n-G Nagios
[Email protected] ~]# id-n-G Apache
[email protected] ~]# groups Nagios
[email protected] ~]# groups Apache
Start the service to view the communication port
[[email protected] ~]#/etc/init.d/httpd start
[Email protected] ~]# lsof-i:80
[[email protected] ~]#/etc/init.d/mysqld start
[Email protected] ~]# lsof-i:3306
To configure the Hosts file parsing:
[Email protected] ~]# cat/etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
:: 1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.0.22 Nagios-server
Third, install Nagios-server service end
[Email protected] ~]# Cd/soft/nagios
[Email protected] nagios]# Tar XF nagios-3.5.1.tar.gz
[[Email protected] nagios]# CD Nagios
[Email protected] nagios]#/configure--with-command-group=nagcmd
[[email protected] nagios]# make all
[[email protected] nagios]# make install
[email protected] nagios]# make Install-init
[email protected] nagios]# make Install-commandmode
After creating the Nagiosweb monitoring interface, you will need to enter your username and password when you log in, respectively, Tony and hwg123
[Email protected] nagios]# htpasswd-bc/usr/local/nagios/etc/htpasswd.users Tony Hwg123
[Email protected] nagios]# cat/usr/local/nagios/etc/htpasswd.users
Tony:fr58UrsZgK.Tc
Check the authorization file
[[email protected] nagios]# grep authuserfile/etc/httpd/conf.d/nagios.conf
Reload the httpd service
[Email protected] nagios]#/etc/init.d/httpd Reload
To modify a contact mailbox:
[Email protected] ~]# cd/usr/local/nagios/etc/objects/
[Email protected] objects]# vim contacts.cfg
Modify Line 35:
email [email protected]
[[email protected] objects]#/etc/init.d/postfix start
[Email protected] objects]# lsof-i:25
[Email protected] objects]# chkconfig postfix on
[Email protected] objects]# chkconfig--list postfix
Enter Http://IP/nagios on the browser and enter tony,hwg123
Go to Web browser interface configuration
To install the Nagios-server server-side plug-in package:
[Email protected] objects]# yum-y install Perl-devel openssl-devel
[Email protected] objects]# cd/soft/nagios/
[Email protected] nagios]# Tar XF nagios-plugins-1.4.16.tar.gz
[Email protected] nagios]# CD nagios-plugins-1.4.16
[Email protected] nagios-plugins-1.4.16]#/configure--with-nagios-user=nagios--with-nagios-group=nagios-- Enable-perl-modules--with-mysql
[[email protected] nagios-plugins-1.4.16]# make
[[email protected] nagios-plugins-1.4.16]# make install
[Email protected] nagios-plugins-1.4.16]# ls/usr/local/nagios/libexec/|wc-l
To install the Nrpe plugin:
[Email protected]]# cd/soft/nagios/
[Email protected]]# Tar XF nrpe-2.12.tar.gz
[Email protected]]# CD nrpe-2.12
[Email protected] nrpe-2.12]#./configure
[[email protected] nrpe-2.12]# make all
[email protected] nrpe-2.12]# make Install-plugin
[email protected] nrpe-2.12]# make Install-daemon
[email protected] nrpe-2.12]# make Install-daemon-config
[Email protected] libexec]# ls/usr/local/nagios/libexec/|wc-l
[Email protected] libexec]# chkconfig Nagios on
[Email protected] libexec]# chkconfig--list Nagios
[Email protected] libexec]# echo "/etc/init.d/nagios start" >>/etc/rc.local
[Email protected] libexec]# tail-1/etc/rc.local
[Email protected] libexec]#/etc/init.d/nagios checkconfig
[Email protected] libexec]#/usr/local/nagios/bin/nagios-v/usr/local/nagios/etc/nagios.cfg
[Email protected] libexec]#/etc/init.d/nagios checkconfig
Iv. Configuration Services (I am here to monitor myself)
[Email protected] etc]# vim nagios.cfg +32

Cfg_file=/usr/local/nagios/etc/objects/commands.cfg
Cfg_file=/usr/local/nagios/etc/objects/contacts.cfg
Cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg
Cfg_file=/usr/local/nagios/etc/objects/templates.cfg
Cfg_file=/usr/local/nagios/etc/objects/hosts.cfg
Cfg_file=/usr/local/nagios/etc/objects/services.cfg

#cfg_file =/usr/local/nagios/etc/objects/localhost.cfg
Add Cfg_file=/usr/local/nagios/etc/objects/hosts.cfg and Cfg_file=/usr/local/nagios/etc/objects/services.cfg
Note the line cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
[Email protected] nagios-server]# cat/usr/local/nagios/etc/objects/hosts.cfg
Define Host{
Use Linux-server
HOST_NAME 22-nagios-server
Alias 22-nagios
Address 192.168.0.22
}

Define Hostgroup{
Hostgroup_name linux-servers
Alias Linux Servers
Members 22-nagios-server
}
[Email protected] nagios-server]# cat/usr/local/nagios/etc/objects/services.cfg
Define Service{
Use Generic-service
HOST_NAME 22-nagios-server
Service_description HTTP
Check_command check_http
notifications_enabled 0
}

Define Service{
Use Generic-service
HOST_NAME 22-nagios-server
Service_description bolg_port_80
Check_command check_tcp!80
Max_check_attempts 3
Normal_check_interval 2
Retry_check_interval 1
Check_period 24x7
Notification_interval 30
Notification_period 24x7
Notification_options W,u,c,r
Contact_groups Admins
}

Define Service{
Use Generic-service
HOST_NAME 22-nagios-server
Service_description bolg_port_3306
Check_command check_tcp!3306
Max_check_attempts 3
Normal_check_interval 2
Retry_check_interval 1
Check_period 24x7
Notification_interval 30
Notification_period 24x7
Notification_options W,u,c,r
Contact_groups Admins
}

Define Service{
Use Generic-service
HOST_NAME 22-nagios-server
Service_description Passwd
Check_command check_passwd
notifications_enabled 0
}

[Email protected] nagios-server]# cat/usr/local/nagios/etc/objects/commands.cfg

# ' check_passwd ' command definintion
Define Command{
Command_name check_passwd
Command_line $USER 1$/check_passwd-h $HOSTADDRESS $-C $ARG 1$
}
[Email protected] nagios-server]#/usr/local/nagios/bin/nagios-v/usr/local/nagios/etc/nagios.cfg
[Email protected] Nagios-server]#/etc/init.d/nagios Reload

This is done by adding a host, adding a service, and then adding a command, and checking the configuration to finally reload the Nagios service.
Note: Possible failures (some are about Nrpe errors)
1, when logging on to the Web interface, prompt error:
Solution: Vim/usr/local/nagios/etc/cgi.cfg All about nagiosadmin to your own added user name, restart the service.
2,command ' check_passwd ' not define
Solution: To/usr/local/nagios/etc/objects/commands.cfg it is OK.
3,connction Refurse Host
Solution: First cd/usr/local/nagios/libexec under, use./check_nrpe-h 192.168.0.150-c check_ping or./check_nrpe-h 127.0.0.1-c Check_pin G
If you are still prompted Connction Refurse host, next look at Nrpe there is no boot: netstat-lntup |grep Nrpe if no boot execution
/usr/local/nagios/bin/nrpe-c/usr/local/nagios/etc/nrpe.cfg-d then executes./check_nrpe-h 192.168.0.150-c check_ping
4,nrpe command ' Check_disk ' not define
Solution: First Ps-ef |grep Nrpe
Pkill Nrpe
/usr/local/nagios/bin/nrpe-c/usr/local/nagios/etc/nrpe.cfg-d
Ps-ef |grep Nrpe
Then get the./check_nrpe-h 192.168.0.150-c Check_disk
5,check_nrpe:error-could not complete SSL handshake.
Resolution: Vi/usr/local/nagios/etc/nrpe.cfg +79
allowed_hosts=127.0.0.1,192.168.0.22
Ps-ef |grep Nrpe
Pkill Nrpe
/usr/local/nagios/bin/nrpe-c/usr/local/nagios/etc/nrpe.cfg-d
Ps-ef |grep Nrpe
6,nrpe:unable to read output
FIX:./check_nrpe-h 192.168.0.150-c Check_emm If you are prompted nrpe:unable to read output and then
Directly to the inside/usr/local/nagios/libexec/check_memory.pl-w 6%-C 3% If prompted permission denied
Description/usr/local/nagios/libexec/check_memory.pl-w 6%-C 3% does not have permission to execute
chmod +x/usr/local/nagios/libexec/check_memory.pl-w 6%-C 3%

Nagios Monitoring Installation II

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.