如何使用 NSClient 批量检查远程主机上一个端口的状态?
我看到您可以使用 netcat 扫描开放端口,但如何扫描批处理文件中的端口以使用 NSclient 将其发送到 Nagios? 例如,我试图从Windows Server内部检查远程unix服务器上的端口7003是否打开,因此批处理应该检查unix上的远程端口并将反馈发送到Nagios,以便我可以在监控站点上看到它。 当前端口搜索的结果是:
nagios# /usr/local/libexec/nagios/check_nrpe2 -H 192.168.55.10 -c run_script -t 20
(UNKNOWN) [192.168.10.10] 7003 (?) open
这就是我现在所做的工作:
@echo off
nc -v -n -z -w 3 192.168.10.10 7003
IF %ERRORLEVEL% EQU 0 goto bueno
:malo
echo TCServer Connectivity: Bad
exit /b 2
:bueno
echo TCServer: Connectivity Good
exit /b 0
:end
非常感谢,我只需要用 echo %errorlevel%
xD 来理解 %errorlevel% 的输出,因为我在想我默认得到 0 或 1...
I saw that you can use netcat to scan for open ports but how can i scan a port in a batch file to send it to Nagios using NSclient?
for example i'm trying to check if port 7003 is open on a remote unix server from inside Windows Server, so the batch should check for the remote port on unix and send the feedback to Nagios so i can see it on the monitoring site.
The result of the current port search is:
nagios# /usr/local/libexec/nagios/check_nrpe2 -H 192.168.55.10 -c run_script -t 20
(UNKNOWN) [192.168.10.10] 7003 (?) open
This is what i have working now:
@echo off
nc -v -n -z -w 3 192.168.10.10 7003
IF %ERRORLEVEL% EQU 0 goto bueno
:malo
echo TCServer Connectivity: Bad
exit /b 2
:bueno
echo TCServer: Connectivity Good
exit /b 0
:end
Thanks so much, i just had to understand the output of %errorlevel% with an echo %errorlevel%
xD since i was thinking i get a 0 or 1 just by default...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这就是我现在所做的工作:
我只需要用
echo %errorlevel%
xD 来理解 %errorlevel% 的输出,因为我认为默认情况下我会得到 0 或 1This is what i have working now:
i just had to understand the output of %errorlevel% with an
echo %errorlevel%
xD since i was thinking i get a 0 or 1 just by default有什么理由不使用默认插件包附带的 check_tcp Nagios 插件吗?
Is there any reason not to use the check_tcp Nagios plugin that comes with the default plugin package?