HPE iLO Restful Redfish API Agent

That is the wrong redfish library. In the description of the plugin is written.

pip3 install python-ilorest-library

Until now i had no time to test if it can be rewritten to work with the generic redfish lib. This is used by my Lenovo xClarity special agent as the example from Lenovo also used this lib.

Hello Andreas, I have already python-ilorest-library version 3.2.2 is installed, but than (without any redfish module) this mistake appears:

File β€œ/omd/sites/devel2/local/share/check_mk/agents/special/agent_ilo”, line 29, in
from redfish import RedfishClient
ModuleNotFoundError: No module named 'redfish

I am not familiar wiht python, but in code of agent_ilo files it looks for module β€œredfish”…

The problem is that the module naming is a little bit confusing between the only β€œredfish” module and the β€œpython-ilorest-library”.

From your other post i see that you also installed the redfish module by itself. That is the problem.
You can only remove all manually installed python modules and reinstall the ilorest module with.

pip3 install python-ilorest-library

After this you should see inside β€œ~/local/lib/python3/” a folder structure like this.

rwxrwx--- 3 SITE SITE  4096 Aug 18 19:42 ply/
drwxrwx--- 2 SITE SITE  4096 Aug 18 19:42 ply-3.11.dist-info/
drwxrwx--- 2 SITE SITE  4096 Aug 18 19:42 python_ilorest_library-3.2.2-py3.8.egg-info/
drwxrwx--- 6 SITE SITE  4096 Aug 18 19:42 redfish/
drwxrwx--- 2 SITE SITE  4096 Aug 18 19:42 six-1.16.0.dist-info/
-rw-rw---- 1 SITE SITE 34549 Aug 18 19:42 six.py

and inside the redfish folder you must have.

-rw-rw---- 1 SITE SITE  530 Aug 18 19:42 __init__.py
drwxrwx--- 2 SITE SITE 4096 Aug 18 19:42 __pycache__/
drwxrwx--- 3 SITE SITE 4096 Aug 18 19:42 hpilo/
drwxrwx--- 3 SITE SITE 4096 Aug 18 19:42 rest/
drwxrwx--- 3 SITE SITE 4096 Aug 18 19:42 ris/

If this is the case then the import must work.

1 Like

Thank you so much for help.

Yeah, there were needed to uninstall python-ilorest-library module after uninstalling β€œredfish” module and than after new python-ilorest-library module install, content of redfish folder was corrected.

What is the advantage of using this special agent instead of SNMP?

SNMP is marked as obsolete from all big server manufacturers. The Redfish API is the actual standard for out of bound management for server systems. It is supported from all the relevant players in the market.
I also made a redfish special agent for Lenovo xClarity, Fujitsu and Dell. If i take a look at the output then and how to get this output then all the different systems are nearly identical. The data is complete structured and has not the many limitations of SNMP data (no floating point, no visible dependencies between data values).

1 Like

Hi
I installed your HPE Ilo extension on a 2.0.0p19 (CFE) and also installed all the needed python lib’s (redfish and python-ilorest-library) but I can’t get any information from my ILO.
Then I tried to run the check manually with:

/omd/sites/main/local/share/check_mk/agents/special/agent_ilo --u USER-p PASSWORD IP

And yes, I replaced USER, PASSWORD, and IP with the needed info’s :slight_smile:
The only information I get back is:

Traceback (most recent call last):
  File "/omd/sites/main/local/share/check_mk/agents/special/agent_ilo", line 25, in <module>
    import cmk.utils.password_store
ModuleNotFoundError: No module named 'cmk'
type or paste code here

Maybe you can help me with the issue.

Best regards
Roberto

Have you run this as siteuser or as root?

Attention inside the package notes is written that you should only install the Redfish lib with β€œpip3 install redfish”. The β€œpython-ilorest-library” is not used anymore and it leads to problems.
Actual package version is 3.4 from here. This version needs to be uploaded to the exchange as i have changed it the last week.

Hi tosch,

I tried as root and as a site user with the same issue.

Hi Andreas

I have downloaded your package from GIT. There I only found the version hpe_ilo-3.4.mkp. Is there any other version in your repository?
I have seen as the exchange version is a 3.3 Checkmk Exchange

3.4 is correct^^
But there you cannot install the β€œpython-ilorest-library” the agent will not work with this one.

su siteuser
cmk -P install hpe_ilo-3.4.mkp
pip3 install redfish
~/local/share/check_mk/agents/special/agent_ilo

Hi again

Thanks for the hint. in between, I removed the package and it’s working as expected. :+1:
GREAT work :muscle: and thanks for your quick help.

