Skip to content

Commit

Permalink
chore: switch project to Python 3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
markuslf committed Jan 7, 2025
1 parent ce42316 commit 8fc8250
Show file tree
Hide file tree
Showing 17 changed files with 41 additions and 72 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nuitka-compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:
- run: 'python.exe -m pip install --upgrade ordered-set Nuitka Nuitka'

# install 3rd party libraries for all check plugins
- run: 'python.exe -m pip install --requirement ${{ github.workspace }}\monitoring-plugins\requirements.txt'
- run: 'python.exe -m pip install --requirement ${{ github.workspace }}\monitoring-plugins\requirements.txt --require-hashes'

# info in case of errors
- run: 'python.exe -m pip list'
Expand Down
6 changes: 3 additions & 3 deletions BUILD.rst
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ Compile using PyInstaller:
cd
cd monitoring-plugins
python3.9 -m pip install --requirement requirements.txt
python3.9 -m pip install --requirement requirements.txt --require-hashes
# compile with pyinstaller
cd check-plugins/disk-usage
Expand Down Expand Up @@ -178,7 +178,7 @@ Compile using Nuitka:
cd
cd monitoring-plugins
python3.9 -m pip install --requirement requirements.txt
python3.9 -m pip install --requirement requirements.txt --require-hashes
# compile with nuitka
cd check-plugins/disk-usage
Expand Down Expand Up @@ -271,7 +271,7 @@ Setup Python on Windows:
python.exe -m pip install --upgrade pip wheel setuptools
python.exe -m pip install --upgrade ordered-set Nuitka pyinstaller
python.exe -m pip install --requirement=requirements.txt
python.exe -m pip install --requirement requirements.txt --require-hashes
Compile using Nuitka+MSVC:

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Icinga Director:

Monitoring Plugins:

