• About Binary Impulse
  • BashBytes
Binary Impulse

Tag Archives: Testing

Web filter testing…

February 27, 2013 4:27 PM / Leave a Comment / Dan

We have been having filtering issues at work.  The only pattern I can see is that upon heavy Internet use (40+Mb) the filtering services have a hard time keeping up.  The problem is that Internet usage is impossible to predict so calling support and trying to reproduce the problem is nearly impossible.  Assuming I can get through at the time it is happening, by the time I update the support personnel on the other end of the phone, it usually starts working again.

Instead of fighting this problem further I came up with a quick script to see how often it really isn’t working, and record my results.

A script that loops though and hits a blocked page every ‘X’ seconds and then parses the HTML results to see if the redirect or block page was served.  This should show my reliability of our web filter during the day without detrimenting any network performance.  I whipped together a quick and dirty script with some functions from my other scripts.  It should do the trick.

#!/bin/bash
#######################################################
# Script created to test web filter's reliability
# It polls a webpage that is supposed to be blocked.
#
#                               Dan Kane
#######################################################

# Web filter Server IP or unique text found in the block page html
WebServer="10.9.1"

# just zeroing the counters
blockedcounter=0

# just zeroing the counters
allowedcounter=0

# Log file location
logfile="/var/log/webfilter.log"

# Blocked url
blockurl="facebook.com"

# used for my output module to show debug information
debug="1"

# used for my output module to log everything
log="1"

# sleep through the loop or go as fast as we can?
sleep="1"

#######################################################
#FUNCTIONS
#

#used for debug and logging
output(){
        if [ $debug -eq "1" ];
        then
                /bin/echo `/bin/date +"%m-%d-%Y %r"`:  $@
        fi
        if [ $log -eq "1" ];
        then
                /bin/echo `/bin/date +"%m-%d-%Y %r"` :  $@ >> $logfile
        fi
}

onexit(){
        echo "didnt work $allowedcounter   :::   worked $blockedcounter"; exit
        exit
}

#######################################################
# CODE
#

# catch traps and show results
trap "onexit" SIGINT > /dev/null

# Enter our 1 second loop
while :
do
        website=$(wget -qO- $blockurl)
        found=$(echo $website | grep $WebServer | wc -l)
        if [ $found -lt 1 ];
        then
                allowedcounter=$(( $allowedcounter + 1 ))
                output "Page NOT blocked  ---  didnt work $allowedcounter   :::   worked $blockedcounter"
        else
                blockedcounter=$(( $blockedcounter + 1 ))
                output "Page blocked  ---   didnt work $allowedcounter   :::   worked $blockedcounter"
        fi
        if [ $sleep -eq "1" ];
        then
                sleep 1
        fi
done

We will start recording the results and see what else we can find out.  If the amount of data we are inserting is too much, maybe insert results into MySQL is in order, but we will see what we find first.

Posted in: How-To's / Tagged: scripts, testing, web filter, web fitler testing

Pages

  • About Binary Impulse
  • BashBytes

Recent Posts

  • My UBook X Linux Tablet Adventure and how I learned more than I ever thought I would need to know about accelerometer drivers
  • Migrating Proxmox Hypervisor’s Boot Volume ZFS Mirror To New (Smaller) Disks
  • OPNsense Performance Tuning for Multi-Gigabit Internet
  • Reddit Deplatforms Popular Microsoft Software Swap Subreddit
  • Comcast Upgrades Gigabit Pro from 3Gbps to 6Gbps!
May 2025
M T W T F S S
 1234
567891011
12131415161718
19202122232425
262728293031  
« Apr    

Recent Comments

  • jasonistre on OPNsense Performance Tuning for Multi-Gigabit Internet
  • Nick on OPNsense Performance Tuning for Multi-Gigabit Internet
  • Kirk Schnable on OPNsense Performance Tuning for Multi-Gigabit Internet
  • nick on OPNsense Performance Tuning for Multi-Gigabit Internet
  • Eric on My UBook X Linux Tablet Adventure and how I learned more than I ever thought I would need to know about accelerometer drivers

Categories

  • How-To's
  • Humorous
  • Musings
  • Newsworthy
  • Other

Meta

  • Register
  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
© Copyright 2025 - Binary Impulse
Infinity Theme by DesignCoral / WordPress