免费注册 查看新帖 |

Chinaunix

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

[其他] nagios监控windows的问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2014-07-16 11:01 |只看该作者 |倒序浏览
写了一个vbs脚本,想监控windows中raid状态,把脚本放在C:\Program Files\NSClient++\scripts\lib,想问下nsclient++的配置文件是怎么写?
网上查了一下,check_raid=cscript.exe //NoLogo //T:40 scripts\lib\check_raid.vbs
但是通过监控端check_nrpe -H 172.20.22.226 -c check_raid
报错No handler for command: check_raid
请问是怎么回事啊?求各位大大帮忙解决,万分感谢。
nsclient++版本0.4.1

论坛徽章:
33
ChinaUnix元老
日期:2015-02-02 08:55:39CU十四周年纪念徽章
日期:2019-08-20 08:30:3720周年集字徽章-周	
日期:2020-10-28 14:13:3020周年集字徽章-20	
日期:2020-10-28 14:04:3019周年集字徽章-CU
日期:2019-09-08 23:26:2519周年集字徽章-19
日期:2019-08-27 13:31:262016科比退役纪念章
日期:2022-04-24 14:33:24
2 [报告]
发表于 2014-07-17 14:31 |只看该作者
不同版本的nsclient++的配置稍微有些不同,以我的0.4.1为例:

1、确保配置文件 nsclient.ini 里面的 allowed hosts 参数允许Nagios服务器的IP地址

2、在 nsclient.ini 的结尾增加以下内容
  1. ; A list of scripts available to run from the CheckExternalScripts module. Syntax is: <command>=<script> <arguments>
  2. [/settings/external scripts/scripts]
  3. check_raid = cscript.exe //T:30 //NoLogo scripts\\lib\\check_raid.vbs

  4. ; A list of wrappped scripts (ie. using the template mechanism)
  5. [/settings/external scripts/wrapped scripts]

  6. ; A list of templates for wrapped scripts
  7. [/settings/external scripts/wrappings]

  8. ; BATCH FILE WRAPPING -
  9. bat = scripts\\%SCRIPT% %ARGS%

  10. ; POWERSHELL WRAPPING -
  11. ps1 = cmd /c echo scripts\\%SCRIPT% %ARGS%; exit($lastexitcode) | powershell.exe -command -

  12. ; VISUAL BASIC WRAPPING -
  13. vbs = cscript.exe //T:30 //NoLogo scripts\\lib\\wrapper.vbs %SCRIPT% %ARGS%
复制代码
3、重启nsclient++的服务

论坛徽章:
0
3 [报告]
发表于 2014-07-18 14:47 |只看该作者
回复 2# Shell_HAT

非常感谢啊,终于有人回复了,不过现在是报CHECK_NRPE: Socket timeout after 10 seconds。不知道是不是我的脚本有问题?
还想问下,如果直接用bat脚本的话,会报“输入错误: 没有文件扩展“.bat”的脚本引擎。”
怎么样解决?


   

论坛徽章:
33
ChinaUnix元老
日期:2015-02-02 08:55:39CU十四周年纪念徽章
日期:2019-08-20 08:30:3720周年集字徽章-周	
日期:2020-10-28 14:13:3020周年集字徽章-20	
日期:2020-10-28 14:04:3019周年集字徽章-CU
日期:2019-09-08 23:26:2519周年集字徽章-19
日期:2019-08-27 13:31:262016科比退役纪念章
日期:2022-04-24 14:33:24
4 [报告]
发表于 2014-07-18 15:45 |只看该作者
Socket timeout after 10 seconds
这个跟脚本没关系,应该是网络的问题。
nsclient++的默认端口号是5666,你试试telnet通不
再ping一下看看是否丢包

论坛徽章:
33
ChinaUnix元老
日期:2015-02-02 08:55:39CU十四周年纪念徽章
日期:2019-08-20 08:30:3720周年集字徽章-周	
日期:2020-10-28 14:13:3020周年集字徽章-20	
日期:2020-10-28 14:04:3019周年集字徽章-CU
日期:2019-09-08 23:26:2519周年集字徽章-19
日期:2019-08-27 13:31:262016科比退役纪念章
日期:2022-04-24 14:33:24
5 [报告]
发表于 2014-07-18 15:52 |只看该作者
; A list of scripts available to run from the CheckExternalScripts module. Syntax is: <command>=<script> <arguments>
[/settings/external scripts/scripts]
check_vbs_test = cscript.exe //T:30 //NoLogo scripts\\test_ok.vbs
check_bat_test = cmd /c scripts\\check_ok.bat

