Ping stops when there is big packet loss











up vote
1
down vote

favorite












my first post here.



I made an script that provide reports of my network every 5 minutes. The script is simple and is working fine except when there is issues in my network. The script is running in Ubuntu Server 18.04.



My line for the Ping command is:



ping -w 300 192.168.1.216


The issue consist when I am having packet losses, ping stop immediately an doesn't finish the 300 seconds (5 minutes) run. I checked online and everywhere but I haven't been able to find a solution to make the ping keep running when there are lost packets. This is an example:



ping -w 300 192.168.1.216
PING 192.168.1.216 (192.168.1.216) 56(84) bytes of data.
64 bytes from 192.168.1.216: icmp_seq=1 ttl=128 time=2.29 ms
64 bytes from 192.168.1.216: icmp_seq=2 ttl=128 time=4.14 ms
64 bytes from 192.168.1.216: icmp_seq=3 ttl=128 time=17.9 ms
64 bytes from 192.168.1.216: icmp_seq=4 ttl=128 time=40.6 ms
64 bytes from 192.168.1.216: icmp_seq=5 ttl=128 time=38.6 ms
From 192.168.1.2 icmp_seq=30 Destination Host Unreachable
From 192.168.1.2 icmp_seq=31 Destination Host Unreachable
From 192.168.1.2 icmp_seq=32 Destination Host Unreachable

--- 192.168.1.216 ping statistics ---
33 packets transmitted, 5 received, +3 errors, 84% packet loss, time 32657ms
rtt min/avg/max/mdev = 2.295/20.738/40.659/16.379 ms, pipe 4


Thanks.





EDIT REASON: Add full script code.



Full script code:



Location="XXX"
host="192.168.6.1"

while true
do
result=$(ping -w 300 -q $host)

sendemail
-f "xxxx@gmail.com"
-u "XXX 5 Minutes Network Report"
-t "pingreport@gmail.com"
-s "smtp.gmail.com:587"
-o tls=yes
-xu "xxxx@gmail.com"
-xp "password"
-m "$result"
done


This is to check the status of our VPN. Like I said is a very simple script. I am using the ping -c 1 as suggested for an emergency one that will let us know if there is connectivity issues in the VPN as soon as possible.










share|improve this question









New contributor




Mr.Alvaro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 1




    Welcome to Ask Ubuntu. I don't understand what you're trying to do, but the -w appears to be doing what it should as the man ping states "it waits either for deadline expire or until count probes are answered or for some error notification from network." - ie. it's stopping because last condition is reached as I understand your question. When I've had to do similar to you, I sent a single ping -c 1 & then processed according to error.code err1721=$? in subsequent lines.
    – guiverc
    Dec 4 at 22:24










  • All that I need is to have a ping running for 300/3600/86400 seconds, that is why I used the -w. What I need is a way that ping doesn't stop when there are network errors when using the -w or another way to make sure it runs for the specific amount of time disregarding network errors, packet lost etc.
    – Mr.Alvaro
    Dec 4 at 22:33















up vote
1
down vote

favorite












my first post here.



I made an script that provide reports of my network every 5 minutes. The script is simple and is working fine except when there is issues in my network. The script is running in Ubuntu Server 18.04.



My line for the Ping command is:



ping -w 300 192.168.1.216


The issue consist when I am having packet losses, ping stop immediately an doesn't finish the 300 seconds (5 minutes) run. I checked online and everywhere but I haven't been able to find a solution to make the ping keep running when there are lost packets. This is an example:



ping -w 300 192.168.1.216
PING 192.168.1.216 (192.168.1.216) 56(84) bytes of data.
64 bytes from 192.168.1.216: icmp_seq=1 ttl=128 time=2.29 ms
64 bytes from 192.168.1.216: icmp_seq=2 ttl=128 time=4.14 ms
64 bytes from 192.168.1.216: icmp_seq=3 ttl=128 time=17.9 ms
64 bytes from 192.168.1.216: icmp_seq=4 ttl=128 time=40.6 ms
64 bytes from 192.168.1.216: icmp_seq=5 ttl=128 time=38.6 ms
From 192.168.1.2 icmp_seq=30 Destination Host Unreachable
From 192.168.1.2 icmp_seq=31 Destination Host Unreachable
From 192.168.1.2 icmp_seq=32 Destination Host Unreachable

