Author: Josh

  • Apache 2.2 – Return 200 OK for missing images

    I recently faced a problem where I needed to configure Apache to return a 200 OK when it received a request for an image that was missing, along with a custom 404 ErrorDocument which was an image. The reason for this requirement is that when Outlook 2003/2007 displays an HTML page where an image request […]

  • Reporting search referrals

    Here is a quick awk command that will parse apache web logs and print a simple virtual host/date/referral csv report that only includes referrals from google, bing, or yahoo: awk ‘tolower($11) ~ “google|bing|yahoo” {print $2 “,” $4 “,” $11}’ ${input_file} >> report.csv

  • Linux guest hangs at “starting udev” (VMware vSphere)

    Having recently upgraded the Virtual Infrastructure at work to vSphere, I have encountered many scenarios with CentOS 5.3 guests not booting or taking a long time to boot. The last message on the console typically indicates that it’s hanging while starting udev. The fix for this issue is to ensure proper time keeping practices have […]

  • Expanding an ext3 filesystem online

    One common scenario that I face in my daily work is to add disk to various filesystems. Setting up systems correctly so that this is possible will save time and frustration. One of the easiest cases is adding disk to a virtual machine when the guest is using LVM and ext3. As always, please be […]

  • Fedora 12 – Disable mouse focus

    One problem that I’ve had with Fedora 12 is that when enabling compliz the focus starts to follow the mouse pointer. This behavior is annoying to me as I don’t like events to occur unless I explicitly ask for them (aka click). To disable this feature, perform the following: 1. install control-center-extra 2. Open with […]

  • Bash Tips – Parse mail logs for used mail boxes

    I was auditing a set of mail servers at work the other day getting a list of all active user accounts and developed this little one liner: zgrep LOGIN /var/log/mail.log.[1-9].gz | sed -n ‘s/.*user=\(.*\), ip.*/\L\1/p’ | sort | uniq >> /tmp/mailbox.list This script finds all logins from the mail log and prints out only the […]

  • MySQL /tmp Usage with Optimize Table Command

    I’m currently trying to prune a MyISAM table with 200 million rows down to 100 million rows. As part of this process, I am simply removing any orphaned records. This is a simple tracking table where every record must have an associated record in the users table. The total size on disk is 11G of […]

  • Command line replace with perl

    I often run into issues on the command line where I’d like to perform a non-greedy search and replace. This is not possible with sed, grep, or egrep, AFAIK, so I must resort to perl. Here is how it’s done: perl -pe ‘s|”http://(.*?)/.*$|$1|g’ The above example will take a list of requested URIs or search […]

  • Apache – Getting rid of (internal dummy connection) in the logs.

    On busy sites the (internal dummy connection) message in apache logs can be a major annoyance as it fills the logs. A simple way to filter this out is to use the following log declarations (assuming IPV6 capable host): SetEnvIf Remote_Addr “::1” dontlog CustomLog /var/log/httpd/access_log combined env=!dontlog RE: http://wiki.apache.org/httpd/InternalDummyConnection

  • Decode base64 text using perl from the command line

    I recently ran into an issue where I needed to decode some base64 text from the command line and used perl to manage the task: perl -MMIME::Base64 -ne ‘print decode_base64($_)’ < /tmp/input.txt RE: http://perldoc.perl.org/MIME/Base64.html