* Since some libraries such as pymysql or openssl have security vulnerabilities for Python 3.6, the project now requires Python 3.9+ to use the plugins in the source code variant.
* jitsi-videobridge-stats: Remove deprecated values ([PR #780](https://github.com/Linuxfabrik/monitoring-plugins/pull/780), thanks to [SnejPro](https://github.com/SnejPro))
* jitsi-videobridge-stats: Remove deprecated warning and critical parameters, always returns OK

Expand Down
10 changes: 5 additions & 5 deletions INSTALL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ In general, you have two options:

OS, Motivation, Install
Linux, "Want to use my OS's package manager and have distro that uses rpm/deb package formats","Package from `Linuxfabrik's Repo Server <https://repo.linuxfabrik.ch>`_"
Linux, "Don't want to use my OS's package manager or have distro that uses package formats other than rpm/deb and can't run Python 3.6+",Binaries from .tar or .zip file on `Linuxfabrik's Download Server <https://download.linuxfabrik.ch/monitoring-plugins/>`_
Linux, "Want to use the latest development version and Python 3.6+ available", `Source code variant from GitHub <https://github.com/Linuxfabrik/monitoring-plugins/tree/main>`_
Linux, "Don't want to use my OS's package manager or have distro that uses package formats other than rpm/deb and can't run Python 3.9+",Binaries from .tar or .zip file on `Linuxfabrik's Download Server <https://download.linuxfabrik.ch/monitoring-plugins/>`_
Linux, "Want to use the latest development version and Python 3.9+ available", `Source code variant from GitHub <https://github.com/Linuxfabrik/monitoring-plugins/tree/main>`_
Windows,"Want to use EXE files",Binaries in ``/windows`` on `Linuxfabrik's Download Server <https://download.linuxfabrik.ch/monitoring-plugins/windows/>`_
Windows,"Want to use the latest development version and Python 3.6+ available", `Source code variant from GitHub <https://github.com/Linuxfabrik/monitoring-plugins/tree/main>`_
Windows,"Want to use the latest development version and Python 3.9+ available", `Source code variant from GitHub <https://github.com/Linuxfabrik/monitoring-plugins/tree/main>`_

FAQ:

Expand Down Expand Up @@ -115,7 +115,7 @@ Python: Run from Source Code

You may use this if nothing from the above fits your needs.

If you run the Linuxfabrik check plugins directly from source (which is no problem at all), you need to install Python 3 on the remote host. The plugins work with at least Python 3.6, but some of them (currently ``disk-io``) will only run if Python 3.8+ is available.
If you run the Linuxfabrik check plugins directly from source (which is no problem at all), you need to install Python 3.9+ on the remote host.


Installation
Expand Down Expand Up @@ -178,7 +178,7 @@ We try to avoid dependencies on 3rd party OS- or Python-libraries wherever possi
.. code-block:: bash
python3 -m pip install --upgrade pip
python3 -m pip install --requirement requirements.txt
python3 -m pip install --requirement requirements.txt --require-hashes
To make SELinux happy, after installing from source, run:

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ To avoid problems when passing *parameter values* that start with a `-`, the com

## Python

When running from source, almost all check plugins are happy with at least Python 3.6. All plugins define the `#!/usr/bin/env python3` shebang.
When running from source, almost all check plugins are happy with Python 3.9+. All plugins define the `#!/usr/bin/env python3` shebang.


## Icons
Expand Down
12 changes: 6 additions & 6 deletions build/shared/venv.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/env bash

python3 -m venv --system-site-packages pyinstaller
python3.9 -m venv --system-site-packages pyinstaller
source pyinstaller/bin/activate

python3 -m pip install --upgrade pip
python3 -m pip install --upgrade wheel
python3 -m pip install --upgrade setuptools
python3 -m pip install pyinstaller
python3.9 -m pip install pip==24.3.1
python3.9 -m pip install wheel==0.45.1
python3.9 -m pip install setuptools==50.3.2
python3.9 -m pip install pyinstaller==6.11.1

# install any libraries specific for the project
python3 -m pip install --requirement=/repos/monitoring-plugins/requirements.txt
python3.9 -m pip install --requirement=/repos/monitoring-plugins/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ADD https://raw.githubusercontent.com/Linuxfabrik/monitoring-plugins/refs/heads/
RUN python -m venv /tmp/venv && \
. /tmp/venv/bin/activate && \
python -m pip install --upgrade pip && \
python -m pip install --no-cache-dir --requirement requirements.txt
python -m pip install --no-cache-dir --requirement requirements.txt --require-hashes

# Verify Python installation
RUN /tmp/venv/bin/python --version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ADD https://raw.githubusercontent.com/Linuxfabrik/monitoring-plugins/refs/heads/

# Install dependencies using pip
RUN python3 -m pip install --upgrade pip && \
python3 -m pip install --no-cache-dir --requirement requirements.txt
python3 -m pip install --no-cache-dir --requirement requirements.txt --require-hashes

# Verify Python installation
RUN python3 --version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ADD https://raw.githubusercontent.com/Linuxfabrik/monitoring-plugins/refs/heads/
RUN python3 -m venv /tmp/venv && \
. /tmp/venv/bin/activate && \
python3 -m pip install --upgrade pip && \
python3 -m pip install --no-cache-dir --requirement requirements.txt
python3 -m pip install --no-cache-dir --requirement requirements.txt --require-hashes

# Verify Python installation
RUN python3 --version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ADD https://raw.githubusercontent.com/Linuxfabrik/monitoring-plugins/refs/heads/

# Install dependencies using pip
RUN python3 -m pip install --upgrade pip wheel setuptools && \
python3 -m pip install --no-cache-dir --requirement requirements.txt
python3 -m pip install --no-cache-dir --requirement requirements.txt --require-hashes

# Verify Python installation
RUN python3 --version
Expand Down
10 changes: 5 additions & 5 deletions check-plugins/cpu-usage/unit-test/containerfiles/rhel-v8
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Base image: Official RHEL 8
FROM registry.access.redhat.com/ubi8

# Install Python 3
RUN dnf -y install python3
# Install Python 3.9
RUN dnf -y install python3.9

# Install tools
RUN dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm && \
Expand All @@ -15,11 +15,11 @@ WORKDIR /tmp
ADD https://raw.githubusercontent.com/Linuxfabrik/monitoring-plugins/refs/heads/main/requirements.txt /tmp/requirements.txt

# Install dependencies using pip
RUN python3 -m pip install --upgrade pip && \
python3 -m pip install --no-cache-dir --requirement requirements.txt
RUN python3.9 -m pip install --upgrade pip && \
python3.9 -m pip install --no-cache-dir --requirement requirements.txt --require-hashes

# Verify Python installation
RUN python3 --version
RUN python3.9 --version

# Default command to keep the container running
CMD ["sleep", "infinity"]
11 changes: 6 additions & 5 deletions check-plugins/cpu-usage/unit-test/containerfiles/rhel-v9
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Base image: Official RHEL 9
FROM registry.access.redhat.com/ubi9

# Install Python 3
RUN dnf -y install python3 python3-pip
# Install Python 3.9
RUN dnf -y install python3.9 python3.9-pip

# Install tools
RUN dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm && \
Expand All @@ -15,11 +15,12 @@ WORKDIR /tmp
ADD https://raw.githubusercontent.com/Linuxfabrik/monitoring-plugins/refs/heads/main/requirements.txt /tmp/requirements.txt

# Install dependencies using pip
RUN python3 -m pip install --upgrade pip && \
python3 -m pip install --no-cache-dir --requirement requirements.txt
RUN dnf -y remove python3-requests
RUN python3.9 -m pip install --upgrade pip && \
python3.9 -m pip install --no-cache-dir --requirement requirements.txt --require-hashes

# Verify Python installation
RUN python3 --version
RUN python3.9 --version

# Default command to keep the container running
CMD ["sleep", "infinity"]
23 changes: 0 additions & 23 deletions check-plugins/cpu-usage/unit-test/containerfiles/sles-v15

This file was deleted.

12 changes: 7 additions & 5 deletions check-plugins/cpu-usage/unit-test/containerfiles/ubuntu-v2004
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ FROM ubuntu:20.04
# Prevent interactive prompts during package installation
ENV DEBIAN_FRONTEND=noninteractive

# Update and install Python 3 and pip
# Update and install Python 3.9 and pip
RUN apt-get update && \
apt-get install -y python3 python3-pip && \
apt-get install -y python3.9 python3.9-venv python3-pip && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

Expand All @@ -17,11 +17,13 @@ WORKDIR /tmp
ADD https://raw.githubusercontent.com/Linuxfabrik/monitoring-plugins/refs/heads/main/requirements.txt /tmp/requirements.txt

# Install dependencies using pip
RUN python3 -m pip install --upgrade pip && \
python3 -m pip install --no-cache-dir --requirement requirements.txt
RUN python3.9 -m venv /tmp/venv && \
. /tmp/venv/bin/activate && \
python3.9 -m pip install --upgrade pip && \
python3.9 -m pip install --no-cache-dir --requirement requirements.txt --require-hashes

# Verify Python installation
RUN python3 --version
RUN python3.9 --version

# Default command to keep the container running
CMD ["sleep", "infinity"]
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ADD https://raw.githubusercontent.com/Linuxfabrik/monitoring-plugins/refs/heads/

# Install dependencies using pip
RUN python3 -m pip install --upgrade pip && \
python3 -m pip install --no-cache-dir --requirement requirements.txt
python3 -m pip install --no-cache-dir --requirement requirements.txt --require-hashes

# Verify Python installation
RUN python3 --version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ADD https://raw.githubusercontent.com/Linuxfabrik/monitoring-plugins/refs/heads/
RUN python3 -m venv /tmp/venv && \
. /tmp/venv/bin/activate && \
python3 -m pip install --upgrade pip && \
python3 -m pip install --no-cache-dir --requirement requirements.txt
python3 -m pip install --no-cache-dir --requirement requirements.txt --require-hashes

# Verify Python installation
RUN python3 --version
Expand Down
12 changes: 0 additions & 12 deletions check-plugins/cpu-usage/unit-test/run
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,6 @@ TESTS = [
},
],
},
{
'containerfile': 'containerfiles/sles-v15',
'podman-run-params': '',
'tests': [
{
'run-where': 'container',
'plugin-params': '',
'assert-regex': r'\d+\.\d+% -.* user:',
'assert-retc': 0,
},
],
},
{
'containerfile': 'containerfiles/ubuntu-v2004',
'podman-run-params': '',
Expand Down

0 comments on commit 8fc8250

Please sign in to comment.