使用Cacti监控你的网络(五)- Cacti插件 (2007-08-31 09:37:45)
声明:本系列文档出自石头记,如若转载请注明出处,本人保留文档的所有权,并欢迎转载。
一、Cacti插件
 
Cacti插件是对cacti的扩展。
要使用cacti插件必须先扩展cacti架构,来支持插件。
1.    安装cacti插件架构扩展
当前版本是V1.1,是专门针对cacti V0.8.6设计的。
1).解压下载的tar包,你会得到一个cacti-plugin-arch目录
# tar –zxvf cacti-plugin-arch.tar.gz
# cd cacti-plugin-arch
# ls
使用Cacti监控你的网络(五)- Cacti插件_职场
 
2).有两中方法来安装cacti的插件架构扩展,第一种方法是使用patch文件,patch文件包含了原始文件与修改后文件的不同之处,所以可以使用patch文件来得到新的文件。第二种方法是使用pre-patched文件进行直接覆盖,将与cacti相对应版本的files-0.8.6*目录下的文件直接拷贝到cacti目录下进行覆盖。在此选择使用patch文件进行安装(这也是官网推荐的方法)。将与cacti相应版本的cacti-pligin-0.8.6*.diff文件拷贝到cacti目录下,然后使用patch命令进行安装。
# cp cacti-plugin-0.8.6j.diff /usr/local/apache/htdocs/cacti
//备份cacti目录,以备插件扩展安装失败后能恢复到原状态
# cd /usr/local/apache/htdocs
# cp –r cacti ./cacti.bak
# cd ./cacti
//首先使用以下命令进行测试
# patch -p1 -N --dry-run < cacti-plugin-0.8.6j.diff
//以上命令成功后,使用以下命令进行安装
# patch -p1 -N < cacti-plugin-0.8.6j.diff
3).安装后配置,首先查看你的cacti配置文件,看cacti相关的数据库信息是否被覆盖,如果被覆盖请直接从备份中拷贝一份到配置文件目录。
# cp ../include/config.php ./include/config.php
打开cacti配置文件,找到以下选项
$config['url_path'] = "/";
如过你的cacti能够在浏览器中使用以下方法直接访问,则不用修改cacti配置文件。
[url]http://www.youdomain.com[/url] 或
[url]http://cacti[/url]机器ip
           如果cacti在浏览器中使用以下方法直接访问,
           [url]http://www.youdomain.com/cacti[/url] 或
           [url]http://cacti[/url]机器ip/cacti
$config['url_path'] = "/";必须被修改为$config['url_path'] = "/cacti/";
           注意前后的/不能丢。
           到此cacti插件结构的扩展完成,现在可以下载并安装你需要的cacti插件了。
     
1.    安装插件
插件的安装、升级、移除是很容易的,在安装插件前你必须以确保安装了cacti插件结构扩展。
1).下载插件,在此以Monitor插件为例。
      Monitor插件下载地址:[url]http://cactiusers.org/downloads/[/url]
      解压下载的tar包。
      # tar -zvcf monitor-0.7.tar.gz
      解压后你会得到一个monitor目录。
2.安装Monitor,只需要将monitor目录拷贝到cacti/plugins/目录下即可。如果是升级安装,只需要完全覆盖原monitor目录即可。
3.激活monitor插件,修改cacti配置文件(cacti目录下的include/config.php)。在配置中查找$plugins = array();行,在此行下面加入:
$plugins[] = 'monitor';
注意:上面monitor的名字必须与cacti/plugins/目录下插件目录的名字相同。
4).有些插件需要进行额外的配置,请根据插件的安装文档进行配置,在此略述。
5).移除插件时只要修改cacti配置文件,注释掉与插件相关的行即可。
如:
            //$plugins[] = 'monitor';
6).在console选项卡下,点击左侧菜单中的Settings链接,在右侧出现的web页中点击Misc选项卡来配置Monitor插件。
使用Cacti监控你的网络(五)- Cacti插件_职场_02
 
以下所看到的是Monitor选项卡下所监控的机器状态。当有机器Down掉后,相应机器图标将由绿色变成红色,并发出声音进行报警。
使用Cacti监控你的网络(五)- Cacti插件_职场_03
3.安装Threshold插件
v0.3.5.1版下载地址:[url]http://download.cactiusers.org/downloads/thold.gzip[/url]
v0.3.5.1版为当前最新版本,此版本在cacti V0.8.6j上安装时有问题,提示一些函数找不到,所以在此使用v0.3.4版。
v0.34版下载地址:[url]http://cactiusers.net/downloads/plugins/thold-0.3.4.tar.gz[/url]
1). 安装Threshold插件,只需将解压出来的Thold目录拷贝到cacti/plugins/目录下,并修改cacti配置文件(cacti目录下的include/config.php)。在配置中查找$plugins = array();行,在此行下面加入:
$plugins[] = 'thold';
刷新cacti首页,你将看到多出来一个Threshld选项卡。
下图是添加Threshold插件和Monitor插件后的cacti界面:
使用Cacti监控你的网络(五)- Cacti插件_职场_04
选中console选项卡,在左侧菜单中点击Settings,然后点击Alerting/Thold选项卡,来设置Threshold插件。
使用Cacti监控你的网络(五)- Cacti插件_休闲_05
使用Cacti监控你的网络(五)- Cacti插件_职场_06
设置完成后在console选项卡下左侧菜单中点击Threshold Templates 。
使用Cacti监控你的网络(五)- Cacti插件_网络_07
点击Add按钮来添加一个Threshold模板。
使用Cacti监控你的网络(五)- Cacti插件_监控_08
在此,以添加一个监控硬盘空间的Threshold模板为例。
使用Cacti监控你的网络(五)- Cacti插件_休闲_09
在Data Field下拉框中选择hdd_free,然后点击go按钮。
使用Cacti监控你的网络(五)- Cacti插件_网络_10 
填写以下信息,在Low Threshold文本框中填入1000,意思是当剩余的硬盘空间小于1000M时,发送邮件报警。在Threshold CDEF下拉框选择Divide by 1024,填入警报邮箱,完成Threshold模板的添加。
使用Cacti监控你的网络(五)- Cacti插件_监控_11 
应用刚才创建的Threshold模板。在console选项卡下点击Devices,选择要应用此模板的Host,点击最上面的Create Graphs for this Host链接,然后点击Auto-create thresholds链接来应用刚创建的Threshold模板。
 
设置完成后在console选项卡下左侧菜单中点击Thresholds 。
 使用Cacti监控你的网络(五)- Cacti插件_监控_12
在此可以管理已创建的警报。
使用Cacti监控你的网络(五)- Cacti插件_Cacti_13 
点击threshld选项卡可以查看警报的触发情况。
 使用Cacti监控你的网络(五)- Cacti插件_休闲_14
 
4. 其它插件
其它插件可到[url]http://cactiusers.org/downloads/[/url]自行下载安装,在此只略述一二。
1).Discovery:This plugin adds the ability to auto-discover devices on a subnet that are not monitored by Cacti and and tells you if they are SNMP enabled.
2). Flowviewer:A simple viewer for viewing reports based on data from flows created by Netflow.
3).Mac Track:The Mac Track plugin for Cacti by The Witness.
4).Settings:This plugin houses common settings and functions used by different plugins.
5).Network Weathermap:这是一个比较复杂的cacti插件,他需要GD库的支持,可以参照cacti的安装小节来支持GD库。使用它可以画出漂亮的网络状况图。
安装方法:
 
二、参考