monitoring-plugins
monitoring-plugins copied to clipboard
All Plugins: venv handling does not work anymore
Describe the bug
As of today, when creating a Python venv for the monitoring plugins, there is no bin/activate_this.py anymore, but only bin/activate. This shell script is not directly executable. To start the venv, the shell script must be called with source bin/activate, which is not possible with exec('source ...').
So the code block # considering a virtual environment has to be refactored.
https://stackoverflow.com/questions/25020451/no-activate-this-py-file-in-venv-pyvenv
First guess: If putting https://raw.githubusercontent.com/pypa/virtualenv/main/src/virtualenv/activation/python/activate_this.py into /path/to/venv/monitoring-plugins-venv3/ and doing an export MONITORING_PLUGINS_VENV3=/path/to/venv/monitoring-plugins-venv3/, it fails with
Traceback (most recent call last):
File "mycheck3", line 28, in <module>
exec(open(ACTIVATE_THIS).read(), {'__file__': ACTIVATE_THIS}) # pylint: disable=W0122
File "<string>", line 28, in <module>
AttributeError: 'str' object has no attribute 'decode'. Did you mean: 'encode'?
which is clear because of Python2 code. Seems that we have to deliver a new activate_this.py by ourselves?
Get the bin/activate from Python 2, adapt this and put it in assets.
Since we are focusing on the compiled plugins on target systems, this may not be necessary anymore.
Code removed.