Cacti monitoring server for monitoring three swordsmen

Blog directory

1, Cacti

1. Introduction to Cacti

2. The function and characteristics of cacti

3. Data types of cacti monitoring

2, Install and configure Cacti monitoring server

1. Configure LAMP environment

2. Install SNMP and RRDTOOL tools

3. Deploy English cacti to connect mariadb

4. Client accessing English cacti's WEB interface

5. Deploy Chinese cacti to connect to mariadb database

6. Client access to Chinese cacti WEB interface

3, Cacti configures monitoring through WEB interface

1. Cacti configuration monitoring local server

2. Cacti configuration monitoring Linux client

3. Cacti configuration monitoring Cisco Router

1, Cacti

1. Introduction to Cacti

cacti is a development performance and traffic detection software developed in PHP language. The detection object can be Linux, Windows servers, routing switches and other Network devices. It mainly collects CPU occupation, memory usage, running process, Network card traffic and other data based on SNMP(simple, Network, Management, protocol, simple Network Management Protocol).

2. The function and characteristics of cacti

1) The role of cacti

Computer hardware performance monitoring
Network traffic monitoring

2) Characteristics of cacti

Monitoring tool developed with php language
LAMP platform needs to be configured
Collect data through SNMP protocol
Collect data and use RRDtool to draw charts

3. Data types of cacti monitoring

CPU usage;

Memory usage;

The running state of the process in the computer;

Computer disk space;
Network card traffic;

2, Install and configure Cacti monitoring server

Packages for this environment can be found at: https://pan.baidu.com/s/1AaftKbrp3ASsN1Br6zyWug
Extraction code: 6iog

1. Configure LAMP environment

[root@centos01 ~]# yum -y install httpd mariadb mariadb-server  
         <!--install Apache and Mariadb database-->
[root@centos01 ~]# yum -y install zlib freetype libjpeg fontconfig gd libxml2-devel php-gd
 <!--install PHP Dependent tools-->
[root@centos01 ~]# Yum - y install PHP MySQL <! -- install PHP -- >
[root@centos01 ~]# cp /etc/ php.ini  /etc/ php.ini.bak   <! -- backup PHP main configuration file -- >
[root@centos01 ~]# vim /etc/ php.ini   <! -- modify the PHP main configuration file -- >
 879 date.timezone = Asia/Shanghai  <!--Time zone changed to Shanghai-->
[root@centos01 ~]# vim /var/www/html/ index.php    <! -- create PHP test file -- >
<?php
phpinfo();
?>
[root@centos01 ~]# cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.bak  
         <!--backups apache Main configuration culture-->
[root@centos01 ~]# vim /etc/httpd/conf/ httpd.conf   <! -- edit apache main configuration file support php home page - >
163 <IfModule dir_module>
164     DirectoryIndex index.html index.php  <!--add to index.php-->
165 </IfModule>
[root@centos01 ~]# Systemctl start httpd <! -- start Apache Service -- >
[root@centos01 ~]# Systemctl enable httpd <! -- set automatic startup after power on -- >
[root@centos01 ~]# Systemctl start mariadb <! -- start mariadb database -- >
[root@centos01 ~]# Systemctl enable MariaDB <! -- set boot auto start -- >
[root@centos01 ~]# Mysqladmin - uroot password <! -- initialize database -- >

Client uses browser to visit php page

2. Install SNMP and RRDTOOL tools

[root@centos01 ~]# Yum - y install net SNMP utils net SNMP <! -- install SNMP -- >
[root@centos01 ~]# Systemctl start snmp <! -- start snmp Service -- >
[root@centos01 ~]# Systemctl enable snmpd <! -- set boot auto start -- >
[root@centos01 ~]# yum -y install cairo-devel zlib-devel libxml2 libxml2-devel glib2 glib2-devel 
libpng libpng-devel freetype freetype-devel libart_lgpl pango pango-devel perl-CPAN
           <!--install RRDtool Tool dependencies-->
