Cacti + Nagios integrated monitoring deployment document

Time:2019-10-20

 

Catalog

Cacti + Nagios monitoring deployment steps… 2

I. cacti installation… 2

1 dependent packages to install:… 2

2 install RRDTOOL 2

3 start database and httpd service… 3

4 write servername and IP to hosts 3

5 install cacti 3

6 create cacti database and authorize:… 3

7 importing cacti’s data table… 3

8. Modify the configuration file to provide the user name and password for PHP to connect to MySQL (as shown in the figure)… 3

9. Log in to the web page and follow the wizard to complete the installation:… 4

10 configure native SNMP. 6

11 add monitoring device through web page… 7

12 generate data for the newly created graph and add polling to the scheduled task… 9

13 change PHP time zone… 9

14. Install the efficient poller pine. 9

II. Installation of cacti plug-in 11

1. If there is no need to patch (plugin management is provided by default in cacti-0.8.8b), just modify the configuration file.

2. Install the monitor, settings, and child plug-ins… 11

3. Refresh the plugin management of the web page, and the blue icon of the plug-in appears. Enable all the plug-ins in turn… 12

4. Alarm function of child… 12

5 installing the weathermap plug-in… 15

3. Client configuration of cacti system 18

1 Linux host… 18

2 windows host… 19

IV. Nagios installation… 20

1 installation dependencies… 20

2 creating user groups… 20

3 build install… 21

4 installing plug-ins… 21

5 create password file for login page… 21

6 create the Apache homepage file and start Nagios 21

7 login address, enter the set user name and password… 22

8 check Nagios configuration file syntax for errors… 22

V. integrating Nagios into cacti 22

1 install ndoutils 22

2 import database… 23

3 modifying configuration files… 23

 

 

Cacti + Nagios monitoring deployment steps

I. cacti installation

Set up the software set to be downloaded by cacti:

cacti-0.8.8b.tar.gz

cacti-spine-0.8.8b.tar.gz

monitor-v1.3-1.tgz

rrdtool-1.2.27.tar.gz

settings-v0.71-1.tgz

thold-v0.5.0.tgz

php-weathermap-0.97b.zip

The rest is the default network installation.

1. Dependent packages to be installed:

# yum install  httpd php php-mysql php-ldap php-xml  net-snmp-utils mysql  mysql-server net-snmp crond lm_sensors  mysql-devel  php-pdo  php-devel –y

2 install RRDTOOL

2.1 software required to install RRDTOOL:

# yum install  -y gcc gcc-c++  libart_lgpl-devel  zlib-devel  libpng-devel  freetype-devel  perl-devel  zlib libpng perl

2.2 unzip RRDTOOL source package installation:

# tar zxvf rrdtool-1.2.27.tar.gz

# cd rrdtool-1.2.27

# ./configure –prefix=/usr/local/

# make && make install

3 start database and httpd service

# service httpd start;chkconfig httpd on

# service mysqld start;chkconfig mysqld on

4 write servername and IP to hosts

# echo ‘192.168.2.81  monitor’ >>/etc/hosts

5 install cacti

# tar zxvf cacti-0.8.8b.tar.gz

# mv cacti-0.8.8b /var/www/html/cacti

Create cacti users, and set related directory owner and group

# useradd cactiuser

# cd /var/www/html/

# chown -R root.root *

# cd cacti

# chown -R cactiuser.cactiuser rra log

6 create cacti database and authorize:

# mysql -uroot –p

mysql> show databases;

mysql> create database cactidb default character set utf8;

mysql> grant all on cactidb.* to ‘cactiuser’@’localhost’ identified by ‘cactiuser’;

mysql> grant all on cactidb.* to ‘cactiuser’@’127.0.0.1’ identified by ‘cactiuser’;

mysql> grant all on cactidb.* to ‘cactiuser’@’%’ identified by ‘cactiuser’;

mysql> flush privileges;

mysql> \q

7 import data table of cacti

# cd /var/www/html/cacti

# mysql -ucactiuser -pcactiuser cactidb

