Reports... again

Started by rostyslav, January 17, 2013, 04:57:01 PM

Previous topic - Next topic

rostyslav

So, I've got the reports working.
I am able to generate many different reports for different time periods now.
It required some additional scripting, so I decided to share it with those who might need it.
The idea behind the scripts is following.
We generate XML files, which is called subreports. Each subreport have its own SQL query and generate its own TimeSeries graph.
After subreports have been generated we list them in the main XML report and compile the main report from command line.

Steps to teach your server to generate reports (tested on Ubuntu):
1. Download packages
wget -r --no-parent https://svn.netxms.org/public/netxms/trunk/src/java/report-generator/
wget http://repo1.maven.org/maven2/net/sf/jasperreports/jasperreports/4.7.0/jasperreports-4.7.0.jar

2. Install required packages:
sudo apt-get install sendemail maven2
mvn install:install-file -DgroupId=jasperreports -DartifactId=jasperreports -Dversion=4.7.0 -Dpackaging=jar -Dfile=./jasperreports-4.7.0.jar

3. Edit pom.xml to remove unnecessary dependencies:
cd ./svn.netxms.org/public/netxms/trunk/src/java/report-generator/
nano pom.xml

4. Compile java package and copy it to your preferred location (I use /opt/netxms/java-lib/):
mvn clean package
cp ./svn.netxms.org/public/netxms/trunk/src/java/report-generator/target/report-generator.jar /opt/netxms/java-lib/

5. Add the following to your netxmsd.conf (modify for your installation):
JavaPath=/usr/bin/java
JavaLibraryDirectory=/opt/netxms/java-lib
JDBCDriver=org.postgresql.Driver
JDBCUrl=jdbc:postgresql://localhost/netxms


Steps to actually generate reports:
1. Download script (xml-generation.pl, createMainXML.pm, createSubReport.pm)
2. Install perl
3. Modify SQL subqueries, descriptions, conditions, folder (where xml files should be stored) in the xml-generation.pl file to suit your needs. (If you are not using PostgreSQL you should also modify the DBI connection and query in createSubReport.pm)
4. Run the xml-generation.pl script. It will generate subreports named <node_name>-<description>-<interval>.jrxml and main report named <interval>.jrxml
5. Compile the report:
"/usr/bin/java" -cp "/opt/netxms/java-lib/report-generator.jar" org.netxms.report.Generator "/etc/netxmsd.conf" "/opt/xml-reports/hourly.jrxml" "/opt/reports/hourly.output"
6. Convert it to pdf:
"/usr/bin/java" -cp "/opt/netxms/java-lib/report-generator.jar" org.netxms.report.Exporter "/opt/reports/hourly.output" "/opt/reports/hourly.pdf"
7. And send it to your e-mail:
sendemail -f "[email protected]" -t "[email protected]" -m "Hourly report" -u "Report" -a "/opt/reports/hourly.pdf"

Best regards,
Rostyslav

sohgnar

Has anyone configured reports with NetXMS server installed on a windows machine?

mialkfl

Hi Gentlemen

I was not able to get reports working on a windows machine so far, too. Could you please post a short guide on how to implement reports module on windows machines?

Thanks in advance and best regards
Florian Mialki

Santosh Khanna

Is there any external tools by which we can generate reports on Windows Installation?


yshiro

Quote from: phonix786 on November 30, 2013, 12:17:52 PM
Is there any external tools by which we can generate reports on Windows Installation?

Hi phonix, i´m using http://community.jaspersoft.com/project/ireport-designer, with iReport you can generate a jrxml file extension, this file will be used by netxms when we succesfully install reports on netxms with windows server.

I have some reports created, like capacity of switches.

Greetings.


Alex Kirhenshtein

I highly recommend you to use Jaspersoft Studio (http://community.jaspersoft.com/project/jaspersoft-studio) instead of iReport

yshiro

Quote from: Alex Kirhenshtein on December 02, 2013, 05:51:33 PM
I highly recommend you to use Jaspersoft Studio (http://community.jaspersoft.com/project/jaspersoft-studio) instead of iReport

Hi Victor, ill give a try, thanks!

Greetings.

rostyslav

I've rewritten the script to PHP. Now it is much more cleaner and easier to understand.
Link to github: https://github.com/frostyslav/netxms-report-generator