generated from jiuka/checkmk_template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 45d4f52
Showing
18 changed files
with
387 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.155.1/containers/ubuntu/.devcontainer/base.Dockerfile | ||
|
||
# [Choice] CheckMK version: 1.6.0-latest, 2.0.0-latest, 2.1.0-latest | ||
ARG VARIANT="2.1.0-latest" | ||
FROM checkmk/check-mk-raw:${VARIANT} | ||
|
||
RUN /docker-entrypoint.sh /bin/true | ||
|
||
# [Optional] Uncomment this section to install additional OS packages. | ||
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ | ||
&& apt-get -y install --no-install-recommends nodejs gcc | ||
|
||
ADD requirements.txt /tmp/requirements.txt | ||
RUN PATH="/omd/sites/cmk/bin:${PATH}" \ | ||
OMD_ROOT="/omd/sites/cmk" \ | ||
/omd/sites/cmk/bin/pip3 install -r /tmp/requirements.txt | ||
|
||
ENTRYPOINT ["/bin/bash"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
NAME=$(python -c 'print(eval(open("package").read())["name"])') | ||
rm /omd/sites/cmk/var/check_mk/packages/* ||: | ||
ln -s $WORKSPACE/package /omd/sites/cmk/var/check_mk/packages/$NAME | ||
|
||
mkp -v pack $NAME | ||
|
||
# Set Outputs for GitHub Workflow steps | ||
if [ -n "$GITHUB_WORKSPACE" ]; then | ||
echo "::set-output name=pkgfile::$(ls *.mkp)" | ||
echo "::set-output name=pkgname::${NAME}" | ||
VERSION=$(python -c 'print(eval(open("package").read())["version"])') | ||
echo "::set-output name=pkgversion::$VERSION" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: | ||
// https://github.com/microsoft/vscode-dev-containers/tree/v0.155.1/containers/ubuntu | ||
{ | ||
"name": "Checkmk", | ||
"build": { | ||
"dockerfile": "Dockerfile", | ||
// Update 'VARIANT' to pick an Ubuntu version: focal, bionic | ||
"args": { "VARIANT": "2.1.0-latest" } | ||
}, | ||
|
||
// Set *default* container specific settings.json values on container create. | ||
"settings": { | ||
"terminal.integrated.shell.linux": "/bin/bash" | ||
}, | ||
|
||
// Add the IDs of extensions you want installed when the container is created. | ||
"extensions": [ | ||
"ms-python.python", | ||
"littlefoxteam.vscode-python-test-adapter" | ||
], | ||
|
||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
|
||
// Use 'postCreateCommand' to run commands after the container is created. | ||
"postCreateCommand": ".devcontainer/symlink.sh", | ||
|
||
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. | ||
"remoteUser": "cmk", | ||
|
||
"remoteEnv": { | ||
"PATH": "${containerEnv:PATH}:/omd/sites/cmk/bin:/omd/sites/cmk/local/lib/python3/bin/", | ||
"OMD_ROOT": "/omd/sites/cmk", | ||
"OMD_SITE": "cmk", | ||
"CMK_SITE_ID": "cmk", | ||
"WORKSPACE": "${containerWorkspaceFolder}" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
flake8 | ||
pytest | ||
pytest-cov | ||
requests-mock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
for DIR in 'agents' 'checkman' 'checks' 'doc' 'inventory' 'notifications' 'pnp-templates' 'web'; do | ||
rm -rfv $OMD_ROOT/local/share/check_mk/$DIR | ||
ln -sv $WORKSPACE/$DIR $OMD_ROOT/local/share/check_mk/$DIR | ||
done; | ||
|
||
rm -rfv $OMD_ROOT/local/lib/check_mk/base/plugins/agent_based | ||
ln -sv $WORKSPACE/agent_based $OMD_ROOT/local/lib/check_mk/base/plugins/agent_based | ||
|
||
rm -rfv $OMD_ROOT/local/lib/nagios/plugins | ||
ln -sv $WORKSPACE/nagios_plugins $OMD_ROOT/local/lib/nagios/plugins |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# DO NOT EDIT - Change template-sync.conf | ||
include .devcontainer/ | ||
include .devcontainer/** | ||
exclude .github/template-sync.conf | ||
include .github/ | ||
include .github/** | ||
include .vscode/ | ||
include .vscode/** | ||
include .flake8 | ||
include .gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Add additional sync excludes for this repo | ||
#exclude .github/do-not-sync | ||
#exclude .flake8 | ||
#exclude .gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/bash | ||
|
||
TEMPDIR=$(mktemp -d) | ||
|
||
cleanup() { | ||
echo "Removing $TEMPDIR" | ||
rm -rf $TEMPDIR | ||
} | ||
trap cleanup EXIT | ||
|
||
git -C $TEMPDIR clone https://github.com/jiuka/checkmk_template.git | ||
|
||
CMD="rsync --archive --cvs-exclude --no-owner --no-group --no-times --verbose" | ||
if [ -e ".devcontainer/template-sync.conf" ]; then | ||
CMD="${CMD} --filter='merge .devcontainer/template-sync.conf'" | ||
fi | ||
if [ -e "${TEMPDIR}/checkmk_template/.devcontainer/template-sync-includes.conf" ]; then | ||
CMD="${CMD} --filter='merge ${TEMPDIR}/checkmk_template/.devcontainer/template-sync-includes.conf'" | ||
fi | ||
CMD="${CMD} --filter='exclude *' ${TEMPDIR}/checkmk_template/ $(pwd)/" | ||
bash -c "$CMD" | ||
|
||
echo $CMD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[flake8] | ||
# In .style.yapf and .pylintrc we use 100, but in some cases this isn't enforced. | ||
max-line-length=550 | ||
ignore= | ||
################################################################################################ | ||
# Miscellaneous stuff | ||
################################################################################################ | ||
################################################################################################ | ||
# Incompatible with YAPF | ||
################################################################################################ | ||
# unexpected spaces around keyword / parameter equals | ||
E251, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: build-release | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
- '!v*[a-z]' | ||
|
||
jobs: | ||
build-release: | ||
name: Build Release Package | ||
runs-on: ubuntu-latest | ||
container: | ||
image: checkmk/check-mk-raw:2.1.0-latest | ||
|
||
env: | ||
OMD_ROOT: /omd/sites/cmk | ||
OMD_SITE: cmk | ||
CMK_SITE_ID: cmk | ||
WORKSPACE: ${{ github.workspace }} | ||
|
||
steps: | ||
- name: Initialize Checkmk Site | ||
run: /docker-entrypoint.sh /bin/true | ||
- uses: actions/checkout@v2 | ||
- name: Setup links | ||
run: .devcontainer/symlink.sh | ||
- name: Update GITHUB_PATH | ||
run: echo "/omd/sites/cmk/bin" >> $GITHUB_PATH | ||
- name: Build Extension | ||
run: .devcontainer/build.sh | ||
id: cmkpkg | ||
|
||
- name: Create Release | ||
id: create_release | ||
uses: actions/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: Release ${{ github.ref }} | ||
draft: false | ||
prerelease: false | ||
|
||
- name: Upload Release Asset | ||
uses: actions/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./${{ steps.cmkpkg.outputs.pkgfile }} | ||
asset_name: ${{ steps.cmkpkg.outputs.pkgfile }} | ||
asset_content_type: application/octet-stream |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: build | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**' | ||
tags-ignore: | ||
- 'v*' | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
name: Build Checkmk package | ||
runs-on: ubuntu-latest | ||
container: | ||
image: checkmk/check-mk-raw:2.1.0-latest | ||
|
||
env: | ||
OMD_ROOT: /omd/sites/cmk | ||
OMD_SITE: cmk | ||
CMK_SITE_ID: cmk | ||
WORKSPACE: ${{ github.workspace }} | ||
|
||
steps: | ||
- name: Initialize Checkmk Site | ||
run: /docker-entrypoint.sh /bin/true | ||
- uses: actions/checkout@v2 | ||
- name: Setup links | ||
run: .devcontainer/symlink.sh | ||
- name: Update GITHUB_PATH | ||
run: echo "/omd/sites/cmk/bin" >> $GITHUB_PATH | ||
- name: Build Extension | ||
run: .devcontainer/build.sh | ||
id: cmkpkg | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: ${{ steps.cmkpkg.outputs.pkgfile }} | ||
path: ${{ steps.cmkpkg.outputs.pkgfile }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Lint | ||
|
||
on: | ||
push: | ||
paths: | ||
- '**.py' | ||
|
||
jobs: | ||
flake8_py3: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python 3.8 | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: 3.8 | ||
- name: Install flake8 | ||
run: pip install flake8 | ||
- name: Run flake8 | ||
uses: suo/flake8-github-action@releases/v1 | ||
with: | ||
checkName: 'flake8_py3' # NOTE: this needs to be the same as the job name | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: pytest | ||
|
||
on: | ||
push: [] | ||
|
||
jobs: | ||
pytest: | ||
|
||
runs-on: ubuntu-latest | ||
container: | ||
image: checkmk/check-mk-raw:2.1.0-latest | ||
|
||
env: | ||
OMD_ROOT: /omd/sites/cmk | ||
OMD_SITE: cmk | ||
CMK_SITE_ID: cmk | ||
WORKSPACE: ${{ github.workspace }} | ||
|
||
steps: | ||
- name: Initialize Checkmk Site | ||
run: /docker-entrypoint.sh /bin/true | ||
- uses: actions/checkout@v2 | ||
- name: Setup links | ||
run: ./.devcontainer/symlink.sh | ||
- name: Install pytest | ||
run: su -l -c "REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt pip3 install -r $GITHUB_WORKSPACE/.devcontainer/requirements.txt" cmk | ||
- name: Update GITHUB_PATH | ||
run: echo "/omd/sites/cmk/bin" >> $GITHUB_PATH | ||
- name: Run pytest | ||
run: python3 -m pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
*.mkp | ||
.coverage | ||
__pycache__ | ||
debug.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"python.pythonPath": "/omd/sites/cmk/bin/python3", | ||
"python.linting.flake8Enabled": true, | ||
"python.linting.enabled": true, | ||
"python.testing.pytestArgs": [ | ||
"." | ||
], | ||
"python.testing.unittestEnabled": false, | ||
"python.testing.nosetestsEnabled": false, | ||
"python.testing.pytestEnabled": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
// See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
// for the documentation about the tasks.json format | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "Install", | ||
"type": "shell", | ||
"command": ".devcontainer/build.sh", | ||
"problemMatcher": [], | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
} | ||
}, | ||
{ | ||
"label": "Start Site", | ||
"type": "shell", | ||
"command": "omd start", | ||
"problemMatcher": [] | ||
}, | ||
{ | ||
"label": "Re-Start Site", | ||
"type": "shell", | ||
"command": "omd restart", | ||
"problemMatcher": [] | ||
}, | ||
{ | ||
"label": "Stop Site", | ||
"type": "shell", | ||
"command": "omd stop", | ||
"problemMatcher": [] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Checkmk extension for ... | ||
|
||
![build](https://github.com/jiuka/checkmk_phion/workflows/build/badge.svg) | ||
![flake8](https://github.com/jiuka/checkmk_phion/workflows/Lint/badge.svg) | ||
![pytest](https://github.com/jiuka/checkmk_phion/workflows/pytest/badge.svg) | ||
|
||
## Description | ||
|
||
This is a template to develop Checkmk Extensions | ||
|
||
## Development | ||
|
||
For the best development experience use [VSCode](https://code.visualstudio.com/) with the [Remote Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension. This maps your workspace into a checkmk docker container giving you access to the python environment and libraries the installed extension has. | ||
|
||
## Directories | ||
|
||
The following directories in this repo are getting mapped into the Checkmk site. | ||
|
||
* `agents`, `checkman`, `checks`, `doc`, `inventory`, `notifications`, `pnp-templates`, `web` are mapped into `local/share/check_mk/` | ||
* `agent_based` is mapped to `local/lib/check_mk/base/plugins/agent_based` | ||
* `nagios_plugins` is mapped to `local/lib/nagios/plugins` | ||
|
||
## Continuous integration | ||
### Local | ||
|
||
To build the package hit `Crtl`+`Shift`+`B` to execute the build task in VSCode. | ||
|
||
`pytest` can be executed from the terminal or the test ui. | ||
|
||
### Github Workflow | ||
|
||
The provided Github Workflows run `pytest` and `flake8` in the same checkmk docker conatiner as vscode. |
Oops, something went wrong.