Python@Work Followup
I just published the Python app for my day job that I mentioned I would be working on. It turned out quite a bit differently than I thought it would.
The goal: grab events from our Active Directory domain controllers from around the world and parse them against our network subnet information (specifically, what building a subnet is deployed in) to provide a list of IP subnets that should be added to Active Directory and assigned to a site.
The tools: one slightly dangerous CS grad, ActivePython, Winbatch, Sysinternal's PSLogList, and a W2K3 server.
The method:
- Put PSLogList on each DC along with a shell script that is scheduled to run it weekly. The command used:
psloglist -s -d 14 -i 5778 > c:\5778logs.csvoutputs the last 14 days' 5778 events with comma-separated values and puts them in a text file. PSLogList can remotely query servers, however its performance over WAN links is much slower than just running it locally and copying over the results. - Wrote a Winbatch script that gets a list of all the current AD DCs, and attempts to find and copy down their CSV files. After it's done, it puts them all together into a single CSV file.
- Wrote a Python script that reads in a CSV file with network subnet information (network address, subnet mask, and building info are used) and then iterates through each 5778 event, associating a network subnet to each referenced client's IP address. I used a bit of brute force to calculate the correct subnet. Our network has a lot of variety, with plenty of subnetted Class B and C subnets, so this calculation takes awhile for the thousands of 5778 events that are being parsed. There are probably more elegant ways of doing this, so this part of the process will improve over time. (The Python script I wrote is in the extended entry.) The script outputs a formatted text file that includes information about every unassigned subnet.
- Created a shell script to wrap this all up and run weekly after the runs of the DCs' scheduled PSLogList jobs.









