自动化运维之系统监控Nagios(一)安装部署-创新互联
一、系统环境
成都网站制作、网站建设的开发,更需要了解用户,从用户角度来建设网站,获得较好的用户体验。创新互联建站多年互联网经验,见的多,沟通容易、能帮助客户提出的运营建议。作为成都一家网络公司,打造的就是网站建设产品直销的概念。选择创新互联建站,不只是建站,我们把建站作为产品,不断的更新、完善,让每位来访用户感受到浩方产品的价值服务。操作系统:CentOS 7 (最小化安装)
软件版本:Nagios 4.11 Pnp4nagios 0.6.25
二、部署脚本
安装脚本如下:
#!/bin/sh #mysql密码 mysqlps=123 #nagios账户密码 nagiospa=123 #nagiosadmin账户密码 nagadps=123 #获取本机IP hostip=` ip a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|awk -F / '{print $1}'|tail -1 ` #系统配置 systemctl stop firewalld.service systemctl disable firewalld.service sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config setenforce 0 yum -y install epel-release yum -y install bash-completion ntp mailx expect yum-axelget vim echo "alias vi='vim'">>/etc/bashrc echo "alias ll='ls -lh --color=auto'">>/etc/bashrc echo "set nu">>/etc/vimrc yum update -y #安装LAMP yum -y install httpd mariadb-server mariadb php php-mysql php-gd php-pear systemctl start httpd systemctl enable httpd systemctl start mariadb systemctl enable mariadb expect <>/usr/local/nagios/etc/objects/commands.cfg sed -i "s/nrpe_user=nrpe/nrpe_user=nagios/g" /etc/nagios/nrpe.cfg sed -i "s/nrpe_group=nrpe/nrpe_group=nagcmd/g" /etc/nagios/nrpe.cfg sed -i "s%/usr/local/nagios/libexec%/usr/lib64/nagios/plugins%g" /usr/local/nagios/etc/resource.cfg #设置nagios Web 访问密码 expect < >/usr/local/nagios/etc/objects/commands.cfg<<-EOF # Bulk with NPCD mode # define command { command_name process-service-perfdata-file command_line /bin/mv /usr/local/pnp4nagios/var/service-perfdata /usr/local/pnp4nagios/var/spool/service-perfdata.\$TIMET\$ } define command { command_name process-host-perfdata-file command_line /bin/mv /usr/local/pnp4nagios/var/host-perfdata /usr/local/pnp4nagios/var/spool/host-perfdata.\$TIMET\$ } EOF cat >>/usr/local/nagios/etc/objects/templates.cfg<<-EOF define host { name host-pnp action_url /pnp4nagios/index.php/graph?host=\$HOSTNAME\$&srv=_HOST_' class='tips' rel='/pnp4nagios/index.php/popup?host=\$HOSTNAME\$&srv=_HOST_ register 0 } define service { name srv-pnp action_url /pnp4nagios/index.php/graph?host=\$HOSTNAME\$&srv=\$SERVICEDESC\$' class='tips' rel='/pnp4nagios/index.php/popup?host=\$HOSTNAME\$&srv=\$SERVICEDESC\$ register 0 } EOF sed -i 's%linux-server%linux-server,host-pnp%' /usr/local/nagios/etc/objects/localhost.cfg sed -i 's%local-service%local-service,srv-pnp%' /usr/local/nagios/etc/objects/localhost.cfg sed -i 's%hostgroup_name linux-server,host-pnp%hostgroup_name linux-server%' /usr/local/nagios/etc/objects/localhost.cfg #重启服务 ln -s /usr/local/nagios/bin/nagios /usr/bin/ nagios -v /usr/local/nagios/etc/nagios.cfg sleep 3 systemctl start nrpe systemctl enable nrpe chkconfig npcd on systemctl start npcd chkconfig nagios on systemctl start nagios systemctl restart httpd systemctl status -l npcd systemctl status -l nrpe systemctl status -l nagios systemctl status -l httpd echo "请访问http://${hostip}/nagios验证配置!!"
部署完成!
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
文章名称:自动化运维之系统监控Nagios(一)安装部署-创新互联
标题来源:http://azwzsj.com/article/djeecp.html