Check Agent for Modbus

Hi,
I’m trying to integrate a device wich works with Modbus_tcp.
I’ve found a previous post that indicates “first check if the agent works correct with your device”.
The agent is in …check_mk/share/trasures/modbus.
How can I check the agent from shell?

Thanks
jose

3 Likes

Hi, I’m looking to deploy it. Here’s the other topic for reference: [Check_mk (english)] Agent for MODBUS

The agent that you can test is available at the following folder:

/opt/omd/sites/SITENAME/share/doc/check_mk/treasures/modbus/agents/special
./agent_modbus IPADDRESS 502 856:2:counter:active_energy 790:2:gauge:active_power

Before testing it you should install the library libmodbus (apt-get install libmodbus or yum install libmodbus)

After installing the libraries and enabling ModBus on a test UPS it worked here using the following parameters:

./agent_modbus XX.XX.XX.XX 502 192:1:counter:“Battery Remaining Time (Minutes)”

246 was the response I was waiting.

image

Use the following commands to install the components:

checks

cp /opt/omd/sites/SITENAME/share/doc/check_mk/treasures/modbus/checks/* /opt/omd/sites/SITENAME/share/check_mk/checks/

checkman

cp /opt/omd/sites/SITENAME/share/doc/check_mk/treasures/modbus/checkman/* /opt/omd/sites/SITENAME/share/check_mk/checkman/

agents

cp /opt/omd/sites/SITENAME/share/doc/check_mk/treasures/modbus/agents/special* /opt/omd/sites/SITENAME/share/check_mk/agents/special/

wato

cp /opt/omd/sites/SITENAME/share/doc/check_mk/treasures/modbus/wato* /opt/omd/sites/SITENAME/share/check_mk/web/plugins/wato/

image

image

image

Hello
It does not work for me on CheckMK 2.1.0p17.cre
Indeed, there is no /opt/omd/sites/SITENAME/share/check_mk/web/plugins/wato/ directory
There is a directory /opt/omd/sites/vic//lib/python3/cmk/gui/plugins/wato/ where I tried to copy the wato modbus.py script.
But Modbus is not proposed in Other Integrations part.
Should I do something else ?
Thx

1 Like

Hi @fledorze,
You are completely right, that folder does not exist, but let me correct my tutorial with more details to assist with your setup.

I`m using 2.2.0p2.cre
image

Execute with your root account.

sudo su
cd
/opt/omd/sites/SITENAME

Now let`s Start:

  • checks (Copy, Paste, Adjust Permissions and check) - 2 Files

cp ./share/doc/check_mk/treasures/modbus/checks/* ./share/check_mk/checks/
ls -lah ./share/check_mk/checks/ | grep modbus

You should be able to see this result:

  • checkman (Copy, Paste and Adjust Permissions) - 1 File

cp ./share/doc/check_mk/treasures/modbus/checkman/* ./share/check_mk/checkman/
ls -lah ./share/check_mk/checkman/ | grep modbus

  • agents (Copy, Paste and Adjust Permissions) - 2 Files

cp ./share/doc/check_mk/treasures/modbus/agents/special/* ./share/check_mk/agents/special/
ls -lah ./share/check_mk/agents/special/ | grep modbus

  • wato (Create Folders, Copy, Paste, Adjust Permissions and check) - 1 File

mkdir ./share/check_mk/web/plugins && chmod 755 ./share/check_mk/web/plugins
mkdir ./share/check_mk/web/plugins/wato && chmod 755 ./share/check_mk/web/plugins/wato
cp ./share/doc/check_mk/treasures/modbus/wato/* ./share/check_mk/web/plugins/wato/
chmod 755 ./share/check_mk/web/plugins/wato/modbus.py
ls -lah ./share/check_mk/web/plugins/wato/ | grep modbus

It might not work and I`m evaluating that on a test environment. :thinking:

The steps are correct, but using 2.2.0 version it does not work properly. You can check the log file and you might see that:


Using 2.1 or a previous one will work:
image
Don`t forget to intall libmodbus-dev and libmodbus-5.

Hello
I followed the steps above and it worked fine on CheckMK 2.1.0p17.cre
thx

1 Like

Thanks for the reply.

Can you mark my answer as an solution?

Hi @pauloadriano : I’ve installed the agent in check 2.1 but I can´t get any answer from device.
Any suggestions?

image

1 Like

Check if your device is accessible from your checkmk instance then try running the command manually:

cd /opt/omd/sites/SITENAME/share/doc/check_mk/treasures/modbus/agents/special

./agent_modbus XX.XX.XX.XX 502 192:1:counter:“Battery Remaining Time (Minutes)”

Hi,
i have send manually: ./agent_modbus 192.168.41.12 502 40103:1:counter:“Temperatur”
Answer: error Illegal data address

The Address 40103 is a Holding Register and works with other programs.
Where is the mistake? Can you help me?

1 Like

Try changing the number of words from 1 to 2 or maybe even more and also try changing the counter type from counter to Gauge. You could also check if libmodbus is installed.

Hi,
I try t send manually:
./agent_modbus x.x.x.x 502 40103:1:counter:“Temperatur”
changing 1/2, counter/gauge

and the answer is always the same: “error: Bad file descriptor”

Can you help me to know where the mistake is?
thanks a lot

1 Like

@stef In that case it seems that we are dealing with an exception, we could use a different plugin like those ones:

If you have any application that can connect to your devices and somehow export that data we can make Checkmk read data and process it. The other alternative is to use RobotMK to use your application and export it like a Robot.

Perhaps

is of any help?

1 Like

I’ve tried to find out the reason for getting Bad file descriptor and the only case where i got this message was by using a wrong port number or destination IP. Please check if the Port is the one which will be used by the Device.

1 Like

Hi, I am the original author from the 2013 version of agent_modbus, I added the modbus “slave” option in the new version, this can be found on my github GitHub - vtacquet/agent_modbus: modbus agent for check_mk

1 Like

Hi,
In the new version 2.0 of the CheckMK Modbus agent there is now the parameter for the Modbus Slave-ID.
But this is still missing in the Wato GUI.
Or can I give this to the agent in the configuration somehow differently?