[root@centos01 ~]# tar zxvf RRDtool-1.7.2. tar.gz  -C / usr / SRC / <! -- decompress RRDtool tool -- >
[root@centos01 ~]# CD / usr / SRC / rrdtool-1.7.2 / <! -- enter directory -- >
[root@centos01 rrdtool-1.7.2]# ./configure --prefix=/usr/local/ && make && make install
          <!--configuration setup RRDtool tool-->

3. Deploy English cacti to connect mariadb

[root@centos01 ~]# Useradd - M - S / SBIN / nologin cacti <! -- create management cacti account -- >
[root@centos01 ~]# tar zxvf cacti-0.8.8b. tar.gz  -C / usr / SRC / <! -- decompress the English cacti package -- >
[root@centos01 ~]# MV / usr / SRC / cacti-0.8.8b / / var / www / HTML / cacti <! -- move cacti to the root directory of the website -- >
[root@centos01 ~]# chown -R  cacti:cacti /var/www/html/cacti/  <! -- set the owner of the admin site -- >
MariaDB [(none)]> create database cacti default character set utf8;  <!--Create database cacti-->
MariaDB [(none)]> grant all on cacti.* to 'cacti'@'localhost' identified by 'cacti';    
         <!--Set authorization cacti Account password cacti visit cacti database-->
[root@centos01 ~]# vim /var/www/html/cacti/include/ config.php  <! -- modify the cacti configuration file to connect to the database -- >
 26 $database_type = "mysql";
 27 $database_default = "cacti";
 28 $database_hostname = "localhost"; 
 29 $database_username = "cacti";         <!--user name-->
 30 $database_password = "cacti";         <!--password-->
[root@centos01 ~]# mysql -u cacti -p cacti < /var/www/html/cacti/ cacti.sql <! -- import data to cacti database -- >
[root@centos01 ~]# mysql -uroot  -ppwd@123          <! -- log in to the database -- >
MariaDB [(none)]> use cacti;        <!--Switch to cacti database-->
MariaDB [cacti]> show tables;      <!--Verify that the data was imported successfully-->
+---------------------------+
| Tables_in_cacti           |
+---------------------------+
| cdef                      |
| cdef_items                |
| colors                    |

4. Client accessing English cacti's WEB interface

1) Client access installation cacti

2) Choose to install cacti

3) Keep default next

4) Default password login

5) Change password to cacti

6) Log in to the home page

5. Deploy Chinese cacti to connect to mariadb database

Follow the English cacti steps to deploy the LAMP environment, install SNMP and RRDtool tools

[root@centos02 ~]# Useradd - M - S / SBIN / nologin cacti <! -- create management cacti user -- >
[root@centos02 ~]# RZ <! -- upload Chinese cacti package -- >
cacti-0.8.8b-cn-zutb.tar.gz 
[root@centos02 ~]# tar zxvf cacti-0.8.8b-cn- zutb.tar.gz           <! -- decompress cacti -- >
[root@centos02 ~]# MV cacti / * / var / www / HTML / <! -- cut to the root directory of the website -- >
[root@centos02 ~]# chown -R  cacti:cacti /var/www/html/    <! -- set the owner of the admin site -- >
[root@centos01 ~]# vim /var/www/html/cacti/include/ config.php  <! -- modify the cacti configuration file to connect to the database -- >
26 $database_type = "mysql"; 
 27 $database_default = "cacti"; 
 28 $database_hostname = "localhost";
 29 $database_username = "cacti";          <!--user name-->
 30 $database_password = "cacti";          <!--password-->
 31 $database_port = "3306";            <!--Port number-->
 32 $database_ssl = false;  
[root@centos02 ~]# mysql -uroot  -ppwd@123        <! -- log in to the database -- >
MariaDB [(none)]> create database cacti default character set utf8; <!--Create database cacti Support Chinese characters-->
MariaDB [(none)]> grant all on cacti.* to 'cacti'@'localhost' identified by 'cacti';      
         <!--to grant authorization cacti Account password cacti visit cacti database-->
