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 on Shinken Migration to Python 3: Any News? #2031

Open
garadar opened this issue Nov 30, 2023 · 11 comments
Open

Update on Shinken Migration to Python 3: Any News? #2031

garadar opened this issue Nov 30, 2023 · 11 comments

Comments

@garadar
Copy link

garadar commented Nov 30, 2023

Dear @naparuba, @geektophe, and @shinken-solutions,

I am an HPC system engineer and have been using Shinken since my beginning in this vast IT world.

I used to work on RHEL/CentOS7, but ongoing administration/maintenance is pushing us to migrate to newer architectures, EL8/9, which complicates the deployment of Shinken with Python 2.

Currently, we are using a Docker container, but it has its limitations.

Do you have any updates on the migration to Python 3?

Thank you for your work and this solution !

PS: (I doubt you are not already aware, but...) The Python tool https://docs.python.org/3/library/2to3.html may be an interesting tool for automating the translation to Python 3.

PS2: If you need help maybe some tasks can be delegate to the community and pull requested. Let us know !

@getienne53
Copy link

hi

I think the project is actually stop or dead :-(

I installed version 3 of Shinken in a debian 11 VM with the following procedure:

apt-get install python3-pip python-six python3-bottle python3-cherrypy3
adduser shinken
su - shinken
git clone https://github.com/shinken-solutions/shinken.git

cd /home/shinken/shinken
python3 setup.py install
python3 setup.py post_install --install-conf --install-default --install-init

for i in arbiter poller reactionner scheduler broker receiver; do
systemctl enable shinken-$i.service;
done

/usr/local/bin/shinken-arbiter -v -c /etc/shinken/shinken.cfg //to control good installation

The 6 shinken services are started !

Well, but the following "shinken" script which apparently allows you to add modules (like webui2) does not seem to have been completely ported to Python3.
-->/usr/local/lib/python3.9/dist-packages/Shinken-3.0.0rc1-py3.9.egg/EGG-INFO/scripts/shinken

In particular, there are several errors in the ConfigParser commands, and the CONFIG dictionary.

best regards

@garadar
Copy link
Author

garadar commented Feb 19, 2024

Hi @getienne53

It was I did, I installed shinken on VM rocky 8 separate of other soft to avoid incompatibility python issue. All with pip is working but you have to set alternative python to python 2.

@getienne53
Copy link

Thanks for your reply @garadar :-)

I tried with update-alternatives --config python :

Selection Path Priority Status

  • 0 /usr/bin/python3.9 2 auto mode
    1 /usr/bin/python2.7 1 manual mode
    2 /usr/bin/python3.9 2 manual mode

Selection 0, 1 or 2 give the same error -->

File "/usr/local/lib/python3.9/dist-packages/Shinken-3.0.0rc1-py3.9.egg/EGG-INFO/scripts/shinken", line 428, in main
cfg = ConfigParser.ConfigParser()
NameError: name 'ConfigParser' is not defined

"ConfigParser" is a python2 command.
The shebang of shinken script is python2 --> #!/usr/bin/env python

So, i don't understand why that dont work, with python 2.7.18

If i modify the shebang with #!/usr/bin/env python3, i have the same error with python3

that's life :-(

@garadar
Copy link
Author

garadar commented Feb 19, 2024

Weird indeed. I a migrating my vm I will give my prodecure once completed.

But I used pip to install it and I had to reinstall my-curl in a specific and old version and recompile another package with specific option.... Well I need to document clearly.

I also contact the customer service of shinken
Enterprise to know if this solution is compatible with latest OS.

Are you on rocky 8 too?

@Guillaume001
Copy link

Hi,

I converted all the files via 2to3 and corrected the problems when running cli shinken. Module installation seems to be working fine.

https://github.com/Guillaume001/shinken/tree/python3

On Debian 12 and Python 3.11.2.

I've got all the deamons running and they seem to be taking their configuration.

I'm trying to port mod-livestatus and mod-logstore-sqlite to connect a thruk but there are still quite a few problems.

@garadar
Copy link
Author

garadar commented Feb 20, 2024

Interesting, I am using this both mod, what kind of issue do you have ?

@getienne53
Copy link

hello

I took the shinken script writed in python3 from Guillaume001's repository. (thanks to him)

Now "sudo shinken --init" works :-)

I tried to install the webui or webui2 modules and I got the following error:

