开发者

How to check if the service and the server is available?

I would like to check if given server is online and given service is active -- or maybe even simpler, if given port is open.

Something like this:

port_check my_server 22

or

service_check my_server ssh

And I would get a binary answer -- yes/no, meaning everything is OK, or there is no connection (server is down, or the service is not active).

I have to run this tool from ordinary user account (non-root). 开发者_JAVA百科The question is -- what is the tool? Thank you in advance for help.

Edit: please note, I have to get binary answer, which means any interactive tool, or tool that tries to log in first is no good. It should be basically a ping but for any service.


telnet is that tool. check.sh

#!/bin/sh

telnet -e / $1 $2 <<END
/
close
END
echo $?

running - check.sh localhost <port>

Note that the service listening the port will be touched.


you can also try nmap tool.

the simplest way to use it is nmap -p$2 $1 but you can alternatively specify a port or even a host range to check.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