类别:原创 服务器

本文参考

http://www.360doc.com/content/14/1031/15/20148927_421444160.shtml

 

第一:说明

目的:本机前提是已安装好了cacti 0.8.8b 并正常工作,本文档主要配置cacti插件weathermap

其它说明: cacti 0.8.8b的安装请参考我的其它博客文章《Cacti 0.8.8b 安装配置(含snmp配置) http://jedy82.blog.51cto.com/425872/1569689

本文在此基础上配置

Cacti服务器ip:192.168.10.112

cacti 使用yum方式安装,默认路径为/usr/share/cacti

第二:本例操作环境     

[root@i-tcz0hdhc ~]# yum update -y

[root@i-tcz0hdhc ~]# uname -a

Linux i-tcz0hdhc 2.6.32-431.29.2.el6.x86_64 #1 SMP Tue Sep 9 21:36:05 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

[root@i-tcz0hdhc ~]# more /etc/redhat-release 

CentOS release 6.6 (Final)

[root@i-tcz0hdhc ~]# 

第三:weathermap插件的安装

Cacti官方插件下载地址:http://docs.cacti.net/plugins

weathermap官方安装文档:http://docs.cacti.net/userplugin:weathermap

Weathermap下载地址: http://network-weathermap.com/files/php-weathermap-0.97c.zip

 

Weathermap必须要gd库的支持

[root@i-tcz0hdhc ~]#

[root@i-tcz0hdhc ~]# yum install -y php-gd

[root@i-tcz0hdhc ~]# service  httpd restart

[root@i-tcz0hdhc ~]# wget http://network-weathermap.com/files/php-weathermap-0.97c.zip

[root@i-tcz0hdhc ~]# unzip php-weathermap-0.97c.zip -d /usr/share/cacti/plugins

[root@i-tcz0hdhc ~]#

之后,再进入[Console]-[Configuration]-[plug Management],点击一下weatermap左边的蓝色向下箭头,直到变成红色向上的箭头。此时可以见到weathermap的Status为:active。说明weathermap已经运行。同时也可以见到[weathermap]的标签了,在 [console]-[Utilities]-[User Management],admin用户的Realm Permissions中也多了Plugin -> Weathermap: Configure/Manage 和Plugin -> Weathermap: View 两项,并已经选定。

第四:weathermap配置使用

安装好weathermap后,看到点Console在左边的列表里会看到weathermap的菜单,我们点击,会看到设置,因为我们还没有定义一个weathermap配置文件,所以我们点右上角的Add按钮,添加一个weathermap配置文件


wps1938.tmp

点击Add之后,我们看到有个文件,其实这个时候调用的就是weathermapconfigs目录下的文件,simple.conf就是自带的一个配置文件,我们可以点击它前面的Add按钮,把他添加到默认配置文件里


wps1948.tmp

至此我们添加了一个weathermap的配置文件,下面就是对weathermap进行配置了,点击weathermap,然后点击Editor对默认图形配置文件进行配置。


wps1959.tmp

点击Editor后我们会看到如下提示


The editor has not been enabled yet. You need to set ENABLED=true at the top of editor.php


Before you do that, you should consider using FilesMatch (in Apache) or similar to limit who can access the editor. There is more information in the install guide section of the manual.


我们按照提示修改editor.php文件


[root@i-tcz0hdhc ~]# vi /usr/share/cacti/plugins/weathermap/editor.php 


$ENABLED=false;改为 $ENABLED=true;


[root@i-tcz0hdhc ~]# 


之后我们刷新页面收到如下页面的错误提示,这需授权允许httpd用户有权写入configs目录,否则无法编辑


The map config directory is not writable by the web server user. You will not be able to edit any files until this is corrected. [WMEDIT01]<p>


[root@i-tcz0hdhc ~]# chown -R apache.root /usr/share/cacti/plugins/weathermap/configs/ 


[root@i-tcz0hdhc ~]# 


最后我们刷新页面就可以看到如下页面


wps1979.tmp

在这里我们可以创建配置文件,或者从一个配置文件创建一个新的配置文件,或者打开一个已有的配置文件进行编辑,这里我们就点击选择从simple.conf文件拷贝一个weathermap配置。命名为test.conf可以看到下图。注意自己建配置文件时 一定要加上.conf的后缀。


wps198A.tmp

这里就是weathermap的编辑页面了这里也可以通过[Console]-[Management]-[Weathermaps],然后点test.conf进入,把上面那个菜单说明下吧。


Change File可以会到前面的那个界面改变编辑的图形配置文件。


Add Node就是添加一个节点,点击之后鼠标会变成变成一个十字,在你想要放Node的地方点一下就可以创建一个Node


Add Link 就是添加添加一条链接,可以把二个Node连接起来,点击Add Link后点击Node,再点击另外一个Node就可以把二个Node连接起来。


Position Legend是调整那个图列的位置,点击之后鼠标会编成十字,点击以下就可以移动到新的位置。


Postion Timestamp是添加一个图片创建的时间啊什么信息的。


Map Style 可以调整这个图形的风格。比如图形名称、.图形大小、图形背景图片、输出图片目录、位置等


基本使用的也就这几个了。


点击一个Node


wps198B.tmp

这里可以改Node的大小,Node的名称和标签名称,


Info URl是用户把鼠标放在这个Node后会出现一个流量图片,这个图片信息来自那里。


Hover Graph URL 这里是当用户点击这个Node是会跳转到那个图。在这里可以选择点击Pick From Cacti,从cacti中选取,


Icon Filename是图标的图像,这里可以有很多比如Router、Host、firewall。当然也可以自己添加,在weathermap的p_w_picpaths里,设置好有点击Submit就可以提交更改了.


 

我们再设置以下Link,点击Link的那条线


Maximum Bandwidth Into这里是设置这条Link的最大带宽,这里根据你自己的具体配置设置了,这里端口是1G的端口,出口带宽是300MB因此我设置为300MB,


Maximum Bandwidth out 是出去的最大流量带宽,可以根据自己的具体情况设置。


Data source是流量从那里获取,这里可以引用mrtg的流量也可以点击Pick form Cacti从cacti里获取,


Info URl是用户把鼠标放在这个Node后会出现一个流量图片,这个图片信息来自那里,


Hover Graph URL 这里是当用户点击这个Node是会跳转到那个图,这个如果选择从cacti获取会自动取得。别的默认就成。这样我们就我完成了对一张拓扑图的编辑。


wps199B.tmp

如下就是我设计的weathermap图像


wps19AC.tmp

注意问题


1,中文显示,我们可以在配置文件里指定中中文字体的路径


vi /usr/share/cacti/plugins/weathermap/configs/test.conf


FONTDEFINE 100/usr/share/cacti/plugins/weathermap/msyh.ttf 10


msyh.ttf是中文字体的名字.需要用户自己加进去,指定路径,后面10字体是大小


2.每次对图形进行调整后,都是自动保存的,不用保存(也没有那个选项!嘿嘿),要在weathermap里看到修改后的效果要等到下次cacti采集器采集后才会绘图。


3.cacti的日志里可能会显示


WEATHERMAP: Poller[0] [Map 1] test.conf: About to write p_w_picpath file. If this is the last message in your log, increase memory_limit in php.ini [WMPOLL01]


等信息,不过我修改php.ini里的设置也不起作用,不用管它!


 

 

至此,weathermap已经安装成功。