sudo shinken install webui2
Traceback (most recent call last):
File "/usr/local/bin/shinken", line 4, in
import('pkg_resources').run_script('Shinken==3.0.0rc1', 'shinken')
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 651, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 1448, in run_script
exec(code, namespace, namespace)
File "/usr/local/lib/python3.9/dist-packages/Shinken-3.0.0rc1-py3.9.egg/EGG-INFO/scripts/shinken", line 546, in
main()
File "/usr/local/lib/python3.9/dist-packages/Shinken-3.0.0rc1-py3.9.egg/EGG-INFO/scripts/shinken", line 456, in main
CLI = CLICommander(CONFIG, cfg, opts)
File "/usr/local/lib/python3.9/dist-packages/Shinken-3.0.0rc1-py3.9.egg/EGG-INFO/scripts/shinken", line 154, in init
self.load_cli_mods(opts)
File "/usr/local/lib/python3.9/dist-packages/Shinken-3.0.0rc1-py3.9.egg/EGG-INFO/scripts/shinken", line 186, in load_cli_mods
spec.loader.exec_module(m)
File "", line 790, in exec_module
File "", line 228, in _call_with_frames_removed
File "/var/lib/shinken/cli/shinkenio/cli.py", line 35, in
from StringIO import StringIO
ModuleNotFoundError: No module named 'StringIO'

By replacing "from StringIO import StringIO" with "from io import StringIO" in /var/lib/shinken/cli/shinkenio/cli.py, we move forward but we still get the error:

shinken@ct-shinken:~/shinken$ sudo shinken install webui2
Grabbing : webui2
TypeError: string argument expected, got 'bytes'
[1708442557] ERROR: [Shinken] There was a critical error : (23, 'Failure writing output to destination')

Same error with "webui" module.

Any idea ?

@garadar
Copy link
Author

garadar commented Feb 20, 2024

Hi @getienne53
On my side I use Trhuk for the webGUI, and it's working really fine. Thruk is not dead:

https://github.com/sni/Thruk

@Guillaume001
Copy link

hi @getienne53

Actualy, i install module livestatus and logstore-sqlite via the following commands :
git clone https://github.com/shinken-monitoring/mod-livestatus.git
git clone https://github.com/shinken-monitoring/mod-logstore-sqlite.git
shinken install --local mod-livestatus/
shinken install --local mod-logstore-sqlite/

Some parts may be missing for downloading modules..

@Guillaume001
Copy link

hi @garadar

I currently have the following errors :

broker logs

[1708385159] INFO: [broker-master] We received modules [<module type=livestatus name=livestatus />, <module type=logstore_sqlite name=logstore-sqlite />] 
[1708385160] WARNING: [broker-master] Cannot import livestatus : __bases__ assignment: 'LifoQueue' deallocator differs from 'object'
[1708385160] WARNING: [broker-master] Cannot import livestatus.livestatus.module : __bases__ assignment: 'LifoQueue' deallocator differs from 'object'
[1708385160] WARNING: [broker-master] Cannot import logstore-sqlite.logstore-sqlite.module : 'NoneType' object has no attribute 'LiveStatusStack'
[1708385160] WARNING: [broker-master] Cannot import livestatus : __bases__ assignment: 'LifoQueue' deallocator differs from 'object'
[1708385160] WARNING: [broker-master] Cannot import livestatus.livestatus.module : __bases__ assignment: 'LifoQueue' deallocator differs from 'object'
[1708385160] WARNING: [broker-master] The module type livestatus for livestatus was not found in modules!
[1708385160] WARNING: [broker-master] The module type logstore-sqlite for logstore-sqlite was not found in modules!
[1708385160] INFO: [broker-master] I correctly loaded the modules: []

scheduler logs

[1708455999] WARNING: [Shinken] 1 checks never came back for the satellite 'poller-master'. I reenable them for polling

during starting up reactionner and poller daemon :

I STOP THE http_daemon <shinken.http_daemon.HTTPDaemon object at 0x7f5d9408b5d0>
I STOP THE http_daemon <shinken.http_daemon.HTTPDaemon object at 0x7f5d9408b5d0>
I STOP THE http_daemon <shinken.http_daemon.HTTPDaemon object at 0x7f5d9408b5d0>
I STOP THE http_daemon <shinken.http_daemon.HTTPDaemon object at 0x7f5d9408b5d0>

@garadar
Copy link
Author

garadar commented Apr 5, 2024

Hi @Guillaume001 @getienne53

It's been a while, but I'm back with some exciting news, I hope. I've managed to make Shinken work without any code changes on Rocky 8.

Here's the procedure I posted: #2033.

Additionally, I've created a SaltStack (similar to Puppet or Ansible) Shinken installation for automatic deployment.

So far, I haven't encountered any conflicts or errors. :)

Let me know how it's work for you !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants