nagios配置示例
nagios安装请移步至此处
本文之谈论简单的配置
1.删除原有的配置文件
nagios又名“难构死”这个“难”就难在配置,它的配置文件太多了,嵌套太多了容易让人混淆和闷圈,所有索性上来就清空它!
我们自定义配置文件
[root@master etc]# pwd
/usr/local/nagios/etc
[root@master etc]# find
.
./htpasswd //http验证文件
./nagios.cfg //nagios的主配置文件
./cgi.cfg //cgi相关配置文件
./resource.cfg //定义资源路径
./nrpe.cfg //此配置文件且不说,十一个外部插件的配置文件,部署于nagios自带的配置文件
./objects //配置文件子目录
./objects/contacts.cfg // 联系人定义配置文件
./objects/timeperiods.cfg //时间定义配置文件
./objects/commands.cfg //检测命令配置文件
./objects/hosts.cfg //检测主机的配置文件
./objects/service.cfg //检测主机和服务的配置文件
./objects/templates.cfg //全局定义配置文件
[root@master etc]# tar -czvf ~/nagios_cfgbackup.tar.gz ./*
[root@master etc]# rm -rf *.cfg objects/*.cfg
2.创建nagios的主配置文件
本配置文件只是去掉了注释和空行,感觉看着直观点儿,如下需要修改和核对的只有分割线中间的部分
# cat nagios.cfglog_file=/usr/local/nagios/var/nagios.log
#########################需要核对和修改的########################
cfg_file=/usr/local/nagios/etc/objects/commands.cfg
cfg_file=/usr/local/nagios/etc/objects/contacts.cfg
cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg
cfg_file=/usr/local/nagios/etc/objects/templates.cfg
cfg_file=/usr/local/nagios/etc/objects/hosts.cfg
cfg_file=/usr/local/nagios/etc/objects/service.cfg
########################################################
object_cache_file=/usr/local/nagios/var/objects.cache
precached_object_file=/usr/local/nagios/var/objects.precache
resource_file=/usr/local/nagios/etc/resource.cfg
status_file=/usr/local/nagios/var/status.dat
status_update_interval=10
nagios_user=nagios
nagios_group=nagios
check_external_commands=1
command_file=/usr/local/nagios/var/rw/nagios.cmd
lock_file=/usr/local/nagios/var/nagios.lock
temp_file=/usr/local/nagios/var/nagios.tmp
temp_path=/tmp
event_broker_options=-1
log_rotation_method=d
log_archive_path=/usr/local/nagios/var/archives
use_syslog=1
log_notifications=1
log_service_retries=1
log_host_retries=1
log_event_handlers=1
log_initial_states=0
log_current_states=1
log_external_commands=1
log_passive_checks=1
service_inter_check_delay_method=s
max_service_check_spread=30
service_interleave_factor=s
host_inter_check_delay_method=s
max_host_check_spread=30
max_concurrent_checks=0
check_result_reaper_frequency=10
max_check_result_reaper_time=30
check_result_path=/usr/local/nagios/var/spool/checkresults
max_check_result_file_age=3600
cached_host_check_horizon=15
cached_service_check_horizon=15
enable_predictive_host_dependency_checks=1
enable_predictive_service_dependency_checks=1
soft_state_dependencies=0
auto_reschedule_checks=0
auto_rescheduling_interval=30
auto_rescheduling_window=180
service_check_timeout=60
host_check_timeout=30
event_handler_timeout=30
notification_timeout=30
ocsp_timeout=5
perfdata_timeout=5
retain_state_information=1
state_retention_file=/usr/local/nagios/var/retention.dat
retention_update_interval=60
use_retained_program_state=1
use_retained_scheduling_info=1
retained_host_attribute_mask=0
retained_service_attribute_mask=0
retained_process_host_attribute_mask=0
retained_process_service_attribute_mask=0
retained_contact_host_attribute_mask=0
retained_contact_service_attribute_mask=0
interval_length=60
check_for_updates=1
bare_update_check=0
use_aggressive_host_checking=0
execute_service_checks=1
accept_passive_service_checks=1
execute_host_checks=1
accept_passive_host_checks=1
enable_notifications=1
enable_event_handlers=1
process_performance_data=0
obsess_over_services=0
obsess_over_hosts=0
translate_passive_host_checks=0
passive_host_checks_are_soft=0
check_for_orphaned_services=1
check_for_orphaned_hosts=1
check_service_freshness=1
service_freshness_check_interval=60
service_check_timeout_state=c
check_host_freshness=0
host_freshness_check_interval=60
additional_freshness_latency=15
enable_flap_detection=1
low_service_flap_threshold=5.0
high_service_flap_threshold=20.0
low_host_flap_threshold=5.0
high_host_flap_threshold=20.0
date_format=us
illegal_object_name_chars=`~!$%^&*|'"<>?,()=
illegal_macro_output_chars=`~$&|'"<>
use_regexp_matching=0
use_true_regexp_matching=0
admin_email=nagios@localhost
admin_pager=pagenagios@localhost
daemon_dumps_core=0
use_large_installation_tweaks=0
enable_environment_macros=0
debug_level=0
debug_verbosity=1
debug_file=/usr/local/nagios/var/nagios.debug
max_debug_file_size=1000000
allow_empty_hostgroup_assignment=0
2.创建cgi配置文件
无需修改
# cat cgi.cfg
main_config_file=/usr/local/nagios/etc/nagios.cfg
physical_html_path=/usr/local/nagios/share
url_html_path=/nagios
show_context_help=0
use_pending_states=1
use_authentication=0
use_ssl_authentication=0
authorized_for_system_information=nagiosadmin
authorized_for_configuration_information=nagiosadmin
authorized_for_system_commands=nagiosadmin
authorized_for_all_services=nagiosadmin
authorized_for_all_hosts=nagiosadmin
authorized_for_all_service_commands=nagiosadmin
authorized_for_all_host_commands=nagiosadmin
default_statusmap_layout=5
default_statuswrl_layout=4
ping_syntax=/bin/ping -n -U -c 5 $HOSTADDRESS$
refresh_rate=90
result_limit=100
escape_html_tags=1
action_url_target=_blank
notes_url_target=_blank
lock_author_names=1
navbar_search_for_addresses=1
navbar_search_for_aliases=1
3.创建资源定义配置文件
无需修改
# cat resource.cfg
$USER1$=/usr/local/nagios/libexec
4.创建全局配置文件
# cat objects/templates.cfg
define contact{name racadmin //联系人名称service_notification_period 24x7 //服务异常报警时间段 在时间配置文件中定定义的时间名称host_notification_period 24x7 //主机异常报警时间段 在时间配置文件中定定义的时间名称service_notification_options w,u,c,r,f,s //报价级别w警告,u未知,c紧急,r错误,f和s不详,有兴趣的可以查下资料host_notification_options d,u,r,f,s //d down,其他的和上边一样service_notification_commands notify-service-by-email //服务故障报警方式 在命令配置文件command中配置host_notification_commands notify-host-by-email //主机故障报警方式 在命令配置文件中command中配置register 0 }
define host{name globalhost //定义主机的全局通用配置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 24x7register 0 }
define host{name racnode //定义主机名use globalhost //引用全局主机定义的所有属性check_period 24x7 //检测的时间check_interval 1 //检测间隔retry_interval 1 //检测重试时间max_check_attempts 5 //异常检测最大次数check_command check-host-alive //检测主机存活notification_period workhours //通知的时间notification_interval 120 //发出通知后再次发出通知的时间 单位是分钟,如果只需要通知一次,则设置为0notification_options d,u,r //什么情况下给联系人发送通知contact_groups admins //联系人组register 0}
define host{name oggnodeuse globalhostcheck_period 24x7check_interval 1retry_interval 1max_check_attempts 5check_command check-host-alivenotification_period workhoursnotification_interval 120notification_options d,u,rcontact_groups adminsregister 0}
define service{name generic-service //定义全局服务熟悉active_checks_enabled 1passive_checks_enabled 1parallelize_check 1obsess_over_service 1check_freshness 0notifications_enabled 1event_handler_enabled 1flap_detection_enabled 1process_perf_data 1retain_status_information 1retain_nonstatus_information 1is_volatile 0check_period 24x7max_check_attempts 3normal_check_interval 10retry_check_interval 2contact_groups admins //联系人配置文件中定义的联系人组notification_options w,u,c,rnotification_interval 60notification_period 24x7register 0 }
define service{name oracleracuse generic-servicemax_check_attempts 4normal_check_interval 5retry_check_interval 1register 0}
define service{name oracleogg //定义服务的名字use generic-service //引用全局服务属性的所有参数max_check_attempts 4normal_check_interval 5retry_check_interval 1register 0}
5.建立命令配置文件
无需修改
define command{command_name notify-host-by-emailcommand_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$}
define command{command_name notify-service-by-emailcommand_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$}
define command{command_name check-host-alivecommand_line $USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 5}
define command{command_name check_local_diskcommand_line $USER1$/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$}
define command{command_name check_local_loadcommand_line $USER1$/check_load -w $ARG1$ -c $ARG2$}
define command{command_name check_local_procscommand_line $USER1$/check_procs -w $ARG1$ -c $ARG2$ -s $ARG3$}
define command{command_name check_local_userscommand_line $USER1$/check_users -w $ARG1$ -c $ARG2$}
define command{command_name check_local_swapcommand_line $USER1$/check_swap -w $ARG1$ -c $ARG2$}
define command{command_name check_local_mrtgtrafcommand_line $USER1$/check_mrtgtraf -F $ARG1$ -a $ARG2$ -w $ARG3$ -c $ARG4$ -e $ARG5$}
define command{command_name check_ftpcommand_line $USER1$/check_ftp -H $HOSTADDRESS$ $ARG1$}
define command{command_name check_hpjdcommand_line $USER1$/check_hpjd -H $HOSTADDRESS$ $ARG1$}
define command{command_name check_snmpcommand_line $USER1$/check_snmp -H $HOSTADDRESS$ $ARG1$}
define command{command_name check_httpcommand_line $USER1$/check_http -I $HOSTADDRESS$ $ARG1$}
define command{command_name check_sshcommand_line $USER1$/check_ssh $ARG1$ $HOSTADDRESS$}
define command{command_name check_dhcpcommand_line $USER1$/check_dhcp $ARG1$}
define command{command_name check_pingcommand_line $USER1$/check_ping -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ -p 5}
define command{command_name check_popcommand_line $USER1$/check_pop -H $HOSTADDRESS$ $ARG1$}
define command{command_name check_imapcommand_line $USER1$/check_imap -H $HOSTADDRESS$ $ARG1$}
define command{command_name check_smtpcommand_line $USER1$/check_smtp -H $HOSTADDRESS$ $ARG1$}
define command{command_name check_tcpcommand_line $USER1$/check_tcp -H $HOSTADDRESS$ -p $ARG1$ $ARG2$}
define command{command_name check_udpcommand_line $USER1$/check_udp -H $HOSTADDRESS$ -p $ARG1$ $ARG2$}
define command{command_name check_ntcommand_line $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -v $ARG1$ $ARG2$}
define command{command_name process-host-perfdatacommand_line /usr/bin/printf "%b" "$LASTHOSTCHECK$\t$HOSTNAME$\t$HOSTSTATE$\t$HOSTATTEMPT$\t$HOSTSTATETYPE$\t$HOSTEXECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA$\n" >> /usr/local/nagios/var/host-perfdata.out}
define command{command_name process-service-perfdatacommand_line /usr/bin/printf "%b" "$LASTSERVICECHECK$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICESTATE$\t$SERVICEATTEMPT$\t$SERVICESTATETYPE$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$\n" >> /usr/local/nagios/var/service-perfdata.out}
define command{command_name check_nrpecommand_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ }
6.建立主机配置文件
# cat objects/hosts.cfg
define host{use oggnode //引用主机定义熟悉 全局配置文件中定义host_name OGG_master //主机名alias GGmaster //别名address 127.0.0.1 //主机的IP地址}
define host{use oggnodehost_name OGG_slavealias GGslaveaddress 192.168.10.168
}
define hostgroup{hostgroup_name oracle_ogg //主机组alias goldenget //别名members OGG_master,OGG_slave //如上定义的成员
}
7.建立服务监控配置文件
# cat objects/service.cfg
#############OGG_MASTER###################### 此主机加测两个服务,一个是httpd一个是sshd
define service{use oracleogg //全局服务定义 中定义的host_name OGG_master //主机配置文件中定义service_description HTTPcheck_command check_http //commond配置文件中定义的检测命令notifications_enabled 0}
define service{use oracleogg host_name OGG_masterservice_description SSHcheck_command check_sshnotifications_enabled 0}
#############OGG_SLAVE###################### 此主集检测一个服务 ssh
define service{use oracleogghost_name OGG_slaveservice_description SSHcheck_command check_sshnotifications_enabled 0}
6.建立联系人配置文件
# cat objects/contacts.cfg
define contact{contact_name nagiosdba use racadmins //全局配置文件中定义alias Nagios Admin ; Full name of useremail XXXXX@qq.com}
define contactgroup{contactgroup_name admins //定义一个联系人组 全局配置文件中引用alias Nagios Administratorsmembers nagiosdba //定义组的成员}
7.建立时间配置文件
# cat objects/timeperiods.cfg //时间定义在全局配置文件中use
define timeperiod{timeperiod_name 24x7alias 24 Hours A Day, 7 Days A Weeksunday 00:00-24:00monday 00:00-24:00tuesday 00:00-24:00wednesday 00:00-24:00thursday 00:00-24:00friday 00:00-24:00saturday 00:00-24:00}
define timeperiod{timeperiod_name workhoursalias Normal Work Hoursmonday 09:00-17:00tuesday 09:00-17:00wednesday 09:00-17:00thursday 09:00-17:00friday 09:00-17:00}
define timeperiod{timeperiod_name nonealias No Time Is A Good Time}
define timeperiod{name us-holidaystimeperiod_name us-holidaysalias U.S. Holidaysjanuary 1 00:00-00:00 ; New Yearsmonday -1 may 00:00-00:00 ; Memorial Day (last Monday in May)july 4 00:00-00:00 ; Independence Daymonday 1 september 00:00-00:00 ; Labor Day (first Monday in September)thursday 4 november 00:00-00:00 ; Thanksgiving (4th Thursday in November)december 25 00:00-00:00 ; Christmas}
define timeperiod{timeperiod_name 24x7_sans_holidaysalias 24x7 Sans Holidaysuse us-holidays ; Get holiday exceptions from other timeperiodsunday 00:00-24:00monday 00:00-24:00tuesday 00:00-24:00wednesday 00:00-24:00thursday 00:00-24:00friday 00:00-24:00saturday 00:00-24:00}
8.检测nagios配置文件
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg Nagios Core 4.0.2
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 11-25-2013
License: GPLWebsite: http://www.nagios.org
Reading configuration data...Read main config file okay...Read object config files okay...Running pre-flight check on configuration data...Checking objects...Checked 5 services.Checked 2 hosts.Checked 1 host groups.Checked 0 service groups.Checked 1 contacts.Checked 1 contact groups.Checked 25 commands.Checked 5 time periods.Checked 0 host escalations.Checked 0 service escalations.
Checking for circular paths...Checked 2 hostsChecked 0 service dependenciesChecked 0 host dependenciesChecked 5 timeperiods
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...Total Warnings: 0
Total Errors: 0Things look okay - No serious problems were detected during the pre-flight check //检测通过
# /etc/init.d/nagios restart
正在启动 nagios: [确定]
打完手工 ########################## 迷途小运维原创 作者:john 转载请注明出处
nagios配置示例相关推荐
- (转)Nagios 配置及监控
Nagios 配置及监控 原文:http://blog.csdn.net/linuxlsq/article/details/52606824 Nagios 监控 在互联网日益发展的今天,监控的重要性已 ...
- hbase 默认目录_HBase 配置示例
基本分布式HBase安装 在下文内容中是一个分布式10节点的群集的基本配置示例:其中,节点被命名为example0,example1...一直到example9,在这个例子中:HBase Master ...
- nagios配置文档
nagios配置文档 关于nagios Nagios是一款用于系统和网络监控的应用程序.它可以在你设定的条件下对主机和服务进行监控,在状态变差和 变好的时候给出告警信息. Nagios最初被设计为在 ...
- Cisco Easy ***综合配置示例
以下内容摘自正在全面热销的最新网络设备图书"豪华四件套"之一<Cisco路由器配置与管理完全手册>(第二版)(其余三本分别是:<Cisco交换机配置与管理完全手册 ...
- LVS DR模型配置示例
要让路由知道哪台主机是Director,进行选择: 1.VIP:MAC(Director VIP) -- MAC绑定,但未必可行,例如路由是运营商的. 2.arptables 3.kernel par ...
- Logstash 参考指南(使用Filebeat Modules配置示例)
使用Filebeat Modules配置示例 本节中的示例展示了如何构建用于解析Filebeat模块收集的数据的Logstash管道: Apache 2日志 本例中的Logstash管道配置展示了如何 ...
- Spring boot自动配置示例
自动配置示例 HttpEncodingAutoConfiguration Http编码自动配置 以该类为例,查看自动配置过程 EnableAutoConfiguration HttpEncodingA ...
- Tomcat server.xml配置示例
转载自 Tomcat server.xml配置示例 几乎所有容器类型的应用都会包含一个名为 server.xml 的文件结构.基本上,其中的每个元数据或者配置都是容器完成初始化所需要的.正是由于 ...
- 交华为换机access配置_华为交换机VLAN内Proxy ARP配置示例
华为交换机VLAN内Proxy ARP配置示例 1.组网需求 图1 VLAN内Proxy ARP组网示例图 如上图1所示,Switch的接口GE1/0/2和GE1/0/1属于同一个sub-VLAN2. ...
最新文章
- SharePoint 2007 安装与配置
- 上周热点回顾(7.1-7.7)
- hash算法的介绍 【清晰易懂】
- Ubuntu 14.04.02 安装openvswitch-2.3.1
- AD20学习笔记4---网表导入及模块化布局设计
- 华科计算机课程设计,华中科大操作系统课程设计报告(附源码).doc
- python中paste函数_PIL图像处理模块paste方法简单使用详解
- 数据结构(C++)—— 向量(Vector)
- 浅谈java实现桌面小程序
- 智慧树工业机器人测试答案_知到智慧树玩转工业机器人答案章节单元测试答案...
- SEO关键词优化 - 利用免费资源刷排名
- Discuz杂志/新闻报道模板(jeavi_line)UTF8-GBK/DZ模板下载
- Notes Twenty-third days-渗透攻击-红队-红队自研
- ipsec-***过程
- 倡导国稻种芯·中国水稻节 万祥军:农民丰收节金秋消费季
- 物流快递发货单接口API代码-快递100API
- iOS 越狱-砸壳工具的使用
- HSV色彩空间和颜色分量范围
- 100天精通Python(基础篇)——第7天:高级变量类型复习
- 《甘草子·秋暮》 柳永
热门文章
- 织梦系统(DEDECMS)后台模板修改一
- 在校大学生学业预警系统java_关于学业预警系统上线使用的通知
- Kinect开发遇到的问题
- NTP DDoS反射放大攻击实验
- 【Smarty】Smarty的下载、配置与Helloworld
- 用于超短脉冲的光栅展宽器
- 计算机领域的诺贝尔奖是图灵奖,计算机界诺贝尔奖“图灵奖”,由3名人工智能深度学习领域的先驱共同获得...
- 代谢组数据:QC归一化(R语言:MetNormalizer包)
- 数字IC-1.10 手撕代码之整数乘法和二范数(Verilog HDL数字加减法练习好帮手)
- 成矿远景叠加分析matlab代码,深水潭金成矿地质特征及成矿远景分析