How can use tail for notifications above 0.99% loadav?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















#!/bin/bash

( tail -f -n0 /proc/loadavg 2> /dev/null & ) | grep -q "^[1-9]"
echo 'The millenium crystals are gunna blow!'


I though I was being clever and that would work. It just hangs and never reacts unless from run start and the first char is [1-9]










share|improve this question
























  • Just to nitpick: The load averages aren't percentages.

    – Kusalananda
    Mar 7 at 9:54

















0















#!/bin/bash

( tail -f -n0 /proc/loadavg 2> /dev/null & ) | grep -q "^[1-9]"
echo 'The millenium crystals are gunna blow!'


I though I was being clever and that would work. It just hangs and never reacts unless from run start and the first char is [1-9]










share|improve this question
























  • Just to nitpick: The load averages aren't percentages.

    – Kusalananda
    Mar 7 at 9:54













0












0








0








#!/bin/bash

( tail -f -n0 /proc/loadavg 2> /dev/null & ) | grep -q "^[1-9]"
echo 'The millenium crystals are gunna blow!'


I though I was being clever and that would work. It just hangs and never reacts unless from run start and the first char is [1-9]










share|improve this question
















#!/bin/bash

( tail -f -n0 /proc/loadavg 2> /dev/null & ) | grep -q "^[1-9]"
echo 'The millenium crystals are gunna blow!'


I though I was being clever and that would work. It just hangs and never reacts unless from run start and the first char is [1-9]







tail






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 7 at 9:22









Inian

5,3751531




5,3751531










asked Mar 7 at 9:20









Stuart NaylorStuart Naylor

11




11












  • Just to nitpick: The load averages aren't percentages.

    – Kusalananda
    Mar 7 at 9:54

















  • Just to nitpick: The load averages aren't percentages.

    – Kusalananda
    Mar 7 at 9:54
















Just to nitpick: The load averages aren't percentages.

– Kusalananda
Mar 7 at 9:54





Just to nitpick: The load averages aren't percentages.

– Kusalananda
Mar 7 at 9:54










2 Answers
2






active

oldest

votes


















1














tail does look for new lines, not for line chages:



-f, --follow[=descriptor]
output appended data as the file grows;


If you want to verify this behaviour for yourself, you can use this command to change a line in testfile:



while true ; do
sed "s/^.*$/$(date)/" -i testfile
sleep 1
done


You could use a wile loop to check for line changes:



while true ; do
grep -q "^[1-9]" /proc/loadavg && echo "$message"
sleep 1
done





