监控软件nagios之配置文件详解
1.nagios根目录
[root@tong1 nagios-4.0.8]# ll
total 28
drwxrwxr-x. 2 nagios nagios 4096 Apr 1 14:50 bin --二进制文件
drwxrwxr-x. 3 nagios nagios 4096 Apr 1 15:27 etc --配置文件
drwxr-xr-x. 2 root root 4096 Apr 1 15:23 include --包含文件
drwxrwxr-x. 2 nagios nagios 4096 Apr 1 15:23 libexec --插件文件
drwxrwxr-x. 2 nagios nagios 4096 Apr 1 15:03 sbin --cgi文件
drwxrwxr-x. 11 nagios nagios 4096 Apr 1 15:23 share --网页文件和文档
drwxrwxr-x. 5 nagios nagios 4096 Apr 1 15:34 var --锁文件和日志文件
[root@tong1 nagios-4.0.8]#
2.templates.cfg配置文件(定义监控中重复的参数)
[root@tong1 nagios-4.0.8]# cd etc/
[root@tong1 etc]# ll
total 68
-rw-rw-r--. 1 nagios nagios 12027 Apr 1 14:53 cgi.cfg --cgi配置文件
-rw-r--r--. 1 nagios ngios 19 Apr 1 14:52 htpasswd --认证文件
-rw-rw-r--. 1 nagios nagios 44637 Apr 1 14:50 nagios.cfg --主配置文件
drwxrwxr-x. 2 nagios nagios 4096 Apr 1 15:27 objects --主机定义文件
-rw-rw----. 1 nagios nagios 1324 Apr 1 14:50 resource.cfg --资源管理文件
[root@tong1 etc]# ll objects/
total 48
-rw-rw-r--. 1 nagios nagios 7700 Apr 1 14:50 commands.cfg --定义命令文件
-rw-rw-r--. 1 nagios nagios 2138 Apr 1 14:50 contacts.cfg --定义联系人和联系人组
-rw-rw-r--. 1 nagios nagios 5375 Apr 1 14:50 localhost.cfg --本地主机的监控文件
-rw-rw-r--. 1 nagios nagios 3096 Apr 1 14:50 printer.cfg --监控打印文件模板
-rw-rw-r--. 1 nagios nagios 3265 Apr 1 14:50 switch.cfg --监控交换机文件模板
-rw-rw-r--. 1 nagios nagios 10621 Apr 1 14:50 templates.cfg --作为资源引用文件
-rw-rw-r--. 1 nagios nagios 3180 Apr 1 14:50 timeperiods.cfg --定义监控时间段
-rw-rw-r--. 1 nagios nagios 3991 Apr 1 14:50 windows.cfg --监控windows主机模板[root@tong1 etc]# cd objects/
[root@tong1 objects]# vim templates.cfg --此文件是固定的,是所有文件中的相同配置(定义后可以不在其它配置文件中定义了)
define contact{
name generic-contact --定义 联系人
service_notification_period 24x7 --服务出现异常通知联系人
host_notification_period 24x7 --主机出现异常通知联系人
service_notification_options w,u,c,r,f,s --服务器级别,w即warn表示警告状态,u即unknown,表示不明状态,c即criticle表示紧急状态,r即recover,表示恢复态
host_notification_options d,u,r,f,s --主机故障级别
service_notification_commands notify-service-by-email --服务发现故障用邮件报警(notify-service-by-email在commands.cfg文件中定义)
host_notification_commands notify-host-by-email --主机发现故障用邮件报警
register 0
}
define host{
name generic-host --主机名,不是真实主机名,是在nagios页面显示的主机名
notifications_enabled 1
event_handler_enabled 1
flap_detection_enabled 1
process_perf_data 1
retain_status_information 1
retain_nonstatus_information 1
notification_period 24x7
register 0
}
define host{
name linux-server --监控linux主机
use generic-host --引用其它主机的配置
check_period 24x7 --监控主机的时间段
check_interval 5 --检查时间间隔
retry_interval 1 --重试检查时间间隔
max_check_attempts 10 --检查多少次才认为是宕机
check_command check-host-alive --检查主机状态的命令(check-host-alive在commands.cfg文件中定义)
notification_period 24X7 --主机故障时报警时间
notification_interval 120 --当主机一直故障每隔120分钟发送一次报警
notification_options d,u,r --定义主机在什么状态时被定为宕机
contact_groups admins --指定联系人组
register 0
}
define host{
name windows-server --监控windows主机
use generic-host
check_period 24x7
check_interval 5
retry_interval 1
max_check_attempts 10
check_command check-host-alive
notification_period 24x7
notification_interval 30
notification_options d,r
contact_groups admins
hostgroups windows-servers
register 0
}
define host{
name generic-printer --监控打印
use generic-host
check_period 24x7
check_interval 5
retry_interval 1
max_check_attempts 10
check_command check-host-alive
notification_period workhours
notification_interval 30
notification_options d,r
contact_groups admins
register 0
}
define host{
name generic-switch --监控交换机
use generic-host
check_period 24x7
check_interval 5
retry_interval 1
max_check_attempts 10
check_command check-host-alive
notification_period 24x7
notification_interval 30
notification_options d,r
contact_groups admins
register 0
}
define service{
name generic-service --监控服务
active_checks_enabled 1
passive_checks_enabled 1
parallelize_check 1
obsess_over_service 1
check_freshness 0
notifications_enabled 1
event_handler_enabled 1
flap_detection_enabled 1
process_perf_data 1
retain_status_information 1
retain_nonstatus_information 1
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 10
retry_check_interval 2
contact_groups admins
notification_options w,u,c,r
notification_interval 60
notification_period 24x7
register 0
}
3.resource.cfg配置文件(变量定义文件)
[root@tong1 objects]# vim ../resource.cfg
$USER1$=/usr/local/nagios-4.0.8/libexec --插件的路径
4.commands.cfg配置文件(加入新的监控命令)
[root@tong1 objects]# vim commands.cfg
define command{
command_name check_local_disk --定义命令名
command_line $USER1$/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$ --监控脚本
}
5.host.cfg配置文件(默认不存在,被监控主机地址和信息)
[root@tong1 objects]# vim host.cfg
define host {
use linux-server #引用主机linux-server的属性信息,linux-server主机在templates.cfg文件中进行了定义.
host_name Nagios-Linux #主机名
alias Nagios-Linux #主机别名
address 192.168.1.111 #被监控的主机地址,这个地址可以是ip,也可以是域名.
}
#定义一个主机组
define hostgroup {
hostgroup_name bsmart-servers #主机组名称,可以随意指定.
alias bsmart servers #主机组别名
members Nagios-Linux #主机组成员,其中“Nagios-Linux”就是上面定义的主机
}
6.services.cfg配置文件(默认不存在,主要定义主机资源和服务)
[root@tong1 objects]# vim services.cfg
define service {
use local-service #引用local-service服务的属性值,local-service在templates.cfg文件中进行了定义.
host_name Nagios-Linux #指定要监控哪个主机上的服务,“Nagios-Server”在hosts.cfg文件中进行了定义.
service_description check-host-alive #对监控服务内容的描述,以供维护人员参考.
check_command check-host-alive #指定检查的命令.
}
7.contacts.cfg配置文件(定义联系人和联系组)
[root@tong1 objects]# vim contacts.cfg
define contact {
contact_name David #联系人的名称,这个地方不要有空格
use generic-contact #引用generic-contact的属性信息,其中“generic-contact”在templates.cfg文件中进行定义
alias Nagios Admin email david.tang@bsmart.cn
}
define contactgroup{
contactgroup_name ts #联系人组的名称,同样不能空格
alias Technical Support #联系人组描述
members David #联系人组成员,其中“david”就是上面定义的联系人,如果有多个联系人则以逗号相隔
}
8.timeperiods.cfg配置文件(定义监控时间段)
[root@tong1 objects]# vim timeperiods.cfg
define timeperiod{
timeperiod_name 24x7
alias 24 Hours A Day, 7 Days A Week
sunday 00:00-24:00
monday 00:00-24:00
tuesday 00:00-24:00
wednesday 00:00-24:00
thursday 00:00-24:00
friday 00:00-24:00
saturday 00:00-24:00
}
# 'workhours' timeperiod definition
define timeperiod{
timeperiod_name workhours
alias Normal Work Hours
monday 09:00-17:00
tuesday 09:00-17:00
wednesday 09:00-17:00
thursday 09:00-17:00
friday 09:00-17:00
}
9.nagios.cfg配置文件(核心配置文件,所有的配置文件必须要在这个配置文件中引用进来)
[root@tong1 objects]# vim ../nagios.cfg
cfg_file=/usr/local/nagios-4.0.8/etc/objects/commands.cfg
cfg_file=/usr/local/nagios-4.0.8/etc/objects/contacts.cfg
cfg_file=/usr/local/nagios-4.0.8/etc/objects/timeperiods.cfg
cfg_file=/usr/local/nagios-4.0.8/etc/objects/templates.cfg
10.检查配置文件是否有异常
[root@tong1 objects]# /usr/local/nagios-4.0.8/bin/nagios -v /usr/local/nagios-4.0.8/etc/objects/localhost.cfg
转载于:https://blog.51cto.com/tongcheng/1627349
监控软件nagios之配置文件详解相关推荐
- Nagios服务器端配置文件详解
Nagios服务器端配置文件详解 Nagios服务器端安装部署详解见:http://www.cnblogs.com/ginvip/p/6505948.html Nagios 主要用于监控一台或者多台本 ...
- Destoon源数据库配置文件在哪_数据库监控软件Lepus安装部署详解
Lepus安装部署 一.软件介绍 Lepus是一套开源的数据库监控平台,目前已经支持MySQL.Oracle.SQLServer.MongoDB.Redis等数据库的基本监控和告警(MySQL已经支持 ...
- Nagios配置文件详解
1. 概述 2. 配置文件 3. 主配置文件nagios.cfg详解 3.1 Log File 3.2 Object Configuration File 3.3 Object Configurati ...
- AndroidManifest.xml配置文件详解
AndroidManifest.xml配置文件详解 . AndroidManifest.xml配置文件对于Android应用开发来说是非常重要的基础知识,本文旨在总结该配置文件中重点的用法,以便日后查 ...
- HAProxy介绍及配置文件详解
一.HAProxy简介 HAProxy是一个开源的.高性能的.基于TCP和HTTP应用的负载均衡软件,借助HAProxy可快速.可靠地提供基于TCP和HTTP应用的负载均衡解决方案 二.HAProxy ...
- Keepalived配置文件详解
keepalived keepalived是集群管理中保证集群高可用的一个服务软件,其功能类似于heartbeat,用来防止单点故障. keepalived工作原理 keepalived是以VRRP( ...
- keepalived安装及配置文件详解
一.安装Keepalived服务 两种安装方式: (1)yum方式安装 yum -y install keepalived# 查看安装路径 rpm -ql keepalived (2)源码安装 1)安 ...
- nagios配置过程详解
一.nagios配置过程详解 1.nagios默认配置文件介绍 nagios安装完毕后,默认的配置文件在/usr/local/nagios/etc目录下,每个文件或目录含义如下表所示: 2.配置文件 ...
- zabbix如何监控oracle,使用zabbix监控oracle数据库的方法详解
一.概述 zabbix是一款非常强大,同时也是应用最为广泛的开源监控软件,本文将给大家介绍如何利用zabbix+python监控oracle数据库. 二.环境介绍 以下是我安装的环境,实际部署时并不需 ...
最新文章
- 一次SQL查询优化原理分析(900W+数据,从17s到300ms)
- echart(2),模拟数据导入篇
- mysql触发器错误信息_MySQL 触发器错误_MySQL
- JQuery移除事件
- “举报”阿里巴巴 Arthas,大幅降低 OOM Trouble shooting 门槛
- GDCM:读取显式长度SQIVR的测试程序
- javaweb连接不上mysql怎么办_java web应用连接mysql会突然connection连接失败
- 前端学习(1703):前端系列javascript之问题解答
- 【转】2.2[译]async/await中阻塞死锁
- caj文件浏览器_知网上PDF文件下载的问题怎么解决?
- 面试题10-二进制中1的个数
- 机器学习基础(三十四)—— 协同过滤(之获得推荐)
- 2021年全球与中国孕妇防辐射服行业市场规模及发展前景分析
- 一些计算机u口无法使用的原因,电脑USB接口不能用的原因大全
- 服务器系统咋关机呀,服务器关机详细步骤
- NET 2.0(C#)调用ffmpeg处理视频的方法(转载)
- PC端微信登录实现流程
- kswapd和pdflush
- 网络基本功(二十四):Wireshark抓包实例分析TCP重传
- 经商要看《大染坊》,做人要学陈寿亭
热门文章
- 不只是华为/阿里/百度/小米/京东,AIoT已然成为资本与新兴企业都认可的赚钱方向...
- 5G 产业链重要投资节点
- 科学:揭示自由意志的生物学本质
- Nature:科学家成功解读大脑构建的分子机制
- CB Insights发布2017全球AI企业100强,出门问问、碳云智能入选
- 国内首家!携程每周两天可在家“躺平”,76% 的员工主动报名
- 八大操作系统掌门人齐聚 1024 程序员节,千年岳麓见证开源新时代
- 用程序消除一道概率题的二义性
- iOS实录15:浅谈iOS Crash
- Oracle优化之表连接方式