Git Commit Layout Question from New-ish User

CMK version: 2.1.0p20 (CME)
OS version: CentOS 7

Working on developing a special agent plugin and would like to upload it for the community use.
It’s not a complex script but I’ve managed to get a working special agent with discovery.
Since I am new to git, github and development workflows in general I thought I’d ask before doing something silly.

I’ve created files as the omdsiteuser under the following folders:

/omd/sites/<omdsiteuser>/local/share/check_mk/web/plugins/wato/cloudflare_status_api_register.py
/omd/sites/<omdsiteuser>/local/share/check_mk/agents/special/agent_cloudflare_status_api
/omd/sites/<omdsiteuser>/local/share/check_mk/checks/agent_cloudflare_status_api.py
/omd/sites/<omdsiteuser>/local/share/check_mk/checks/cloudflare_status_api

Is it considered best practice to initialize the project from the ‘check_mk’ folder in the path above and ‘git add’ the files using the subfolder/path?
If I decide to work on another plugin later, will there be a conflict?

Or should I build out a special project folder and copy to the omdsiteuser for testing?
Hopefully this isn’t too silly of a question.

Sincerely,
Scotsie

1 Like

Hi Scott,

always nice to see things given back to the community!

a pull request to the upstream repo for a new check will not be granted due to limited resources on tribe29 side. So your best bet is building an .mkp. Checkmk extension packages (MKPs) - Integrating extensions from the community into Checkmk

If you use CFE or CEE you can easily build that from the working files in your environment and pull them into the .mkp using the Web-UI

Gerd

2 Likes

A good way to achieve what @gstolz wrote is to use a devcontainer template like this

from @Jiuka or my modification of his template

2 Likes

What everyone else said: Extensions should start their life as an MKP and might be included in Checkmk when a certain adoption rate is achieved.
There is an article on MKPs in the Official User Guide: Checkmk extension packages (MKPs) - Integrating extensions from the community into Checkmk
In the Checkmk exchange we added two stub MKPs (“Hello World” and “Hello Bakery”) to act solely as a template for own MKPs (the “Hello bakery” is to show bakery integration, not needed in your case). https://exchange.checkmk.com/

1 Like

We use a helper script that copies the contents of an MKP packaged extension into the current directory which then is used as git repo.

1 Like

Thanks for all the replies and encouragement.
I fully intend (and have) create an MKP for the transfer and upload to the exchange.

My intent on this post was more along the lines of creating a repository on github and uploading the code in a file structure that makes sense and is appropriate. I’ve noticed that some exchange repositories are one folder with multiple plugins underneath, while others are individual plugins and they all mirror the folder structure of the OMD folders themselves.

It left me wondering if there are some tips, tricks or standard I’m not aware of and would regret doing something now with a little more experience.

Once again I appreciate the information and feedback.

Sincerely,
Scotsie

Updating this as a follow up and to invite further feedback.
After working more on a custom special agent type check I settled on recreating the $OMD_ROOT folder structure. The special agent location includes a folder outside of the ~/local/share/check_mk structure. I felt it helpful demonstrate the actual path.

./local/lib/check_mk/base/plugins/agent_based/cloudflare_status_api.py
./local/share/check_mk/checkman/cloudflare_status_api
./local/share/check_mk/web/plugins/wato/cloudflare_status_api_register.py
./local/share/check_mk/agents/special/agent_cloudflare_status_api
./local/share/check_mk/checks/agent_cloudflare_status_api.py

I did find that the local/lib/check_mk folder is a symbolic link which git chokes on if trying to deploy directly to the $OMD_ROOT.
My method is to clone down to a folder in the $OMD_ROOT<repofolder> and create symbolic links to represent the actual files. This seems to work fine with the exception that updating the agent_based script actively seemed to require an omd restart of the site for changes to take effect.

I truly appreciate your comments, assistance and links provided. Looking forward to working on more projects in the future.
NOTE: CheckMK Exchange has posted v1.0.0 of the Cloudflare Status API checks but I just uploaded v1.0.2 so that should be forthcoming soon.

Sincerely,
Scotsie