Monitor Web Traffic From Linux Bash
Page 1 of 1
Monitor Web Traffic From Linux Bash
Use freq of time for example 60 seconds!
I came across this on google search and wanted to try it out
Code Update Link For Example
app.box.com/s/y3agimth51ceh8b7n4e8tw8rps29qxy9
- Code:
#!/bin/sh
#
# ./run.sh -f 60 -l /var/log/apache2/access.log
#
# ./run.sh -f 60 -l 1.txt
#
# /var/log/apache2/access.log
#
##############################################################################
# This script will monitor the number of lines in a log file to determine the
# number of requests per second.
#
# Example usage:
# reqs-per-sec -f 15 -i /var/www/http/access.log
#
# Author: Adam Franco
# Date: 2009-12-11
# License: http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
##############################################################################
#
# ./run.sh -f 60
#l='/var/log/apache2/access.log'
usage="Usage: `basename $0` -f <frequency in seconds, min 1, default 60> -l <log file>"
# Set up options
while getopts ":l:f:" options; do
case $options in
l ) logFile=$OPTARG;;
f ) frequency=$OPTARG;;
\? ) echo -e $usage
exit 1;;
* ) echo -e $usage
exit 1;;
esac
done
# Test for logFile
if [ ! -n "$logFile" ]
then
echo -e $usage
exit 1
fi
# Test for frequency
if [ ! -n "$frequency" ]
then
frequency=60
fi
# Test that frequency is an integer
if [ $frequency -eq $frequency 2> /dev/null ]
then
:
else
echo -e $usage
exit 3
fi
# Test that frequency is an integer
if [ $frequency -lt 1 ]
then
echo -e $usage
exit 3
fi
if [ ! -e "$logFile" ]
then
echo "$logFile does not exist."
echo
echo -e $usage
exit 2
fi
lastCount=`wc -l $logFile | sed 's/\([0-9]*\).*/\1/'`
while true
do
newCount=`wc -l $logFile | sed 's/\([0-9]*\).*/\1/'`
diff=$(( newCount - lastCount ))
rate=$(echo "$diff / $frequency" |bc -l)
echo $rate
lastCount=$newCount
sleep $frequency
done
From stackoverflow.com/questions/345546/how-to-get-requests-per-second-for-apache-in-linux
Last edited by jamied_uk on 1st October 2016, 14:25; edited 1 time in total
Re: Monitor Web Traffic From Linux Bash
Also I Found This
You can use the formatting switches as follows:
You can mix and match the switches as required.
If you want to add a new line as part of the format string use the newline character as follows:
You can mix and match the switches as required.
If you want to add a new line as part of the format string use the newline character as follows:
linux.about.com/od/commands/fl/Run-A-Command-And-Return-Time-Statistics-Using-The-time-Command.htm
You can use the formatting switches as follows:
You can mix and match the switches as required.
If you want to add a new line as part of the format string use the newline character as follows:
- Code:
time -f "Elapsed Time = %E, Inputs %I, Outputs %O" <command>
You can mix and match the switches as required.
If you want to add a new line as part of the format string use the newline character as follows:
- Code:
time -f "Elapsed Time = %E \n Inputs %I \n Outputs %O" <command>
linux.about.com/od/commands/fl/Run-A-Command-And-Return-Time-Statistics-Using-The-time-Command.htm
Re: Monitor Web Traffic From Linux Bash
Even More
google.co.uk/#safe=off&q=linux+time+command
google.co.uk/#safe=off&q=using+bash+script++to+find+decent+rate+from+travel+time
google.co.uk/#safe=off&q=linux+time+command
google.co.uk/#safe=off&q=using+bash+script++to+find+decent+rate+from+travel+time
Similar topics
» FTP Files From Linux With Bash
» Calculating Pi With Bash On Linux
» Get wifi net working after monitor mode on kali linux
» Bash Psychic Game For Linux Bash
» Linux BASH Script Running Commands and Functions From Bash Script and saving to varables
» Calculating Pi With Bash On Linux
» Get wifi net working after monitor mode on kali linux
» Bash Psychic Game For Linux Bash
» Linux BASH Script Running Commands and Functions From Bash Script and saving to varables
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum