SNMP::Map - Tool for drawing network map
my $map = new SNMP::Map; $map->get_data(username=> 'user', password =>'pass', ipv3 => ['10.8.255.238','10.8.255.239','10.8.255.244','10.8.255.248'], vlan=>'vlan-224' ); $map->get_output(file => 'map.jpg');
The SNMP::Map module is used for drawing network map of hosts which support SNMP. Spanning Tree root switch can be distinguished by its position and color. Module provides switches and ports on the picture linked by each other.You can get various information about switch and its link. Image map file is also available. So, it can be used to create javascript for popuping additional info.
This is the constructor. It does not accept any attributes.
my $map = new SNMP::Map;
get_data
method gets data from switches using SNMP protocol. It starts from the spanning tree root switch,
and makes recursive calls to all switches linked to root. By default, it uses SNMP v3, but for switches
listed in ipv2 array reference,it uses SNMP v2. If a failure occurs, method returns underfined value,
you can use the error manpage to get error. At least, one ip adress must be specified by ipv2 or ipv3 attribute.
It is recommended to get more info, list all switches by ipv2 and ipv3 attributes. It was tested on
'WS-C2950','WS-C2960','WS-3750' platforms. 'WS-C2950' switches must be listed in ipv2.
Attributes:
$map->get_data(username=>'user', community=>'comm', password=>'pass', ipv3=>['10.8.255.115','10.8.255.118','10.8.255.119','10.8.255.111'], ipv2=>['10.8.255.145','10.8.255.133','10.8.255.151','10.8.255.149'], vlan => 'vlan-192');
This method is used for saving image into file. Also you can get an image map file. A color value used in attributes of the method may be ``h,s,v'' (hue, saturation, brightness) floating point numbers between 0 and 1, or an X11 color name such as 'white', 'black', 'red', 'green', 'blue', 'yellow', 'magenta', 'cyan', or 'burlywood'.
Attributes:
log(1/cost)*100
.
$map->get_output(file=>'../map.jpg', root_fillcolor=>'blue', root_fontcolor=>'cyan', fontcolor=>'red', color=>'green', shapes => {unknown => 'record','IP Phone' =>'ellipse'}, edges_colors=>['blue','0,0,0.9','0,0,0.8','0,0,0.7','0,0.5,0.6','0,0,0.5','0,0,0.4','red'], height=>5, width=>9, edge_style=>'dashed', cmap=>'map' );
return last error message.
returns hash reference with information about host.To use this method you must call the get_data manpage first. Keys of the hash reference are the ip address of the hosts.The following information could be obtained:
$info = $map->nodes_info(); print $info->{10.8.255.101}{deviceID}; print $info->{10.8.255.101}{priority}; print $info->{10.8.255.101}{mac}; print $info->{10.8.255.101}{platform}; print $info->{10.8.255.101}{interfaces}{Gi0/1}{cost}; #cost for Gi0/1 port print $info->{10.8.255.101}{interfaces}{Gi0/1}{cost}; #state for Gi0/1 port
take the number of the link as first parameter. To use this method you must call the get_data manpage first.Number correspond to href parameter of the image map file of link. The following information could be obtained:
$info = $map->edge_info(5); print $info->{from_ip}; print $info->{from_interface}; #name of the port print $info->{from_virtual}; #name of the virtual port print $info->{to_ip}; print $info->{to_interface}; #name of the port print $info->{to_virtual}; #name of the virtual port
Module was tested on 'WS-C2950','WS-C2960','WS-3750' platforms. ipv2 option in the get_data manpage method is used for WS-C2950.
Krol Alexander <kasha@bigmir.net>
This module is free software; you can redistribute it or modify it under the same terms as Perl itself.