Re: Question on Bash Shell Script for Load Performance Monitoring

From: Chris (chrish_at_po.wr.com)
Date: 10/26/04

  • Next message: Paul Lutus: "Re: Question on Bash Shell Script for Load Performance Monitoring"
    Date: 26 Oct 2004 13:06:55 -0700
    
    

    aixenv@yahoo.com (aixenv) wrote in message news:<d687f0.0410240647.67e55eb4@posting.google.com>...
    > I am writing a script to monitor a server which has halted at a
    > strange hour with no visible reason, I have reason to suspect it could
    > be a runaway qmail process or the system is just getting under heavy
    > load, or both.
    >
    > SO I wrote the following script, it works, it just seems very
    > "sloppy", and I was just curious how else I could accomplish the same
    > goal.
    >
    > Also i thought of emailing the output of /tmp/srvload.log to an email
    > address and thought it might be nice to sort newest entries in
    > /tmp/srvload.log to the beginning of the file versus appending them to
    > the end of the file. however i am unclear how to proceed and
    > accomplish this goal
    >
    > any assistance would be appreciated, below is said script.
    >
    > #!/bin/bash
    >
    > while
    > true
    > do
    > echo "" >> /tmp/srvload.log
    > echo "#############################" >> /tmp/srvload.log
    > echo "" >> /tmp/srvload.log
    > echo "The current time is `date`" >> /tmp/srvload.log
    > echo "" >> /tmp/srvload.log
    > echo "- Current system load average" >> /tmp/srvload.log
    > uptime >> /tmp/srvload.log
    > echo "" >> /tmp/srvload.log
    > echo "- The number of current qmail processes" >> /tmp/srvload.log
    > ps aux|grep qmail|wc -l >> /tmp/srvload.log
    > echo "" >> /tmp/srvload.log
    > echo "- The current number of Messages in the queue">>
    > /tmp/srvload.log
    > qmail-qstat >> /tmp/srvload.log
    > echo "" >> /tmp/srvload.log
    > echo "#############################" >> /tmp/srvload.log
    > echo "" >> /tmp/srvload.log
    > sleep 300
    > done
    >
    > The mail script would be like so, perhaps there is a way to combine
    > both of these into 1 script
    >
    > #!/bin/bash
    >
    > while
    > true
    > do
    > echo "`cat /tmp/srvload.log`" | mail -s "Sysload.sh output"
    > myemail@mydomain.com
    > sleep 1800
    > done
    >
    > thank you
    >
    > aix

    COUNTER=`cat /tmp/srvload.log |wc -l`

    while [ $COUNTER -ge "0" ]
      do
        awk "NR==$COUNTER" /tmp/srvload.log >> /tmp/reverse.log
        let COUNTER-=1
      done

    mail -s "Sysload.sh output" myemail@mydomain.com < /tmp/reverse.log

    There's probably a single command somewhere that cats the file in
    reverse; but I haven't crossed paths with it.

    Regards,
    Chris


  • Next message: Paul Lutus: "Re: Question on Bash Shell Script for Load Performance Monitoring"

    Relevant Pages