最近在使用nagios实现监控功能,这几天安装nagvis出现一些问题,困了好久,今天终于弄出来了,本来都要崩溃了,终于天道酬勤,也说明:永远不要放弃!!
先说我的具体步骤吧:参考文章http://ppp1013.blog.51cto.com/927700/214784
如下:
一:nagvis安装
1.安装需求:
1).Nagios已正常运行。
2).使用NDOUtils将Nagios监控信息存入数据库
3).PHP5.0以上版本,并需要安装php-gd、php-mysql、php5-mbstring、php5-session、php5-xml模块。
注意此处安装php5.0可以参考 我的 基于fedora16的nagios环境搭建--个人日记--php反思。
4).安装Graphviz >= 2.14,下载http://www.graphviz.org/graphviz-rhel.repo文件放到/etc/yum.repos.d/目录下,yum list available 'graphviz*';yum install 'graphviz*'。或者到网站http://www.graphviz.org/Download_linux_fedora.php这里有所有需要的fedora版本的graphviz。
(我是按照需要的一个一个安装的,使用yum install graphviz*命令安装全部的文件时,graphviz-qt文件安装不上,主要原因是graphviz-qt和graphviz版本不匹配。但是我确实安装了graphviz,不知道为什么。所以还是参考网址http://www.graphviz.org/Download_linux_fedora.php所需要的文件一个一个安装吧)
2:nagvis安装
1).下载Nagivs,http://www.nagvis.org。
2).tar xvzf nagvis-1.3.x.tar.gz
3).mv nagvis /usr/local/nagios/share/nagvis
因为现在是nagvis1.6了,再使用nagvis1.3就会出现很多问题。所以安装nagvis应该按一下步骤进行。
进入nagvis目录:
[root@localhost nagvis]# ./install.sh
+------------------------------------------------------------------------------+
| Welcome to NagVis Installer 1.6.3 |
+------------------------------------------------------------------------------+
| This script is built to facilitate the NagVis installation and update |
| procedure for you. The installer has been tested on the following systems: |
| - Debian Etch, Hardy (4.0, 5.0) |
| - Ubuntu Hardy, Intrepid, Jaunty, Karmic, Lucid (8.04 to 10.04) |
| - SuSE Linux Enterprise Server 10 and 11 |
| |
| Similar distributions to the ones mentioned above should work as well. |
| That (hopefully) includes RedHat, Fedora, CentOS, OpenSuSE |
| |
| If you experience any problems using these or other distributions, please |
| report that to the NagVis team. |
+------------------------------------------------------------------------------+
| Do you want to proceed? [y]: //注意直接回车就是继续,输入n就停止
+------------------------------------------------------------------------------+
| Starting installation of NagVis 1.6.3 |
+------------------------------------------------------------------------------+
| OS : Fedora release 16 (Verne) |
| |
+--- Checking for tools -------------------------------------------------------+
| Using packet manager /bin/rpm found |
| |
+--- Checking paths -----------------------------------------------------------+
| Please enter the path to the nagios base directory [/usr/local/nagios]:
| nagios path /usr/local/nagios // nagios 主目录 found |
| Please enter the path to NagVis base [/usr/local/nagvis]: /usr/local/nagios/share/nagvis //自己输入nagvis目录
| |
+--- Checking prerequisites ---------------------------------------------------+
| PHP 5.3 found |
| PHP Module: gd php found |
| PHP Module: mbstring php found |
| PHP Module: gettext compiled_in found |
| PHP Module: session compiled_in found |
| PHP Module: xml php found |
| PHP Module: pdo php found |
| Apache mod_php found |
| Do you want to update the backend configuration? [n]: y //yes
| Checking Backends. (Available: mklivestatus,ndo2db,ido2db,merlinmy) |
| Do you want to use backend mklivestatus? [y]: n //not
| Do you want to use backend ndo2db? [n]: y //yes 使用ndo2db数据库方式
| Do you want to use backend ido2db? [n]: //not
| Do you want to use backend merlinmy? [n]: //not
| /usr/local/nagios/bin/ndo2db-3x (ndo2db) found |
| PHP Module: mysql php found |
| Graphviz 2.28 found |
| Graphviz Module dot 2.28.0 found |
| Graphviz Module neato 2.28.0 found |
| Graphviz Module twopi 2.28.0 found |
| Graphviz Module circo 2.28.0 found |
| Graphviz Module fdp 2.28.0 found |
| SQLite 3.7 found |
| |
+--- Trying to detect Apache settings -----------------------------------------+
| Please enter the web path to NagVis [/nagvis]: /nagios/nagvis //web 下显示
| Please enter the name of the web-server user [apache]: nagios
//这两项就是web 的user 和 group 应该是httpd.conf里的用户和组
| Please enter the name of the web-server group [apache]: nagios
| create Apache config file [y]:
| (此处要说明一下:我的apache安装在 /usr/local/apache下了,而此处要产生的config文件在/etc/httpd/conf.d目录下。到底用不用我不是很清楚。我也在此处输入 n试了试,效果和输入y一样。建议选y吧)
+--- Checking for existing NagVis ---------------------------------------------+
| NagVis 1.6.3 found |
| Do you want the installer to update your config files when possible? [y]:
| Remove backup directory after successful installation? [n]: y //yes
| |
+------------------------------------------------------------------------------+
| Summary |
+------------------------------------------------------------------------------+
| NagVis home will be: /usr/local/nagios/share/nagvis |
| Owner of NagVis files will be: nagios |
| Group of NagVis files will be: nagios |
| Path to Apache config dir is: /etc/httpd/conf.d |
| Apache config will be created: yes |
| |
| Installation mode: update |
| Old version: 1.6.3 |
| New version: 1.6.3 |
| Backup directory: /usr/local/nagios/share/nagvis.old-2012-04-15 |
| |
| Note: The current NagVis directory will be moved to the backup directory. |
| The backup directory will be removed after successful installation. |
| Your configuration files will be copied. |
| The configuration files will be updated if possible. |
| |
| Do you really want to continue? [y]: //yes
+------------------------------------------------------------------------------+
| Starting installation |
+------------------------------------------------------------------------------+
| Moving old NagVis to /usr/local/nagios/share/nagvis.old-2012-04-15_17:03:29.. done |
| Creating directory /usr/local/nagios/share/nagvis... done |
| Creating directory /usr/local/nagios/share/nagvis/var... done |
| Creating directory /usr/local/nagios/share/nagvis/var/tmpl/cache... done |
| Creating directory /usr/local/nagios/share/nagvis/var/tmpl/compile... done |
| Creating directory /usr/local/nagios/share/nagvis/share/var... done |
| Copying files to /usr/local/nagios/share/nagvis... done |
| Creating directory /usr/local/nagios/share/nagvis/etc/profiles... done |
| Creating main configuration file... done |
| adding sesscookie=/nagios/nagvis done |
| adding base="/usr/local/nagios/share/nagvis" done |
| adding htmlbase="/nagios/nagvis" done |
| setting backend to ndomy_1 done |
| Adding webserver group to file_group... done |
| *** /etc/httpd/conf.d/nagvis.conf will NOT be overwritten ! |
| *** creating /etc/httpd/conf.d/nagvis.conf.2012-04-15_17:03:29 instead (comm |
| Creating web configuration file... done |
| Setting permissions for web configuration file... done |
| |
| Restoring custom map configuration files... done |
| Restoring custom automap configuration files... done |
| Restoring conf.d/ configuration files... done |
| Restoring custom map images... done |
| Restoring custom gadget images... done |
| Restoring custom iconsets... done |
| Restoring custom shapes... done |
| Restoring custom templates... done |
| Restoring custom template images... done |
| Restoring custom gadgets... done |
| Restoring custom stylesheets... done |
| |
+------------------------------------------------------------------------------+
| Handling changed/removed options |
+------------------------------------------------------------------------------+
| Removing allowedforconfig option from main config... done |
| Removing autoupdatefreq option from main config... done |
| Removing htmlwuijs option from main config... done |
| Removing wuijs option from main config... done |
| Removing usegdlibs option from main config... done |
| Removing displayheader option from main config... done |
| Removing hovertimeout option from main config... done |
| Removing allowed_for_config option from map configs... done |
| Removing allowed_user from map configs... done |
| Removing allowed_for_config from automap configs... done |
| Removing allowed_user from automap configs... done |
| Removing hover_timeout from map configs... done |
| Removing usegdlibs from map configs... done |
+------------------------------------------------------------------------------+
| HINT: Please check the changelog or the documentation for changes which |
| affect your configuration files |
| |
+--- Setting permissions... ---------------------------------------------------+
| /usr/local/nagios/share/nagvis/etc/nagvis.ini.php-sample done |
| /usr/local/nagios/share/nagvis/etc done |
| /usr/local/nagios/share/nagvis/etc/maps done |
| /usr/local/nagios/share/nagvis/etc/maps/* done |
| /usr/local/nagios/share/nagvis/etc/automaps done |
| /usr/local/nagios/share/nagvis/etc/automaps/* done |
| /usr/local/nagios/share/nagvis/etc/profiles done |
| /usr/local/nagios/share/nagvis/share/userfiles/images/maps done |
| /usr/local/nagios/share/nagvis/share/userfiles/images/maps/* done |
| /usr/local/nagios/share/nagvis/share/userfiles/images/shapes done |
| /usr/local/nagios/share/nagvis/share/userfiles/images/shapes/* done |
| /usr/local/nagios/share/nagvis/var done |
| /usr/local/nagios/share/nagvis/var/* done |
| /usr/local/nagios/share/nagvis/var/tmpl done |
| /usr/local/nagios/share/nagvis/var/tmpl/cache done |
| /usr/local/nagios/share/nagvis/var/tmpl/compile done |
| /usr/local/nagios/share/nagvis/share/var done |
| |
| Removing backup directory done |
+------------------------------------------------------------------------------+
| Installation complete |
| |
| You can safely remove this source directory. |
| |
| For later update/upgrade you may use this command to have a faster update: |
| ./install.sh -n /usr/local/nagios -p /usr/local/nagios/share/nagvis -b ndo2db -u nagios -g nagios -w /etc/httpd/conf.d -a y
| |
| What to do next? |
| - Read the documentation |
| - Maybe you want to edit the main configuration file? |
| Its location is: /usr/local/nagios/share/nagvis/etc/nagvis.ini.php |
| - Configure NagVis via browser |
| <http://localhost/nagios/nagvis/config.php> |
| - Initial admin credentials: |
| Username: admin |
| Password: admin |
+------------------------------------------------------------------------------+
修改配置文件:
此时在/nagvis/etc目录下就有nagvis.ini.php 不需要修改名字了
在[paths]模块修改URL path
; path options
[paths]
; absolute physical NagVis path
base="/usr/local/nagios/share/nagvis/" ###取消注释
; absolute html NagVis path
htmlbase="/nagios/nagvis" ###取消注释
; absolute html NagVis cgi path
htmlcgi="/nagios/cgi-bin" ###取消注释
在[backend_ndomy_1]模块修改连接数据库的一下信息(dbuser和dbpass改为nagios,原因同上)
; options for the NDO-Backend
; in this example the ID of the Backend is "ndomy_1" you can define another ID.
[backend_ndomy_1]
; type of backend - MUST be set
;backendtype="ndomy" ###取消注释
; hostname for NDO-db
;dbhost="localhost" ###取消注释
; portname for NDO-db
;dbport=3306 ###取消注释
; database-name for NDO-db
;dbname="ndodb" ###取消注释 //nagios的数据库的名字
; username for NDO-db
;dbuser="ndouse" ###取消注释数据库的用户
; password for NDO-db
;dbpass="111111" ###取消注释,用户密码
; prefix for tables in NDO-db
;dbprefix="nagios_" ###取消注释
; instace-name for tables in NDO-db
;dbinstancename="default" ###取消注释
; maximum delay of the NDO Database in Seconds
;maxtimewithoutupdate=180 ###取消注释
; path to the cgi-bin of this backend
;htmlcgi="/nagios/cgi-bin" ###取消注释
至此配置文件修改完了。
3:web登录nagvis
从以上的配置中知道nagvis的web配置为/nagios/nagvis
当我以如下方式登录时localhost/nagios/nagvis 出现如下
You don't have permission to access /nagios/nagvis/ on this server.
当我
即便我在httpd.conf 中我Include conf/nagvis.conf
nagvis.conf 中我写入
Alias /nagios/nagvis "/usr/local/nagios/share/nagvis/share"
<Directory "/usr/local/nagios/share/nagvis/share">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<Directory "/usr/local/nagios/share/nagvis/share">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
而nagvis.ini.php path段如下
[paths]
; absolute physical NagVis path
;base="/usr/local/nagvis/"
base="/usr/local/nagios/share/nagvis/"
; absolute html NagVis path
;htmlbase="/nagvis"
htmlbase="/nagvis/"
; absolute html NagVis cgi path
htmlcgi="/nagios/cgi-bin"
使用如下网址登录 localhost/nagvis
2: httpd.conf 中把 Include conf/nagvis.conf 注释
而nagvis.ini.php path段如下
[paths]
; absolute physical NagVis path
;base="/usr/local/nagvis/"
base="/usr/local/nagios/share/nagvis/"
; absolute html NagVis path
;htmlbase="/nagvis"
htmlbase="/nagios/nagvis/share"
; absolute html NagVis cgi path
htmlcgi="/nagios/cgi-bin"
使用如下网址登录localhost/nagios/nagvis/share
登录结果如图:
虽然出图了,但是我不知道 对不对因为我的点击 automaps-->default automap 出现自己的locahost 不出任何图,出现一个错误:the object localhost doest exist。 不知道为什么。
注意:nagvis 必须与ndoutis 和nagios 有关,ndoutils必须正确运行,这个要注意,因为nagvis是要靠ndoutils 的数据库要来画图。