SNMP Check for ISIS-MIB finishing touches - Help

Hello Everyone,

I have been working on some SNMP based checks and I’m nearly ready to publish the first one based on ISIS-MIB.

I found lots of helpful information on the snmp-plugin-basics thread as well as the Phion-MIB example referenced in the article

I also found a helpful template created by @Jiuka, which I’ve decided to use.

I believe the steps I have left to publish this check to the exchange are:

  1. Write tests (this is where I need tips/direction)
  2. Understand and configure devcontainer and environment. (package config?)
  3. Create .mkp file (the process looks straight forward)

Steps1/2 are where I need the most help. This is my first time using a devcontainer with vscode, and I may have missed something. The check currently works, so I’m researching tests and devcontainers to try to fill in my missing knowledge, so I can publish something of good quality the community can use. I would be grateful for any help/direction that might speed up the process.

Cheers,
Curtis

Hi @curtisbowden

Tests are not strictly necessary, but good practice in software development. For the snmp plugins i tend to do unit test which simply test each of the functions in the by it self. I made some examples for you plugin:

The @pytest.mark.parametrize part just calls the function below multiple times with different inputs. However the first two checks only have one set of inputs not multiple.

If you have installed Docker, VSCode and the Remote Containers it should allow you to open the project in a container. You should then be able to run for example pytest. If this does not work I would need to know what error you get while opening the project in a container.

Regards Marius

Hi @Jiuka, (Marius)

Thank you for the response, I’ll admit I was hoping you would see this

I had a look at the tests you wrote, greatly appreciated. The purpose of the tests and the format are easier to understand with the context of functions I’m familiar with. Would it make sense to do a pull request to merge your branch? I could extend the test functions with more inputs to gain some further understanding.

I do have Docker, VSCode and Remote Containers, and VSCode detects the devcontainer when opening the folder. The issue is that I can’t save once it’s running, and I can’t connect to the running CheckMK site in my browser and the container becomes ‘unhealthy’ after a while.

Launch Container
devcontainer-01

Save Error (Trying to fix errors that flake8 detected)
devcontainer-03

Container OK

Container Unhealty

Previous to trying this dev process I was running CheckMK with docker (shown below) and manually pulling a repository into the container with git… but I would like to join the developer’s club and do it properly. I assume I just have to open the port on the devcontainer

docker container run -dit -p 8080:5000 --tmpfs /opt/omd/sites/cmk/tmp:uid=1000,gid=1000 -v/omd/sites --name monitoring -v/etc/localtime:/etc/localtime:ro --restart always checkmk/check-mk-raw:2.0.0-latest

Thanks again Marius, much appreciation.

Cheers,
Curtis