nagios监控之(监控配置)
打开上一章:nagios监控之(运行环境搭建)
PS: 上一张已经把nagios的基本环境搭建完成,并能成功浏览nagios页面
现在讲下nagios配置文件
配置文件 放在nagios/etc下面
cgi.cfg 控制CGI访问的配置文件
nagios.cfg nagios主配置文件
resource.cfg 变量定义文件,这个一般不做修改。
/etc/objects/ 这是存放配置文件模板的目录,定义 要监控的对象和相关信息的配置文件
objects/commands.cfg 定义监控某个功能所使用的命令的配置文件。
objects/contacts.cfg 定义常用联系人和联系组的配置文件
objects/localhost.cfg 定义本地主机的配置文件
objects/templates.cfg 定义主机和服务的一个模板
objects/timeperiods.cfg 定义监控时间段的配置文件
还有printer.cfg switch.cfg windows.cfg 这几个默认不启动的配置文件,不做介绍了。
等了解了naigos 的配置文件之间的关系,自己就可以随意添加项要监控的内容了。
配置文件之间的关系
nagios 这些配置文件 之间存在很多相互引用,因为相互引用这样,使得nagios 的管理更加方便,但是 对于 刚刚接触nagios的朋友来说,反而显得 关系很混乱,但是只要把关系弄清楚,就算是熟练掌握了nagios了
配置nagios
(1)templates.cfg文件
define contact{
name generic-contact 定义联系人名称
service_notification_period 24
#定义出现服务异常时,发送通知的时间段,24在timeperiods.cfg定义的,这24参数也算引用
host_notification_period 24
#定义出现主机异常时,发送通知的时间段,24在timeperiods.cfg定义的
service_notification_options w,u,c,r
#定义通知可以被发错的情况,w表示警告warn,u表示不明unknown
#c表示紧急criticle,r表示恢复recover
host_notification_options d,u,r
#d:宕机 u:不可到达状态 r:恢复状态
service_notification_commands notify-service-by-email
#服务故障时,通过email方式进行通知,notify-service-by-email 在commands.cfg中定义的
host_notification_commands notify-host-by-email
#主机故障时,通过email方式进行通知,notify-host-by-email在commands.cfg中定义的
register 0
}
define host{
name generic-host 定义主机模板的名称,不是电脑的主机名,只针对这个define host模板
notifications_enabled 1
event_handler_enabled 1
flap_detection_enabled 1
failure_prediction_enabled 1
process_perf_data 1 开启数据传输功能,后面将用到
retain_status_information 1
retain_nonstatus_information 1
notification_period 24
register 0
}
define host{
name linux-server 定义这个主机模板的名称,每个模板 里面的属性不一样,不要闹混了。
use generic-host 引用generic-host这个主机的属性,到当前主机当中,use表示引用
check_period 24 表示检查主机的时间段
check_interval 5 表示检查主机的时间间隔 这里是5分钟
retry_interval 1 第一次检查失败时,重试检查间隔 这里是1分钟
max_check_attempts 10 主机出现异常时,会尝试10次检查,再最后判断是否真正的出现异常
check_command check-host-alive 指定检查主机状态的命令,在commands.cfg中定义的
notification_period 24 主机故障时,发送通知的时间范围,在timeperiods.cfg中定义的
notification_interval 120 表示异常后,间隔120分钟进行第二次通知,若为0 表示只进行1次通知
notification_options d,u,r 定义 主机在什么状态下会发送通知d:宕机 u:不可到达 r:恢复状态
contact_groups admins 指定联系人组 这个admin 在contacts.cfg文件中定义的
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
failure_prediction_enabled 1
process_perf_data 1
retain_status_information 1
retain_nonstatus_information 1
is_volatile 0
check_period 24
max_check_attempts 3 指定了nagios对服务的最大检查次数
normal_check_interval 10 设置服务检查时间间隔
retry_check_interval 2 重试检查时间间隔,这里是2分钟
contact_groups admins 指定联系人组
notification_options w,u,c,r
notification_interval 60
notification_period 24
register 0
}
define service{
name local-service
use generic-service
max_check_attempts 2
normal_check_interval 5
retry_check_interval 1
register 0
}
(2)resource.cfg 定义nagios的变量文件 文件内容 只用到了一行
$USER1$=/usr/local/nagios/libexec
不用解释相信大家也明白这句意思了。
(3)commands.cfg
以chkec_ping 为例:
define command{
command_name check_ping
command_line $USER1$/check_ping -H $HOSTADDRESS$ -W $ARG1$ -C $ARG2$ -P 5
}
nagios服务运行后 就会检查ping 如果能ping通 代表机器运行正常,仅此而已
里面有很多命令 ,把自己不需要的注释掉,自定义项添加的 可以根据里面的格式自己编辑
(4)host.cfg文件,次文件默认不存在,需要自己创建。里面是被监控主机的属性。
define host{
use linux-server 引用linux-server的属性到当前主机里
host_name web 定义被监控的主机名
alias yanzhe-web 主机别名 nagios浏览器显示的就是主机别名
address 192.168.1.101 被监控的主机IP地址,也可以是域名
}
define host{
use linux-server
host_name mysql
alias yanzhe-mysql
address 192.168.1.102
}
define hostgroup{ 定义一个主机组
hostgroup_name sa-servers 主机组名称
alias sa servers 主机组的别名
members web,mysql 组包括的成员
}
(5)services.cfg文件 进行定义了都对主机进行 那些监控服务,用什么命令。
define service{
use local-service 引用local-service服务的属性。
host_name web 监控web主机上的服务 web在hosts.cfg中定义的。
service_description PING 监控服务的内容 。
check_command check_ping!100.0,20%!500.0,60% 指定检查的命令 check_ping在commands.cfg中进行的定义,后跟两个参数 命令与参数之间用!分割开。
}
define service{
use local-service
host_name web
service_description SSH
check_command check_ssh
}
define service{
use local-service
host_name web
service_description SSHD
check_command check_tcp!22
}
define service{
use local-service
host_name web
service_description http
check_command check_http
}
#******************************mysql*****************************
define service{
use local-service
host_name mysql
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
define service{
use local-service
host_name mysql
service_description SSH
check_command check_ssh
}
define service{
use local-service
host_name mysql
service_description ftp
check_command check_ftp
}
define service{
use local-service
host_name mysql
service_description mysqlport
check_command check_tcp!3306
}
(6)contacts.cfg 文件 定义联系人和联系组的,出现故障后,通过email或者短信发送给谁。
define contact{
contact_name sasystem 定义联系人的名称
use generic-contact 引用generic-contact的属性
alias sa-system 联系人别名
email 13406351516@139.com 用139邮箱 手机也可以收到短信,但比直接用短信通知慢一些
}
define contactgroup{
contactgroup_name admins 定义联系人组名称
alias system administrator group 联系人组的描述
members sasystem 就是上面定义的联系人。
}
(7)timeperiods.cfg文件 定义监控时间段。
define timeperiod{
timeperiod_name 24
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
}
这里来设置时间段的控制 其他的设置不用修改
(8)cgi.cfg文件 添加 admin的权限
default_user_name=admin
authorized_for_system_information=nagiosadmin,admin
authorized_for_configuration_information=nagiosadmin,admin
authorized_for_system_commands=admin
authorized_fro_all_services=nagiosadmin,admin
authorized_fro_all_hosts=nagiosadmin,admin
authorized_fro_all_service_commands=nagiosadmin,admin
authorized_fro_all_host_commands=nagiosadmin,admin
(9)nagios.cfg文件
添加hosts.cfg 和 services.cfg 的 指引路径
cfg_file=/usr/local/nagios/etc/objects/hosts.cfg
cfg_file=/usr/local/nagios/etc/objects/services.cfg
注释localhost.cfg的指引路径 #cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
修改:
command_check_interval=2
*******************nagios的配置已经完成了*******************
这几个配置文件之间的关系,刚刚接触可能感觉比较混乱,熟悉了就简单了。
打开下一章:nagios监控之(运行和维护)
转载于:https://blog.51cto.com/yanzhe/1129608
nagios监控之(监控配置)相关推荐
- Nagios监控系统安装及配置文档
3. 前言 做为系统管理员,管理着几十台或几百台服务器在运行.一个非常迫切的需求就是希望了解服务器及服务器上运行的服务的运行状况,在服务器或服务出现当机或停止的时候能够第一时间知道,及时处理.以便最小 ...
- 实战Nagios NSCA方式监控Linux系统资源使用情况 -- Nagios配置篇 -- Nagios Server端
现在说说在我们系统中如何是用NSCA方式来获取我们需要的被监控节点的资源使用情况信息. 先讲讲Nagios Server端的基本配置: 1. nagios web gui 访问配置,系统中使用的是na ...
- 实战Nagios NSCA方式监控Linux系统资源使用情况 -- Nagios配置篇 -- 被监控端
Nagios要求被监控端按照约定格式定时将数据发送到Nagios端.监控包括节点和服务2种. 节点监控约定数据格式如下: [<timestamp>] PROCESS_HOST_CHECK_ ...
- 【集群监控——Cacti、Nagios、Zabbix安装配置过程】
常见三大集群监控软件 常见监控平台 Cacti 组件说明 1)SNMP 2)RRDtool Cacti监控组件安装配置 Nagios 老牌监控服务器 Cacti – Nagios 对比 Nagios ...
- Nagios 网卡流量监控
本文所用到的监控流量插件来自"石头"的 1.20 版 shell 插件.感谢之.... 下载地址为: 点击下载 . 总体设置可以分为两块, linux 主机及非 linux 主机. ...
- nagios(系统监控)
nagios(系统监控) Nagios是一款开源的免费网络监视工具,能有效监控Windows.Linux和Unix的主机状态,交换机路由器等网络设置,打印机等. 在系统或服务状态异常时发出邮件或短信报 ...
- Nagios之linux监控windows主机
服务器端安装: 安装snmp服务和其他插件服务: [root@nagios~]# yum -y install net-snmp* #安装snmp服务. CPAN安装: wgetftp://ftp.m ...
- Prometheus监控以及告警配置
Prometheus监控 Prometheus简介 Prometheus是一套开源的系统监控报警框架.Prometheus作为新一代的云原生监控系统,相比传统监控监控系统(Nagios或者Zabbix ...
- ossim监控mysql_OSSIM中配置网络资产监控
OSSIM中配置网络资产监控 你还在为在Linux下安装配置LAMP环境苦恼,你还在不断尝试编译安装配置Nagios吗?下文为大家介绍如何通过OSSIM实现对服务器的监控,特点是操作简单.速度快,真正 ...
- 架设nagios+rrdtool+pnp4nagios监控windows主机
OS:centos 5.7final 32bit Apache/2.4.2 PHP/5.3.13 Nagios® Core™ 3.4.1 nagios-plugins-1.4.15 rrdtool- ...
最新文章
- a标签跳页传参,以及截取URL参数
- matlab配对交易回测,精品案例 | 经典投资策略之配对交易策略
- Rxjava 优雅的实现短信验证码发送
- AWS DataPipline 的一次尝试。
- uploadify多文件上传插件
- 北岛创投发起7200万美元加密VC基金,保罗·都铎·琼斯参与投资
- C#基础5.1:StringBuilder和StopWatch类
- Android10获取唯一ID最佳做法
- 一致性算法中的节点下限(转)
- 基于umi写一个用户管理CRUD
- spring事务失效一:非public方法
- java档案管理系统_基于JAVA的简单档案管理系统
- Unity 动态鼠标切换
- 毕业答辩ppt怎么做?
- 比较TTL集成电路与CMOS集成电路
- Centos Linux 可视化管理工具
- VOC2012数据集的探索性数据分析(EDA)
- 潘多拉固件设置ipv6_openwrt-LEDE系统IPV6设置教程
- 国产开发板各项性能测试--米尔MYD-YT507H开发板
- 《读者》2005言论