Giter VIP home page Giter VIP logo

aiowmi's People

Contributors

jan-guenter avatar joente avatar koos85 avatar majurgens avatar mdicss avatar robbm1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aiowmi's Issues

Use library own logger.

Is your feature request related to a problem? Please describe.
Use of a global logger by the library is unacceptable. Library logs interfere with application output. And this cannot be avoided.

Describe the solution you'd like
Use a custom logger inside the library via logging.getLogger('aiowmi') with the default "NullHandler" handler.

Zero integer values end up as None/null

Describe the bug
Query: Select * from Win32_UTCTime

Result when run at different seconds 59,0,1:

Year|Month|Day|DayOfWeek|WeekInMonth|Quarter|Hour|Minute|Second|Milliseconds
2022|6|17|5|3|2|11|32|59|(null)
2022|6|17|5|3|2|11|33|(null)|(null)
2022|6|17|5|3|2|11|33|1|(null)

As you see, Milliseconds is always None/null. When Second is 0, it ends up as None/null too.

Old wmic linux-binary shows them correctly as 0 (even Milliseconds which is "not implemented" according to Microsoft docs).

If using ignore_missing=True, Second/Milliseconds disappear completely from results.

To Reproduce

"""basic code from example, here is my print function"""
props = res.get_properties()
v = []
for name, prop in props.items():
    if prop.value is None:
        v.append('(null)')
    else:
        v.append(str(prop.value))
print('|'.join(v))

Expected behavior
Value should be 0 instead of None/null

Errors at Irregular Intervals

Hello everyone,
first of all thank you for this great library. After wmic stopped working, I searched a long time for a good replacement.

I use the wmic_server to monitor some servers. But now I get the following error in irregular intervals:

Aug 25 16:26:14 ##### nice[675]: [2022-08-25 16:26:14 +0200] [675] [CRITICAL] WORKER TIMEOUT (pid:122590)
Aug 25 16:26:14 ##### nice[122590]: ERROR:asyncio:Fatal error: protocol.data_received() call failed.
Aug 25 16:26:14 ##### nice[122590]: protocol: <aiowmi.protocol.Protocol object at 0x7fb800628a30>
Aug 25 16:26:14 ##### nice[122590]: transport: <_SelectorSocketTransport fd=14 read=polling write=<idle, bufsize=0>>
Aug 25 16:26:14 ##### nice[122590]: Traceback (most recent call last):
Aug 25 16:26:14 ##### nice[122590]:   File "/usr/lib/python3.8/asyncio/runners.py", line 44, in run
Aug 25 16:26:14 ##### nice[122590]:     return loop.run_until_complete(main)
Aug 25 16:26:14 ##### nice[122590]:   File "/usr/lib/python3.8/asyncio/base_events.py", line 603, in run_until_complete
Aug 25 16:26:14 ##### nice[122590]:     self.run_forever()
Aug 25 16:26:14 ##### nice[122590]:   File "/usr/lib/python3.8/asyncio/base_events.py", line 570, in run_forever
Aug 25 16:26:14 ##### nice[122590]:     self._run_once()
Aug 25 16:26:14 ##### nice[122590]:   File "/usr/lib/python3.8/asyncio/base_events.py", line 1823, in _run_once
Aug 25 16:26:14 ##### nice[122590]:     event_list = self._selector.select(timeout)
Aug 25 16:26:14 ##### nice[122590]:   File "/usr/lib/python3.8/selectors.py", line 468, in select
Aug 25 16:26:14 ##### nice[122590]:     fd_event_list = self._selector.poll(timeout, max_ev)
Aug 25 16:26:14 ##### nice[122590]:   File "/usr/local/lib/python3.8/dist-packages/gunicorn/workers/base.py", line 203, in handle_abort
Aug 25 16:26:14 ##### nice[122590]:     sys.exit(1)
Aug 25 16:26:14 ##### nice[122590]: SystemExit: 1
Aug 25 16:26:14 ##### nice[122590]: During handling of the above exception, another exception occurred:
Aug 25 16:26:14 ##### nice[122590]: Traceback (most recent call last):
Aug 25 16:26:14 ##### nice[122590]:   File "/usr/lib/python3.8/asyncio/selector_events.py", line 862, in _read_ready__data_received
Aug 25 16:26:14 ##### nice[122590]:     self._protocol.data_received(data)
Aug 25 16:26:14 ##### nice[122590]:   File "/usr/local/lib/python3.8/dist-packages/aiowmi/protocol.py", line 86, in data_received
Aug 25 16:26:14 ##### nice[122590]:     req, data, = self._requests[self._buf.call_id], self._buf.data
Aug 25 16:26:14 ##### nice[122590]: KeyError: 7
Aug 25 16:26:15 ##### nice[675]: [2022-08-25 16:26:15 +0200] [675] [WARNING] Worker with pid 122590 was terminated due to signal 9
Aug 25 16:26:15 ##### nice[133453]: [2022-08-25 16:26:15 +0200] [133453] [INFO] Booting worker with pid: 133453

The servers are read out every 5 minutes with several querys.
What could be the reason for the error?

Problem with charsets on replies from wmicserver with Windows in spanish

Hi, I’m having a problem where my wmic client makes a petition to wmicserver but receives a message with the wrong Charset.

This is the message in question:

OK – Found 1 Services(s), 1 OK and 0 with problems (0 excluded). ‘Administraci▒n de licencias de Escritorio remoto’ (TermServLicensing) is Running.|’Total Service Count’=1; ‘Service Count OK State’=1;;1; ‘Service Count Problem State’=0; ‘Excluded Service Count’=0;

As you can see… Administraci▒n accents fail.

Do you know a solution for this?

Windows is in Spanish.

WMIC Server Terminates with [FIN, ACK] on RemoteCreateInstance response

Describe the bug
When trying to make a WMIC call using check_wmi_plus (v1.68) the call is failing continuously with the below copied error message.
"UNKNOWN - The WMI query had problems. We're not exactly sure what this error is. There was some kind of problem performing the WMI query on the target host (10.232.xx.xx). Wmic error text on the next line.

Problem with the wmi query on the target host. WBEM_E_UNKNOWN (2147944122)"

To Reproduce
Steps to reproduce the behavior:

  1. Setup WMIC server on CentOS 7.6 and install Nagios with check_wmi_plus plug-in
  2. Trigger a check_wmi_plus command to query Windows node system properties (eg. CPU/RAM)
  3. Run the command "check_wmi_plus.pl -H 10.232.xx.xx -m checkmem -u UserName/Password -w 80 -c 90"
  4. See error

Expected behavior
Expected to see a reponse with CPU/RAM utilization

Screenshots
Error Screen-1
image

Error Screen-2
image

N/W Trace Screen-1
image

N/W Trace Screen-2
image

wmic.py SyntaxError: invalid syntax

I tried to implement wmic server, and I would like to test it, but I obtain:

File "wmic_server.py", line 41
debug and print("YAML configuration is:")
^
SyntaxError: invalid syntax

My python version:
Python 2.7.17

Wrong type hint for results function

Is your feature request related to a problem? Please describe.
Function "results" in QContext module hinted with OrderedDict[str, PropertyInfo], but return QContext instead.

Describe the solution you'd like
Fix returning type to QContext .

IOError: [Errno 24] Too many open files

Describe the bug
We're getting fatal errors that ends in timeouts problems, with too many processes on our nagios server and making it freeze.
Before the issue, the log says:
IOError: [Errno 24] Too many open files
Than, a gunicorn thead goes in timeout, get killed and recreated.

Additional context
We used the gunicorn "version" of the systemd service. At the moment, we set gunicorn with 8 worker and 8 thread. We tried with less (5) and more (10), but after some time the service still showed the same error.
The last time, I created a new local user, increased the open file limit to 16384 (adding a row in /etc/security/limits.conf file) and edited the systemd unit file to use the new user. I've also tested the access with the new user, and after the change it shows the new limit.
However, after some time, the service still reach the limit and nagios wmi check start freezing.
Do you think the limit is still too low and it should be raised?
On nagios there are around 4-5000 wmi checks, which are often requested in parallel.
I don't have a more detailed log at the moment, but I can get it the next time.
Do you have any advice?

Long Running Server

Access to this library from a long running server would be great. Access via HTTP(s).
I'm think something like a server running in gunicorn that we can HTTP POST to and get JSON data back from.

Get properties in right order

Hi, first of all, thank you very much for putting this nice library together.

I have a large monitoring software running which heavily uses WMIC. I am trying to use this library to create a drop-in replacement for WMIC.

the wmic command I am using is with delimiter = " = ".
When I am querying something like "select DisplayName, Name, State from Win32_Service", I get something like this:

CLASS: Win32_Service
DisplayName = Name = State
Print spooler = spooler = Stopped
...

But when I run this same query with this library, I get the properties in a random order.
How can I get them in the same order as requested?

pycryptodome is missing from setup.py

Describe the bug
pip install aiowmi does not install the dependency of pycryptodome.

To Reproduce
pip install aiowmi

Expected behavior
All package dependencies should be installed by pip

Additional context
Add install_requires to setup.py, or consider switching to the new standard pyproject.toml

Great package btw!

JSON output

Can we get JSON output from the library? Maybe the output is already convertible to JSON output?
I'm not very good with python and so maybe this is already available

ERROR:asyncio:Fatal error: protocol.data_received() call failed

Describe the bug
We're getting fatal errors that ends in timeouts problems, with too many processes on our nagios server and making it freeze.

To Reproduce
The problem occurs in some machines in a specific domain, only in that domain, even if we have 2 more not giving errors.

Steps to reproduce the behavior:
We run the wmicserver with debug, not as a service, and we have the following errors, repeated in loop:

ERROR:asyncio:Fatal error: protocol.data_received() call failed.
protocol: <aiowmi.protocol.Protocol object at 0x7f2360bdad00>
transport: <_SelectorSocketTransport fd=15 read=polling write=<idle, bufsize=0>>
Traceback (most recent call last):
File "/usr/lib/python3.9/asyncio/selector_events.py", line 870, in _read_ready__data_received
self._protocol.data_received(data)
File "/opt/aiowmi/aiowmi/protocol.py", line 88, in data_received
req, data, = self._requests[self._buf.call_id], self._buf.data
KeyError: 7

Windows 10 WBEM_E_ACCESS_DENIED

Describe the bug
Get WBEM_E_ACCESS_DENIED while trying to query SELECT Name FROM Win32_UserAccount on remote Windows 10 machine. Same code works as expected on Windows 7 and Windows Server 2019.

The user on the target machine is configured correctly because wbemtest from another Windows 10 is working correctly. However, wbemtest running from Windows 7 also gives access denied.

This appears in function anext from qcontext.py

To Reproduce
Steps to reproduce the behavior:
Try to query from Win32_UserAccount

Expected behavior
Get user accounts

Additional context
It is worth noting that quering SELECT * FROM __InstanceCreationEvent works as expected.

Timezone format incorrect?

This PR (#8) started returning timezone data. However, it seems to return an invalid timezone format.

I believe that the timezone offset is supposed to be a 3 digit number of minutes as per UUU in https://docs.microsoft.com/en-us/windows/win32/wmisdk/cim-datetime. The code seems to return HH:MM format.

For example, running a query like:
SELECT Name,LastModified WHERE Name="c:\\pagefile.sys"

returns a date like
2022-06-21T12:18:17.537989**+10:00**
where the timezone is +10 hours

Native Windows clients return a date like
2022-06-21T12:18:17.537989+600
where the timezone is +600 minutes (correct as per documentation)

Wait for-ever on result

Describe the bug
It is possible that in case-of-an-error, the WMI library will wait forever for data to return

To Reproduce
Reproducing is difficult, as usually Windows returns with data as expected. However, it is possible to fake the code and wait for too much data which forces an endless wait for data.

Expected behavior
Raise a time-out error at some reasonable point in time. (should be possible to adjust using arguments)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.