Using manually created weathermap with device status and advanced functionality.
There is a built-in network map in Zenoss, but it has very limited functionality: it can only display devices with ther Layer 3 dependencies and their statuses. You can't choose what devices to show, their location on map, output additional information. So I need something more advanced. Surfing the Internet I found a http://www.network-weathermap.com/ with a nice package which allows you to manually define you map configuration and what to show on it.
The weathermap program is written in php and uses RRD files (prepared by other software like MRTG) for reading data in. It has plugin for Cacti, but nothing for Zenoss. Although it can read RRD (and Zenoss stores its data in this format) it fails to read my switches interface statistics because of spaces in their names. Weathermap uses spaces as a separator between different TARGET definitions and does not accept quotes. The second problem is that writing long pathnames is very boring for me. Weathermap supports plugins and you can write you own, but plugins only work for TARGETs. My PERL programming is much better that PHP so I decided to do a wrapper, which sucks information from Zenoss and puts it into weathermap configuration file.
The syntax of map configuration is very simple, all the information you need is written at http://www.network-weathermap.com/docs. Consult this site for it.
The basic idea is the following. You define nodes and links between them. Nodes are defined with the following commands:
NODE gw.youtsite.com # this should correspond to device name in Zenoss
LABEL main-router #the name to be shown on map
ICON 200 100 images/router.jpg #you could change the way it is looking
POSITION 500 600 #position on map - could be absolute or relative
POSITION switch-net.manage.chant.ru +150 +200
INFOURL <%url%> #if you want a html link back to zenoss from this device
TARGET static:<%status%> #change color of device based on it status in zenoss
And the links:
LINK link-name #any name you like
WIDTH 5 #fixed width of line or
WIDTH <%status-width(width_ok,device name,component name)%> #draw link with width 0 if it is down otherwise draw it with width_ok width
NODES node1 node2 # which nodes this link connects
TARGET static:<%rrd(device name,component name,datasource name,RPN)%>:<%rrd(device name,component name,data source name,RPN)%>
#TARGET defines what labels on link will show - usually we want bandwidth.
#component names should be in the form os/interfaces/port_name
#and datasource name - ifOutOctets or smth like this
#RPN - something like '*8' - multiply value by 8 - I prefer megabits, not bytes.
#next is overlibgraph - the most nice feature - which graph to show when mouse is over the current object
#for links it could be OVERLIBGRAPH, OUTOVERLIBGRAPH, OVERLIBGRAPH - counsult weathermap manual
OUTOVERLIBGRAPH <%graph(device_name,component name,Graph name - for example, Throughput)%>
#you could also define bandwidth like BANDWIDTH 1000M - if is different from default value
As you see, the are only few extra command which can save you time - <%rrd()%> - get value from rrd file, <%graph()%> - get graph url, <%url%> - get url to device. %<status-wdith>% - width-of link based on its PortStatus property.
And this is my header for map definition file.
KEYPOS DEFAULT 10 800 Traffic Load
KEYTEXTCOLOR 0 0 0
KEYOUTLINECOLOR 0 0 0
KEYBGCOLOR 255 255 255
BGCOLOR 255 255 255
TITLECOLOR 0 0 0
TIMECOLOR 0 0 0
SCALE DEFAULT 0 1 220 0 255
SCALE DEFAULT 1 10 140 0 255
SCALE DEFAULT 10 25 32 32 255
SCALE DEFAULT 25 40 0 192 255
SCALE DEFAULT 40 55 0 240 0
SCALE DEFAULT 55 70 240 240 0
SCALE DEFAULT 70 85 255 192 0
SCALE DEFAULT 85 100 255 0 0
#do nothing scale
SCALE TEST 0 10 0 0 0
#scale for coroling devices according to their status
SCALE STATUS 0 0 0 255 0
SCALE STATUS 1 1 0 255 0
SCALE STATUS 2 2 0 255 0
SCALE STATUS 3 3 0 0 250
SCALE STATUS 4 4 255 153 51
SCALE STATUS 5 5 255 0 0
HTMLSTYLE overlib #use overlib
SET key_hidezero_DEFAULT 1
# End of global section
# DEFAULT definitions:
USEICONSCALE TEST #by default status of node only changes its label color
USESCALE STATUS # if you want icon of your device to be also colored according to it status
# than change it iconscale - USEICONSCALE STATUS
LABELOFFSET 0 50
# OVERLIBWIDTH 597
# OVERLIBHEIGHT 177
Values are read from zenoss via HTTP REST call, it is better to place all files on your web server. Download weathermap package from http://www.network-weathermap.com/. Install it (you need only to unpack it). Download perl script from attached files. Edit its header and set your zenoss site URL, username and password. My script uses JSON::XS perl module, so you also need to install this perl package. Also edit wget_type to 1 or 2 depending on you wget version. My FreeBSD wget works with 1, but Linux - with 2.
The process of making a map is the following: Create you map file description with the commands given above and consulting weathermap website. Then process it with my script like ./convert_map.pl map.src >map.conf. If critical error happens then script stopes with a message about it. And finally convert it to html representation with weathermap:
./weathermap --config map.conf --htmloutput map.html
Point you browser to map.html. If everything is OK you could now add this commands to your cron - 5 minutes interval will be enough.