8. Modify the configuration file to provide the user name and password for PHP to connect to MySQL (as shown in the figure)

# vim include/config.php

# vim include/global.php

……

/* make sure these values refect your actual database/host/user/password */

$database_type = “mysql”;

$database_default = “cactidb”;

$database_hostname = “localhost”;

$database “username =” user name “;

$database “password =” password “;

$database_port = “3306”;

……

 

 

9. Log in to the web page and follow the wizard prompts to complete the installation:

The default is admin. The password will be changed after the first login:

After modifying the password, enter the management interface:

10 configure native SNMP

10.1 modify configuration file

# vim /etc/snmp/snmpd.conf

……

com2sec notConfigUser  192.168.2.81      public

access  notConfigGroup  “”     any       noauth    exact  all  none none

view all    included  .1                               80

10.2 start up services

# service snmpd start;chkconfig snmpd on

11 add monitoring equipment through web page

Delete the default host in device:

Add monitoring host in device:

After creating, add all SNMP * items in the associated data queries column, and delete the remaining points X.

Click Save to save.

Draw a graph for the monitor:

Select the monitoring item in the check box and create

Add a newly created drawing to the drawing tree

12 generate data for the newly created graph and add polling to the scheduled task

# su – cactiuser

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

$ crontab -e

*/1 * * * * /usr/bin/php  /var/www/html/cacti/poller.php &> /dev/null

$ exit

# service crond restart

Add another host this way.

13 change PHP time zone

# /etc/php.ini

Date. Timezone = Asia / Shanghai (in addition, if the virtual environment platform cacti server is better for time synchronization)

14 install the high-efficiency poller spine

(download the corresponding version of cacti pine)

14.1 installation dependency

# yum -y install net-snmp-devel help2man openssl-devel

# tar -zxvf cacti-spine-0.8.8b.tar.gz

# cd cacti-spine-0.8.8b/

#. / configure / / installed under / usr / local / pine by default

# make && make install

14.2 modifying profile information and location

# cd /usr/local/spine/etc/

# mv spine.conf.list spine.conf

# vim spine.conf

……

DB_Host localhost
DB_Database cactidb
DB_User cactiuser
DB_Pass cactiuser
DB_Port 3306

# cp spine.conf /etc/spine.conf

14.3 running pine

# /usr/local/spine/bin/spine

SPINE: Using spine config file
[/etc/spine.conf]

SPINE: Version 0.8.8b starting

SPINE: Time: 1.1267 s, Threads: 5,
Hosts: 3
The above prompt indicates that the installation is successful!

14.4 modify cacti configuration

Console – > cacti settings – > paths – > spine
Console – > cacti settings – > poller – > poller type, select pine from the drop-down box to switch to pine

Console -> Cacti
Settings->Poller->Poller Interval,Cron Interval->Every Minute

Console – > cacti

Modify the values of step and heartbeat in console management > Templates > data templates (in sequence or in batch):

(1) in associated
(2) set step to 60s drawing once

(3) set heartbeat to 120s

14.5 rebuild poller cache

Console -> System Utilities -> Rebuild
Poller Cache

 

II. Installation of cacti plug-in

After the main program is installed, you need to install plug-ins to implement some extended functions, such as defining alert thresholds, adding module options, etc.

1 if there is no need to patch (plugin management is provided by default in cacti-0.8.8b), just modify the configuration file.

# cd /var/www/html/cacti/

# vim include/global.php

……

$database_type = “mysql”;

$database_default = “cactidb”;

$database_hostname =
“localhost”;

$database_username =
“cactiuser”;

$database_password =
“cactiuser”;

$database_port = “3306”;

……

# vim include/config.php

$url_path = “/ cacti /” (default)

2. Install the monitor, settings and child plug-ins

Monitor: provides the running state of the server through simple and clear icons.

Settings: provide common information for different plug-ins, such as email information and DNS information.

Thold: provide equipment exception warning.

Download and extract the required plug-in and copy it to the relevant directory:

 

