How to Add a Report
by
zenoss
—
last modified
2007-10-17 12:43PM
Instructions for creating new reports
Creating a customized report through the Web GUI
Zenoss features a method of creating reports using the Web GUI. These can be reached by clicking on the "Reports" link on the left navigation bar. From here one can select "Graph Reports" in the table of reports. This is where new customized reports can be created and edited, reports created this way allow for the accumulation of various graphs from different devices on one page.
Other cases require the creation of a completely custom report, in which case the instructions below should be helpful.
Creating a custom report using TALES
Zenoss reports are simply html pages that use TALES markup.
New pages can be created using the Zope Zope Management Interface (ZMI)
interface. Navigate to this url on your Zenoss server:
http://localhost:8080/zport/dmd/Reports
You can add a report at this point in the Report tree by adding
"/manage" to the URL in your browser:
http://localhost:8080/zport/dmd/Reports/manage
Here you can select "Report" from the menu on the right, and add a new
Report. Name it "test" and save it. After you see your new "test"
report, leave the ZMI by selecting the "test" object, and then
selecting the "Test" tab at the top of the page.
You will then see a sample page:
Reports
This is Page Template test.
If we use some Zenoss TALES templates, we can get a test page that has
the Zenoss look & feel. Navigate back to our test page under the ZMI:
http://localhost:8080/zport/dmd/Reports/test/manage
Now change the text to this:
<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">
<h1>Reports</h1>
This is Page Template <i tal:content='here/title_or_id'/>.
</tal:block>
</tal:block>
</tal:block>
</tal:block>
The meat of a report goes here:
<tal:block metal:fill-slot="contentPane">
...
</tal:block>
Typically, a list of records is pulled from the database, summarized,
and then shown in a table using the TALES markup.
Although you can make changes and save them using the web interface,
it is a cumbersome editor. It is simpler to make the changes to an
external file and reload it. If you store your file in the
$ZENHOME/Products/ZenReports/reports directory, you can load it in
with the ReportLoader:
$ cd $ZENHOME/Products/ZenReports
$ python ReportLoader.py --force
Plugins
Reports are often summaries which are not tied to a particular object.
Instead of adding code to objects to make them available in the page
template, you can put the python code for a report in the
$ZENHOME/Products/ZenReports/plugin directory.
You can execute a plugin using this tal:block:
<tal:block tal:define="
objects python:here.ReportServer.plugin('cpu', here.REQUEST);
"
...
</tal:block>
Plugins are executed every time a report is run, and do not require a
Zope restart to get pick up changes. With help from the ZenReports?
Plugin module, you can even test the reports from the command line.
This further reduces the number of times that Zope is used as a
development environment.
See the examples in the plugins directory.
Describe the use of the Table Macros
Not complete...