Working principle diagram:
650) this. length = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/095111I62-0.png "title =" 56830ac83311448a8065c609acb998cd.png "width =" 600 "height =" 237 "border =" 0 "hspace =" 0 "vspace =" 0 "style =" width: 600px; height: 237px; "alt =" 092233980.png"/>
The entire system consists of four parts:
1. the Cacti system platform is used to set and view charts. Cacti requires the support of the LAMP environment.
2. snmp is used to collect data and map the data to rrdtool. Port 161.162 is used and the MIB database is used to maintain data information. The positioning data based on the OID is similar to 1.3.6.1.2.1 ); in Linux, use the snmpget and snmpwalk programs that come with net-snmp, and use the snmp function of php in Windows.
3. The RRDTool graphics engine is used to store and draw images for performance data.
4. the Mysql database is used to store the information required for RRDTool plotting.
Common monitoring objects of cacti:
1. Server resources: CPU, memory, disk, process, and connections
2. server type: WEB, Mail, FTP, and database
3. Network Interfaces: traffic, forwarding speed, and Packet Loss Rate
Cacti focuses on network traffic, system load monitoring network traffic, cpu, hard disk usage, etc)
1. Install cacti Based on the lamp environment apache + mysql + php + net-snmp + rrdtool)
yum install -y httpd httpd-devel mysql mysql-server mysql-devel php php-devel php-mysql php-common php-gd php-mbstring php-xml php-imap php-ldap php-odbc php-pear php-xmlrpc php-bcmath gd gd-devel freetype freetype-devel libjpeg libjpeg-devel libpng libpng-devel zlib zlib-devel libxml2 libxml2-devel libjpeg* libgcrypt libgcrypt-devel libxslt libxslt-devel php-snmp net-snmp net-snmp-utils perl-DBI rrdtool perl-rrdtool perl-DBD-MySQL net-snmp-libs lm_sensorsservice httpd startservice mysqld startchkconfig httpd onchkconfig mysqld on
Ii. install and configure cacti
1. Install cacti
wget http://www.cacti.net/downloads/cacti-0.8.8b.tar.gztar zxvf cacti-0.8.8b.tar.gzmv cacti-0.8.8b/* /var/www/html
2. Import the database structure
mysql>create database cacti;mysql>use cacti;mysql>source /var/www/html/cacti.sql;
3. Configure cacti to connect to the database:
Vi/var/www/html/include/config. php $ database_type = "mysql"; $ database_default = "cacti"; $ database_hostname = "localhost"; $ database_username = "root"; $ database_password = "password "; $ database_port = "3306"; $ database_ssl = false;
4. Configure snmp to monitor local hosts
vi /etc/snmp/snmpd.confcom2sec notConfigUser 127.0.0.1 publicaccess notConfigGroup "" any noauth exact all none noneview all included .1 80service snmpd restart
Iii. Other cacti configurations
1. Set the time zone in php
vi /etc/php.inidate.timezone = Asia/Shanghaiservice httpd restart
2. Run it once to generate the initial image file:
/usr/bin/php /var/www/html/poller.php
3. Set a scheduled task to generate a chart every five minutes:
crontab -e*/5 * * * * /usr/bin/php /var/www/html/poller.php
4. Modify the default cacti settings: console-> setting
650) this. length = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/0951111504-1.jpg "title =" qq 30915103755.jpg "width =" 500 "height =" 94 "border =" 0 "hspace =" 0 "vspace =" 0 "style =" width: 500px; height: 94px; "alt =" 103846489.jpg"/>
Rrdtool-v # view rrdtool version
Snmp version: sets the snmp version, which is generally version2.
Snmp community: Set the community name. The default value is public.
5. Set permissions:
chown -R apache.root /var/www/html/chmod 775 -R /var/www/htmlchmod 777 /var/www/html/rra /var/www/html/log
6. Enter the http address: // ip address to specify the default path of the component. Next, complete. The default account and password are admin.
650) this. length = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/095111KK-2.jpg "title =" qq 30920200352.jpg "width =" 500 "height =" 305 "border =" 0 "hspace =" 0 "vspace =" 0 "style =" width: 500px; height: 305px; "alt =" 200347818.jpg"/>
After the configuration, check the localhost and find that the image is-nan: 650) this. length = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/0951116329-3.jpg "title =" qq 30920200249.jpg "alt =" 200639488.jpg" width = "500" height = "203" border = "0" hspace = "0" vspace = "0" style = "width: 500px; height: 203px; "/>
Solution: rrdtool fetch-r 300 localhost_mem_buffers_3.rrd AVERAGE # obtain the captured information using rrdtool. The result is-nan. Now, the last date is 1379679000, when date + % s gets more than the last date, it is time to plot the data.
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/09511161I-4.jpg "title =" qq 30920200840.jpg "alt =" 200858899.jpg"/>
4. Linux host monitoring
Configured SNMP for the monitored Host:
Yum install-y net-snmp-* vi/etc/snmp/snmpd. confcom2sec notConfigUser 192.168.0.10 public # change to allow IPaccess notConfigGroup for host monitoring "" any noauth exact all none noneview all included. 1 80 service snmpd restart # restart snmp
Add a device to the monitoring host:
Console-> Device-> Add-> create
650) this. length = 650; "src =" http://www.bkjia.com/uploads/allimg/131227/095111O39-5.jpg "title =" qq 30915144511.jpg "width =" 500 "height =" 276 "border =" 0 "hspace =" 0 "vspace =" 0 "style =" width: 500px; height: 276px; "alt =" 144542288.jpg"/>
Add to graph tree:
Console-> Graph Trees-> Add-> Tree Item Type-> Host-> select Host-> create
V. Monitoring Windows Hosts
First, the snmp Service has been added to the host, and then the installation of snmp-informant-std will have more SNMP traps in the Service, no need to configure, and then configure the Snmp Service:
Start-run-services. msc, find "snmp service", right-click "properties", select "security", click "add" in "accept group name ", write the community used by your cacti in "group name", select "Accept snmp Packets from these hosts", the default value is "localhost", and click "edit ", change "localhost" to the actual IP address of the cacti monitoring server!
6. Solve the following problems without drawing or data
1. The image is not generated. Run #/usr/bin/php/var/www/html/poller. php.
2. Permission problem: Modify the permission # chmod 777-R/var/www/html/rra/var/www/html/log/
3. Check for data output in snmp configuration # snmpwalk-v2c-c public 127.0.0.1
4. Delete all files under rra and clear the cache # system utilities-> Rebuild poller cache
5. the system time is incorrect. Reset the time.
6. The database table is damaged and repaired # mysqlcheck-ao cacti-auto-repair-uroot-p
7. Try to restart the snmpd service # service snmpd restart
This article is from the "Linux popular technology" blog, please be sure to keep this source http://going.blog.51cto.com/7876557/1297289