Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - alex_rhys-hurn

#1
General Support / How To: NetXMS Reports in 2021
November 21, 2021, 05:19:37 PM
There are MANY NetXMS Reporting Server articles on Telegram and here on the Forum, as well as the Wiki and the Official Manual.

Most of them are either incomplete, old and out of date, or straight out wrong. For example the official manual at https://www.netxms.org/documentation/adminguide/reporting.html is, as of today,  incorrect.

This article is my attempt to write a reasonably detailed but complete set of steps to working with NetXMS Reporting Server on Ubuntu in 2021.  Its a bit of a rough brain dump, sorry. Please help me to edit and complete this, just reply to the thread.

Pre-requisites
On the Server

  • A fully functioning NetXMS Server version 3.9.361 installed via the PPA on Ubuntu 18.04.6.
  • Above NetXMS using Mysql (Mariadb should also work)
  • Maven installed on your Ubuntu Server (apt install maven)
  • SSH On your server so you can log in easily
On your PC

  • Oracle Mysql Workbench (to make browsing and understanding the netxms db structure easy) if you are a guru with SQL on the CLI, maybe you dont need this, but I am a network guy not a DB or Java guy.
  • Jasper Reports Studio community edition - you use this to actually write the report templates
  • Mobaxterm (in my opinion the best Terminal Client for SSH to your server, and has a file manager built in so you can upload the report templates to the server.)
  • Java JRE version 11
  • NetXMS Management Console to match your NetXMS version
  • Notepad++ - as editing xml files in regular windows notepad will not work
  • Oracle Mysql Java Connector - so you can connect your Jasper Studio directly to your NetXMS MySQL. This makes using the query builder easy, and basically removes the need for the MySQL Workbench.

NetXMS Reporting Concepts:
1: NetXMS is leveraging the Jasper Reports engine, and this is tightly integrated with NetXMS server
2: The NetXMS Management Console is used to EXECUTE reports, but CANNOT CREATE reports.
3: You must change your perspective in the Management COnsole to the Reports Perspective
4: Management Console Server Configuration (nxmc) is used to configure the basic settings of NetXMS Report (nxreport)
5: You use the Jsaper Reports Studio on your PC to create report templates
6: You upload the files and folders of your Studio template to the server
7: Then you compile the report using MAVEN to create a .jar file, you must have a pom.xml and configure it correctly.
8: copy the .jar file to the NetXMS NXreportd definities folder, and restart services, this loads the template to the report server
9: Go to NXMC and execute the report either manually on schedule.
10: Right click the executed item and export as PDF or Excel.

Installing and Starting
To install the NetXMS Report server has now become extremely easy, and you must ignore almost all other articles on the net about how to install.

Install Procedure:

  • SSH to your NetXMS Server.
  • Run the command: sudo apt install netxms-reporting
  • After the installation has finished set the service to start automatically at boot up
  • Run the command: systemctl enable nxreportd.service
  • Then execute systemctl start nxreportd

Enable Procedure
Now you must configure NetXMS to enable and use the report server.

  • Log in to nxmc, go to CONFIGURATION > SERVER CONFIGURATION
  • Use the filter function and search for Report
  • Change the item ReportingServerHostname to 127.0.0.1 (this works around an issue where by default Ubuntu hosts file resolves localhost to ::1 for IPv6 but nxreportd is only listening on ipv4)
  • Change the item EnableReportingServer to 1

At this point reporting server is installed and enabled. Lets check if it is working.

First, execute:

systemctl status nxreportd.service

you should see status running, and some log details.

Second, SSH to your server and execute

netstat -plantu | grep 4710

This should show you if the tcp port is open and an application (java) is listening there, result should look like:
tcp6       0      0 127.0.0.1:4710          :::*                    LISTEN      10802/java

If you dont see the port 4710 and the word LISTEN and the word java, go back and check with systemctl whats wrong the service.

Third, log in to nxmc and change your perspective to Reports perspective (top right corner of nxmc screen), once in press refresh on the Report Navigator side bar, nothing should happen and the list should be empty. If you get an error about communication then go back and check that the server configuration and nxreportd.service are ok and that netstat shows LISTEN

If all is good at this point, NetXMS Reporting server is installed and working, now you are ready to create and install some report templates.

Creating and Installing report templates.

Because we are all impatient, and because there is a learning curve to using Studio to create reports, it is interesting to play with some sample reports.

I like the empty report as it is simple and has nothing to break.

Download the sample reports from https://www.netxms.org/forum/installation/install-report-server/?action=dlattach;attach=2208 and save them to your PC

Exctract the archive (I use Peazip, it can read Zipped Tarballs).

Now open your Jasper Reports Studio, and open the main.jrxml file from within the sample_reports>empty>src>resources folder. This is the actual report template for a demo empty report.

