Installation documentation
解决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