Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New type option not working with multiple values #9

Open
lekzz opened this issue Dec 1, 2020 · 2 comments
Open

New type option not working with multiple values #9

lekzz opened this issue Dec 1, 2020 · 2 comments

Comments

@lekzz
Copy link

lekzz commented Dec 1, 2020

The new type option doesn't seem to work multiple values.

from README:

Get memory load:

zbxwmi["-action","-json","-type","n,n,n","-fields","AvailableBytes,CommitLimit,CommittedBytes","Win32_PerfRawData_PerfOS_Memory",{HOST.HOST}]

Actual result:

$ sudo /etc/zabbix/externalscripts/zbxwmi -action json -fields AvailableBytes,CommitLimit,CommittedBytes Win32_PerfRawData_PerfOS_Memory -type n,n,n -cred /etc/zabbix/wmi.pw SERVER
An error occured: can only concatenate str (not "NoneType") to str

old script

$ sudo /etc/zabbix/externalscripts/zbxwmi.old -action json -fields AvailableBytes,CommitLimit,CommittedBytes Win32_PerfRawData_PerfOS_Memory -cred /etc/zabbix/wmi.pw SERVER
[{"AvailableBytes": "11361402880", "CommitLimit": "19728936960", "CommittedBytes": "6544306176", "Name": "None"}]

Also tried with n,n,n,s as the old script reports an extra name value, same error.
And with s,s,s,s, which results in a slightly different error "An error occured: can only concatenate str (not "int") to str"

@nicolagatta
Copy link

Not sure you fixed..., I was just having the same issue.
You can use the key (-k) option to map the fields

/usr/lib/zabbix/externalscripts/zbxwmi -k "AvailableBytes,AvailableKBytes" -a json -type n,n -fields "AvailableBytes,AvailableKBytes" "Win32_PerfFormattedData_PerfOS_Memory" -cred /etc/zabbix/wmi.pw SERVER

output is:
[{"AvailableBytes": 1109749760, "AvailableKBytes": 1083740}]

@lekzz
Copy link
Author

lekzz commented May 28, 2021

Using -k seems to work indeed.
I guess i was wrong with the bug description and it's really about the "json" action sometimes requiring -k, but not always.

Example of single value failing without -k:

sudo /etc/zabbix/externalscripts/zbxwmi -action get -fields PagesPersec Win32_PerfFormattedData_PerfOS_Memory -t n -cred /etc/zabbix/wmi.pw SERVER
3

sudo /etc/zabbix/externalscripts/zbxwmi -action both -fields PagesPersec Win32_PerfFormattedData_PerfOS_Memory -t n -cred /etc/zabbix/wmi.pw SERVER
{ "data": [ {"{#WMI.PAGESPERSEC}": 0} ] }

sudo /etc/zabbix/externalscripts/zbxwmi -action json -fields PagesPersec Win32_PerfFormattedData_PerfOS_Memory -t n -cred /etc/zabbix/wmi.pw SERVER
An error occured: can only concatenate str (not "NoneType") to str

sudo /etc/zabbix/externalscripts/zbxwmi -action json -k PagesPersec -fields PagesPersec Win32_PerfFormattedData_PerfOS_Memory -t n -cred /etc/zabbix/wmi.pw SERVER
[{"PagesPersec": 0}]

Example of single value working without -k:

sudo /etc/zabbix/externalscripts/zbxwmi -action json -item "6" -fields PercentProcessorTime Win32_PerfFormattedData_PerfOS_Processor -t n -cred /etc/zabbix/wmi.pw SERVER
[{"Name": "6", "PercentProcessorTime": 5}]

It seems unclear what the -k key option really is for. If it has to be the same as -fields it seems redundant. In the README other examples use "-k DeviceID" however removing it from those examples results in the exact same output?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants