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

Web+nagios+nagiosql installation and deployment

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

Installation and configuration of nagios under Linux 1. Nagios client configuration 1. Install http and mysql# yum-y install httpdgettext mysql mysql-server mysql-devel php php-mysql php-pear php-mysql mysqlperl mysql-server perl-DBI perl-DBD-MySQL httpd gcc glibc glibc-common gdgd-devel php gcc automake autoconf libtool make

two。 Create nagios users and user groups # useradd-s / sbin/nologinnagios # useradd-s / sbin/nologinapache#echo "nagios" | passwd-- stdin nagios # groupadd nagcmd#usermod-G nagcmd nagios

3. Install the Nagios plug-in

Install the plugins plug-in before installing nrpe

1) install nagios-plugins# wget http://www.nagios-plugins.org/download/nagios-plugins-2.1.1.tar.gz# tar zxvf nagios-plugins-2.1.1.tar.gz# cd nagios-plugins-2.1.1#. / configure--prefix=/usr/local/nagios# make&& make install

2) install nrpe# wget-- no-check-certificate http://downloads.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz#tar xf nrpe-2.15.tar.gz# cd nrpe-2.15#. / configure & & make & & make install cp sample-config/nrpe.cfg.in / usr/local/nagios/etc/cp init-script / etc/init.d/nrpechmod + x / etc/init.d/ Nrpevim / usr/local/nagios/etc/nrpe.cfg allowed_hosts=192.168.104.60 command [check _ swap] = / usr/local/nagios/libexec/check_swap-w 20% Murc 10%

Service start

/ etc/init.d/nrpe restartservice nagios restartservice httpd restartservice mysqld restart

1. Install Nagios server 1. Basic support Kit: gcc glibc glibc-common gdgd-devel xinetd openssl-devel gettext automake autoconf libtool make#yuminstall-y gcc glibc glibc-common gdgd-devel xinetd openssl-devel gettext automake autoconf libtool make

two。 Create nagios users and user groups # useradd-s / sbin/nologinnagios # useradd-s / sbin/nologinapache#echo "nagios" | passwd-- stdin nagios# groupadd nagcmd#usermod-G nagcmd nagios#usermod-G nagcmd apache# mkdir-p / usr/local/nagios

Permissions to view the nagios directory

# ll-d / usr/local/nagios/

3. Compile and install Nagios# wget-- no-check-certificate https://sourceforge.net/projects/nagios-cn/files/sourcecode/zh_CN%203.2.3/nagios-cn-3.2.3.tar.bz2# tar xfnagios-cn-3.2.3.tar.bz2#cd nagios-cn-3.2.3#./configure-- prefix=/usr/local/nagios/-- with-nagios-user=nagios--with-nagios-group=nagios-- with-command-group=nagcmd

# make all

# makeinstall

# makeinstall-init

# makeinstall-commandmode

# makeinstall-config

# chkconfig--add nagios# chkconfig--level 35 nagios on# chkconfig--list nagios

1. Verify that the program is installed correctly

Change the directory to the installation path (here is / usr/local/nagios) to see if there are five directories: etc, bin, sbin, share, and var. If so, it indicates that the program is installed correctly on the system. The purpose of each directory of Nagios is described as follows:

The directory where the binNagios executable is located, the directory where the etcNagios configuration file is located, the directory where the file needed to execute the external command is located, the directory where the shareNagios web page file is located, the directory where the external plug-in is located, the directory where the varNagios log file, lock and other files are located, the directory where the var/archivesNagios log is automatically archived, the directory used to store the external command file 1. Install the Nagios plug-in

Install the plugins plug-in before installing nrpe

1) install nagios-plugins# wget http://www.nagios-plugins.org/download/nagios-plugins-2.1.1.tar.gz# tar zxvf nagios-plugins-2.1.1.tar.gz# cd nagios-plugins-2.1.1#. / configure--prefix=/usr/local/nagios# make&& make install

2) install nrpe

NRPE is an extension of the monitoring software nagios, which is used on the monitored server to provide some local information about the server to the nagios monitoring platform. For example, cpu load, memory usage, hard disk usage, and so on. NRPE can be called the for linux client of nagios.

# wget-- no-check-certificate http://downloads.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz#tar xf nrpe-2.15.tar.gz# cd nrpe-2.15#. / configure & & make & & make install3) install nagiosQL

NagiosQL is a web graphical management application specially designed for nagios. Its main function is to operate the database and configuration files, including writing the information of the configuration file to the database, modifying the monitoring configuration information of Nagios in the database, and updating the configuration stored in the database to the file. Users can modify the configuration intuitively through the Web page provided by NagiosQL. The implementation architecture is very simple and the function is very practical.

Introduction to Nagiosql features:

1. Have basic nagios configuration management capabilities, import and export configuration files

two。 Ability to check and troubleshoot nagios configuration files

3. Nagiosql can customize the file structure, continue the previous configuration structure, and generate the configuration according to IP

4. Nagiosql will make a configuration backup for each configuration change, save it with a timestamp as a suffix, and theoretically roll back to any historical configuration.

# wget-- no-check-certificate http://downloads.sourceforge.net/project/nagiosql/nagiosql/NagiosQL%203.1.1/nagiosql_311.tar.gz# tar xf nagiosql_311.tar.gz# cp-R nagiosql/ usr/local/nagios/nagiosql# mkdir-p/etc/nagiosql/ {hosts,services,backup/ {, hosts,services} Import} # chown-R apache:nagios / etc/nagiosql/# chmod-R 755 / etc/nagiosql# chmod 777 / usr/local/nagios/nagiosql/config# chown nagios:apache / usr/local/nagios/etc# chown nagios:apache / usr/local/nagios/etc/ {nagios.cfg,cgi.cfg} # chown nagios:apache / usr/local/nagios/etc/*# chmod 664 / usr/local/nagios/etc/ {nagios.cfg Cgi.cfg} # chmod 775 / usr/local/nagios/etc# chown nagios:apache / usr/local/nagios/bin/nagios# chmod 750 / usr/local/nagios/bin/nagios# chown-R apache.nagios / usr/local/nagios/var/spool/# chown nagios:apache / usr/local/nagios/var/rw/nagiosNaNd# chmod 660 / usr/local/nagios/var/rw/nagiosNaNd2. Install and configure http, mysql, and Phpls

Http and Php are not necessary to install nagios, but nagios provides a web monitoring interface, through which the running status of monitored hosts and resources can be clearly seen. Therefore, it is necessary to install a web service. It should be noted that after the nagios3.1.x version of nagios, php support is required when configuring the web monitoring interface. The version of nagios we downloaded here is nagios-cn-3.2.3, so after installing http, we also need to compile the php module.

Install http, mysql and php1) yum install # yum install-y httpd phpphp-mysql php-pear perl-DBD-MySQL perl perl-DBImysql mysql-server mysql-devel

2) configure http

Edit the file of nagios, path: / etc/httpd/conf.d/nagios.conf

# vim / etc/httpd/conf.d/nagios.confAlias/nagiosQL "/ usr/local/nagios/nagiosql" # SSLRequireSSL OptionsNone AllowOverrideNone Orderallow,deny Allowfrom all

Find the httpd.conf file, path: / etc/httpd/conf/httpd.con

# vim / etc/httpd/conf/httpd.con add the following: ScriptAlias/nagios/cgi-bin "/ usr/local/nagios/sbin" AuthType Basic Options ExecCGI AllowOverride None Order allow,deny Allow from all AuthName "Nagios Access" AuthUserFile/usr/local/nagios/etc/htpasswd.users Require valid-userAlias/nagios "/ usr/local/nagios/share" AuthType Basic Options None AllowOverride None Order allow Deny Allow from all AuthName "nagios Access" AuthUserFile/usr/local/nagios/etc/htpasswd.users Require valid-user3) start http, mysql, nagios services # service nagios restart# service httpd restart# service mysqld restart4) Registration Service # chkconfig nagios on# chkconfig httpd on# chkconfig mysqld on

