Lenovo Xclarity plugin

Hi,

In my Enterprise distributed environment of Checkmk on version 2.0.0p24 I’ve tried to install plugin based on information below:
https://exchange.checkmk.com/p/lenovo-xclarity
I’ve installed redfish modules based on instructions.

When I implement this new rule with the default username USERID on Lenovo XClarity management, I’ve got this error message below. Is there any known action what else could I do to resolve this problem.

File "/omd/sites/name_of_site/local/share/check_mk/agents/special/agent_lenovo_xclarity", line 186, in <module>
result = get_hw_inventory(ip, login_account, login_password)
File "/omd/sites/name_of_site/local/share/check_mk/agents/special/agent_lenovo_xclarity", line 43, in get_hw_inventory
REDFISH_OBJ = redfish.redfish_client(
AttributeError: module 'redfish' has no attribute 'redfish_client'CRIT
ignored: ucd_cpu_load: CPU load

Regards,
Matjaž

What version of the Python3 Redfish module do you have installed?
It looks like not the correct one.

Hi,

This is the output of installation process.

pip3 install redfish
Collecting redfish
  Downloading redfish-3.1.7-py3-none-any.whl (40 kB)
     |████████████████████████████████| 40 kB 2.1 MB/s
Collecting jsonpatch; python_version >= "3.5"
  Downloading jsonpatch-1.32-py2.py3-none-any.whl (12 kB)
Collecting requests
  Downloading requests-2.28.1-py3-none-any.whl (62 kB)
     |████████████████████████████████| 62 kB 2.1 MB/s
Collecting requests-unixsocket
  Downloading requests_unixsocket-0.3.0-py2.py3-none-any.whl (11 kB)
Collecting jsonpath-rw
  Downloading jsonpath-rw-1.4.0.tar.gz (13 kB)
Collecting jsonpointer
  Downloading jsonpointer-2.3-py2.py3-none-any.whl (7.8 kB)
Collecting requests-toolbelt
  Downloading requests_toolbelt-0.9.1-py2.py3-none-any.whl (54 kB)
     |████████████████████████████████| 54 kB 3.5 MB/s
Collecting idna<4,>=2.5
  Downloading idna-3.3-py3-none-any.whl (61 kB)
     |████████████████████████████████| 61 kB 6.0 MB/s
Collecting urllib3<1.27,>=1.21.1
  Downloading urllib3-1.26.12-py2.py3-none-any.whl (140 kB)
     |████████████████████████████████| 140 kB 8.7 MB/s
Collecting charset-normalizer<3,>=2
  Downloading charset_normalizer-2.1.1-py3-none-any.whl (39 kB)
Collecting certifi>=2017.4.17
  Downloading certifi-2022.6.15.1-py3-none-any.whl (160 kB)
     |████████████████████████████████| 160 kB 14.6 MB/s
Collecting ply
  Downloading ply-3.11-py2.py3-none-any.whl (49 kB)
     |████████████████████████████████| 49 kB 9.6 MB/s
Collecting decorator
  Downloading decorator-5.1.1-py3-none-any.whl (9.1 kB)
Collecting six
  Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Using legacy 'setup.py install' for jsonpath-rw, since package 'wheel' is not installed.
Installing collected packages: jsonpointer, jsonpatch, idna, urllib3, charset-normalizer, certifi, requests, requests-unixsocket, ply, decorator, six, jsonpath-rw, requests-toolbelt, redfish
    Running setup.py install for jsonpath-rw ... done
Successfully installed certifi-2022.6.15.1 charset-normalizer-2.1.1 decorator-5.1.1 idna-3.3 jsonpatch-1.32 jsonpath-rw-1.4.0 jsonpointer-2.3 ply-3.11 redfish-3.1.7 requests-2.28.1 requests-toolbelt-0.9.1 requests-unixsocket-0.3.0 six-1.16.0 urllib3-1.26.12

Was the install done as site user or in the system?
Here an example how it must look like.

OMD[test]:~$ pip3 install redfish
Collecting redfish
  Downloading redfish-3.1.7-py3-none-any.whl (40 kB)
     |████████████████████████████████| 40 kB 649 kB/s
Collecting jsonpatch
  Downloading jsonpatch-1.32-py2.py3-none-any.whl (12 kB)
Collecting jsonpath-rw
  Downloading jsonpath-rw-1.4.0.tar.gz (13 kB)
Collecting requests
  Downloading requests-2.28.1-py3-none-any.whl (62 kB)
     |████████████████████████████████| 62 kB 1.3 MB/s
Collecting requests-unixsocket
  Downloading requests_unixsocket-0.3.0-py2.py3-none-any.whl (11 kB)
Collecting jsonpointer
  Downloading jsonpointer-2.3-py2.py3-none-any.whl (7.8 kB)
Collecting requests-toolbelt
  Downloading requests_toolbelt-0.9.1-py2.py3-none-any.whl (54 kB)
     |████████████████████████████████| 54 kB 1.7 MB/s
Collecting ply
  Downloading ply-3.11-py2.py3-none-any.whl (49 kB)
     |████████████████████████████████| 49 kB 1.7 MB/s
Collecting decorator
  Downloading decorator-5.1.1-py3-none-any.whl (9.1 kB)
Collecting six
  Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting charset-normalizer<3,>=2
  Downloading charset_normalizer-2.1.1-py3-none-any.whl (39 kB)
Collecting certifi>=2017.4.17
  Downloading certifi-2022.6.15.1-py3-none-any.whl (160 kB)
     |████████████████████████████████| 160 kB 1.5 MB/s
Collecting urllib3<1.27,>=1.21.1
  Downloading urllib3-1.26.12-py2.py3-none-any.whl (140 kB)
     |████████████████████████████████| 140 kB 1.6 MB/s
Collecting idna<4,>=2.5
  Downloading idna-3.3-py3-none-any.whl (61 kB)
     |████████████████████████████████| 61 kB 1.8 MB/s
Using legacy 'setup.py install' for jsonpath-rw, since package 'wheel' is not installed.
Installing collected packages: urllib3, idna, charset-normalizer, certifi, six, requests, ply, jsonpointer, decorator, requests-unixsocket, requests-toolbelt, jsonpath-rw, jsonpatch, redfish
    Running setup.py install for jsonpath-rw ... done
Successfully installed certifi-2022.6.15.1 charset-normalizer-2.1.1 decorator-5.1.1 idna-3.3 jsonpatch-1.32 jsonpath-rw-1.4.0 jsonpointer-2.3 ply-3.11 redfish-3.1.7 requests-2.28.1 requests-toolbelt-0.9.1 requests-unixsocket-0.3.0 six-1.16.0 urllib3-1.26.12
OMD[test]:~$ python3
Python 3.9.10 (main, Jul  6 2022, 22:25:18)
[GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import redfish
>>> redfish.redfish_client("192.168.1.1", "user", "password")
/omd/sites/test/local/lib/python3/redfish/rest/v1.py:1108: UserWarning: Scheme not specified for '192.168.1.1'; adding 'https://'
  warnings.warn("Scheme not specified for '{}'; adding 'https://'".format(base_url))

It’s the same redfish version as your one.

Yes I did the installation with site user.
For the refence, currently I’m using not the latest image of appliance. I’m still using 1.4.19, which is still supported. My python3 version is little bit older 3.8.7.
What do you think is it safe to upgrade with latest appliance 1.5.x ?

Here is my call with redfish_client:

OMD[proview_uni]:~$ python3
Python 3.8.7 (default, Feb  3 2021, 02:51:04)
[GCC 10.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import redfish
>>> redfish.redfish_client("192.168.1.1", "user", "password")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'redfish' has no attribute 'redfish_client'
>>>

Regards,
Matjaž

Please check again.

>>> redfish.__version__
'3.1.7'
>>>

Is it possible that you had the “python-redfish” library installed from HPE on the system?
This cannot be a problem of the appliance version. The Python version is inside the CMK site.
The difference here is that my system is a CMK 2.1.0p11. But it must also work on the CMK 2.0.0pxx

Hi,

This is my result.
I just did ssh with root user, then with su site_name and ran the command pip3 install redfish.
Sorry, what exactly you mean with the question regarding “python-redish” installed from HPE on the system?
IF you’re asking about installation of MKP package, it was added through GUI.

>>> import redfish
>>> redfish.__version__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'redfish' has no attribute '__version__'
>>>

Can you please have a look at the folder “~/local/lib/python3/” what is there inside?

Hi,

This is the output of ls.

OMD[proview_uni]:~/local/lib/python3$ ls
__pycache__/                         jsonpointer.py
bin/                                 ply/
certifi/                             ply-3.11.dist-info/
certifi-2022.6.15.1.dist-info/       redfish/
charset_normalizer/                  redfish-3.1.7.dist-info/
charset_normalizer-2.1.1.dist-info/  requests/
cmk/                                 requests-2.28.1.dist-info/
decorator-5.1.1.dist-info/           requests_toolbelt/
decorator.py                         requests_toolbelt-0.9.1.dist-info/
idna/                                requests_unixsocket/
idna-3.3.dist-info/                  requests_unixsocket-0.3.0.dist-info/
jsonpatch-1.32.dist-info/            six-1.16.0.dist-info/
jsonpatch.py                         six.py
jsonpath_rw/                         urllib3/
jsonpath_rw-1.4.0-py3.8.egg-info/    urllib3-1.26.12.dist-info/
jsonpointer-2.3.dist-info/
OMD[proview_uni]:~/local/lib/python3$

Looks ok.
I checked with an 2.0.0p28 and it is working without any problem.

OMD[test2]:~$ pip3 install redfish
Collecting redfish
  Downloading redfish-3.1.7-py3-none-any.whl (40 kB)
     |████████████████████████████████| 40 kB 945 kB/s
Collecting requests-unixsocket
  Downloading requests_unixsocket-0.3.0-py2.py3-none-any.whl (11 kB)
Collecting requests-toolbelt
  Downloading requests_toolbelt-0.9.1-py2.py3-none-any.whl (54 kB)
     |████████████████████████████████| 54 kB 3.0 MB/s
Collecting jsonpatch; python_version >= "3.5"
  Downloading jsonpatch-1.32-py2.py3-none-any.whl (12 kB)
Collecting jsonpointer
  Downloading jsonpointer-2.3-py2.py3-none-any.whl (7.8 kB)
Collecting jsonpath-rw
  Downloading jsonpath-rw-1.4.0.tar.gz (13 kB)
Collecting requests
  Downloading requests-2.28.1-py3-none-any.whl (62 kB)
     |████████████████████████████████| 62 kB 2.2 MB/s
Collecting ply
  Downloading ply-3.11-py2.py3-none-any.whl (49 kB)
     |████████████████████████████████| 49 kB 13.7 MB/s
Collecting decorator
  Downloading decorator-5.1.1-py3-none-any.whl (9.1 kB)
Collecting six
  Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting idna<4,>=2.5
  Downloading idna-3.3-py3-none-any.whl (61 kB)
     |████████████████████████████████| 61 kB 5.1 MB/s
Collecting urllib3<1.27,>=1.21.1
  Downloading urllib3-1.26.12-py2.py3-none-any.whl (140 kB)
     |████████████████████████████████| 140 kB 5.4 MB/s
Collecting charset-normalizer<3,>=2
  Downloading charset_normalizer-2.1.1-py3-none-any.whl (39 kB)
Collecting certifi>=2017.4.17
  Downloading certifi-2022.6.15.1-py3-none-any.whl (160 kB)
     |████████████████████████████████| 160 kB 15.3 MB/s
Using legacy 'setup.py install' for jsonpath-rw, since package 'wheel' is not installed.
Installing collected packages: idna, urllib3, charset-normalizer, certifi, requests, requests-unixsocket, requests-toolbelt, jsonpointer, jsonpatch, ply, decorator, six, jsonpath-rw, redfish
    Running setup.py install for jsonpath-rw ... done
Successfully installed certifi-2022.6.15.1 charset-normalizer-2.1.1 decorator-5.1.1 idna-3.3 jsonpatch-1.32 jsonpath-rw-1.4.0 jsonpointer-2.3 ply-3.11 redfish-3.1.7 requests-2.28.1 requests-toolbelt-0.9.1 requests-unixsocket-0.3.0 six-1.16.0 urllib3-1.26.12
OMD[test2]:~$ python3
Python 3.8.7 (default, Jul  6 2022, 22:50:14)
[GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import redfish
>>> redfish.__version__
'3.1.7'
>>> redfish.redfish_client("192.168.1.1", "user", "password")
/omd/sites/test2/local/lib/python3/redfish/rest/v1.py:1108: UserWarning: Scheme not specified for '192.168.1.1'; adding 'https://'
  warnings.warn("Scheme not specified for '{}'; adding 'https://'".format(base_url))

You see same Python version as in your site.
I don’t know what went wrong in our environment.

Hi,

My environment was upgraded from version 1.6 to 2.0. Any thought about that?

Regards,
Matjaž

I would test with an empty test site and compare your prod system with the test system.
There should be no problem after an 1.6 upgrade.

Hi,

I’ve found one similar system on another site, with same version of site.
At the start, it was promising, redfish client returned result of version properly.

‘’’
OMD[proview_obizola]:~$ python3
Python 3.8.7 (default, Feb 3 2021, 02:51:04)
[GCC 10.1.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

import redfish
redfish.version
‘3.1.7’
quit()
‘’’

Then I create Xclarity Rule for this server object in Checkmk. I’ve used default management user USERID.
After some time I’ve configure Host property to Activate possible API’s
After some time I’ve got similar error like in the first example when I open this topic
Then I went back to ssh console as site user, and very strange, now also redfish client return an eror.

‘’’

import redfish
redfish.version
Traceback (most recent call last):
File “”, line 1, in
AttributeError: module ‘redfish’ has no attribute ‘version
‘’’

Do you have any idea, what could be changed in this procedure for such behavior?

Regards,
Matjaž

Hi,

With the command
pip3 install redfish --upgrade (at least two times)
I was able to restore that the redfish library is working again.
‘’’
OMD[proview_obizola]:~$ python3
Python 3.8.7 (default, Feb 3 2021, 02:51:04)
[GCC 10.1.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

import redfish
redfish.version
‘3.1.7’

‘’’
But as soon after enabling the API for this check, for some time there is same error back like from the start of this Topic.

Regards,
Matjaž

I don’t know what happens on your machine. Something/someone must change there some Python packages over the time :wink:

This is very strange. I also don’t know who is this something/someone.
Now for example I have a situation that one part of library (version) is working, but for exception is not working.

‘’’
OMD[proview_obizola]:~$ python3
Python 3.8.7 (default, Feb 3 2021, 02:51:04)
[GCC 10.1.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

import redfish
redfish.exception
Traceback (most recent call last):
File “”, line 1, in
AttributeError: module ‘redfish’ has no attribute ‘exception’
redfish.version
‘3.1.7’

‘’’

For example this is the latest log, as I saw it from the console of check:

‘’’
File “/omd/sites/proview_obizola/local/share/check_mk/agents/special/agent_lenovo_xclarity”, line 53, in get_hw_inventory
REDFISH_OBJ.login(auth=utils.g_AUTH)
File “/omd/sites/proview_obizola/local/lib/python3/redfish/rest/v1.py”, line 966, in login
raise SessionCreationError(‘HTTP {}: Failed to created the session
{}’.format(resp.status, error_str))
redfish.rest.v1.SessionCreationError: HTTP 404: Failed to created the session
The request specified a URI of a resource that does not exist.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/omd/sites/proview_obizola/local/share/check_mk/agents/special/agent_lenovo_xclarity”, line 186, in
result = get_hw_inventory(ip, login_account, login_password)
File “/omd/sites/proview_obizola/local/share/check_mk/agents/special/agent_lenovo_xclarity”, line 54, in get_hw_inventory
except redfish.exception.RedfishException as e:
AttributeError: module ‘redfish’ has no attribute ‘exception’CRIT
‘’’