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

Integration of building nagios+nconf+cacti+npc in production environment

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

Share

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

System: CentOS6.5 kernel version system: 2.6.32-431.23.3.el6.x86_64

Close iptables, selinux

Chkconfig iptables off

Preparation before installation

Yum install-y httpd-* mysql-* php-* net-snmp* gcc glibc glibc-common gd gd-devel openssl*

First, the construction of nagios environment

1. Install nagios

Useradd nagios

Tar zxf nagios-3.2.0.tar.gz

Cd nagios-3.2.0

. / configure-prefix=/var/www/html/nagios

Make all

Make install & make install-init & & make install-commandmode & & make install-config & & make install-webconf

two。 Install nagios in Chinese

This is relatively simple. It's like patching.

Tar zxf nagios-cn-3.2.0.tar.bz2

Cd nagios-cn-3.2.0

. / configure-prefix=/var/www/html/nagios

Make all

Make install & make install-init & & make install-commandmode & & make install-config & & make install-webconf

3. Add nagios login authentication file, be sure to use the default nagiosadmin as the user

Htpasswd-c / var/www/html/nagios/etc/htpasswd.users nagiosadmin

* otherwise, the file / var/www/html/nagios/etc/cgi.cfg needs to be modified.

Vi / etc/nagios/cgi.cfg

Authorized_for_system_information=nagiosadmin

Authorized_for_configuration_information=nagiosadmin

Authorized_for_system_commands=nagiosadmin

Authorized_for_all_services=nagiosadmin

Authorized_for_all_hosts=nagiosadmin

Authorized_for_all_service_commands=nagiosadmin

Authorized_for_all_host_commands=nagiosadmin

4. Install the plug-in:

Tar xf nagios-plugins-1.4.14.tar.gz

Cd nagios-plugins-1.4.14

. / configure-prefix=/var/www/html/nagios/

Make

Make install

5. Add the user running Apache to the nagios group so that Apache has permission to read the file

Usermod-G nagios apache # # adds apache users to the nagios group.

6. Stage testing

Chown nagios.nagios / var/www/html/nagios/-R

Service httpd restart

Chkconfig httpd on

/ etc/init.d/nagios start

* ask http://IP/nagios to see if the account password is correct

Second: the construction of cacti environment

Installation of 1.rrdtool

What needs to be installed here is: rrdtool,rrdtool-devel.rrdtool-perl,rrdtool-php, rrdtool-python. The version of rrdtools I use is 1.3.8-7.el6.x86_64. Since I am using rrdtool in Aliyun yum, I will install it directly by yum install rrdtool*.

Rrdtool-devel-1.3.8-7.el6.x86_64

Rrdtool-perl-1.3.8-7.el6.x86_64

Rrdtool-1.3.8-7.el6.x86_64

Rrdtool-php-1.3.8-7.el6.x86_64

Rrdtool-python-1.3.8-7.el6.x86_64

If you don't download it yourself. After the download is complete, the local yum is installed. (there are 1.4 in Baidu Cloud)

Yum localinstall-y-nogpgcheck rrdtool-*

Service mysqld start

two。 Configure snmp

Vim / etc/snmp/snmpd.conf

Com2sec notConfigUser 127.0.0.1 public

Access notConfigGroup "" any noauth exact all none none

View all included. 1 80

* the first two lines are modified and the last line is uncommented

Service snmpd restart

Snmpwalk-v 1-c public localhost IP-MIB::ipAdEntIfIndex

IP-MIB::ipAdEntIfIndex.127.0.0.1 = INTEGER: 1

IP-MIB::ipAdEntIfIndex.xxx.xxx.xxx.xxx = INTEGER: 2

IP-MIB::ipAdEntIfIndex.xxx.xxx.xxx.xxx = INTEGER: 3

If the above information is displayed, the snmp configuration is successful, and the xxx.xxx.xxx.xxx will vary according to your local IP information configuration.

3. Install cacti

Cacti-0.8.7e-cn-utf8.tar.gz

Mv cacti-0.8.7e-cn-utf8 / var/www/html/cacti

4. Create a cacti database

# mysql

Mysql > create database cacti default character set utf8; / / Database character set set utf8, otherwise garbled

Mysql > grant all privileges on cacti.* to cacti@localhost identified by 'cacti' with grant option

Mysql > flush privileges

5. Import the table contents of cacti into the database you created

Cd / var/www/html/cacti

Mysql-ucacti-pcacti cacti

< cacti.sql 6.编辑.php文件,以适应环境。 vim /var/www/html/cacti/include/config.php 修改内容如下 $database_type = "mysql"; $database_default = "cacti"; $database_hostname = "localhost"; $database_username = "cacti"; $database_password = "cacti"; useradd -r -M cacti chown -R cacti /var/www/html/cacti/rra/ chown -R cacti /var/www/html/cacti/log/ 7.在cacti用户下创建计划任务以画图 vim /etc/crontab */5 * * * * root php /var/www/html/cacti/poller.php &>

/ dev/null

Php / var/www/html/cacti/poller.php > / dev/null 2 > & 1

8. Install the Chinese font or the image text will be garbled.

Mkdir / ttf

Mv ttf-arphic-ukai_0.2.20080216.1.orig.tar.gz / ttf

Cd / ttf

Tar xf ttf-arphic-ukai_0.2.20080216.1.orig.tar.gz

Mv ukai.ttc / usr/share/fonts/ukai.ttc

Rm-rf / ttf

9. Launch cacti from the web page, install, and view the graphical interface

Control Panel > Devices > Native > SNMP options > SNMP version Select version 1 > Save

Control Panel > Settings > path > RRDTool default Font path / usr/share/fonts/ukai.ttc > Save

If the configuration is correct, our cacti will have data every few minutes, as shown in the figure. You can also manually execute the following command to generate rrd images manually.

Php / var/www/html/cacti/poller.php

SNMP version number

Font path

Charts in Chinese

Three: install cacti-spine

1. Installation of cacti-spine

Because the default cmd.php is used to poll data, the speed will be very slow, especially when there are many monitoring nodes, cmd.php is even more insufficient, so we use Spine to poll data. Cacti-spine is an engine developed by C language to replace the fast acquisition speed of cmd.php.

Tar xf cacti-spine-0.8.7e.tar.gz

Cd cacti-spine-0.8.7e

. / configure

# make & & make install

Vi / usr/local/spine/etc/spine.conf

The modifications are as follows:

DB_Host localhost

DB_Database cacti

DB_User cacti

DB_Pass cacti

DB_Port 3306

/ usr/local/spine/bin/spine

Echo / usr/local/spine/bin/spine > > / etc/rc.d/rc.local

* if you are directly successful, then congratulations, please read the 2.cacti-spine app directly, if there is an error *

[root@iZ2314cchhjZ cacti-spine-0.8.7e] #. / configure

Configure: error: cannot run / bin/sh config/config.sub

[root@iZ2314cchhjZ cacti-spine-0.8.7e] #

Resolution steps

Cd cacti-spine-0.8.7e/config

Ll-h

Rm-rf config.guess config.sub ltmain.sh

Ln-s-f / usr/share/libtool/config/config.sub config.sub

Ln-s-f / usr/share/libtool/config/config.guess config.guess

Ln-s-f / usr/share/libtool/config/ltmain.sh ltmain.sh

Cd..

. / configure

Make

Make install

Vi / usr/local/spine/etc/spine.conf

The modifications are as follows:

DB_Host localhost

DB_Database cacti

DB_User cacti

DB_Pass cacti

DB_Port 3306

/ usr/local/spine/bin/spine

Echo / usr/local/spine/bin/spine > > / etc/rc.d/rc.local

* if your make is successful, please ignore it here *

At this time, your make reported an error, because you may not have installed libtool or the version of libtool does not match.

. / libtool: line 467: CDPATH: command not found

. / libtool: line 1145: func_opt_split: command not found

Libtool: Version mismatch error. This is libtool 2.2.6b, but the

Libtool: definition of this LT_INIT comes from an older release.

Libtool: You should recreate aclocal.m4 with macros from libtool 2.2.6b

Libtool: and run autoconf again.

Make: * * [spine] error 63

First check to see if you have installed libtool. If not, yum install libtool* and then try again.

If it doesn't work,

[root@iZ2314cchhjZ cacti-spine-0.8.7e] # autoreconf-force-install

[root@iZ2314cchhjZ cacti-spine-0.8.7e] # make

Make install

Vi / usr/local/spine/etc/spine.conf

The modifications are as follows:

DB_Host localhost

DB_Database cacti

DB_User cacti

DB_Pass cacti

DB_Port 3306

/ usr/local/spine/bin/spine

Echo / usr/local/spine/bin/spine > > / etc/rc.d/rc.local