share|improve this answer






























    0














    I think you can in conjunction use tail with grep for changes and not just new lines.



    I just read before I came here that /proc/loadavg isn't actually a file but a kernel interface and maybe you are right, but even if it could I will still be up the swanny.



    I was hoping for an inotify notification rather than the load of just constant loops but seems like computer says no.






    share|improve this answer























    • I take it that something like Nagios is not on the table for this?

      – Raman Sailopal
      Mar 7 at 10:58











    • :) maybe not as nagios is likely doing the same and polling rather than using a tail inotify Just means I can not use tail in a notification event scheme and will just have to use polling like ctx suggests

      – Stuart Naylor
      Mar 8 at 2:48











    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',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    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
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f504871%2fhow-can-use-tail-for-notifications-above-0-99-loadav%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    tail does look for new lines, not for line chages:



    -f, --follow[=descriptor]
    output appended data as the file grows;


    If you want to verify this behaviour for yourself, you can use this command to change a line in testfile:



    while true ; do
    sed "s/^.*$/$(date)/" -i testfile
    sleep 1
    done


    You could use a wile loop to check for line changes:



    while true ; do
    grep -q "^[1-9]" /proc/loadavg && echo "$message"
    sleep 1
    done





    share|improve this answer



























      1














      tail does look for new lines, not for line chages:



      -f, --follow[=descriptor]
      output appended data as the file grows;


      If you want to verify this behaviour for yourself, you can use this command to change a line in testfile:



      while true ; do
      sed "s/^.*$/$(date)/" -i testfile
      sleep 1
      done


      You could use a wile loop to check for line changes:



      while true ; do
      grep -q "^[1-9]" /proc/loadavg && echo "$message"
      sleep 1
      done





      share|improve this answer

























        1












        1








        1







        tail does look for new lines, not for line chages:



        -f, --follow[=descriptor]
        output appended data as the file grows;


        If you want to verify this behaviour for yourself, you can use this command to change a line in testfile:



        while true ; do
        sed "s/^.*$/$(date)/" -i testfile
        sleep 1
        done


        You could use a wile loop to check for line changes:



        while true ; do
        grep -q "^[1-9]" /proc/loadavg && echo "$message"
        sleep 1
        done





        share|improve this answer













        tail does look for new lines, not for line chages:



        -f, --follow[=descriptor]
        output appended data as the file grows;


        If you want to verify this behaviour for yourself, you can use this command to change a line in testfile:



        while true ; do
        sed "s/^.*$/$(date)/" -i testfile
        sleep 1
        done


        You could use a wile loop to check for line changes:



        while true ; do
        grep -q "^[1-9]" /proc/loadavg && echo "$message"
        sleep 1
        done






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 7 at 9:51









        ctxctx

        1,749515




        1,749515























            0














            I think you can in conjunction use tail with grep for changes and not just new lines.



            I just read before I came here that /proc/loadavg isn't actually a file but a kernel interface and maybe you are right, but even if it could I will still be up the swanny.



            I was hoping for an inotify notification rather than the load of just constant loops but seems like computer says no.






            share|improve this answer























            • I take it that something like Nagios is not on the table for this?

              – Raman Sailopal
              Mar 7 at 10:58











            • :) maybe not as nagios is likely doing the same and polling rather than using a tail inotify Just means I can not use tail in a notification event scheme and will just have to use polling like ctx suggests

              – Stuart Naylor
              Mar 8 at 2:48















            0














            I think you can in conjunction use tail with grep for changes and not just new lines.



            I just read before I came here that /proc/loadavg isn't actually a file but a kernel interface and maybe you are right, but even if it could I will still be up the swanny.



            I was hoping for an inotify notification rather than the load of just constant loops but seems like computer says no.






            share|improve this answer























            • I take it that something like Nagios is not on the table for this?

              – Raman Sailopal
              Mar 7 at 10:58











            • :) maybe not as nagios is likely doing the same and polling rather than using a tail inotify Just means I can not use tail in a notification event scheme and will just have to use polling like ctx suggests

              – Stuart Naylor
              Mar 8 at 2:48













            0












            0








            0







            I think you can in conjunction use tail with grep for changes and not just new lines.



            I just read before I came here that /proc/loadavg isn't actually a file but a kernel interface and maybe you are right, but even if it could I will still be up the swanny.



            I was hoping for an inotify notification rather than the load of just constant loops but seems like computer says no.






            share|improve this answer













            I think you can in conjunction use tail with grep for changes and not just new lines.



            I just read before I came here that /proc/loadavg isn't actually a file but a kernel interface and maybe you are right, but even if it could I will still be up the swanny.



            I was hoping for an inotify notification rather than the load of just constant loops but seems like computer says no.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Mar 7 at 10:01









            Stuart NaylorStuart Naylor

            11




            11












            • I take it that something like Nagios is not on the table for this?

              – Raman Sailopal
              Mar 7 at 10:58











            • :) maybe not as nagios is likely doing the same and polling rather than using a tail inotify Just means I can not use tail in a notification event scheme and will just have to use polling like ctx suggests

              – Stuart Naylor
              Mar 8 at 2:48

















            • I take it that something like Nagios is not on the table for this?

              – Raman Sailopal
              Mar 7 at 10:58











            • :) maybe not as nagios is likely doing the same and polling rather than using a tail inotify Just means I can not use tail in a notification event scheme and will just have to use polling like ctx suggests

              – Stuart Naylor
              Mar 8 at 2:48
















            I take it that something like Nagios is not on the table for this?

            – Raman Sailopal
            Mar 7 at 10:58





            I take it that something like Nagios is not on the table for this?

            – Raman Sailopal
            Mar 7 at 10:58













            :) maybe not as nagios is likely doing the same and polling rather than using a tail inotify Just means I can not use tail in a notification event scheme and will just have to use polling like ctx suggests

            – Stuart Naylor
            Mar 8 at 2:48





            :) maybe not as nagios is likely doing the same and polling rather than using a tail inotify Just means I can not use tail in a notification event scheme and will just have to use polling like ctx suggests

            – Stuart Naylor
            Mar 8 at 2:48

















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • 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%2funix.stackexchange.com%2fquestions%2f504871%2fhow-can-use-tail-for-notifications-above-0-99-loadav%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

            Peggy Mitchell

            Palaiologos

            The Forum (Inglewood, California)