# cd /root/cacti/

# tar zxvf settings-v0.71-1.tgz

# tar zxvf thold-v0.5.0.tgz

# tar zxvf monitor-v1.3-1.tgz

# mv monitor settings thold /var/www/html/cacti/plugins

# cd –

3 refresh the plugin management of the web page, and the blue icon of the plugin appears.successivelyAll enabled

 

4. Alarm function of child

4.1 define notification mailing list

 

4.2 setting up sending mail server and other relevant

After setting, click Save to save, and you can click Send a test email in the upper right corner to send a test email.

4.3 specific application of email alarm

After creation, configure as follows, save

View newly added warning status

Test and early warning

# dd if=/dev/zero of=/boot/mail.img bs=1M
count=120

 

4.4 or you can create threshold templates first, and then create alarm items after saving.

 

5 install the weathermap plug-in

(weathermap can be used as a plug-in of cacti, or it can be used independently. It needs PHP and PHP GD support.)

5.1 download software package

php-weathermap-0.97b.zip

5.2 installation

# cd /root/cacti/

# unzip php-weathermap-0.97b.zip

# mv weathermap/
/var/www/html/cacti/plugins

# cd /var/www/html/cacti/plugins/weathermap/

# chown -R apache.apache configs/
output/

Refresh cacti, console – plugin management, click the button to install

 

5.3 editor

# yum install php php-gd

# service httpd restart

Find the weathermap in the console list, click Add to add a weathermap configuration file, where simple.conf is the default configuration file, and click Edit to use it.

Or directly enter the editor of the weathermap module, and enter simple.conf to edit.

After editing the drawing, it will take effect directly, and view the effect after preparing the topology map.

 

3. Client configuration of cacti system

1 Linux host

1.1 installation dependency

# yum install net-snmp* –y

# vim /etc/snmp/snmpd.conf

……

com2sec notConfigUser   192.168.2.82    public

access  notConfigGroup “”    any   
noauth   exact  all none none

view all    included 
.1               80

1.2 start SNMP

# service snmpd start;chkconfig snmpd on

Finally, add the device from the web page.

2 windows host

Start the SNMP service in the system service:

Then modify the attributes as shown in the following figure:

After configuring SNMP, install the SNMP informant-std-16.exe program (download).

 

IV. Nagios installation

Set up the software collection to download for Nagios

nagios-4.1.1.tar.gz

nagios-plugins-2.1.1.tar.gz

ndoutils-2.0.0.tar.gz

npc-2.0.4.tar.gz

php-json-ext-1.2.1.tar.bz2

nrpe-2.15.tar.gz

NSClient++-Stable-64.msi

Other is the default installation.

1 installation dependency

# yum -y install httpd php gcc glibc
glibc-common gd gd-devel libpng libjpeg zlib openssl-devel mysql-devel php-pdo

2 create user group

# useradd nagios

# usermod -G nagios apache

3 compile and install

# tar -zxvf nagios-4.1.1.tar.gz

# cd nagios-4.1.1

# ./configure –with-command-group=nagios

# make all

# make install

# make install-init

# make install-commandmode

# make install-config

# make install-webconf

# make install-exfoliation

# make install-classicui

[Note: make install execution is a new interface of naigios. If you want to change to the previous classic theme, you need to execute the old interface of make install classic UI. ]

4 install plug-ins

# tar zxvf nagios-plugins-2.1.1.tar.gz

# cd nagios-plugins-2.1.1

# ./configure –with-nagios-user=nagios
–with-nagios-group=nagios

# make && make install

5 create password file for login page

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

 

6. Create the Apache homepage file and start Nagios

# touch /var/www/html/index.html

# service nagios start;chkconfig nagios
on

7. Login address, enter the set user name and password

 

8 check Nagios configuration file syntax for errors

# cd /usr/local/nagios

# ./bin/nagios -v etc/nagios.cfg

 

……………

    Checked 5 time periods.

    Checked 0 host escalations.

    Checked 0 service escalations.

