Oded Peer
Oded Peer

Reputation: 2437

How can I test if a remote server is up in Linux?

I want to test that my remote databases are up by testing connectivity to the DB port. Is there a simple way to do this in a linux shell script? My servers running on hosts X1, X2, ..., Xn and y on port P1, P2, ..., Pn I want to query all of them from admin server.

Upvotes: 0

Views: 1272

Answers (3)

jerger
jerger

Reputation: 53

You may either use netcat directly or more our test tool dda-serverspec for more dedicated tests (https://github.com/DomainDrivenArchitecture/dda-serverspec-crate) for such tasks. You may define your expectation

{:netcat [{:host "mywebserver.com" :port "443"}
          {:host "telnet mywebserver.com" :port "80"}
          {:host "telnet mywebserver.com" :port "8443"}]}

and test these expectation either against localhost or against remote hosts (connect by ssh). For remote tests you've to define a targets:

{:existing [{:node-name "test-vm1"
             :node-ip "35.157.19.218"}
            {:node-name "test-vm2"
             :node-ip "18.194.113.138"}]
 :provisioning-user {:login "ubuntu"}}

You may run the test with java -jar dda-serverspec.jar --targets targets.edn serverspec.edn

Upvotes: 0

quux
quux

Reputation: 918

You can use telnet to check if ports are ready for connection.

Upvotes: -1

rkosegi
rkosegi

Reputation: 14678

there are many possibilities how to achieve this, but I think most relaible way to do this is use NAGIOS plugin nrpe_tcp.

Please check:

http://exchange.nagios.org/directory/Plugins/Network-Protocols/*-TCP-and-UDP-%28Generic%29

Upvotes: 2

Related Questions