Monitoring Linux hosts with CACTI

Source: Internet
Author: User
Tags rrdtool snmp snmpwalk

First, the preparatory work

Environment: Centos 5.6

Required Software:

http

Php

Php-mysql

Php-snmp

Mysql

Perl-dbd-mysql

Php-pdo

RRDtool

Net-snmp

Net-snmp-libs

Net-snmp-utils

#下载相关软件

cd/usr/local/src/

wget http://www.cacti.net/downloads/cacti-0.8.7e.tar.gz

Ii. Introduction of the environment

The main monitor is CentOS 5.6

Main monitoring Machine ip=192.168.0.61

Three, installation configuration

(1) Install the APACHE+PHP+GD Web environment on the main monitor machine, recommend compiling and installing, no longer repeat, the Department for convenience with Yum installed



Yum Install http php php-mysql php-snmp mysql mysql-server net-snmp net-snmp-libs net-snmp-utils php-pdo perl-dbd-mysql


(2) Installing Rrdtool,rrdtool on the main monitor is too heavy, so choose Add Source, then install with Yum

Installing RRDtool rrdtool rrdtool-devel rrdtool-php


Download the server and use the command

Yum Localinstall--nogpgcheck


(3) Configuring SNMP

Vi/etc/snmp/snmp.conf

#将下边这行中的default

Com2secnotconfiguser Default Public

#改为127.0.0.1

Com2secnotconfiguser 127.0.0.1 Public

#将下边这行中的systemview

Access Notconfiggroup "" Any noauth exact systemview none None

#改为all

Access Notconfiggroup "" Any noauth exact none none

#将下边这行的注释 "#" to get rid of it,

#view all included. 1 80


Service SNMPD Restart


(4) Installation cacti

#把解压后的包移动到你的相应的web目录

Tar xvf cacti-0.8.7e.tar.gz

MV Cacti-0.8.7e/var/www/html/cacti

(5) Building libraries, authorizing, and importing database structures in the database

#注意导入cacti. SQL when the path to the file

Mysql-p

mysql> CREATE database cacti;

Mysql> Grant all privileges the cacti.* to [e-mail protected] identified by ' cacti ' with GRANT option;

Mysql> Grant all privileges the cacti.* to [e-mail protected] identified by ' cacti ' with GRANT option;

mysql> use cacti;

Mysql> Source/var/www/html/cacti/cacti.sql;

#配置cacti以连接数据库

vi/var/www/html/cacti/include/config.php

(6) Under Browser configuration

#用浏览器打开 Http://192.168.0.61/cacti, the cacti Installation guide will be displayed and the settings will not appear again.

#点击 "Next"

#选择 "New Install", click "Next"

#指定 RRDtool, PHP, SNMP tool Binary file path, to ensure that all paths are displayed "FOUND", no "not FOUND", click Finish to complete the installation.

#Cacti default username and password is admin, enter username and password, click Login

#为了安全的原因, after the first successful login, cacti will force you to change a new password, enter a new password and confirm the password, click Save, go to cacti Console interface:

#点击 graphs, view the chart for cacti monitoring this machine:

(7) Increase into a scheduled task, so that cacti every five minutes to generate a monitoring chart.

Crontab-e

#加入如下内容. Note the path of the poller.php

*/5 * * * * php/var/www/html/cacti/poller.php >/dev/null 2>&1

#确保/var/www/html/cacti/rra/Directory exists

#如果暂时未看到图表, can be executed manually, generate graphs

#php/var/www/html/cacti/poller.php >/dev/null 2>&1

(8) Monitoring Linux hosts with CACTI

#在被监控的linux主机上安装net-SNMP

Yum Install Net-snmp

Vi/etc/snmp/snmpd.conf

#更改以下部分

#将下边这行中的default

Com2secnotconfiguser Default Public

#改为10.0.0.52 (cacti) server address)

Com2secnotconfiguser 10.0.0.52 Public

#将下边这行中的systemview

Access Notconfiggroup "" Any noauth exact systemview none None

#改为all

Access Notconfiggroup "" Any noauth exact none none

#将下边这行的注释 "#" to get rid of it,

#view all included. 1 80

Service SNMPD Restart

(9) If there is a problem, please note that the version 1 of the SNMP protocol is a workaround

If you use version 1, you need to change all the monitors and the snmpd.conf of the monitored machine.

#vi/etc/snmp/snmpd.conf

#将下边这行

View SystemView included. 1.3.6.1.2.1.1

#改为

View SystemView included. 1.3.6.1.2.1



Second, cacti common plug-in installation

Before installing another plug-in, install a patch--plugin Architecture of cacti to support plug-ins

PA 2.8 = Cacti 0.8.7g


# tar XVF cacti-plugin-0.8.7g-pa-v2.8.tar.gz

