惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Secure Thoughts
S
Securelist
P
Proofpoint News Feed
D
DataBreaches.Net
Cisco Talos Blog
Cisco Talos Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
Project Zero
Project Zero
A
About on SuperTechFans
罗磊的独立博客
WordPress大学
WordPress大学
月光博客
月光博客
Latest news
Latest news
C
Cyber Attacks, Cyber Crime and Cyber Security
GbyAI
GbyAI
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
博客园 - 三生石上(FineUI控件)
F
Fortinet All Blogs
W
WeLiveSecurity
Attack and Defense Labs
Attack and Defense Labs
V
Visual Studio Blog
Blog — PlanetScale
Blog — PlanetScale
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
P
Privacy International News Feed
AI
AI
博客园 - 司徒正美
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Stack Overflow Blog
Stack Overflow Blog
M
MIT News - Artificial intelligence
Help Net Security
Help Net Security
T
Tor Project blog
V
Vulnerabilities – Threatpost
C
Cisco Blogs
I
Intezer
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
MyScale Blog
MyScale Blog
雷峰网
雷峰网
MongoDB | Blog
MongoDB | Blog
Forbes - Security
Forbes - Security
V
V2EX
Apple Machine Learning Research
Apple Machine Learning Research
T
Threat Research - Cisco Blogs
B
Blog RSS Feed
博客园 - 叶小钗
N
News and Events Feed by Topic
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Simon Willison's Weblog
Simon Willison's Weblog
C
CERT Recently Published Vulnerability Notes
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
N
News and Events Feed by Topic

博客园 - 菲一打

【转】Linux从入门到精通——运维工程师成长路线图——CTO马哥Linux视频教学 【转】 要做linux运维工程师的朋友,必须要掌握以下几个工具才行 【转】Linux shell笔记 【转】Linux上vi(vim)编辑器使用教程 无法远程连接SQLSERVER2000的解决方法 Python类的__getitem__和__setitem__特殊方法 让Python支持中文注释 【转】python入门指引 【转】布同:如何循序渐进学习Python语言 nagios中监测dns 227.7.128.68的网络状态 【转】新手该如何学python怎么学好python? 在nagios中使用python脚本监控linux主机 【转】手游公司运维之从一个人运维到运维主管 【转】VMware 克隆 Linux 系统后找不到 eth0 网卡问题 【转】sed & awk常用正则表达式 【转】Linux 服务器安全配置 【转】shell脚本实现多台服务器自动巡检--可参考学习 【转】nagios 命令解释 在nagios中使用nrpe自定义脚本
在nagios中监控windows主机系统地址的状态
菲一打 · 2014-04-17 · via 博客园 - 菲一打

原来的
[root@nhserver2_5 objects]# cd /usr/local/nagios/etc/objects
[root@nhserver2_5 objects]# vim commands.cfg
# 'check_http' command definition
define command{
        command_name    check_http
        command_line    $USER1$/check_http -I $HOSTADDRESS$ $ARG1$
        }
要修改为
define command{
        command_name    check_http
        command_line    $USER1$/check_http -H $HOSTADDRESS$ -p $ARG1$ -u $ARG2$
        }

[root@nhserver2_5 objects]# cd usr/local/nagios/etc/objects
[root@nhserver2_5 objects]# vim hosts_172.16.1.191.cfg
define host{
        use                     windows-server
        host_name               172.16.1.191
        alias                   172.16.1.191
        address                 172.16.1.191
        }

define hostgroup{
        hostgroup_name  windows-servers
        alias           Windows Servers
        }

define service{
        use                     local-service
        host_name               172.16.1.191
        service_description     check-host-alive
        check_command           check-host-alive
        max_check_attempts      5
        normal_check_interval   3
        retry_check_interval    2
        check_period            24x7
        notification_interval   10
        notification_period     24x7
        }

define service{
        use                     local-service
        host_name               172.16.1.191
        service_description     172.16.1.191:9000/gx/login.jsp
        check_command           check_http!9000!"/gx/login.jsp"
        max_check_attempts      5
        normal_check_interval   3
        retry_check_interval    2
        check_period            24x7
        notification_interval   10
        notification_period     24x7
        }

[root@nhserver2_5 objects]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
[root@nhserver2_5 objects]# service nagios reload

测试
[root@nhserver2_5 libexec]# ./check_http -I 172.16.1.191 -p 9000 -u "/gx/login.jsp"  
HTTP OK: HTTP/1.1 200 OK - 1438 bytes in 0.003 second response time |time=0.003178s;;;0.000000 size=1438B;;;0

