diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..203f3c8 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: +- package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..3342c54 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,29 @@ +name: Build + +on: [push, pull_request] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + + - uses: actions/checkout@v4 + + - name: Install dependencies + run: | + sudo apt-get update + + - name: Install + run: pip install . + + - name: Show all plugins + run: | + nagios_d3s_check_health || true + echo + nagios_d3s_check_memory || true + echo + nagios_d3s_check_os_updates || true + echo + nagios_d3s_check_systemd_service --service sshd || true diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml new file mode 100644 index 0000000..17336ee --- /dev/null +++ b/.github/workflows/package.yml @@ -0,0 +1,39 @@ +name: Linux packages + +on: [push, pull_request] + +env: + PACKAGE_NAME: d3s-nagios-plugins-git + PACKAGE_MAINTAINER: vhotspur + PACKAGE_SUMMARY: "Collection of various Nagios plugins" + PACKAGE_VERSION: 1.0.0 + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install dependencies + run: | + sudo apt-get update + + - name: Prepare install for Debian + run: | + pip install --root ${{github.workspace}}/pkg-deb --prefix /usr . + find ${{github.workspace}}/pkg-deb + + - uses: jiro4989/build-deb-action@v3 + with: + package_root: ${{github.workspace}}/pkg-deb + package: ${{ env.PACKAGE_NAME }} + maintainer: ${{ env.PACKAGE_MAINTAINER }} + desc: '${{ env.PACKAGE_SUMMARY }}' + version: '${{ env.PACKAGE_VERSION }}' + arch: 'amd64' + + - uses: actions/upload-artifact@v4 + with: + name: deb-package + path: | + ./d3s*.deb diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..c4fbf92 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,47 @@ +name: Release + +on: + push: + tags: + - "v*.*.*" + +env: + PACKAGE_NAME: d3s-nagios-plugins + PACKAGE_MAINTAINER: vhotspur + PACKAGE_SUMMARY: "Collection of various Nagios plugins" + PACKAGE_VERSION: 1.0.0 + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install dependencies + run: | + sudo apt-get update + + - name: Prepare install for Debian + run: | + pip install --root ${{github.workspace}}/pkg-deb --prefix /usr . + find ${{github.workspace}}/pkg-deb + + - uses: jiro4989/build-deb-action@v3 + with: + package_root: ${{github.workspace}}/pkg-deb + package: ${{ env.PACKAGE_NAME }} + maintainer: ${{ env.PACKAGE_MAINTAINER }} + desc: '${{ env.PACKAGE_SUMMARY }}' + version: '${{ env.PACKAGE_VERSION }}' + arch: 'amd64' + + - name: Setup release notes + run: ./contrib/get-release-notes.sh ${{ env.PACKAGE_VERSION }} >gh-release-body.txt + + - name: Release + uses: softprops/action-gh-release@v1 + with: + body_path: gh-release-body.txt + files: | + msim*.deb + msim*.rpm diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..8c7e67b --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,30 @@ +# D3S Nagios Plugins change log + +All notable changes to D3S Nagios Plugins will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## Unreleased + +### Fixed + +### Added + +### Changed + +### Deprecated + +### Removed + + +## v1.0.0 - 2024-03-20 + +### Changed + +* Packaging setup (@vhotspur) +* Move changelog to a more structured format (@vhotspur) + +### Added + +* Automated releases (@vhotspur) diff --git a/contrib/get-release-notes.sh b/contrib/get-release-notes.sh new file mode 100755 index 0000000..8302b3b --- /dev/null +++ b/contrib/get-release-notes.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# Get release notes from change log file. + +set -ueo pipefail + +get_changelog_for() { + # Find text between header lines and remove those header lines + sed -n -e "/^## v${1} - 20[0-9][0-9]-[01][0-9]-[0123][0-9]$/,/^## v/{/^## v/d;p}" +} + +strip_empty_lines() { + # https://unix.stackexchange.com/a/552195 + sed -e '/./,$!d' -e :a -e '/^\n*$/{$d;N;ba' -e '}' +} + +get_changelog_for "$1" < "CHANGELOG.md" | strip_empty_lines diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..1d1cc50 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,4 @@ +[build-system] +requires = ["setuptools>=42"] +build-backend = "setuptools.build_meta" + diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..e95875e --- /dev/null +++ b/setup.cfg @@ -0,0 +1,29 @@ +[metadata] +name = d3s-nagios-plugins +version = 1.0 +author = Vojtech Horky +author_email = horky@d3s.mff.cuni.cz +description = Collection of various Nagios plugins +long_description = file: README.md +long_description_content_type = text/markdown +url = https://github.com/d-iii-s/d3s-nagios-plugins +keywords = Nagios monitoring +classifiers = + License :: OSI Approved :: Apache 2 License + +[options] +package_dir = + = src +packages = find: +python_requires = >=3.8 +zip_safe = False + +[options.packages.find] +where = src + +[options.entry_points] +console_scripts = + nagios_d3s_check_health = d3s.nagios_plugins.check_health:main + nagios_d3s_check_memory = d3s.nagios_plugins.check_memory:main + nagios_d3s_check_os_updates = d3s.nagios_plugins.check_os_updates:main + nagios_d3s_check_systemd_service = d3s.nagios_plugins.check_systemd_service:main diff --git a/setup.py b/setup.py deleted file mode 100755 index 67a394b..0000000 --- a/setup.py +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env python3 - -# -# Copyright 2019 Vojtech Horky -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -from setuptools import setup - -def get_readme(): - with open('README.md') as f: - return f.read() - -setup( - name='d3s-nagios-plugins', - version='0.1', - description='Collection of various Nagios plugins', - long_description=get_readme(), - classifiers=[ - 'Programming Language :: Python :: 3.6', - ], - keywords='nagios monitoring', - url='https://lab.d3s.mff.cuni.cz/nagios-plugins/', - install_requires=[], - include_package_data=True, - zip_safe=False, - packages=[ - 'd3s', - 'd3s.nagios_plugins', - ], - entry_points={ - 'console_scripts': [ - 'nagios_d3s_check_health=d3s.nagios_plugins.check_health:main', - 'nagios_d3s_check_memory=d3s.nagios_plugins.check_memory:main', - 'nagios_d3s_check_os_updates=d3s.nagios_plugins.check_os_updates:main', - 'nagios_d3s_check_systemd_service=d3s.nagios_plugins.check_systemd_service:main', - ], - }, -) diff --git a/d3s/__init__.py b/src/d3s/__init__.py similarity index 100% rename from d3s/__init__.py rename to src/d3s/__init__.py diff --git a/d3s/nagios.py b/src/d3s/nagios.py similarity index 100% rename from d3s/nagios.py rename to src/d3s/nagios.py diff --git a/d3s/nagios_plugins/__init__.py b/src/d3s/nagios_plugins/__init__.py similarity index 100% rename from d3s/nagios_plugins/__init__.py rename to src/d3s/nagios_plugins/__init__.py diff --git a/d3s/nagios_plugins/check_health.py b/src/d3s/nagios_plugins/check_health.py similarity index 100% rename from d3s/nagios_plugins/check_health.py rename to src/d3s/nagios_plugins/check_health.py diff --git a/d3s/nagios_plugins/check_memory.py b/src/d3s/nagios_plugins/check_memory.py similarity index 100% rename from d3s/nagios_plugins/check_memory.py rename to src/d3s/nagios_plugins/check_memory.py diff --git a/d3s/nagios_plugins/check_os_updates.py b/src/d3s/nagios_plugins/check_os_updates.py similarity index 100% rename from d3s/nagios_plugins/check_os_updates.py rename to src/d3s/nagios_plugins/check_os_updates.py diff --git a/d3s/nagios_plugins/check_systemd_service.py b/src/d3s/nagios_plugins/check_systemd_service.py similarity index 100% rename from d3s/nagios_plugins/check_systemd_service.py rename to src/d3s/nagios_plugins/check_systemd_service.py diff --git a/d3s/units.py b/src/d3s/units.py similarity index 100% rename from d3s/units.py rename to src/d3s/units.py