Homebrew NMS: Send Out Nedi, Get Back Useful Data - Page 2

 By Charlie Schluting
Page 2 of 2   |  Back to Page 1
Print Article

Using Perl, again, and DBD::Pg, we'll begin by defining our DB connection information:

Next, we need to open the file and begin reading it. The final block of code is quite large, because it is necessary to execute all processing steps on every line of the file. The steps are: check for data sanity, assign variables names to each attribute of the line, and then perform one of two actions. If the MAC is already known, and its location has not changed, simply update the "lastseen" field in the database. Otherwise, this is a new host entry.

Checking data sanity is quite important, since pieces of information can often be missing. The example skips over unknown data, but it would be just as easy to flag it for human perusal if that is required.

Hopefully this has been a good example of how easy it is to manipulate discovery data. Next time we'll begin talking about how all this can be used, and what other pieces of data should be involved.

This article was originally published on Sep 27, 2007
Get the Latest Scoop with Networking Update Newsletter