服务端的操作:
##################################安装lamp环境及依赖包##########################
   24  rpm -ivh gd-devel-2.0.35-11.el6.x86_64.rpm --nodeps  # 加不加都可以
   25  cd /media/Packages/
   26   yum -y install httpd gcc glibc glibc-common gd gd-devel php php-mysql mysql mysql-devel mysql-server
################################添加用户,组,apache用户赋予nagios用户权限#####
   27   groupadd  nagios
   28  useradd -g nagios nagios  # 27和28部 可以写为 useradd nagios 默认用户的组为nagios
   29  passwd nagios
   30  usermod (-a) -G nagios apache
   31  cd /root/Desktop/
   32  ls
#############################安装nagios主程序####################################
   33  tar -xzvf nagios-4.0.3.tar.gz
   34  cd nagios-4.0.3
   35  ls
   36  ./configure --with-command-group=nagios --enable-event-broker
   37  make all  # 编译所有
   38  make install   //安装主程序,CGI和HTML文件
   39  make install-init   //在/etc/rc.d/init.d安装启动脚本
   39  make install-commandmode   //配置目录权限
   40  make install-config   //安装示例配置文件
   41  make install-webconf   //安装nagios的web接口,会在/etc/httpd/conf.d目录中创建       nagios.conf文件。
#####################################创建用户访问控制用户和密码##################
    配置apache
    找到apache 的配置文件,修改httpd.conf
    找到:
    User daemon
    
Group daemon
    修改为?
    User nagios
    
Group nagios
    然后找到?
    <IfModule dir_module>
    
DirectoryIndex index.html
    
</IfModule>
    修改为?
    <IfModule dir_module>
    
DirectoryIndex index.html index.php
    
</IfModule>
    接着增加如下内容:?
    AddType application/x-httpd-php .php
    为了安全起见,一般情况下要让nagios 的web 监控页面必须经过授权才能访问,这需要增加验证配置,即在httpd.conf 文件最后添加如下信息:?

    #setting for nagios

    ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"

    <Directory "/usr/local/nagios/sbin">
     
    AuthType Basic
     
    Options ExecCGI
     
    AllowOverride None
     
    Order allow,deny
     
    Allow from all
     
    AuthName "Nagios Access"
     
    AuthUserFile /usr/local/nagios/etc/htpasswd             //用于此目录访问身份验证的文件
     
    Require valid-user

    </Directory>

    Alias /nagios "/usr/local/nagios/share"

    <Directory "/usr/local/nagios/share">
     
    AuthType Basic
     
    Options None
     
    AllowOverride None
     
    Order allow,deny
     
    Allow from all
     
    AuthName "nagios Access"
     
    AuthUserFile /usr/local/nagios/etc/htpasswd
     
    Require valid-user

    </Directory>

   42   htpasswd -c /usr/local/nagios/etc/htpasswd  nagiosadmin         #nagiosadmin为用户名 htpasswd为用户设置密码
   43  service httpd restart
   44  ifup eth0
   45  service iptables stop
   46  setenforce 0
   47  ifconfig
   48  cd /root/Desktop
####################################安装nagios-Plugin插件#############################
   49  tar -xzvf nagios-plugins-1.5.tar.gz
   50  cd nagios-plugins-1.5
   51  ls
   52   ./configure --with-nagios-user=nagios --with-nagios-group=nagios
   53  make &&make install
   54  chkconfig --add nagios  # 把nagios添加到开机系统中
   55  chkconfig nagios on   #把nagios设置为开机启动
   56  /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg             检查nagios的配置文件 出现两个 0 就正确
   57  service nagios start
   58  cd /root/Desktop
   59  ls

   监控windows 时 安装windows的插件
   1: 进入nagios的配置文件下的nagios.cfg里面
   vim /usr/local/nagios/etc/nagios.cfg
   cfg-file把# 注释去掉
   2:vim etc/objects/windows.cfg
      改为虚拟机的IP  address         172.18.9.122    ; IP address of the     host
   3:windows 下安装插件NSClient++ IP设为虚拟机的IP
     
   

