系统环境:
操作系统:CentOS-5.7 x86_64
Apache版本: Apache-2.2.22
Nagios版本: nagios-3.3.1
GD库: gd-2.0.33

2、安装前准备:
2.1、安装GD库

 
1
; html-script: false ]yum install -y gd.x86_64 gd-devel.x86_64

2.2、安装Apache
http://www.ttlsa.com/html/654.html
2.3、下载Nagios,Nagios-plugins,nrpe
官方网站
http://www.nagios.org/download/
截至2012.3.9在官网上的最新版本分别是
版本:nagios-3.3.1

 
1
; html-script: false ]wget http://sourceforge.net/projects/nagios/files/nagios-3.x/nagios-3.3.1/nagios-3.3.1.tar.gz/download

版本:nagios-plugins-1.4.15

 
1
; html-script: false ]wget http://downloads.sourceforge.net/project/nagiosplug/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz?r=http%3A%2F%2Fwww.nagios.org%2Fdownload%2Fplugins%2F&ts=1331283502&use_mirror=ncu

nrpe下载地址http://www.nagios.org/download/addons/
版本:nrpe-2.13

 
1
; html-script: false ]wget http://downloads.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.13/nrpe-2.13.tar.gz?r=http%3A%2F%2Fexchange.nagios.org%2Fdirectory%2FAddons%2FMonitoring-Agents%2FNRPE--2D-Nagios-Remote-Plugin-Executor%2Fdetails&ts=1331283624&use_mirror=nchc

2.4、安装前注意事项:
Nagios,Nagios-plugins,nrpe安装在监控服务器上。
nrpe安装在Linux/Unix被监控端。

3、创建帐号及组
3.1、创建帐号

 
1
2
; html-script: false ]/usr/sbin/useradd -m nagios
passwd nagios

3.2、创建组

 
1
; html-script: false ]/usr/sbin/usermod -a -G nagios nobody

nobody为运行apache的帐号。

4、安装配置nagios
4.1、解压&安装

 
1
2
3
4
5
; html-script: false ]cd /usr/local/src/tarbag/
tar zxvf nagios-3.3.1.tar.gz -C ../software/
cd ../software/nagios/
./configure --prefix=/usr/local/nagios --with-command-group=nagios --with-gd-lib=/usr/lib64/ --with-gd-inc=/usr/lib64/
make all

# 使用make install来安装主程序,CGI和HTML文件

 
1
; html-script: false ]make install

# 使用make install-init在/etc/rc.d/init.d安装启动脚本

 
1
; html-script: false ]make install-init

# 使用make install-cofig来安装示例配置文件,安装的路径是/usr/local/nagios/etc.

 
1
; html-script: false ]make install-config

# 使用make install-commandmode来配置目录权限

 
1
; html-script: false ]make install-commandmode

注:
nagios目录功能的简要说明:
bin Nagios执行程序所在目录,nagios文件即为主程序
etc Nagios配置文件位置
sbin Nagios Cgi文件所在目录,也就是执行外部命令所需文件所在的目录
Share Nagios网页文件所在的目录
var Nagios日志文件、spid 等文件所在的目录
var/archives 日志归档目录
var/rw 用来存放外部命令文件

4.2、配置apache
将下面行加入apache配置文件的alias模块

 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
; html-script: false ]----------------------------------------
ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
 
<Directory "/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.users
   Require valid-user
</Directory>
 
Alias /nagios "/usr/local/nagios/share"
 
<Directory "/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.users
   Require valid-user
</Directory>
----------------------------------------

创建apache目录验证文件

 
1
2
3
4
; html-script: false ]htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password: (输入密码)
Re-type new password: (再输入一次密码)
Adding password for user nagiosadmin

重启apache:

 
1
; html-script: false ]apachectl -k restart

配置nagios配置文件

 
1
; html-script: false ]vi /usr/local/nagios/etc/objects/contacts.cfg

将里面的email地址改为自己的email地址。

5、安装Nagios插件

 
1
2
3
4
5
; html-script: false ]tar zxvf nagios-plugins-1.4.15.tar.gz -C ../software/
cd ../software/nagios-plugins-1.4.15/
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install

6、启动Nagios
配置机器启动时自动启动Nagios

 
1
2
; html-script: false ]chkconfig --add nagios
chkconfig nagios on

检查Nagios配置文件

 
1
; html-script: false ]/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

# 启Nnagios

 
1
; html-script: false ]service nagios start

7、关闭SELinux及防火墙(切勿小视)
7.1、关闭SELinux

 
1
; html-script: false ]vi /etc/selinux/config

将下面行设为disabled

 
1
; html-script: false ]SELINUX=disabled

重启系统即可生效
或者使用setenforce关闭selinux
usage: setenforce [ Enforcing | Permissive | 1 | 0 ]

 
1
; html-script: false ]setenforce 0

这样就可以不用重启系统即可生效了

7.2、关闭防火墙

 
1
2
; html-script: false ]service iptables stop
chkconfig iptables off

如果开启防火墙,应该允许访问apache(一般为80端口)并允许nagios去抓取被监控机信息(一般nrpe为5666端口)。

8、访问Nagios服务器
http://IP/nagios/
输入用户名及密码登录。

9、安装nrpe插件
nrpe是用来监控Linux机器的插件

 
1
2
3
4
; html-script: false ]tar zxvf nrpe-2.13.tar.gz -C ../software/
cd ../software/nrpe-2.13
./configure
make all

在Nagios服务器端只要安装nrpe监控插件就行

 
1
; html-script: false ]make install-plugin

在/usr/local/nagios/etc/objects/commands.cfg中定义check_nrpe命令

 
1
; html-script: false ]vi /usr/local/nagios/etc/objects/commands.cfg

修改配置文件如下

 
 
1
2
3
4
5
6
7
8
9
10
11
; html-script: false ]########################################################################
#
# 2012.03.09 add by Tony
# NRPE COMMAND
#
########################################################################
# 'check_nrpe ' command definition
define command{
        command_name check_nrpe
        command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
        }

nagios服务端安装的更多相关文章

  1. 开源入侵检测系统OSSEC搭建之一:服务端安装

    OSSEC是一款开源的多平台的入侵检测系统,可以运行于Windows, Linux, OpenBSD/FreeBSD, 以及 MacOS等操作系统中.主要功能有日志分析.完整性检查.rootkit检测 ...

  2. svn服务端安装、权限修改以及客户端的使用

    2017-10-1016:10:2 svn服务端安装.权限修改以及客户端的使用 svn服务端.客户端.汉化包下载 http://pan.baidu.com/s/1c1Ogj2C 1.安装服务器端程序( ...

  3. git的CentOS服务端安装和windows客户端的使用

    git的CentOS服务端安装和windows客户端的使用 此教程以 搬瓦工vps CentOS 6 x64 的系统为环境,搭建 git 服务端.windows 7 系统为客户端. git客户端 在W ...

  4. ssr 服务端安装教程

    1 ShadowsocksR 多用户版服务端安装教程(SS-Panel后端) 2 ShadowsocksR 单用户版服务端安装教程

  5. Zabbix 3.4 服务端安装部署

    关于zabbix的安装部署官方也提供了详细的安装文档,链接如下: https://www.zabbix.com/download 选择zabbix的版本,服务器平台及使用的数据库 安装和配置zabbi ...

  6. centos 7 上zabbix 3.0 服务端安装

    zabbix服务端安装 安装完毕mysql-5.6.php5.6 mysql-5.6安装:https://www.cnblogs.com/xzlive/p/9771642.html  创建zabbix ...

  7. 03-openldap服务端安装配置

    openldap服务端安装配置 阅读目录 基础环境准备 安装openldap服务端 初始化openldap配置 启动OpenLDAP 重新生成配置文件信息 规划OpenLDAP目录树组织架构 使用GU ...

  8. 运用Zabbix实现内网服务器状态及局域网状况监控(3) —— Zabbix服务端安装

    1. Zabbix服务端安装,基于LNMP PHP5.5+Nginx1.9安装配置:http://www.cnblogs.com/vurtne-lu/p/7707536.html MySQL5.5编译 ...

  9. NFS相关、NFS服务端安装配置、exportfs命令、nfs客户端的问题

    1.NFS (network file system,基于RPC协议) 2.NFS服务端安装配置安装服务端:yum install nfs-utils rpcbind -y安装客户端:yum inst ...

随机推荐

  1. 在VSCode中使用码云

    在VSCode中使用码云 一.SSH公钥 使用SSH公钥可以让你在你的电脑和码云通讯的时候使用安全连接(Git的Remote要使用SSH地址) 链接 https://gitee.com/profile ...

  2. 【课堂笔记精选】为了能够用“Unity”软件做游戏,我要从最基础的开始复习JavaScript

    [声明]在“随笔”模块,只是知识点,但是在“文章”模块(https://www.cnblogs.com/Robot-DX3906/articles/10579584.html)里面,有更多内容. 20 ...

  3. What is EJB

    What is EJB 0.什么是EJB? 答:EJB是用于构建企业应用程序模块托管的.服务器端组件架构.EJB技术加速并简化了开发基于Java技术的分布式.事务性.安全和便携的应用程序. 先看一下E ...

  4. mysql数据库设置外键,更新与删除选项

    CASCADE:父表delete.update的时候,子表会delete.update掉关联记录:SET NULL:父表delete.update的时候,子表会将关联记录的外键字段所在列设为null, ...

  5. CentOS 7.4使用yum源安装MySQL5.7

    从CentOS 7.0发布以来,yum源中开始使用Mariadb来代替MySQL的安装.即使你输入的是yum install -y mysql , 显示的也是Mariadb的安装内容.使用源代码进行编 ...

  6. spring-mvc.xml的定时器配置

    <!-- 设置时间 --> <bean id="myJobTrigger" class="org.springframework.scheduling. ...

  7. Aizu:2224-Save your cats

    Save your cats Time limit 8000 ms Memory limit 131072 kB Problem Description Nicholas Y. Alford was ...

  8. Snowflake Snow Snowflakes【Poj3349】

    Description You may have heard that no two snowflakes are alike. Your task is to write a program to ...

  9. 【UE4】二十四、UE4内部版本引擎和官方版本引擎版本保持兼容的方法

    内部使用的引擎和官方正式发布的引擎版本号不一致,这种情况会导致一些插件由于版本不一致无法使用,有其是在没有插件源码的情况下.解决方法为 修改Engine\Source\Runtime\Launch\R ...

  10. 进入saftmode解决方案

    Name node is in safe mode.The reported blocks 356 needs additional 2 blocks to reach the threshold 0 ...