# cp-r cacti-plugin-arch/*/var/www/html/cacti/

cd/var/www/html/cacti/

Mysql-ucacti-pcacti Cacti <pa.sql

Patch-p1-n <cacti-plugin-0.8.7g-pa-v2.8.diff

VI include/config.php

Modified to $url_path = "/cacti/";

Login to enable PA.


Install common plugins

Monitor,settings,thold


# tar ZXVF monitor-latest.tgz

# tar ZXVF settings-latest.tgz

# tar ZXVF thold-latest.tgz

# MV monitor-0.9//var/www/cacti/plugins/monitor

# MV Settings-0.6//var/www/cacti/plugins/settings

# MV Thold-0.41//var/www/cacti/plugins/thold

Login install to enable the corresponding plug-in.



Vi. Common troubleshooting

A PNG image with no data visible on the browser is installed. Look at Apache's log.

If it appears:

========================

[Thu Feb 09 15:12:24 2006] [ERROR] [Client 127.0.0.1] File does not exist:/var/www/html/favicon.ico

Error:opening '/var/www/html/cacti/rra/localhost_mem_buffers_3.rrd ': Permission denied

PS: Workaround: Turn off SELinux to resolve the issue.


PS: The above can not get the data graph mostly with poller.php,cmd.php permission.

Error when cacti has a graph with no data, and the state is Nan

PS: This is probably a problem with SNMP, execute the following command without getting the result. Indicates that SNMP does not support 64-bit MIB libraries. Recompile install SNMP

# Snmpwalk-c public-v 2c 127.0.0.1 If-mib::ifhcinoctets

If-mib::ifhcinoctets.1 = counter64:7437357

If-mib::ifhcinoctets.2 = Counter64:353773if-mib::ifhcinoctets.3 = counter64:0

PS: the monitored host cannot obtain SNMP information, and may be caused by inconsistent SNMP versions of the host and the current host.

The Ps:rrdtools version should be consistent, especially when upgrading cacti. Versions are inconsistent, and may RRA data formats differently. Can not be processed.

Line up the wrong idea

1. View log files under log. Usually there will be a hint

2, test that SNMP is not working properly snmpwalk-v 2c-c public hostip If normal, some data will appear. Some errors may occur, and there will be corresponding error prompts.

3, Auto Run poller.php No. There are no users joining the cacti. There is no permission to write rra/log/to the cacti User:

4,crontab–u cactiuser–e for Cactiuser Plus auto-run poller.php tasks: */5 * * * * root/usr/local/bin/php /usr/local/share/cacti/poller.php/dev/null 2>&1

Refresh data once in 5 minutes. You can also set it as needed.

5. Add the cmd.php and poller.php files in the cacti directory to the permission to run.


=

Script Download and Settings


wget http://mysql-cacti-templates.googlecode.com/files/mysql-cacti-templates-1.1.2.tar.gz

TAR-XZVF mysql-cacti-templates-1.1.2.tar.gz

CD mysql-cacti-templates-1.1.2

CP ss_get_mysql_stats.php/xok.la/cacti/scripts

You can see that there are multiple monitoring items in it, and the report monitors Apache and Nginx. I'm only testing mysql,mysql related to 2 files:

Template file: Cacti_host_template_x_db_server_ht_0.8.6i.xml

Plugin: ss_get_mysql_stats.php


Modify the 30th line of the ss_get_mysql_stats.php file


$mysql _user = ' cacti ';

$mysql _pass = ' cacti ';

$cache _dir = "var/www/html/cacti/cache/";

Set up account-related information for the database you are preparing to monitor


mkdir/xok.la/cacti/cache/


chmod 777-r/xok.la/cacti/cache/

By default, the obtained data/tmp/, there will be cacti can not read the situation. So put it in the cacti directory.


Second, create the account and permissions required to monitor MySQL

Configure the MySQL server so that the cacti machine can access the status information of the MySQL server and must have "process" permission. If you want to monitor the InnoDB status, you must also have "SUPER" permissions.


Mysql> Grant Process,super on * * to ' cacti ' @ '% ' identified by ' cacti ';

Mysql> grant all privileges on cacti.* to [email protected] '% ' identified by ' cacti ';

Three, template import

Import Cacti_host_template_x_db_server_ht_0.8.6i.xml in the Cacti Management interface (import Templates).


Iv. Adding a Device


Create graph. In the left menu bar under the Console tab, select Devices, create a new devices for the host you want to monitor, or select an existing devices.

Add graph Templates (such as x MySQL Connections gt template) that you want to monitor the MySQL status in associated graph Templates.

and click on the top of the create Graphs for this host link, select the x MySQL Connections GT in the Graph Templates selection box, then click the Create button and the following Web page appears.


Monitoring Linux hosts with CACTI

Related Article

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.