先将当前的nagios2.9备份
cd /usr/local
cp -r nagios nagios2.9
cd /etc/init.d/
cp nagios nagios2.9


升级(从2.9到3.0.3)
下载nagios-3.0.3
首先大致的看一下里面的两篇文章
whatsnew.html和upgrading.html
介绍了新版的特点和升级方法

然后开始升级工作
解压缩后执行
./configure --with-command-group=nagios
make all
make install
然后验证
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

报两个warning和一个critical
两个warning是:downtime_file 和 comment_file这两个文件已经不在使用,将他们的内容添加到state_retention_file这个文件的后面
一个critical是:434行有错误,变量不能识别
解决两个warning的方法如下:
先将nagios.cfg中comments 和downtime变量注释掉
# COMMENT FILE
# This is the file that Nagios will use for storing host and service
# comments.

#comment_file=/usr/local/nagios/var/comments.dat

# DOWNTIME FILE
# This is the file that Nagios will use for storing host and service
# downtime data.

#downtime_file=/usr/local/nagios/var/downtime.dat
查找state_retention_file=/usr/local/nagios/var/retention.dat
然后执行
cd /usr/local/nagios/var
cat comments.dat >>retention.dat
cat downtime.dat >>retention.dat
解决critical的方法如下
注释掉434行的#check_result_buffer_slots=4096
这个变量已经不在使用了。
然后再验证启动nagios就没问题了

需要说明:从2.x升级到3.x还有这样一点要注意
Extended host and extended service definitions have been deprecated. They are still read and processed by Nagios, but it is recommended that you move the directives found in these definitions to your host and service definitions, respectively.
我配置的有extended service,但是里面的配置信息是nagios grapher自动生产的。况且3.x是可以读的,只是推荐写到service定义中而已。我这里并没有按照这条的建议。没对原来的配置做修改。


Nagvis启动故障的排查
更新nagios之后 启动nagvis需要的NDO组件
/usr/local/nagios/bin/ndo2db -c /usr/local/nagios/etc/ndo2db.cfg
提示Could not bind socket: Address already in use
查看/usr/local/nagios/etc/ndo2db.cfg
有这样的内容
# SOCKET TYPE
# This option determines what type of socket the daemon will create
# an accept connections from.
# Value:
#   unix = Unix domain socket (default)
#   tcp  = TCP socket
socket_type=unix
#socket_type=tcp
socket是unix类型的(是一个sock文件),而不是tcp类型的(tcp端口)

原来是/usr/local/nagios/var/ndo.sock还存在(因为ndo是使用kill命令杀掉进程的)
所以删掉这个.sock文件即可
运行/usr/local/nagios/bin/ndo2db -c /usr/local/nagios/etc/ndo2db.cfg
启动没问题,但是nagivs页面没打开
查看进程也不对
因为会有两个/usr/local/nagios/bin/ndo2db -c /usr/local/nagios/etc/ndo2db.cfg进程才是正常的
查看重启nagios,查看启动日志,报错
Error: Could not load module '/usr/local/nagios/bin/ndomod.o' -> /usr/local/nagios/var/spool/checkresults/nebmodeRKfDc: undefined symbol: find_serviceextinfo
发现是程序版本的问题,要使用支持3.x的NDO
下载ndoutils-1.4b7
解压缩后执行
./configure --with-mysql-lib=/usr/local/mysql/lib/mysql --with-mysql-inc=/usr/local/mysql/include/
make
将原来的备份
[root@info src]# cd /usr/local/nagios/bin
[root@info bin]# cp ndo2db ndo2db_2.x
[root@info bin]# cp ndomod.o ndomod.o_2.x

将正在运行的ndo杀掉,sock文件删掉
然后转到刚刚make好的ndo的文件夹的src目录下
[root@info var]# cd /home/nagios/ndoutils-1.4b7/src
复制3.x版本的ndo程序
[root@info src]# cp  ndomod-3x.o  /usr/local/nagios/bin/ndomod.o
[root@info src]# cp ndo2db-3x   /usr/local/nagios/bin/ndo2db
启动NDO
[root@info src]# /usr/local/nagios/bin/ndo2db -c /usr/local/nagios/etc/ndo2db.cfg

重启nagios
日志里面出现
[1217822155] ndomod: NDOMOD 1.4b7 (10-31-2007) Copyright (c) 2005-2007 Ethan Galstad ([email][email protected][/email])
[1217822155] ndomod: Successfully connected to data sink.  0 queued items to flush.
[1217822155] Event broker module '/usr/local/nagios/bin/ndomod.o' initialized successfully.

稍等一会nagvis页面就会正常出现了

写得十分简单,敬请斧正!