Nagios监控端和被控端安装配置指南,Ubuntu安装配置Nginx

ca88手机网页登录 6

一、nagios监控端安装

Nginx
是一个很牛的高性能Web和反向代理服务器,它具有很多非常优越的特性:在高连接并发的情况下,Nginx是Apache服务器不错的替代品:Nginx在美国是做虚拟主机生意的老板们经常选择的软件平台之一。能够支持高达
50,000 个并发连接数的响应,感谢Nginx为我们选择了 epoll and
kqueue作为开发模型。

CentOS 6.7 安装Nagios教程

CentOS 6.7 安装Nagios教程
参考文档:

一.安装依赖包

[[email protected]
~]# yum install -y httpd php
[[email protected]
~]# yum install -y gcc glibc glibc-common
[[email protected]
~]# yum install -y gd gd-devel
[[email protected]
~]# yum install -y perl ntp unzip
[[email protected]
~]# yum install -y openssl-devel

[[email protected]
~]# /etc/init.d/ntpd start
[[email protected]
~]# chkconfig ntpd on

[[email protected]
~]# /usr/sbin/useradd -m nagios
[[email protected]
~]# passwd nagios

[[email protected]
~]# /usr/sbin/groupadd nagcmd
[[email protected]
~]# /usr/sbin/usermod -a -G nagcmd nagios
[[email protected]
~]# /usr/sbin/usermod -a -G nagcmd apache
[[email protected]
~]# id nagios
uid=500(nagios) gid=500(nagios) groups=500(nagios),501(nagcmd)
[[email protected]
~]# id apache
uid=48(apache) gid=48(apache) groups=48(apache),501(nagcmd)

二.nagios的安装

[[email protected]
~]# cd /usr/local/src
[[email protected]
src]# wget

[[email protected]
src]# wget

[[email protected]
src]# tar zxvf nagios-4.1.1.tar.gz
[[email protected]ca88手机网页登录,
src]# cd nagios-4.1.1
[[email protected]
nagios-4.1.1]# ./configure –prefix=/usr/local/nagios
–with-comand-group=nagcmd
[[email protected]
nagios-4.1.1]# make all
[[email protected]
nagios-4.1.1]# make install
[[email protected]
nagios-4.1.1]# make install-init
[[email protected]
nagios-4.1.1]# make install-config
[[email protected]
nagios-4.1.1]# make install-commandmode
[[email protected]
nagios-4.1.1]# make install-webconf
[[email protected]
nagios-4.1.1]# cp -rf contrib/eventhandlers
/usr/local/nagios/libexec/
[[email protected]
nagios-4.1.1]# chown -R nagios:nagios
/usr/local/nagios/libexec/eventhandlers

三.nagios plugins的安装

[[email protected]
src]# tar xzf nagios-plugins-2.1.1.tar.gz
[[email protected]
src]# cd nagios-plugins-2.1.1
[[email protected]
nagios-plugins-2.1.1]# ./configure –prefix=/usr/local/nagios
–with-nagios-user=nagios –with-nagios-group=nagios
[[email protected]
nagios-plugins-2.1.1]# make && make install

四.nrpe插件安装

[[email protected]
src]# wget

[[email protected]
src]# tar zxf nrpe-2.15.tar.gz
[[email protected]
src]# cd nrpe-2.15
[[email protected]
nrpe-2.15]# ./configure –prefix=/usr/local/nagios
[[email protected]
nrpe-2.15]# make all
[[email protected]
nrpe-2.15]# make install-plugin
[[email protected]
nrpe-2.15]# make install-daemon
[[email protected]
nrpe-2.15]# make install-daemon-config

# 测试启动
# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d

# 自带了启动脚本
[[email protected]
nrpe-2.15]# cp -rf init-script.in /etc/init.d/nrpe
[[email protected]
nrpe-2.15]# chmod a+x /etc/init.d/nrpe
[[email protected]
~]# /etc/init.d/nrpe start

注:其实nagios获取信息都是靠/usr/local/nagios/libexec/check_nrpe
这个脚本主动获取nrpe服务端信息

