2014年8月13日 星期三

[研究] Nagios 4.0.8 安裝(tar.gz)(CentOS 6.5 x86_64)

[研究] Nagios 4.0.8 安裝 (CentOS 6.5 x86_64)

2014-08-13

官方網站
http://www.nagios.com/

Nagios Core 目前最新版為 4.0.8 (2014-08-06)
NRPE 目前最新版為 2.15 (2013-09-06)
http://sourceforge.net/projects/nagios/files/
http://nchc.dl.sourceforge.net/project/nagios/nagios-4.x/nagios-4.0.8/nagios-4.0.8.tar.gz
http://cznic.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz

Nagios Plugins 目前最新版為 2.0.3 (2014-06-26)
http://www.nagios.org/download/plugins/
http://nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz

Nagios + plugins 快速安裝參考 (目前沒有 4.0 版的)
http://nagios.sourceforge.net/docs/3_0/quickstart-fedora.html
http://nagios.sourceforge.net/docs/3_0/quickstart.html

NRPE 安裝
http://nagios.sourceforge.net/docs/nrpe/NRPE.pdf
http://support.nagios.com/knowledgebase/officialdocs

預設帳號是 nagiosadmin
預設密碼是 password
如果想改密碼, 請找到

htpasswd -cb /usr/local/nagios/etc/htpasswd.users nagiosadmin password

把 password 換成你要的密碼

安裝參考
http://assets.nagios.com/downloads/nagioscore/docs/Installing_Nagios_Core_From_Source.pdf

快速安裝程式


echo -e "\033[31;42m ********** Install nagios-4.0.8.gz on CentOS 6.5 x86_64 ********** \033[0m"
echo -e "\033[31m 2014-08-13 ********** \033[0m"
echo -e "Ref : http://nagios.sourceforge.net/docs/3_0/quickstart-fedora.html"

# Check SELinux status
if  [ "`grep SELINUX=disabled /etc/selinux/config`" == "" ]; then

# disable SELinux now
/usr/sbin/setenforce 0

# disable SELinux after every reboot
# echo "/usr/sbin/setenforce 0" >> /etc/rc.local  

#or
# disable SELinux always
sed -i -e "s@SELINUX=enforcing@#SELINUX=enforcing@"   /etc/selinux/config
sed -i -e "s@SELINUX=permissive@#SELINUX=permissive@"   /etc/selinux/config
sed -i -e "/SELINUX=/aSELINUX=disabled"   /etc/selinux/config
fi

# Kill nptd on running...
ProcessID="`ps aux | grep ntpd | awk '{print $2}' `"
for i in $ProcessID
do
  echo $i
  kill -9 $i
done
ntpdate tick.stdtime.gov.tw

# Kill yum on running...
ProcessID="`ps aux | grep yum | awk '{print $2}' `"
for i in $ProcessID
do
  echo $i
  kill -9 $i
done

#Prerequisites

yum -y install httpd php gcc glibc glibc-common gd gd-devel xinetd openssl-devel

#1) Create Account Information

#su -l
/usr/sbin/useradd nagios
#passwd nagios
/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -G nagcmd nagios
/usr/sbin/usermod -G nagcmd apache

#2) Download Nagios and the Plugins

cd  /usr/local/src
if test -f nagios-4.0.8.tar.gz
then
    echo "nagios-4.0.8.tar.gz exist"
else
    wget  http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.8.tar.gz
fi

if test -f nagios-plugins-2.0.3.tar.gz
then
    echo "nagios-plugins-2.0.3.tar.gz exist"
else
    wget  http://nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz
fi

if test -f nrpe-2.15.tar.gz
then
    echo "nrpe-2.15.tar.gz exist"
else
    wget  http://downloads.sourceforge.net/nagios/nrpe-2.15.tar.gz
fi

#3) Compile and Install Nagios

tar xvzf nagios-4.0.8.tar.gz
cd nagios-4.0.8
./configure --with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-commandmode

# 4) Customize Configuration

# vi /usr/local/nagios/etc/objects/contacts.cfg

#5) Configure the Web Interface

make install-webconf
#htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
# Set ID : nagiosadmin, Password : password
htpasswd -cb /usr/local/nagios/etc/htpasswd.users nagiosadmin password
service httpd restart

#[root@localhost nagios-4.0.8]# ls -al /usr/local/nagios/etc
#total 76
#drwxrwxr-x. 3 nagios nagios  4096 Aug 13 10:14 .
#drwxr-xr-x. 8 root   root    4096 Aug 13 10:14 ..
#-rw-rw-r--. 1 nagios nagios 12015 Aug 13 10:14 cgi.cfg
#-rw-r--r--. 1 root   root      26 Aug 13 10:14 htpasswd.users
#-rw-rw-r--. 1 nagios nagios 44475 Aug 13 10:14 nagios.cfg
#drwxrwxr-x. 2 nagios nagios  4096 Aug 13 10:14 objects
#-rw-rw----. 1 nagios nagios  1312 Aug 13 10:14 resource.cfg
#[root@localhost nagios-4.0.8]#

#[root@localhost nagios-4.0.8]# ls -al /usr/local/nagios/etc/objects/
#total 56
#drwxrwxr-x. 2 nagios nagios  4096 Aug 13 10:14 .
#drwxrwxr-x. 3 nagios nagios  4096 Aug 13 10:14 ..
#-rw-rw-r--. 1 nagios nagios  7688 Aug 13 10:14 commands.cfg
#-rw-rw-r--. 1 nagios nagios  2138 Aug 13 10:14 contacts.cfg
#-rw-rw-r--. 1 nagios nagios  5375 Aug 13 10:14 localhost.cfg
#-rw-rw-r--. 1 nagios nagios  3096 Aug 13 10:14 printer.cfg
#-rw-rw-r--. 1 nagios nagios  3265 Aug 13 10:14 switch.cfg
#-rw-rw-r--. 1 nagios nagios 10621 Aug 13 10:14 templates.cfg
#-rw-rw-r--. 1 nagios nagios  3180 Aug 13 10:14 timeperiods.cfg
#-rw-rw-r--. 1 nagios nagios  3991 Aug 13 10:14 windows.cfg
#[root@localhost nagios-4.0.8]#



#6) Compile and Install the Nagios Plugins

cd  /usr/local/src
tar xzf nagios-plugins-2.0.3.tar.gz
cd nagios-plugins-2.0.3
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install


# 7) Start Nagios

chkconfig --add nagios
chkconfig nagios on
# check  /usr/local/nagios/etc/nagios.cfg
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
# reload nagios.cfg
service nagios start

#8) Modify SELinux Settings
# Fedora ships with SELinux (Security Enhanced Linux) installed and in Enforcing mode by default. This can result in "Internal Server Error" messages when you attempt to access the Nagios CGIs.
# See if SELinux is in Enforcing mode.
# getenforce
# Put SELinux into Permissive mode.
# setenforce 0
# To make this change permanent, you'll have to modify the settings in /etc/selinux/config and reboot.
# Instead of disabling SELinux or setting it to permissive mode, you can use the following command to run the CGIs under SELinux enforcing/targeted mode:
# chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin/
# chcon -R -t httpd_sys_content_t /usr/local/nagios/share/
# For information on running the Nagios CGIs under Enforcing mode with a targeted policy, visit the NagiosCommunity.org wiki at http://www.nagioscommunity.org/wiki.

# 9) Login to the Web Interface

# You should now be able to access the Nagios web interface at the URL below. You'll be prompted for the username (nagiosadmin) and password you specified earlier.

#firefox http://localhost/nagios/ &

#如果你有自己做的設定檔案, 記得改變擁有者, 讓 nagios 可以讀取
#chown -R nagios:nagios /usr/local/nagios/etc
#sed -i -e "s@use_authentication=1@use_authentication=0@"  /usr/local/nagios/etc/cgi.cfg

