make all make install [color=Red]//来安装主程序,CGI和HTML文件 [/color] make install-init [color=Red]//在/etc/rc.d/init.d安装启动脚本[/color] make install-commandmode [color=Red]//来配置目录权限[/color] make install-config [color=Red]//来安装示例配置文件,安装的路径是/usr/local/nagios/etc[/color].
share Nagios网页文件所在的目录 var Nagios日志文件、spid 等文件所在的目录
var/archives Empty directory for the archived logs /var/rw Empty directory for the external command file
2.安装插件 1)解压缩: tar -zxvf nagios-plugins-1.4.9.tar.gz cd nagios-plugins-1.4.9 ./configure --prefix=/usr/local/nagios/ [color=Red](在redhat系统上面安装可能出现configure时,到这里checking for redhat spopen problem...就不动了,所以需要在configure时再加上--enable-redhat-pthread-workaround )[/color] make make install ls /usr/local/nagios/libexec/ 会显示安装的插件文件,即所有的插件都安装在libexec这个目录下
我的是daemon,下面将这个用户加入nagios组 usermod -G nagios daemon 3)修改apache配置: 修改apache的配置文件,增加nagios的目录,并且访问此目录需要进行身份验证 vi /usr/local/apache2/conf/httpd.conf,在最后增加如下内容 :
ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin Options ExecCGI AllowOverride None Order allow,deny Allow from all AuthName "Nagios Access" AuthType Basic AuthUserFile /usr/local/nagios/etc/htpasswd [color=Red]//用于此目录访问身份验证的文件[/color] Require valid-user Alias /nagios /usr/local/nagios/share Options None AllowOverride None Order allow,deny Allow from all AuthName "Nagios Access" AuthType Basic AuthUserFile /usr/local/nagios/etc/htpasswd [color=Red]//用于此目录访问身份验证的文件[/color] Require valid-user
4)增加验证用户: 也就是通过web访问nagios的时候,必须要用这个用户登陆.在这里我们增加用户test:密码为123456 #/usr/local/apache2/bin/htpasswd -c /usr/local/nagios/etc/htpasswd test [color=Red]//用户名[/color] New password: //(输入123456) Re-type new password: (再输入一次密码) Adding password for user test 5)查看认证文件的内容: [root@localhost conf]# less /usr/local/nagios/etc/htpasswd test:OmWGEsBnoGpIc [color=Red] //前半部分是用户名test,后面是加密后的密码 [/color]
# vi contactgroups.cfg define contactgroup{ contactgroup_name sagroup [color=Red]//联系人组的名称,同样不能空格 [/color] alias System Administrators [color=Red]//别名 [/color] members test [color=Red]//组的成员,来自于上面定义的contacts.cfg,如果有多个联系人则以逗号相隔 [/color] }
例如,我们查看check_disk这个插件的用法则可以使用check_disk –h # ./check_disk -h check_disk (nagios-plugins 1.4.9) 1.91 Copyright (c) 1999 Ethan Galstad <[email]nagios@nagios.org[/email]> Copyright (c) 1999-2006 Nagios Plugin Development Team <[email]nagiosplug-[email]devel@lists.sourceforge.net[/email][/email]> This plugin checks the amount of used disk space on a mounted file system and generates an alert if free space is less than one of the threshold values Usage: check_disk -w limit -c limit [-p path | -x device] [-t timeout][-m] [-e] [-W limit] [-K limit] [-v] [-q] [-E]
设置密码 # passwd nagios 2)安装nagios插件 tar -zxvf nagios-plugins-1.4.9.tar.gz cd nagios-plugins-1.4.9 编译安装 ./configure --enable-redhat-pthread-workaround make make install 这一步完成后会在/usr/local/nagios/下生成两个目录libexec和share # ls /usr/local/nagios/ libexec share
修改目录权限 # chown nagios.nagios /usr/local/nagios # chown -R nagios.nagios /usr/local/nagios/libexec 3)安装nrpe 解压缩 tar -zxvf nrpe-2.8.1.tar.gz cd nrpe-2.8.1 编译 ./configure NRPE的端口是5666 make all 接下来安装NPRE插件,daemon和示例配置文件
安装check_nrpe这个插件 make install-plugin 之前说过监控机需要安装check_nrpe这个插件,被监控机并不需要,我们在这里安装它是为了测试的目的
安装deamon make install-daemon 安装配置文件 make install-daemon-config 现在再查看nagios目录就会发现有4个目录了 # ls /usr/local/nagios/ bin etc libexec share 将NRPE deamon作为xinetd下的一个服务运行的.在这样的情况下xinetd就必须要先安装好,不过一般系统已经默认装了 4)安装xinetd脚本 # make install-xinetd 输出如下 /usr/bin/install -c -m 644 sample-config/nrpe.xinetd /etc/xinetd.d/nrpe
可以看到创建了这个文件/etc/xinetd.d/nrpe 编辑这个脚本 vi /etc/xinetd.d/nrpe # default: on # description: NRPE (Nagios Remote Plugin Executor) service nrpe { flags = REUSE socket_type = stream port = 5666 wait = no user = nagios group = nagios server = /usr/local/nagios/bin/nrpe server_args = -c /usr/local/nagios/etc/nrpe.cfg --inetd log_on_failure += USERID disable = no only_from = 127.0.0.1 [color=Red]在后面增加监控主机的地址192.168.1.240,以空格间隔 [/color] }
改后 only_from = 127.0.0.1 192.168.1.240 编辑/etc/services文件,增加NRPE服务 vi /etc/services
安装check_nrpe插件 # tar -zxvf nrpe-2.8.1.tar.gz # cd nrpe-2.8.1 # ./configure # make all # make install-plugin [color=Red]只运行这一步就行了,因为只需要check_nrpe插件 [/color] 在apache刚装好了nrpe,现在我们测试一下监控机使用check_nrpe与被监控机运行的nrpedaemon之间的通信.