In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail how to install Nagios in linux. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
1. Nagios server installation
1. Install the required dependency package
2. Add users and groups required by Nagios
3. Compile and install Nagios and create login Nagios WEB program users
4. Nagios-plugin (plug-in)
5. Configuration service self-starting
Second, configure Nagios to monitor Win host based on NRPE
1. The monitored end
Installation: NSClient++-0.3.9-x64
2. Monitoring end
1. Test connectivity with the monitored side
two。 The monitoring side defines commands, hosts, and services
3. Add the defined template to the nagios.cfg file
4. Restart the service
Third, monitor Linux host based on NRPE
1. The monitored end:
1. Add user
two。 Install the plug-in nagios-plugins-1.4.15
3. Install NRPE
4. Configure NRPE Profil
# vi / usr/local/nagios/etc/nrpe.cfg
5. Define nrpe startup scripts and increase permissions
6. Add self-startup
7. Start the service
2. Configure the monitoring end:
1. Install NRPE
After installation, generate check_nrpe and use this plug-in to test the monitored host
two。 Define command
3. Define hosts and services
4. Add the path to the defined linhost.cfg profile to / usr/localhost/etc/nagios.cfg
5. Test configuration file / usr/local/nagios/bin/nagios-v / usr/local/nagios/etc/nagios.cfg
6. Restart the service
7. Web page to check hosts monitoring status
* for other information about monitoring windows hosts based on NRPE, inquire about online information separately *
1. Install and configure Nagios
1. Solve the dependency of installing Nagios:
# yum-y install httpd gcc glibc glibc-common gd gd-devel php php-mysql mysql mysql-devel mysql-server
2. Add the users and groups needed for nagios to run:
# groupadd nagcmd
# useradd-G nagcmd nagios
# passwd nagios
# usermod-a-G nagcmd apache
3. Compile and install nagios:
# tar zxf nagios-3.3.1.tar.gz
# cd nagios-3.3.1
#. / configure-with-command-group=nagcmd-enable-event-broker
# make all
# make install
# make install-init
# make install-commandmode
# make install-config
# vi / usr/local/nagios/etc/objects/contacts.cfg
Emailnagios@localhost # this is the default setting
# make install-webconf
# htpasswd-c / usr/local/nagios/etc/htpasswd.users nagiosadmin
# service httpd restart
4. Compile and install nagios-plugins
# tar zxf nagios-plugins-1.4.15.tar.gz
# cd nagios-plugins-1.4.15
#. / configure-with-nagios-user=nagios-with-nagios-group=nagios
# make
# make install
5. Configure and start Nagios
# vi / usr/local/nagios/etc/nagios.cfg
# chkconfig-add nagios
# chkconfig nagios on
# / usr/local/nagios/bin/nagios-v / usr/local/nagios/etc/nagios.cfg
# service nagios start
6. Configure selinux
# getenforce
# setenforce 0
7. View nagios through the web interface:
Http://your_nagios_IP/nagios
You need to specify the web authentication account and password set above when you log in.
II. Configuration file
Main configuration file for Nagios
/ usr/local/nagios/etc/nagios.cfg
Nagios template configuration directory
/ usr/local/nagios/etc/objects
Call the check command directory / usr/local/nagios/libexec
Monitoring remote Win hosts based on NSClinet++
1. Installation and configuration of the monitored end
Install NSClient++-0.3.9-x64
2. Test whether it is connected
# cd / usr/local/nagios/libexec
#. / check_nt-H 192.168.1.119-v UPTIME-p 12489
If you have a password, then: #. / check_nt-H 192.168.1.119-v UPTIME-p 12489-s luoxj,123
3. Configure the monitoring end.
& define commands.cfg- definition commands
# cd / usr/local/nagios/etc/objects/
# vi commands.cfg
Define command {
Command_name check_nt
Command_line $USER1 $/ check_nt-H $HOSTADDRESS$-p 12489-v $ARG1 $$ARG2 $
}
& define hosts and services
# vi windows.cfg
Define host {
Use windows-server
Host_name winhost
Alias My Windows Host
Address 192.168.1.119
}
Define service {use generic-service host_name winhost service_description NSClient++ Version check_command checkntasking CLIENTVERSION} defines that the service can be renamed according to the actual situation and can be replaced in vim:., $s@winserver@winhost@g
& & enable the defined file and increase the path of the defined file
# vi / usr/local/nagios/etc/nagios.cfg
Cfg_file=/usr/local/nagios/etc/objects/windows.cfg
& & test to make sure there is nothing wrong with the configuration file
# / usr/local/nagios/bin/nagios-v / usr/local/nagios/etc/nagios.cfg-d
# service nagios restart
Monitoring remote Linux hosts based on NRPE
1. Installation and configuration of the monitored end
1) add nagios users first
# useradd-s / sbin/nologin nagios
2) NRPE depends on nagios-plugins, so you need to install it first
# tar zxf nagios-plugins-1.4.15.tar.gz
# cd nagios-plugins-1.4.15
#. / configure-with-nagios-user=nagios-with-nagios-group=nagios
# make all
# make instal
3) install NRPE
# tar-zxvf nrpe-2.12.tar.gz
# cd nrpe-2.12.tar.gz
#. / configure-with-nrpe-user=nagios\
-- with-nrpe-group=nagios\
-- with-nagios-user=nagios\
-- with-nagios-group=nagios\
-- enable-command-args\
-- enable-ssl
# make all
# make install-plugin
# make install-daemon
# make install-daemon-config
4) configure NRPE
# vim / usr/local/nagios/etc/nrpe.conf
Log_facility=daemon
Pid_file=/var/run/nrpe.pid
Server_address=172.16.100.11
Server_port=5666
Nrpe_user=nagios
Nrpe_group=nagios
Allowed_hosts=172.16.100.1
Command_timeout=60
Connection_timeout=300
Debug=0
& define the command of monitoring object &
Commanded [check _ users] = / usr/local/nagios/libexec/check_users-w 5-c 10
Commanded [check _ load] = / usr/local/nagios/libexec/check_load-w 15leg10 penny 5-c 30pyrmr25 penny 20
Commanded [check _ sda1] = / usr/local/nagios/libexec/check_disk-w 20%-c 10%-p / dev/sda1
Commanded [check _ zombie_procs] = / usr/local/nagios/libexec/check_procs-w 5-c 10-s Z
Commanded [check _ total_procs] = / usr/local/nagios/libexec/check_procs-w 150-c 200
5) start NRPE
# / usr/local/nagios/bin/nrpe-c / usr/local/nagios/etc/nrpe.cfg-d
To facilitate the startup of the NRPE service, you can define the following as a / etc/init.d/nrped script:
# vi / etc/init.d/nrped
#! / bin/bash
# chkconfig: 2345 88 12
# description: NRPE DAEMON
NRPE=/usr/local/nagios/bin/nrpe
NRPECONF=/usr/local/nagios/etc/nrpe.cfg
Case "$1" in
Start)
Echo-n "Starting NRPE daemon..."
$NRPE-c $NRPECONF-d
Echo "done."
Stop)
Echo-n "Stopping NRPE daemon..."
Pkill-u nagios nrpe
Echo "done."
Restart)
$0 stop
Sleep 2
$0 start
*)
Echo "Usage: $0 start | stop | restart"
Esac
Exit 0
# chmod + x / etc/init.d/nrped
# service nrped start
# netstat-tnlp # # check whether nrpe port 5666 is enabled
Tcp 0 0 0.0.0.0 5666 0.0.0.015 * LISTEN 17282/nrpe
# service iptables stop
# setenforce 0
6) configure objects that can be monitored by remote hosts
On the monitored side, the services or resources that can be monitored through NRPE need to be defined by using commands in the nrpe.conf file. The syntax format of the defined command is: command [] =. For example:
Commanded [check _ rootdisk] = / usr/local/nagios/libexec/check_disk-w 20%-c 10%-p /
Commanded [check _ swap] = / usr/local/nagios/libexec/check_disk-w 40%-c 20%
Commanded [check _ sensors] = / usr/local/nagios/libexec/check_sensors
Commanded [check _ users] = / usr/local/nagios/libexec/check_users-w 10-c 20
Commanded [check _ load] = / usr/local/nagios/libexec/check_load-w 10pm 8rem 5-c 20je 18je 15
Commanded [check _ zombies] = / usr/local/nagios/libexec/check_procs-w 5-c 10-s Z
Commanded [check _ all_procs] = / usr/local/nagios/libexec/check_procs-w 150-c 200
2. Configure the monitoring end
1) install NRPE
# tar-zxvf nrpe-2.12.tar.gz
# cd nrpe-2.12.tar.gz
#. / configure-with-nrpe-user=nagios\
-- with-nrpe-group=nagios\
-- with-nagios-user=nagios\
-- with-nagios-group=nagios\
-- enable-command-args\
-- enable-ssl
# make all
# make install-plugin
After the installation is complete, / usr/local/nagios/libexec/check_nrpe generates this plug-in to test whether the client is working properly
# cd / usr/local/nagios/libexec/
#. / check_nrpe-H 192.168.1.124
NRPE v2.12
2) define how to monitor remote hosts and services:
To monitor a remote Linux host through NRPE, you need to use the chech_nrpe plug-in. The syntax format is as follows:
Check_nrpe-H [- n] [- u] [- p] [- t] [- c] [- a]
Define commands to monitor remote Linux hosts:
# vi / usr/local/nagios/etc/objects/commands.cfg add nrpe command
Define command {
Command_name check_nrpe
Command_line $USER1 $/ check_nrpe-H $HOSTADDRESS$-c $ARG1 $
}
* create a template file *
# cd / usr/local/nagios/etc/objects/
# vim linhost.cfg or # cp localhost.cfg linhost.cfg
* define remote Linux hosts:
Define host {
Use linux-server
Host_name linhost
Alias my Linux Host
Address 192.168.1.124
}
Comment if the host group does not need it To add a service, you can refer to the command [check _ users] = / usr/local/nagios/libexec/check_users-w 5-c 10 command [check _ load] = / usr/local/nagios/libexec/check_load-w 15 command 10 usr/local/nagios/libexec/check_disk 5-c 30 sda1 25, 20 command [check _ sda1] = / usr/local/nagios/libexec/check_disk-w 20%-c 10%-p / dev/ sda1 command [check _ zombie_procs] = / usr/local / nagios/libexec/check_procs-w 5-c 10-s Zcommand [check _ total_procs] = / usr/local/nagios/libexec/check_procs-w 150-c 200 for detailed configuration service * define remote Linux service: you can also add parameters to set and monitor
Define service {
Use generic-service host_name linhost service_description check_users check_command check_nrpe!check_users} # Create a service for monitoring the uptime of the server
# Change the host_name to match the name of the host you defined abovedefine service {use generic-service host_name linhost service_description load check_command check_nrpe!check_load} # Create a service for monitoring CPU load
# Change the host_name to match the name of the host you defined abovedefine service {use generic-service host_name linhost service_description sda1 check_command check_nrpe!check_sda1} # Create a service for monitoring memory usage
# Change the host_name to match the name of the host you defined abovedefine service {use generic-service host_name linhost service_description Zombie check_command checknrpetual checkpointing zombiechecking procs} define service {use generic-service host_name linhost service_description Total procs check_command checkingnrpeaking checkpointing totalizing procs} 3) add the set linhost.cfg file to / usr/local/nagios/etc/nagios.cfg # vi / usr/local/nagios/etc/nagios.cfg
Cfg_file=/usr/local/nagios/etc/objects/linhost.cfg
4) Test the configuration file # / usr/local/nagios/bin/nagios-v / usr/local/nagios/etc/nagios.cfg5) restart the service # service nagios restart
This is the end of the article on "how to install Nagios in linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.