chkconfig httpd on
service httpd restart

#echo -e "\033[31m Please wait for FireFox, Account: nagiosadmin ********** \033[0m"
#htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
htpasswd -cb /usr/local/nagios/etc/htpasswd.users nagiosadmin password
#firefox http://localhost/nagios &

echo -e "\033[31;42m ********** Install Nagios Plugins on CentOS ********** \033[0m"

cd  /usr/local/src
tar zxvf nagios-plugins-2.0.3.tar.gz
cd nagios-plugins-2.0.3
./configure
make
make install

#/bin/cp -f /usr/local/nagios/etc/objects/*.cfg  /usr/local/nagios/etc/.
sed -i -e "s@use_authentication=1@use_authentication=0@"  /usr/local/nagios/etc/cgi.cfg

chown -R nagios.nagios /usr/local/nagios
#yum -y install xinetd
#firefox http://localhost/nagios &

echo -e "\033[31;42m ********** Install Nagios NRPE on CentOS  ********** \033[0m"


if  [ "chkconfig --list | grep nrpe" != "" ]; then
  echo "Turn Off nrpe by yum install, if exist"
  chkconfig nrpe off
  service nrpe stop
fi

# nrpe is ok on "service nrpe restart", but failed on "/usr/lib/nagios/plugins/check_nrpe -H localhost"
# so we will start NRPE by xinetd
#./configure need gcc

cd  /usr/local/src
tar zxvf nrpe-2.15.tar.gz
cd nrpe-2.15
#yum -y install gcc xinetd nagios-devel openssl-devel
#yum -y install openssl-devel

./configure
make all
make install-plugin
make install-daemon
make install-daemon-config
make install-xinetd


chown nagios.nagios /usr/local/nagios

chown -R nagios.nagios /usr/local/nagios/libexec

echo "nrpe 5666/tcp # NRPE"  >> /etc/services

chkconfig xinetd on
service xinetd restart
service xinetd status
netstat -at | grep nrpe
/usr/local/nagios/libexec/check_nrpe -H localhost

service iptables restart
#iptables  -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
#iptables  -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
# Fedora
#iptables  -A INPUT -m state --state NEW -m tcp -p tcp --dport 5666 -j ACCEPT
#iptables -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 5666 -j ACCEPT
#iptables -I RH-Firewall-1-INPUT -s 192.168.128.0/24 -m state --state NEW -m tcp -p tcp --dport 5666 -j ACCEPT
#iptables -I RH-Firewall-1-INPUT -p tcp -m tcp --dport 5666 -j ACCEPT
# CentOS 5.4 x86
iptables -I RH-Firewall-1-INPUT -s 192.168.128.0/24 -m state --state NEW -m tcp -p tcp --dport 5666 -j ACCEPT
# Fedora 12 x86
iptables -I INPUT -s 192.168.128.0/24 -m state --state NEW -m tcp -p tcp --dport 5666 -j ACCEPT
service iptables save
service iptables restart

echo -e "\033[31;42m ********** TEST on CentOS  ********** \033[0m"

#let other nagios machine can browse this machine
#sed -i -e "s@127.0.0.1@127.0.0.1  192.168.128.128  10.3.0.208@"  /etc/xinetd.d/nrpe

chown -R nagios.nagios /usr/local/nagios

#service nagios restart
service xinetd restart
service httpd restart

# Kill nagios daemon on running...
ProcessID="`ps aux | grep nagios | awk '{print $2}' `"
for i in $ProcessID
do
  echo $i
  kill -9 $i
done
ps aux | grep nagios
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg

echo -e "\033[31m *.cfg : /usr/local/nagios/etc/*.cfg \033[0m"
echo " "
echo -e "\033[31m Please wait for FireFox ...\033[0m"
echo -e "\033[31m Account: nagiosadmin \033[0m"
echo -e "\033[31m Password : password \033[0m"

firefox http://localhost/nagios &




(完)

相關

