yum -y install httpd gcc gcc-c++ glibc glibc-common gd gd-devel useradd nagios groupadd nagcmd usermod -G nagcmd nagios usermod -G nagcmd apache cd /usr/local/src wget http://nchc.dl.sourceforge.net/sourceforge/nagios/nagios-3.0.6.tar.gz wget http://nchc.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.13.tar.gz wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.13.tar.gz tar zxvf nagios-3.0.6.tar.gz cd nagios-3.0.6 ./configure --with-command-group=nagcmd --prefix=/usr/local/nagios make all make install make install-init make install-config make install-commandmode make install-webconf cd ../ tar zxvf nagios-plugins-1.4.13.tar.gz cd nagios-plugins-1.4.13 ./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios make && make install cd ../ tar zxvf nrpe-2.13.tar.gz cd nrpe-2.13 ./configure make all make install-plugin make install-daemon make install-daemon-config htpasswd -bc /usr/local/nagios/etc/htpasswd.users nagiosadmin nagiosadmin101 echo "alias nagioscheck='/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg' " >> /root/.bashrc source /root/.bashrc chkconfig nagios on chkconfig httpd on service httpd start service nagios start
#基本安裝過程這裏就不重複了,htpasswd -bc這行代碼的做用是不須要人爲干預的生成密碼名爲nagiosadmin101的angiosadmin用戶,然後期因爲常常要修改/usr/local/nagios/etc/nagios.cfg配置文件,因此須要檢測其語法,因此將其長命令生成名爲nagioscheck的別名命令。
mysql
Nagios客戶端自動安裝腳本,以下所示:ios
useradd nagios cd /usr/local/src wget http://nchc.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.13.tar.gz wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.13.tar.gz tar zxvf nagios-plugins-1.4.13.tar.gz cd nagios-plugins-1.4.13 ./configure make make install chown nagios:nagios /usr/local/nagios chown -R nagios:nagios /usr/local/nagios/libexec cd ../ tar zxvf nrpe-2.13.tar.gz cd nrpe-2.13 ./configure make all make install-plugin make install-daemon make install-daemon-config sed -i 's@allowed_hosts=127.0.0.1@allowed_hosts=114.112.11.11@'/usr/local/nagios/etc/nrpe.cfg /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d echo "/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d" >> /etc/rc.local
#allowed_hosts這行是將原先的127.0.0.1由如今的服務器地址114.112.11.11地址代替(已做無害處理),這行代碼你們能夠根據實際須要考慮是否增長,接下來的工做就是調試Nagios服務器端了,具體過程這裏略過。
c++
事實上,在機器進IDC機房以前,像nagios和puppet客戶端軟件,應該在每臺上線機器上部署安裝好,機器上線前確定首先是集中在本身的局域網內Kickstart後而後初始化,這時網絡穩定、調試也方便,因此用puppet自動化維化既方便又省力,這樣省得機器上線之後又遠程維護安裝,即耗了人力成本,並且也增長了機器風險。另注:我看許多朋友都是自行編寫SHELL腳本做爲Nagios插件來做爲對MySQL主從同步的補充功能,其實Nagios中有自帶的check_mysql及check_mysql_health插件來實現,因爲check_mysql在部署過程當中總是頻繁報「段錯誤」,因此目前主要仍是用check_mysql_health,由於咱們不單單是監控從機上面的SQL和IO進程,更重要的是,咱們要監控從機的延遲時間。
web