[Snort-users] Re: Snort-users digest, Vol 1 #1522 - 12 msgs

Fernando Miguelez Palomo jtbmipaf at ...4632...
Fri Jan 25 17:07:32 EST 2002


We use top in batch mode:
top i b d 1 > datafile

And then process it with the attached script:
./sacamed datafile

You will need to install rascal (a shell scientific calculator), which can 
be found in:
http://rascal.sourceforge.net

Regards, 
Fernando

===========================================================================
#!/bin/bash
# Program: sacamed
# Written by Fernando Miguélez Palomo

NUM_LIN=`cat $1 | grep CPU[0-9] | wc -l`

echo "Number of lines is: $NUM_LIN"

CONT=1

TOTAL_USER=0
TOTAL_SYS=0

while [ $CONT -le $NUM_LIN ]
do
    TEMP=`cat $1 | grep CPU[0-9] | sed -n "$CONT"p | sed "s/  */ /g" | cut 
-f 3 -d " " | cut -d "%" -f 1 | sed "s/,/./g"`
    TOTAL_USER=`rascal -e "$TOTAL_USER + $TEMP" | grep -v rascal`
    TEMP=`cat $1 | grep CPU[0-9] | sed -n "$CONT"p | sed "s/  */ /g" | cut 
-f 5 -d " " | cut -d "%" -f 1 | sed "s/,/./g"`
    TOTAL_SYS=`rascal -e "$TOTAL_SYS + $TEMP" | grep -v rascal`
    CONT=`expr $CONT + 1`
done

echo "Total user: $TOTAL_USER"
echo "Total system: $TOTAL_SYS"

MED_USER=`rascal -nq -e "$TOTAL_USER / $NUM_LIN * 1.0"`
MED_SYS=`rascal -nq -e "$TOTAL_SYS / $NUM_LIN * 1.0"`

echo "Average user rate: $MED_USER"
echo "Average system rate: $MED_SYS"






More information about the Snort-users mailing list