【移动应用开发技术】Nagios监控系统安装和配置_第1页
【移动应用开发技术】Nagios监控系统安装和配置_第2页
【移动应用开发技术】Nagios监控系统安装和配置_第3页
【移动应用开发技术】Nagios监控系统安装和配置_第4页
【移动应用开发技术】Nagios监控系统安装和配置_第5页
已阅读5页,还剩6页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

【移动应用开发技术】Nagios监控系统安装和配置

Nagios是一款企业级开源免费的监控工具,其关注点在于保证服务的正常运行,并且在服务发生问题时提供报警机制。Nagios服务端:33Nagios监控端:web1(.235)

web2(36)1)

安装nagios依赖软件包通过yum方式快速安装Nagios所需的依赖软件包yum

-y

install

gd

gd-devel

openssl

openssl-devel

httpd

php

gcc

glibc

glibc-common

make

net-snmp

wget2)

创建nagios账户与组配置时使用--with-nagios-user和--with-nagios-group指定以该账号的身份运行Nagios。useradd

nagios3)

×××地址Nagios:/project/nagios/nagios-4.x/nagios-4.2.1/nagios-4.2.1.tar.gzNagios-plugin:/download/nagios-plugins-2.1.2.tar.gzNrpe:/project/nagios/nrpe-3.x/nrpe-3.0.1.tar.gz4)

Nagios的安装tar

-zxf

nagios-4.2.1.tar.gz

-C

/usr/local

cd

/usr/local

cd

nagios-4.2.1/

./configure

--with-nagios-user=nagios

--with-nagios-group=nagios

make

all

make

install

#安装主程序,CGI以及HTML文件

make

install-init

#安装启动脚本/etc/init.d/nagios

make

install-commandmode

#安装与配置目录权限

make

install-config

#安装配置文件模板

#

由于nagios最终将以web的形式进行管理与监控,安装过程中使用make

install-webconf命令将生成Apache附加配置文件/etc/httpd/conf.d/nagios.conf

make

install-webconf5)

Nagios插件安装tar

-zxf

nagios-plugins-2.1.2.tar.gz

-C

/usr/local

cd

/usr/local/nagios-plugins-2.1.2/

./configure

--prefix=/usr/local/nagios

make

make

install

tar

-zxf

nrpe-3.0.1.tar.gz

-C

/usr/local/

cd

/usr/local

cd

nrpe-3.0.1/

./configure

--prefix=/usr/local/nagios

make

all

make

install-plugin

make

install-daemon

make

install-daemon-config

chown

nagios:nagios

-R

/usr/local/nagios6)

禁用selinux并关闭防火墙setenforce

0

service

iptables

stop7)

创建web访问账户htpasswd

-c

/usr/local/etc/htpasswd.users

tomcat8)

启动nagios/etc/init.d/httpd

start

/etc/init.d/nagios

start9)

修改nagios配置文件主配置文件:nagios.cfg主配置文件中使用cfg_file配置项加载其他配置文件,为了方便管理,将两台监控主机创建不同的配置文件,35配置文件名为web1.cfg,36配置文件名为web2.cfgvi

/usr/local/nagios/etc/nagios.cfg

cfg_file=/usr/local/nagios/etc/objects/commands.cfg

cfg_file=/usr/local/nagios/etc/objects/contacts.cfg

cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg

cfg_file=/usr/local/nagios/etc/objects/templates.cfg

#

Definitions

for

monitoring

the

local

(Linux)

host

cfg_file=/usr/local/nagios/etc/objects/localhost.cfg

#下面两个配置文件需要手动创建出来,用于监控两台web服务器

cfg_file=/usr/local/nagios/etc/web1.cfg

cfg_file=/usr/local/nagios/etc/web2.cfg

……修改CGI配置文件(cgi.cfg),需要将访问web页面的账号加入进来vi

/usr/local/nagios/etc/cgi.cfg

use_authentication=1

authorized_for_system_information=nagiosadmin,tomcat

authorized_for_configuration_information=nagiosadmin,tomcat

authorized_for_system_commands=nagiosadmin,tomcat

authorized_for_all_services=nagiosadmin,tomcat

authorized_for_all_hosts=nagiosadmin,tomcat

authorized_for_all_service_commands=nagiosadmin,tomcat

authorized_for_all_host_commands=nagiosadmin,tomcat

……修改命令配置文件(commands.cfg),该文件定义具体的命令实现方式,如发送报警邮件具体使用什么工具、邮件内容格式定义。vi

/usr/local/nagios/etc/objects/commands.cfg

……

define

command{

command_name

check-host-alive

command_line

$USER1$/check_ping

-H

$HOSTADDRESS$

-w

3000.0,80%

-c

5000.0,100%

-p

5

}

……

#以下内容需要手动添加,用于进行远程主机监控,需要安装nrpe软件包

define

command{

command_name

check_nrpe

command_line

$USER1$/check_nrpe

-H

$HOSTADDRESS$

-c

$ARG1$

}

修改nrpe配置文件(nrpe.cfg),用于监控远程主机所需要的命令vi

/usr/local/nagios/etc/nrpe.cfg

command[check_users]=/usr/local/nagios/libexec/check_users

-w

5

-c

10

command[check_load]=/usr/local/nagios/libexec/check_load

-w

15,10,5

-c

30,25,20

command[check_hda1]=/usr/local/nagios/libexec/check_disk

-w

20%

-c

10%

-p

/dev/hda1

command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs

-w

5

-c

10

-s

Z

command[check_total_procs]=/usr/local/nagios/libexec/check_procs

-w

150

-c

200

#下面一行为手动添加

command[check_disk]=/usr/local/nagios/libexec/check_disk

-w

20%

-c

10%

……修改监控主机配置文件(localhost.cfg),该文件用于设置如何监控本机服务器资源。vi

/usr/local/nagios/etc/objects/localhost.cfg

……

define

host{

use

linux-server

;

Name

of

host

template

to

use

;

This

host

definition

will

inherit

all

variables

that

are

defined

;

in

(or

inherited

by)

the

linux-server

host

template

definition.

host_name

localhost

alias

localhost

address

}

……

define

hostgroup{

hostgroup_name

linux-servers

;

The

name

of

the

hostgroup

alias

Linux

Servers

;

Long

name

of

the

group

members

localhost

;

Comma

separated

list

of

hosts

that

belong

to

this

group

}

……

创建远程监控配置文件web1.cfg与web2.cfg,用于监控远程服务器系统资源与服务,可以使用localhost.cfg作为参考模板。下面列出web1.cfg的所有内容,web2.cfg

只需要参考web1.cfg的内容修改主机名称、IP地址以及主机名称即可。define

host{

use

linux-server

;

Name

of

host

template

to

use

;

This

host

definition

will

inherit

all

variables

that

are

defined

;

in

(or

inherited

by)

the

linux-server

host

template

definition.

host_name

web1

alias

address

35

}

define

hostgroup{

hostgroup_name

webs

;

The

name

of

the

hostgroup

alias

Linux

Servers

;

Long

name

of

the

group

members

web1

;

Comma

separated

list

of

hosts

that

belong

to

this

group

}

define

service{

use

generic-service

;

Name

of

service

template

to

use

host_name

web1

service_description

PING

check_command

check_ping!100.0,20%!500.0,60%

notifications_enabled

1

}

define

service{

use

generic-service

;

Name

of

service

template

to

use

host_name

web1

service_description

Sys_Load

check_command

check_nrpe!check_load

notifications_enabled

1

}

define

service{

use

generic-service

;

Name

of

service

template

to

use

host_name

web1

service_description

Current

Users

check_command

check_nrpe!check_users

notifications_enabled

1

}

define

service{

use

generic-service

;

Name

of

service

template

to

use

host_name

web1

service_description

Total

Processes

check_command

check_nrpe!check_total_procs

notifications_enabled

1

}

define

service{

use

generic-service

;

Name

of

service

template

to

use

host_name

web1

service_description

SSH

check_command

check_ssh

notifications_enabled

1

}

define

service{

use

generic-service

;

Name

of

service

template

to

use

host_name

web1

service_description

HTTP

check_command

check_http

notifications_enabled

1

}10)

重新加载nagios配置其他配置文件不需修改,可以直接使用,重启nagios,重新加载所有的配置/etc/init.d/nagios

restart下面以web1为例,web2与web1操作一致1)

yum安装nagios插件需依赖的软件包yum

-y

install

openssl

openssl-devel2)

创建nagios用户和组useradd

-s

/sbin/nologin

nagios3)

安装Nagios-plugintar

-zxf

nagios-plugins-2.1.2.tar.gz

-C

/usr/local

cd

/usr/local/

cd

nagios-plugins-2.1.2/

./configure

make

make

install4)

安装Nrpetar

-zxf

nrpe-3.0.1.tar.gz

-C

/usr/local

cd

/usr/local/nrpe-3.0.1/

./configure

make

all

make

install-plugin

make

install-daemon

make

isntall-daemon-config

chown

-R

nagios:nagios

/usr/local/nagios

5)

修改nrpe配置文件cp

/usr/local/nrpe-3.0.1/sample-config/nrpe.cfg

/usr/local/nagios/etc/

vi

/usr/local/nagios/etc/nrpe.cfg

……

allowed_hosts=,33

……

command[check_users]=/usr/local/nagios/libexec/check_users

-w

5

-c

10

command[check_load]=/usr/local/nagios/libexec/check_load

-w

15,10,5

-c

30,25,20

com

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论