上篇博文主要讲解了cacti监控host主机,由于上篇博文cacti的版本也不是最新的!所以在实战2更新了cacti的版本,并添加了监控远程服务器和优化轮询
实战2 重点
一、新版cacti监控host
二、新版cacti监控Remote Host
三、新版cacti优化spine轮询
附加
四、网卡流量和存储挂在盘
一、新版cacti监控host
1、安装lamp平台
1
|
[root@cacti ~]
# yum install -y httpd php php-mysql php-snmp php-xml php-gd mysql mysql-server gd gd-devel
|
2、启动服务,设置开机自启动
1
2
3
4
|
[root@cacti ~]
# service httpd start
[root@cacti ~]
# service mysqld start
[root@cacti ~]
# chkconfig httpd on
[root@cacti ~]
# chkconfig mysqld on
|
3、测试httpd是否能够正常工作
4、测试php能够正常工作
[root@cacti ~]# cat /var/www/html/a.php
<?php
phpinfo();
?>
好了,到此lamp就安装完成了
3、安装net-snmp
1
|
[root@cacti ~]# yum install -y net-snmp net-snmp-utils
|
4、修改snmp的配置文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
[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
1
2
3
4
5
6
7
8
9
10
11
12
|
[root@cacti ~]
# yum install -y rrdtool
测试RRDTool能够正常工作
[root@cacti ~]
# rrdtool -v
RRDtool 1.3.8 Copyright 1997-2009 by Tobias Oetiker <tobi@oetiker.ch>
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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
[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
点击【Next】 进行下一步安装
选择【New Install】,点击【Next】进行下一步安装
监测是否有权限错误,如果有,请修改对应目录的权限,然后点击【Finsh】,进行下一步
输入账户和密码,默认都是admin,点击【Login】,进行下一步
系统提示:强制修改密码,然后平【Save】,进行下一步安装;进入cacti的首页面
好了,到这里我们已经可以看cacti的配置界面了,下面我们就来详细的看一下。从上图中我们可以看到最上面有两个标签一个是红颜色的“console”控制台标签,另一个是“graphs”图像标签,下面我们点击一下“graphs”标签,如下图:
大家可以从图上看到,由于我们还没做任何配置,所以这里没有任何图像。好了,下面我们就来详细说一说这两个标签中内容。先说,console 标签。
大家先看左边这一栏,从图中我们可以看出,大致分为七个大项和多个项目。下面我们来的罗列一下,分别讲解。
(1).Create 创建
New Graphs 添加新图形
(2).Management 管理
Graph Management 图形管理。可以在此删除、复制图像,Cacti会自动创建图像。不过如果我们有特殊的需要,比如将几张图上的数据合并在一张图像上的话也可以在此手工新建图像;
Graph Trees 图形树。在graphs界面里,图像或devices是树状结构显示的,可以在此设置树的结构;
Data Sources 数据源。记要用来管理rrd文件的,一般无需修改,Cacti会自己创建rrd文件;
Devices 设备管理。这是我们最经常需要修改的地方,可以在此创建新的设备或修改其名称等信息。
(3).Collection Methods 数据收集方法,一般我们无需对这两项进行修改。(非常重要在下面的内容中进行详解)
Data Queries 数据查询,
Data Input Methods 数据输入方法
(4).Templates 模板,这些模板可以导出、导入也可以自己编写,一般无需修改。
Graph Templates 图形模板
Host Templates 主机模板
Data Templates 数据模板
(5).Import/Export 导入/导出,对上述模板的导入、导出。我们可以在Cacti的官方网站上找到这些模板,不过需要注意模板对于的Cacti的版本。
Import Templates 导入模板
Export Templates 导出模板
(6).Configuration 配置
Settings 系统设置,Cacti的主要配置菜单;可以在此重新设置对应的程序的路径、版本等信息。也可以设置图像的输出方式(允许ftp)、显示效果、登陆方式(允许使用LDAP)等。
Plugin Management 插件管理
(7).Utilities 工具
System Utilities 系统工具,显示Cacti系统的一些cache和log信息,如果log文件太大建议直接到后台查看;
User Management 用户管理,可以在此添加、删除用户,并对每个用户设置详细的权限;
Logout User 用户退出
里面的具体内容请大家自己去看,下面我们来讲解一下第三大项收集方法,收集方法即数据收集方法。其中,有两种方法:
数据查询:xml格式数据收集方法
数据输入方法:命令或脚本(比较常用)
注,脚本只需要指定如何获取数据,并且获取到的数据经过处理后要按元宝输出。案例,
1
2
|
TAG:data TAG:data
input:30 output:40
|
好了,我们用脚本定义了收集数据方法,也指定了数据输出,那脚本多长时间执行一次呢?执行的时间是cacti程序设置的,下面我们来配置cacti安装的最重要的一步也是最后一步,设置cacti收集数据的默认的任务计划。这里任务计划是由poller.php程序执行的,需要说明的是poller.php是由php写的,单线程的功能相对较弱,为此cacti官方单独开发了一个多线程Spine工具,适合大规模监控应用。好了下面我们就来配置一下任务计划并查看。
1
2
3
|
[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
|
为了防止这个任务计划不执行,我们最好手动验证一下
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
[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配置文件的时区
1
2
3
4
5
6
7
8
9
10
|
[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 ]
|
接下来我们再来测试一下
1
2
3
4
5
6
7
8
9
|
[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。
接下来我们点击一下“Localhost”主机,出现以下界面。
上图是默认的配置,我们只要修改一处即可,便是“SNMP Options”。如下图
接下来我们选择右上脚的“Create Graphs for this Host”(为这个主机增加监控图形),
我们选择监控本地主机的磁盘空间,点击“Create”即可。下面我们来点击最上面的“Graph”标签 。如下图,
从图中我们可以看到我们新增加的监控磁盘空间的图形还没有出图,我们得等个几分钟才会出现图形,请博友耐心等待。好了,过几分钟就会出现下面的效果图
到这里我们配置Cacti监控localhost就全部完成了
二、新版cacti监控Remote Host
1、客户端安装net-snmp(被监控端)
1
|
[root@node1_cacti ~]# yum install -y net-snmp net-snmp-utils net-snmp-libs
|
2、修改net-snmp配置文件
1
2
3
4
5
6
|
[root@node1_cacti ~]# cd /etc/snmp/
[root@node1_cacti snmp]# cp snmpd.conf snmpd.conf.bak
[root@node1_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
|
3、启动服务并设置开启自启动
1
2
3
4
5
6
7
8
9
10
11
12
13
|
[root@node1_cacti snmp]# service snmpd start
Starting snmpd: [ OK ]
[root@node1_cacti snmp]# chkconfig snmpd on
[root@node1_cacti snmp]# netstat -ntulp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp
0
0
0.0
.
0.0
:
22
0.0
.
0.0
:* LISTEN
1039
/sshd
tcp
0
0
127.0
.
0.1
:
25
0.0
.
0.0
:* LISTEN
1115
/master
tcp
0
0
127.0
.
0.1
:
199
0.0
.
0.0
:* LISTEN
1348
/snmpd
tcp
0
0
:::
22
:::* LISTEN
1039
/sshd
tcp
0
0
::
1
:
25
:::* LISTEN
1115
/master
udp
0
0
0.0
.
0.0
:
161
0.0
.
0.0
:*
1348
/snmpd
udp
0
0
0.0
.
0.0
:
68
0.0
.
0.0
:*
934
/dhclient
|
3、在cacti服务器端测试
1
2
3
4
5
6
7
|
[root@cacti ~]# snmpnetstat -v 2c -c
public
-Can -Cp tcp
192.168
.
0.106
Active Internet (tcp) Connections (including servers)
Proto Local Address Remote Address (state)
tcp *.
22
*.* LISTEN
tcp
127.0
.
0.1
.
25
*.* LISTEN
tcp
127.0
.
0.1
.
199
*.* LISTEN
tcp
192.168
.
0.106
.
22
192.168
.
0.102
.
55805
ESTABLISHED
|
好了,这里我们的实验环境就全部配置完成。下面我们继续……
4、cacti监控远程主机
进入Cacti的console面板->点击“Devices”进入设备面板->
好了,到这里我们主机就增加完成了。下面我们来查看一下。点击“Graph Management”可以看到刚才创建的监测点对应的图像,注意由于Cacti默认每5分钟到监测服务器上取一次数据,所以刚创建的监测点会出现图像不能显示的现象,需要等几分钟查看才会正常显示。
点击分支名称或“Add”新的分支->
好了,到这里我们配置的Cacti监控远程主机配置到这里就全部完成了
三、新版cacti优化spine轮询
注,出于效率原因,在大量采集数据时使用自带的cmd.php轮询器会比较慢,1分钟1次的采集频率可能无法完成轮询所有机器。这里为了优化,采用官方推荐的spine来高效轮询。本例使用源代码编译安装,下载的版本是spine-0.8.8b,所用cacti为0.8.8b。
1、解决依赖关系
1
|
[root@cacti ~]
# yum install -y mysql-devel net-snmp-devel
|
2、安装spine
1
2
3
4
5
|
[root@cacti src]
# yum -y install gcc gcc-c++ make
[root@cacti src]
# tar xf cacti-spine-0.8.8b.tar.gz
[root@cacti src]
# cd cacti-spine-0.8.8b
[root@cacti cacti-spine-0.8.8b]
# ./configure
[root@cacti cacti-spine-0.8.8b]
# make && make install
|
3、提供配置文件并修改
1
2
3
4
5
6
7
8
9
|
[root@cacti ~]
# cp /usr/local/spine/etc/spine.conf.dist /usr/local/spine/etc/spine.conf
[root@cacti ~]
# vim /usr/local/spine/etc/spine.conf
#末尾行
DB_Host localhost
DB_Database cactidb
DB_User cactiuser
DB_Pass cactiuser
DB_Port 3306
DB_PreG 0
|
4、测试是否能够正常工作
1
2
3
4
|
[root@cacti ~]
# /usr/local/spine/bin/spine -C /usr/local/spine/etc/spine.conf
SPINE: Using spine config
file
[
/usr/local/spine/etc/spine
.conf]
SPINE: Version 0.8.8b starting
SPINE: Time: 0.2917 s, Threads: 5, Hosts: 3
|
5、在cacti里设置spine路径
Console -> Configuration -> Settings -> Paths -> Alternate Poller Path -> Spine Poller File Path
|
输入spine路径:/usr/local/spine/bin/spine
6. 修改Cacti使用的Poller Type
Console -> Cacti Settings->Poller->Poller Type
在下拉中选择spine,如下图:
好了,到这里我们spine优化器就安装完成了,这一篇博客就到这里吧
四、网卡流量和存储挂在盘
作为互联网时代,用真实的物理主机做服务器无非是资源的一种浪费,更多的企业为了减少成本,采用了租用云主机或者内部的私有化来搭建各种服务。
就是这一种情况的出现,使得绝大多数的存储盘并不是直接的本地硬盘,而是挂在过来的、这种情况的监控,我们需要额外的添加来实现动态的监控存储盘
1、点击【console】,然后选择【Device】后的《cacti server》来作为实验对象,点击《cacti server》
2、进入《cacti server》选项后,进行添加网卡数据源和挂在磁盘数据源,如下图
注意:
SNMP-Interface Statistics :接口状态也就是网卡流量监控的数据源
ucd/net - Get Monitred Partitions :默认已经添加
Unix - Get Mouted Partitions :挂载分区的监控
Add Data Query:
选择完成后,点击添加如同下;表示网卡和存储盘已经添加
之后我们选择:Create Graphs for this host;
进入后进行网卡接口的选择,有三块网卡,如下图
lo:本地回环接口
eth0:第一块网卡 内网卡
eth1:第二块网卡 外网卡
进入后进行挂在盘的选择,如下图
这个地方自已在做的时候,出现了一点问题就是找不到存储盘,明明在系统上可以看到,无论怎么刷新都不显示,最后才明白,多次点击画黑圈的方框就出来了。
到此,网卡和存储盘的添加就完成了,接下来我们来看看绘图后的效果
内外网卡的监控
挂在盘的监控
到此,实战2就完成了,期待实战3
与运维的朋友一起进步。很高兴结识很多的朋友
本文转自zys467754239 51CTO博客,原文链接:http://blog.51cto.com/467754239/1427119,如需转载请自行联系原作者