nagios监控绘图之一键安装pnp4nagios脚本
很多公司,有时候总是要你搭建个监控用来监控机器,就这样一次又一次的搭建,要知道重复性的工作越干越没有劲,于是我就写个脚本,下次安装时就一次生成,这一篇是关于pnp4nagios一键安装脚本,可以在新安装的机器运行,也可以重复性执行。如果要安装cacti和npc的话,把
cacti_npc.sh和该脚本放在一起执行就就行了。其中cacti_npc.sh脚本内容:http://blog.chinaunix.net/uid-25046147-id-4228848.html
系统测试版本:Centos release 5.5
-
#/bin/bash/
-
##Auther Gavin
-
##Mail wkgbc456@163.com
-
#Blog http://wkgbc.blog.chinaunix.net/
-
-
NSTALL_LOG=/tmp/install_log
-
NPREFIX=/var/www/html/nagios
-
PNPPATH=/var/www/html/pnp4nagios
-
-
read -p read -p "You select fist install,Input F,Reinstall Input R,Uinstall Input U,exit Input other... " INSTALL
-
case $INSTALL in
-
f|F)
-
echo -e "Starting install ....."
-
;;
-
r|R)
-
/etc/init.d npcd stop
-
/etc/init.d nagios stop
-
rm -rf $PNPPATH
-
rm -rf /etc/init.d/npcd
-
rm -rf /etc/httpd/conf.d/pnp4nagios.conf
-
cp $NPREFIX/etc/{nagios.cfg.pnp_bak,nagios.cfg}
-
cp $NPREFIX/etc/{command.cfg.pnp_bak,command.cfg}
-
cp $NPREFIX/etc/objects/{templates.cfg.pnp_bak,templates.cfg}
-
cp $NPREFIX/etc/objects/{localhost.pnp_bak,localhost,cfg}
-
/etc/init.d/nagios reload
-
/etc/init.d/httpd reload
-
;;
-
u|U)
-
rm -rf /var/www/html/pnp4nagios
-
rm -rf /etc/init.d/npcd
-
rm -rf /etc/httpd/conf.d/pnp4nagios.conf
-
cp $NPREFIX/etc/{nagios.cfg.pnp_bak,nagios.cfg}
-
cp $NPREFIX/etc/{command.cfg.pnp_bak,command.cfg}
-
cp $NPREFIX/etc/objects/{templates.cfg.pnp_bak,templates.cfg}
-
cp $NPREFIX/etc/objects/{localhost.pnp_bak,localhost,cfg}
-
/etc/init.d/nagios reload
-
/etc/init.d/httpd reload
-
exit 0
-
;;
-
*)
-
exit 2
-
;;
-
esac
-
-
if [ -f pnp4nagios-0.6.21.tar.gz ];then
-
tar xvf pnp4nagios-0.6.21.tar.gz
-
cd pnp4nagios-0.6.21
-
make clean
-
./configure --prefix=/var/www/html/pnp4nagios --with-nagios-user=nagios --with-nagios-group=nagcmd --with-rrdtool=/usr/local/rrdtool/bin/rrdtool
-
[ $? == "0" ] && make all || exit;
-
[ $? == "0" ] && make install || exit;
-
[ $? == "0" ] && make install-webconf || exit;
-
[ $? == "0" ] && make install-config || exit;
-
[ $? == "0" ] && make install-init || exit;
-
cd ..
-
mv $PNPPATH/share/{install.php,install.php.bak}
-
cp $PNPPATH/etc/{misccommands.cfg-sample,misccommands.cfg}
-
cp $PNPPATH/etc/{nagios.cfg-sample,nagios.cfg}
-
cp $PNPPATH/etc/{rra.cfg-sample,rra.cfg}
-
cp $PNPPATH/etc/check_commands/{check_nwstat.cfg-sample,check_nwstat.cfg}
-
cp $PNPPATH/etc/check_commands/{check_all_local_disks.cfg-sample,check_all_local_disks.cfg}
-
chown nagios:nagcmd ./* -R
-
-
chkconfig npcd on
-
-
###############Mody nagios.cfg
-
cp $NPREFIX/etc/{nagios.cfg,nagios.cfg.pnp_bak}
-
cp $NPREFIX/etc/{command.cfg,command.cfg.pnp_bak}
-
cp $NPREFIX/etc/objects/{templates.cfg,templates.cfg.pnp_bak}
-
cp $NPREFIX/etc/objects/{localhost.cfg,localhost.pnp_bak}
-
sed -i 's@process_performance_data=0@process_performance_data=1@g' $NPREFIX/etc/nagios.cfg
-
sed -i 's@#host_perfdata_command=process-host-perfdata@host_perfdata_command=process-host-perfdata@g' $NPREFIX/etc/nagios.cfg
-
sed -i 's@#service_perfdata_command=process-service-perfdata@service_perfdata_command=process-service-perfdata@g' $NPREFIX/etc/nagios.cfg
-
-
-
cat >>$NPREFIX/etc/objects/commands.cfg<<EOF
-
define command {
-
command_name process-service-perfdata
-
command_line /usr/bin/perl $PNPPATH/libexec/process_perfdata.pl
-
}
-
define command {
-
command_name process-host-perfdata
-
command_line /usr/bin/perl $PNPPATH/libexec/process_perfdata.pl -d HOSTPERFDATA
-
}
-
EOF
-
-
cat >>$NPREFIX/etc/objects/templates.cfg<<EOF
-
define host {
-
name host-pnp
-
action_url /pnp4nagios/index.php/graph?host=\$HOSTNAME$&srv=_HOST_
-
register 0
-
}
-
define service {
-
name srv-pnp
-
action_url /pnp4nagios/index.php/graph?host=\$HOSTNAME$&srv=\$SERVICEDESC$
-
register 0
-
}
-
EOF
-
-
else
-
echo "The Pnp4nagios isn't..." >>$INSTALL_LOG
-
fi
-
-
################mody pnp4nagios.conf######
-
-
sed -i 's@/usr/local/nagios/@'$NPREFIX/'@g' /etc/httpd/conf.d/pnp4nagios.conf
-
-
################Add Server GUI###############
-
sed -i 's@local-service@local-service,srv-pnp@g' $NPREFIX/etc/objects/localhost.cfg
-
sed -i '1,40 s@linux-server@linux-server,host-pnp@g' $NPREFIX/etc/objects/localhost.cfg
-
-
/etc/init.d/httpd restart
-
/etc/init.d/npcd restart
-
/etc/init.d/nagios restart
-
-
bash cacti_npc.sh;
|
其他一键安装脚本,测试系统Centos 5.5
-
cacti与npc一键安装脚本链接:http://blog.chinaunix.net/uid-25046147-id-4228848.html
-
-
nagios一键安装脚本:http://blog.chinaunix.net/uid-25046147-id-4228845.html
-
-
nrpe一键安装:http://blog.chinaunix.net/uid-25046147-id-4228843.html
-
-
pnp4nagios一键安装脚本:http://blog.chinaunix.net/uid-25046147-id-4228835.html
-
-
一键安装LAMP:http://blog.chinaunix.net/uid-25046147-id-4226114.html
阅读(3536) | 评论(2) | 转发(0) |