Skip to content

Commit

Permalink
RMON管理の数値が0になる問題の修正
Browse files Browse the repository at this point in the history
MIB値を文字列へ変換する関数の呼び出しの見直し
  • Loading branch information
twsnmp committed Dec 4, 2024
1 parent b5497c4 commit 0ac6204
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions backend/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func getNetworkPorts(n *datastore.NetworkEnt) {
}
switch a[0] {
case "lldpLocChassisId":
n.SystemID = datastore.GetMIBValueString(a[0], &variable, false)
n.SystemID = datastore.GetMIBValueString(a[0], &variable, true)
case "lldpLocSysName":
if setName {
n.Name = datastore.GetMIBValueString(a[0], &variable, false)
Expand All @@ -116,7 +116,7 @@ func getNetworkPorts(n *datastore.NetworkEnt) {
n.Descr += " " + datastore.GetMIBValueString(a[0], &variable, false)
}
case "lldpLocPortId":
portMap[a[1]] = datastore.GetMIBValueString(a[0], &variable, false)
portMap[a[1]] = datastore.GetMIBValueString(a[0], &variable, true)
case "lldpLocPortDesc":
id, ok := portMap[a[1]]
if !ok {
Expand Down Expand Up @@ -202,7 +202,7 @@ func getNetworkPorts(n *datastore.NetworkEnt) {
}
for _, variable := range r.Variables {
if datastore.MIBDB.OIDToName(variable.Name) == name {
pn := datastore.GetMIBValueString(name, &variable, false)
pn := datastore.GetMIBValueString(name, &variable, true)
if pn == "" {
pn = "#" + index
}
Expand Down Expand Up @@ -260,15 +260,15 @@ func FindNeighborNetworksAndLines(n *datastore.NetworkEnt) *FindNeighborNetworks
switch a[0] {
case "lldpRemChassisId":
remoteMap[a[1]] = &datastore.NetworkEnt{
SystemID: datastore.GetMIBValueString(a[0], &variable, false),
SystemID: datastore.GetMIBValueString(a[0], &variable, true),
}
case "lldpRemPortId":
if rn, ok := remoteMap[a[1]]; ok {
b := strings.Split(a[1], ".")
if len(b) < 2 {
return nil
}
id := datastore.GetMIBValueString(a[0], &variable, false)
id := datastore.GetMIBValueString(a[0], &variable, true)
rn.Ports = append(rn.Ports, datastore.PortEnt{
ID: id,
Index: b[1],
Expand All @@ -278,7 +278,7 @@ func FindNeighborNetworksAndLines(n *datastore.NetworkEnt) *FindNeighborNetworks
}
case "lldpRemSysName":
if rn, ok := remoteMap[a[1]]; ok {
rn.Name = datastore.GetMIBValueString(a[0], &variable, false)
rn.Name = datastore.GetMIBValueString(a[0], &variable, true)
}
case "lldpRemSysDesc":
if rn, ok := remoteMap[a[1]]; ok {
Expand Down Expand Up @@ -345,7 +345,7 @@ func FindNeighborNetworksAndLines(n *datastore.NetworkEnt) *FindNeighborNetworks
}
switch a[0] {
case "ipNetToMediaPhysAddress":
arpMap[a[1]] = datastore.GetMIBValueString(a[0], &variable, false)
arpMap[a[1]] = datastore.GetMIBValueString(a[0], &variable, true)
}
return nil
})
Expand All @@ -358,7 +358,7 @@ func FindNeighborNetworksAndLines(n *datastore.NetworkEnt) *FindNeighborNetworks
}
switch a[0] {
case "atPhysAddress":
arpMap[a[1]] = datastore.GetMIBValueString(a[0], &variable, false)
arpMap[a[1]] = datastore.GetMIBValueString(a[0], &variable, true)
}
return nil
})
Expand Down
2 changes: 1 addition & 1 deletion backend/snmp.go
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ func GetRMON(n *datastore.NodeEnt, t string) *RMONEnt {
}
name := a[0]
index := a[1]
value := datastore.GetMIBValueString(name, &variable, false)
value := datastore.GetMIBValueString(name, &variable, true)
vendor := ""
mi := datastore.FindMIBInfo(name)
if mi != nil && mi.Type == "PhysAddress" {
Expand Down
4 changes: 2 additions & 2 deletions polling/snmp.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ func doPollingSnmpCount(pe *datastore.PollingEnt, agent *gosnmp.GoSNMP) {
}
if err := agent.Walk(oid, func(variable gosnmp.SnmpPDU) error {
name := datastore.MIBDB.OIDToName(variable.Name)
s := datastore.GetMIBValueString(name, &variable, false)
s := datastore.GetMIBValueString(name, &variable, true)
if regexFilter != nil && !regexFilter.Match([]byte(s)) {
return nil
}
Expand Down Expand Up @@ -543,7 +543,7 @@ func getSnmpIndex(n *datastore.NodeEnt, name string) map[string]string {
n := datastore.MIBDB.OIDToName(variable.Name)
a := strings.SplitN(n, ".", 2)
if len(a) == 2 {
ret[a[1]] = datastore.GetMIBValueString(a[0], &variable, false)
ret[a[1]] = datastore.GetMIBValueString(a[0], &variable, true)
}
return nil
}); err != nil {
Expand Down

0 comments on commit 0ac6204

Please sign in to comment.