How to check if a server is up / down if pinging to that machine is not allowed
Hi,
How to check if a server is up / down if pinging to that machine is not allowed ? should we do ssh and grep the required part in script?? please help |
Various methods exist.
If you run "nmap -Pn -sn <hostname>" it avoids ping but attempts to see if the host is up. Output should be something like: Starting Nmap 5.21 ( http://nmap.org ) at 2012-08-27 13:19 EDT Nmap scan report for host (x.x.x.x) Host is up. Nmap done: 1 IP address (1 host up) scanned in 0.00 seconds If you run Nagios for monitoring the plugins include a binary called check_tcp and you can specify port 22 for that. ./check_tcp -H host -p 22 TCP OK - 0.001 second response time on port 22|time=0.000778s;;;0.000000;10.000000 Even if you don't run Nagios you can download and build that plugin for use. I think were it me I'd go with something that just checked to see if the port was responding like the above rather than doing a full ssh login and command run. |
Thanks mate!
I totally forgot about NMAP :doh: |
My apologies. I gave some incorrect advice above. The -PN is something I've used to avoid ping when doing full scans with nmap but what it really does is "assume the host is up" so it will always report host is up even if it fails on scanning.
Instead what seems to work after testing is: Code:
nmap -PS22 -p22 <hostname or IP> Interestingly although the output of nmap will correctly report a host is down using that syntax it still gives a return code 0 as if it succeeded. This means to use it in a script you'd have to test for the text it outputs rather than the return code. |
That's because the rtn code is that of the nmap program (code) itself, not the returned data ie nmap worked fine ... it doesn't know/care whether you consider up or down to be a fail or success.
|
Quote:
Quote:
|
All times are GMT -5. The time now is 02:51 PM. |