--- 192.168.1.216 ping statistics ---
33 packets transmitted, 5 received, +3 errors, 84% packet loss, time 32657ms
rtt min/avg/max/mdev = 2.295/20.738/40.659/16.379 ms, pipe 4


Thanks.





EDIT REASON: Add full script code.



Full script code:



Location="XXX"
host="192.168.6.1"

while true
do
result=$(ping -w 300 -q $host)

sendemail
-f "xxxx@gmail.com"
-u "XXX 5 Minutes Network Report"
-t "pingreport@gmail.com"
-s "smtp.gmail.com:587"
-o tls=yes
-xu "xxxx@gmail.com"
-xp "password"
-m "$result"
done


This is to check the status of our VPN. Like I said is a very simple script. I am using the ping -c 1 as suggested for an emergency one that will let us know if there is connectivity issues in the VPN as soon as possible.










share|improve this question









New contributor




Mr.Alvaro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 1




    Welcome to Ask Ubuntu. I don't understand what you're trying to do, but the -w appears to be doing what it should as the man ping states "it waits either for deadline expire or until count probes are answered or for some error notification from network." - ie. it's stopping because last condition is reached as I understand your question. When I've had to do similar to you, I sent a single ping -c 1 & then processed according to error.code err1721=$? in subsequent lines.
    – guiverc
    Dec 4 at 22:24










  • All that I need is to have a ping running for 300/3600/86400 seconds, that is why I used the -w. What I need is a way that ping doesn't stop when there are network errors when using the -w or another way to make sure it runs for the specific amount of time disregarding network errors, packet lost etc.
    – Mr.Alvaro
    Dec 4 at 22:33













up vote
1
down vote

favorite









up vote
1
down vote

favorite











my first post here.



I made an script that provide reports of my network every 5 minutes. The script is simple and is working fine except when there is issues in my network. The script is running in Ubuntu Server 18.04.



My line for the Ping command is:



ping -w 300 192.168.1.216


The issue consist when I am having packet losses, ping stop immediately an doesn't finish the 300 seconds (5 minutes) run. I checked online and everywhere but I haven't been able to find a solution to make the ping keep running when there are lost packets. This is an example:



ping -w 300 192.168.1.216
PING 192.168.1.216 (192.168.1.216) 56(84) bytes of data.
64 bytes from 192.168.1.216: icmp_seq=1 ttl=128 time=2.29 ms
64 bytes from 192.168.1.216: icmp_seq=2 ttl=128 time=4.14 ms
64 bytes from 192.168.1.216: icmp_seq=3 ttl=128 time=17.9 ms
64 bytes from 192.168.1.216: icmp_seq=4 ttl=128 time=40.6 ms
64 bytes from 192.168.1.216: icmp_seq=5 ttl=128 time=38.6 ms
From 192.168.1.2 icmp_seq=30 Destination Host Unreachable
From 192.168.1.2 icmp_seq=31 Destination Host Unreachable
From 192.168.1.2 icmp_seq=32 Destination Host Unreachable

--- 192.168.1.216 ping statistics ---
33 packets transmitted, 5 received, +3 errors, 84% packet loss, time 32657ms
rtt min/avg/max/mdev = 2.295/20.738/40.659/16.379 ms, pipe 4


Thanks.





EDIT REASON: Add full script code.



Full script code:



Location="XXX"
host="192.168.6.1"

while true
do
result=$(ping -w 300 -q $host)

sendemail
-f "xxxx@gmail.com"
-u "XXX 5 Minutes Network Report"
-t "pingreport@gmail.com"
-s "smtp.gmail.com:587"
-o tls=yes
-xu "xxxx@gmail.com"
-xp "password"
-m "$result"
done


