opsgenie / opsgenie-integration

Apache License 2.0
28 stars 55 forks source link

support Check_MK v2.x python3 environment #77

Closed autodon closed 3 years ago

autodon commented 3 years ago

The following changes were made to function in newly released Check_MK 2.0.0p1

The plugin description was changed to identify which version of the Opsgenie API was being used, as well as the Check_MK major version supported.

faziletozer commented 3 years ago

The requests library is supported by both python2 and python3 interpreters. So, instead of having two separate files for both versions, can you merge them so that the requests library is used in both?

autodon commented 3 years ago

Agreed, requests is supported by python2 and python3. The "issue" is that Checkmk 2.x only supports python3, and provides it's own version of python3. You want to use the version of python available in the CMK environment. The Checkmk v2.x environment does not have python in the PATH, only python3. This is the reason I created a new file with a description that clearly indicates which Checkmk version it is intended to be used with.

Another option would be to have the header line read "#!/usr/bin/env python" and ask the user to create a symlink in their Checkmk 2.x environment pointing to python3. I did not want to do this. I would prefer to avoid directing the user to alter their python environment.

CMK 1.6.x environment

OMD[TestSite1x]:~$ which python
~/bin/python
OMD[TestSite1x]:~$ which python2
~/bin/python2
OMD[TestSite1x]:~$ which python3
/usr/bin/python3
OMD[TestSite1x]:~$ ls -l ~/bin/ | grep -i python
lrwxrwxrwx. 1 root root         7 Oct 13  2020 python -> python2*
lrwxrwxrwx. 1 root root        14 Oct 13  2020 python-config -> python2-config*
lrwxrwxrwx. 1 root root         9 Oct 13  2020 python2 -> python2.7*
lrwxrwxrwx. 1 root root        16 Oct 13  2020 python2-config -> python2.7-config*
-rwxr-xr-x. 1 root root     35592 Oct 13  2020 python2.7*
-rwxr-xr-x. 1 root root      1683 Oct 13  2020 python2.7-config*

CMK 2.0.x environment

OMD[TestSite2x]:~$ which python
/bin/python
OMD[TestSite2x]:~$ which python2
/bin/python2
OMD[TestSite2x]:~$ which python3
~/bin/python3
OMD[TestSite2x]:~$ ls -l ~/bin/ | grep -i python
lrwxrwxrwx. 1 root root         9 Mar 25 14:05 python3 -> python3.8*
lrwxrwxrwx. 1 root root        16 Mar 25 14:05 python3-config -> python3.8-config*
-rwxr-xr-x. 1 root root     18560 Mar 16 20:05 python3.8*
-rwxr-xr-x. 1 root root      3069 Feb  3 03:04 python3.8-config*