Checking for
circular paths…

    Checked 1 hosts

    Checked 0 service dependencies

    Checked 0 host dependencies

    Checked 5 timeperiods

Checking
global event handlers…

Checking
obsessive compulsive processor commands…

Checking misc
settings…

 

Total
Warnings: 0

Total
Errors:   0

 

V. integrating Nagios into cacti

1 install ndoutils

# tar zxvf ndoutils-2.0.0.tar.gz

# cd ndoutils-2.0.0

# ./configure
–prefix=/usr/local/nagios/ LDFLAGS=-L/usr/lib
–with-mysql-inc=/usr/include/mysql/ –with-mysql-lib=/usr/lib64/mysql/(/var/lib/mysql/)
–enable-mysql –disable-pgsql –with-ndo2db-user=nagios
–with-ndo2db-group=nagios

# make && make install

2 import database

# cd db/

# ./installdb -u cactiuser -p cactiuser
-h localhost -d cactidb

3 modify the configuration file

# cd ..

# cp
config/ndomod.cfg-sample /usr/local/nagios/etc/ndomod.cfg

# cp
config/ndo2db.cfg-sample /usr/local/nagios/etc/ndo2db.cfg

# vim
/usr/local/nagios/etc/nagios.cfg

broker_module=/usr/local/nagios/bin/ndomod.o
config_file=/usr/local/nagios/etc/ndomod.cfg

process_performance_data=1

# service nagios
checkconfig

Running
configuration check…

 OK.

# vim
/usr/local/nagios/etc/ndomod.cfg

output_type=tcpsocket

output=127.0.0.1

data_processing_options=-1

# vim /usr/local/nagios/etc/ndo2db.cfg

socket_type=tcp

db_name=cactidb

db_prefix=npc_

db_user=cactiuser

db_pass=cactiuser

debug_level=1

  1. tar zxvf npc-2.0.4.tar.gz
  2. mv npc /var/www/html/cacti/plugins/
  3. vim /var/www/html/cacti/include/config.php
  4. Join in:
  5.      $plugins[]
    = ‘npc’;

Ndomod: error writing to data sink!

Install NPC support: JSON (not done in white)

4 install JSON

NPC display needs JSON support in PHP

1) installation dependency

# yum install -y
php-devel

2) install JSON

# tar jxvf
php-json-ext-1.2.1.tar.bz2

# cd
php-json-ext-1.2.1

# phpize

# ./configure
&& make && make install

3) enable JSON

# vim
/etc/php.d/json.ini

extension=php_json.so

ln –s
/usr/lib64/php/modules/json.so /usr/lib64/php/modules/php_json.so

# yum reinstall
php-common -y

5 install NPC plug-in in cacti

# tar xvf npc2.0.4.tar

# mv npc /var/www/html/cacti/plugins/

Enable plug-ins on Web pages

Plug-in configuration

Modify file permissions

# cd
/usr/local/nagios/etc/

# chmod 644
ndo2db.cfg ndomod.cfg

# chown
nagios.nagios ndomod.cfg ndo2db.cfg

# chown .nagios
htpasswd.users

Startup service

# service mysqld
restart

# service httpd
restart

# /usr/local/nagios/bin/ndo2db
-c /usr/local/nagios/etc/ndo2db.cfg

# vim /etc/rc.local

/usr/local/nagios/bin/ndo2db
-c /usr/local/nagios/etc/ndo2db.cfg

# service nagios
restart

If there is no display in the host page and there is an error in the log, Aug 26 19:52:54 monitor ndo2db: MySQL error: ‘unknown column

mysql> use
cactidb;

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;

After modifying the database, restart the service in turn.

If the data in this label box is still blank and all are 0, and there is such an error in the log as Aug 28 21:31:19 monitor ndo2db: MySQL error: ‘unknown column

(go to the mysql-upgrade-2.0.0.sql file in ndoutils, and change all Nagios in mysql-upgrade-2.0.0.sql to NPC.)

mysql> use
cactidb;

