Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for Checkmk 2.3.0 #5

Merged
merged 7 commits into from
Jun 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.155.1/containers/ubuntu/.devcontainer/base.Dockerfile

# [Choice] CheckMK version: 2.2.0-latest
ARG VARIANT="2.2.0-latest"
# [Choice] CheckMK version: 2.3.0-latest
ARG VARIANT="2.3.0-latest"
FROM checkmk/check-mk-raw:${VARIANT}

RUN /docker-entrypoint.sh /bin/true
Expand Down
10 changes: 1 addition & 9 deletions .devcontainer/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,11 @@

NAME=$(python3 -c 'print(eval(open("package").read())["name"])')
VERSION=$(python3 -c 'print(eval(open("package").read())["version"])')
rm -f $NAME-$VERSION.mkp \
/omd/sites/cmk/var/cat check_mk/packages/${NAME}-*.mkp \
rm /omd/sites/cmk/var/check_mk/packages/${NAME} \
/omd/sites/cmk/var/check_mk/packages_local/${NAME}-*.mkp ||:

mkp -v package package 2>&1 | sed '/Installing$/Q' ||:

cp /omd/sites/cmk/var/check_mk/packages_local/$NAME-$VERSION.mkp .

mkp inspect $NAME-$VERSION.mkp

# Set Outputs for GitHub Workflow steps
if [ -n "$GITHUB_WORKSPACE" ]; then
echo "pkgfile=${NAME}-${VERSION}.mkp" >> $GITHUB_OUTPUT
echo "pkgname=${NAME}" >> $GITHUB_OUTPUT
echo "pkgversion=$VERSION" >> $GITHUB_OUTPUT
fi
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"build": {
"dockerfile": "Dockerfile",
// Update 'VARIANT' to pick an Ubuntu version: focal, bionic
"args": { "VARIANT": "2.2.0-latest" }
"args": { "VARIANT": "2.3.0-latest" }
},

"customizations": {
Expand Down
3 changes: 2 additions & 1 deletion .devcontainer/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
flake8
pytest
pytest-md
pytest-cov
pytest-mock
pytest-emoji
requests-mock
9 changes: 7 additions & 2 deletions .devcontainer/symlink.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
#!/bin/bash
PKGNAME=$(python3 -c 'print(eval(open("package").read())["name"])')
ln -sv $WORKSPACE $OMD_ROOT/local/lib/python3/cmk_addons/plugins/$PKGNAME

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/python3/cmk/base/plugins/agent_based
ln -sv $WORKSPACE/agent_based $OMD_ROOT/local/lib/python3/cmk/base/plugins/agent_based

mkdir -p $OMD_ROOT/local/lib/python3/cmk/base/cee/plugins
ln -sv $WORKSPACE/bakery $OMD_ROOT/local/lib/python3/cmk/base/cee/plugins/bakery

rm -rfv $OMD_ROOT/local/lib/nagios/plugins
ln -sv $WORKSPACE/nagios_plugins $OMD_ROOT/local/lib/nagios/plugins
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
buy_me_a_coffee: jiuka
21 changes: 14 additions & 7 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: Build Release Package
runs-on: ubuntu-latest
container:
image: checkmk/check-mk-raw:2.2.0-latest
image: checkmk/check-mk-raw:2.3.0-latest
permissions:
contents: write

Expand All @@ -24,17 +24,24 @@ jobs:
steps:
- name: Initialize Checkmk Site
run: /docker-entrypoint.sh /bin/true
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Parse Package File
run: |
NAME=$(python3 -c 'print(eval(open("package").read())["name"])')
VERSION=$(python3 -c 'print(eval(open("package").read())["version"])')
echo "CMKPKG_NAME=$NAME" >> "$GITHUB_ENV"
echo "CMKPKG_VERSION=$VERSION" >> "$GITHUB_ENV"
- 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
run: |
chown -R cmk:cmk $GITHUB_WORKSPACE
su -l -c "mkp -v package $GITHUB_WORKSPACE/package" cmk
cp /omd/sites/cmk/var/check_mk/packages_local/${CMKPKG_NAME}-${CMKPKG_VERSION}.mkp .
echo "pkgfile=${CMKPKG_NAME}-${CMKPKG_VERSION}.mkp" >> $GITHUB_OUTPUT
id: cmkpkg

- name: Create Release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
release_name: Release ${{ github.ref }}
draft: false
Expand Down
20 changes: 14 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
name: Build Checkmk package
runs-on: ubuntu-latest
container:
image: checkmk/check-mk-raw:2.2.0-latest
image: checkmk/check-mk-raw:2.3.0-latest

env:
OMD_ROOT: /omd/sites/cmk
Expand All @@ -24,16 +24,24 @@ jobs:
steps:
- name: Initialize Checkmk Site
run: /docker-entrypoint.sh /bin/true
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Parse Package File
run: |
NAME=$(python3 -c 'print(eval(open("package").read())["name"])')
VERSION=$(python3 -c 'print(eval(open("package").read())["version"])')
echo "CMKPKG_NAME=$NAME" >> "$GITHUB_ENV"
echo "CMKPKG_VERSION=$VERSION" >> "$GITHUB_ENV"
- 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
run: |
chown -R cmk:cmk $GITHUB_WORKSPACE
su -l -c "mkp -v package $GITHUB_WORKSPACE/package" cmk
cp /omd/sites/cmk/var/check_mk/packages_local/${CMKPKG_NAME}-${CMKPKG_VERSION}.mkp .
echo "pkgfile=${CMKPKG_NAME}-${CMKPKG_VERSION}.mkp" >> $GITHUB_OUTPUT
id: cmkpkg
- name: Upload artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ steps.cmkpkg.outputs.pkgfile }}
path: ${{ steps.cmkpkg.outputs.pkgfile }}
12 changes: 8 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,23 @@ on:
push:
paths:
- '**.py'
- .github/workflows/lint.yml

jobs:
flake8_py3:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v4
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.9
python-version: '3.12'
- name: Install flake8
run: pip install flake8
- name: Run flake8
uses: py-actions/flake8@v2
with:
plugins: "flake8-github"
args: "--format github"
29 changes: 16 additions & 13 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
name: pytest

on:
push: []
push:
paths:
- '**.py'
- .github/workflows/pytest.yml

jobs:
pytest:

runs-on: ubuntu-latest
container:
image: checkmk/check-mk-raw:2.2.0-latest
image: checkmk/check-mk-raw:2.3.0-latest

env:
OMD_ROOT: /omd/sites/cmk
Expand All @@ -17,14 +20,14 @@ jobs:
WORKSPACE: ${{ github.workspace }}

steps:
- name: Initialize Checkmk Site
run: /docker-entrypoint.sh /bin/true
- uses: actions/checkout@v3
- 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
- name: Initialize Checkmk Site
run: /docker-entrypoint.sh /bin/true
- uses: actions/checkout@v4
- 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: Run pytest
run: |
chown -R cmk:cmk $GITHUB_WORKSPACE $GITHUB_STEP_SUMMARY
su -l -c "cd $GITHUB_WORKSPACE; python3 -m pytest -v --emoji -cov . --md $GITHUB_STEP_SUMMARY " cmk
8 changes: 4 additions & 4 deletions agent_based/dell_storage_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# checkmk_dell_storage - Checkmk extension for Dell Storage API
#
# Copyright (C) 2021 Marius Rieder <marius.rieder@scs.ch>
# Copyright (C) 2021-2024 Marius Rieder <marius.rieder@durchmesser.ch>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand All @@ -19,9 +19,9 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

from .agent_based_api.v1 import (
from cmk.agent_based.v2 import (
CheckPlugin,
Metric,
register,
Result,
Service,
State,
Expand All @@ -45,7 +45,7 @@ def check_dell_storage_agent(section):
yield Metric('time', float(time))


register.check_plugin(
check_plugin_dell_storage_agent = CheckPlugin(
name='dell_storage_agent',
service_name='Dell Storage API',
discovery_function=discovery_dell_storage_agent,
Expand Down
11 changes: 6 additions & 5 deletions agent_based/dell_storage_alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# checkmk_dell_storage - Checkmk extension for Dell Storage API
#
# Copyright (C) 2021 Marius Rieder <marius.rieder@scs.ch>
# Copyright (C) 2021-2024 Marius Rieder <marius.rieder@durchmesser.ch>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand All @@ -20,8 +20,9 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

from typing import NamedTuple
from .agent_based_api.v1 import (
register,
from cmk.agent_based.v2 import (
AgentSection,
CheckPlugin,
Result,
Service,
State,
Expand All @@ -39,7 +40,7 @@ def parse_dell_storage_alert(string_table):
return [ScAlert(*alert) for alert in string_table]


register.agent_section(
agent_section_dell_storage_alert = AgentSection(
name='dell_storage_alert',
parse_function=parse_dell_storage_alert,
)
Expand All @@ -60,7 +61,7 @@ def check_dell_storage_alert(section):
yield Result(state=State.WARN, summary=f'{alert.alertDefinition}: {alert.message} {alert.supportUrl}')


register.check_plugin(
check_plugin_dell_storage_alert = CheckPlugin(
name='dell_storage_alert',
service_name='StorageCenter Alert',
discovery_function=discovery_dell_storage_alert,
Expand Down
13 changes: 7 additions & 6 deletions agent_based/dell_storage_center.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# checkmk_dell_storage - Checkmk extension for Dell Storage API
#
# Copyright (C) 2021 Marius Rieder <marius.rieder@scs.ch>
# Copyright (C) 2021-2024 Marius Rieder <marius.rieder@durchmesser.ch>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand All @@ -20,14 +20,15 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

from typing import NamedTuple
from .agent_based_api.v1 import (
from cmk.agent_based.v2 import (
AgentSection,
CheckPlugin,
Metric,
register,
Result,
Service,
State,
)
from .utils.dell_storage import (
from cmk_addons.plugins.dell_storage.lib.dell_storage import (
DSResult
)

Expand All @@ -54,7 +55,7 @@ def parse_dell_storage_center(string_table):
return [StorageCenter(*sc) for sc in string_table]


register.agent_section(
agent_section_dell_storage_center = AgentSection(
name='dell_storage_center',
parse_function=parse_dell_storage_center,
)
Expand Down Expand Up @@ -88,7 +89,7 @@ def check_dell_storage_center(item, section):
return


register.check_plugin(
check_plugin_dell_storage_center = CheckPlugin(
name='dell_storage_center',
service_name='StorageCenter %s',
discovery_function=discovery_dell_storage_center,
Expand Down
13 changes: 7 additions & 6 deletions agent_based/dell_storage_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# checkmk_dell_storage - Checkmk extension for Dell Storage API
#
# Copyright (C) 2021 Marius Rieder <marius.rieder@scs.ch>
# Copyright (C) 2021-2024 Marius Rieder <marius.rieder@durchmesser.ch>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand All @@ -20,13 +20,14 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

from typing import NamedTuple
from .agent_based_api.v1 import (
register,
from cmk.agent_based.v2 import (
AgentSection,
CheckPlugin,
Result,
Service,
State,
)
from .utils.dell_storage import (
from cmk_addons.plugins.dell_storage.lib.dell_storage import (
DSResult
)

Expand All @@ -48,7 +49,7 @@ def parse_dell_storage_controller(string_table):
return [ScController(*ctrl) for ctrl in string_table]


register.agent_section(
agent_section_dell_storage_controller = AgentSection(
name='dell_storage_controller',
parse_function=parse_dell_storage_controller,
)
Expand All @@ -73,7 +74,7 @@ def check_dell_storage_controller(item, section):
return


register.check_plugin(
check_plugin_dell_storage_controller = CheckPlugin(
name='dell_storage_controller',
service_name='Controller %s',
discovery_function=discovery_dell_storage_controller,
Expand Down
Loading