nagios 3.0.6 搭建配置文档

  • 格式:docx
  • 大小:18.47 KB
  • 文档页数:10

nagios 3.0.6 搭建配置文档Nagios是一款用于系统和网络监控的应用程序。

它可以在你设定的条件下对主机和服务进行监控,在状态变差和变好的时候给出告警信息。

nagios特征简单说明:监控网络服务(SMTP、POP3、HTTP、NNTP、PING等);监控主机资源(处理器负荷、磁盘利用率等);简单地插件设计使得用户可以方便地扩展自己服务的检测方法;并行服务检查机制;具备定义网络分层结构的能力,用"parent"主机定义来表达网络主机间的关系,这种关系可被用来发现和明晰主机宕机或不可达状态;当服务或主机问题产生与解决时将告警发送给联系人(通过EMail、短信、用户定义方式);具备定义事件句柄功能,它可以在主机或服务的事件发生时获取更多问题定位;自动的日志回滚;可以支持并实现对主机的冗余监控;可选的WEB界面用于查看当前的网络状态、通知和故障历史、日志文件等nagios-3.0.6.tar.gz -----------------------主程序nagios-plugins-1.4.13.tar.gz------------------插件nrpe_2.8.1.tar.gz --------------------------监控Linux需要nsclient++0.3.5 ---------------------------监控windows需要nagios服务器端(192.168.1.176)linux被监控端(192.168.1.175)一。

安装nagios服务器端配置1.准备软件包(我偷懒了,嘿嘿)yum install httpdyum install gccyum install glibc glibc-commonyum install gd gd-develyum install mysql mysql-server mysql-develyum install gnutls2.建立用户useradd nagiospasswd nagios建立一个用户组名为nagcmd组,用于web借口执行外部命令。

并将nagios用户和apache用户都加到这个组中groupadd nagcmdusermod -G nagcmd nagiosusermod -G nagcmd apache3.下载nagios和插件程序包wget/sourceforge/nagios/nagios-3.0.6.tar.gz wget/sourceforge/nagiosplug/nagios-plugins -1.4.13.tar.gzwget/project/nagios/nrpe-2.x/nrp e-2.8.1/nrpe-2.8.1.tar.gz4.安装nagisotar xzf nagios-3.0.6.tar.gzcd nagios-3.0.6.tar.gz运行Nagios配置脚本并使用先前开设的用户及用户组:./configure --with-group=nagios --with-user=nagios--with-command-group=nagcmd --with-gd-lib=/usr/lib--with-gd-inc=/usr/include编译Nagios程序包源码make all安装二进制运行程序、初始化脚本、配置文件样本并设置运行目录权限make installmake install-initmake install-configmake install-commandmode5.定义收报警邮件的邮箱vi /usr/local/nagios/etc/objects/contacts.cfg更改email地址nagiosadmin的联系人定义信息中的EMail信息为你的EMail 信息以接收报警内容。

6.配置web接口安装Nagios的WEB配置文件到Apache的conf.d目录下make install-webconf创建一个nagiosadmin 的用户用于Nagios的WEB接口登录。

记下你所设置的登录口令,一会儿你会用到它。

htpasswd -c /usr/local/nagios/etc/ers nagiosadmin输入密码(记住密码,这是你等下登陆nagios web页面的用户名和密码)重启Apache服务以使设置生效。

service httpd restartchown -R nagiso.nagiso /usr/local/nagios/etc/ers(这个一定要修改,这个属主权限没有更改为nagios的话,web页面很多没有权限打开,我因为这个,调试了很久)编辑httpd.conf配置文件vi /etc/httpd/conf/httpd.conf在配置文件最后添加如下内容ScriptAlias "/nagios/cgi-bin" "/usr/local/nagios/sbin"<Directory "/usr/local/nagios/sbin">Options ExecCGIAllowOverride NoneOrder allow,denyAllow from allAuthName "Nagios Access"AuthType BasicAuthUserFile /usr/local/nagios/etc/ersRequire valid-user</Directory>Alias /nagios "/usr/local/nagios/share"<Directory "/usr/local/nagios/share">Options NoneAllowOverride NoneOrder allow,denyAllow from allAuthName "Nagios Access"AuthType BasicAuthUserFile /usr/local/nagios/etc/ersRequire valid-user</Directory>重启apachekillall httpdservice httpd restart[root@duoduo-test /]# service httpd restartStopping httpd: [ OK ] Starting httpd: [Fri Mar 26 00:51:01 2010] [warn] The ScriptAlias directive in /etc/httpd/conf/httpd.conf at line 992 will probably never match because it overlaps an earlier ScriptAlias.[Fri Mar 26 00:51:01 2010] [warn] The Alias directive in/etc/httpd/conf/httpd.conf at line 1003 will probably never match because it overlaps an earlier Alias.httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName[ OK ]重启httpd服务,会出现警告信息,但是不会影响nagios的运行,此问题我在网上查询了很久的资料,没有明确的方法7.编译比安装nagios插件tar -zxvf nagios-plugins-1.4.11.tar.gzcd nagios-plugins-1.4.11./configure --prefix=/usr/local/nagios --with-nagios-user=nagios--with-nagios-gourp=nagiosmake&&make install8.验证nagios的样例配置文件/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg出现这样的就代表没有错误,假如有错误,会指出哪个配置文件哪行有错误,只要去修改就行[root@duoduo-test local]# /usr/local/nagios/bin/nagios -v/usr/local/nagios/etc/nagios.cfgNagios 3.0.6Copyright (c) 1999-2008 Ethan Galstad ()Last Modified: 12-01-2008License: GPLReading configuration data...Running pre-flight check on configuration data...Checking services...Checked 19 services.Checking hosts...Checked 2 hosts.Checking host groups...Checked 1 host groups.Checking service groups...Checked 0 service groups.Checking contacts...Checked 1 contacts.Checking contact groups...Checked 1 contact groups.Checking service escalations...Checked 0 service escalations.Checking service dependencies...Checked 0 service dependencies.Checking host escalations...Checked 0 host escalations.Checking host dependencies...Checked 0 host dependencies.Checking commands...Checked 25 commands.Checking time periods...Checked 5 time periods.Checking for circular paths between hosts...Checking for circular host and service dependencies...Checking global event handlers...Checking obsessive compulsive processor commands...Checking misc settings...Total Warnings: 0Total Errors: 0Things look okay - No serious problems were detected during the pre-flight check[root@duoduo-test local]#chkconfig --add nagioschkconfig nagios on如果没有报错,可以启动Nagios服务service nagios start9.关闭selinuxvi /etc/sysconfig/selinuxSELINUX=disabled将selinux设置为disabled状态,重启系统使selinux配置生效10。