mysql> source /home/cacti/ndoutils-2.0.0/db/mysql-upgrade-2.0.0.sql

 

The final display effect is as follows.

At this point, the integration of cacti + Nagios framework and the installation of basic plug-ins are completed.

 

Four, NagiosTo configure

1 Nagios server configuration

1)

# cd /home/nagioss/

# tar zxvf nrpe-2.15.tar.gz

# yum install openssl openssl-devel

# cd nrpe-2.15

# ./configure && make all
&& make install

# make install-plugin

# make install-daemon

# make install-daemon-config

# ls /usr/local/nagios/libexec/

2)

# cd etc/objects

# vim commands.cfg

# ‘check_nt’ command definition

define command{

       
command_name    check_nrpe

       
command_line    $USER1$/check_nrpe
-H $HOSTADDRESS$ -c $ARG1$

        }

3)

# vim hosts.cfg

define host{

        use                     linux-server

        host_name               monitor

        alias                    monitor

        address                 192.168.2.81

        }

define host{

        use                     windows-server

        host_name               TESTSERVER

        alias                    TESTSERVER

        address                  192.168.2.6

        }

define hostgroup{

        hostgroup_name  linux-servers

        alias            Linux Servers

        members        monitor,server-redis-1

  }

define hostgroup{

        hostgroup_name  windows-servers

        alias            Windows Servers

        members        UATSERVER,TESTSERVER

        }

# vim /usr/local/nagios/etc/nagios.cfg

cfg_file=/usr/local/nagios/etc/objects/hosts.cfg

cfg_dir=/usr/local/nagios/etc/objects/services

#cfg_file=/usr/local/nagios/etc/objects/localhost.cfg

Create a new service directory, and create corresponding service files in the directory

Make similar changes to the service file according to the nrpe configuration of the monitored end

# vim object/services/2.5.cfg

……

define service{

       
use                            
generic-service

       
host_name                       server-redis-1

       
service_description               
HTTP

       
check_command                  check_nrpe!check_http

       
}

# vim object/services/win2.9.cfg

define service{

       
use                     generic-service

       
host_name               UATSERVER

       
service_description        W3SVC

       
check_command    check_nt!SERVICESTATE!-d SHOWALL -l W3SVC

       
}

 

 

4)

# service nagios configtest

perhaps

# /usr/local/nagios/bin/nagios -v ../../nagios.cfg

There is a warning here, because the two descriptions are the same after copying the content. Just change one.

 

5)       

 

2. Linux server configuration of monitored end

1)

# useradd nagios

2)

# tar zxvf
nagios-plugins-2.1.1.tar.gz

# cd
nagios-plugins-2.1.1

# yum install gcc
gcc-c++ -y

# ./configure
–with-nagios-user=nagios –with-nagios-group=nagios

# make &&
make install

3)

# tar zxvf nrpe-2.15.tar.gz

# cd nrpe-2.15

# yum install openssl openssl-devel

# ./configure && make all
&& make install

# make install-plugin

# make install-daemon

# make install-daemon-config

# make install-xinetd

# ls
/usr/local/nagios/libexec/

4)

# vim /usr/local/nagios/etc/nrpe.cfg

allowed_hosts=127.0.0.1,192.168.2.81

# df –h

5)

Nrpe services have two modes of operation: ‘standalone day’ or ‘xinetd’

# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg
-d

# echo ‘/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg
-d’ >>/etc/rc.local

Check whether the nrpe port is started

# netstat -nptul|grep nrpe

6)

# ./check_nrpe -H 192.168.2.5

#. / check_nrpe – H 192.168.2.5 – C check_users

7)

Add on redis service

# vim etc/nrpe.cfg

Add on monitoring service

# vim services/2.5.cfg

8)

# service nagios configtest

# service nagios restart;service httpd
restart

 

3. Windows server configuration of monitored end

Nsclient + + program engine needs to be installed on Windows Server. After installation, the server can obtain monitoring data through check ont, as shown in the figure:

1)

NSClient++-Stable-64.msi

2)

