Capture the data in Linux .While doing load test.

Hi All,

I am trying to capture the data in linux .While doing load test.
is there's any sample script please help me.

Linux test4 2.6.18-308.8.1.el5 #1 SMP Fri May 4 16:43:02 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux

Thanks,

Not sure if this is what you're looking for - you could redirect the output to a file, if you want it for posterior use.

$ command arguments > file

Please provide more details.. inputs, data samples, desired output..

Hi Balajesuri,

When we are doing the load test. script has to capture the data and save it some xxx location. After the load test i have to send other developer .

if the load is high it has to send alert to mail. is there's any sample script available.

i am a new bie to scripting.

Thanks,

Basic one to check load:

#!/bin/bash

LOAD_VALUE=`cat /proc/loadavg | sed 's/\./ /' | awk '{print $1}'`

if [ $LOAD_VALUE -gt "6" ]; then
       mail -s �PANIC� someone@somedomain.com
fi

Replace the value "6" for one that apply to you.

Thank you so much braniak.

I have a small doubt how to capture the data while performing the load test. I have to review the captured data later

Regards,

As I said, this is a simple way to do it, and it's not sofisticated at all.. :stuck_out_tongue:

In your main script, that will execute some sort of commands, put the "touch" command at the beginning, execute the load.sh in background and put the "rm -rf" at the end:

#!/bin/bash

touch /tmp/load.pid # Create the "control" file.

./load.sh & # Execute the load.sh in background.

comandos(){
ls
sleep 5
ls -lhtr
sleep 5
}

comandos

sleep 1

comandos

rm -rf /tmp/load.pid # Remove the "control" file.

exit 0

Then, create the load.sh like this:

#!/bin/bash

while [ -e /tmp/load.pid ]
        do
        LOAD_VALUE=`cat /proc/loadavg | sed 's/\./ /' | awk '{print $1}'`

                if [ $LOAD_VALUE -gt "6" ]; then
                        echo "`date` - $LOAD_VALUE" >> load.log
                        mail -s "PANIC" someone@somedomain.com
                        exit 1
                else
                        echo "`date` - $LOAD_VALUE" >> load.log
                fi
        sleep 5
        done
exit 0