Chinaunix首页 | 论坛 | 博客
  • 博客访问: 624269
  • 博文数量: 73
  • 博客积分: 1813
  • 博客等级: 上尉
  • 技术积分: 1213
  • 用 户 组: 普通用户
  • 注册时间: 2009-12-27 19:59
文章分类
文章存档

2013年(1)

2012年(12)

2011年(28)

2010年(31)

2009年(1)

我的朋友

分类: LINUX

2010-07-22 18:35:02

.安装配置被监控端 192.168.0.61 192.168.0.62 。。。

 

1.创建用户nagios (在多台主机上作同样的配置,如果要监控其他服务,可以再作处理)

 

# useradd nagios

 

2.安装nagios-plugins

 

# tar zxvf nagios-plugins-1.4.13.tar.gz

# cd nagios-plugins-1.4.13

# ./configure --prefix=/usr/local/nagios/

# make

# make install

 

# chown -R nagios.nagios /usr/local/nagios 

 

2.安装nrpe,版本与监控端保持一致

 

# tar zxvf nrpe-2.12.tar.gz

# cd nrpe-2.12

# ./configure
#####ubuntu下编译:./configure --with-ssl=/usr/bin/openssl --with-ssl-lib=/usr/lib/i386-linux-gnu/

# make all

# make install-plugin

# make install-daemon

# make install-daemon-config

 

# ll /usr/local/nagios/

total 16

drwxrwxr-x 2 nagios nagios 4096 Jul 21 11:30 bin

drwxrwxr-x 2 nagios nagios 4096 Jul 22 13:40 etc

drwxr-xr-x 2 nagios nagios 4096 Jul 21 11:20 libexec

drwxr-xr-x 3 root   root   4096 Jul 21 11:19 share

 

3.修改配置文件nrpe.cfg

此文件可以从监控端服务器上复制到这里来,因为服务器端都是配置好的文件,我设置的完全一样。

 

# scp 192.168.0.13:/usr/local/nagios/etc/nrpe.cfg /usr/local/nagios/etc/nrpe.cfg

 

#cat /usr/local/nagios/etc/nrpe.cfg | grep allowed_hosts

allowed_hosts=127.0.0.1,192.168.0.13      #此处为监控端服务器IP地址

 

4.启动客户端nrpe

 

# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d

# tail -f /var/log/messages

Jul 22 16:41:16 localhost nrpe[14911]: Starting up daemon

Jul 22 16:41:16 localhost nrpe[14911]: Listening for connections on port 5666

Jul 22 16:41:16 localhost nrpe[14911]: Allowing connections from: 127.0.0.1,192.168.0.13

日志信息出现如上,表明启动成功,测试一下

 

去监控端上测试:

# /usr/local/nagios/libexec/check_nrpe -H 192.168.0.61  一定是在监控端上测试的,而不是在刚安装好的客户端上,自己以前在这里犯

过错!!总是报ssl问题。

NRPE v2.12                     会显示nrpe版本号

 

# /usr/local/nagios/libexec/check_nrpe -H 192.168.0.61 -c check_load

OK - load average: 0.00, 0.00, 0.00|load1=0.000;15.000;30.000;0; load5=0.000;10.000;25.000;0; load15=0.000;5.000;20.000;0;

 

再次成功!

 

.去客户端配置hosts.cfg hostgroups.cfg services.cfg来完成对服务器群的监控

 

192.168.0.13

 

1.配置hosts.cfg

 

# cat hosts.cfg   增加机器

 

define host {

host_name               nagios-server

alias                   nagios server

address                 192.168.0.13

contact_groups          sagroup

check_command           check-host-alive

max_check_attempts      5

notification_interval   10

notification_period     24x7

notification_options    d,u,r

}

 

define host {

host_name               mysql-server-61

alias                   mysql server 61

address                 192.168.0.61

contact_groups          sagroup

check_command           check-host-alive

max_check_attempts      5

notification_interval   10

notification_period     24x7

notification_options    d,u,r

}

 

define host {

host_name               mysql-server-62

alias                   mysql server 62

address                 192.168.0.62

contact_groups          sagroup

check_command           check-host-alive

max_check_attempts      5

notification_interval   10

notification_period     24x7

notification_options    d,u,r

}

 

2.配置hostgroups.cfg

 

# cat hostgroups.cfg

 

define hostgroup {

hostgroup_name  sa-servers

alias           sa servers

members         nagios-server,mysql-server-61,mysql-server-62  #上面提到过这里,把主机成员增加到这里

}

 

3.配置 services.cfg

 

[root@localhost etc]# cat services.cfg

 

##### nagios-server:services.cfg ######

 

define service {

host_name               nagios-server

service_description     check-host-alive

check_period            24x7

max_check_attempts      4

normal_check_interval   3

retry_check_interval    2

contact_groups          sagroup

notification_interval   10

notification_period     24x7

notification_options    w,u,c,r

check_command           check-host-alive

}

 

 