[研究] Nagios 4.0.8 安裝(tar.gz)(CentOS 6.5 x86_64)
http://shaurong.blogspot.com/2014/08/nagios-408-targzcentos-65-x8664.html

[研究] Nagios 3.5.1 安裝 (yum)(CentOS 6.5 x64)
http://shaurong.blogspot.com/2014/01/nagios-351-yumcentos-65-x64.html

[研究] Nagios 4.0.2 快速安裝程式(tar.gz) (CentOS 6.5 x64)
http://shaurong.blogspot.com/2014/01/nagios-402-centos-65-x64.html

[研究] Nagios XI 2012 R2.7 安裝
http://shaurong.blogspot.com/2014/01/nagios-xi-2012-r27.html

[研究] Nagios 4.0.0 Beta1 安裝 (CentOS 6.4 x64)
http://shaurong.blogspot.com/2013/08/nagios-400-beta1-centos-64-x64.html

[研究] Nagios XI 2012 R1.5 安裝
http://shaurong.blogspot.com/2013/02/nagios-xi-2012-r15.html

[研究] Nagios XI 2012 R1.5 安裝
http://forum.icst.org.tw/phpbb/viewtopic.php?t=79313

CentOS 5.8 Nagios 3.3.1 Check_nt回報設定
http://forum.icst.org.tw/phpbb/viewtopic.php?t=26279

網路監控你選Cacti還是Nagios呢?
http://forum.icst.org.tw/phpbb/viewtopic.php?t=24328

[研究] Nagios 3.2.3 安裝(tar.gz)(Fedora 15 x86)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=20255

[研究] Nagios 3.2.3 安裝(tar.gz)(CentOS 6.0 x86)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=20254

[研究] Nagios 3.2.3快速安裝程式(yum)(Fedora 15 x86)(失敗)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=20253

[研究] Nagios 3.2.3快速安裝程式(yum)(Fedora 14 x86)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=19201

有人成功在 Fedora 14 上安裝 nagios-3.2.3.tar.gz 嗎 ?
http://forum.icst.org.tw/phpbb/viewtopic.php?t=19184

[研究] Nagios XI 安裝
http://forum.icst.org.tw/phpbb/viewtopic.php?t=18007

[研究] Nagios 3.2.0 快速安裝程式(tar.gz)(CentOS 5.4 x86)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=17761

[問題] 請問如何用 nagios 檢查 iptables 是否有執行 ?
http://forum.icst.org.tw/phpbb/viewtopic.php?t=17678

[問題] 請問 nagios 的歷史狀態資料如何清除 ?
http://forum.icst.org.tw/phpbb/viewtopic.php?t=17677

[研究] Nagios 2.12快速安裝程式(Fedora9,tgz版)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=16129

大家用過哪些管理工具?感覺如何? (Nagios, MRTG,...)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=16091

[研究] Nagios 2.11快速安裝程式(Fedora 9 + yum安裝)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=16073

[研究] Nagios 快速安裝程式(Fedora 9 + yum安裝)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=16072

[研究] Nagios 3.0.6 快速安裝程式(tar.gz)(Fedora Core 9)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=16071

有人會用 nagios 的 check_oracle 嗎 ?
http://forum.icst.org.tw/phpbb/viewtopic.php?t=14382

[研究] Nagios 2.7 安裝(yum)(Fedora Core 5)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=12854

nagios 2.9穩定嗎? 還是偵測方式問題? (FC5, 使用 tar.gz 安裝)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=12853

[問題] F7 (Fedora 7)上如何用yum安裝nagios ?
http://forum.icst.org.tw/phpbb/viewtopic.php?t=12743

【FreeBSD】Nagios-提供高效能和高準確性的網路監控軟體
http://forum.icst.org.tw/phpbb/viewtopic.php?t=12648

[問題] FC5(Fedora Core 5)上用tar.gz安裝nagios 2.9體無法使用?
http://forum.icst.org.tw/phpbb/viewtopic.php?t=12599


沒有留言:

張貼留言