#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (C) 2019 Checkmk GmbH - License: GNU General Public License v2
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and
# conditions defined in the file COPYING, which is part of this source code package.


# example: agent_modbus 192.168.0.1 502 856:2:counter:active_energy 790:2:gauge:active_power
def agent_modbus_arguments(params, hostname, ipaddress):
    port, vars = params
    args = quote_shell_string(ipaddress)

    args += ' ' + str(port)
    for cid, ctype, words, name in vars:
        args += " %s:%s:%s:%s" % (cid, ctype, words, name.replace(" ", "_"))

    return args


special_agent_info['modbus'] = agent_modbus_arguments
