开发者

How to make a batch to check status of one port on remote host using NSClient?

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...


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

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


Is there any reason not to use the check_tcp Nagios plugin that comes with the default plugin package?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