wmic_server setup

Home Forums Help wmic_server setup

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #751
    Woland
    Participant

    Hello everyone,

    I’ve been trying to setup the monitoring using the new wmic server but have hit a roadblock

    When I run
    PYTHONPATH=/etc/aiowmi/aiowmi FLASK_ENV=development WMIC_SERVER_DEBUG=1 python3 /etc/aiowmi/contrib/wmic_server/wmic_server.py
    Traceback (most recent call last):
    File “/etc/aiowmi/contrib/wmic_server/wmic_server.py”, line 5, in <module>
    from flask import Flask, jsonify, request, make_response
    File “/usr/local/lib64/python3.6/site-packages/flask/__init__.py”, line 7, in <module>
    from .app import Flask as Flask
    File “/usr/local/lib64/python3.6/site-packages/flask/app.py”, line 20, in <module>
    from werkzeug.routing import BuildError
    File “/usr/local/lib/python3.6/site-packages/werkzeug/routing.py”, line 1378, in <module>
    class UUIDConverter(BaseConverter):
    File “/usr/local/lib/python3.6/site-packages/werkzeug/routing.py”, line 1393, in UUIDConverter
    def to_python(self, value: str) -> uuid.UUID:
    AttributeError: module ‘uuid’ has no attribute ‘UUID’

    When I try to run
    nice gunicorn -b 127.0.0.1:2313 –pythonpath /etc/aiowmi/aiowmi,/etc/aiowmi/contrib/wmic_server –threads 1 wmic_server:app
    [2022-07-16 12:03:47 +1000] [1386296] [INFO] Starting gunicorn 20.1.0
    [2022-07-16 12:03:47 +1000] [1386296] [INFO] Listening at: http://127.0.0.1:2313 (1386296)
    [2022-07-16 12:03:47 +1000] [1386296] [INFO] Using worker: sync
    [2022-07-16 12:03:47 +1000] [1386299] [INFO] Booting worker with pid: 1386299
    [2022-07-16 12:03:47 +1000] [1386299] [ERROR] Exception in worker process
    Traceback (most recent call last):
    File “/usr/local/lib/python3.6/site-packages/gunicorn/arbiter.py”, line 589, in spawn_worker
    worker.init_process()
    File “/usr/local/lib/python3.6/site-packages/gunicorn/workers/base.py”, line 134, in init_process
    self.load_wsgi()
    File “/usr/local/lib/python3.6/site-packages/gunicorn/workers/base.py”, line 146, in load_wsgi
    self.wsgi = self.app.wsgi()
    File “/usr/local/lib/python3.6/site-packages/gunicorn/app/base.py”, line 67, in wsgi
    self.callable = self.load()
    File “/usr/local/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py”, line 58, in load
    return self.load_wsgiapp()
    File “/usr/local/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py”, line 48, in load_wsgiapp
    return util.import_app(self.app_uri)
    File “/usr/local/lib/python3.6/site-packages/gunicorn/util.py”, line 359, in import_app
    mod = importlib.import_module(module)
    File “/usr/lib64/python3.6/importlib/__init__.py”, line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
    File “<frozen importlib._bootstrap>”, line 994, in _gcd_import
    File “<frozen importlib._bootstrap>”, line 971, in _find_and_load
    File “<frozen importlib._bootstrap>”, line 955, in _find_and_load_unlocked
    File “<frozen importlib._bootstrap>”, line 665, in _load_unlocked
    File “<frozen importlib._bootstrap_external>”, line 678, in exec_module
    File “<frozen importlib._bootstrap>”, line 219, in _call_with_frames_removed
    File “/etc/aiowmi/contrib/wmic_server/wmic_server.py”, line 5, in <module>
    from flask import Flask, jsonify, request, make_response
    File “/usr/local/lib64/python3.6/site-packages/flask/__init__.py”, line 7, in <module>
    from .app import Flask as Flask
    File “/usr/local/lib64/python3.6/site-packages/flask/app.py”, line 20, in <module>
    from werkzeug.routing import BuildError
    File “/usr/local/lib/python3.6/site-packages/werkzeug/routing.py”, line 1378, in <module>
    class UUIDConverter(BaseConverter):
    File “/usr/local/lib/python3.6/site-packages/werkzeug/routing.py”, line 1393, in UUIDConverter
    def to_python(self, value: str) -> uuid.UUID:
    AttributeError: module ‘uuid’ has no attribute ‘UUID’
    [2022-07-16 12:03:47 +1000] [1386299] [INFO] Worker exiting (pid: 1386299)
    [2022-07-16 12:03:47 +1000] [1386296] [INFO] Shutting down: Master
    [2022-07-16 12:03:47 +1000] [1386296] [INFO] Reason: Worker failed to boot.

    I’m running rocky linux, thanks for your help

    #758
    trentasis
    Participant

    Hi,
    similar error

    # WMIC_SERVER_CONFIG=/tmp/wmicserver/aiowmi-main/contrib/wmic_server/wmic_server.yaml PYTHONPATH=/tmp/wmicserver/aiowmi-main/aiowmi/ FLASK_ENV=development WMIC_SERVER_DEBUG=1 python /tmp/wmicserver/aiowmi-main/contrib/wmic_server/wmic_server.py
    File “/tmp/wmicserver/aiowmi-main/contrib/wmic_server/wmic_server.py”, line 41
    debug and print(“YAML configuration is:”)
    ^
    SyntaxError: invalid syntax

    Any suggestion?

    Can you detail pyton version required and dependenciens or moduels required and how to isntall?

    thanks

    #770
    Woland
    Participant

    I can’t seem to post, this is my third time now
    I have all the requirements.txt satisfied in both aiowmi and wmic_server

    This is the error
    PYTHONPATH=/usr/bin/python FLASK_ENV=development WMIC_SERVER_DEBUG=1 python /etc/aiowmi/contrib/wmic_server/wmic_server.
    py
    Traceback (most recent call last):
    File “/etc/aiowmi/contrib/wmic_server/wmic_server.py”, line 18, in <module>
    from aiowmi.connection import Connection
    File “<frozen importlib._bootstrap>”, line 971, in _find_and_load
    File “<frozen importlib._bootstrap>”, line 955, in _find_and_load_unlocked
    File “<frozen importlib._bootstrap>”, line 656, in _load_unlocked
    File “<frozen importlib._bootstrap>”, line 626, in _load_backward_compatible
    File “/usr/local/lib/python3.6/site-packages/aiowmi-0.2.1-py3.6.egg/aiowmi/connection.py”, line 5, in <module>
    File “<frozen importlib._bootstrap>”, line 971, in _find_and_load
    File “<frozen importlib._bootstrap>”, line 955, in _find_and_load_unlocked
    File “<frozen importlib._bootstrap>”, line 656, in _load_unlocked
    File “<frozen importlib._bootstrap>”, line 626, in _load_backward_compatible
    File “/usr/local/lib/python3.6/site-packages/aiowmi-0.2.1-py3.6.egg/aiowmi/protocol.py”, line 5, in <module>
    File “<frozen importlib._bootstrap>”, line 971, in _find_and_load
    File “<frozen importlib._bootstrap>”, line 955, in _find_and_load_unlocked
    File “<frozen importlib._bootstrap>”, line 656, in _load_unlocked
    File “<frozen importlib._bootstrap>”, line 626, in _load_backward_compatible
    File “/usr/local/lib/python3.6/site-packages/aiowmi-0.2.1-py3.6.egg/aiowmi/dcom.py”, line 8, in <module>
    File “<frozen importlib._bootstrap>”, line 971, in _find_and_load
    File “<frozen importlib._bootstrap>”, line 951, in _find_and_load_unlocked
    File “<frozen importlib._bootstrap>”, line 894, in _find_spec
    File “<frozen importlib._bootstrap_external>”, line 1157, in find_spec
    File “<frozen importlib._bootstrap_external>”, line 1131, in _get_spec
    File “<frozen importlib._bootstrap_external>”, line 1112, in _legacy_get_spec
    File “<frozen importlib._bootstrap>”, line 441, in spec_from_loader
    File “<frozen importlib._bootstrap_external>”, line 544, in spec_from_file_location
    File “/usr/local/lib/python3.6/site-packages/aiowmi-0.2.1-py3.6.egg/aiowmi/rpc/bind_ack.py”, line 1
    SyntaxError: future feature annotations is not defined

    #772
    admin
    Keymaster
    #774
    Woland
    Participant

    Thanks for your help admin!

    I’ve upgraded to 3.9 and used the following to install requirements

    python3.9 -m pip install -r /etc/aiowmi/requirements.txt
    WARNING: Running pip install with root privileges is generally not a good idea. Try python3.9 -m pip install --user instead.
    Collecting pycryptodome>=3.14.0
    Downloading pycryptodome-3.15.0-cp35-abi3-manylinux2010_x86_64.whl (2.3 MB)
    |████████████████████████████████| 2.3 MB 28.3 MB/s
    Installing collected packages: pycryptodome
    Successfully installed pycryptodome-3.15.0

    [root@nagios ~]# python3.9 -m pip install -r /etc/aiowmi/contrib/wmic_server/requirements.txt
    WARNING: Running pip install with root privileges is generally not a good idea. Try python3.9 -m pip install --user instead.
    Collecting aiowmi>=0.1.17
    Downloading aiowmi-0.2.1.tar.gz (75 kB)
    |████████████████████████████████| 75 kB 5.3 MB/s
    Collecting Flask>=2.0.3
    Downloading Flask-2.2.0-py3-none-any.whl (101 kB)
    |████████████████████████████████| 101 kB 16.7 MB/s
    Collecting PyYAML>=6.0
    Downloading PyYAML-6.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (661 kB)
    |████████████████████████████████| 661 kB 36.0 MB/s
    Requirement already satisfied: pycryptodome>=3.14.0 in /usr/local/lib64/python3.9/site-packages (from aiowmi>=0.1.17->-r /etc/aiowmi/contrib/wmic_server/requirements.txt (line 1)) (3.15.0)
    Collecting Jinja2>=3.0
    Downloading Jinja2-3.1.2-py3-none-any.whl (133 kB)
    |████████████████████████████████| 133 kB 19.0 MB/s
    Collecting itsdangerous>=2.0
    Downloading itsdangerous-2.1.2-py3-none-any.whl (15 kB)
    Collecting click>=8.0
    Downloading click-8.1.3-py3-none-any.whl (96 kB)
    |████████████████████████████████| 96 kB 9.9 MB/s
    Collecting importlib-metadata>=3.6.0; python_version < “3.10”
    Downloading importlib_metadata-4.12.0-py3-none-any.whl (21 kB)
    Collecting Werkzeug>=2.2.0
    Downloading Werkzeug-2.2.1-py3-none-any.whl (232 kB)
    |████████████████████████████████| 232 kB 29.5 MB/s
    Collecting MarkupSafe>=2.0
    Downloading MarkupSafe-2.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (25 kB)
    Collecting zipp>=0.5
    Downloading zipp-3.8.1-py3-none-any.whl (5.6 kB)
    Using legacy ‘setup.py install’ for aiowmi, since package ‘wheel’ is not installed.
    Installing collected packages: aiowmi, MarkupSafe, Jinja2, itsdangerous, click, zipp, importlib-metadata, Werkzeug, Flask, PyYAML
    Running setup.py install for aiowmi … done
    Successfully installed Flask-2.2.0 Jinja2-3.1.2 MarkupSafe-2.1.1 PyYAML-6.0 Werkzeug-2.2.1 aiowmi-0.2.1 click-8.1.3 importlib-metadata-4.12.0 itsdangerous-2.1.2 zipp-3.8.1

    #815
    admin
    Keymaster

    Did you get this sorted? I assume that there are probably other dependencies

    #869
    p7s1p4
    Participant

    you should get the mentioned python modules via pip:
    flask, aiowmi, pycryptodome, pyyaml
    eg
    python -m pip install pyyaml

    when they are found by your python interpreter you can start the server easily … python must be version 3.7 or higher …

    #881
    superskunk
    Participant

    hi all, i have problems creating service for the wmic server. i tried to use the sample and edit it to my needs, but i’m not good and it doesn’t work. here’s my service:
    [Unit]
    Description=WMIC Server

    [Service]
    Restart=always
    # we need the pythonpath to contain the aiowmi directory and the directory where the wmic_server.py is locat$

    # Update the following placeholders before using this file
    AIOWMI_INSTALL_DIR= /home/engineering/aiowmi/
    WMIC_SERVER_INSTALL_DIR= /home/engineering/aiowmi/contrib/wmic_server/
    WMIC_SERVER_CONFIG= /home/engineering/aiowmi/contrib/wmic_server/

    ExecStart= nice gunicorn -b 127.0.0.1:2313 –pythonpath AIOWMI_INSTALL_DIR,WMIC_SERVER_INSTALL_DIR –threads 1 “wmic_server:app”
    ExecStop= /usr/bin/pkill -f “wmic_server:app”

    # Optionally, use these additional settings
    # WMIC_SERVER_CONFIG_DIRECTORY defaults to WMIC_SERVER_INSTALL_DIR
    # Environment=WMIC_SERVER_CONFIG=WMIC_SERVER_CONFIG_DIRECTORY/wmic_server.yaml
    # Environment=WMIC_SERVER_DEBUG=1

    [Install]
    WantedBy=multi-user.target
    ——————————————————————————————————–

    And this is the error:
    [/usr/lib/systemd/system/wmic_server.service:13] Executable path is not absolute, ignoring: nice gunicorn -b 127.0.0.1:2313 –pythonpath AIOWMI_INSTALL_DIR,WMIC_SERVER_INSTALL_DIR –threads 1 “wmic_server:app”
    Oct 21 15:51:52 TESSCENTWEB001.xxx.IT systemd[1]: wmic_server.service has no ExecStart= setting, which is only allowed for RemainAfterExit=yes services. Refusing.

    i know that the problem is that i don’t have the necessary knowledge, can someone help me? thank you very much

    #883
    admin
    Keymaster

    Can you run the wmic server successfully from the command line?
    If yes, then you have a systemd problem. Perhaps try a systemd forum?

    #887
    superskunk
    Participant

    yes i can run succesfully the server with the command PYTHONPATH=/home/xxx/aiowmi/ WMIC_SERVER_DEBUG=1 python3.7 /home/xxx/aiowmi/contrib/wmic_server/wmic_server.py but i have hundreds of wmi checks and i read that starting server in this way is not recomended in production. Now i have simply created a boot script that launches the python command above, but i’d like to run the service properly.

    #899
    mdicss
    Participant

    Hi
    I run into the same problem. There is a conflict with two scripts uuid.py and the path to find one. For me
    pip3 uninstall uuid
    pip3 uninstall aiowmi
    pip3 install aiowmi
    did the trick.

    #931
    bisontim
    Participant

    I solved with User inside the service definition and adding the full path to nice and unicorn.
    This is my procedure:
    which gunicorn
    /home/administrator/.local/bin/gunicorn

    So I put into wmic_server.service:

    [Unit]
    Description=WMIC Server

    [Service]
    User=administrator
    Restart=always
    # we need the pythonpath to contain the aiowmi directory and the directory where the wmic_server.py is located

    # Update the following placeholders before using this file
    # AIOWMI_INSTALL_DIR
    # WMIC_SERVER_INSTALL_DIR
    # WMIC_SERVER_CONFIG

    ExecStart=/usr/bin/nice /home/administrator/.local/bin/gunicorn -b 127.0.0.1:2313 –pythonpath /etc/wmic_server,/etc/wmic_server/aiowmi/contrib/wmic_server –threads 1 wmic_server:app
    ExecStop=/usr/bin/pkill -f “wmic_server:app”

    # Optionally, use these additional settings
    # WMIC_SERVER_CONFIG_DIRECTORY defaults to WMIC_SERVER_INSTALL_DIR
    # Environment=WMIC_SERVER_CONFIG=WMIC_SERVER_CONFIG_DIRECTORY/wmic_server.yaml
    # Environment=WMIC_SERVER_DEBUG=1

    [Install]
    WantedBy=multi-user.target

    And it works.
    Furthermore, you have to subsitute the placeholder AIOWMI_INSTALL_DIR and WMIC_SERVER_INSTALL_DIR in the ExecStart, not to use them as variables.

    Bye
    Mario

    • This reply was modified 8 months, 2 weeks ago by bisontim.
    #945
    superskunk
    Participant

    Bella Mario sei un grande! i used Mario’s suggestion and now the service works like a charm. Thanks a lot.

    #979
    ShakeZpear
    Participant

    I am stuck in a similar but slightly different situation – but none of the above solved the problem of wmic_server not starting.

    The primary visible symptom is following “last message” of the starting server:

    “ImportError: cannot import name ‘UUID’ from ‘uuid’ (/opt/commoc/lib/python3/aiowmi/uuid.py)”

    Versions:

    Ubuntu 20.04
    Python3: 3.8.10
    gunicorn 20.0.4

    The wmic_server.yaml ist the unchanged sample file.

    I am stuck with my intellectual abilities here 🙂

    Thanks for any help.

    Complete Stack trace:

    nice[1255306]: [INFO] Starting gunicorn 20.0.4
    nice[1255306]: [1255306] [INFO] Listening at: http://127.0.0.1:2313 (1255306)
    nice[1255306]: [1255306] [INFO] Using worker: sync
    nice[1255310]: [1255310] [INFO] Booting worker with pid: 1255310
    nice[1255310]: [ERROR] Exception in worker process
    nice[1255310]: Traceback (most recent call last):
    nice[1255310]: File “/usr/lib/python3/dist-packages/gunicorn/arbiter.py”, line 583, in spawn_worker
    nice[1255310]: worker.init_process()
    nice[1255310]: File “/usr/lib/python3/dist-packages/gunicorn/workers/base.py”, line 119, in init_process
    nice[1255310]: self.load_wsgi()
    nice[1255310]: File “/usr/lib/python3/dist-packages/gunicorn/workers/base.py”, line 144, in load_wsgi
    nice[1255310]: self.wsgi = self.app.wsgi()
    nice[1255310]: File “/usr/lib/python3/dist-packages/gunicorn/app/base.py”, line 67, in wsgi
    nice[1255310]: self.callable = self.load()
    nice[1255310]: File “/usr/lib/python3/dist-packages/gunicorn/app/wsgiapp.py”, line 49, in load
    nice[1255310]: return self.load_wsgiapp()
    nice[1255310]: File “/usr/lib/python3/dist-packages/gunicorn/app/wsgiapp.py”, line 39, in load_wsgiapp
    nice[1255310]: return util.import_app(self.app_uri)
    nice[1255310]: File “/usr/lib/python3/dist-packages/gunicorn/util.py”, line 383, in import_app
    nice[1255310]: mod = importlib.import_module(module)
    nice[1255310]: File “/usr/lib/python3.8/importlib/__init__.py”, line 127, in import_module
    nice[1255310]: return _bootstrap._gcd_import(name[level:], package, level)
    nice[1255310]: File “<frozen importlib._bootstrap>”, line 1014, in _gcd_import
    nice[1255310]: File “<frozen importlib._bootstrap>”, line 991, in _find_and_load
    nice[1255310]: File “<frozen importlib._bootstrap>”, line 975, in _find_and_load_unlocked
    nice[1255310]: File “<frozen importlib._bootstrap>”, line 671, in _load_unlocked
    nice[1255310]: File “<frozen importlib._bootstrap_external>”, line 848, in exec_module
    nice[1255310]: File “<frozen importlib._bootstrap>”, line 219, in _call_with_frames_removed
    nice[1255310]: File “/opt/commoc/bin/wmic_server/wmic_server.py”, line 5, in <module>
    nice[1255310]: from flask import Flask, jsonify, request, make_response
    nice[1255310]: File “/usr/lib/python3/dist-packages/flask/__init__.py”, line 21, in <module>
    nice[1255310]: from .app import Flask
    nice[1255310]: File “/usr/lib/python3/dist-packages/flask/app.py”, line 60, in <module>
    nice[1255310]: from .sessions import SecureCookieSessionInterface
    nice[1255310]: File “/usr/lib/python3/dist-packages/flask/sessions.py”, line 22, in <module>
    nice[1255310]: from .json.tag import TaggedJSONSerializer
    nice[1255310]: File “/usr/lib/python3/dist-packages/flask/json/tag.py”, line 47, in <module>
    nice[1255310]: from uuid import UUID
    nice[1255310]: ImportError: cannot import name ‘UUID’ from ‘uuid’ (/opt/commoc/lib/python3/aiowmi/uuid.py)
    nice[1255310]: [2023-03-18 10:05:45 +0100] [1255310] [INFO] Worker exiting (pid: 1255310)
    nice[1255306]: [2023-03-18 10:05:45 +0100] [1255306] [INFO] Shutting down: Master
    nice[1255306]: [2023-03-18 10:05:45 +0100] [1255306] [INFO] Reason: Worker failed to boot.
    Mar 18 10:05:46 ubu2004commoc-installtest systemd[1]: wmic_server.service: Main process exited, code=exited, status=3/NOTIMPLEMENTED
    Mar 18 10:05:46 ubu2004commoc-installtest systemd[1]: wmic_server.service: Failed with result ‘exit-code’.
    Mar 18 10:05:46 ubu2004commoc-installtest systemd[1]: wmic_server.service: Scheduled restart job, restart counter is at 4.
    Mar 18 10:05:46 ubu2004commoc-installtest systemd[1]: Stopped WMIC Server.

    #981
    ShakeZpear
    Participant

    forgot: aiowmi version 0.2.3

Viewing 15 posts - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.