How to determine which of several computers is configured as primary
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
We have an old system in which from a set of computers, exactly one is configured as the "live" machine and the rest are fail-overs. We used to use ping to determine which was which, however, security updates now render ping useless.
I have found that ssh is still available and I can do essentially the same thing using ssh, however, I don't see that ssh has the same timeout option as does ping (we used a 1 second timeout which was more than adequate in our environment). I changed the script to use use ssh (running uname) and the process will work, except that I don't have the timeout option, when the script hits the machine that has been reconfigured, ssh hangs for a very long time.
Is there anyway to set a short time out for ssh to connect or find some other way to kill it after 1-2 seconds? Of course, if there is another way to see quickly if any machine responds to a hostname, or rather if no machine responds to a hostname, I'd love to know that, too.
Thanks
linux ssh
add a comment |Â
up vote
1
down vote
favorite
We have an old system in which from a set of computers, exactly one is configured as the "live" machine and the rest are fail-overs. We used to use ping to determine which was which, however, security updates now render ping useless.
I have found that ssh is still available and I can do essentially the same thing using ssh, however, I don't see that ssh has the same timeout option as does ping (we used a 1 second timeout which was more than adequate in our environment). I changed the script to use use ssh (running uname) and the process will work, except that I don't have the timeout option, when the script hits the machine that has been reconfigured, ssh hangs for a very long time.
Is there anyway to set a short time out for ssh to connect or find some other way to kill it after 1-2 seconds? Of course, if there is another way to see quickly if any machine responds to a hostname, or rather if no machine responds to a hostname, I'd love to know that, too.
Thanks
linux ssh
ping
is never a goot tool for that... you should "monitor" things using a check that mimicks the real traffic of the application you are monitoring. For example, if it is a webserver; you do an HTTP query, etc.
â Patrick Mevzek
Feb 1 at 2:02
Patrick - Well, we could debate about ping as it had been working, but ultimately, since ping was disabled, its no longer a candidate. I thought about your exact solution, however, the problem is that the server will always respond looking like the "xyz" server - when they reconfigure, the live machine has the IP address and hostname of the official system, while the other machines take on their "alternate egos". A query as you suggest would always reply "Server XYZ is at IP 1.2.3.4". I could have reported a MAC address, I suppose.
â Jim
Feb 2 at 13:21
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
We have an old system in which from a set of computers, exactly one is configured as the "live" machine and the rest are fail-overs. We used to use ping to determine which was which, however, security updates now render ping useless.
I have found that ssh is still available and I can do essentially the same thing using ssh, however, I don't see that ssh has the same timeout option as does ping (we used a 1 second timeout which was more than adequate in our environment). I changed the script to use use ssh (running uname) and the process will work, except that I don't have the timeout option, when the script hits the machine that has been reconfigured, ssh hangs for a very long time.
Is there anyway to set a short time out for ssh to connect or find some other way to kill it after 1-2 seconds? Of course, if there is another way to see quickly if any machine responds to a hostname, or rather if no machine responds to a hostname, I'd love to know that, too.
Thanks
linux ssh
We have an old system in which from a set of computers, exactly one is configured as the "live" machine and the rest are fail-overs. We used to use ping to determine which was which, however, security updates now render ping useless.
I have found that ssh is still available and I can do essentially the same thing using ssh, however, I don't see that ssh has the same timeout option as does ping (we used a 1 second timeout which was more than adequate in our environment). I changed the script to use use ssh (running uname) and the process will work, except that I don't have the timeout option, when the script hits the machine that has been reconfigured, ssh hangs for a very long time.
Is there anyway to set a short time out for ssh to connect or find some other way to kill it after 1-2 seconds? Of course, if there is another way to see quickly if any machine responds to a hostname, or rather if no machine responds to a hostname, I'd love to know that, too.
Thanks
linux ssh
asked Jan 30 at 20:18
Jim
83
83
ping
is never a goot tool for that... you should "monitor" things using a check that mimicks the real traffic of the application you are monitoring. For example, if it is a webserver; you do an HTTP query, etc.
â Patrick Mevzek
Feb 1 at 2:02
Patrick - Well, we could debate about ping as it had been working, but ultimately, since ping was disabled, its no longer a candidate. I thought about your exact solution, however, the problem is that the server will always respond looking like the "xyz" server - when they reconfigure, the live machine has the IP address and hostname of the official system, while the other machines take on their "alternate egos". A query as you suggest would always reply "Server XYZ is at IP 1.2.3.4". I could have reported a MAC address, I suppose.
â Jim
Feb 2 at 13:21
add a comment |Â
ping
is never a goot tool for that... you should "monitor" things using a check that mimicks the real traffic of the application you are monitoring. For example, if it is a webserver; you do an HTTP query, etc.
â Patrick Mevzek
Feb 1 at 2:02
Patrick - Well, we could debate about ping as it had been working, but ultimately, since ping was disabled, its no longer a candidate. I thought about your exact solution, however, the problem is that the server will always respond looking like the "xyz" server - when they reconfigure, the live machine has the IP address and hostname of the official system, while the other machines take on their "alternate egos". A query as you suggest would always reply "Server XYZ is at IP 1.2.3.4". I could have reported a MAC address, I suppose.
â Jim
Feb 2 at 13:21
ping
is never a goot tool for that... you should "monitor" things using a check that mimicks the real traffic of the application you are monitoring. For example, if it is a webserver; you do an HTTP query, etc.â Patrick Mevzek
Feb 1 at 2:02
ping
is never a goot tool for that... you should "monitor" things using a check that mimicks the real traffic of the application you are monitoring. For example, if it is a webserver; you do an HTTP query, etc.â Patrick Mevzek
Feb 1 at 2:02
Patrick - Well, we could debate about ping as it had been working, but ultimately, since ping was disabled, its no longer a candidate. I thought about your exact solution, however, the problem is that the server will always respond looking like the "xyz" server - when they reconfigure, the live machine has the IP address and hostname of the official system, while the other machines take on their "alternate egos". A query as you suggest would always reply "Server XYZ is at IP 1.2.3.4". I could have reported a MAC address, I suppose.
â Jim
Feb 2 at 13:21
Patrick - Well, we could debate about ping as it had been working, but ultimately, since ping was disabled, its no longer a candidate. I thought about your exact solution, however, the problem is that the server will always respond looking like the "xyz" server - when they reconfigure, the live machine has the IP address and hostname of the official system, while the other machines take on their "alternate egos". A query as you suggest would always reply "Server XYZ is at IP 1.2.3.4". I could have reported a MAC address, I suppose.
â Jim
Feb 2 at 13:21
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
Yes, you can use the ConnectTimeout
option. From man ssh_config
:
ConnectTimeout: Specifies the timeout (in seconds) used when connecting to the SSH server, instead of using the default system TCP timeout. This value is used only when the target is down or really unreachable, not when it refuses the connection.
Therefore, for a 5 second timeout:
ssh -o ConnectTimeout=5 host true
Note that this won't handle the case that you connect quickly, but the actual command you're running is slow, either on the connecting machine or the machine which you're connecting to. You may want to handle that case by both using ConnectTimeout
and the timeout
binary from GNU coreutils with a higher timeout as a backup.
For example, this will time out connections that take over 5 seconds, and will also terminate if anything in the entire operation takes over 7 seconds (by sending SIGTERM
). 3 seconds after that, if ssh
still didn't quit, we send SIGKILL
:
timeout 7 -k 3 ssh -o ConnectTimeout=5 host true
Whether you also want to use timeout
or not depends on what you want to achieve, but it will at least allow you to fail fast.
works perfectly, thanks
â Jim
Jan 30 at 20:44
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
Yes, you can use the ConnectTimeout
option. From man ssh_config
:
ConnectTimeout: Specifies the timeout (in seconds) used when connecting to the SSH server, instead of using the default system TCP timeout. This value is used only when the target is down or really unreachable, not when it refuses the connection.
Therefore, for a 5 second timeout:
ssh -o ConnectTimeout=5 host true
Note that this won't handle the case that you connect quickly, but the actual command you're running is slow, either on the connecting machine or the machine which you're connecting to. You may want to handle that case by both using ConnectTimeout
and the timeout
binary from GNU coreutils with a higher timeout as a backup.
For example, this will time out connections that take over 5 seconds, and will also terminate if anything in the entire operation takes over 7 seconds (by sending SIGTERM
). 3 seconds after that, if ssh
still didn't quit, we send SIGKILL
:
timeout 7 -k 3 ssh -o ConnectTimeout=5 host true
Whether you also want to use timeout
or not depends on what you want to achieve, but it will at least allow you to fail fast.
works perfectly, thanks
â Jim
Jan 30 at 20:44
add a comment |Â
up vote
2
down vote
accepted
Yes, you can use the ConnectTimeout
option. From man ssh_config
:
ConnectTimeout: Specifies the timeout (in seconds) used when connecting to the SSH server, instead of using the default system TCP timeout. This value is used only when the target is down or really unreachable, not when it refuses the connection.
Therefore, for a 5 second timeout:
ssh -o ConnectTimeout=5 host true
Note that this won't handle the case that you connect quickly, but the actual command you're running is slow, either on the connecting machine or the machine which you're connecting to. You may want to handle that case by both using ConnectTimeout
and the timeout
binary from GNU coreutils with a higher timeout as a backup.
For example, this will time out connections that take over 5 seconds, and will also terminate if anything in the entire operation takes over 7 seconds (by sending SIGTERM
). 3 seconds after that, if ssh
still didn't quit, we send SIGKILL
:
timeout 7 -k 3 ssh -o ConnectTimeout=5 host true
Whether you also want to use timeout
or not depends on what you want to achieve, but it will at least allow you to fail fast.
works perfectly, thanks
â Jim
Jan 30 at 20:44
add a comment |Â
up vote
2
down vote
accepted
up vote
2
down vote
accepted
Yes, you can use the ConnectTimeout
option. From man ssh_config
:
ConnectTimeout: Specifies the timeout (in seconds) used when connecting to the SSH server, instead of using the default system TCP timeout. This value is used only when the target is down or really unreachable, not when it refuses the connection.
Therefore, for a 5 second timeout:
ssh -o ConnectTimeout=5 host true
Note that this won't handle the case that you connect quickly, but the actual command you're running is slow, either on the connecting machine or the machine which you're connecting to. You may want to handle that case by both using ConnectTimeout
and the timeout
binary from GNU coreutils with a higher timeout as a backup.
For example, this will time out connections that take over 5 seconds, and will also terminate if anything in the entire operation takes over 7 seconds (by sending SIGTERM
). 3 seconds after that, if ssh
still didn't quit, we send SIGKILL
:
timeout 7 -k 3 ssh -o ConnectTimeout=5 host true
Whether you also want to use timeout
or not depends on what you want to achieve, but it will at least allow you to fail fast.
Yes, you can use the ConnectTimeout
option. From man ssh_config
:
ConnectTimeout: Specifies the timeout (in seconds) used when connecting to the SSH server, instead of using the default system TCP timeout. This value is used only when the target is down or really unreachable, not when it refuses the connection.
Therefore, for a 5 second timeout:
ssh -o ConnectTimeout=5 host true
Note that this won't handle the case that you connect quickly, but the actual command you're running is slow, either on the connecting machine or the machine which you're connecting to. You may want to handle that case by both using ConnectTimeout
and the timeout
binary from GNU coreutils with a higher timeout as a backup.
For example, this will time out connections that take over 5 seconds, and will also terminate if anything in the entire operation takes over 7 seconds (by sending SIGTERM
). 3 seconds after that, if ssh
still didn't quit, we send SIGKILL
:
timeout 7 -k 3 ssh -o ConnectTimeout=5 host true
Whether you also want to use timeout
or not depends on what you want to achieve, but it will at least allow you to fail fast.
edited Jan 30 at 20:27
answered Jan 30 at 20:22
Chris Down
75.5k11178195
75.5k11178195
works perfectly, thanks
â Jim
Jan 30 at 20:44
add a comment |Â
works perfectly, thanks
â Jim
Jan 30 at 20:44
works perfectly, thanks
â Jim
Jan 30 at 20:44
works perfectly, thanks
â Jim
Jan 30 at 20:44
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f420787%2fhow-to-determine-which-of-several-computers-is-configured-as-primary%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
ping
is never a goot tool for that... you should "monitor" things using a check that mimicks the real traffic of the application you are monitoring. For example, if it is a webserver; you do an HTTP query, etc.â Patrick Mevzek
Feb 1 at 2:02
Patrick - Well, we could debate about ping as it had been working, but ultimately, since ping was disabled, its no longer a candidate. I thought about your exact solution, however, the problem is that the server will always respond looking like the "xyz" server - when they reconfigure, the live machine has the IP address and hostname of the official system, while the other machines take on their "alternate egos". A query as you suggest would always reply "Server XYZ is at IP 1.2.3.4". I could have reported a MAC address, I suppose.
â Jim
Feb 2 at 13:21