-
Notifications
You must be signed in to change notification settings - Fork 177
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
Issue while fetching bios info in windows 10. #189
Comments
The code works fine when i run it seperate. |
@sandeep1-0 I don't see that you are using the |
Error getting BIOS info: wmi: cannot load field "InstallDate" into a "string": unsupported type ()2020-05-18T20:53:53.946+0530 DEBUG It's returning null |
@sandeep1-0 can you please post the code that you are running that is producing your error? Thanks! |
func ProdInfo() map[string]interface{} {
var proddict map[string]interface{}
product, err := ghw.Product()
if err != nil {
fmt.Printf("Error getting product info: %v", err)
}
proddict = make(map[string]interface{})
prod_model := product.Family
proddict["prod_model"] = prod_model
return proddict
}
Now this is the error im getting. As i said when running individually it works fine. |
@sandeep1-0 OK, thank you! I will push up a fix soon. |
Ok thanks @jaypipes |
The github.com/StackExchange/wmi package is great, but handles nil results from the WMI/WQL call *only* if the type in the receiving struct is a pointer type: https://github.com/StackExchange/wmi/blob/cbe66965904dbe8a6cd589e2298e5d8b986bd7dd/wmi.go#L420-L426 So, for various fields (all strings that I can gather so far) that on *some* systems return nil type from WMI, I've made the fields in the receiver structs *string instead of string. This should allow nil-types to be properly handled and not run into the `unsupported type (<nil>)` issue faced in Issue #189 Closes Issue #189
The github.com/StackExchange/wmi package is great, but handles nil results from the WMI/WQL call *only* if the type in the receiving struct is a pointer type: https://github.com/StackExchange/wmi/blob/cbe66965904dbe8a6cd589e2298e5d8b986bd7dd/wmi.go#L420-L426 So, for various fields (all strings that I can gather so far) that on *some* systems return nil type from WMI, I've made the fields in the receiver structs *string instead of string. This should allow nil-types to be properly handled and not run into the `unsupported type (<nil>)` issue faced in Issue #189 Closes Issue #189
@sandeep1-0 I've merged a fix for this issue. Would you mind pulling the latest code and checking to see if your issue is addressed? |
Error getting block storage info: wmi: cannot load field "DefaultBlockSize" into a "uint64": unsupported type ()2020-05-22T10:38:06.704+0530 Thanks for your concern but still I'm facing the issue. |
Hmm, looks like non-string receiver fields also need to be nil-safe... you'd think that WMI would not return a |
Apparently WMI will return `<nil>` type even for integer fields like DefaultBlockSize :( Issue #189
Apparently WMI will return `<nil>` type even for integer fields like DefaultBlockSize :( Issue #189
@sandeep1-0 OK, please check the latest version. I changed the WMI receiver field types to all pointers. This should fix you. |
Still the same. |
@sandeep1-0 please ensure you are pulling the |
Yes i downloaded that source code and put it in the library still same error i'm getting. Will this work if we pass some default values for all. |
@sandeep1-0 I don't know what you mean by "pass some default values for all". Could you elaborate? The default values for pointer types is 0. Maybe you could post the exact code that you are running and some more details about the environment you are running it in? What version of Golang? What version of Windows? If you run the |
go version : go version go1.14.2 windows/amd64 I have created a new module for metricbeat which fetches all the system data like hard-disk details, system details etc. If you have metricbeat available i have attached the code. |
@sandeep1-0 it's working perfectly fine for me. Here's what I did:
func main() {
fmt.Printf("%+v\n", HDInfo()) } I then executed it and everything worked fine:
I suspect you are caching an old version of the |
Yeah it worked that way. Can you help me understand what could be the problem there. |
Hey again, @sandeep1-0. Sorry for the delayed response. Did you get your code working? I suspect all you needed to do was ensure that you were building your metricbeat plugin with a |
Yes. I have moved the code like you mentioned earlier it's works perfectly fine. I don't understand the go.mod what you have mentioned. So where should I change those inorder to make my code works as it was before? |
Sorry for that I am new to go and I have only basic ideas to solve the problem. Thanks for your library and help it made my work so much easier. |
No need to apologize, Sandeep :) So, when you use code from a Go library (like
if you then do a
you will see Go pull down the latest versions of any libraries referenced in your own code. After some time, you might need to bring in an updated version of once of your library dependencies. An example would be You would do that by:
Best, |
Thank you jay. |
Metricbeat failing to fetch bios info. Getting the following error while tried to fetch those.
020-05-18T20:53:53.604+0530 DEBUG [module] module/wrapper.go:154 Starting metricSetWrapper[module=system, name=asset, host=]
Error getting BIOS info: wmi: cannot load field "InstallDate" into a "string": unsupported type ()2020-05-18T20:53:53.946+0530 DEBUG [module] runtime/panic.go:969 Stopped metricSetWrapper[module=system, name=asset, host=]
2020-05-18T20:53:53.946+0530 ERROR runtime/signal_windows.go:246 recovered from panic while fetching 'system/asset' for host ''. Recovering, but please report this: runtime error: invalid memory address or nil pointer dereference. {"stack": "github.com/elastic/beats/libbeat/logp.Recover\n\tG:/go/src/github.com/elastic/beats/libbeat/logp/global.go:88\nruntime.gopanic\n\tc:/go/src/runtime/panic.go:969\nruntime.panicmem\n\tc:/go/src/runtime/panic.go:212\nruntime.sigpanic\n\tc:/go/src/runtime/signal_windows.go:246\ngithub.51.al/elastic/beats/metricbeat/module/system/asset.ProdInfo\n\tG:/go/src/github.com/elastic/beats/metricbeat/module/system/asset/asset_func.go:160\ngithub.51.al/elastic/beats/metricbeat/module/system/asset.(*MetricSet).Fetch\n\tG:/go/src/github.com/elastic/beats/metricbeat/module/system/asset/asset.go:62\ngithub.51.al/elastic/beats/metricbeat/mb/module.(*metricSetWrapper).multiEventFetch\n\tG:/go/src/github.com/elastic/beats/metricbeat/mb/module/wrapper.go:227\ngithub.51.al/elastic/beats/metricbeat/mb/module.(*metricSetWrapper).fetch\n\tG:/go/src/github.com/elastic/beats/metricbeat/mb/module/wrapper.go:207\ngithub.51.al/elastic/beats/metricbeat/mb/module.(*metricSetWrapper).startPeriodicFetching\n\tG:/go/src/github.com/elastic/beats/metricbeat/mb/module/wrapper.go:184\ngithub.51.al/elastic/beats/metricbeat/mb/module.(*metricSetWrapper).run\n\tG:/go/src/github.com/elastic/beats/metricbeat/mb/module/wrapper.go:171\ngithub.51.al/elastic/beats/metricbeat/mb/module.(*Wrapper).Start.func1\n\tG:/go/src/github.com/elastic/beats/metricbeat/mb/module/wrapper.go:112"}
2020-05-18T20:53:53.947+0530 DEBUG [module] module/wrapper.go:120 Stopped Wrapper[name=system, len(metricSetWrappers)=1]
2020-05-18T20:53:58.527+0530 DEBUG [service] service/service.go:33 Received sigterm/sigint, stopping
2020-05-18T20:53:58.527+0530 DEBUG [service] service/service.go:39 Received svc stop/shutdown request
2020-05-18T20:53:58.528+0530 INFO instance/beat.go:308 metricbeat stopped.
2020-05-18T20:53:58.667+0530 INFO [monitoring] log/log.go:132 Total non-zero metrics {"monitoring": {"metrics": {"beat":{"cpu":{"system":{"ticks":218,"time":218},"total":{"ticks":358,"time":358,"value":358},"user":{"ticks":140,"time":140}},"info":{"ephemeral_id":"30e22451-2f46-4833-9d41-64017cad3489","uptime":{"ms":8160}},"memstats":{"gc_next":4194304,"memory_alloc":2410544,"memory_total":4124872,"rss":24899584}},"libbeat":{"config":{"module":{"running":0}},"output":{"type":"file"},"pipeline":{"clients":0,"events":{"active":0}}},"system":{"cpu":{"cores":4}}}}}
2020-05-18T20:53:58.668+0530 INFO [monitoring] log/log.go:133 Uptime: 8.2992701s
2020-05-18T20:53:58.668+0530 INFO [monitoring] log/log.go:110 Stopping metrics logging.
The text was updated successfully, but these errors were encountered: