一、系統(tǒng)環(huán)境
成都創(chuàng)新互聯(lián)公司成立于2013年,我們提供高端成都網(wǎng)站建設(shè)公司、網(wǎng)站制作公司、成都網(wǎng)站設(shè)計、網(wǎng)站定制、成都全網(wǎng)營銷、小程序設(shè)計、微信公眾號開發(fā)、成都網(wǎng)站營銷服務(wù),提供專業(yè)營銷思路、內(nèi)容策劃、視覺設(shè)計、程序開發(fā)來完成項目落地,為成都廣告設(shè)計企業(yè)提供源源不斷的流量和訂單咨詢。
操作系統(tǒng):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 ` #系統(tǒng)配置 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 #設(shè)置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 #重啟服務(wù) 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驗證配置!!"
部署完成!