; A list of wrappped scripts (ie. using the template mechanism)
[/settings/external scripts/wrapped scripts]


; A list of templates for wrapped scripts
[/settings/external scripts/wrappings]

; BATCH FILE WRAPPING -
bat = scripts\\%SCRIPT% %ARGS%

; POWERSHELL WRAPPING -
ps1 = cmd /c echo scripts\\%SCRIPT% %ARGS%; exit($lastexitcode) | powershell.exe -command -

; VISUAL BASIC WRAPPING -
vbs = cscript.exe //T:30 //NoLogo scripts\\lib\\wrapper.vbs %SCRIPT% %ARGS%

这样设置nsclient.ini,可以执行BAT脚本。

论坛徽章:
0
6 [报告]
发表于 2014-07-18 16:23 |只看该作者
本帖最后由 hblicy 于 2014-07-23 11:52 编辑

回复 5# Shell_HAT

OK了,谢谢。
我用下面命令运行,发现了可能是VBS的问题。
#/usr/local/nagios/libexec/check_nrpe -H 10.244.144.226 -c check_raid -t 30
No output available from command (cscript.exe //NoLogo //T:30 scripts\\lib\\check_raid.vbs).
用bat发现没问题了,应该就是添加上面那些ini的内容了。

另外还想问下,ipmitool您有用过吗?我在windows 2003上面运行ipmitool sdr总是不成功?在liinux下好像要加载openipmi的驱动,才可以运行。 windows没有找到。
  1. E:\ipmitool\ipmitool>ipmitool.exe sdr
  2. No hostname specified!
  3. ipmi_lan_send_cmd failed to open intf
  4. Get Device ID command failed
  5. Unable to open SDR for reading

  6. E:\ipmitool\ipmitool>ipmitool.exe -I open sdr
  7. Error loading interface open

  8. E:\ipmitool\ipmitool>
复制代码

论坛徽章:
33
ChinaUnix元老
日期:2015-02-02 08:55:39CU十四周年纪念徽章
日期:2019-08-20 08:30:3720周年集字徽章-周	
日期:2020-10-28 14:13:3020周年集字徽章-20	
日期:2020-10-28 14:04:3019周年集字徽章-CU
日期:2019-09-08 23:26:2519周年集字徽章-19
日期:2019-08-27 13:31:262016科比退役纪念章
日期:2022-04-24 14:33:24
7 [报告]
发表于 2014-07-18 16:58 |只看该作者
回复 6# hblicy


是的,要用Nagios监控,你的脚本里面需要输出返回给Nagios的内容,以及设置相应的退出码,否则Nagios无法判断服务的状态。

论坛徽章:
0
8 [报告]
发表于 2014-07-21 10:16 |只看该作者
回复 7# Shell_HAT

嗯,是的,我原来是写了个bat,我想用vbs放在后台运行,发现用vbs居然无输出了,用回bat还是可以的。
你有在windows下用过ipmitool吗?


   

论坛徽章:
33
ChinaUnix元老
日期:2015-02-02 08:55:39CU十四周年纪念徽章
日期:2019-08-20 08:30:3720周年集字徽章-周	
日期:2020-10-28 14:13:3020周年集字徽章-20	
日期:2020-10-28 14:04:3019周年集字徽章-CU
日期:2019-09-08 23:26:2519周年集字徽章-19
日期:2019-08-27 13:31:262016科比退役纪念章
日期:2022-04-24 14:33:24
9 [报告]
发表于 2014-07-21 10:31 |只看该作者
回复 8# hblicy


    没用过ipmitool

论坛徽章:
0
10 [报告]
发表于 2014-07-22 14:54 |只看该作者
回复 9# Shell_HAT

哦,还是谢谢你了。
   
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP