In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
I. brief introduction of cacti monitoring software
1. Cacti is a software implemented in PHP language, its main function is to use snmp services to obtain data, then use rrdtool to store and update data, and when users need to view data, use rrdtool to generate charts and present them to users. Therefore, snmp and rrdtool are the key to cacti. Snmp is related to data collection, and rrdtool is related to data storage and chart generation.
2. Mysql cooperates with PHP program to store some variable data and call it, such as hostname, host ip, snmp community name, port number, template information and other variables.
3. The data captured by snmp is not stored in mysql, but in the rrd file generated by rrdtool (in the rra folder of the cacti root directory). The update and storage of data in rrdtool is the processing of rrd file. Rrd file is a fixed-size archive file (RoundRobinArchive), and the number of data it can store has been defined at the time of creation.
Second, set up cacti monitoring environment
1. Introduction to building environment:
Server side
CentOS
*. *
Client
Any network device
192.168.1.110
2. Close iptables and SElinux
[root@localhost configs] # iptables-F
[root@localhost configs] # setenforce 0
3. Cacti server operation:
[root@localhost/] # yum install epel-release / / install the epel extension source in preparation for the following installation of cacti
[root@localhost/] # yum install-y httpd php php-mysql mysql mysql-server mysql-devel php-gd libjpeg libjpeg-devel libpng libpng-devel / / install php and mysql software related to cacti
[root@localhost/] # yum install-y cacti net-snmp net-snmp-utils rrdtool / / install cacti, net-snmp, rrdtool
Here the installation of cacti can be installed directly with yum, or you can download tar.gz-related installation package through wget, the only difference is yum installation, when configuring the cacti.conf file, yum is automatically generated, only need to modify the corresponding parameters inside, the following configuration will have instructions, here is a simple description of how to manually configure the cacti.conf file when installing through the decompression package.
First of all, if you do not configure the cacti.conf file, we will enter the cacti installation wizard will report an error, incorrect URL and other information.
Therefore, this must be configured. Nine times out of ten, the articles on the Internet are plagiarism. There is no description of this piece, and some of them are not detailed. I have been in this area for a long time. So hereby explains:
Here's how to configure the manual configuration cacti.conf file
Go to the [root@localhost/] # cd / etc/httpd/conf.d/ directory
Manually rebuild the cacti.conf file
[root@localhost/] # vi cacti.conf
Alias / cacti/ "/ usr/share/cacti/"
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
Then save and exit.
In this way, you can enter the cacti installation wizard after configuration.
Start the service:
[root@localhost/] # / etc/init.d/mysqld start
[root@localhost/] # / etc/init.d/httpd start
[root@localhost/] # / etc/init.d/snmpd start
Change the httpd profile:
[root@localhost/] # vi / etc/httpd/conf.d/cacti.conf / / change the "Deny from all" of the configuration file to "Allow from all"
[root@localhost/] # / etc/init.d/httpd restart
Import data to create a cacti library:
[root@localhost/] # mysql-uroot-e "create database cacti"
[root@localhost/] # mysql-uroot-e "grant all on cacti.* to 'cacti'@'127.0.0.1' identified by' cacti';"
[root@localhost/] # mysql-uroot cacti
< /usr/share/doc/cacti-1.1.19/cacti.sql 编辑cacti配置文件: [root@localhost/]# vi /usr/share/cacti/include/config.php $database_type ="mysql"; 数据库名称 $database_default= "cacti";数据库名称 $database_hostname= "127.0.0.1";主机名称 $database_username= "cacti";数据库用户名 $database_password= "cacti";数据库密码 $database_port ="3306"; $database_ssl =false; *注意*:这块的信息必须和数据用户信息、密码对应,负责会报错: +---------------------------------------+ | query | +---------------------------------------+ | User: 'cacti'@'127.0.0.1'; | | User: 'root'@'127.0.0.1'; | | User: ''@'localhost'; | | User: 'cactiuser'@'localhost'; | | User: 'root'@'localhost'; | | User: ''@'localhost.localdomain'; | | User: 'root'@'localhost.localdomain'; | +---------------------------------------+ $database_type ="mysql"; 数据库名称 $database_default= "cacti";数据库名称 $database_hostname= "127.0.0.1";主机名称 $database_username= "cacti";数据库用户名 $database_password= "cacti";数据库密码 $database_port ="3306"; $database_ssl =false; 存在用户名密码不匹配的,参照一下修改: 查看MYSQL数据库中所有用户: mysql>SELECT DISTINCT CONCAT ('User:'', user,'''@''',host,''';') AS query FROM mysql.user
+-+
| | query |
+-+
| | User: 'cacti'@'127.0.0.1'; |
| | User: 'root'@'127.0.0.1'; |
| | User:''@ 'localhost'; |
| | User: 'cactiuser'@'localhost'; |
| | User: 'root'@'localhost'; |
| | User:''@ 'localhost.localdomain'; |
| | User: 'root'@'localhost.localdomain'; |
+-+
Change password and refresh permissions:
Mysql > grant all on cacti.* to 'cacti'@'127.0.0.1' identified by' 321321'
Query OK, 0 rows affected (0.00 sec)
Mysql > flush privileges
Query OK, 0 rows affected (0.00 sec) restart mysql httpd service:
There is an error when installing cacti
one
ERROR: Your Cacti database login account does not have access to the MySQL TimeZone database. Please provide the Cacti database account select "access to the" time_zone_name "table in the" mysql "database, and populate MySQL's TimeZone information before proceeding.
Solution: log in to mysql and do the following
Mysql > GRANT SELECT ON mysql.time_zone_name TO cacti@localhost IDENTIFIED BY 'cactiwhsir'
Mysql > flush privileges
And then found out that it was wrong again.
ERROR: Your MySQL TimeZone database is not populated. Please populate this database before proceeding.
Solution: log in to mysql and do the following
Mysql_tzinfo_to_sql / usr/share/zoneinfo/Asia/Shanghai Shanghai | mysql-u root-p mysql
Adjust the httpd configuration to use the cacti source directory as the root of the website
Vi/etc/httpd/conf/httpd.conf
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/ usr/share/cacti/"
3. Web accesses cacti and installs
Http://ip/cact
The above three steps follow the system default steps and click
When entering the administrative password for the first time in cacti, both the account number and password are admin. After entering the password, the system requires the user to change the password by default.
4. Execute poller.php, generate graphics, and join planned tasks
[root@localhost/] # / usr/bin/php / usr/share/cacti/poller.php
OK u:0.01 s:0.02 r:0.67
OK u:0.01 s:0.02 r:0.67
OK u:0.01 s:0.02 r:0.71
OK u:0.01 s:0.02 r:0.71
OK u:0.01 s:0.02 r:0.78
OK u:0.01 s:0.02 r:0.78
OK u:0.01 s:0.02 r:0.84
OK u:0.01 s:0.02 r:0.84
OK u:0.01 s:0.02 r:1.00
OK u:0.01 s:0.02 r:1.00
02:53:39 AM-SYSTEM STATS: Time:1.2623 Method:cmd.php Processes:1 Threads:N/A Hosts:2 HostsPerProcess:2 DataSources:5 RRDsProcessed:5
[root@localhost/] # crontab-e / / join the cron service to make the traffic on the picture change regularly
* / 5 * / usr/bin/php / usr/share/cacti/poller.php
5. The following is on the client side:
[root@hpf-linux mysql] # yum install-y net-snmp lm_sensors
[root@hpf-linux/] # vi / etc/snmp/snmpd.conf / / modify syslocation and syscontact, where syslocation can write to the ip,syscontact of the monitoring client and the administrator's mailbox
Syslocation 192.168.1.110
Syscontact Root aming@linux.com
At the same time, click the following modification in the configuration file. If you do not modify it, you will not be able to find the network card option when adding network card detection.
View systemview included .1.3.6.1.2.1.1
Modified to:
View systemview included .1.3.6.1.2.1
[root@hpf-linux/] # / etc/init.d/snmpd start
Starting snmpd: [OK]
6. Configure cacti detection under the browser
Go to the browser and log in to the cacti management backend, click console, click New Graphs, and click "Create New Host" in the upper right corner.
Description writes the name or customization of the monitoring client
Hostname writes monitored client ip
Host Template chooses ucd/net SNMP Host
SNMP Version chooses Version 2
Click the create in the lower right corner
After the introduction of snmp appears, click "CreateGraphs for this Host" in the upper right corner.
Select the hardware information or network card to be monitored in the box below, such as eth0,eth2, tick in the rightmost square, and then click create in the lower right corner.
Graph Types: then select Graph Template Based. In the box below, select the item you want to monitor, such as Unix- Load Average, tick in the small box on the right, and then click create in the lower right corner.
Click Graph Trees on the left, select "DefaultTree", and click Add in the upper right corner
Tree Item Type select "Host", Host select the machine ip we just added, and click create in the lower right corner.
Click the Graphs button in the upper left corner, and you can see on the left that the host we just added has been added below the Defaut Tree. The graphics will not come out so quickly at first, it will take a while.
*
No picture is shown, and other information such as unkonwn,snmp is normal.
It may be caused by a time problem, so take a look at the cacti log and pay attention to the start time and end time (this is because the system synchronizes time with the time server every 10 minutes).
This will cause problems with the execution time of the database record poller.
At this time to check the poller always time, always time must be correct this will cause the poller process to stop working, until the system time exceeds the start_time,poller process to start working, the image can come out! Here is a special note: you can not simply modify the time in the database poller_time table, because there are many tables in the database that also record the time of collecting all kinds of data.
So there are two solutions:
1 when the system time exceeds start_time (after 12: 10 p.m.), everything returns to normal (if you are patient).
2 if the current system time is not correct, modify the system time correctly, then delete all the files under / usr/share/cacti/rra, and finally force the poller program to regenerate all the files under / usr/share/cacti/rra. The operation process is as follows:
[root@zz cacti] # rm-rf / usr/share/cacti/rra/*
[root@zz cacti] # / usr/bin/php / usr/share/cacti/poller.php-- force
OK u:0.00 s:0.00 r:0.05
OK u:0.00 s:0.00 r:0.05
OK u:0.00 s:0.00 r:0.07
OK u:0.00 s:0.00 r:0.07
OK u:0.00 s:0.00 r:0.11
OK u:0.00 s:0.00 r:0.11
OK u:0.00 s:0.00 r:0.17
OK u:0.00 s:0.00 r:0.17
OK u:0.00 s:0.00 r:0.27
OK u:0.00 s:0.00 r:0.27
OK u:0.00 s:0.00 r:0.29
OK u:0.00 s:0.00 r:0.29
OK u:0.00 s:0.00 r:0.30
OK u:0.00 s:0.00 r:0.30
OK u:0.00 s:0.01 r:0.31
OK u:0.00 s:0.01 r:0.32
OK u:0.00 s:0.01 r:0.34
OK u:0.00 s:0.01 r:0.34
10MB 282016 11:58:02 AM-SYSTEM STATS: Time:0.4926 Method:cmd.php Processes:1 Threads:N/A Hosts:4 HostsPerProcess:4 DataSources:13 RRDsProcessed:9
11:58:02 AM-WEATHERMAP: Poller [0] Weathermap 0.97a starting-Normal logging mode. Turn on DEBUG in Cacti for more information
10 Oct 28 seconds with 11:58:02 AM-WEATHERMAP: Poller [0] STATS: Weathermap 0.97a run complete-Fri, 28 Oct 16 11:58:02 + 0800: 0 maps were run in 0 seconds with 0 warnings.
Be sure to delete all files under usr/share/cacti/rra/ before executing
/ usr/bin/php / usr/share/cacti/poller.php-- force, otherwise some rra will report the wrong time!
After a while, the long-lost image will come out.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.