ModbusTCP support

Started by mmarin11, June 15, 2021, 06:57:37 PM

Previous topic - Next topic

mmarin11

Dear community. We are trying to monitor power generators which use ModbusTCP protocol

Is there ModbusTCP support in NetXMS 3.8?

Is someone using NetXMS to monitor power generator using Modbus protocol?

Thank you

Victor Kirhenshtein

Hi,

currently MODBUS/TCP is not supported, although we plan to add it.

Best regards,
Victor

Dawid Kellerman


What you could do is use node-red with modbus and mqtt

Write some code on nodered, poll the modbus and forward the answer to a particular topic mqtt on netxms is listening to.
I do something similar on a click plc (modbus) but can unfortunately not share my code but it is easy to do from the tutorials.

Hope it helps

alex_rhys-hurn

#3
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.

Dawid Kellerman

Hi alex_rhys-hurn
Really elegant solution certainly easier to implement than mine.
From the little that I know seems like this might even give the developers a simple working opensource solution to ship with..

Thank you for sharing!