Studio Concepts
1: When you save your template file it MUST be called main.jrxml
2: Best practice seems to be to put main.jrxml in a folder called resources which is in a folder called src, see image at bottom of post.
3: Read https://github.com/netxms/sample-report but note that the sample report in there is a demonstration of the PARAMETERS available, the report doesnt actually query netxms in anyway.
4: download the oracle java mysql connector on your PC, place it somewhere meaningful to you.
5: I have not succeeded to have images work in my templates, dont use them at the beginning. Report will compile but execution will fail on NetXMS
6: Connect your Studio to NetXMS  mysql server (you need to make mysql listen on all interfaces, and also make your Mysql user allow to connect remotely - out of scope of this howto).
7: You can run the reports in the preview tab quite well, and if you have connected studio to mysql it will return data, you can export these to pdf/excel from studio if you wish.
8: If you want to create and run one off reports just run them from Studio, if you want to have other users run reports and/or schedule them to be emailed then add the reports to NetXMS.
9: Take time to understand Jasper Reports concepts of Fields and Parameters.
10: Use the query builder to create your sql query, choose the data connector you installed earlier.
11: In query builder, once you have formulated your sql query press READ FIELDS from the top right. This will scan the query and the DB and populate the fields column below.
12: Review the fields and check that the class types for your data are what you expect.
13: Add Parameters in the parameter tab and tick the IS FOR PROMPT option if you want to enter parameters for your report, e.g. start date and end date for the report query.
14: When you are ready to publish this report (which you must do manually not using studio publish feature) then go to the source tab and remove the PROPERTY NAME that refers to your local data adaptor, NetXMS will use its own data adapter.

Now, in order for Maven to build your report in to a .jar file that you can place in NetXMS report server you must have a pom.xml file.

Use this one:

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

  <modelVersion>4.0.0</modelVersion>
  <groupId>org.netxms.report</groupId>
  <version>1.0.0</version>
  <artifactId>user-list</artifactId>
  <packaging>jar</packaging>
  <name>User List</name>
  <url>http://www.netxms.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

<dependencies>
  <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-all</artifactId>
            <version>2.4.4</version>
  </dependency>
</dependencies>

  <build>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <excludes>
          <exclude>**/*.jasper</exclude>
        </excludes>
      </resource>
    </resources>
    <plugins>
      <plugin>
        <groupId>org.codehaus.gmavenplus</groupId>
        <artifactId>gmavenplus-plugin</artifactId>
        <version>1.4</version>
        <executions>
          <execution>
            <id>set-build-uuid-property</id>
            <phase>initialize</phase>
            <goals>
              <goal>execute</goal>
            </goals>
            <configuration>
              <scripts>
                <script>
                  import java.util.UUID
                  project.properties.setProperty('buildUuid', UUID.randomUUID().toString())
                </script>
              </scripts>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>2.5</version>
        <configuration>
          <archive>
            <manifestEntries>
              <Build-Id>${buildUuid}</Build-Id>
            </manifestEntries>
          </archive>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>



You must edit the following to suit your report:
<artifactId>user-list</artifactId>
<name>User List</name>
<directory>src/main/resources</directory>


Use a directory structure like the image at bottom of post, and place pom.xml in the root, this is the file structure BEFORE you use maven to assemble the final .jar file. Maven build process will place the META-INF and MANIFEST.MF in the correct place:


To build the report, execute from within the root structure of your project (where pom.xml is):

mvn package

This should build without errors, and create a folder called target with the resulting .jar file inside. This is what you will deploy to Nxreportd.

To deploy the report template, copy the .jar file in target directory to:

/var/lib/netxms/nxreportd/definitions

To check if it was deployed, run systemctl status nxreportd.service and read the log at the bottom.

Now restart netxmsd and nxreportd services.

Log back in to nxmc and go to report perspective, you should see your report listed in the report navigator. Click it and the execute it.
#2
Hi.

I have installed NetXMS on a server successfully and I have installed nxmc console on a windows machine and my android tablet. All works fine.

My problem is trying to run the 64bit console on my Ubuntu 16.04 machine which is my primary machine.

Java on my laptop is:
openjdk version "9-internal"
OpenJDK Runtime Environment (build 9-internal+0-2016-04-14-195246.buildd.src)
OpenJDK 64-Bit Server VM (build 9-internal+0-2016-04-14-195246.buildd.src, mixed mode)


The problem I get when I run nxmc is:

Splash screen shows, then the error below shows:

An error has occurred. See the log file
/home/alex/nxmc/configuration/1465766534651.log.


The contents of the log file dont mean much to me but I see plenty errors: See attachment.

Any help you can give me to get this running is much appreciated.

Regards,

Alex