Archive for the ‘Work’ Category

Monitor a specific packet type with tcpdump

Thursday, April 2nd, 2009

tcpdump is a powerful network traffic dump utility. Here’s an example of how to use it to watch for a specific packet type on a specific interface.

Print SYN but not SYN ACK packets
$ tcpdump -nn -i eth0 ‘tcp[13] & 0×12=0×02′

Print SYN or SYN ACK packets
$ tcpdump -nn -i eth0 ‘tcp[13] & 0×02=0×02′

Print FIN packets
$ tcpdump -nn -i eth0 ‘tcp[13] & 0×01=0×01′

Here’s a breakdown of how the previous commands work.

-nn Don’t convert host addresses or port numbers to names

-i eth0 Listen on interface

proto [ byte offset: size ]

Available proto (protocol) layers: ether, fddi, tr, wlan, ppp, slip, link, ip, arp, rarp, tcp, udp, icmp, ip6 or radio.

Size (optional values: one, two, or four) defaults to one, and indicates the number of bytes for comparison.

Example: $ tcpdump -nn -i eth0 ‘tcp[13] & 0×12=0×02′

tcp[13] says use the data (one byte) inside the packet using the tcp protocol layer at byte offset 13 for comparison.”

& 0×12=0×02 says execute a bitwise AND operation against the bits 0001 0010 and match on the bits 0000 0010. It’s important to bitmask at least down to the control bits which reside at 0×3f or 0011 1111, as we are not interested in the presence of ECN bits (which contain ECE and CWR), and they may manipulate our comparison results.

& 0×3f=0×02 is more thorough than 0×12=0×02 (because it checks all of the control bits (0011 1111) rather than just 0001 0010) and can be used in its place. You can use the decimal value for the right side of the comparison (eg. 0×12=2), but I find it helpful to use the Hex value as you’re already using a Hex value for the bitmasking.

It should be noted that you can also use the available TCP flags field values: tcp-fin, tcp-syn, tcp-rest, tcp-push, tcp-ack, tcp-urg.

Print SYN but not SYN ACK packets
$ tcpdump -nn ‘tcp[tcpflags] & tcp-syn != 0 and tcp[tcpflags] & tcp-ack = 0′

But that’s not nearly as fun, right?

References:
TCP Header
Hexadecimal
Mask (computing)

Microsoft Office Outlook 2007

Thursday, April 2nd, 2009

Microsoft Office Outlook 2007. It's not that scary.

With our recent transition to the MeritMail collaboration suite, we deprecated our campus Meeting Maker service. As a result, I lost the fat client I had grown fond of over the last three years. I am not saying Meeting Maker is a gem, but I had learned to appreciate the ability to manage my calendar without the uncertainty of a typical AJAX interface.

After giving the web client a respectable chance, I was provoked by a colleague to try Outlook 2007. Fast forward a few months, and I’m loving it. The Calendar and Task integration is wonderful. Need to flag a message for follow-up? Click the little flag to the right of the “Subject” line. A list of tasks is then compiled in a To-Do Bar, which contains a handy view of the current month, my upcoming calendar events, and my incomplete tasks.

This entire experience has been chilling for me as I am not a Microsoft fan-boy, and am typically a big proponent of Open Source Software. I would have laughed had told me a few years ago that I would be using Outlook as my primary email / calendar / task management software.

Six months of happenings

Thursday, February 19th, 2009

Over six months has passed since my last update. Instead of describing the happenings, I have included pictures and some brief captions. Note that these events are not necessarily in chronological order.

I rode in mustang and pace cars around the track at the Las Vegas Speedway.
Mustang ride at the Las Vegas Speedway
Pace car ride at the Las Vegas Speedway

It got really cold. I got a nasty cold.
17 below zero Fahrenheit.

It snowed a lot.
Lots of snow on my truck.

I saw a moose.
A moose.

We had water damage in our house. Presumably from the weight of the snow on the roof.
Water damage from the heavy snow on my roof.

  • I attended VMworld 2008 in Las Vegas.
  • I am now a Senior Programmer / Analyst for ITSS.
  • I am taking a Pre-Calculus class.
  • D & I started cross country skiing.
  • I am using Outlook 2007.
  • DTM has posted 8 times.
  • I’m reading “Managing Humans”.
  • My gmail thread surpassed 20,000 messages.

Windows PowerShell Execution Policies

Wednesday, May 28th, 2008

Windows Powershell sets its Execution Policy to Restricted by default, which states that PowerShell can only be used in interactive mode (no scripts will run.) Use the Get-ExecutionPolicy cmdlet to check which execution policy is currently in-force.

$ Get-ExecutionPolicy

The following execution policy definitions are from Microsoft’s website:

  • Restricted – No scripts can be run. Windows PowerShell can be used only in interactive mode.
  • AllSigned – Only scripts signed by a trusted publisher can be run.
  • RemoteSigned – Downloaded scripts must be signed by a trusted publisher before they can be run.
  • Unrestricted – No restrictions; all Windows PowerShell scripts can be run.

To change the execution policy, use Set-ExecutionPolicy. The following will enable you to execute all PowerShell scripts.

$ Set-ExecutionPolicy Unrestricted

Windows PowerShell - Recursively delete files and directories modified more than ‘n’ days ago.

Thursday, May 22nd, 2008

I was recently tasked with writing a script that recursively deletes files and directories modified more than ‘n’ days ago - here’s the kicker - using Windows. Many people have accomplished this with long VB Scripts. I was hoping for a much cleaner solution, and decided to try Windows PowerShell . I am quite impressed with Windows Powershell’s capabilities.

The following script recursively deletes files and directories modified more than 16 days ago.

