Cacti for CentO monitoring and Installation

Source: Internet
Author: User

Cacti for CentO monitoring and Installation

1, CactiMonitoring Introduction

Cacti is a set of network traffic monitoring graphical analysis tools developed based on PHP, MySQL, SNMP and RRDTool.

Cacti is a software implemented in php. Its main function is to use the SNMP service to obtain data and then use rrdtool to store and update data, when you need to view data, use RRDTool to generate charts and present them to users. Therefore, SNMP and RRDTool are the key to Cacti. SNMPSnmp is related to data collection, and RRDTool is related to data storage and chart generation.

SNMP (Simple Network Management Protocol) is used to collect internal data, such as load, disk status, and bandwidth. Network monitoring tools such as Cacti use this data to generate icons for monitoring purposes.

In a typical Cacti and SNMP deployment, one or more SNMP-enabled devices and an independent monitoring server are used to collect SNMP feedback from those devices, SNMP must be enabled for the device to be monitored.

MySQL works with PHP programs to store some variable data and call the variable data, such as the host name, Host IP address, SNMP group name, port number, template information, and other variables.

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 ). RRDTool processes RRD files for data update and storage, and RRD files are RoundRobin Archive files with fixed sizes. The number of data records that RRDTool can store has been defined at the time of creation.

2Deploy CactiMonitoring Service

Preparations before installation:

1) add firewall rules

Vim/etc/sysconfig/iptables

-A input-m state -- state NEW-m tcp-p tcp -- dport 80-j ACCEPT

#-A input-m state -- state NEW-m tcp-p tcp -- dport 3306-j ACCEPT # the same database machine does not need

-A input-m state -- state NEW-m udp-p udp -- dport 161-j ACCEPT

: Wq # Save and exit

/Etc/init. d/iptables restart # restart the firewall to make the configuration take effect.

2) Disable SELinux

Vim/etc/selinux/config

# SELINUX = enforcing # comment out

# SELINUXTYPE = targeted # comment out

SELINUX = disabled # Add

: Wq! # Save and exit

Setenforce 0 # Make the configuration take effect immediately, and restart the system to take effect permanently

3) Monitoring Environment Description:

Type operating system IP Address

Monitoring Server CentOS6.7 x86_64 192.168.17.10

Monitoring client CentOS6.7 x86_64 192.168.17.20

Monitoring client Windows 7 192.168.17.1

There are two hosts in the LAN, one for Linux and one for Windows. Now you need to configure a Cacti monitoring server to monitor these two hosts.

The following operations are performed on the monitored server (192.168.17.10.

1) Because yum is used for installation, the epel extension source is required.

Yum install-y epel-release

2) install the LAMP environment and install it using yum (based on the actual environment, it is recommended to install it using the source code)

Yum install-y httpd php-mysql-servermysql-devel php-gd libjpeg-devellibpng libpng-devel

3) install cacti and net-snmprrdtool

Yum install-y cacti net-snmpnet-snmp-utils rrdtool

4) Start the mysql, apache, and snmp services respectively.

/Etc/init. d/mysqld start

/Etc/init. d/httpd start

/Etc/init. d/snmpd start

5) modify the Apache configuration file http. conf (/etc/httpd/conf/httpd. conf) and cacti. conf (/etc/httpd/conf. d/cacti. conf)

Vim/etc/httpd/conf/httpd. conf

Remove "# ServerName www.example.com: 80" and change "#" to "ServerNamewww.example.com: 80"

Vim/etc/httpd/conf. d/cacti. conf

Change "Deny from all" to "Allow from all"

/Etc/init. d/httpd restart

6) create a cacti database and a cacti user

Mysql-uroot-e "create database cacti" # create a database

Mysql-uroot-e "grant all on cacti. * to 'cacti' @ '127. 0.0.1 'identified by 'cacti ';"

# Create a cacti user

Mysql-uroot cacti </usr/share/doc/cacti-0.8.8b/cacti. SQL

# Import the cacti database template file

7) modify the cacti configuration file used to connect to the database

Vim/usr/share/cacti/include/config. php is changed as follows:

$ Database_type = "mysql"; # Database Type

$ Database_default = "cacti"; # default database

$ Database_hostname = "127.0.0.1"; # Database address

$ Database_username = "cacti"; # database username

$ Database_password = "cacti"; # Database Password