[root@nhserver2_5 libexec]# ./check_http -I 172.16.1.191 -p 9000 -u "/gxx/login.jsp"
HTTP WARNING: HTTP/1.1 400 No Host matches server name skylink-3488y1g - 143 bytes in 0.002 second response time |time=0.002433s;;;0.000000 size=143B;;;0

-----------------------------------------------------------

过一会,就能在nagios的services中看到172.16.1.191:9000/gx/login.jsp这个地址能正常访问了。
172.16.1.191
172.16.1.191:9000/gx/login.jsp    
    OK     04-17-2014 21:05:21     0d 0h 0m 49s     1/5     HTTP OK: HTTP/1.1 200 OK - 1438 bytes in 0.016 second response time     
check-host-alive
    OK     04-17-2014 21:04:19     0d 0h 1m 51s     1/5     PING OK - Packet loss = 0%, RTA = 0.49 ms

改动一下地址172.16.1.191:9000/gxx/login.jsp(为gxx),看结果如何:提示没有找到合适的地址,结果正确。
172.16.1.191    
172.16.1.191:9000/gxx/login.jsp    
    WARNING     04-17-2014 21:09:04     0d 0h 1m 9s     1/5     HTTP WARNING: HTTP/1.1 400 No Host matches server name 172.16.1.191 - 139 bytes in 0.002

second response time     
check-host-alive    
    PENDING     N/A     0d 0h 2m 9s+     1/5     Service check scheduled for Thu Apr 17 21:10:04 CST 2014

=============================================================================
自定义一个check_http_nh命令来做:

[root@nhserver2_5 objects]# cd /usr/local/nagios/etc/objects
define command{
        command_name    check_http
        command_line    $USER1$/check_http -I $HOSTADDRESS$ $ARG1$
        #command_line    $USER1$/check_http -H $HOSTADDRESS$ -p $ARG1$ -u $ARG2$
        }
#加入一个自定义的命令
define command{
        command_name    check_http_nh
        #command_line    $USER1$/check_http -I $HOSTADDRESS$ $ARG1$
        command_line    $USER1$/check_http_nh -H $HOSTADDRESS$ -p $ARG1$ -u $ARG2$
        }

[root@nhserver2_5 libexec]# cd /usr/local/nagios/libexec
[root@nhserver2_5 libexec]# cp check_http check_http_nh
[root@nhserver2_5 libexec]# chown nagios.nagios check_http_nh

[root@nhserver2_5 objects]# cd /usr/local/nagios/etc/objects
[root@nhserver2_5 objects]# vim hosts_172.16.1.191.cfg
define host{
        use                     windows-server
        host_name               172.16.1.191
        alias                   172.16.1.191
        address                 172.16.1.191
        }

define hostgroup{
        hostgroup_name  windows-servers
        alias           Windows Servers
        }

define service{
        use                     local-service
        host_name               172.16.1.191
        service_description     check-host-alive
        check_command           check-host-alive
        max_check_attempts      5
        normal_check_interval   3
        retry_check_interval    2
        check_period            24x7
        notification_interval   10
        notification_period     24x7
        }

define service{
        use                     local-service
        host_name               172.16.1.191
        service_description     172.16.1.191:9000/gx/login.jsp
        check_command           check_http_nh!9000!"/gx/login.jsp"   #改为自定义的命令来检测
        max_check_attempts      5
        normal_check_interval   3
        retry_check_interval    2
        check_period            24x7
        notification_interval   10
        notification_period     24x7
        }

[root@nhserver2_5 libexec]# cd /usr/local/nagios/libexec
[root@nhserver2_5 libexec]# ./check_http_nh -I 172.16.1.191 -p 9000 -u "/gx/login.jsp"
HTTP OK: HTTP/1.1 200 OK - 1438 bytes in 0.020 second response time |time=0.019584s;;;0.000000 size=1438B;;;0

[root@nhserver2_5 objects]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
[root@nhserver2_5 objects]# service nagios reload

过一会儿,就能看到nagios中的service的状态正常了:
172.16.1.191
172.16.1.191:9000/gx/login.jsp    
    OK     04-17-2014 21:46:20     0d 0h 1m 1s     1/5     HTTP OK: HTTP/1.1 200 OK - 1438 bytes in 0.009 second response time     
check-host-alive    
    OK     04-17-2014 21:45:20     0d 0h 2m 1s     1/5     PING OK - Packet loss = 0%, RTA = 0.97 ms