免费注册 查看新帖 |

Chinaunix

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

[网络配置] nagios利用域名监测http服务,求助! [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-05-02 16:09 |只看该作者 |倒序浏览
小女子刚刚接触linux和nagios,现接到任务要监测相应服务器的http服务,有访问链接地址,但是没有ip地址,nagios是否可以直接通过访问链接监测相应服务器的http服务呢?自己通过百度尝试了添加了相应的主机和服务,但是验证nagios配置文件时出错,报错信息如下:
Check your configuration file(s) to ensure that they contain valid
     directives and data defintions.  If you are upgrading from a previous
     version of Nagios, you should be aware that some variables/definitions
     may have been removed or modified in this version.  Make sure to read
     the HTML documentation regarding the config files, as well as the
     'Whats New' section to find out what has changed.
配置文件中小女子定义了主机和相关http服务,配置信息是这么写的
define host{
        use                     linux-server            ; Name of host template to use
                                                        ; This host definition will inherit all variables that are defined
                                                        ; in (or inherited by) the linux-server host template definition.
        host_name               ab
        alias                  ab
        }
define hostgroup{
        hostgroup_name  test ; The name of the hostgroup
        alias           test Servers ; Long name of the group
        members         ab     ; Comma separated list of hosts that belong to this group
        }
define service{
        use                             generic-service         ; Name of service template to use
        host_name                       ab
        service_description             HTTP
        check_command                        check_http -H http://epub.cnki.net/grid2008/index/ZKCALD.htm -p 80

        notifications_enabled                1
        }
麻烦各位大侠帮忙给解决一下吧!!!!非常感谢!!!!

论坛徽章:
0
2 [报告]
发表于 2013-05-02 16:23 |只看该作者
这个要写脚本分析了,刚好我写过,跟你分享一下

http://gm100861.blog.51cto.com/1930562/926945

论坛徽章:
381
CU十二周年纪念徽章
日期:2014-01-04 22:46:58CU大牛徽章
日期:2013-03-13 15:32:35CU大牛徽章
日期:2013-03-13 15:38:15CU大牛徽章
日期:2013-03-13 15:38:52CU大牛徽章
日期:2013-03-14 14:08:55CU大牛徽章
日期:2013-04-17 11:17:19CU大牛徽章
日期:2013-04-17 11:17:32CU大牛徽章
日期:2013-04-17 11:17:37CU大牛徽章
日期:2013-04-17 11:17:42CU大牛徽章
日期:2013-04-17 11:17:47CU大牛徽章
日期:2013-04-17 11:17:52CU大牛徽章
日期:2013-04-17 11:17:56
3 [报告]
发表于 2013-05-02 17:10 |只看该作者
nagios默认的check_http没法检测url,只检测80端口,你还是象楼上那样自己做命令检查吧

论坛徽章:
0
4 [报告]
发表于 2013-05-02 17:14 |只看该作者
回复 3# chenyx
谢谢,请问如果我只监测80端口的话,应该如何修改呢,应该用哪个check命令?


   

论坛徽章:
381
CU十二周年纪念徽章
日期:2014-01-04 22:46:58CU大牛徽章
日期:2013-03-13 15:32:35CU大牛徽章
日期:2013-03-13 15:38:15CU大牛徽章
日期:2013-03-13 15:38:52CU大牛徽章
日期:2013-03-14 14:08:55CU大牛徽章
日期:2013-04-17 11:17:19CU大牛徽章
日期:2013-04-17 11:17:32CU大牛徽章
日期:2013-04-17 11:17:37CU大牛徽章
日期:2013-04-17 11:17:42CU大牛徽章
日期:2013-04-17 11:17:47CU大牛徽章
日期:2013-04-17 11:17:52CU大牛徽章
日期:2013-04-17 11:17:56
5 [报告]
发表于 2013-05-02 17:21 |只看该作者
HTTP服务定义里面check_http后面的内容不要
host定义里面添加address epub.cnki.net
你测试下看看.

论坛徽章:
0
6 [报告]
发表于 2013-05-07 15:40 |只看该作者
现在利用域名监控主机可以解决了,可是有些需要用url监控的 ,似乎需要楼主给的脚本信息,这两天也摸索了一下,可是也没找到具体如何实现,楼主能否详细讲解一下,编写的脚本如何使用呢,是不是需要把它放到特定的目录下,再在commands.cfg中定义一个利用脚本监测命令,然后再在服务定义中引用呢回复 2# gm100861


   

论坛徽章:
381
CU十二周年纪念徽章
日期:2014-01-04 22:46:58CU大牛徽章
日期:2013-03-13 15:32:35CU大牛徽章
日期:2013-03-13 15:38:15CU大牛徽章
日期:2013-03-13 15:38:52CU大牛徽章
日期:2013-03-14 14:08:55CU大牛徽章
日期:2013-04-17 11:17:19CU大牛徽章
日期:2013-04-17 11:17:32CU大牛徽章
日期:2013-04-17 11:17:37CU大牛徽章
日期:2013-04-17 11:17:42CU大牛徽章
日期:2013-04-17 11:17:47CU大牛徽章
日期:2013-04-17 11:17:52CU大牛徽章
日期:2013-04-17 11:17:56
7 [报告]
发表于 2013-05-07 15:52 |只看该作者
脚本需要放到nagios主目录下的libexec目录下,赋予脚本x权限,用户及组用nagios的用户.
然后楼主参考其他检查项目的配置,自己写cfg.

论坛徽章:
0
8 [报告]
发表于 2013-05-13 10:11 |只看该作者
楼上正解。

论坛徽章:
381
CU十二周年纪念徽章
日期:2014-01-04 22:46:58CU大牛徽章
日期:2013-03-13 15:32:35CU大牛徽章
日期:2013-03-13 15:38:15CU大牛徽章
日期:2013-03-13 15:38:52CU大牛徽章
日期:2013-03-14 14:08:55CU大牛徽章
日期:2013-04-17 11:17:19CU大牛徽章
日期:2013-04-17 11:17:32CU大牛徽章
日期:2013-04-17 11:17:37CU大牛徽章
日期:2013-04-17 11:17:42CU大牛徽章
日期:2013-04-17 11:17:47CU大牛徽章
日期:2013-04-17 11:17:52CU大牛徽章
日期:2013-04-17 11:17:56
9 [报告]
发表于 2013-05-13 19:47 |只看该作者
http://bbs.chinaunix.net/forum.p ... amp;fromuid=1730385
我找到方法了,楼主参考下吧

论坛徽章:
0
10 [报告]
发表于 2013-05-14 16:18 |只看该作者
本帖最后由 kaiyang2013 于 2013-05-14 16:20 编辑

回复 9# chenyx
谢谢楼主啦,按照楼主给的提示信息,我做了相应修改,可是出现的提示信息是Name or service not known ,用了多个url测试,均出现这个问题,麻烦楼主帮忙给检查一下哪里出问题了,万分感谢!
1.定义命令
  1. define command{
  2.         command_name    check_http_u
  3.         command_line       $USER1$/check_http -I $HOSTADDRESS$ -u $ARG1$
  4.         }
复制代码
2.定义相应服务
  1. define service{
  2.         use                               generic-test-service  ; Name of service template to use
  3.         host_name                    apabi ;前面定义好的主机名
  4.         service_description      HTTP_URL;
  5.         check_command            check_http_u!'/path/index.html' ;
  6.         notifications_enabled      1;
  7. }
复制代码
3.主机定义
  1. define host{
  2.         use                         web-80-test1-server             ; Name of host template to use
  3.                                                         ; This host definition will inherit all variables that are defined
  4.                                                         ; in (or inherited by) the linux-server host template definition.
  5.         host_name               apabi
  6.         alias                         apabi
  7.         address                    http://www.apabi.com/xzjlt/
  8.         notifications_enabled           1
  9.         }
复制代码
4.主机模板定义
  1. define host{
  2.         name                                 web-80-test1-server    ; The name of this host template
  3.         use                                   generic-host    ; This template inherits other values from the generic-host template
  4.         check_period                     24x7            ; By default, Linux hosts are checked round the clock
  5.         check_interval                    5               ; Actively check the host every 5 minutes
  6.         retry_interval                     1               ; Schedule host check retries at 1 minute intervals
  7.         max_check_attempts         20              ; Check each Linux host 20 times (max)
  8.         check_command                check_http_u        ; Default command to check if servers are "alive"
  9.         notification_period             workhours       ; Linux admins hate to be woken up, so we only notify during the day
  10.                                                         ; Note that the notification_period variable is being overridden from
  11.                                                         ; the value that is inherited from the generic-host template!
  12.         notification_interval           360             ; Resend notifications every 2 hours
  13.         notification_options           d,u,r           ; Only send notifications for specific host states
  14.         contact_groups                 admins          ; Notifications get sent to the admins by default
  15.         register                             0               ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
  16.         }
复制代码
5.服务模板定义
  1. define service{
  2.         name                            generic-test-service     ; The 'name' of this service template
  3.         active_checks_enabled             1               ; Active service checks are enabled
  4.         passive_checks_enabled           1               ; Passive service checks are enabled/accepted
  5.         parallelize_check                      1               ; Active service checks should be parallelized (disabling this can lead to major performance problems)
  6.         obsess_over_service               1               ; We should obsess over this service (if necessary)
  7.         check_freshness                     0               ; Default is to NOT check service 'freshness'
  8.         notifications_enabled               1               ; Service notifications are enabled
  9.         event_handler_enabled            1               ; Service event handler is enabled
  10.         flap_detection_enabled            1               ; Flap detection is enabled
  11.         failure_prediction_enabled        1               ; Failure prediction is enabled
  12.         process_perf_data                  1               ; Process performance data
  13.         retain_status_information        1               ; Retain status information across program restarts
  14.         retain_nonstatus_information   1               ; Retain non-status information across program restarts
  15.         is_volatile                                0               ; The service is not volatile
  16.         check_period                           24x7            ; The service can be checked at any time of the day
  17.         max_check_attempts               20           ; Re-check the service up to 3 times in order to determine its final (hard) state
  18.         normal_check_interval              10          ; Check the service every 10 minutes under normal conditions
  19.         retry_check_interval                 2           ; Re-check the service every two minutes until a hard state can be determined
  20.         contact_groups                       admins          ; Notifications get sent out to everyone in the 'admins' group
  21.         notification_options                 w,u,c,r         ; Send notifications about warning, unknown, critical, and recovery events
  22.         notification_interval                 360          ; Re-notify about service problems every hour
  23.         notification_period                  24x7            ; Notifications can be sent out at any time
  24.          register                                0              ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
  25.         }
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP