How to determine which of several computers is configured as primary

The name of the pictureThe name of the pictureThe name of the pictureClash 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







share|improve this question




















  • 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














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







share|improve this question




















  • 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












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







share|improve this question












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









share|improve this question











share|improve this question




share|improve this question










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
















  • 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










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.






share|improve this answer






















  • works perfectly, thanks
    – Jim
    Jan 30 at 20:44










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















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






























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.






share|improve this answer






















  • works perfectly, thanks
    – Jim
    Jan 30 at 20:44














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.






share|improve this answer






















  • works perfectly, thanks
    – Jim
    Jan 30 at 20:44












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.






share|improve this answer














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.







share|improve this answer














share|improve this answer



share|improve this answer








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
















  • 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












 

draft saved


draft discarded


























 


draft saved


draft discarded














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













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay