好了,到此lamp就安装完成了
3、安装net-snmp
[root@cacti ~]# yum install -y net-snmp net-snmp-utils 4、修改snmp的配置文件
[root@cacti ~]# cd /etc/snmp/
[root@cacti snmp]# cp snmpd.conf snmpd.conf.bak
[root@cacti snmp]# vim snmpd.conf
去掉末尾.1
#view systemview included .1.3.6.1.2.1.1
view systemview included .1.3.6.1.2.1
启动net-snmp,并测试net-snmp能够正常工作
[root@cacti ~]# service snmpd start
Starting snmpd: [ OK ]
[root@cacti ~]# snmpnetstat -v 2c -c public -Ca -Cp tcp localhost
Active Internet (tcp) Connections (including servers)
Proto Local Address Remote Address (state)
tcp *.ssh *.* LISTEN
tcp *.mysql *.* LISTEN
tcp localhost.smtp *.* LISTEN
tcp localhost.smux *.* LISTEN
tcp localhost.ssh localhost.53011 ESTABLISHED 5、安装RRDTool
[root@cacti ~]# yum install -y rrdtool
测试RRDTool能够正常工作
[root@cacti ~]# rrdtool -v
RRDtool 1.3.8 Copyright 1997-2009 by Tobias Oetiker
Compiled Aug 21 2010 10:57:18
Usage: rrdtool [options] command command_options
Valid commands: create, update, updatev, graph, graphv, dump, restore,
last, lastupdate, first, info, fetch, tune,
resize, xport
RRDtool is distributed under the Terms of the GNU General
Public License Version 2. (www.gnu.org/copyleft/gpl.html)
For more information read the RRD manpages 6、安装配置cacti
[root@cacti src]# tar xf cacti-0.8.8b.tar.gz -C /var/www/html/
[root@cacti src]# cd /var/www/html/
[root@cacti html]# ll
total 8
drwxr-xr-x. 13 1000 users 4096 Aug 6 2013 cacti-0.8.8b
[root@cacti html]# mv cacti-0.8.8b cacti
#创建cacti数据库,并导入cacti.sql到数据库中
[root@cacti ~]# cd /var/www/html/cacti/
[root@cacti cacti]# mysqladmin create cactidb
[root@cacti cacti]# ll cacti.sql #cacti源码包中自带的cacti数据库
-rw-r--r--. 1 1000 users 178349 Aug 6 2013 cacti.sql
[root@cacti cacti]# mysql cactidb < cacti.sql #导入自带的cacti数据库
#创建授权用户
[root@cacti ~]# mysql -e "GRANT ALL ON cactidb.* TO cactiuser@localhost IDENTIFIED BY 'cactiuser'"
[root@cacti ~]# mysqladmin flush-privileges
[root@cacti ~]# mysql -ucactiuser -pcactiuser
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.1.73 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| cactidb |
| test |
+--------------------+
3 rows in set (0.01 sec)
mysql> \q
Bye
#修改cacti连接数据库的程序文件
[root@cacti ~]# cd /var/www/html/cacti/include/
[root@cacti include]# cp config.php config.php.bak
[root@cacti include]# vim config.php
/* make sure these values refect your actual database/host/user/password */
$database_type = "mysql";
$database_default = "cactidb"; #修改使用的数据库
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "cactiuser";
$database_port = "3306";
$database_ssl = false;
/*
Edit this to point to the default URL of your Cacti install
ex: if your cacti install as at http://serverip/cacti/ this
would be set to /cacti/
*/
//$url_path = "/cacti/";
#下面我们来创建一个cacti用户(安装初始化cacti)并修改相关目录权限,
[root@cacti ~]# cd /var/www/html/cacti/
[root@cacti cacti]# useradd cactiuser
[root@cacti cacti]# chown -R cactiuser:cactiuser log/ rra/ 7、浏览器访问cacti
输入cacti服务器的地址http://192.168.0.104/cacti http://s3.运维网.com/wyfs02/M02/2F/4E/wKiom1OfDBaDglOAAAO6gB3cRlE242.jpg
点击【Next】 进行下一步安装 http://s3.运维网.com/wyfs02/M01/2F/4E/wKioL1OfDCuQ-10HAAHMUUCurS4194.jpg
选择【New Install】,点击【Next】进行下一步安装 http://s3.运维网.com/wyfs02/M01/2F/4E/wKiom1OfDIjAfgQOAATVFgK8s2A738.jpg
监测是否有权限错误,如果有,请修改对应目录的权限,然后点击【Finsh】,进行下一步 http://s3.运维网.com/wyfs02/M00/2F/4E/wKiom1OfDRaB-LhMAAF1mkalPkc890.jpg
输入账户和密码,默认都是admin,点击【Login】,进行下一步 http://s3.运维网.com/wyfs02/M00/2F/4E/wKioL1OfDRXiJBjkAAG0wZOkqGM922.jpg
系统提示:强制修改密码,然后平【Save】,进行下一步安装;进入cacti的首页面 http://s3.运维网.com/wyfs02/M02/2F/4E/wKiom1OfDcHxbI9MAAOxrLYeoZM809.jpg好了,到这里我们已经可以看cacti的配置界面了,下面我们就来详细的看一下。从上图中我们可以看到最上面有两个标签一个是红颜色的“console”控制台标签,另一个是“graphs”图像标签,下面我们点击一下“graphs”标签,如下图:
大家可以从图上看到,由于我们还没做任何配置,所以这里没有任何图像。好了,下面我们就来详细说一说这两个标签中内容。先说,console 标签。
大家先看左边这一栏,从图中我们可以看出,大致分为七个大项和多个项目。下面我们来的罗列一下,分别讲解。
(1).Create 创建
注,脚本只需要指定如何获取数据,并且获取到的数据经过处理后要按元宝输出。案例,
TAG:data TAG:data
input:30 output:40 好了,我们用脚本定义了收集数据方法,也指定了数据输出,那脚本多长时间执行一次呢?执行的时间是cacti程序设置的,下面我们来配置cacti安装的最重要的一步也是最后一步,设置cacti收集数据的默认的任务计划。这里任务计划是由poller.php程序执行的,需要说明的是poller.php是由php写的,单线程的功能相对较弱,为此cacti官方单独开发了一个多线程Spine工具,适合大规模监控应用。好了下面我们就来配置一下任务计划并查看。
[root@cacti ~]# echo '*/5 * * * * /usr/bin/php /var/www/html/cacti/poller.php &>/dev/null' > /var/spool/cron/cactiuser
[root@cacti ~]# crontab -u cactiuser -l
*/5 * * * * /usr/bin/php /var/www/html/cacti/poller.php &>/dev/null 为了防止这个任务计划不执行,我们最好手动验证一下
[root@cacti ~]# su cactiuser
[cactiuser@cacti root]$ /usr/bin/php /var/www/html/cacti/poller.php
PHP Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in /var/www/html/cacti/include/global_constants.php on line 165
PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in /var/www/html/cacti/include/global_constants.php on line 165
PHP Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in /var/www/html/cacti/include/global_constants.php on line 166
PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in /var/www/html/cacti/include/global_constants.php on line 166
PHP Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in /var/www/html/cacti/include/global_constants.php on line 167
PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in /var/www/html/cacti/include/global_constants.php on line 167
PHP Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in /var/www/html/cacti/include/global_constants.php on line 168
PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in /var/www/html/cacti/include/global_constants.php on line 168
PHP Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in /var/www/html/cacti/include/global_constants.php on line 169
PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in /var/www/html/cacti/include/global_constants.php on line 169
PHP Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in /var/www/html/cacti/include/global_constants.php on line 170
PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in /var/www/html/cacti/include/global_constants.php on line 170
PHP Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in /var/www/html/cacti/include/global_constants.php on line 171
PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in /var/www/html/cacti/include/global_constants.php on line 171
PHP Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in /var/www/html/cacti/include/global_arrays.php on line 671
PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in /var/www/html/cacti/include/global_arrays.php on line 671
PHP Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in /var/www/html/cacti/include/global_arrays.php on line 672
PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in /var/www/html/cacti/include/global_arrays.php on line 672
PHP Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in /var/www/html/cacti/include/global_arrays.php on line 673
PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in /var/www/html/cacti/include/global_arrays.php on line 673
PHP Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in /var/www/html/cacti/include/global_arrays.php on line 674
PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in /var/www/html/cacti/include/global_arrays.php on line 674
PHP Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in /var/www/html/cacti/include/global_arrays.php on line 675
PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in /var/www/html/cacti/include/global_arrays.php on line 675
PHP Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in /var/www/html/cacti/include/global_arrays.php on line 676
PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in /var/www/html/cacti/include/global_arrays.php on line 676
PHP Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in /var/www/html/cacti/include/global_arrays.php on line 677
PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in /var/www/html/cacti/include/global_arrays.php on line 677 输出后有警告信息,提示时区有问题;接下来我们来修改php配置文件的时区
[root@cacti ~]# vim /etc/php.ini
[Date]
; Defines the default timezone used by the date functions
; http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone
;date.timezone =
date.timezone = Asia/Shanghai
[root@cacti ~]# service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ] 接下来我们再来测试一下
[cactiuser@cacti root]$ /usr/bin/php /var/www/html/cacti/poller.php
#查看一下cacti输出日志
[cactiuser@cacti root]$ cd /var/www/html/cacti/log
[cactiuser@cacti log]$ tail -f
cacti.log .htaccess
[cactiuser@cacti log]$ tail -f cacti.log
06/16/2014 07:35:02 PM - SYSTEM STATS: Time:0.5954 Method:cmd.php Processes:1 Threads:N/A Hosts:2 HostsPerProcess:2 DataSources:5 RRDsProcessed:5
06/16/2014 07:40:02 PM - SYSTEM STATS: Time:0.3670 Method:cmd.php Processes:1 Threads:N/A Hosts:2 HostsPerProcess:2 DataSources:5 RRDsProcessed:5
06/17/2014 07:45:01 AM - SYSTEM STATS: Time:0.2106 Method:cmd.php Processes:1 Threads:N/A Hosts:2 HostsPerProcess:2 DataSources:5 RRDsProcessed:5 7、配置Cacti监控本机
首先我们点击一下“Devices”标签,出下以下界面,大家从图中可以看出,默认的主机就是Localhost。 http://s3.运维网.com/wyfs02/M01/2F/4E/wKiom1OfFLSAzPQuAALzofzW608100.jpg http://s3.运维网.com/wyfs02/M00/2F/4E/wKioL1OfFJfx7peIAAQP2AKp9N8529.jpg
接下来我们点击一下“Localhost”主机,出现以下界面。 http://s3.运维网.com/wyfs02/M02/2F/4E/wKiom1OfFOGT-C5yAAUm27XnNwg456.jpg
上图是默认的配置,我们只要修改一处即可,便是“SNMP Options”。如下图http://s3.运维网.com/wyfs02/M01/2F/4E/wKioL1OfFL3jBscmAAYkABNW3Mc425.jpg
接下来我们选择右上脚的“Create Graphs for this Host”(为这个主机增加监控图形), http://s3.运维网.com/wyfs02/M00/2F/4E/wKiom1OfFTqw1DNdAAVI5tZQmAE872.jpg
我们选择监控本地主机的磁盘空间,点击“Create”即可。下面我们来点击最上面的“Graph”标签 。如下图,