$ Database_port = "3306"; # Database port number

$ Database_ssl = false;

8. Access cacti through web browsing and install

Http: // ip/cacti # ip refers to the ip address used to install the cacti server, which is 192.168.17.10.

Click "next" and "Finish" twice.

Enter admin to log on and reset the new password.

9) execute the poller. php program, generate a graph, and add it to the task plan.

/Usr/bin/php/usr/share/cacti/poller. php # execute the program to generate a graph

Crontab-e # Add:

*/5 */usr/bin/php/usr/share/cacti/poller. php &>/dev/null

So far, the Cacti monitoring server has been installed.

3, Configure the host to be monitored (Monitoring client)

1) configure the Linux Client

Install net-snmp and other related software packages on the Linux client, and enable the firewall UDP161 port.

(1) Enable Firewall UDP port 161

Vim/etc/sysconfig/iptables # edit Firewall Configuration

-A input-m state -- state NEW-m udp-p udp -- dport 161-j ACCEPT

/Etc/init. d/iptables restart # restart the firewall to make the configuration take effect.

(2) install net-snmp and lm_sensors (Linux Hardware monitoring software)

Yum install-y net-snmp lm_sensors

(3) Configure snmpd. conf (/etc/snmp/snmpd. conf) and start the snmp service

Modify syslocation and syscontact. syslocation can write the local ip address and syscontact can write the Administrator email address.

Syslocation 192.168.17.20

Syscontact Root balich@foxmail.com

In the configuration file, modify the settings as follows. If you do not modify the settings, the NIC option cannot be found during Nic detection;

Viewsystemview embedded ded. 1.3.6.1.2.1.1

To:

Viewsystemview encoded ded. 1.3.6.1.2.1

: Wq # Save and exit

/Etc/init. d/snmpd start # start the snmp service

2) configure the windows Client

Here is windows 7, which may be different from the 2003 system, but the basic idea is the same.

(1) start to Control Panel to uninstall programs to enable or disable Windows functions

Select Simple Network Management Protocol (SNMP) and click OK.

(2) Start-run and enter [services. msc] To go to service management.

Find SNMP Service and double-click it. A dialog box is displayed;

In [security], click "accepted community name" and click "add" à "community name" to fill in "public"

In [security], "Accept SNMP packets from the following hosts", click "add" à "192.168.17.10"

Click OK]

Click "restart" in the upper left corner.

So far, the Windows host has been configured

4Set CactiMonitoring Server for WindowsAnd LinuxHost monitoring

1) Add monitoring for Linux Hosts

Log on to the cacti console, click console> Device, and click Add in the upper right corner]

Description: Write the local ip address or your custom name (webserver)

Hostname write local ip address (192.168.17.20)

Select ucd/net SNMP Host as the Host Template

Select Version 2 for SNMP Version

Click Create in the lower-right corner.

Click "Create Graphs for this Host" in the upper right corner"

Graph Types: select SNMP-InterfaceStatistics.

Select the network card to be monitored in the following box. For example, select eth0, check in the rightmost small box, and click Create in the lower right corner.

Click Graph Trees on the left.

Select "Default Tree"

Click Add in the upper-right corner.

Select "Host" for Tree Item Type"

Host: select the ip address of the machine we just added.

Click create in the lower-right corner.

Click Graphs in the upper left corner.

You can see on the left

The host we just added under the Defaut Tree will not come out so quickly at the beginning. It will take a while.

2) Add monitoring for Windows Hosts

In the cacti management background, click console> Device, and click Add in the upper right corner]

Description: Write the local ip address or your custom name (Windows 7)

Hostname write local ip address (192.168.17.1)

Select Windows 2000/XP Host as the Host Template.

Select Version 2 for SNMP Version

Click Create in the lower-right corner.

Click "Create Graphs for this Host" in the upper right corner"

Graph Types: select SNMP-InterfaceStatistics.

In the following box, select the nic and disk to be monitored, select the corresponding area, and click Create in the lower right corner.

Click Graph Trees on the left.

Select "Default Tree"

Click Add in the upper-right corner.

Select "Host" for Tree Item Type"

Host: select the ip address of the machine we just added.

Click create in the lower-right corner.

Click Graphs in the upper left corner.

You can see on the left

The host we just added under the Defaut Tree will not come out so quickly at the beginning. It will take a while.

So far, the host monitoring settings have been completed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.