標籤:linux nagios
Installation documentation
https://assets.nagios.com/downloads/nagioscore/docs/Installing_Nagios_Core_From_Source.pdf#_ga=1.139535539.1081149190.1491445330
解決Perl軟體編譯問題
[[email protected] yum.repos.d]# echo ‘export LC_ALL=C‘>> /etc/profile 《##設定環境變數
[[email protected] yum.repos.d]# tail -l /etc/profile
. "$i"
else
. "$i" >/dev/null 2>&1
fi
fi
done
unset i
unset -f pathmunge
export LC_ALL=C
[[email protected] yum.repos.d]# source /etc/profile 《#### 使增加的環境變數配置生效
[[email protected] yum.repos.d]# echo $LC_ALL 《#####查看設定結果
C
[[email protected] yum.repos.d]# cd ~
關閉放火牆和selinux
1). [[email protected] ~]# setenforce 0
setenforce: SELinux is disabled
2). [[email protected] ~]# sed -i "s/SELINUX=enforcing/SELINUX=disabled/g"
/etc/selinux/config
3). [[email protected] ~]# chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin/
[[email protected] ~]# chcon -R -t httpd_sys_content_t /usr/local/nagios/share/
解決時間同步問題
[[email protected] ~]# /usr/sbin/ntpdate pool.ntp.org
10 Nov 11:01:05 ntpdate[68483]: the NTP socket is in use, exiting
[[email protected] ~]# echo ‘#time sync by zp at 2016-11-10‘>>/var/spool/cron/root
[[email protected] ~]# echo ‘*/5 * * * * /usr/sbin/ntpdate pool.ntp.org > /dev/null 2>&1‘>> /var/spool/cron/root
[[email protected] ~]# crontab -l
#time sync by zp at 2016-11-10
*/5 * * * * /usr/sbin/ntpdate pool.ntp,org > /dev/null 2>&1
[[email protected] ~]#
安裝 Nagios服務端所需要的軟體包
需要web介面顯示監控效果,介面的展示主要使用PHP程式,因此需要LAMP環境。
yum install gcc glibc glibc-common -y <##### 升級編譯軟體
yum install gd gd-devel -y 《######使用者後面的PNP出圖的包
yum install mysql-server -y 《#####非必需,監控資料庫
yum install httpd php php-gd -y 《#####apache、php環境
[[email protected] ~]# rpm -qa mysql httpd php 《####檢查LAMP環境
mysql-5.1.73-7.el6.x86_64
php-5.3.3-48.el6_8.x86_64
httpd-2.2.15-54.el6_8.x86_64
建立Nagios伺服器需要的使用者和組
/usr/sbin/useradd nagios -M -s /sbin/nologin
/usr/sbin/usradd apache -M -s /sbin/nologin
/usr/sbin/usrmod -a -G nagcmd nagios
/usr/sbin/usrmod -a -G nagcmd apache
安裝省略。。。。。
字串檢查方法:
[[email protected] objects]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
添加郵件
vi /usr/local/nagios/etc/objects/contacts.cfg +35
修改 [email protected] 為 [email protected]
輸入 http://IP/nagios/可進入nagios 監控畫面
監控網站顯示It appears as though you do not have permission to view information for any of the services you requests...
解決方案:
表用建立的使用者沒許可權,加許可權即可:
[[email protected] etc]# sed -i ‘s/nagiosadmin/nagios/g‘ cgi.cfg
[[email protected] etc]# /etc/init.d/nagios reload
Running configuration check...
Reloading nagios configuration...
done
Create a Default User for Web Access. Add a default user for Web Interface Access: htpasswd –c /usr/local/nagios/etc/htpasswd.users nagiosadmin
【Nagios】