成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

自動化運維之系統(tǒng)監(jiān)控Nagios(一)安裝部署-創(chuàng)新互聯(lián)

一、系統(tǒng)環(huán)境

成都網(wǎng)站制作、網(wǎng)站建設的開發(fā),更需要了解用戶,從用戶角度來建設網(wǎng)站,獲得較好的用戶體驗。創(chuàng)新互聯(lián)建站多年互聯(lián)網(wǎng)經(jīng)驗,見的多,溝通容易、能幫助客戶提出的運營建議。作為成都一家網(wǎng)絡公司,打造的就是網(wǎng)站建設產(chǎn)品直銷的概念。選擇創(chuàng)新互聯(lián)建站,不只是建站,我們把建站作為產(chǎn)品,不斷的更新、完善,讓每位來訪用戶感受到浩方產(chǎn)品的價值服務。

 操作系統(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 <<EOF
	set timeout -1
	spawn mysql_secure_installation
	expect {
		"*(enter for none):" { send "\r"; exp_continue }
		"*password:" { send "${mysqlps}\r"; exp_continue }
		"*password:" { send "${mysqlps}\r"; exp_continue }
		"*users?" { send "Y\r"; exp_continue }
		"*remotely?" { send "Y\r"; exp_continue }
		"*it?" { send "Y\r"; exp_continue }
		"*now?" { send "Y\r"; exp_continue }
		}
	expect eof
EOF

#安裝Nagios

yum install -y gd gd-devel gcc glibc glibc-common openssl openssl-devel openssl-perl unzip wget

useradd -m nagios

expect <<EOF
	set timeout -1
	spawn passwd nagios
	expect {
		"*password:" { send "${nagiospa}\r";exp_continue }
		"*password:" { send "${nagiospa}\r" }
		}
	expect eof
EOF


groupadd nagcmd

usermod -a -G nagcmd nagios

usermod -a -G nagcmd apache

cd /tmp

wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.1.1.tar.gz

tar xzf nagios-4.1.1.tar.gz

cd nagios-4.1.1

./configure --with-command-group=nagcmd

make all

make install

make install-init

make install-commandmode

make install-config

make install-webconf

make install-exfoliation

make install-classicui

#安裝nagios-plugins、nrpe

yum install -y nagios-plugins* nrpe*

echo -e "#'check_nrpe' command definition
define command{
\tcommand_name check_nrpe
\tcommand_line \$USER1\$/check_nrpe -H \$HOSTADDRESS\$ -c \$ARG1\$
}">>/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 <<EOF
	set timeout -1
	spawn htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
	expect {
		"*password:" { send "${nagadps}\r";exp_continue }
		"*password:" { send "${nagadps}\r" }
		}
	expect eof
EOF

#修復假報警

touch /var/www/html/index.html

#安裝pnp4nagios

yum -y install php-gd rrdtool-perl rrdtool librrds-perl perl-Time-HiRes

cd /tmp

wget http://nchc.dl.sourceforge.net/project/pnp4nagios/PNP-0.6/pnp4nagios-0.6.25.tar.gz

tar zxvf pnp4nagios-0.6.25.tar.gz

cd pnp4nagios-0.6.25

./configure --with-nagios-user=nagios --with-nagios-group=nagcmd

make all

make fullinstall

sed -i "s%Order allow,deny%Require all granted%g" /etc/httpd/conf.d/pnp4nagios.conf

sed -i "s%Allow from all%%g" /etc/httpd/conf.d/pnp4nagios.conf

cd /usr/local/pnp4nagios/etc

ls|grep sample|awk -F"." '{print $1}'|xargs -i{} mv {}.cfg-sample {}.cfg

cd /usr/local/pnp4nagios/etc/pages

ls|grep sample|awk -F"." '{print $1}'|xargs -i{} mv {}.cfg-sample {}.cfg

cd /usr/local/pnp4nagios/etc/check_commands

ls|grep sample|awk -F"." '{print $1}'|xargs -i{} mv {}.cfg-sample {}.cfg

mv /usr/local/pnp4nagios/share/install.php /usr/local/pnp4nagios/share/install.php.bak

sed -i 's%process_performance_data=0%process_performance_data=1%' /usr/local/nagios/etc/nagios.cfg
sed -i 's%enable_environment_macros=0%enable_environment_macros=1%' /usr/local/nagios/etc/nagios.cfg

sed -i 's%#host_perfdata_command%host_perfdata_command%' /usr/local/nagios/etc/nagios.cfg

sed -i 's%#service_perfdata_command%service_perfdata_command%' /usr/local/nagios/etc/nagios.cfg

sed -i 's%#host_perfdata_file=/usr/local/nagios/var/host-perfdata%host_perfdata_file=/usr/local/pnp4nagios/var/host-perfdata%' /usr/local/nagios/etc/nagios.cfg

sed -i 's%#service_perfdata_file=/usr/local/nagios/var/service-perfdata%service_perfdata_file=/usr/local/pnp4nagios/var/service-perfdata%' /usr/local/nagios/etc/nagios.cfg

sed -i '847i host_perfdata_file_template=DATATYPE::HOSTPERFDATA\\tTIMET::\$TIMET\$\\tHOSTNAME::\$HOSTNAME\$\\tHOSTPERFDATA::\$HOSTPERFDATA\$\\tHOSTCHECKCOMMAND::\$HOSTCHECKCOMMAND\$\\tHOSTSTATE::\$HOSTSTATE\$\\tHOSTSTATETYPE::\$HOSTSTATETYPE\$' /usr/local/nagios/etc/nagios.cfg

sed -i '848i service_perfdata_file_template=DATATYPE::SERVICEPERFDATA\\tTIMET::\$TIMET\$\\tHOSTNAME::\$HOSTNAME\$\\tSERVICEDESC::\$SERVICEDESC\$\\tSERVICEPERFDATA::\$SERVICEPERFDATA\$\\tSERVICECHECKCOMMAND::\$SERVICECHECKCOMMAND\$\\tHOSTSTATE::\$HOSTSTATE\$\\tHOSTSTATETYPE::\$HOSTSTATETYPE\$\\tSERVICESTATE::\$SERVICESTATE\$\\tSERVICESTATETYPE::\$SERVICESTATETYPE\$' /usr/local/nagios/etc/nagios.cfg

sed -i 's%#host_perfdata_file_mode%host_perfdata_file_mode%' /usr/local/nagios/etc/nagios.cfg

sed -i 's%#service_perfdata_file_mode%service_perfdata_file_mode%' /usr/local/nagios/etc/nagios.cfg

sed -i 's%#host_perfdata_file_processing_interval=0%host_perfdata_file_processing_interval=15%' /usr/local/nagios/etc/nagios.cfg

sed -i 's%#service_perfdata_file_processing_interval=0%service_perfdata_file_processing_interval=15%' /usr/local/nagios/etc/nagios.cfg

sed -i 's%#host_perfdata_file_processing_command%host_perfdata_file_processing_command%' /usr/local/nagios/etc/nagios.cfg

sed -i 's%#service_perfdata_file_processing_command%service_perfdata_file_processing_command%' /usr/local/nagios/etc/nagios.cfg

sed -i 's%process-service-perfdata%psp12%' /usr/local/nagios/etc/objects/commands.cfg
sed -i 's%process-host-perfdata%php12%' /usr/local/nagios/etc/objects/commands.cfg

cat >>/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驗證配置!!"

部署完成!

另外有需要云服務器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。

分享文章:自動化運維之系統(tǒng)監(jiān)控Nagios(一)安裝部署-創(chuàng)新互聯(lián)
當前地址:http://jinyejixie.com/article28/djeecp.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供微信小程序、網(wǎng)站導航、服務器托管、自適應網(wǎng)站、ChatGPT、網(wǎng)站設計

廣告

聲明:本網(wǎng)站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

h5響應式網(wǎng)站建設
万全县| 巫溪县| 祥云县| 河东区| 噶尔县| 获嘉县| 环江| 合作市| 阳新县| 彰化县| 合川市| 喀什市| 海林市| 福鼎市| 莱芜市| 福鼎市| 高淳县| 九江市| 牙克石市| 栾川县| 资溪县| 尤溪县| 资溪县| 平阳县| 邢台市| 札达县| 潍坊市| 蒙城县| 台湾省| 阳新县| 新闻| 马山县| 容城县| 保靖县| 呼和浩特市| 开原市| 北川| 东城区| 寿光市| 永福县| 张家口市|