五.配置并启动服务

[[email protected]
~]# vi /usr/local/nagios/etc/objects/contacts.cfg
define contact{
        contact_name                    nagiosadmin           
        use                            generic-contact       
        alias                          Nagios Admin           
        email                         
[email protected]
        }

[[email protected]
~]# vi /usr/local/nagios/etc/objects/commands.cfg       
define command{
        command_name    check_nrpe
        command_line    $USER1$/check_nrpe -H “$HOSTADDRESS$” -c
“$ARG1$”
}
       
[[email protected]
~]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

# 检查配置文件是否正确
[[email protected]
~]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

[[email protected]
~]# chkconfig nagios on
[[email protected]
~]# service nagios start

[[email protected]
~]# chkconfig nrpe on
[[email protected]
~]# /etc/init.d/nrpe start

[[email protected]
~]# chkconfig httpd on
[[email protected]
~]# service httpd start
[[email protected]
~]# touch /var/www/html/index.html

六.配置邮件发送

[[email protected]
~]# yum -y install mailx
[[email protected]
~]# echo “mail test” | mail -s test
[email protected]

#如果不配置mail.rc默认会用本地postfix发送邮件
#email send tools
#nano /etc/mail.rc
#set
[email protected]
smtp=smtp.126.com
#set
[email protected]
smtp-auth-password=xxoo
#set smtp-auth=login

ca88手机网页登录 1

ca88手机网页登录 2

CentOS 6.7
安装Nagios教程

参考文档:

1. nagios安装

Nagios是一款开源的免费网络监视工具,能有效监控Windows、Linux和Unix的主机状态,交换机路由器等网络设置,打印机等。在系统或服务状态异常时发出邮件或短信报警第一时间通知网站运维人员,在状态恢复后发出正常的邮件或短信通知。

————————————–分割线

在Ubuntu下配置Mrtg监控Nginx和服务器系统资源

使用 snmp+Mrtg 监控 Linux 系统

Mrtg服务器搭建(监控网络流量)

网络监控器Nagios全攻略

Nagios搭建与配置详解

Nginx环境下构建Nagios监控平台

在RHEL5.3上配置基本的Nagios系统(使用Nagios-3.1.2)

CentOS 5.5+Nginx+Nagios监控端和被控端安装配置指南

Ubuntu 13.10 Server 安装 Nagios Core 网络监控运用

一.安装依赖包

# wget

# tar zxvf nagios-3.2.2.tar.gz
# cd nagios-3.2.2
# useradd -m -s /bin/bash nagios
# groupadd nagios
# usermod -G nagios nagios
# groupadd nagcmd
# usermod -a -G nagcmd nagios
# usermod -a -G nagcmd www
# ./configure –prefix=/data/nagios –with-command-group=nagcmd
# make
# make all
# make install
# make install-init     # 生成init启动脚本
# make install-config     # 安装示例配置文件
# make install-commandmode     # 设置相应的目录权限

  1. nagios安装
    # wget

    # tar zxvf nagios-3.2.2.tar.gz
    # cd nagios-3.2.2
    # useradd -m -s /bin/bash nagios
    # groupadd nagios
    # usermod -G nagios nagios
    # groupadd nagcmd
    # usermod -a -G nagcmd nagios
    # usermod -a -G nagcmd www
    # ./configure –prefix=/usr/local/nagios –with-command-group=nagcmd
    # make
    # make all
    # make install
    # make install-init    # 生成init启动脚本
    # make install-config    # 安装示例配置文件
    # make install-commandmode    # 设置相应的目录权限
     
  2. nagiox插件安装
    # wget

    # tar zxvf nagios-plugins-1.4.15.tar.gz
    # cd nagios-plugins-1.4.15
    # ./configure –with-nagios-user=nagios –with-nagios-group=nagios
    –prefix=/usr/local/nagios
    # make
    # make install
     
  3. nrpe安装
    # apt-get install libssl-dev
    # wget

    # tar zxvf nrpe-2.12.tar.gz
    # cd nrpe-2.12
    # ./configure
    # make all
    # cp src/check_nrpe /usr/local/nagios/libexec/
     
    4.安装配置Nginx
    #sudo apt-get install nginx php5-fpm libssl-dev fcgiwrap apache2
    # htpasswd -c -m /usr/local/nagios/etc/nagiosAdmin.net nagiosadmin
    # 启动服务
    # /etc/init.d/php5-fpm start
    # /etc/init.d/fcgiwrap start       
    #默认是socket模式,socket文件在/var/run/fcgiwrap.socket
    # /etc/init.d/nagios start
    # /etc/init.d/nginx start

