How can we properly handle basham, for example, the same output fping
to get the output at the output - the node is available or unavailable - with a minimum delay from the moment the script is run. Errors in the form of a failed first ping are not taken into account - the grid is local.
|
1 answer
You can use the ping
utility by sending one packet ( -c1
) to check the availability of a node. Depending on the return value of the utility output, it is possible to signal the availability or unavailability of a node. For example:
host="192.168.222.222" ping -c1 "$host" > /dev/null && echo ""$host" is UP" || echo ""$host" is DOWN"
- “The errors in the form of a failed first ping are not taken into account - the grid is local.” - One package will not be enough for such a requirement. - edem
- In this case, @edem will have to add one packet at a time until clarity is reached :) in fact, seriously, if there is a temporary lack of ICMP responses, it would be good to think about the reasons for this phenomenon - approximatenumber
- @edem, you can send more packets. as far as I remember, the logic for generating the return code for the ping program is such that zero will return even if at least one answer is received. - aleksandr barakin
|
bash
means this is impossible;bash
itself cannot work with the network. 2) What do you mean by "node availability"? - user194374ping -c1 <host> > /dev/null && echo "host is UP" || echo "host is DOWN"
ping -c1 <host> > /dev/null && echo "host is UP" || echo "host is DOWN"
- approximatenumber