在CentOS 7上进行Nagios核心升级
时间:2020-03-21 11:47:35 来源:igfitidea点击:
我们将Nagios Core从4.1.1升级到4.3.4。
备份现有的Nagios配置
Nagios和Apache服务应停止:
# systemctl stop nagios httpd
确保我们有备份:
# rsync -rav /usr/local/nagios//opt/nagios411backup/
升级和配置
下载Nagios Core版本4.3.4并解压缩存档:
# wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.3.4.tar.gz # tar xf ./nagios-4.3.4.tar.gz && cd ./nagios-4.3.4
配置和编译:
# ./configure --with-command-group=nagcmd # make all
安装主程序,CGI,HTML文件,示例配置文件等:
# make install # make install-init # make install-commandmode # make install-config # make install-webconf # make install-webconfig
从备份中恢复配置文件" nagios.cfg":
# cp -f /opt/nagios411backup/etc/nagios.cfg /usr/local/nagios/etc/
根据需要恢复密码文件" htpasswd.users":
# cp -f /opt/nagios411backup/etc/htpasswd.users /usr/local/nagios/etc/
还原对象:
# rsync -rav /opt/nagios411backup/etc/objects//usr/local/nagios/etc/objects/
在我们的情况下,我们还想还原所有自定义监视配置文件:
# rsync -rav /opt/nagios411backup/etc/monitoring//usr/local/nagios/etc/monitoring/
这些已被弃用,并将在将来的版本中删除,现在不妨更改它们:
# sed -i 's/normal_check_interval/check_interval/g' /usr/local/nagios/etc/objects/templates.cfg # sed -i 's/normal_check_interval/check_interval/g' /usr/local/nagios/etc/objects/printer.cfg # sed -i 's/normal_check_interval/check_interval/g' /usr/local/nagios/etc/objects/switch.cfg
# sed -i 's/retry_check_interval/retry_interval/g' /usr/local/nagios/etc/objects/templates.cfg # sed -i 's/retry_check_interval/retry_interval/g' /usr/local/nagios/etc/objects/printer.cfg # sed -i 's/retry_check_interval/retry_interval/g' /usr/local/nagios/etc/objects/switch.cfg
# sed -i 's/^command_check_interval/#command_check_intervald/g' /usr/local/nagios/etc/nagios.cfg
我们使用Nagiosgraph,因此需要它来继续处理数据(从备份还原的配置文件确实已经包含该行,因此主要供以后参考)。
# sed -i 's/process_performance_data=0/process_performance_data=1/g' /usr/local/nagios/etc/nagios.cfg
重新加载并重新启动服务:
# systemctl daemon-reload # systemctl restart nagios # systemctl restart httpd
校验:
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg Nagios Core 4.3.4 Copyright (c) 2009-present Nagios Core Development Team and Community Contributors Copyright (c) 1999-2009 Ethan Galstad Last Modified: 2016-08-24 License: GPL Website: https://www.nagios.org Reading configuration data... Read main config file okay... Read object config files okay... Running pre-flight check on configuration data... Checking objects... Checked 1671 services. Checked 190 hosts. Checked 44 host groups. Checked 47 service groups. Checked 5 contacts. Checked 6 contact groups. Checked 126 commands. Checked 7 time periods. Checked 0 host escalations. Checked 0 service escalations. Checking for circular paths... Checked 190 hosts Checked 0 service dependencies Checked 0 host dependencies Checked 7 timeperiods Checking global event handlers... Checking obsessive compulsive processor commands... Checking misc settings... Total Warnings: 0 Total Errors: 0 Things look okay - No serious problems were detected during the pre-flight check
如果新旧Nagios版本之间的配置不匹配会影响您的设置,请相应地进行更改。