News:

We really need your input in this questionnaire

Main Menu
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

Messages - alex_rhys-hurn

#1
General Support / Re: How To: NetXMS Reports in 2021
November 27, 2021, 09:46:58 PM
Quote from: Dawid Kellerman on November 27, 2021, 06:34:38 PM
Hi Everyone,
I got the server running but I am afraid my Jasper reports and java powers are limited.
The Alarm resolution works perfectly I found that somewhere in the forum. Sample is just that ..
Does anyone have some reports in .jar file format they are willing to share? Possibly a sticky topic with contributed reports?
Would be great if the server shipped with a few reports on installation!

Thank you  in Advance
Dawid

To comment on your request for other peoples examples of reports in .jar format, this is unlikely to work, because each persons NetXMS deployment will be slightly different. The idata_XXXX tables, Categories and myriad other things will vary from person to person, so the SQL queries that they use may not work for you.

The users list I shared above is a very standard thing, all netXMS have that table, and so it is reasonably safe to share that one.

So I would prefer if folks are willing to share sources of templates, and there are a few already.

It would be nice if there were a sticky like the other object and dci templates that are outthere.

A point on security here, if you do use somebody elses template, be sure to check the SQL code, as you dont want malicious SQL being used against your DB.

Best,

Alex
#2
General Support / Re: How To: NetXMS Reports in 2021
November 27, 2021, 09:38:13 PM
Hi Dawid,

Attached is user-list-1.0.0.jar already compiled. This report will output a list of the users in NetXMS and when they were created and last logged in.

Assuming you are using ubuntu with MySQL the following procedure:

Copy this .jar file to:
/var/lib/netxms/nxreportd/definitions

and restart nxreportd with:
systemctl restart nxreportd

Attached PDF shows what the output should look like. (edited for privacy)

Also attached is a zip file of the source of this report, it should build with no problems (as it has no dependencies) with:
mvn package

Note that java knowledge is not required. You can learn with some youtubes how to make a report in Jasper quite quickly, but you will need to learn some sql query code, and learn the data layout in the NetXMS dictionary.

This user report is simple because it just queries the users table with a simple:
SELECT * FROM netxms.users;

That is the query code in the Jasper Reports Query builder. You must modify this SQL query code to suit the Database Engine you are using.

Let me know if you struggle.
#3
General Support / Re: ModbusTCP support
November 26, 2021, 04:20:41 PM
Hi,

What we do is as follows:

1) Deploy an Ubuntu Virtual Machine in the same VLAN as the Monitoring network
2) Install MBPoll (https://github.com/epsilonrt/mbpoll)
3) Install NetXMS Agent
4) Write a script that uses mbpoll to poll your modbus devices and return data.
5) Call the script from within netxms agent as ExternalParameter
6) NetXMS Agent will send the data back to NetXMS Server (over encrypted link)
7) Create your nodes for the data you want.

Here is an example, this is a Moxa Gateway that is polling Comap Genset controls (but this can be modified to poll any Modbus device as long as you know the IP, Slave Address and Register you want to poll):

The "G2Mode=" part of the statement in below command is the name of the Node that will be passed to NetXMS
The "-r 168" part of the statement in below command is the Modbus Register that you want to read
           echo -n G2Mode= &  mbpoll -a $MBADDR $IPADDR -c 1 -t 4 -r 168 -1 | awk 'NR==14' | awk '{$1=""; print $0}' | awk '{$1=$1}1'

Output of the above command looks like (This case a text string is returned to show what mode the Genset is in, could be OFF,MAN,ON,AUTO):
           G2Mode=AUTO
So NetXMS would see the Object and DCI as G2Mode, and the data as AUTO

Script to poll generators

#!/bin/sh
# Created: 30-Mar-2020
# This is a single script used by ExternalParametersProvider in NetXMS to collect multiple values on an interval:
# Doc: https://www.netxms.org/documentation/adminguide/agent-management.html#externalparametersprovider
# Topic: Collect various parameters from Gensets

#Define IP Address of Moxa Mgate in Generator
IPADDR=a.b.c.d
#Define Modbus Slave Address of Comap in Generator
MBADDR=6
#Define the Parameters to use in DCI and then poll via Modbus, and output everything on 1 line with no spaces
#The modbus register to poll is defined by -r

echo -n G2Mode= &  mbpoll -a $MBADDR $IPADDR -c 1 -t 4 -r 168 -1 | awk 'NR==14' | awk '{$1=""; print $0}' | awk '{$1=$1}1'
echo -n G2EngineState= &  mbpoll -a $MBADDR $IPADDR -c 1 -t 4 -r 163 -1 | awk 'NR==14' | awk '{$1=""; print $0}' | awk '{$1=$1}1'
echo -n G2ActivePower= &  mbpoll -a $MBADDR $IPADDR -c 1 -t 4 -r 264 -1 | awk 'NR==14' | awk '{$1=""; print $0}' | awk '{$1=$1}1'
echo -n G2ApparentPower= &  mbpoll -a $MBADDR $IPADDR -c 1 -t 4 -r 274 -1 | awk 'NR==14' | awk '{$1=""; print $0}' | awk '{$1=$1}1'
echo -n G2PowerFactor= &  mbpoll -a $MBADDR $IPADDR -c 1 -t 4 -r 261 -1 | awk 'NR==14' | awk '{$1=""; print $0}' | awk '{$1=$1}1'
echo -n G2TempCoolant= &  mbpoll -a $MBADDR $IPADDR -c 1 -t 4 -r 17 -1 | awk 'NR==14' | awk '{$1=""; print $0}' | awk '{$1=$1}1'
echo -n G2TempRoom= &  mbpoll -a $MBADDR $IPADDR -c 1 -t 4 -r 35 -1 | awk 'NR==14' | awk '{$1=""; print $0}' | awk '{$1=$1}1'
echo -n G2PressLubeOil= &  mbpoll -a $MBADDR $IPADDR -c 1 -t 4 -r 16 -1 | awk 'NR==14' | awk '{$1=""; print $0}' | awk '{$1=$1}1'
echo -n G2-V-L1-N= &  mbpoll -a $MBADDR $IPADDR -c 1 -t 4 -r 249 -1 | awk 'NR==14' | awk '{$1=""; print $0}' | awk '{$1=$1}1'
echo -n G2-V-L2-N= &  mbpoll -a $MBADDR $IPADDR -c 1 -t 4 -r 250 -1 | awk 'NR==14' | awk '{$1=""; print $0}' | awk '{$1=$1}1'
echo -n G2-V-L3-N= &  mbpoll -a $MBADDR $IPADDR -c 1 -t 4 -r 251 -1 | awk 'NR==14' | awk '{$1=""; print $0}' | awk '{$1=$1}1'
echo -n G2-V-L1-L2= &  mbpoll -a $MBADDR $IPADDR -c 1 -t 4 -r 253 -1 | awk 'NR==14' | awk '{$1=""; print $0}' | awk '{$1=$1}1'
echo -n G2-V-L2-L3= &  mbpoll -a $MBADDR $IPADDR -c 1 -t 4 -r 254 -1 | awk 'NR==14' | awk '{$1=""; print $0}' | awk '{$1=$1}1'
echo -n G2-V-L3-L1= &  mbpoll -a $MBADDR $IPADDR -c 1 -t 4 -r 255 -1 | awk 'NR==14' | awk '{$1=""; print $0}' | awk '{$1=$1}1'
echo -n G2Frequency= &  mbpoll -a $MBADDR $IPADDR -c 1 -t 4 -r 256 -1 | awk 'NR==14' | awk '{$1=""; print $0}' | awk '{$1=$1}1'
echo -n G2CurrentL1= &  mbpoll -a $MBADDR $IPADDR -c 1 -t 4 -r 258 -1 | awk 'NR==14' | awk '{$1=""; print $0}' | awk '{$1=$1}1'
echo -n G2CurrentL2= &  mbpoll -a $MBADDR $IPADDR -c 1 -t 4 -r 259 -1 | awk 'NR==14' | awk '{$1=""; print $0}' | awk '{$1=$1}1'
echo -n G2CurrentL3= &  mbpoll -a $MBADDR $IPADDR -c 1 -t 4 -r 260 -1 | awk 'NR==14' | awk '{$1=""; print $0}' | awk '{$1=$1}1'
echo -n G2BatteryV= &  mbpoll -a $MBADDR $IPADDR -c 1 -t 4 -r 13 -1 | awk 'NR==14' | awk '{$1=""; print $0}' | awk '{$1=$1}1'
echo -n G2RunHours= &  mbpoll -a $MBADDR $IPADDR -c 1 -t 4:int -r 3587 -B -1 | awk 'NR==14' | awk '{$1=""; print $0}' | awk '{$1=$1}1'
echo -n G2NumStarts= &  mbpoll -a $MBADDR $IPADDR -c 1 -t 4 -r 3589 -1 | awk 'NR==14' | awk '{$1=""; print $0}' | awk '{$1=$1}1'
echo -n G2NumUnscStarts= &  mbpoll -a $MBADDR $IPADDR -c 1 -t 4 -r 3590 -1 | awk 'NR==14' | awk '{$1=""; print $0}' | awk '{$1=$1}1'
echo -n G2kWhours= &  mbpoll -a $MBADDR $IPADDR -c 1 -t 4:int -r 3595 -B -1 | awk 'NR==14' | awk '{$1=""; print $0}' | awk '{$1=$1}1'


