Update mysql database with arpwatch textfile database

Posted by bVector on Server Fault See other posts from Server Fault or by bVector
Published on 2012-10-11T20:06:38Z Indexed on 2012/10/11 21:39 UTC
Read the original article Hit count: 435

Filed under:
|
|
|
|

I'm looking to keep arpwatch entries in a mysql database to crossreference with other information I'm storing based on mac addresses. I've manually imported the arpwatch database into my mysql database, but being a novice with databases I'm not sure what the best way to continually update the database with new entries without creating duplicates would be. None of the fields can be unique, as even the time is duplicated frequently. I'm not interested in the actual arpwatch events like flip flop or new station, just the mac/ip/time pairings.

Would a simple bash (or sql) shell script do the trick? Would it be possible to make the mac address plus the time be a composite key of some sort?

  • the database is called utility, table is arpwatch, columns are mac, ip, time
  • a seperate table named 'hosts' with columns mac, ip, type, hostname, location, notes has mac as the primary key. This table will correlate different ip addresses that a mac had over time using the arpwatch column
  • initial import was done with MySQL Workbench using INSERT INTO commands with creative search and replace on the text file

© Server Fault or respective owner

Related posts about bash

Related posts about database