This is to check the status of our VPN. Like I said is a very simple script. I am using the ping -c 1 as suggested for an emergency one that will let us know if there is connectivity issues in the VPN as soon as possible.










share|improve this question









New contributor




Mr.Alvaro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











my first post here.



I made an script that provide reports of my network every 5 minutes. The script is simple and is working fine except when there is issues in my network. The script is running in Ubuntu Server 18.04.



My line for the Ping command is:



ping -w 300 192.168.1.216


The issue consist when I am having packet losses, ping stop immediately an doesn't finish the 300 seconds (5 minutes) run. I checked online and everywhere but I haven't been able to find a solution to make the ping keep running when there are lost packets. This is an example:



ping -w 300 192.168.1.216
PING 192.168.1.216 (192.168.1.216) 56(84) bytes of data.
64 bytes from 192.168.1.216: icmp_seq=1 ttl=128 time=2.29 ms
64 bytes from 192.168.1.216: icmp_seq=2 ttl=128 time=4.14 ms
64 bytes from 192.168.1.216: icmp_seq=3 ttl=128 time=17.9 ms
64 bytes from 192.168.1.216: icmp_seq=4 ttl=128 time=40.6 ms
64 bytes from 192.168.1.216: icmp_seq=5 ttl=128 time=38.6 ms
From 192.168.1.2 icmp_seq=30 Destination Host Unreachable
From 192.168.1.2 icmp_seq=31 Destination Host Unreachable
From 192.168.1.2 icmp_seq=32 Destination Host Unreachable

--- 192.168.1.216 ping statistics ---
33 packets transmitted, 5 received, +3 errors, 84% packet loss, time 32657ms
rtt min/avg/max/mdev = 2.295/20.738/40.659/16.379 ms, pipe 4


Thanks.





EDIT REASON: Add full script code.



Full script code:



Location="XXX"
host="192.168.6.1"

while true
do
result=$(ping -w 300 -q $host)

sendemail
-f "xxxx@gmail.com"
-u "XXX 5 Minutes Network Report"
-t "pingreport@gmail.com"
-s "smtp.gmail.com:587"
-o tls=yes
-xu "xxxx@gmail.com"
-xp "password"
-m "$result"
done


This is to check the status of our VPN. Like I said is a very simple script. I am using the ping -c 1 as suggested for an emergency one that will let us know if there is connectivity issues in the VPN as soon as possible.







networking 18.04






share|improve this question









New contributor




Mr.Alvaro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Mr.Alvaro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Dec 5 at 16:04





















New contributor




Mr.Alvaro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Dec 4 at 21:53









Mr.Alvaro

64




64




New contributor




Mr.Alvaro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Mr.Alvaro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Mr.Alvaro is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 1




    Welcome to Ask Ubuntu. I don't understand what you're trying to do, but the -w appears to be doing what it should as the man ping states "it waits either for deadline expire or until count probes are answered or for some error notification from network." - ie. it's stopping because last condition is reached as I understand your question. When I've had to do similar to you, I sent a single ping -c 1 & then processed according to error.code err1721=$? in subsequent lines.
    – guiverc
    Dec 4 at 22:24










  • All that I need is to have a ping running for 300/3600/86400 seconds, that is why I used the -w. What I need is a way that ping doesn't stop when there are network errors when using the -w or another way to make sure it runs for the specific amount of time disregarding network errors, packet lost etc.
    – Mr.Alvaro
    Dec 4 at 22:33














  • 1




    Welcome to Ask Ubuntu. I don't understand what you're trying to do, but the -w appears to be doing what it should as the man ping states "it waits either for deadline expire or until count probes are answered or for some error notification from network." - ie. it's stopping because last condition is reached as I understand your question. When I've had to do similar to you, I sent a single ping -c 1 & then processed according to error.code err1721=$? in subsequent lines.
    – guiverc
    Dec 4 at 22:24










  • All that I need is to have a ping running for 300/3600/86400 seconds, that is why I used the -w. What I need is a way that ping doesn't stop when there are network errors when using the -w or another way to make sure it runs for the specific amount of time disregarding network errors, packet lost etc.
    – Mr.Alvaro
    Dec 4 at 22:33








1




1




Welcome to Ask Ubuntu. I don't understand what you're trying to do, but the -w appears to be doing what it should as the man ping states "it waits either for deadline expire or until count probes are answered or for some error notification from network." - ie. it's stopping because last condition is reached as I understand your question. When I've had to do similar to you, I sent a single ping -c 1 & then processed according to error.code err1721=$? in subsequent lines.
– guiverc
Dec 4 at 22:24




Welcome to Ask Ubuntu. I don't understand what you're trying to do, but the -w appears to be doing what it should as the man ping states "it waits either for deadline expire or until count probes are answered or for some error notification from network." - ie. it's stopping because last condition is reached as I understand your question. When I've had to do similar to you, I sent a single ping -c 1 & then processed according to error.code err1721=$? in subsequent lines.
– guiverc
Dec 4 at 22:24












All that I need is to have a ping running for 300/3600/86400 seconds, that is why I used the -w. What I need is a way that ping doesn't stop when there are network errors when using the -w or another way to make sure it runs for the specific amount of time disregarding network errors, packet lost etc.
– Mr.Alvaro
Dec 4 at 22:33




All that I need is to have a ping running for 300/3600/86400 seconds, that is why I used the -w. What I need is a way that ping doesn't stop when there are network errors when using the -w or another way to make sure it runs for the specific amount of time disregarding network errors, packet lost etc.
– Mr.Alvaro
Dec 4 at 22:33










1 Answer
1






active

oldest

votes

















up vote
1
down vote













I would consider changing your script to run ping -c 1 <ip-address> every five minutes, instead of relying on the ping binary to provide that behavior. Then you can also check the return status ($?) to determine if it succeeded or failed.



It would be helpful if you also post your script, so that the context of your problem can be more easily understood.






share|improve this answer





















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "89"
    };
    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: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });






    Mr.Alvaro is a new contributor. Be nice, and check out our Code of Conduct.










    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1098502%2fping-stops-when-there-is-big-packet-loss%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote













    I would consider changing your script to run ping -c 1 <ip-address> every five minutes, instead of relying on the ping binary to provide that behavior. Then you can also check the return status ($?) to determine if it succeeded or failed.



    It would be helpful if you also post your script, so that the context of your problem can be more easily understood.






    share|improve this answer

























      up vote
      1
      down vote













      I would consider changing your script to run ping -c 1 <ip-address> every five minutes, instead of relying on the ping binary to provide that behavior. Then you can also check the return status ($?) to determine if it succeeded or failed.



      It would be helpful if you also post your script, so that the context of your problem can be more easily understood.






      share|improve this answer























        up vote
        1
        down vote










        up vote
        1
        down vote









        I would consider changing your script to run ping -c 1 <ip-address> every five minutes, instead of relying on the ping binary to provide that behavior. Then you can also check the return status ($?) to determine if it succeeded or failed.



        It would be helpful if you also post your script, so that the context of your problem can be more easily understood.






        share|improve this answer












        I would consider changing your script to run ping -c 1 <ip-address> every five minutes, instead of relying on the ping binary to provide that behavior. Then you can also check the return status ($?) to determine if it succeeded or failed.



        It would be helpful if you also post your script, so that the context of your problem can be more easily understood.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 5 at 0:17









        mpontillo

        7461518




        7461518






















            Mr.Alvaro is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            Mr.Alvaro is a new contributor. Be nice, and check out our Code of Conduct.













            Mr.Alvaro is a new contributor. Be nice, and check out our Code of Conduct.












            Mr.Alvaro is a new contributor. Be nice, and check out our Code of Conduct.
















            Thanks for contributing an answer to Ask Ubuntu!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1098502%2fping-stops-when-there-is-big-packet-loss%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            數位音樂下載

            When can things happen in Etherscan, such as the picture below?

            格利澤436b