Archive for July 28th, 2004
Managing SARG
One of my tasks in my new job is to monitor network usage, including internet access. The workplace implements Webmin authentication for the Squid proxy, i.e. users have to give their usernames and passwords before being allowed to access the internet.
Lately, though, there have been reports of password-sharing and visiting of banned (read: pr0n and warez) sites. Monitoring was limited to user authentication, so in this case it wasn’t enough. SARG to the rescue. I configured SARG to generate daily, weekly and monthly reports. I was surprised, though, at the sizes of the files it generated. Besides, I had no way of displaying the reports because the proxy server did not have a web server, and not even a browser. I also did not have physical access to the server, except through SSH. SARG was configured to output the daily reports to my home directory. From there, I can view individual HTML files but after a while, this seemed cumbersome. So I thought: why not write a script to compress the outputs and have the gzip’d files mailed to me? Hence, this script:
#!/bin/bash
#
# This script compresses daily reports
# generated by SARG.
# Created 28 July 2004 by iandexter[at]gmail[dot]com
# Program paths
TAR=/bin/tar
GZIP=/bin/gzip
# I have to tar the files in their respective
# directories first so the paths
# from the SARG-generated “index.html” are preserved.
echo “Compressing sarg.daily reports…”
# Get input dates in the form. Do some swapping,
# if necessary.
first_day=$1
last_day=$2
month=$3
year=$4
# This is specific to my configuration: the output
# directories are in the form,
# ddMMYYYY-ddMMYYYY
if [ $first_day -gt $last_day ]
then
tmp=$first_day
first_day=$last_day
last_day=$tmp
fi
# Run through the dates
for i in `seq $first_day 1 $last_day`
do
tar_file=${i}${month}${year}
dir=${tar_file}-${tar_file}
$TAR -cf ${tar_file}.tar ${dir}/ | $GZIP -9 ${tar_file}.tar
done
echo “Done.”
chmod u+x the script.)
Ready to get stolen
Here’s an update on the antipixel-type buttons I posted here: they’re now part of gtmcknight.com’s “More buttons to steal”. W00t! So go ahead, steal them already.
Mounting a USB flash drive
USB flash drives — the ubiquituous thingies that look a lot like keychains around people’s necks nowadays — are mounted much like SCSI disks in Linux. They are usually detected at boot up or when inserted, provided the proper modules are installed. So:
- Make sure the USB storage module is installed:
# modprobe usb-storage
- Once that’s done, and your USB drive is recognized, try to look up the device either in
dmesgor# tail /var/log/messagesIt should be something like “/dev/sda1“. - Mount it the usual way:
# mount /dev/sdax /mnt/<your mountpoint>
- Or, if you want to avoid having to
sudoevery time you access the drive, edit your/etc/fstabto contain the following:/dev/sda1 /mnt/usb vfat noauto,rw,user 0 0Create a mount directory andchownit, thenmountandunmountthe drive the normal way.
01000111 01101111 00100000 01100110 01101111 01110010 01110100 01101000 00101110 00101110 00101110
00100111 01010100 01101000 01100101 01110010 01100101 00100000 01100001 01110010 01100101 00100000 00110001 00110000 00100000 01110000 01100101 01101111 01110000 01101100 01100101 00100000 01101001 01101110 00100000 01110100 01101000 01100101 00100000 01110111 01101111 01110010 01101100 01100100 00111010 00100000 01110100 01101000 01101111 01110011 01100101 00100000 01110111 01101000 01101111 00100000 01100011 01100001 01101110 00100000 01110010 01100101 01100001 01100100 00100000 01100010 01101001 01101110 01100001 01110010 01111001 00101100 00100000 01100001 01101110 01100100 00100000 01110100 01101000 01101111 01110011 01100101 00100000 01110111 01101000 01101111 00100000 01100100 01101111 01101110 00100111 01110100 00101110 00100111
