/
How-to get a local copy of a special agent

How-to get a local copy of a special agent

To modify a Checkmk special agent, avoid changing original files to prevent losing changes after upgrades.

LAST TESTED ON CHECKMK 2.3.0P1

Table of Contents

Step-by-step guide

  1. Log on via SSH and become the siteuser

    root@linux# su mysite

    .

  2. Copy the agent to the local structure

    OMD[mysite]~$: cp \
    ~/lib/python3/cmk/special_agents/<script>.py \
    ~/local/share/check_mk/agents/special/~/lib/python3/cmk/special_agents/<script>
    
    # target without .py extension !

    .

    Please be aware that in order for the custom special agent to be executed by Checkmk instead of the default one, it needs to have the same name as the default special agent.

  3. Make the script executable

    OMD[mysite]~$:chmod +x ~/local/share/check_mk/agents/special/<script>

    .

  4. Append the following line to the end of the script using Vim.

    OMD[mysite]~$: vim ~/local/share/check_mk/agents/special/<script>
    if __name__ == "__main__":
        main()

    For more information, study this python article.