• bash script

    From Spectre@21:3/101 to Anybody on Saturday, January 18, 2020 09:50:00
    load=`echo $(cat /proc/loadavg | awk '{print $1}') \> 8 | bc -l`
    echo "SABRETOOTH! Your Server Load Alert Needs Attention! " | mail -s
    "System Load Alert $load" spectre@tlp.zapto.org

    Can anyone riddle me why the current load avg doesn't make it into the alert email? $load isn't printing... thats nominally all one line, its just
    wrapped at 80 cols here.

    Spec


    --- SuperBBS v1.17-3 (Eval)
    * Origin: (21:3/101)
  • From Spectre@21:3/101 to tenser on Saturday, January 18, 2020 16:11:00
    load=`echo $(cat /proc/loadavg | awk '{print $1}') \> 8 | bc -l`
    if [ "$load" -ne 0 ]; then

    This will make more sense, but I didn't realise what it was all doing at the time, and I left the logic operation out.

    Somehow in a fashion I don't completely understand renders the question a binary one, 1 or 0, which is why the loadavg is never printed at least not a way I recognised.

    Looking at your logic, I would be guessing in some way the cat can still be removed and it was a foible of whoever wrote it. I tend to do it that way
    too, I'm more used to redirection than what individial commands can do.

    I still don't quite get this though.

    awk '{print $1}') \> 8

    and how that becomes print if > 8..

    and bc is rendering the integer.

    In order to get what I was looking for, the actual load average into the message, I had to re-read "/proc/loadavg"

    Thanks for your time, and explanation.

    Spec


    --- SuperBBS v1.17-3 (Eval)
    * Origin: (21:3/101)
  • From Spectre@21:3/101 to Anybody on Saturday, January 18, 2020 09:50:00
    load=`echo $(cat /proc/loadavg | awk '{print $1}') \> 8 | bc -l`
    echo "SABRETOOTH! Your Server Load Alert Needs Attention! " | mail -s
    "System Load Alert $load" spectre@tlp.zapto.org

    Can anyone riddle me why the current load avg doesn't make it into the alert email? $load isn't printing... thats nominally all one line, its just wrapped at 80 cols here.

    Spec


    --- SuperBBS v1.17-3 (Eval)
    * Origin: (21:3/101)
  • From Spectre@21:3/101 to Anybody on Saturday, January 18, 2020 09:50:00
    load=`echo $(cat /proc/loadavg | awk '{print $1}') \> 8 | bc -l`
    echo "SABRETOOTH! Your Server Load Alert Needs Attention! " | mail -s
    "System Load Alert $load" spectre@tlp.zapto.org

    Can anyone riddle me why the current load avg doesn't make it into the alert email? $load isn't printing... thats nominally all one line, its just wrapped at 80 cols here.

    Spec


    --- SuperBBS v1.17-3 (Eval)
    * Origin: (21:3/101)
  • From Spectre@21:3/101 to tenser on Saturday, January 18, 2020 16:11:00
    load=`echo $(cat /proc/loadavg | awk '{print $1}') \> 8 | bc -l`
    if [ "$load" -ne 0 ]; then

    This will make more sense, but I didn't realise what it was all doing at the time, and I left the logic operation out.

    Somehow in a fashion I don't completely understand renders the question a binary one, 1 or 0, which is why the loadavg is never printed at least not a way I recognised.

    Looking at your logic, I would be guessing in some way the cat can still be removed and it was a foible of whoever wrote it. I tend to do it that way too, I'm more used to redirection than what individial commands can do.

    I still don't quite get this though.

    awk '{print $1}') \> 8

    and how that becomes print if > 8..

    and bc is rendering the integer.

    In order to get what I was looking for, the actual load average into the message, I had to re-read "/proc/loadavg"

    Thanks for your time, and explanation.

    Spec


    --- SuperBBS v1.17-3 (Eval)
    * Origin: (21:3/101)
  • From Spectre@21:3/101 to tenser on Saturday, January 18, 2020 16:11:00
    load=`echo $(cat /proc/loadavg | awk '{print $1}') \> 8 | bc -l`
    if [ "$load" -ne 0 ]; then

    This will make more sense, but I didn't realise what it was all doing at the time, and I left the logic operation out.

    Somehow in a fashion I don't completely understand renders the question a binary one, 1 or 0, which is why the loadavg is never printed at least not a way I recognised.

    Looking at your logic, I would be guessing in some way the cat can still be removed and it was a foible of whoever wrote it. I tend to do it that way too, I'm more used to redirection than what individial commands can do.

    I still don't quite get this though.

    awk '{print $1}') \> 8

    and how that becomes print if > 8..

    and bc is rendering the integer.

    In order to get what I was looking for, the actual load average into the message, I had to re-read "/proc/loadavg"

    Thanks for your time, and explanation.

    Spec


    --- SuperBBS v1.17-3 (Eval)
    * Origin: (21:3/101)