首页 技术 正文
技术 2022年11月13日
0 收藏 313 点赞 3,790 浏览 2761 个字

nagios分为监控机和被监控机两类机器    监控主机:gserver150(192.168.111.150)被监控主机:gserver151(192.168.111.151) 一.  监控机器
1. 创建nagios组和用户  #groupadd nagcmd  #/usr/sbin/useradd -m nagios  #passwd nagios  #/usr/sbin/usermod -a -G nagcmd nagios 2. 安装nagios软件  #tar zxvf nagios-3.4.3.tar.gz  #./configure –with-command-group=nagcmd  #make all
  #make install  #make install-init  #make install-config  #make install-commandmode CentOS 6.2安装nagiosCentOS 6.2安装nagios 3. 配置nagios 安装完成后配置信息在:/usr/local/nagios/etc 修改 /usr/local/nagios/etc/objects/contacts.cfg文件的email,修改为实际邮件地址。 4. 配置web接口  # make install-webconf   CentOS 6.2安装nagiosCentOS 6.2安装nagios  nagios在http上的配置文件为/etc/httpd/conf.d/nagios.conf  将该文件内容补充到httpd的conf的结尾,重启httpd即可。    修改nagiosadmin的密码  #htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin    CentOS 6.2安装nagios    新密码为:qwer1234 5. 配置、启动nagios服务CentOS 6.2安装nagios    CentOS 6.2安装nagios 6. 浏览器访问http://192.168.111.150/nagios    CentOS 6.2安装nagiosCentOS 6.2安装nagios 7. 安装nagios插件   # ./configure –with-nagios-user=nagios \                          –with-nagios-group=nagios \                          –with-mysql=/opt/mysql-5.5.29 \                          –with-pgsql=/opt/pgsql-9.1.2  #make  #make install更改httpd.conf中打开cgi module   CentOS 6.2安装nagiosCentOS 6.2安装nagios   安装完成后,重新启动apache,就可以看到nagios开始监控本机CentOS 6.2安装nagios   CentOS 6.2安装nagios二. 被监控机1. 创建nagios用户    #sudo /usr/sbin/useradd nagios    #sudo passwd nagios    CentOS 6.2安装nagios    CentOS 6.2安装nagios2. 安装nagios插件    #tar zxvf nagios-plugins-1.4.16.tar.gz    #./configure    #make    #make install    安装完成后再/usr/local/nagios下生成两个目录    CentOS 6.2安装nagios    CentOS 6.2安装nagios3. 修改目录权限   #chown nagios.nagios /usr/local/nagios   #chown -R nagios.nagios /usr/local/nagios/libexec4. 安装nrpe   #tar zxvf nrpe-2.13.tar.gz    CentOS 6.2安装nagiosCentOS 6.2安装nagios   #./configure   #make   #make install   CentOS 6.2安装nagiosCentOS 6.2安装nagios   安装check_nrpe插件(监控机需安装check_nrpe这个插件,被监控机不需要,安装它是为了测试的目的)   #make install-plugin   CentOS 6.2安装nagiosCentOS 6.2安装nagios   安装deamon
   #make install-daemon   CentOS 6.2安装nagiosCentOS 6.2安装nagios   安装配置文件   #make install-daemon-config   CentOS 6.2安装nagiosCentOS 6.2安装nagios   现在再查看nagios目录就会发现有4个目录了   CentOS 6.2安装nagiosCentOS 6.2安装nagios 5. 安装xinetd   按照安装文档的说明,是将NRPE deamon作为xinetd下的一个服务运行的.在这样的情况下xinetd就必须要先安装好,不过一般系统已经默认装了。   安装xinetd(如果没有安装的话)   #yum install xinetd.x86_64      安装xinetd脚本   #make install-xinetd   CentOS 6.2安装nagiosCentOS 6.2安装nagios   编辑/etc/services文件,增加NRPE服务    #vi /etc/services   nrpe            5666/tcp                # nrpe   CentOS 6.2安装nagiosCentOS 6.2安装nagios   重启xinetd服务   #sudo /sbin/service xinetd restart   CentOS 6.2安装nagiosCentOS 6.2安装nagios   用netstat命令查看端口,可以看到 nrpe已经运行   #netstat -at | grep nrpe   #netstat -ant | grep 5666   CentOS 6.2安装nagiosCentOS 6.2安装nagios6.检查nrpe是否工作正常   #/usr/local/nagios/libexec/check_nrpe -H localhost   CentOS 6.2安装nagiosCentOS 6.2安装nagios  显示nrpe的版本号,说明nrpe工作正常  三. 在监控机上添加被监控主机1. 编写cfg_file文件(gserver)    登录gserver150,进入目录/usr/local/nagios/etc/objects,localhost.cfg即为本机的cfg_file。    复制localhost.cfg为gserver151.cfg    并修改gserver151.cfg文件里面的127.0.0.1为192.168.111.151, localhost为gserver151    在service里面的host_name都需要相应的修改为gserver151,附件为配置文件 CentOS 6.2安装nagios    CentOS 6.2安装nagios    屏蔽掉    CentOS 6.2安装nagios    否则可能出现nagios不能启动的问题。利用下面的命令检查nagios.conf可以发现问题是hostgroup定义重了。    CentOS 6.2安装nagios2. 将localhost.cfg设置到gserver150上    打开/usr/local/nagios/etc/nagios.cfg文件,在下面位置添加一行    CentOS 6.2安装nagiosCentOS 6.2安装nagios    重启nagios服务    #service nagios restart    即可看到下图。(刚开始gserver151是灰色的,过一会儿nagios获取数据后,开始变为绿色)    CentOS 6.2安装nagiosCentOS 6.2安装nagios 四. nagios监控1. 监控cpu使用率2. 监控memory使用率  FAQ1. 如果出现如下提示,说明nagios服务没有启动。   CentOS 6.2安装nagiosCentOS 6.2安装nagios   执行以下命令   sudo chkconfig –add nagios   sudo chkconfig nagios on   sudo servcie nagios start   启动nagios服务即可2. 如果出现以下情况,可能是httpd的cgi模块没有打开,此时需要在httpd.conf中打开mod_cgid.so模块即可   CentOS 6.2安装nagiosCentOS 6.2安装nagios

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,085
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,560
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,409
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,182
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,819
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,902