PHPcomputerlocator SourceForge Logo


Warning

This software is very early alpha. It may not do anything for you. There is no warranty for it. I have a very basic knowledge of SNMP so there may be a better way of doing this. If you know of a better way of doing this please let me know.

Purpose

I wrote this simple PHP tool to get a better idea where particular machines are connected. This is useful if particular machine is misbehaving. This has been tested on a Cisco 3750 switch stack and Enterasys Matrix E1 switch. Let me know if it does work for you.

Implementation

Basic idea behind implementation is to use snmpwalk to get a listing of devices that are connected to a certain port. For example command
snmpwalk -v 2c -c public -On 10.24.1.100 .1.3.6.1.2.1.17.4.3.1.2
will produce a list of ports and what MAC addresses are connected to a particular port. MAC addresses are in decimal format so I use PHP to convert it to HEX.

After that if you supply a netmap (CSV files that has port number, location and machine name) it will appear in the table.

Installation

Prerequisite is a web server with PHP support and PEAR libraries. Go to http://www.php.net/ for details on how to install it.
  1. You will need to install these two PEAR packages
    pear install HTML_Common
    pear install HTML_Table
  2. Download the latest release of phpComputerLocator from here.
  3. Unpack it in a folder that is accessible to your web server ie phpcomputerlocator.
  4. Copy sample-config.php to config.php and edit it. In most cases the only things you will need to set are $snmpwalk which is the full pathname to snmpwalk command and IP address of your switch stack ie. IP of module 1 in a stack
  5. If you want more useful information create a file called ${IP}-netmap.csv where IP is the ip address of a particular switch ie. 192.168.1.100-netmap.csv  and include more information about connected ports ie. where is it physically located etc. First field is the port number (1-250), second setting is patch panel port, third physical location ie. office #123 and fourth name of the machine that should be connected to the port. You can leave off any information that you don't want to put in.
  6. Now go to your browser and point it to e.g. http://localhost/phpcomputerlocator
  7. Follow the directions from there
You should then get something like this

PHPcomputerlocator MAC matrix

Help wanted

I would like to improve this script so that is pretty useful. I am also interested in seeing people try this script against switches other than Cisco and Enterasys. Also if someone has insight how to query the arp table on Enterasys or other switches.
Please click here to contact me.