define service {

host_name               nagios-server

service_description     check_tcp 80

check_period            24x7

max_check_attempts      4

normal_check_interval   3

retry_check_interval    2

contact_groups          sagroup

notification_interval   10

notification_period     24x7

notification_options    w,u,c,r

check_command           check_tcp!80

}

 

 

 

define service {

host_name               nagios-server

service_description     check_local_disk

check_period            24x7

max_check_attempts      4

normal_check_interval   3

retry_check_interval    2

contact_groups          sagroup

notification_interval   10

notification_period     24x7

notification_options    w,u,c,r

#check_command          check_local_disk!20%!10%!/

check_command           check_nrpe!check_disk

}

 

 

 

define service {

host_name               nagios-server

service_description     check_load

check_period            24x7

max_check_attempts      4

normal_check_interval   3

retry_check_interval    2

contact_groups          sagroup

notification_interval   10

notification_period     24x7

notification_options    w,u,c,r

check_command           check_nrpe!check_load

}

 

define service {

host_name               nagios-server

service_description     check_total_procs

check_period            24x7

max_check_attempts      4

normal_check_interval   3

retry_check_interval    2

contact_groups          sagroup

notification_interval   10

notification_period     24x7

notification_options    w,u,c,r

check_command           check_nrpe!check_total_procs

}

 

define service {

host_name               nagios-server

service_description     check_users

check_period            24x7

max_check_attempts      4

normal_check_interval   3

retry_check_interval    2

contact_groups          sagroup

notification_interval   10

notification_period     24x7

notification_options    w,u,c,r

check_command           check_nrpe!check_users

}

 

#### mysql-server-61:services.cfg ######

 

define service {

host_name               mysql-server-61

service_description     check_total_procs

check_period            24x7

max_check_attempts      4

normal_check_interval   3

retry_check_interval    2

contact_groups          sagroup

notification_interval   10

notification_period     24x7

notification_options    w,u,c,r

check_command           check_nrpe!check_total_procs

}

 

 

define service {

host_name               mysql-server-61

service_description     check_users

check_period            24x7

max_check_attempts      4

normal_check_interval   3

retry_check_interval    2

contact_groups          sagroup

notification_interval   10

notification_period     24x7

notification_options    w,u,c,r

check_command           check_nrpe!check_users

}

 

define service {

host_name               mysql-server-61

service_description     check_disk_/dev/sda3

check_period            24x7

max_check_attempts      4

normal_check_interval   3

retry_check_interval    2

contact_groups          sagroup

notification_interval   10

notification_period     24x7

notification_options    w,u,c,r

check_command           check_nrpe!check_disk

}

 

define service {

host_name               mysql-server-61

service_description     check_load

check_period            24x7

max_check_attempts      4

normal_check_interval   3

retry_check_interval    2

contact_groups          sagroup

notification_interval   10

notification_period     24x7

notification_options    w,u,c,r

check_command           check_nrpe!check_load

}

 

define service {

host_name               mysql-server-61

service_description     check_swap

check_period            24x7

max_check_attempts      4

normal_check_interval   3

retry_check_interval    2

contact_groups          sagroup

notification_interval   10

notification_period     24x7

notification_options    w,u,c,r

check_command           check_nrpe!check_swap

}

 

#### mysql-server-62:services.cfg #####

 

define service {

host_name               mysql-server-62

service_description     check-host-alive

check_period            24x7

max_check_attempts      4

normal_check_interval   3

retry_check_interval    2

contact_groups          sagroup

notification_interval   10

notification_period     24x7

notification_options    w,u,c,r

check_command           check-host-alive

}

 

 

define service {

host_name               mysql-server-62

service_description     check_users

check_period            24x7

max_check_attempts      4

normal_check_interval   3

retry_check_interval    2

contact_groups          sagroup

notification_interval   10

notification_period     24x7

notification_options    w,u,c,r

check_command           check_nrpe!check_users

}

 

define service {

host_name               mysql-server-62

service_description     check_disk_/dev/sda3

check_period            24x7

max_check_attempts      4

normal_check_interval   3

retry_check_interval    2

contact_groups          sagroup

notification_interval   10

notification_period     24x7

notification_options    w,u,c,r

check_command           check_nrpe!check_disk

}

 

4.完成配置,检测配置。

 

#/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Checking for circular paths between hosts...

Checking for circular host and service dependencies...

Checking global event handlers...

Checking obsessive compulsive processor commands...

Checking misc settings...

 

Total Warnings: 0

Total Errors:   0

 

出现此处,表明,配置文件没有错误,可以启动nagios

 

#service nagios restart  启动成功

 

5.进入web监控界面

 

 

大功告成!!

 

Nagios安装   连载1: http://blog.chinaunix.net/u3/109105/showart.php?id=2255631
Nagios配置   连载2: http://blog.chinaunix.net/u3/109105/showart.php?id=2279011
Nagios被监控端安装配置 连载3
过载3: http://blog.chinaunix.net/u3/109105/showart.php?id=2279015

阅读(1097) | 评论(0) | 转发(1) |
0

上一篇:Nagios配置 连载2

下一篇:mysql的ndb集群

给主人留下些什么吧!~~