监控linux安装nrep插件
###############################安装nrpe插件########################################
   60  tar -xzvf nrpe-2.12.tar.gz
   61  cd nrpe-2.12
   62  ./configure --with-nrpe-user=nagios --with-nrpe-group=nagios --with-nagios-user=nagios --with-nagios-group=nagios --enable-command-args --enable-ssl
   63  make all
   64  make install-plugin
####################创建监控linux主机的配置文件linuxserver.cfg#######################
   65  cd /usr/local/nagios/
   66  ls
   67  cd etc/objects/
   68  ls
   69  vim linuxserver.cfg

添加:

define host{
        use linux-server
        host_name linuxserver
        alias my linux server
        address 172.18.9.98 (客户端ip)
}
define service{
        use                     local-service
        host_name               linuxserver
        service_description     Current Users
        check_command           check_nrpe!check_users
        }
define service{
        use                     local-service
        host_name               linuxserver
        service_description     Current Load
        check_command           check_nrpe!check_load
        }
define service{
        use                             local-service
        host_name                       linuxserver
        service_description             Swap Usage
        check_command                   check_local_swap!20!10
        }
define service{
        use                             local-service
        host_name                       linuxserver
        service_description             http
        check_command                   check_http
        }

#######################在命令文件里添加命令调用linuxserver.cfg里面的服务############
   70  vim commands.cfg
   71  cd ..
   72  ls

      添加:
      在commands.cfg中增加对check_nrpe的定义
define command{
        command_name    check_nrpe        
        command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$       
        }

###################在主配置文件里面添加调用linuxserver.cfg配置文件的命令############
   73  vim nagios.cfg
去掉#号 进入vim /usr/local/nagios/etc/nagios.cfg
添加:
cfg_file=/usr/local/nagios/etc/objects/linuxserver.cfg

######################重启服务测试############################################
   74  service nagios restart

客户端操作:
###################################安装依赖环境####################################
   67  rpm -ivh gd-devel-2.0.35-11.el6.x86_64.rpm --nodeps
   68  cd /media/Packages/
   69  yum -y install httpd gcc glibc glibc-common gd gd-devel php php-   mysql mysql mysql-devel mysql-server openssl*
######################################创建默认不能登录系统的nagios用户############
   70  useradd -s /sbin/nologin nagios
   71  cd /root/Desktop
   72  ls
########################安装nagios-plugin插件######################################
   73  tar -xzvf nagios-plugins-1.5.tar.gz
   74  cd nagios-plugins-1.5
   75  ls
   76  ./configure --with-nagios-user=nagios --with-nagios-group=nagios
   77  make all
   78  make install
   79  cd /root/Desktop
#########################安装nrpe插件##############################################
   80  tar -xzvf nrpe-2.12.tar.gz
   81  cd nrpe-2.12
   82  ./configure --with-nrpe-user=nagios --with-nrpe-group=nagios --with-nagios-user=nagios --with-nagios-group=nagios --enable-command-args --enable-ssl
   83  make all
   84  make install-plugin && make install-daemon &&make install-daemon-config
#############################修改nrpe配置文件使其与服务器建立连接####################
   85  vim /usr/local/nagios/etc/nrpe.cfg
修改参数:
allowed_hosts=172.16.100.1(服务器ip)

##########################启动nrpe插件#####################################
   86  /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
   87  ifup eth0
   88  service iptables stop
   89  setenforce 0
   90  ifconfig
####################################开启http服务#################################
   91  service httpd restart

