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

Panic with SYNOLOGY-DISK-MIB::diskTable #32

Closed
MyaLongmire opened this issue Dec 17, 2021 · 3 comments
Closed

Panic with SYNOLOGY-DISK-MIB::diskTable #32

MyaLongmire opened this issue Dec 17, 2021 · 3 comments

Comments

@MyaLongmire
Copy link

I have written go code to try and load in and use SYNOLOGY-DISK-MIB::diskTable but it panics. I have attached the go program and the zip of the mibs. Any help is greatly appreciated.

From what I can tell I call gosmi.GetNode, GetNode calls smi.GetNode(smiModule, name), in GetNode smiModulePtr is empty and skips down the the for loop doesn't find anything, returns nil and panics.

synology.txt -> the go program (github made me upload it as a txt)

Synology_MIB_File.zip -> the mibs

@sleepinggenius2
Copy link
Owner

This is the output I get when I run the attached go program with the standard IETF MIBs and the provided Synology MIBs loaded:

$ go run synology.go
.1.3.6.1.4.1.6574.2.1
node: diskTable
get index: [{{ReadOnly ObjectType The index of disk table Column diskIndex 1.3.6.1.4.1.6574.2.1.1.1 11 Current Type[Integer32 Status=Unknown, Format=, Units=]} 0xc001d09b80 Type[Integer32 Status=Unknown, Format=, Units=]}]
index: map[diskIndex:{}]
order: [diskIndex diskID diskModel diskType diskStatus diskTemperature diskRole diskRetry diskBadSector diskIdentifyFail diskRemainLife diskName]

@sleepinggenius2
Copy link
Owner

sleepinggenius2 commented Dec 17, 2021

One potential flaw that I see in the provided code is that you have a qualified name in your lookup, but you are completely ignoring the module, which might be causing an issue. You are also not returning after an errored GetNode call. I would suggest doing something like this instead:

...
s := strings.Split(oid, "::")
moduleName := s[0]
module, err := gosmi.GetModule(moduleName)
if err != nil {
  fmt.Printf("%v", err)
  return
}
node := s[1]
out, err := module.GetNode(node)
if err != nil {
  fmt.Printf("%v", err)
  return
}
...

As you already have the node in out at this point, I'm not sure why you are then looking it up again by OID with gosmi.GetNodeByOID(types.OidMustFromString(oidNum)). Also, if you know the module name, then it's unnecessary to load all the files in the paths first.

@MyaLongmire
Copy link
Author

Thank you for your help. I will implement your suggestion :)

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