Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does Nagios monitor the server

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "Nagios how to monitor the server", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn this article "how Nagios monitors the server".

Nagios is a monitoring system that monitors the running status and network information of the system. Nagios can monitor specified local or remote hosts and services, while providing exception notification functions and other Nagios can run on the Linux/Unix platform, while providing an optional browser-based WEB interface to facilitate system administrators to view network status, various system problems, logs, and so on.

1. The main functions and features of Nagios:

Monitor network services (SMTP, POP3, HTTP, NNTP, PING, etc.)

Monitor host resources (processes, disks, etc.)

Simple plug-in design can easily extend the monitoring function of Nagios

Concurrent processing of monitoring such as services

Prepare the package:

Nagios Core nagios-3.2.2.tar.gz

Nagios Plugins nagios-plugins-1.4.15.tar.gz

Nagios Addons nrpe-2.12.tar.gz

Server-side installation

Check the installation server environment (LAMP) # rpm-qa | grep httpd # rpm-qa | if grep php does not have it, install # yum-y install gcc glibc glibc-common gd gd-devel php openssl-devel httpd create user: # useradd-m-s / bin/bash nagios # groupadd nagios # usermod-G nagios nagios # vi / etc/passwd nagios:x:500:500::/home/nagios:/sbin/nologin change to: nagios:x:500:500::/home/nagios: / bin/bash creates a user group named nagcmd to execute external commands from the Web interface. Add both nagios and apache users to this group. Because we are using the Web monitoring panel of CGI, we will also add a nagcmd group for CGI to execute the relevant instructions. # / usr/sbin/groupadd nagcmd # / usr/sbin/usermod-G nagcmd nagios # / usr/sbin/usermod-a-G nagcmd daemon (since apache is installed in compiled mode, it runs as daemon user by default)

To download the relevant software packages, the server needs to install the following three packages, and the client only needs to install the last two plug-in packages:

[root@server ~] # cd / usr/local/src/tarbag/ [root@server tarbag] # wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.2.tar.gz [root@server tarbag] # wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz [root@server tarbag] # wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.12.tar.gz

Extract and compile and install Nagios:

# tar xvzf nagios-3.2.2.tar.gz # cd nagios-3.2.2

Run the Nagios configuration script and use the previously opened users and user groups:

#. / configure-prefix=/usr/local/nagios-with-command-group=nagcmd

Compile the Nagios package source code:

# make all

Install the binary runtime, initialize the script, configure the sample file, and set the permissions for the run directory:

# make install # make install-init / / install the startup script # make install-config / / install the sample configuration file in / etc/rc.d/init.d. The installation path is / usr/local/nagios/etc # make install-commandmode / / configuration directory permissions # ls / usr/local/nagios/ bin etc libexec sbin share var

Third, configure nagios

The sample configuration files are installed in this directory / usr/local/nagios/etc by default. These sample files can be configured for Nagios to work properly with a simple modification.

Use the editor software you are good at to edit this / usr/local/nagios/etc/objects/contacts.cfg configuration file and change the EMail information in the contact definition information of the email address nagiosadmin to your EMail message to receive the alarm content.

Vi / usr/local/nagios/etc/objects/contacts.cfg

1. Install the nagios plug-in

# cd.. / # tar zxvf nagios-plugins-1.4.16.tar.gz # cd nagios-plugins-1.4.16 #. / configure-- with-nagios-user=nagios-- with-nagios-group=nagios-- prefix=/usr/local/nagios/ specify the installation directory and users and groups # make Make install configuration httpd generates Nagios's Apache configuration file # cd nagios-3.2.2 # make install-webconf / usr/bin/install-c-m 644 sample-config/httpd.conf / etc/httpd/conf.d/nagios.conf # cd sample-config reference sample-config/httpd.conf configuration content added to Apache's httpd.conf configuration file to create a nagiosadmin user's Apache interface login for Nagios. Write down the login password you have set, and you will use it later. #. / htpasswd-c / usr/local/nagios/etc/htpasswd.users nagiosadmin password: nagiosmonitor restarts the Apache service to make the settings take effect. Install the NRPE plug-in, and to get more detailed information on the client, you must also install the NRPE plug-in on the server and client. # cd.. # tar zxvf nrpe-2.14.tar.gz # cd nrpe-2.14 #. / configure-with-nagios-user=nagios-with-nagios-group=nagios-prefix=/usr/local/nagios/ # make all # make install-plugin;make install-daemon;make install-daemon-config # ls / usr/local/nagios/libexec/ check_apt check_ftp check_mailq check_overcr check_tcp. Verify the sample configuration file # / usr/local/nagios/bin/nagios-v / usr/local/nagios/etc/nagios.cfg of Nagios. If no error is reported, you can start the Nagios service to start httpd and nagios services and verify # chkconfig-add nagios/ / set nagios and http boot self-startup # chkconfig nagios on # chkconfig httpd on # service nagios start # service httpd start

