ere 发表于 2015-9-8 10:29:57

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_commandcheck_http
notifications_enabled1
}
define service{
use                           generic-service         ; Name of service template to use
host_name                     1921682215
service_description             TCP
check_commandcheck_tcp!80!
notifications_enabled1
}
define service{
use                           generic-service         ; Name of service template to use
host_name                     1921682215
service_description             SNMP
check_commandcheck_snmp!-P 1 -C public -w 1:400 -o .1.3.6.1.2.1.31.1.1.1.18.12
notifications_enabled1
}

  
  关于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 ^ -w $ARG2$ -c $ARG3$
}

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



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

  
页: [1]
查看完整版本: Nagios 常用配置大全