[root@centos02 ~]# vim /var/www/html/ cacti.sql      <! -- open this profile -- >
CREATE DATABASE `cacti` CHARACTER SET utf8 COLLATE utf8_general_ci;<!--Delete this line-->
[root@centos01 ~]# mysql -u cacti -p cacti < /var/www/html/ cacti.sql   <! -- import data to cacti database -- >
[root@centos01 ~]# mysql -uroot  -ppwd@123         <! -- log in to the database -- >
MariaDB [(none)]> use cacti;          <!--Switch to cacti database-->
MariaDB [cacti]> show tables;        <!--Verify that the data was imported successfully-->
+---------------------------+
| Tables_in_cacti           |
+---------------------------+
| cdef                      |
| cdef_items                |
| colors                    |

6. Client access to Chinese cacti WEB interface

1) Client access installation cacti

2) Choose to install cacti

3) Keep default next

4) Default password login

5) Change password to cacti

6) Log in to the home page

3, Cacti configures monitoring through WEB interface

[root@centos02 ~]# vim /etc/snmp/ snmpd.conf           <! -- modify SNMP configuration file -- >
42 com2sec notConfigUser  192.168.100.20       public          <!--Add server IP address-->
64 access  notConfigGroup ""      any       noauth    exact  all none     none
88 view all    included  .1                               80
[root@centos02 ~]# Systemctl restart snmpd <! -- restart the snmp client -- >

1. Cacti configuration monitoring local server

1) Add new host

2) Configure hosts to add

3) Save the host you just created

4) Add graphics tree

5) Save the graph tree you just created

6) Add new graphics for 100.20 hosts

7) You can change the color according to your needs, and then click Add

8) Manually update cacti data

[root@centos02 ~]# /usr/bin/php /var/www/html/poller.php --force

9) Set scheduled task to update cacti data

[root@centos02 ~]# Crontab - e <! -- set scheduled task -- >
*/5     *       *       *       *       /usr/bin/php /var/www/html/poller.php --force       
             <!--Update every 5 minutes cacti data--> 

10) Wait a few minutes and check the monitoring chart

2. Cacti configuration monitoring Linux client

1) Install SNMP client

[root@centos03 ~]# Yum - y install net snmp <! -- install snmp client -- >
[root@centos03 ~]# vim /etc/snmp/ snmpd.conf           <! -- modify SNMP master profile -- >
42 com2sec notConfigUser  192.168.100.30       public       <!--Add monitored end IP address-->
64 access  notConfigGroup ""      any       noauth    exact  all none     none
88 view all    included  .1                               80
[root@centos03 ~]# Systemctl start snmp <! -- start snmp client -- >
[root@centos03 ~]# Systemctl enable snmpd <! -- start up automatically -- >

2) cacti monitoring add host

3) Save the new host you just added

4) 100.30 adding graphics tree to host

5) Save drawing tree

6) Add new graphics for 100.30 hosts

7) Modify the graphic color according to your own needs, and click Add

8) Wait for a few minutes to view the monitoring chart

3. Cacti configuration monitoring Cisco Router

1) GNS3 configuration IP address

R1#config t          
R1(config)#Int f 0 / 0 <! -- enter the 0 / 0 interface -- >
R1(config-if)#No switchport <! -- Open three-tier interface -- >
R1(config-if)#IP add 192.168.100.40 255.255.255.0 <! -- configure IP address -- >
R1(config-if)#No shutdown <! -- activate configuration -- >
R1(config-if)#Do Ping 192.168.100.10 <! -- Ping cacti server -- >
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.100.10, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 8/24/56 ms
R1(config)#SNMP Server Community Public ro <! -- router opens SNMP protocol -- >

2) cacti add host

3) Save added hosts

4) Add a graphics tree for 100.40

5) Save drawing tree

6) Add new drawing

7) Change the color according to your needs, click Add

8) View monitoring chart

————————Thank you for reading————————

Tags: Linux PHP Database MariaDB MySQL

Posted on Fri, 05 Jun 2020 04:57:50 -0400 by lzylzlz