All the way default, and finally select all to install

3)

4)

Edit the nsc.ini file in the installation directory, and open the nsclient + + port. Because the modules required for installation have been checked, there is no need to set them.

[Settings]

Allowed hosts = 192.168.2.81 / / monitoring server address

[NSClient]

Port = 12489 / / enable port 12489

Check whether port “12489” and “5666” are listening:

 

5)

Make sure that there is check ont in the command file (default)

 

6)

# ./libexec/check_nt -H 192.168.2.6 -v
UPTIME -p 12489

 

# ./check_nt -H 192.168.2.9 -v SERVICESTATE
-p 12489  -l ChampBEndService_3

 

# ./check_nt -H 192.168.2.9 -v PROCSTATE -p
12489 -l CHAMP_SERVICE_3.exe

 

7)

# service nagios configtest

# service nagios restart;service httpd
restart

V. add cactiTemplate monitoring MySQLservice

1 package to download

percona-cacti-templates-1.1.6-1.noarch.rpm

2 copy RPM package to cacti server and extract it

# mv percona-cacti-templates-1.1.6-1.noarch.rpm
/opt

# cd /opt

# rpm2cpio percona-cacti-templates-1.1.6-1.noarch.rpm
| cpio –div

# cp usr/share/cacti/scripts/ss_get_mysql_stats.php
\
usr/share/cacti/resource/percona/templates/cacti_host_template_percona_mysql_server_ht_0.8.6i-sver1.1.6.xml
/opt/

# cp
/opt/ss_get_mysql_stats.php /var/www/html/cacti/scripts/

# vim
/var/www/html/cacti/scripts/ss_get_mysql_stats.php

 

3 import template file

Copy / opt / cacti? Host? Template? Percona? MySQL? Server? HT? 0.8.6i-sver1.1.6.xml to the local machine, open the cacti page – console – Import templates – to find the file path and import.

After the import is successful, add the host and select the template in the related items.

Vi. add cactiTemplate monitoring windowsHost

1. Open SNMP on Windows host and install informant-std-16.exe

2 download package

Cacti_SNMP_Informant_Standard_Metrics_v13.zip

3 decompress the template file and import all the template files in the template folder through the interface operation;

Then put all the SNMP ﹣ information ﹣ standard *. XML files in the folder.. \ resource \ SNMP ﹣ queries into the cacti / resource / SNMP ﹣ queries / path of the server, and make sure that all users are readable.

4. Add the monitoring device, and select the template from the host template, associated graph templates, associated data queries and other corresponding items.

Create
Graph for this Host

 

VII. Using NagiosMonitoring windowsService (champbendservice_)

1 test plug-ins first

# /usr/local/nagios/libexec

#
./check_nt -H 192.168.2.9 -v SERVICESTATE -p 12489 -d SHOWALL -l
ChampBEndService_3

 

#
./check_nt -H 192.168.2.9 -v PROCSTATE -p 12489 -d SHOWALL -l
CHAMP_SERVICE_3.exe

 

If the test is OK, the nsclient + + configuration and service of the controlled end are correct.

2 add settings

# vim objects/commands.cfg

 

# vim services/win2.9.cfg

 

3 restart service

# service nagios checkconfig

# service nagios restart

# service httpd restart

 

VIII. Setting NagiosSend alarm email

If there is warning in the log:

1 install postfix and remove sendmail

# yum remove sendmail

# service postfix start;chkconfig postfix on

2 add the address of the local email to the white list of the email, otherwise it will be treated as spam by the third party email.

3 test received mail

 

Nine, cactiAdd router and switch

 

Recommended Today

Single and multiple buttons are styled with pictures

I’ve always seen people asking how to style and enlarge the buttons of radio buttons and multi buttons? Let’s share an example I did. 1. First make the button into a picture  2.html page Copy code The code is as follows: <!DOCTYPE HTML> <html> <head> <meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ /> <script type=”text/javascript” src=”jquery-1.10.2.min.js”></script> <script type=”text/javascript”> […]