首页 > 代码库 > 【Nagios】

【Nagios】

Installation documentation

https://assets.nagios.com/downloads/nagioscore/docs/Installing_Nagios_Core_From_Source.pdf#_ga=1.139535539.1081149190.1491445330

解决Perl软件编译问题

[root@nkgl50873268c yum.repos.d]# echo ‘export LC_ALL=C‘>> /etc/profile  《##设置环境变量

[root@nkgl50873268c 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

[root@nkgl50873268c yum.repos.d]# source /etc/profile  《#### 使增加的环境变量配置生效

[root@nkgl50873268c yum.repos.d]# echo $LC_ALL            《#####查看设置结果

C

[root@nkgl50873268c yum.repos.d]#  cd ~

关闭放火墙和selinux

1). [root@nkgl50873268c ~]# setenforce 0

setenforce: SELinux is disabled

2). [root@nkgl50873268c ~]# sed -i "s/SELINUX=enforcing/SELINUX=disabled/g"

/etc/selinux/config

3). [root@nkgl50873268c ~]# chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin/

[root@nkgl50873268c ~]# chcon -R -t httpd_sys_content_t /usr/local/nagios/share/

解决时间同步问题

[root@nkgl50873268c ~]# /usr/sbin/ntpdate pool.ntp.org

10 Nov 11:01:05 ntpdate[68483]: the NTP socket is in use, exiting

[root@nkgl50873268c ~]# echo ‘#time sync by zp at 2016-11-10‘>>/var/spool/cron/root

[root@nkgl50873268c ~]# echo ‘*/5 * * * * /usr/sbin/ntpdate pool.ntp.org  > /dev/null 2>&1‘>> /var/spool/cron/root

[root@nkgl50873268c ~]# crontab -l

#time sync by zp at 2016-11-10

*/5 * * * * /usr/sbin/ntpdate pool.ntp,org  > /dev/null 2>&1

[root@nkgl50873268c ~]#

安装 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环境

[root@nkgl50873268c ~]# 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

安装省略。。。。。

字符串检查方法:

[root@nkgl50873268c objects]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

添加邮件

vi /usr/local/nagios/etc/objects/contacts.cfg +35

修改 nagios@localhost 为 523022598@qq.com

输入 http://IP/nagios/可进入nagios 监控画面

监控网站显示It appears as though you do not have permission to view information for any of the services you requests...

解决方法:

表用创建的用户没权限,加权限即可:

[root@nkgl570873268i etc]# sed -i ‘s/nagiosadmin/nagios/g‘ cgi.cfg

[root@nkgl50873268i 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】