nagios安装及监控Linux主机的更多相关文章

  1. 一步步实现Nagios监控linux主机及飞信报警

    一步步实现Nagios监控linux主机及飞信报警 上篇文章介绍了在linux主机上架设nagios监控服务,并对windows主机进行服务状态变化的监控,这次我们继续上次内容.      首先实现n ...

  2. Zabbix监控Linux主机设置

          说明: Zabbix监控服务端已经配置完成,现在要使用Zabbix对Linux主机进行监控. 具体操作: 以下操作在被监控的Linux主机进行,这里以CentOS 6.x系统为例. 一.配 ...

  3. nagios系列(八)之nagios通过nsclient监控windows主机

    nagios通过nsclient监控windows主机 1.下载NSClient -0.3.8-Win32.rar安装在需要被监控的windows主机中 可以设置密码,此处密码留空 2.通过在nagi ...

  4. zabbix通过snmp监控linux主机

    1.安装net-snmp [root@db01 ~]# yum install -y net-snmp 2.修改配置文件 [root@db01 ~]# vim /etc/snmp/snmpd.conf ...

  5. zabbix通过agent监控linux主机

    前言: 前几篇博客分别介绍了通过snmp来进行监控linux主机与windows主机,本篇介绍通过agent客户端来进行系统监控. 环境: server:192.168.249.142 client: ...

  6. 使用cacti监控linux主机

    介绍:使用cacti监控linux主机,需要在linux主机上面安装snmp服务,并修改snmpd.conf文件,指定cacti服务器的地址,然后在cacti的前台界面添加此主机即可,此处以监控cen ...

  7. Cacti监控Linux主机

    1 要监视一台Linux主机,需要在被监控的主机上安装net-snmp相关软件包,CentOS安装可使用“yum -y install net-snmp”命令:# yum -y install net ...

  8. Nagios利用NSClient++监控Windows主机

    在Nagios的libexec下有check_nt这个插件,它就是用来检查windows机器的服务的.其功能类似于check_nrpe.不过还需要搭配另外一个软件NSClient++,它则类似于NRP ...

  9. nagios监控linux主机监控内存脚本

    说明 工作包括两部分监控端(一二三)和被监控端(四) 一.nrpe.cfg中添加脚本 nrpe.cfg中添加命令索引 command[check_used_mem]=/usr/local/nagios ...

随机推荐

  1. Reinstall the Arduino Pro Mini Bootloade ISP(转)

    源:Reinstall the Arduino Pro Mini Bootloade ISP To resolve the errors I burned the bootloader to the ...

  2. hadoop如何查看文件系统

    1.查看当前的文件系统 [root@hadoopmaster bin]# . itemsdrwxr 00 00 /user 当然也可以以浏览器中这样查看localhost:50070   这就是had ...

  3. ZOJ 3930 Dice Notation

    简单模拟题.一个int写成了char,搞了4个多小时.真垃圾.. #include<stdio.h> #include<string.h> +],s[+]; +]; +]; i ...

  4. 服务器性能分析工具gprof的使用及没有生成gmon.out文件的原因

            早上从网上查看资料时无意中看到了gprof这个工具,随便把他用在项目里试了一下.结果发现调用次数的数据比较全,但调用时间基本上都是0.网上查了一下发现gprof只记录执行时间超过0.0 ...

  5. Java中的Runtime类

    Runtime类描述了虚拟机一些信息.该类采用了单例设计模式,可以通过静态方法 getRuntime()获取Runtime类实例.下面演示了获取虚拟机的内存信息: package Main; publ ...

  6. 将ADS1.2的工程迁移到KEIL上-基于2440

    裸机程序应该是一个很好的选择 1. 不拷贝启动代码,因为我们用自己的启动代码 2.       建立工程目录分级,建立完成后如下所示 拷贝相应代码到对应目录中 Option中拷贝 Core中拷贝 建立 ...

  7. Android 屏幕适配方案(转载)

    3.百分比的引入 1.引入 其实我们的解决方案,就是在项目中针对你所需要适配的手机屏幕的分辨率各自简历一个文件夹. 如下图: 然后我们根据一个基准,为基准的意思就是: 比如480*320的分辨率为基准 ...

  8. PHP读取Excel文件(PHPExcel)

    /*     * 读取Excel文件     * */    require_once (dirname(dirname(dirname(__FILE__))).'/PHPExcel/PHPExcel ...

  9. ubuntu 16.04 php 安装curl方法

    先查看自己的php是否已经安装了curl.方法如下:1.在web服务器目录( Ubuntu下的通常为 /var/www )新建test.php文件2.编辑文件,键入下面一行代码:<?php ph ...

  10. 安卓弹出对话框——Alertdialog(一)

    首先看各种样式的对话框: 我们看到,Dialog有很多的子类实现,所以我们要定义一个对话框,使用其子类来实例化一个即可,而不要直接使用Dialog这个父类来构造. 二.AlertDialog 今天我们 ...