一.weathermap作为cacti插件的用法
1.安装weathermap插件
1 2 3 4 5 |
wget http://www.network-weathermap.com/files/php-weathermap-0.97a.zip unzip php-weathermap-0.97a.zip mv weathermap/ /var/www/html/plugins/ chown -R apache:apache /var/www/html/plugins/weathermap/configs/ chown -R apache:apache /var/www/html/plugins/weathermap/output/ |
点击安装weathermap后
至此,weathermap已经安装成功。
2.配置使用weathermap
安装好weathermap后,看到点Console在左边的列表里会看到weathermap的菜单,我们点击,会看到设置,因为我们还没有定义一个weathermap配置文件,所以我们点右上角的Add按钮,添加一个weathermap配置文件
点击Add之后,我们看到有二个文件,其实这个时候调用的就是weathermap的configs目录下的文件,simple.conf就是自带的一个配置文件,我们可以点击它前面的Add按钮,把他添加到默认配置文件里
至此我们添加了一个weathermap的配置文件,下面就是对weathermap进行配置了,点击weathermap,然后点击Editor对默认图形配置文件进行配置。
点击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
1 |
vi /var/www/html/plugins/weathermap/editor.php |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<php require_once 'editor.inc.php'; require_once 'Weathermap.class.php'; // so that you can't have the editor active, and not know about it. $ENABLED=true; if(! $ENABLED) { print " The editor has not been enabled yet. You need to set ENABLED=true at the top of editor.php "; print " 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. "; exit(); } |
注意问题:
1 2 |
vi /var/www/html/plugins/weathermap/configs/simple.conf FONTDEFINE 100 /var/www/html/plugins/weathermap/msyh.ttf 10 |
二.weathermap独立的使用。
1.安装基本环境
1 2 3 4 5 6 7 8 9 |
yum install httpd php php-gd php-pear rrdtool -y servie http start chkconfig http on service crond start chkconfig crond on wget http://www.network-weathermap.com/files/php-weathermap-0.97a.zip unzip php-weathermap-0.97a.zip mv weathermap/ /var/www/html/ chown -R apache:apache /var/www/html/weathermap/configs/ |
2.配置weathermap
1 |
vi /var/www/html/weathermap/editor.php |
特别注意:
3.生成图形
1 |
/usr/bin/php /var/www/html/weathermap/weathermap --config /var/www/html/weathermap/configs/simple.conf --image-uri ../weathermap/test.png |
1 |
vi /etc/crontab |
1 |
*/5 * * * * root /usr/bin/php /var/www/html/weathermap/weathermap --config /var/www/html/weathermap/configs/simple.conf --image-uri ../weathermap/test.png |
1 |
ln /test.png /var/www/html/weathermap/test.png |
总结:
3.最重要的一点,就是关于weathermap的安全性问题,其实在它的官网也说明了。
When you are happy that the world can’t edit your maps, then enable the editor. This is done by editing the top of editor.php and changing $ENABLED=false;
to $ENABLED=true;
You should now be able to go to http://your.server/cacti/plugins/weathermap/editor.php in a browser, and get a welcome page that offers to load or create a config file. That’s it. All done. Please see the editor manual page for more about using the editor!
You can also edit an existing map from the Cacti web interface, by choosing Manage..Weathermaps and then clicking on the name of a config file in the list of active maps. The editor will open with that map loaded.
Important Security Note: The editor allows anyone who can access editor.php to change the configuration files for your network weathermaps. There is no authentication built-in for editing, even with the Cacti Plugin. This is why the configuration file doesn’t exist by default – the editor won’t work until you choose to make it work. It’s recommended that you either:
- change the ownership of configuration files so that the editor can’t write to them once they are complete, or
- use your webserver’s authentication and access control facilities to limit who can access the editor.php URL. On apache, this can be done using the FilesMatch directive and mod_access.
1 |
vi /etc/httpd/conf/httpd.conf |
1 2 3 4 5 6 7 |
<Directory /var/www/html/weathermap> <Files editor.php> Order Deny,Allow Deny from all Allow from 127.0.0.1 </Files> </Directory> |