————————————–分割线

Nagios 的详细介绍:请点这里
Nagios 的下载地址:请点这里

本文永久更新链接地址:

6.7 安装Nagios教程 CentOS 6.7
安装Nagios教程
参考文档:
一.安装依赖包…

[root@Nagios ~]# yum install -y httpd php
[root@Nagios ~]# yum install -y gcc glibc glibc-common
[root@Nagios ~]# yum install -y gd gd-devel
[root@Nagios ~]# yum install -y perl ntp unzip
[root@Nagios ~]# yum install -y openssl-devel

2. nagiox插件安装

nagios的完整WEB配置

[root@Nagios ~]# /etc/init.d/ntpd start
[root@Nagios ~]# chkconfig ntpd on

# wget

# tar zxvf nagios-plugins-1.4.15.tar.gz
# cd nagios-plugins-1.4.15
# ./configure –with-nagios-user=nagios –with-nagios-group=nagios
–prefix=/data/nagios
# make
# make install

  1.     server {   
  2.     listen          80;   
  3.     server_name     1.1.1.2;   
  4.     root            /usr/local/nagios/share;   
  5.    
    index index.html index.htm index.php default.html default.htm default.php; 
     
  6.    
  7.     location ~ .*\.php?$ {   
  8.             fastcgi_pass    127.0.0.1:9000;   
  9.             fastcgi_index   index.php;   
  10.             include fastcgi_params;   
  11.            
    fastcgi_param SCRIPT_FILENAME /usr/local/nagios/share$fastcgi_script_name; 
     
  12.             auth_basic      “nagios admin”;   
  13.             auth_basic_user_file   
    /usr/local/nagios/etc/nagiosAdmin.net;   
  14.      }   
  15.     location ~ .*\.cgi$ {   
  16.             root    /usr/local/nagios/sbin;   
  17.             rewrite ^/nagios/cgi-bin/(.*)\.cgi /$1.cgi break;   
  18.             fastcgi_pass unix:/var/run/fcgiwrap.socket;   
  19.             fastcgi_index index.cgi;   
  20.            
    fastcgi_param SCRIPT_FILENAME /usr/local/nagios/sbin$fastcgi_script_name; 
     
  21.             include fastcgi_params;   
  22.             auth_basic      “nagios admin”;   
  23.             auth_basic_user_file   
    /usr/local/nagios/etc/nagiosAdmin.net;   
  24.    
  25.     }   
  26.     location /nagios {   
  27.             alias /usr/local/nagios/share;   
  28.             auth_basic      “nagios admin”;   
  29.             auth_basic_user_file   
    /usr/local/nagios/etc/nagiosAdmin.net;   
  30.    
  31.     }   
  32.     location ~ .*\.pl$ {   
  33.             fastcgi_pass  unix:/var/run/fcgiwrap.socket;   
  34.             fastcgi_index index.pl;   
  35.             fastcgi_param SCRIPT_FILENAME 
    /usr/local/nagios/sbin$fastcgi_script_name;   
  36.             include fastcgi_params;   
  37.     }   
  38. }   

[root@Nagios ~]# /usr/sbin/useradd -m nagios
[root@Nagios ~]# passwd nagios

3. nrpe安装

ca88手机网页登录 3

[root@Nagios ~]# /usr/sbin/groupadd nagcmd
[root@Nagios ~]# /usr/sbin/usermod -a -G nagcmd nagios
[root@Nagios ~]# /usr/sbin/usermod -a -G nagcmd apache
[root@Nagios ~]# id nagios
uid=500(nagios) gid=500(nagios) groups=500(nagios),501(nagcmd)
[root@Nagios ~]# id apache
uid=48(apache) gid=48(apache) groups=48(apache),501(nagcmd)

# tar zxvf nrpe-2.12.tar.gz
# cd nrpe-2.12
# ./configure
# make all
# cp src/check_nrpe /data/nagios/libexec/

二.nagios的安装

4. 配置
# 加入系统服务并设为开机自动
# chkconfig –add nagios
# chkconfig nagios on

[root@Nagios ~]# cd /usr/local/src
[root@Nagios src]# wget

[root@Nagios src]# wget

[root@Nagios src]# tar zxvf nagios-4.1.1.tar.gz
[root@Nagios src]# cd nagios-4.1.1
[root@Nagios nagios-4.1.1]# ./configure –prefix=/usr/local/nagios
–with-comand-group=nagcmd
[root@Nagios nagios-4.1.1]# make all
[root@Nagios nagios-4.1.1]# make install
[root@Nagios nagios-4.1.1]# make install-init
[root@Nagios nagios-4.1.1]# make install-config
[root@Nagios nagios-4.1.1]# make install-commandmode
[root@Nagios nagios-4.1.1]# make install-webconf
[root@Nagios nagios-4.1.1]# cp -rf contrib/eventhandlers
/usr/local/nagios/libexec/
[root@Nagios nagios-4.1.1]# chown -R nagios:nagios
/usr/local/nagios/libexec/eventhandlers

# mkdir /data/nagios/var/rw
# chown nagios.nagios /data/nagios/var/rw

三.nagios plugins的安装

# 测试配置文件可用
# /data/nagios/bin/nagios -v /data/nagios/etc/nagios.cfg

[root@Nagios src]# tar xzf nagios-plugins-2.1.1.tar.gz
[root@Nagios src]# cd nagios-plugins-2.1.1
[root@Nagios nagios-plugins-2.1.1]# ./configure
–prefix=/usr/local/nagios –with-nagios-user=nagios
–with-nagios-group=nagios
[root@Nagios nagios-plugins-2.1.1]# make && make install

# 取消用户认证(方便调试)
# vi /data/nagios/etc/cgi.cfg
找到use_authentication=1并把值改为0

四.nrpe插件安装

# 修改联系人邮箱
# vi /data/nagios/etc/objects/contacts.cfg

[root@Nagios src]# wget

[root@Nagios src]# tar zxf nrpe-2.15.tar.gz
[root@Nagios src]# cd nrpe-2.15
[root@Nagios nrpe-2.15]# ./configure –prefix=/usr/local/nagios
[root@Nagios nrpe-2.15]# make all
[root@Nagios nrpe-2.15]# make install-plugin
[root@Nagios nrpe-2.15]# make install-daemon
[root@Nagios nrpe-2.15]# make install-daemon-config

# 定义check_nrpe命令
# vi /data/nagios/etc/objects/commands.cfg

# 测试启动
# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d

define command{
command_name check_nrpe
command_line /data/nagios/libexec/check_nrpe -H $HOSTADDRESS$ -c
$ARG1$
}

# 自带了启动脚本
[root@Nagios nrpe-2.15]# cp -rf init-script.in /etc/init.d/nrpe
[root@Nagios nrpe-2.15]# chmod a+x /etc/init.d/nrpe
[root@Nagios ~]# /etc/init.d/nrpe start

# 启动服务
# service nagios start

注:其实nagios获取信息都是靠/usr/local/nagios/libexec/check_nrpe
这个脚本主动获取nrpe服务端信息

  1. nginx 配置
    Nginx 的 cgi 支持参见 Nginx fastcgi perl (pl、cgi)支持
    http://www.linuxidc.com/Linux/2011-09/44019.htm

五.配置并启动服务

