greenoldman
greenoldman

Reputation: 21072

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

Upvotes: 0

Views: 1570

Answers (2)

qdiesel
qdiesel

Reputation: 411

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.

Upvotes: 1

khachik
khachik

Reputation: 28693

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.

Upvotes: 2

Related Questions