I'm doing inventory of my network devices across 7 routers. My perfect world would be to setup a kron on each router to run a "show arp" using attributes to pick the mac addresses out and then tftp it to my server. From there I could dump that into an excel sheet and run a compare between it and my inventory database exoprted to a excel (which has mac addresses entered).
The initial delema is that the attributes for "show arp" only deal with "lines" and no specifics within a line or a column from the output.
Is anyone aware of a way to do pull only the mac addesses from a "show arp"?
Thanks in advance,
Regex is what you need. Scrape the output of sh arp and parse it line by line. From the following output:
Protocol Address Age (min) Hardware Addr Type Interface Internet 75.***.**.** - 0017.59bf.2143 ARPA FastEthernet0/1 Internet 192.168.2.6 1 904c.e52d.072c ARPA FastEthernet0/0.2 Internet 192.168.7.1 - 0017.59bf.2142 ARPA FastEthernet0/0.24 Internet 75.**.**.* 0 001d.a2e8.0ad9 ARPA FastEthernet0/1
...this regex will match the MAC address:
Try it out here:
In which case create a cron job to run a python script.
I recommend using the netmiko library for connecting to the switch and issuing the command. You would then parse the output with the above the regex and output to a CSV file named with a timestamp.
You could then audit these CSV at you leisure.
Check out my code in this post for a starting point:
I would use either Python or Ansible to pull that out. Ansible with NTC module and TextFSM templates should do the trick. You can also straightaway write the results into a file.