一.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> |