Hi andreas-doehler,

I tried to use your agent on our iLO5 hosts, but I’m unable to get the check working.

I’ve installed your latest version 3.4 and redfish in version 3.1.6.

When I run the check on commandline, I get the following error:

Traceback (most recent call last):
  File "/omd/sites/intel/local/share/check_mk/agents/special/agent_ilo", line 337, in <module>
    REDFISHOBJ = redfish.redfish_client(base_url=iLO_host, username=iLO_account,
AttributeError: module 'redfish' has no attribute 'redfish_client'

What am I missing?

I tested at my system and had no problem. You are sure that it is only the Python module β€œredfish” installed? Not the old β€œpython-ilorest-library” one.

The test on the command line was done as site user or?
I can do on the command line as site user the following.

python3

import redfish
redfish.redfish_client()

This gives the error message

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/omd/sites/cmk/local/lib/python3/redfish/rest/v1.py", line 1093, in redfish_client
    if "://" not in base_url:
TypeError: argument of type 'NoneType' is not iterable

There you see the library is there and the attribute β€œredfish_client” is also existing.

this is what I get:

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

the system was freshly installed (Ubuntu 20.04), python-ilorest-library is not installed.

I don’t think so. This error only happens if python-ilorest-library is installed.

OMD[central]:~$ 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
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'redfish'
>>> exit()
OMD[central]:~$ pip3 install python-ilorest-library
Collecting python-ilorest-library
  Using cached python-ilorest-library-3.5.0.2.zip (88 kB)
Collecting jsonpatch
  Using cached jsonpatch-1.32-py2.py3-none-any.whl (12 kB)
Collecting jsonpath_rw
  Using cached jsonpath-rw-1.4.0.tar.gz (13 kB)
Collecting jsonpointer
  Using cached jsonpointer-2.3-py2.py3-none-any.whl (7.8 kB)
Collecting urllib3
  Using cached urllib3-1.26.11-py2.py3-none-any.whl (139 kB)
Collecting six
  Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting ply
  Using cached ply-3.11-py2.py3-none-any.whl (49 kB)
Collecting decorator
  Using cached decorator-5.1.1-py3-none-any.whl (9.1 kB)
Using legacy 'setup.py install' for python-ilorest-library, since package 'wheel' is not installed.
Using legacy 'setup.py install' for jsonpath-rw, since package 'wheel' is not installed.
Installing collected packages: six, ply, jsonpointer, decorator, urllib3, jsonpath-rw, jsonpatch, python-ilorest-library
    Running setup.py install for jsonpath-rw ... done
    Running setup.py install for python-ilorest-library ... done
Successfully installed decorator-5.1.1 jsonpatch-1.32 jsonpath-rw-1.4.0 jsonpointer-2.3 ply-3.11 python-ilorest-library-3.5.0.2 six-1.16.0 urllib3-1.26.11
OMD[central]:~$ 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()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'redfish' has no attribute 'redfish_client'
>>>
>>> print(redfish.__version__)
3.5.0.0

With correct lib installed.

OMD[central]:~/local/lib/python3$ ll
total 4
drwxr-xr-x 5 central central 4096 Aug 18 18:48 cmk/
OMD[central]:~/local/lib/python3$ pip3 install redfish
Collecting redfish
  Downloading redfish-3.1.6-py3-none-any.whl (40 kB)
     |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 40 kB 1.9 MB/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 2.8 MB/s
Collecting jsonpath-rw
  Using cached jsonpath-rw-1.4.0.tar.gz (13 kB)
Collecting jsonpointer
  Using cached jsonpointer-2.3-py2.py3-none-any.whl (7.8 kB)
Collecting jsonpatch
  Using cached 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 848 kB/s
Collecting ply
  Using cached ply-3.11-py2.py3-none-any.whl (49 kB)
Collecting decorator
  Using cached decorator-5.1.1-py3-none-any.whl (9.1 kB)
Collecting six
  Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting certifi>=2017.4.17
  Downloading certifi-2022.6.15-py3-none-any.whl (160 kB)
     |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 160 kB 32.8 MB/s
Collecting urllib3<1.27,>=1.21.1
  Using cached urllib3-1.26.11-py2.py3-none-any.whl (139 kB)
Collecting idna<4,>=2.5
  Downloading idna-3.3-py3-none-any.whl (61 kB)
     |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 61 kB 5.2 MB/s
Collecting charset-normalizer<3,>=2
  Downloading charset_normalizer-2.1.0-py3-none-any.whl (39 kB)
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 charset-normalizer-2.1.0 decorator-5.1.1 idna-3.3 jsonpatch-1.32 jsonpath-rw-1.4.0 jsonpointer-2.3 ply-3.11 redfish-3.1.6 requests-2.28.1 requests-toolbelt-0.9.1 requests-unixsocket-0.3.0 six-1.16.0 urllib3-1.26.11
OMD[central]:~/local/lib/python3$ cd
OMD[central]:~$ 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()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/omd/sites/central/local/lib/python3/redfish/rest/v1.py", line 1093, in redfish_client
    if "://" not in base_url:
TypeError: argument of type 'NoneType' is not iterable
>>> print(redfish.__version__)
3.1.6
>>>

this is my list of installed packages:

OMD[intel]:~$ pip list
Package                Version
---------------------- --------------------
attrs                  19.3.0
Automat                0.8.0
blinker                1.4
certifi                2019.11.28
chardet                3.0.4
Click                  7.0
cloud-init             22.2
colorama               0.4.3
command-not-found      0.3
configobj              5.0.6
constantly             15.1.0
cryptography           2.8
dbus-python            1.2.16
decorator              5.1.1
distro                 1.4.0
distro-info            0.23ubuntu1
entrypoints            0.3
gpg                    1.13.1-unknown
httplib2               0.14.0
hyperlink              19.0.0
idna                   2.8
importlib-metadata     1.5.0
incremental            16.10.1
Jinja2                 2.10.1
jsonpatch              1.22
jsonpath-rw            1.4.0
jsonpointer            2.0
jsonschema             3.2.0
keyring                18.0.1
language-selector      0.1
launchpadlib           1.10.13
lazr.restfulclient     0.14.2
lazr.uri               1.0.3
MarkupSafe             1.1.0
more-itertools         4.2.0
netifaces              0.10.4
oauthlib               3.1.0
pexpect                4.6.0
pip                    20.0.2
ply                    3.11
pyasn1                 0.4.2
pyasn1-modules         0.2.1
pycrypto               2.6.1
PyGObject              3.36.0
PyHamcrest             1.9.0
PyJWT                  1.7.1
pymacaroons            0.13.0
PyNaCl                 1.3.0
pyOpenSSL              19.0.0
pyrsistent             0.15.5
pyserial               3.4
python-apt             2.0.0+ubuntu0.20.4.7
python-debian          0.1.36ubuntu1
PyYAML                 5.3.1
redfish                3.1.6
requests               2.22.0
requests-toolbelt      0.9.1
requests-unixsocket    0.2.0
SecretStorage          2.3.1
service-identity       18.1.0
setuptools             45.2.0
simplejson             3.16.0
six                    1.14.0
sos                    4.3
ssh-import-id          5.10
systemd-python         234
Twisted                18.9.0
ubuntu-advantage-tools 27.9
ufw                    0.36
unattended-upgrades    0.1
urllib3                1.25.8
wadllib                1.3.3
wheel                  0.34.2
zipp                   1.0.0
zope.interface         4.7.1

is there any other way I can check for python-ilorest-library?

this is the output of help(β€˜modules’)

OMD[intel]:~$ python3
Python 3.8.7 (default, Feb  3 2021, 02:48:47)
[GCC 10.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> help('modules')

Please wait a moment while I gather a list of all available modules...

/omd/sites/intel/lib/python3.8/site-packages/setuptools/distutils_patch.py:25: UserWarning: Distutils was imported before Setuptools. This usage is discouraged and may exhibit undesirable behaviors or errors. Please use Setuptools' objects directly or at least import Setuptools first.
  warnings.warn(
Cryptodome          asyncio             jira                requests_kerberos
Cython              asyncore            jmespath            requests_oauthlib
OpenSSL             atexit              json                requests_toolbelt
PIL                 attr                jsonpatch           resource
PyPDF2              audioop             jsonpath_rw         rlcompleter
__future__          babel               jsonpointer         roman
_abc                base64              jsonschema          rrdtool
_ast                bcrypt              jwt                 rsa
_asyncio            bdb                 kerberos            runpy
_bisect             binascii            keyword             s3transfer
_blake2             binhex              kubernetes          sched
_bootlocale         bisect              ldap                secrets
_bz2                boto3               ldapurl             select
_cffi_backend       botocore            ldif                selectors
_codecs             builtins            lib2to3             setuptools
_codecs_cn          bz2                 linecache           setuptools_git
_codecs_hk          cProfile            livestatus          setuptools_scm
_codecs_iso2022     cachetools          locale              shelve
_codecs_jp          calendar            logging             shlex
_codecs_kr          certifi             lzma                shutil
_codecs_tw          cffi                mailbox             signal
_collections        cgi                 mailcap             simple-merge-rrd
_collections_abc    cgitb               markupsafe          site
_compat_pickle      chardet             marshal             sitecustomize
_compression        charset_normalizer  marshmallow         six
_contextvars        chunk               marshmallow_oneofschema slapdtest
_crypt              click               math                smtpd
_csv                cmath               mimetypes           smtplib
_ctypes             cmd                 mmap                snap7
_ctypes_test        code                modulefinder        sndhdr
_curses             codecs              more_itertools      snmpsim
_curses_panel       codeop              multidict           socket
_datetime           collections         multiprocessing     socketserver
_decimal            colorsys            mypy_extensions     spwd
_dummy_thread       compileall          nacl                sqlite3
_elementtree        concurrent          netrc               sre_compile
_functools          configparser        netsnmp             sre_constants
_hashlib            contextlib          nis                 sre_parse
_heapq              contextvars         nntplib             ssl
_imp                copy                ntpath              stat
_io                 copyreg             nturl2path          statistics
_json               crypt               numbers             string
_ldap               cryptography        numpy               stringprep
_locale             csv                 oauthlib            struct
_lsprof             ctypes              omdlib              subprocess
_lzma               curses              opcode              sunau
_markupbase         cython              openapi_spec_validator symbol
_md5                dataclasses         operator            symtable
_mssql              datetime            opsgenie_sdk        sys
_multibytecodec     dateutil            optparse            sysconfig
_multiprocessing    dbm                 ordered_set         syslog
_opcode             decimal             os                  tabnanny
_operator           decorator           ossaudiodev         tarfile
_osx_support        deepdiff            paramiko            telnetlib
_pickle             defusedxml          parser              tempfile
_posixshmem         dicttoxml           passlib             tenacity
_posixsubprocess    difflib             pathlib             termios
_py_abc             dis                 pbr                 textwrap
_pydecimal          distutils           pdb                 this
_pyio               dns                 pickle              threading
_pyrsistent_version docstring_parser    pickletools         time
_queue              doctest             pip                 timeit
_random             docutils            pipes               tkinter
_sha1               dummy_threading     pkg_resources       token
_sha256             easy_install        pkgutil             tokenize
_sha3               email               platform            trace
_sha512             encodings           plistlib            traceback
_signal             ensurepip           ply                 tracemalloc
_sitebuiltins       enum                poplib              tty
_socket             errno               posix               turtle
_sqlite3            faulthandler        posixpath           turtledemo
_sre                fcntl               pprint              types
_ssl                filecmp             profile             typing
_stat               fileinput           pstats              typing_extensions
_statistics         flask               psutil              unicodedata
_string             flask_babel         psycopg2            unittest
_strptime           fnmatch             pty                 urllib
_struct             formatter           pvectorc            urllib3
_symtable           fractions           pwd                 uu
_sysconfigdata__linux_x86_64-linux-gnu ftplib              py_compile          uuid
_testbuffer         functools           pyasn1              vcr
_testcapi           gc                  pyasn1_modules      venv
_testimportmultiple genericpath         pyclbr              warnings
_testinternalcapi   getopt              pycparser           wave
_testmultiphase     getpass             pydoc               weakref
_thread             gettext             pydoc_data          webbrowser
_threading_local    glob                pyexpat             websocket
_tkinter            grp                 pyghmi              werkzeug
_tracemalloc        gzip                pymssql             wrapt
_uuid               hashlib             pymysql             wsgiref
_warnings           heapq               pyparsing           xdrlib
_weakref            hmac                pyprof2calltree     xml
_weakrefset         html                pyrsistent          xmlrpc
_xxsubinterpreters  http                pysmi               xxlimited
_xxtestfuzz         idlelib             pysnmp              xxsubtype
_yaml               idna                pytz                yaml
abc                 imaplib             pyximport           yapf
activedirectory     imghdr              queue               yapftests
adal                imp                 quopri              yarl
aifc                importlib           random              zipapp
antigravity         importlib_metadata  re                  zipfile
apispec             inspect             readline            zipimport
apispec_oneofschema io                  redfish             zipp
argparse            ipaddress           redis               zlib
array               itertools           reportlab
ast                 itsdangerous        reprlib
asynchat            jinja2              requests

Here is the problem - these are Python2 modules and not Python3.
Please don’t mix pip and pip3

The only important folder is β€œ~/local/lib/python3/”.

1 Like

Thank you! You are right, the library was installed and showed with pip3 list.
After pip3 uninstall everything works as expected. Thanks again for your quick support!

1 Like