(4)配置完成后,chkconfig snmpd on
service snmpd start
测试是否成功:
snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex
若成功会显示类似与以下:
ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.127.0.0.1 = 1
ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.192.168.0.20 = 2
(5)yum install rrdtool
或者是: 下载 rrdtool-1.4.4.tar.gz(然后tar zxf rrdtool-1.4.4.tar.gz
cd rrdtool-1.4.4
./configure && make && make install
ln -s /usr/local/rrdtool-1.4.4/bin/rrdtool /usr/local/bin)
(6)cd ~
lftp 192.168.0.254
cd /pub/docs/cacti
get cacti-0.8.7g.tar.gz(主程,主要的调用模块) cacti-plugin-0.8.7g-PA-v2.8.tar.gz(这是一个插件,用于扩展) cacti-spline-0.8.7g.tar.gz(用于加速的,与数据库的交互,本来默认的是cnmd的速度不快)
tar zxf cacti-0.8.7g.tar.gz -C /var/www/html (-C选项是指定解压目录。)
cd /var/www/html
mv cacti-0.8.7g cacti
useradd cacti
cd cacti
chown -R cacti rra log(将目录rra和log以及其下的文件的所有者改为cacti,这样cacti用户可以向里面写东西。)
ll cacti.sql
mysqladmin create cacti(创建库名)
mysql cacti < cacti.sql(该两句是创建数据库cacti,并且把cacti.sql导进去)
mysql
grant all on cacti.* to cacti@localhost identified by 'cacti';
(给用户cacti登录本地密码是cacti,对数据库的cacti的所有表具有所以的权限。)
flush privileges;
quit
(6)
cd /var/www/html/cacti/include
vi config.php
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "cacti";
$database_port = "3306";
(7)crontab -u cacti -e(以用户cacti的身份来编制crontab文件。)
或者是su - cacti crontab -e 编写;
*/5 * * * * php /var/www/html/cacti/poller.php >/dev/null 2>&1
(该句指令的意思是每隔五分钟执行一次 php /var/www/html/cacti/poller.php,在这里php是个命令,然后将输出的正确的还是错的全都输入到/dev/null中去,所有没有文件显示你的命令的输出,你只有最后去cd /var/www/html/cacti/log cat cacti.log 和 ll /var/www/html/cacti/rra可以显示你的实时更新的文件,与流量有关的。)
/etc/init.d/httpd start
http://192.168.0.20/cacti/install/index.php
http://192.168.0.20/cacti/index.php
user name:admin
password:admin(初始密码是admin。初次登录的时候系统会立即让你去改密码的。)
http://192.168.0.20/cacti/settings.php
(8)yum install automake autoheader -y
libtool主要的一个作用是在编译大型软件的过程中解决了库的依赖问题;
yum install libtool
cd ~
tar zxf cacti-spine-0.8.7g(加速的一种工具。)
cd cacti-spine-0.8.7g
(1.autoscan (autoconf): 扫描源代码以搜寻普通的可移植性问题,比如检查编译器,库,头文件等,生成文件configure.scan,它是configure.ac的一个雏形。
your source files --> [autoscan*] --> [configure.scan] --> configure.ac
2.aclocal (automake):根据已经安装的宏,用户定义宏和acinclud.m4文件中的宏将configure.ac文件所需要的宏集中定义到文件 aclocal.m4中。aclocal是一个perl 脚本程序,它的定义是:“aclocal - create aclocal.m4 by scanning configure.ac”
3.autoheader(autoconf): 根据configure.ac中的某些宏,比如cpp宏定义,运行m4,声称config.h.in4.automake: automake将Makefile.am中定义的结构建立Makefile.in,然后configure脚本将生成的Makefile.in文件转换为Makefile。如果在configure.ac中定义了一些特殊的宏,比如AC_PROG_LIBTOOL,它会调用libtoolize,否则它会自己产生config.guess和config.sub
5.autoconf:将configure.ac中的宏展开,生成configure脚本。这个过程可能要用到aclocal.m4中定义的宏。)
aclocal
libtoolize --force
autoheader
autoconf
automake
./configure
make && make install
cd /usr/local/spine/ect/
cp spine.conf.dist spine.conf
vi spine.conf
DB_Host localhost
DB_Database cacti
DB_User cacti
DB_Pass cacti
DB_Port 3306
ll spine.conf
(9)
cd /usr/local/spine/bin
http://192.168.0.20/cacti/
进入user :admin
password : admin
进入之后会让你修改密码:
你设置完密码之后进去,点击console,然后点击setting,然后再横栏里点击Poller,然后再Poller Type :选择 spine(你选择加速的!),点击上面的Paths:Alternate Poller Paths中填入:/usr/local/spine/bin/spine保存退出。
点击graph,进入graphs->tree Mode,一会每五分钟,你就会再后面看到图形哦!!。因为你的机子只有你自己访问,所以肯定很少啦!)其实你在cat /var/www/html/cacti/log/cacti.log 或者 ll /var/www/html/cacti/rra也会随时间的便会不断的更新,比如最近是13:55,一会过了一个小时是14:55,那么ll /var/www/html/cacti/rra的时间也会更新到14:55.
实验二:
倘若你要监控其他主机的话:
假设你要监控:IP:192.168.0.25
步骤(1).console->device然后点击右上角的Add.
Description:desktop85.example.com
Hostname: 192.168.0.25
Host Template : ucd/net SNMP Host
SNMP Options:
SNMP Version: Version 1
然后点击右下角的create。
(2)create之后在页面的右上角会出现 Create Graphs for this Host,点击一下
选择你要监控的主机Host:desktop25.example.com(192.168.0.25)
Graph Types:All
在下面的Graph Templates下选择:
Graph Template Name
Create: ucd/net - CPU Usage
Create: ucd/net - Load Average
Create: ucd/net - Memory Usage
然后你还可以create:select a graph type to create
在Data Query中选择你要监控的数据。可以全选,
然后再右下角的:select a graph type:In/Out Bits
之后点击Create。
(3)console->Graph Tree
在右上角点击:Add
Name:desktop25.example.com
Sorting Type:Mannual Ordering
然后点击create。
然后再弹出的一个页面上会显示Save Successful。然后你在添加:tree Items 点击右房的Add修改:tree Item Type 选择HOST,在 Tree Item values:Host选择:desktop25.example.com
然后在Round Robin Archive:后面选择:Daily(5 minutes Average)之后点击create。然后点击Save。
(4)此时你可以点击graphs 可以看到Host:desktop25.example.com点击一下可以看到你所监控的desktop25机子上的一些变化。
实验三:在你所监控的服务器上添加扩展:
步骤一:
(1)
cd ~
lftp 192.168.0.254
cd pub/docs/cacti
get cacti-plugin-0.8.7g-PA-v2.8.tar.gz(这是一个插件,用于扩展)
tar zxf cacti-plugin-0.8.7g-PA-v2.8.tar.gz
cd cacti-plugin-arch
less README(可以看一些指导你怎么做的文件!)
cp cacti-plugin-0.8.7g-PA-v2.8.diff /var/www/html/cacti/
cd /var/www/html/cacti
yum install patch
patch -p1 -N < cacti-plugin-0.8.7g-PA-v2.8.diff(打补丁)
cd /var/www/html/cacti/include/
vi config.php
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "cacti";
$database_port = "3306";
$url_path = "/cacti/";
global.php这个文件可以采用默认,不用修改。
(2)cd ~/cacti-plugin-arch
mysql cacti < pa.sql
(3)此时你在访问http://desktop85/cacti点击
console->User Managerment进入之后点击admin你会再下面看到多了一个选项Plugin Management 选中。然后点击Save。
(4)接下来你要添加插件了:
lftp 192.168.0.254
cd pub/docs/cacti
get monitor-0.8.2.tar.gz thold-0.4.3.tar.gz settings-0.5.tar.gz
(你也可以去官方网站下载:http://cactiusers.org)
然后
tar zxf monitor-0.8.2.tar.gz -C /var/www/html/cacti/plugins
tar zxf thold-0.4.3.tar.gz -C /var/www/html/cacti/plugins
tar zxf settings-0.5.tar.gz -C /var/www/html/cacti/plugins
(只是解压到/var/www/html/cacti/plugins就可以了,其他的什么也不做。)
(5)去访问http://desktop85/cacti
console->User management
点击admin将Configure Threshold Templates Configure Thresholds View Thresholds View Monitoring Global Settings添加上。 然后再console->plugin Management点击Monitor,Settings,Thold点击安装或者enable plugin 。你会再横的一栏上看到多了thold monitor这些选项。再monitor中可看到你的设备,没有的话你可以去console->devices添加Monitor Host。再console->setting中也多了好多选项。z
注意如果无法出现图形你去查看/etc/php.ini date.timezone = Asia/Shanghai 还要检查/etc/init.d/crond restart,还有注意监控的那台机子上也要安装snmpd rrdtool (否则不可以监控和画图的噢!)(参阅http://hi.baidu.com/quanzhou722/blog/item/d31431169996345021a4e9db.html)