How can use tail for notifications above 0.99% loadav?

Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom: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]
tail
add a comment |
#!/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
Just to nitpick: The load averages aren't percentages.
– Kusalananda♦
Mar 7 at 9:54
add a comment |
#!/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
#!/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
tail
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
add a comment |
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
add a comment |
2 Answers
2
active
oldest
votes
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
add a comment |
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.
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
add a comment |
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
);
);
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
Required, but never shown
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
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
add a comment |
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
add a comment |
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
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
answered Mar 7 at 9:51
ctxctx
1,749515
1,749515
add a comment |
add a comment |
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.
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
add a comment |
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.
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
add a comment |
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.
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.
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
add a comment |
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
add a comment |
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.
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
Required, but never shown
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
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
Required, but never shown
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
Required, but never shown
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
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
Just to nitpick: The load averages aren't percentages.
– Kusalananda♦
Mar 7 at 9:54