2. Client installation

# useradd-s / sbin/nologin nagios/ / add nagios user installation nagios-plugins # tar-zxvf nagios-plugins-1.4.15.tar.gz # cd nagios-plugins-1.4.15 #. / configure-- prefix=/usr/local/nagios # make # make install # chown nagios.nagios / usr/local/nagios/ # chown-R nagios.nagios / usr/local/nagios/libexec/ install nrpe plugin # tar-zxvf nrpe-2.12.tar.gz # cd Nrpe-2.12 #. / configure-- prefix=/usr/local/nagios/ # make all # make install-plugin install check_nrpe this plugin # make install-daemon install daemon # make install-daemon-config installation configuration file if the installation times is wrong: checking for SSL headers... Configure: error: Cannot find ssl headers # rpm-qa | grep openssl openssl-devel-0.9.8e-12.el5_4.6 openssl-0.9.8e-12.el5_4.6 yum install openssl-devel or download: http://www.openssl.org/source/ tar zxvf openssl-1.0.0a.tar.gz cd openssl-1.0.0a. / config make make test make install modify the client configuration file vi / usr/local/nagios/etc/nrpe.cfg server_ Port:5666 allowed_hosts=127.0.0.1 192.168.1.95 / add the server-side IP address specifies the nagios monitoring host ip, and multiple ip are separated by commas. The following IP address is the ip address of the nagios server, that is, only the specified ip is allowed to obtain local information through port 5666 opened by nrpe. Then modify the command part of the nrpe.cfg. Start the NRPE daemon: (you can add this command to / etc/rc.local so that boot starts automatically) # / usr/local/nagios/bin/nrpe-c / usr/local/nagios/etc/nrpe.cfg-d can add this command to / etc/rc.local In order to boot echo "/ usr/local/nagios/bin/nrpe-c / usr/local/nagios/etc/nrpe.cfg-d" > > / etc/rc.local # netstat-utpln | grep nrpe / / check whether the nrpe process has been started normally # / usr/local/nagios/libexec/check_nrpe-H 127.0.0.1 NRPE v2.14 / / nrpe test results The result is that nrpe has worked normally, and then test # / usr/local/nagios/libexec/check_nrpe-H 192.168.1.77ash on the nagios monitoring server / ip return information of the monitored host NRPE version installed on the monitored server: NRPE v2.123, define the monitoring content

# vi / usr/local/nagios/etc/nrpe.cfg / / define the monitoring server content command [check _ users] = / usr/local/nagios/libexec/check_users-w 5-c 10 # monitor the number of users logged in [check _ load] = / usr/local/nagios/libexec/check_load-w 1510 load 5-c 30pm 2510 # Monitoring CPU load command [check _ command] = / check-w 20%-c 10 %-p / dev/sda2 # monitors disk utilization The sda2 here must be the actual hard disk partition You can use fdisk-l to check the command [check _ swap] = / usr/local/nagios//libexec/check_swap-w 20-c 10 # to monitor the swap space command [check _ zombie_procs] = / usr/local/nagios/libexec/check_procs-w 5-c 10-s Z # to monitor the zombie process command [check _ total_procs] = / usr/local/nagios/libexec/check_procs-w 150-c 200 # to monitor all processes Note: The content in parentheses after command is the defined variable. The variable name can be specified at will, as long as it is consistent with the server configuration file, it can be all the contents of the article "how Nagios monitors the server". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report