• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
百分百
http://www.qrw100.com
博客园    首页    新随笔    联系   管理    订阅  订阅

Nagios 常用配置大全

以IP:192.168.2.215为例:下面依次罗列了check_ping(网络是否通畅),check_http(WEB服务),check_tcp(TCP端口是否开启),check_snmp(SNMP监控某个参数(根据OID))

define host{
       use                   linux-server
       host_name             1921682215
       alias                 1921682215
       address               192.168.2.215
       }
define service{
        use                             generic-service
        host_name                       1921682215
        process_perf_data               1
        service_description             PING
        check_command                   check_ping!100.0,20%!500.0,60%
        }
define service{
        use                             generic-service         ; Name of service template to use
        host_name                       1921682215
        service_description             HTTP
	check_command			check_http
	notifications_enabled		1
        }
define service{
        use                             generic-service         ; Name of service template to use
        host_name                       1921682215
        service_description             TCP
	check_command			check_tcp!80!
	notifications_enabled		1
        }
define service{
        use                             generic-service         ; Name of service template to use
        host_name                       1921682215
        service_description             SNMP
	check_command			check_snmp!-P 1 -C public -w 1:400 -o .1.3.6.1.2.1.31.1.1.1.18.12
	notifications_enabled		1
        }

 

关于SNMP这个OID对于每种设备还不一样.所以这种方法不怎么好.

Nagios官方网站给我提供了一个解决方案:

 

首先安装

perl -MCPAN -e "install Net::SNMP"

一路默认设置,唯一就是选择时区的时候要自己选一下

安装成功之后

在nagios-snmp-plugins.1.1.1.tgz解压出来的文件夹里执行install.sh.

经过几个设置就安装好了

安装完之后就可以进行配置了.

根据 http://nagios.manubulon.com/index_snmp.html

可以配置"硬盘使用情况","内存使用情况","SNMP服务","服务器环境(网络设备风扇,温度等)"等信息.

以"硬盘使用情况"为例吧.

首先我们需要在commands.cfg添加一条命令

# 'check_snmp_storage" command definition
define command{
        command_name    check_snmp_storage
        command_line    $USER1$/check_snmp_storage.pl -H $HOSTADDRESS$ -C $ARG1$ -m ^[C] -w $ARG2$ -c $ARG3$
        }

 这是监控Windows平台下的C盘的使用状况,其中^[C]表示C盘.
如果是Linux下监控/home可以把^[C]改成/home.
然后在配置文件里面添加一个监控命令:

define service{
        use                             generic-service
        host_name                       1921682215
        service_description             SNMP_Storage
        check_command            check_snmp_storage!public!60!90
        notifications_enabled        1
}

 

posted @ 2011-12-16 13:10  爱尚美  阅读(771)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3