server {
    listen       88;
    server_name  _;

[root@Nagios ~]# vi /usr/local/nagios/etc/objects/contacts.cfg
define contact{
        contact_name                    nagiosadmin           
        use                            generic-contact       
        alias                          Nagios Admin           
        email                          ca0gu0@126.com
        }

    location / {
        root   /data/nagios/share;
        index  index.html index.htm index.php;
    }

[root@Nagios ~]# vi /usr/local/nagios/etc/objects/commands.cfg     
 
define command{
        command_name    check_nrpe
        command_line    $USER1$/check_nrpe -H “$HOSTADDRESS$” -c
“$ARG1$”
}
       
[root@Nagios ~]# htpasswd -c /usr/local/nagios/etc/htpasswd.users
nagiosadmin

    location ~ .*\.(php|php5)?$
    {
      root /data/nagios/share;
      fastcgi_pass  127.0.0.1:9000;
      fastcgi_index index.php;
      include fcgi.conf;
    }

# 检查配置文件是否正确
[root@Nagios ~]# /usr/local/nagios/bin/nagios -v
/usr/local/nagios/etc/nagios.cfg

    location /nagios {
        alias /data/nagios/share;
    }

[root@Nagios ~]# chkconfig nagios on
[root@Nagios ~]# service nagios start

    location /cgi-bin/images {
        alias /data/nagios/share/images;
    }

[root@Nagios ~]# chkconfig nrpe on
[root@Nagios ~]# /etc/init.d/nrpe start

    location /cgi-bin/stylesheets {
        alias /data/nagios/share/stylesheets;
    }

[root@Nagios ~]# chkconfig httpd on
[root@Nagios ~]# service httpd start
[root@Nagios ~]# touch /var/www/html/index.html

    location /cgi-bin {
        alias /data/nagios/sbin;
    }

六.配置邮件发送

    location ~ .*\.(cgi|pl)?$
    {
      gzip off;
      root   /data/nagios/sbin;
      rewrite ^/nagios/cgi-bin/(.*)\.cgi /$1.cgi break;
      fastcgi_pass  unix:/data/nginx/logs/perl-fcgi.sock;
      fastcgi_index index.cgi;
      include fcgi.conf;
      fastcgi_read_timeout   60;
    }
}

[root@Nagios ~]# yum -y install mailx
[root@Nagios ~]# echo “mail test” | mail -s test ca0gu0@126.com

ca88手机网页登录 4

#如果不配置mail.rc默认会用本地postfix发送邮件
#email send tools
#nano /etc/mail.rc
#set from=s0lence@126.com smtp=smtp.126.com
#set smtp-auth-user=xx@oo smtp-auth-password=xxoo
#set smtp-auth=login

ca88手机网页登录 5

ca88手机网页登录 6

————————————–分割线

在Ubuntu下配置Mrtg监控Nginx和服务器系统资源
http://www.linuxidc.com/Linux/2013-08/88417.htm

使用 snmp+Mrtg 监控 Linux 系统
http://www.linuxidc.com/Linux/2012-11/73561.htm

Mrtg服务器搭建(监控网络流量)
http://www.linuxidc.com/Linux/2012-07/64315.htm

网络监控器Nagios全攻略
http://www.linuxidc.com/Linux/2013-07/87067.htm

Nagios搭建与配置详解
http://www.linuxidc.com/Linux/2013-05/84848.htm

Nginx环境下构建Nagios监控平台
http://www.linuxidc.com/Linux/2011-07/38112.htm

在RHEL5.3上配置基本的Nagios系统(使用Nagios-3.1.2)
http://www.linuxidc.com/Linux/2011-07/38129.htm

CentOS 5.5+Nginx+Nagios监控端和被控端安装配置指南
http://www.linuxidc.com/Linux/2011-09/44018.htm

Ubuntu 13.10 Server 安装 Nagios Core 网络监控运用
http://www.linuxidc.com/Linux/2013-11/93047.htm

————————————–分割线

Nagios
的详细介绍
:请点这里
Nagios
的下载地址
:请点这里

本文永久更新链接地址:http://www.linuxidc.com/Linux/2015-11/125427.htm

ca88手机网页登录 7

发表评论

电子邮件地址不会被公开。 必填项已用*标注