TIME NOW
World current time now,
CALENDAR
Calendar monthly, yearly
login CONVERT LENGTH
login CONVERT TEMPERATURE
login DICTIONARIES, LISTS
login SCIENCE EDUCATION RELIGION
login WORK CALCULATOR
login CALCULATE LIFE

Linux commands, scripts, examples, tutorial

Previous articlePage bottomNext article  ALL TOPICS

Linux. Web Server, connections monitoring script:

 
Simple script to monitor HTTP web server connections. It is launched using CRON service every minute:
#!/bin/bash

data=`date +'%m-%d %T'`
folder='/_scripts/_logs'
file1='apache_netstat.txt'
file2='apache_limit.txt'


a=` netstat -tn | grep :80 | grep -v TIME_WAIT | grep -v FIN_WAIT2 | wc -l `

#echo 1

if [ $a -ge 1 ]  # usual traffic
then
echo  "$data  $a " >> $folder/$file1 2>/dev/null
fi

#echo 2

if [ $a -ge 10  ] # dangerous traffic
then

echo  "$data"                  >> $folder/$file2 2>/dev/null
echo $a                        >> $folder/$file2 2>/dev/null
free -m | grep Mem | awk ' { print $3 }' >> $folder/$file2 2>/dev/null
uptime | awk '{ print $10 , $11, $12 }'  >> $folder/$file2 2>/dev/null
echo '------------------------'         >> $folder/$file2 2>/dev/null

fi

#echo 3

exit 0
 
 
Previous articlePage topNext article  ALL TOPICS



 Use username: Guest, Anonymous, Programmer






QUOTES:
Passions spin the plot: We are betrayed by what is false within.
George Meredith
I like to listen. I have learned a great deal from listening carefully. Most people never listen.
Ernest Hemingway
It's your unlimited power to care and to love that can make the biggest difference in the quality of your life.
Anthony Robbins