Discussion:
Fully create Multi-Graph
James Newman
2013-03-04 15:51:28 UTC
Permalink
James Newman [http://community.zenoss.org/people/JimForTheWin] created the discussion

"Fully create Multi-Graph"

To view the discussion, visit: http://community.zenoss.org/message/72266#72266

--------------------------------------------------------------
So this has been kicking my butt for the last two weeks.

I want to programatically create a multigraph report.  I am at the point where I can add datasources and collections, but I need to figure out how to add items to the collections and then Groups to the report.

If anyone has a working example of all of this, that would be great,  if not, what I'm working on right now is the following:

(Assume all variables and lists are properly defined elsewhere)


# Function to add Collections to the multi-graph report
def addCollection(location, type, report):
    collectionName = str(location.split('/')[1] + " " + type)

if collectionName not in str(rpt.getCollections()):
        report.manage_addCollection(collectionName)

    addCollectionItem(location, collectionName, type)

# Function to add Collection Items to Collections within the multi-graph report   
def addCollectionItem(location, colName, type):
try:
for dev in dmd.Devices.Server.Linux.BLAH.Clustered.type.getSubDevices_recursive():
if dev.getLocationName in location:
                colName.manage_addCollectionItem(dev)
    except:
for dev in dmd.Devices.Server.Linux.BLAH.NonClustered.type.getSubDevices_recursive():
if dev.getLocationName in location:
                colName.manage_addCollectionItem(dev)


ro = dmd.Reports.getOrganizer('/Multi-Graph Reports/')

# Loop over all the things!
for profile in profiles:
    # Create a shortened customer name
    customer = '-'.join(profile.split('-')[0:2])

    # Create a report named after the customer short name.  If one already exists, we try and continue anyway.   
    ro = dmd.Reports.getOrganizer('/Multi-Graph Reports/')

try:
        rpt = ro._getOb(str(customer))
    except:
        rpt = ro.manage_addMultiGraphReport(str(customer))

for loc in listLocations:
if options == "smtp":
            addCollection(loc, "SMTP", rpt)
elif "eps" in options:
            addCollection(loc, "EPS", rpt)

        addCollection(loc, "TM1", rpt)



So This creates the report, creates the collection, and then _doesn't_ add the CollectionItem.

I've found a couple of places in the Zenoss source that use manage_addCollectionItem(),  but I can't seem to get the usage correct for my example:

from /opt/zenoss/ZenModel/CollectionItem.py
def manage_addCollectionItem(context, id, deviceId, compPath, sequence,
                                                            REQUEST = None):

from /opt/zenoss/ZenModel/Collection.py
def manage_addCollectionItem(self, itemType,
            deviceIds=(), componentPaths=(), deviceClasses=(), systems=(),
            groups=(), locations=(), recurse=False, REQUEST=None):


Anyone help me out?  And then if possible, also provide an example for adding a Graph Group?
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/72266#72266]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
dpetzel
2013-03-04 16:05:51 UTC
Permalink
dpetzel [http://community.zenoss.org/people/dpetzel] created the discussion

"Re: Fully create Multi-Graph"

To view the discussion, visit: http://community.zenoss.org/message/72260#72260

--------------------------------------------------------------
col = mg.manage_addCollection("Host Collection")
col_grp_path = "/Groups/" + REPORT_GROUP_BASE + "/" + self.app_name
col.createCollectionItem(orgPath=col_grp_path, recurse=True)
Maybe it will be of help?
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/72260#72260]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
James Newman
2013-03-04 16:18:54 UTC
Permalink
James Newman [http://community.zenoss.org/people/JimForTheWin] created the discussion

"Re: Fully create Multi-Graph"

To view the discussion, visit: http://community.zenoss.org/message/72267#72267

--------------------------------------------------------------
Taken from the IRC channel:

Paths are required to add devices to collections:

d.getPrimaryUrlPath().replace("/zport/dmd", "")

Above returns the path of device d.
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/72267#72267]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
James Newman
2013-03-04 16:31:54 UTC
Permalink
James Newman [http://community.zenoss.org/people/JimForTheWin] created the discussion

"Re: Fully create Multi-Graph"

To view the discussion, visit: http://community.zenoss.org/message/72268#72268

--------------------------------------------------------------
And then adding graph groups:

graph_group = mg.manage_addGraphGroup(graph_name,collectionId=col_name, graphDefId=graph_name)
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/72268#72268]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
Loading...