cesbit / aiowmi Goto Github PK
View Code? Open in Web Editor NEWPython WMI Queries
License: GNU General Public License v3.0
Python WMI Queries
License: GNU General Public License v3.0
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.
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
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?
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.
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:
Expected behavior
Expected to see a reponse with CPU/RAM utilization
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
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 .
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?
Can it support the generation of WMI object instances, and support method calls and property settings for these objects, similar to impacket's iWbemServices.PutInstance method?
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.
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?
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!
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
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
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.
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)
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)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.