DCI Summary Table to Excel Query

Started by sharpspro, May 01, 2015, 10:48:42 AM

Previous topic - Next topic

sharpspro

Is there a way to run the DCI Summary table on all server nodes from excel? I tested running a query on NetXMS from within excel and was able to.

Currently I export the data from the DCI Summary Table to excel and run custom reports on drive space needs. Just looking for away to automate this process and will be looking into the reporting addon of NetXMS as well.

Alex Kirhenshtein

You can automate it a bit using nxshell (which is python internally) – generate CSV or xlsx file.
However, if you want fully automated reports – you need to use some kind of reporting engine, either built-in Jasper or some external solution.

Sample script which export summary table into csv file:#!/usr/bin/env python
# -*- coding: utf-8 -*-

import csv, sys

menuPath = "Table1" # Table's "Menu Path"
baseObjectId = 2 # Infrastructure Services
outputFile = 'test.csv'

for table in session.listDciSummaryTables():
    if table.getMenuPath() == menuPath:
        result = session.queryDciSummaryTable(table.getId(), baseObjectId)
        if result:
            with open(outputFile, 'w') as f:
                w = csv.writer(f, dialect='excel')
                columns = []
                for c in result.getColumns():
                    columns.append(c.getDisplayName())
                w.writerow(columns) # Header

                for row in result.getAllRows():
                    cells = []
                    for i in range(0, row.size()):
                        cells.append(row.get(i).getValue())
                    w.writerow(cells)