免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 17116 | 回复: 3
打印 上一主题 下一主题

[其他] nagios配置文件的一些问题请教! [复制链接]

论坛徽章:
2
羊年新春福章
日期:2015-04-27 16:56:53射手座
日期:2015-04-27 16:58:18
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-07-09 19:50 |只看该作者 |倒序浏览
本帖最后由 rdcwayx 于 2014-10-12 14:51 编辑

简单配置好nagios后发觉有个错误,但是在templates.cfg里面是有linux-server这个模版名称的啊?怎么回事啊?
  1. [root@RAC1 ~]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

  2. Nagios Core 3.2.3
  3. Copyright (c) 2009-2010 Nagios Core Development Team and Community Contributors
  4. Copyright (c) 1999-2009 Ethan Galstad
  5. Last Modified: 10-03-2010
  6. License: GPL

  7. Website: [url]http://www.nagios.org[/url]
  8. Reading configuration data...
  9.    Read main config file okay...
  10. Processing object config file '/usr/local/nagios/etc/hosts.cfg'...
  11. Processing object config file '/usr/local/nagios/etc/services.cfg'...
  12. Processing object config file '/usr/local/nagios/etc/commands.cfg'...
  13. Processing object config file '/usr/local/nagios/etc/contacts.cfg'...
  14. Processing object config file '/usr/local/nagios/etc/timeperiods.cfg'...
  15. Processing object config file '/usr/local/nagios/etc/templates.cfg'...
  16. Processing object config file '/usr/local/nagios/etc/objects/localhost.cfg'...
  17. Error: Template 'linux-server #引用主机linux-server的属性信息,templates.cfg中定义' specified in host definition could not be not found (config file '/usr/local/nagios/etc/hosts.cfg', starting on line 10)
  18.    Error processing object config files!


  19. ***> One or more problems was encountered while processing the config files...

  20.      Check your configuration file(s) to ensure that they contain valid
  21.      directives and data defintions.  If you are upgrading from a previous
  22.      version of Nagios, you should be aware that some variables/definitions
  23.      may have been removed or modified in this version.  Make sure to read
  24.      the HTML documentation regarding the config files, as well as the
  25.      'Whats New' section to find out what has changed.

  26. hosts.cfg:
  27. [root@RAC1 etc]# cat hosts.cfg
  28. #########################################################
  29. #
  30. #define what hosts to be deteted?
  31. #author:xwy39
  32. #date:2013/07/09
  33. #
  34. #
  35. #########################################################

  36. define host{
  37.     use          linux-server #引用主机linux-server的属性信息,templates.cfg中定义
  38.    
  39.     host_name    RAC1         #主机名
  40.     alias        xwy39        #主机别名
  41.     address      192.168.0.200#被监控的主机地址

  42. }

  43. #define host{
  44. #    use          linux-server #引用主机linux-server的属性信息,templates.cfg中定义
  45. #     
  46. #    host_name    RAC2         #主机名
  47. #    alias        xwy39        #主机别名
  48. #    address      192.168.0.201#被监控的主机地址

  49. #}

  50. define hostgroup{
  51. hostgroup_name    sa-servers
  52. alias             sa servers
  53. members           RAC1

  54. template.cfg:


  55. ###############################################################################
  56. ###############################################################################
  57. #
  58. # CONTACT TEMPLATES
  59. #
  60. ###############################################################################
  61. ###############################################################################

  62. # Generic contact definition template - This is NOT a real contact, just a template!

  63. define contact{
  64.         name                            generic-contact         ; The name of this contact template
  65.         service_notification_period     24x7                    ; service notifications can be sent anytime
  66.         host_notification_period        24x7                    ; host notifications can be sent anytime
  67.         service_notification_options    w,u,c,r,f,s             ; send notifications for all service states, flapping events, and scheduled downtime events
  68.         host_notification_options       d,u,r,f,s               ; send notifications for all host states, flapping events, and scheduled downtime events
  69.         service_notification_commands   notify-service-by-email ; send service notifications via email
  70.         host_notification_commands      notify-host-by-email    ; send host notifications via email
  71.         register                        0                       ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL CONTACT, JUST A TEMPLATE!
  72.         }




  73. ###############################################################################
  74. ###############################################################################
  75. #
  76. # HOST TEMPLATES
  77. #
  78. ###############################################################################
  79. ###############################################################################

  80. # Generic host definition template - This is NOT a real host, just a template!

  81. define host{
  82.         name                            RAC1    ; The name of this host template
  83.         notifications_enabled           1               ; Host notifications are enabled
  84.         event_handler_enabled           1               ; Host event handler is enabled
  85.         flap_detection_enabled          1               ; Flap detection is enabled
  86.         process_perf_data               1               ; Process performance data
  87.         retain_status_information       1               ; Retain status information across program restarts
  88.         retain_nonstatus_information    1               ; Retain non-status information across program restarts
  89.         notification_period             24x7            ; Send host notifications at any time
  90.         register                        0               ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
  91.         }


  92. # Linux host definition template - This is NOT a real host, just a template!

  93. define host{
  94.         name                            linux-server    ; The name of this host template
  95.         use                             RAC1    ; This template inherits other values from the generic-host template
  96.         check_period                    24x7            ; By default, Linux hosts are checked round the clock
  97.         check_interval                  5               ; Actively check the host every 5 minutes
  98.         retry_interval                  1               ; Schedule host check retries at 1 minute intervals
  99.         max_check_attempts              10              ; Check each Linux host 10 times (max)
  100.         check_command                   check-host-alive ; Default command to check Linux hosts
  101.         notification_period             workhours       ; Linux admins hate to be woken up, so we only notify during the day
  102.                                                         ; Note that the notification_period variable is being overridden from
  103.                                                         ; the value that is inherited from the generic-host template!
  104.         notification_interval           120             ; Resend notifications every 2 hours
  105.         notification_options            d,u,r           ; Only send notifications for specific host states
  106.         contact_groups                  admins          ; Notifications get sent to the admins by default
  107.         register                        0               ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
  108.         }



  109. # Windows host definition template - This is NOT a real host, just a template!

  110. define host{
  111.         name                    windows-server  ; The name of this host template
  112.         use                     RAC1    ; Inherit default values from the generic-host template
  113.         check_period            24x7            ; By default, Windows servers are monitored round the clock
  114.         check_interval          5               ; Actively check the server every 5 minutes
  115.         retry_interval          1               ; Schedule host check retries at 1 minute intervals
  116.         max_check_attempts      10              ; Check each server 10 times (max)
  117.         check_command           check-host-alive        ; Default command to check if servers are "alive"
  118.         notification_period     24x7            ; Send notification out at any time - day or night
  119.         notification_interval   30              ; Resend notifications every 30 minutes
  120.         notification_options    d,r             ; Only send notifications for specific host states
  121.         contact_groups          admins          ; Notifications get sent to the admins by default
  122.         hostgroups              windows-servers ; Host groups that Windows servers should be a member of
  123.         register                0               ; DONT REGISTER THIS - ITS JUST A TEMPLATE
  124.         }


  125. # We define a generic printer template that can be used for most printers we monitor

  126. define host{
  127.         name                    generic-printer ; The name of this host template
  128.         use                     RAC1    ; Inherit default values from the generic-host template
  129.         check_period            24x7            ; By default, printers are monitored round the clock
  130.         check_interval          5               ; Actively check the printer every 5 minutes
  131.         retry_interval          1               ; Schedule host check retries at 1 minute intervals
  132.         max_check_attempts      10              ; Check each printer 10 times (max)
  133.         check_command           check-host-alive        ; Default command to check if printers are "alive"
  134.         notification_period     workhours               ; Printers are only used during the workday
  135.         notification_interval   30              ; Resend notifications every 30 minutes
  136.         notification_options    d,r             ; Only send notifications for specific host states
  137.         contact_groups          admins          ; Notifications get sent to the admins by default
  138.         register                0               ; DONT REGISTER THIS - ITS JUST A TEMPLATE
  139.         }


  140. # Define a template for switches that we can reuse
  141. define host{
  142.         name                    generic-switch  ; The name of this host template
  143.         use                     RAC1    ; Inherit default values from the generic-host template
  144.         check_period            24x7            ; By default, switches are monitored round the clock
  145.         check_interval          5               ; Switches are checked every 5 minutes
  146.         retry_interval          1               ; Schedule host check retries at 1 minute intervals
  147.         max_check_attempts      10              ; Check each switch 10 times (max)
  148.         check_command           check-host-alive        ; Default command to check if routers are "alive"
  149.         notification_period     24x7            ; Send notifications at any time
  150.         notification_interval   30              ; Resend notifications every 30 minutes
  151.         notification_options    d,r             ; Only send notifications for specific host states
  152.         contact_groups          admins          ; Notifications get sent to the admins by default
  153.         register                0               ; DONT REGISTER THIS - ITS JUST A TEMPLATE
  154.         }




  155. ###############################################################################
  156. ###############################################################################
  157. #
  158. # SERVICE TEMPLATES
  159. #
  160. ###############################################################################
  161. ###############################################################################

  162. # Generic service definition template - This is NOT a real service, just a template!

  163. define service{
  164.         name                            generic-service         ; The 'name' of this service template
  165.         active_checks_enabled           1                       ; Active service checks are enabled
  166.         passive_checks_enabled          1                       ; Passive service checks are enabled/accepted
  167.         parallelize_check               1                       ; Active service checks should be parallelized (disabling this can lead to major performance problems)
  168.         obsess_over_service             1                       ; We should obsess over this service (if necessary)
  169.         check_freshness                 0                       ; Default is to NOT check service 'freshness'
  170.         notifications_enabled           1                       ; Service notifications are enabled
  171.         event_handler_enabled           1                       ; Service event handler is enabled
  172.         flap_detection_enabled          1                       ; Flap detection is enabled
  173.         process_perf_data               1                       ; Process performance data
  174.         retain_status_information       1                       ; Retain status information across program restarts
  175.         retain_nonstatus_information    1                       ; Retain non-status information across program restarts
  176.         is_volatile                     0                       ; The service is not volatile
  177.         check_period                    24x7                    ; The service can be checked at any time of the day
  178.         max_check_attempts              3                       ; Re-check the service up to 3 times in order to determine its final (hard) state
  179.         normal_check_interval           10                      ; Check the service every 10 minutes under normal conditions
  180.         retry_check_interval            2                       ; Re-check the service every two minutes until a hard state can be determined
  181.         contact_groups                  admins                  ; Notifications get sent out to everyone in the 'admins' group
  182.         notification_options            w,u,c,r                 ; Send notifications about warning, unknown, critical, and recovery events
  183.         notification_interval           60                      ; Re-notify about service problems every hour
  184.         notification_period             24x7                    ; Notifications can be sent out at any time
  185.          register                        0                      ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
  186.         }


  187. # Local service definition template - This is NOT a real service, just a template!

  188. define service{
  189.         name                            local-service           ; The name of this service template
  190.         use                             generic-service         ; Inherit default values from the generic-service definition
  191.         max_check_attempts              4                       ; Re-check the service up to 4 times in order to determine its final (hard) state
  192.         normal_check_interval           5                       ; Check the service every 5 minutes under normal conditions
  193.         retry_check_interval            1                       ; Re-check the service every minute until a hard state can be determined
  194.         register                        0                       ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
  195.         }
复制代码

论坛徽章:
16
IT运维版块每日发帖之星
日期:2015-10-02 06:20:00IT运维版块每月发帖之星
日期:2015-09-11 19:30:52IT运维版块每周发帖之星
日期:2015-09-11 19:20:31IT运维版块每日发帖之星
日期:2015-08-26 06:20:00每日论坛发贴之星
日期:2015-08-20 06:20:00IT运维版块每日发帖之星
日期:2015-08-20 06:20:002015年辞旧岁徽章
日期:2015-03-03 16:54:15金牛座
日期:2014-05-04 16:58:09双子座
日期:2013-12-17 16:44:37辰龙
日期:2013-11-22 15:20:59狮子座
日期:2013-11-18 22:55:08射手座
日期:2013-11-12 10:54:26
2 [报告]
发表于 2013-07-10 11:53 |只看该作者
你的host.cfg没配置server?

论坛徽章:
8
戌狗
日期:2013-10-12 11:37:19双子座
日期:2014-05-06 14:40:39巨蟹座
日期:2014-06-14 09:22:18戌狗
日期:2014-09-18 16:05:44巨蟹座
日期:2014-12-27 16:37:26酉鸡
日期:2015-01-20 18:39:022015年亚洲杯之沙特阿拉伯
日期:2015-04-20 22:38:242015亚冠之萨济拖拉机
日期:2015-06-19 16:01:03
3 [报告]
发表于 2014-10-10 11:24 |只看该作者
解决了吗?也遇到这问题

论坛徽章:
0
4 [报告]
发表于 2014-11-27 22:26 |只看该作者
把配置文件中的“#”号换为“;”就好了
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP