scratchProjects.com :: Programming the world from scratch

scratchProjects.com :: Programming the world from scratch
Header Right
Navigation
Programming Languages
Spacer

Using VBScript to Add Hostnames in CSV Logs

- 24 May 2006 -             [Download Code]

Vote:     Boo Yay

Written By: Kevin Jordan

Description: Get your server logs ready for a database by using this VBScript to pull the hostname from a computer and add it to the beginning of each line in a .csv file.

  1. Creating the Logs and Calling the Script
  2. Helper Functions
  3. Adding to the CSV
  4. Pull it Together

Introduction

One goal of most operations teams is to have a central log store. That way you can investigate any issues from the convenience of a single location. We needed to load all our logs into an oracle database, so we used Log Parser to get the majority of our server logs and put them into .csv format. Unfortunately, not all the logs had the servers hostname included. So this script takes each line in the .csv file and adds the hostname column.

Creating the Logs and Calling the Script

The first thing I have is a batch script that calls Log Parser and puts everything on the central storage location:

This script is run every night from task scheduler on the computer we�re trying to collect logs from. In my case, I had this set up on about 30 servers. However, the script was actually stored on the central server so that if I needed to make a change, I just did it in one place, instead of having to update all 30 systems.

The first line sets a date variable used for naming the files. It�s in the form yyyymmdd. The next three lines call Log Parser. Log Parser is a tool from Microsoft used to query various Windows log files. The query syntax is SQL based. I wanted to get the previous days logs so I used the BETWEEN statements. I retrieved information from the following:

  1. Non-information events from the Application log (warnings and errors).
  2. Unsuccessful login events from the Security log.
  3. IIS 6 errors from the HTTPERR log.

    The last line is where we call our VBScript. I�ll start by explaining the functions and then we�ll look at the script as a whole.

    Go To Part 2 Discuss This Article In Our Forum

Spacer
Sponsored Links
Find Articles:




Footer Left Spacer Spacer Footer Right

Contest Details | Press Releases | Privacy Policy | Write For Us |
© copyright(scratchProjects.com) 2006