Application of 2.cacti-spine

Control Panel > Settings > path > Spine Poller path / usr/local/spine/bin/spine

Control Panel > Settings > Poller > Poller Type spine

Fourth: integrate Nagios and Cacti

1. Download and install ndoutils

Tar zxvf ndoutils-1.4b9.tar.gz

Cd ndoutils-1.4b9

. / configure-prefix=/var/www/html/nagios-enable-mysql-disable-pgsql-with-mysql-inc=/usr/include/mysql-with-mysql-lib=/usr/lib/mysql

Make

two。 Prepare the configuration file

Cp-v src/ {ndomod-3x.o,ndo2db-3x,file2sock,log2ndo} / var/www/html/nagios/bin

Cd db

. / installdb-ucacti-pcacti-hlocalhost-d cacti

Cd..

Cp-v config/ {ndo2db.cfg-sample,ndomod.cfg-sample} / var/www/html/nagios/etc

Mv / var/www/html/nagios/etc/ndo2db.cfg-sample / var/www/html/nagios/etc/ndo2db.cfg

Mv / var/www/html/nagios/etc/ndomod.cfg-sample / var/www/html/nagios/etc/ndomod.cfg

Chmod 644 / var/www/html/nagios/etc/ndo*

Chown nagios.nagios / var/www/html/nagios/etc/*

Chown nagios.nagios / var/www/html/nagios/bin/*

3. Modify the nagios.cfg configuration file to suit the current environment

Vim / var/www/html/nagios/etc/nagios.cfg

# add:

Broker_module=/var/www/html/nagios/bin/ndomod-3x.o config_file=/var/www/html/nagios/etc/ndomod.cfg

# check

Event_broker_options=-1 # # enable event broker for Nagios

4. Modify ndo2db.cfg to adapt to the current environment

Vim / var/www/html/nagios/etc/ndo2db.cfg

# ensure that the following items are unique

Socket_type=unix

Db_servertype=mysql

Db_host=localhost

Db_port=3306

Db_name=cacti

Db_prefix=nagios_

Db_user=cacti

Db_pass=cacti

5. Modify ndomod.cfg to adapt to the current environment

Vim / var/www/html/nagios/etc/ndomod.cfg

# ensure that the only content of the following is

Output_type=unixsocket

Output=127.0.0.1

6. Add a startup process for ndo2db

Cp. / daemon-init / etc/init.d/ndo2db

Vim / etc/init.d/ndo2db

# and modify Ndo2dbBin to the following values:

Ndo2dbBin=/var/www/html/nagios/bin/ndo2db-3x

Chmod + x / etc/init.d/ndo2db

7. Start the daemon and nagios

Service ndo2db start

Tail-20 / var/log/messages # # check to see if there are any errors. If there is no error, please continue.

Service nagios restart

Fifth: install the cacti-plugin plug-in management

The Cacti-Plugin installation process is as follows:

Gunzip cacti-plugin-0.8.7e-PA-v2.5-cn-utf8.diff.gz

Mv cacti-plugin-0.8.7e-PA-v2.5-cn-utf8.diff / var/www/cacti/

Cd / var/www/html/cacti

Mysql-ucacti-pcacti cacti

< pa.sql patch -p1 -N < cacti-plugin-0.8.7e-PA-v2.5-cn-utf8.diff 如果你的cacti访问时候是使用http://ip/cacti,你需要修改/var/www/cacti/include/global.php 修改如下: $database_type = "mysql"; $database_default = "cacti"; $database_hostname = "localhost"; $database_username = "cacti"; $database_password = "cacti"; $database_port = "3306"; $config['url_path'] = '/cacti/'; #记住是修改不是添加 配置Cacti 控制面板 >

User Management > admin > Zone permissions, select plug-in Management > Save

Then we can see an extra "plug-in Management" option under configuration in the control panel.

Six: install the NPC plug-in

Tar zxvf npc-2.0.4.tar.gz

Mv npc / var/www/html/cacti/plugins/

Vim / var/www/html/cacti/include/config.php

# add:

$plugins [] = 'npc'

1. Install npc support: json (install depending on the situation)

First use this command to see if there is a module php-m for JSON in PHP | skip grep json if it does.

Tar zxvf json-1.2.1.tgz

Cd json-1.2.1

Phpize # # if no Phpize file is found, it is because the php-devel package is not installed

. / configure

Make & & make install

Php-I | grep php.ini # # check whether there is import information

Open the php.ini file to add support for json

Vim / etc/php.ini

# add

Extension=json.so

Php-m # # check to see if any json is loaded

two。 Configure the basic npc environment

one。 Add php support for apache.

Vim / etc/httpd/conf/httpd.conf

# add a line:

AddType application/x-httpd-php .php .phtml

# modify the original DirectoryIndex to:

DirectoryIndex index.html index.html.var index.php

Usermod-G cacti apache

Service httpd restart # # restart apache for php to take effect

Linux lecturer of Xueshen Technology Co., Ltd.: top contact QQ 3059942361 to learn more about Linux system architect, you can contact me at any time

two。 Modify the configuration file so that npc can read the new data.

Vim / var/www/html/nagios/etc/ndo2db.cfg

Db_prefix=npc_

three。 Modify the table structure in mysql:

# mysql-ucacti-pcacti

Mysql > use cacti

Mysql > alter table npc_eventhandlers add long_output TEXT NOT NULL default''after output

Mysql > alter table npc_hostchecks add long_output TEXT NOT NULL default''after output

Mysql > alter table npc_hoststatus add long_output TEXT NOT NULL default''after output

Mysql > alter table npc_notifications add long_output TEXT NOT NULL default''after output

Mysql > alter table npc_servicechecks add long_output TEXT NOT NULL default''after output

Mysql > alter table npc_servicestatus add long_output TEXT NOT NULL default''after output

Mysql > alter table npc_statehistory add long_output TEXT NOT NULL default''after output

Mysql > alter table npc_systemcommands add long_output TEXT NOT NULL default''after output

four。 Restart the ndo2db process, reload the configuration file and restart the nagios service.

Service ndo2db restart

Service nagios restart

five。 Configure NPC on Web to make it read properly.

Control Panel > plug-in Management > install > enable

Control Panel > Settings > NPC

Nagios Command File Path= / var/www/html/nagios/var/rw/nagios.cmd

Nagios URL= your address (http://101.200.175.24/nagios)

Then refresh the npc to see the data.

If the status is OFF when you click NPC. Do the following:

Vim / var/www/html/nagios/etc/ndomod.cfg

# modify

Output_type=tcpsocket

Vim / var/www/html/nagios/etc/ndo2db.cfg

# modify

Socket_type=tcp

* make sure it's the only item *

Seven: installation and configuration of Nconf

The preparatory work of 1.nconf

# mysql

Mysql > create database nconf

Mysql > grant all privileges on nconf.* to nconf@localhost identified by 'nconf'

Mysql > flush privileges

Mysql > quit

two。 Install nconf

Tar-zxf nconf-1.2.6-0.tgz-C / var/www/html/

Cd / var/www/html/nconf

Chown-R apache.apache config/ temp/ static_cfg/ output/

3. Go to the Web page and follow the installation instructions on the web page to install step by step.

* use the nconf database and nconf database user / password you just created

4. After successfully connecting to the mysql database, everything remains by default until the following, set the nconf administrator password, and the default login user is admin

5. After that, the web page installation is complete.

Rm-rf INSTALL INSTALL.php UPDATE UPDATE.php

# Delete the initialization files required for installation

Ln-s / var/www/html/nagios/bin/nagios bin/nagios

Chmod + x / var/www/html/nconf/bin/generate_config.pl

Chown-R apache.apache bin

Chmod + x / var/www/html/nagios/bin/nagios

Chmod + x / var/www/html/nconf/ADD-ONS/deploy_local.sh

Vim / var/www/html/nconf/ADD-ONS/deploy_local.sh

# modify the Nagios path to / var/www/html/nagios/etc/

6. Refresh the web page

7. Click Generate Nagios config to try to generate a configuration file to test whether it is successfully associated with nagios

8. The last setting

1. When the monitoring service and host are configured on the web page, click Generate Nagios config

II. Deploy_local.sh is nconf's own configuration file import script

/ var/www/html/nconf/ADD-ONS/deploy_local.sh

Manual execution of this script will generate two directories, Default_collector and global, under / var/www/html/nagios/etc

III. Modify the nagios main configuration file

Vim / var/www/html/nagios/etc/nagios.cfg

# annotate all the cfg_file=* fields and add them

Cfg_dir=/var/www/html/nagios/etc/Default_collector

Cfg_dir=/var/www/html/nagios/etc/global

Service nagios reload

# reload the nagios configuration file to make it effective

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