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

Nagios+PNP installation and deployment

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

To download the relevant software packages required, the nagios version used in this article is 3.4.3 Magi NagiosMui plugins version 2.2.1 Magi NRPE version 2.15. Once you have configured the yum source, you can begin the following installation.

1. Install relevant software packages

# yum-y install gd fontconfig-devel libjpeg-devel libpng-devel gd-devel perl-GD openssl-devel php mailx postfix cpp gcc* libstdc++ glib2-devel libtoul-ltdl-devel httpd php*

Create nagios users and groups

# groupadd-g 6000 nagios#groupadd-g 6001 nagcmd#useradd-u 6000-g nagios-G nagcmd nagios

3. Compile and install nagios

# tar zxvf nagios-3.4.3.tar.gz#cd nagios#./configure-prefix=/usr/local/nagios-with-nagios-user=nagios-with-nagios-group=nagios-with-command-user=nagios-with-command-group=nagcmd-enable-event-broker-enable-nanosleep-enable-embedded-perl-with-perlcache#make all#make install#make install-init#make install-commandmode#make install-webconf#make install-config

4. Configure apache

1. Configure apache

Found in the configuration file / etc/httpd/conf/httpd.conf

DirectoryIndex index.html index.html.var

Modify it to:

DirectoryIndex index.html index.php

Add the following under the apache configuration file:

AddType application/x-httpd-php .php

two。 Set up user access control

# htpasswd-cm / usr/local/nagios/etc/htpasswd.users nagiosadmin

5. permission setting and starting service

# chown nagios:nagcmd / usr/local/nagios/etc/htpasswd.users#usermod-a-G nagios,nagcmd apache#service httpd restart

VI. Installation of Nagios plug-in

# tar zxvf nagios-plugins-2.2.1.tar.gz#cd nagios-plugins-2.2.1#./configure-- prefix=/usr/local/nagios-- with-nagios-user=nagios-- with-nagios-group=nagios#make all#make install#chmod 755 / usr/local/nagios#chkconfig httpd on;chkconfig nagios on#/usr/local/nagios/bin/nagios-v / usr/local/nagios/etc/nagios.cfg

VII. Disable selinux and iptables

# setenforce 0#service iptables status

8. Install rrdtool tools

# yum-y install cairo-devel libxml2-devel pango-devel pango libpng-devel freetype freetype-devel libart_lgpl-devel zlib* cgilib*#tar zxvf rrdtool-1.4.5.tar.gz#cd rrdtool-1.4.5#./configure-- prefix=/usr/local/rrdtool#make & & make install#/usr/local/rrdtool/bin/rrdtool-v

IX. Install PNP

1. Install PNP

# tar zxvf pnp4nagios-0.6.14.tar.gz#cd pnp4nagios-0.6.14#./configure-prefix=/usr/local/pnpnagios-with-nagios-user=nagios-with-nagios-group=nagios-with-rrdtool=/usr/local/rrdtool/bin/rrdtool#make all#make install#make install-webconf#make install-config#make install-init

two。 Configure PNP

1) modify the configuration file under / usr/local/pnpnagios/etc

# cp misccommands.cfg-sample misccommands.cfg#cp nagios.cfg-sample nagios.cfg#cp rra.cfg-sample rra.cfg

2) modify the configuration file under / usr/local/pnpnagios/etc/pages

# cd / usr/local/pnpnagios/etc/pages#cp web_traffic.cfg-sample web_traffic.cfg

3) modify the configuration file under / usr / local/pnpnagios/etc/check_commands

# cd / etc/local/pnpnagios/etc/check_commands#cp check_all_local_disks.cfg-sample check_all_local_disks.cfg#cp check_nrpe.cfg-sample check_nrpe.cfg#cp check_nwstat.cfg-sample check_nwstat.cfg

Then if service npcd start starts correctly, the installation is successful.

Configuration of 3.nagios

Modify the / usr/local/nagios/etc/objects/commands.cfg configuration file as follows:

Modify / usr/local/nagios/etc/objects/templates.cfg, which is as follows:

If you need to enable log debugging, modify the / usr/local/pnpnagios/etc/process_perfdata.cfg configuration file

LOG_LEVEL = 0

Change the number to 2. This enables the debugging function of the log.

Add nagios data output settings and modify nagios main configuration file / usr/local/nagios/etc/nagios.cfg:

.process _ performance_data=1host_perdata_command=process-host-perfdataservice_perfdata_command=process-service-perfdata.

Modify the / usr/local/nagios/etc/objects/localhost.cfg configuration file as follows:

.define host {. Use linux-server,hosts-pnp.}. Define service {use local-service Services-pnp host_name localhost service_description PING check_command checkmarks pingling 100.050. 050.

Verify the performance analysis icon function

Restart the ncpd,nagios,httpd service and type http://192.168.111.105/nagios/ in the browser. Login screen appears, user name: nagiosadmin; password: nagiosadmin. The following interface appears:

Click the small unstitching icon and the following interface appears:

To monitor the remote host, you need to install nrpe on the monitored host (192.168.111.114). The installation process is as follows:

# tar zxvf nrpe-2.15.tar.gz#cd nrpe-2.15#./configure-prefix=/usr/local/nagios-enable-command-args#make all#make install-plugin#make install-daemon#make install-daemon-config#make install-xinetd

Modify the / etc/hosts configuration file by adding the following two lines at the end of the file:

Nrpe 5666/tcpnrpe 5666/udp

Modify the / etc/xinetd.d/nrpe configuration file as follows:

Modify the IP after the only_from to the address of the monitoring host:

Only_from = 192.168.111.105

Start the xinetd service to see if port 5666 is listening:

# netstat-anp | grep 5666

Transfer the check_nrpe script from the monitored host to the monitoring host:

# scp / usr/local/nagios/libexec/check_nrpe root@192.168.111.105:/usr/local/nagios/libexec

The monitoring host operates as follows:

# / usr/local/nagios/libexec/check_nrpe-H 192.168.111.114 (test whether the monitored host nrpe is working properly)

Modify the commands.cfg file by adding the following:

Define a new monitored CVM, modify the localhost.cfg file, and add the following:

Check whether the nagios master configuration file is configured correctly, and restart the nagios service if there is no problem:

# / usr/local/nagios/bin/nagios-v / usr/local/nagios/etc/nagios.cfg#service nagios restart

Extensions (custom plug-ins, such as mysql)

1. Install mysql-server on the monitored host

# yum-y install mysql-server#service mysqld restart

two。 Establish a remotely connected user on the monitored host

Mysql > create user 'nagios'@192.168.111.114 identified by' 123 investors MySQL > flush privileges

3. Monitoring host installs mysql client program

# yum-y install mysql

4. Write plug-in check_mysql

#! / bin/bashmysql_user=nagiosmysql_password=123mysql_host=192.168.111.114if mysql-h $mysql_host-u $mysql_user-p$mysql_password-e "show databases" & > / dev/null then echo "mysql:OK" exit 0else echo "mysql:DOWN" exit 2fi

5. Modify script permissions

Chmod 755 check_mysql

6. Modify / usr/local/nagios/etc/objects/command.cfg

Define command {command_name check_mysql command_line $USER1 $/ check_mysql}

7. Modify / usr/local/nagios/etc/objects/localhost.cfg

Define service {. Service_description mysql. Check_command check_mysql.}

End of plug-in customization

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