5) establish the installation file of nagios

# touch/usr/local/nagios/nagiosql/install/ENABLE_INSTALLER6) manually install nagiosql

Open the browser: http:// native IP/nagiosQL

If the environment required for the test is passed, press the next step directly.

To configure the database, select the default.

Delete the installation directory and use the change permissions here:

# chmod 000/usr/local/nagios/nagiosql/install

1. NagioSQL configuration

The browser enters the local IP/nagiosQL of http://. Enter the user name and password.

Click manage-Domain-localhost--- to "modify"

Nagios base directory / usr/local/nagios/etc/

Import path / etc/nagiosql/import/

Nagios command file / usr/local/nagios/var/rw/nagiosNaNd

Nagios process file / usr/local/nagios/var/nagios.lock

Nagios profile / usr/local/nagios/etc/nagios.cfg

Tools-some configuration files are listed on the right side of the import data, and you can select Import.

Import only imports the contents of the configuration file into the Mysql database, and when using its configuration file, it is a cfg file, so the following is a write process

Tools-nagios control-write detection data-write other data

Check the profile successfully

After writing, you can see the corresponding cfg file to see if the write was successful.

Ls / etc/nagisql/

Vim/usr/local/nagios/etc/nagios.cfg comments all the beginning of cfg_file and then adds the following statement cfg_dir=/etc/nagiosql/hosts/ cfg_dir=/etc/nagiosql/services/cfg_file=/etc/nagiosql/commands.cfgcfg_file=/etc/nagiosql/contactgroups.cfgcfg_file=/etc/nagiosql/contacts.cfgcfg_file=/etc/nagiosql/contacttemplates.cfgcfg_file=/etc/nagiosql/hostdependencies.cfgcfg_file=/etc/nagiosql/hostescalations.cfgcfg_file=/etc/nagiosql/hostextinfo .cfgcfg _ file=/etc/nagiosql/hostgroups.cfgcfg_file=/etc/nagiosql/hosttemplates.cfgcfg_file=/etc/nagiosql/servicedependencies.cfgcfg_file=/etc/nagiosql/serviceescalations.cfgcfg_file=/etc/nagiosql/serviceextinfo.cfgcfg_file=/etc/nagiosql/servicegroups.cfgcfg_file=/etc/nagiosql/servicetemplates.cfgcfg_file=/etc/nagiosql/timeperiods.cfg

Check the nagios configuration file

/ usr/local/nagios/bin/nagios-v/usr/local/nagios/etc/nagios.cfg restart nagios/etc/init.d/nagios restart2. NagioSQL add Monitoring Host

1. Log in to the nagiosqlweb administration interface

Browsers access 192.168.200.166/nagiosQL

two。 Add command

Click Command-define-add, and then enter the command you want to add.

1) add nrpe command

2) add monitoring host

Enter the nagiosQL management console to supervise-host- add

Such as: add a host for test, and add the following

Note: after saving the host configuration, you also need to click the write button, otherwise it will not be valid.

3) add monitoring services

Supervision-Services-add

The contents of the service are as follows:

Configuration name: imp_check_swap / / Note: the configuration name here must be the same as the configuration file name of the relevant project of the monitored host

Service description: linux_swap / / Custom

Check the command: check_nrpe / / previously defined command

$ARG1 $: the command defined by check_swap// in the monitored host

Click the Save button to add the finish remember points to write the configuration.

Then associate the custom service on the CVM, as shown in the figure below:

Find the monitored host that has been added in the Supervisor-host option. The monitored host here is test. Click modify later.

Note: don't forget the write operation, otherwise it will be invalid.

4) finally restart the service, and the configuration file takes effect.

3. Check the nagios monitoring interface to verify the monitoring effect.

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

Database

Wechat

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

12
Report