# prune.ps1
$sticky = (Get-date).AddDays(-16)
$backupDir = "B:\backup"
echo "Recursively deleting files and directories written before $sticky"
Get-ChildItem $backupDir -Recurse | Where-Object { $_.LastWriteTime -lt $sticky } | Remove-Item -Recurse

Note that you can change Remove-Item -Recurse to Remove-Item -Whatif to “pretend” to delete files, and display potential deletes on STDOUT. You can also specify Remove-Item -Confirm.

I created a scheduled task that runs a .bat file containing the following:
powershell.exe c:\scripts\prune.ps1 >> c:\scripts\logs\prune.log

To watch and or view the output of the script, specify the -noexit switch on the command line.
powershell.exe -noexit c:\scripts\prune.ps1

How to install NVIDIA drivers with Fedora 9

Tuesday, May 20th, 2008

Update: The current (173.14.09) stable NVIDIA driver works with Fedora 9. The following information is outdated and kept for archival purposes.

The latest stable NVIDIA drivers will not install when using the version of X.org that is distributed with Fedora 9. I was able to use NVIDIA’s beta 172.08 display drivers after a few manipulations.

Version 172.08 does not support ABI, so I placed the following in /usr/bin/startx

defaultserverargs="-ignoreABI"

I also commented the following from /etc/X11/xorg.conf

# Load "glx"

Fedora 9 and NVIDIA Drivers x86_64 Instructions

Download the appropriate beta driver

$ wget http://us.download.nvidia.com/XFree86/
Linux-x86_64/173.08/NVIDIA-Linux-x86_64-173.08-pkg2.run

Run the installer

$ sh NVIDIA-Linux-x86_64-173.08-pkg2.run

Edit /usr/bin/startx (for runlevel 3 users) and add the following:

defaultserverargs="-ignoreABI"

Edit /etc/X11/xorg.conf and comment the following:

# Load "glx"

Upgrade to Fedora 9

Friday, May 16th, 2008

I upgraded my primary workstation to Fedora 9 this week. Although the upgrade was mostly uneventful, I did struggle with a few annoyances.

The latest revision of openbox lacks a specific functionality that’s vital to my coherent work flow. It lacks the ability to hold down the left mouse button on the title bar, and use the scroll wheel to migrate the currently held window to the next or previous desktop. It was easy to roll back to a previous version from the Fedora Core 6 Extras repository.

Another annoyance is that konsole removed the –noxft switch in their latest revision, this allowed me to prevent my terminals from having anti-aliased fonts. I use the font Terminus (highly recommended, by the way) within my terminals, and having that anti-aliased is just unacceptable. I could just disable anti-aliasing across all applications, but then my browser and mail client would look terrible. I was able to solve this issue with ~/.fonts.conf.

The last issue I had was with pulseaudio. Sound was very soft, even with the speakers and alsamixer set to 100%. I removed alsa-plugins-pulseaudio, and things started functioning normally.

I tried KDE again this week, and was dissapointed (as usual.) It was quite sluggish, and seemed very kludged together. Maybe someone will develop a feature-full window manager that doesn’t require big iron to run before I’m a gray-beard. They would then have to convince me that it is indeed better to have all that eye candy, yeah right.

Software raid 1 - Failing and recovering a disk

Tuesday, April 29th, 2008

A software raid group disk failed in one of my servers yesterday.

The kernel was spewing SCSI errors:

kernel: ata2: status=0xd0 { Busy }
kernel: SCSI error : return code = 0×8000002

# mdadm --display /dev/md0
# mdadm --display /dev/md1

both reported a failed disk sdb*

The procedure to rebuild the md groups is as follows:

Replace bad disk (sdb in this scenario.) Note that if you do not bring down the server to replace the disk, be sure to “remove” the disk from the raid groups using mdadm.

# mdadm --remove /dev/md0 /dev/sdb0
# mdadm --remove /dev/md1 /dev/sdb1

Read the good disk’s partition table (sda in this scenario.)

# fdisk -l /dev/sda
Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 fd Linux raid autodetect
/dev/sda2 14 19457 156183930 fd Linux raid autodetect

Install identical partition table on newly replaced disk. Create partitions that start and end on the same listed cylinders and are of type “fd.” Be sure to set the boot flag, and don’t forget to write the changes.

# fdisk /dev/sdb

Add partitions back to the appropriate raid groups.

# mdadm --add /dev/md0 /dev/sdb0
# mdadm --add /dev/md1 /dev/sdb1

Ensure the raid groups are rebuilding properly.

# mdadm --display /dev/md0
# mdadm --display /dev/md1

Searching and executing with find(1)

Thursday, April 17th, 2008

This afternoon I was faced with searching a directory tree for large files that have rotated within the last 24 hours - a symptom of a problem we were experiencing with a service.

Here’s what I put together quickly:

# find -iname name-\*.log -mtime 0 -exec du -sh {} \;

Explanation of the switches (from the find man page):

-iname pattern
Base of file name (the path with the leading directories removed) matches case insensitive shell pattern pattern

-mtime n
data was last modified n*24 hours ago.

-exec command {} \;
run the specified command on the matched files

It’s not complex (and probably not post-worthy,) but someone may find it helpful.

Nagios 2.6 and check_hpjd, Dell servers in an instrument rack, and network storage

Thursday, May 31st, 2007

Some of the jet direct emulation daemons on Kyocera Mitas are not compatible with the check_hpjd nagios plugin. I spent some time revamping our SNMP checks for certain printers - I have not yet fished, but am definitely making progress.

I ordered a server & rack extensions [plus round -> square hole converters] for one of our faculty members wanting to drop a Dell server in an instrument rack (25″ deep), this should be fun / interesting.

I’ve been spending a lot of time “putting out fires”, and resolving rt requests this week. Tomorrow night we’ll be migrating our storage from a local array to DCS network storage. This should be a major relief to our backup system.