PHPcomputer locator for Baystack 450
Revision: $Date: 2003/08/27 21:06:32 $
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.
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 Baystack 450 switch stack ie. I
have 8 cascaded Baystack 450 switches. It may work with other switches
but I can't test it at this time. Let me know if it does work for you.
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 .188.8.131.52.184.108.40.206.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.
Other useful info is arp table that you have to generate by hand that could be crossreferenced and included in the table
Prerequisite is a web server with PHP support and PEAR libraries. Go to http://www.php.net/ for details on how to install it.
You should then get something like this
- Download the tarball here .
- Unpack it in a folder that is accessible to your web server ie phpcomputerlocator.
- Edit config.php. 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 450 stack.
- If you want more useful information edit 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.
- Create an ARP table. If you want mac addresses from the switch associated with an actual IP do following
- Ping the broadcast ie. ping -b 10.24.255.255
- After a while (a minute or so) your machine will create an arp table
- Dump the arp table with arp -a > arp.table
- Now go to your browser and execute http://localhost/phpcomputerlocator/show_mac_matrix.php
- It may take couple seconds before the table comes up
I would like to improve this script so that is pretty useful. If you
know of a better way to do what I am doing please let me know.
Especially how to map MAC addresses to IPs. If someone has an insight
on how that could be done without resorting to step 5 I would really
appeciate any insight.
Please contact me at