Article 3724 of comp.lang.perl: Xref: feenix.metronet.com comp.lang.perl:3724 comp.protocols.snmp:437 Path: feenix.metronet.com!news.utdallas.edu!wupost!uunet!pipex!uknet!mcsun!julienas!cnam!bortz From: Stephane Bortzmeyer Newsgroups: comp.lang.perl,comp.protocols.snmp Subject: A set of Perl scripts to record addresses on a LAN with SNMP Followup-To: comp.protocols.snmp Date: 26 Jun 1993 16:21:59 +0200 Organization: CNAM Lines: 82 Sender: bortz@cnam.cnam.fr Distribution: world Message-ID: <20hm27$9pe@cnam.cnam.fr> NNTP-Posting-Host: cnam.cnam.fr Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Hello, I've just finished a set of Perl scripts which enables the network admini- strator to keep tracks of the machines which are active on the LAN. These scripts are available on ftp.cnam.fr:pub/CNAM/MISC/record_arp.tar.Z. Here is the README: ---------------------- beginning of README -------------------- Record addresses in a LAN from SNMP agents This set of Perl scripts allow you to record addresses of machines which "speak" on your LAN. It does so by dumping ARP tables of SNMP agents. ARP tables are tables of mapping between a MAC (Medium Access Control, hardware) addrress, such as an Ethernet address and a network (high-level) address, at the present time, only an IP address. To use it, you need: - Perl, a nice programming language for system and network administrators. Perl is available on uunet.uu.net:gnu/perl-xxx.tar.Z, on tut.cis.ohio-state.edu:perl/xx and on jpl-devvax.jpl.nasa.gov:pub/perlxxx. It is described in "Programming Perl" by Wall and Schwartz (O'Reilly). - at least one SNMP agent on a frequented machine (I mean a machine which speaks with many others, such as a central router). This agent has to be in MIB-II (RFC 1213). Today, almost all network devices (hubs, routers, bridges, etc) are sold with a built-in SNMP agent. It can also run on a general-purpose computer too. SNMP is described in "The simple book" by Rose (Prentice-Hall). - a software package which allows you to direct SNMP requests from the command line. My scripts are tailored for Tricklet, but it shoudln't be too hard to modify them for, say, CMU's SNMP. To get Tricklet, a great package to do network management with SNMP, ftp to dutepp0.et.tudelft.nl:/pub/Tricklet. There are many other interesting network things on this machine, all made by the Data Network Performance Analysis Project at Delft University of Technology. Many thanks to them. For CMU, try lancaster.andrew.cmu.edu:pub/cmu-snmpxxx.tar. You have the following scripts: - arp.pl dumps the ARP table from a distant machine. Useful to test if this machine has a correct SNMP agent. - record_mac_addresses.pl is the most important script: it gathers information from your agents. Edit the line beginning with "@agents=" to write your own agents. Choose a name for your database and edit "$DBM_file_name =" and "$log_file_name =" accordingly. Then, run this script from crontab every three or four hours. - print_mac_addresses.pl dumps the whole database. I like the following C shell alias "alias macaddr 'perl /path/print_mac_addresses.pl | grep -i \!$'" which allows me to find a machine by its name, IP address or MAC address. - remove_mac_address.pl to suppress an entry (by its IP address). Of course, this package is without any warranty and I don't speak for my employer... (But if you have bug reports, I'd like to see them.) -------------------- end of README --------------------- Well, it was just to show that network management was useful in practice :-) and that fancy interfaces aren't the only way to do it (cron is good too). Stephane Bortzmeyer Conservatoire National des Arts et Metiers bortzmeyer@cnam.cnam.fr Laboratoire d'Informatique 292, rue Saint-Martin tel: +33 (1) 40 27 27 31 75141 Paris Cedex 03 fax: +33 (1) 40 27 27 72 France "C'est la nuit qu'il est beau de croire a la lumiere." E. Rostand