Jul 26, 2011 1:33 PM
Can't get more than one data column to display in a report
I've written several reports in the past, but it was prior to the new Alias system that was put in place. I wrote 3 basic reports that work fine, but there's nothing fancy about them, they are just 3 columns, device name, component, value. I then tried to make a fourth report with 5 total columns, but no matter what I've tried it always only shows the data in one column. I basically just copied and modified the code from the interface utilization report...
Here is the python plugin:
###########################################################################
#
# This program is part of Zenoss Core, an open source monitoring platform.
# Copyright (C) 2007, 2009 Zenoss Inc.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 as published by
# the Free Software Foundation.
#
# For complete information please visit: http://www.zenoss.com/oss/
#
###########################################################################
import Globals
from Products.ZenReports.AliasPlugin import AliasPlugin, Column, \
RRDColumnHandler, \
PythonColumnHandler
class ipSLApktloss( AliasPlugin ):
"""
ipSLA packet loss report
"""
def getComponentPath(self):
return 'ipSLAs'
def _getComponents(self, device, componentPath):
components=[]
try:
for s in device.ipSLAs():
if s.rttMonCtrlAdminRttType == "Jitter":
components.append(s)
except AttributeError:
pass
return components
def getColumns(self):
return [
Column('deviceName', PythonColumnHandler( 'device.titleOrId()' )),
Column('SLA', PythonColumnHandler( 'component.name()' )),
Column('droppedPkts', RRDColumnHandler( 'rttMonLatestJitterOperPacketLossSD' )),
Column('sentPkts', RRDColumnHandler( 'rttMonEchoAdminNumPackets' )),
]
def getCompositeColumns(self):
return [
Column('percentLoss', PythonColumnHandler('float(droppedPkts)/float(sentPkts)'))
]
Here is the tales file:
<tal:block tal:define="
tableName string:ipslapktlossreport;
tm here/ZenTableManager;
tableState python:tm.getTableState(tableName, sortedHeader='percentLoss',
sortedSence='desc');
sts python:here.ZenTableManager.setReqTableState;
zem python:here.dmd.ZenEventManager;
startDate python:sts(tableName, 'startDate',
zem.defaultAvailabilityStart());
endDate python:sts(tableName, 'endDate',
zem.defaultAvailabilityEnd());
how python:sts(tableName, 'how', 'AVERAGE');
summaryOptions python:('AVERAGE', 'MAXIMUM', 'MINIMUM', 'LAST');
deviceClass python:sts(tableName, 'deviceClass', '/');
deviceFilter python:sts(tableName, 'deviceFilter', '');
objects python:here.ReportServer.plugin('ipSLApktloss', tableState);
objects python: (hasattr(request, 'doExport') and list(objects)) or objects;
exportFields python:[('deviceName', 'Device'), ('SLA', 'SLA'), ('sentPkts', 'Sent Packets'), ('droppedPkts', 'Dropped Packets'), ('percentLoss', '% Loss')];
batch python:here.ZenTableManager.getBatch(tableName,objects,sortedHeader='percentLoss', sortedSence='desc');
">
<tal:block metal:use-macro="here/reportMacros/macros/exportableReport">
<tal:block metal:fill-slot="report">
<tal:block metal:use-macro="here/templates/macros/page1">
<tal:block metal:fill-slot="breadCrumbPane">
<span metal:use-macro="here/miscmacros/macros/reportBreadCrumbsList"/>
</tal:block>
<tal:block metal:fill-slot="contentPane">
<tal:block metal:use-macro="here/reportMacros/macros/utilizationForm"/>
<form method="POST" tal:attributes="action request/URL; name string:deviceList"
tal:define="tabletitle string:ipSLA Packet Loss;
showfilterbox python:True;
tblcolspan string:5">
<tal:block metal:use-macro="here/zenuimacros/macros/zentable">
<tal:block metal:fill-slot="zentablecontents">
<tr>
<th tal:replace="structure python:here.ZenTableManager.getTableHeader(
tableName,'deviceName','Device')"/>
<th tal:replace="structure python:here.ZenTableManager.getTableHeader(
tableName,'SLA','SLA')"/>
<th tal:replace="structure python:here.ZenTableManager.getTableHeader(
tableName,'sentPkts','Sent Packets')"/>
<th tal:replace="structure python:here.ZenTableManager.getTableHeader(
tableName,'droppedPkts','Dropped Packets')"/>
<th tal:replace="structure python:here.ZenTableManager.getTableHeader(
tableName,'percentLoss','% Loss')"/>
</tr>
<tal:block tal:repeat="r batch">
<tr tal:define="odd repeat/r/odd"
tal:attributes="class python:test(odd,'odd','even')">
<td><a tal:attributes="href python:r.device.getPrimaryUrlPath()+'/ipSLAipSlaDevice'"
tal:content="python:r.deviceName"/></td>
<td><a tal:attributes="href python: r.component.getPrimaryUrlPath()"
tal:content="python: r.SLA"/></td>
<td tal:content="python: r.sentPkts"/>
<td tal:content="python: r.droppedPkts"/>
<td tal:content="python: r.percentLoss"/>
</tr>
</tal:block>
<tr>
<td colspan="5" align='center'>
<form metal:use-macro="here/zenTableNavigation/macros/navtool"/>
</td>
</tr>
</tal:block>
</tal:block>
</form>
</tal:block>
</tal:block>
</tal:block>
</tal:block>
</tal:block>
The resulting output is like...
Device | SLA | Sent Packets | Dropped Packets | % Loss |
---|---|---|---|---|
Device 1 | SLA Name 1 | 1000 | ||
Device 2 | SLA Name 2 | 1000 |
Only the Sent Packets column gets populated, the other two do not. If I comment out the sentPkts column in the plugin then the Dropped Packets column gets populated. It's always only using one column. It's also never able to calculate percentLoss because it doesn't get the values for the other columns to be able to do the calculation. I've spent hours trying to debug this and I'm completely out of ideas.
Any help would be greatly appreciated, I must be missing something here.
-
Like (0)