Closed SilverAlex85 closed 3 weeks ago
What's the powershell output of Get-DhcpServerv4ScopeStatistics -ComputerName "domaincontroller03.yourdomain.local"
?
Lokks fine, below the output:
PS C:\Windows\system32> Get-DhcpServerv4ScopeStatistics -ComputerName "domaincontroller03.*****.local"
ScopeId Free InUse PercentageInUse Reserved Pending SuperscopeName
------- ---- ----- --------------- -------- ------- --------------
192.168.20.0 40 11 21,56863 6 0 Servernetz
192.168.30.0 38 33 46,47887 12 0 Managementnetz
192.168.40.0 176 77 30,43478 2 0 VoIP
192.168.10.0 217 33 13,2 6 0 Hospiz
192.168.15.0 198 2 1 2 0 Buchhaltung
192.168.20.0 151 49 24,5 10 0 Verwaltungsnetz
192.168.30.0 200 0 0 0 0 WLAN
192.168.70.0 242 8 3,2 2 0
192.168.80.0 249 1 0,4 1 0
192.168.90.0 233 17 6,8 5 0
Is it german locale?
I removed the handling of the fraction part PercentageInUse
in https://github.com/Linuxfabrik/monitoring-plugins/commit/413dd07184cb4b27e622ed328efacddf6bb3430e - this could have been the source of the error according to the output in Icinga.
Could you please try the new version?
Sorry, both Linux and Windows Server 2022 are german localization. Give some minutes, i give it a try and report back to you.
I have tried the new version and looks good, below the output:
/usr/local/lib/python3.10/dist-packages/winrm/init.py:87: UserWarning: There was a problem converting the Powershell error message: not well-formed (invalid token): line 1, column 205 warnings.warn("There was a problem converting the Powershell error " "message: %s" % (e)) Everything is ok.
The only confusing thing is this winrm/powershell message.
Thanks for the change.
This is a powershell or winrm library related issue. Can you do me a favor, run this on your Linux directly in Python and report back the output?
import winrm
session = winrm.Session('192.168.20.3', auth=('Administrator@mydomain.local', 'mypassword'), transport='ntlm')
session.run_ps('Get-DhcpServerv4ScopeStatistics -ComputerName "domaincontroller03.****.local"')
Same error message:
nagios@monitor01:/usr/lib64/nagios/plugins$ ./dhcp-scope-usage --hostname=domaincontroller03.bssnetz.local --winrm-hostname=192.168.20.3 --winrm-username=administrator --winrm-password= --winrm-domain=.local --winrm-transport=ntlm /usr/local/lib/python3.10/dist-packages/winrm/init.py:87: UserWarning: There was a problem converting the Powershell error message: not well-formed (invalid token): line 1, column 205 warnings.warn("There was a problem converting the Powershell error " "message: %s" % (e)) Everything is ok.
I think you misunderstood me :-)
Please start python
on your monitor01
, paste in this script, adjust it and tell me the result.
import winrm
session = winrm.Session('192.168.20.3', auth=('Administrator@mydomain.local', 'mypassword'), transport='ntlm')
session.run_ps('Get-DhcpServerv4ScopeStatistics -ComputerName "domaincontroller03.mydomain.local"')
Sorry, I had almost guessed that. Below the output:
Python 3.10.12 (main, Jul 29 2024, 16:56:48) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import winrm
>>> session = winrm.Session('192.168.20.3', auth=('administrator@domain.local', '*****'), transport='ntlm')
>>> session.run_ps('Get-DhcpServerv4ScopeStatistics -ComputerName "domaincontroller03.bssnetz.local"')
/usr/local/lib/python3.10/dist-packages/winrm/__init__.py:87: UserWarning: There was a problem converting the Powershell error message: not well-formed (invalid token): line 1, column 205
warnings.warn("There was a problem converting the Powershell error " "message: %s" % (e))
<Response code 0, out "b'\r\nScopeId F'", err "b'#< CLIXML\r\n<Objs Ver'">
>>>
I hope this helps.
Not much, but your Powershell returns an error that starts with #< CLIXML\r\n<Objs Ver
. The winrm library stumbles over it because it's invalid XML. There is nothing we can do about this, and you need to investigate further. I will close this issue.
However, you may get the full Powershell error by using this code snippet:
import winrm
session = winrm.Session('192.168.20.3', auth=('administrator@domain.local', '*****'), transport='ntlm')
result = session.run_ps('Get-DhcpServerv4ScopeStatistics -ComputerName "domaincontroller03.bssnetz.local"')
print(result.std_err)
okay thanks for your help.
This issue respects the following points:
Which variant of the Monitoring Plugins do you use?
Bug description
Output from check dhcp-scope-usage different from shell and icinga, result is shown below. I think second issue or error is the convertion from a powershell error message and in Icingaweb the convertion from a string to a float value.
Steps to reproduce - Plugin call
./dhcp-scope-usage --hostname=domaincontroller03.****.local --winrm-hostname=192.168.20.3 --winrm-username=Administrator --winrm-password=**** --winrm-domain=****.local --winrm-transport=ntlm
Steps to reproduce - Data
Output from shell:
Output from Icinga2:
Environment
Plugin Version
dhcp-scope-usage: v2023112901 by Linuxfabrik GmbH, Zurich/Switzerland
Python version
3.10.12
List of Python modules
Additional Information
No response