1.nagios 启动(root身份)

/etc/init.d/nagios restart

(/etc/init.d/xinetd restart 重启nsca,用于接收客户端的数据,端口为5667,接收数据出现问题时,需要重启)

2.nagios 配置文件编辑

(su - nagios编辑)

1/usr/local/nagios/etc/objects/hostgroups.cfg中定义hostgroup,有时禁用host,需要在这里把相应主机注释掉

 

define hostgroup{

        hostgroup_name  NETWORK-DEVICE Group

        alias NETWOKR_DEVICE

        members  FW01

        }

 

 

2)/usr/local/nagios/etc/nagios.cfg (禁用主机注释掉相应主机配置文件)

cfg_file=/usr/local/nagios/etc/objects/DB1.cfg


 


3.检查配置,

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg 用来检查配置是否有问题,

出现这样的说明没问题

.........

Total Warnings: 0

Total Errors: 0

Things look okay - No serious problems were detected during the pre-flight check

再用root重启/etc/init.d/nagios restart 



常用脚本


客户端

useradd -u 2001 -s /sbin/nologin nagios

cd /usr/local

tar -xzvf nagios.tar.gz

sed -i "s/WEB2/DB3/g"  /usr/local/nagios/exe_scripts.sh  

echo "*/2 * * * * sh /usr/local/nagios/exe_scripts.sh >/dev/null 2>&1" >>/var/spool/cron/nagios

 

服务端

sed -i "s/ DB1/DB3/g"  /usr/local/nagios/etc/objects/DB3.cfg

sed -i "s/address 10.99.2.40/address 10.99.2.42/g"  /usr/local/nagios/etc/objects/DB3.cfg