NetXMS agent config file /etc/nxagentd.conf:
#GCP1, poll every 10 sec
ExternalParametersProvider = /home/admin/gensets/gcp1.sh:10


People with more skills in scripting both bash and nxsl can probably massivley improve this, but so far its working.

Enjoy.
#4
General Support / Re: How To: NetXMS Reports in 2021
November 25, 2021, 02:27:02 PM
ADDITIONAL NOTES Thanks to Alex K for the info, xposted from Telegram

Report Data Sources

1) Normally you use SQL queries directly to the DB, these should be formatted to suit your own SQL server implementation, if you migrate from one DB platform to another, you should expect to update your report templates, as the queries may no longer work, or work poorly.

2) You cannot currently use NXSL Scripting language directly in the report templates query builder, but you can use java. You can use a datasource java program to access the NetXMS API. See attached example.

Working in the Data Base

The Database tables called idata_XXXX are tables that contain DCI historical data. The Number after idata_ is an ObjectID (node id).

In recent versions of the reporting server you also have access to temporary view, which is created when report is executed, name of this view is passed as IDATA_VIEW report parameter and view is just:

select * from idata_X union all select * from idata_Y ...

- for all nodes in the system, so this way you can query specific DCI for nodes, for example - previously you'd have to use API for that.

For example in the Jasper Reports Studio query builder:

<parameter name="IDATA_VIEW" class="java.lang.String" isForPrompting="false">
      <defaultValueExpression><![CDATA["idata_view"]]></defaultValueExpression>
   </parameter>
...
   <queryString>
      <![CDATA[SELECT ...
FROM $P!{IDATA_VIEW} iv
LEFT JOIN items io ON io.item_id = iv.item_id
LEFT JOIN object_properties op ON op.object_id = io.node_id



#5
General Support / Re: How To: NetXMS Reports in 2021
November 22, 2021, 06:59:44 AM
Dear Alex,

Thank you for the info,  I will make some edits.

Question:

What is the procedure to REMOVE a report?

Do I just delete the .jar file from the /var/lib/netxms/nxreportd/definitions directory?

What about the directory where the report was expanded, must I delete that also, or will nxreportd remve that for me?

Also, when I re-deploy, can I just copy the .jar file and nxreportd will overwrite the contents of the directory already there?

Thanks,

Alex
#6
General Support / Re: error on documentation link
November 21, 2021, 05:35:02 PM
Yes, I am also getting

403 Forbidden
nginx/1.18.0

I also reported on telegram
#7
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.
#8
Hey Victor,

Thanks for the tip.

Creating a symlink to Openjdk 8 in the same folder I extracted the client to, worked fine.

All is well.

Thanks,

Alex
#9
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