@@ -39,48 +39,6 @@ func (t *Table) Walk() error {
3939 return nil
4040}
4141
42- // addWalkValue parses the PDU and stored result in an indexed way
43- //
44- // The OID part below the table is something like:
45- // 1.X.Y.Y
46- //
47- // 1 entry OID, just a construct to represent the row
48- // X value OID
49- // Y.Y actual index part (can be a longer chain)
50- //
51- // TODO: this might not apply to all tables
52- func (t * Table ) addWalkValue (data gosnmp.SnmpPDU ) error {
53- subOid := GetSubOid (data .Name , t .Oid )
54- if subOid == "" {
55- // other data in walk, ignoring it
56- return nil
57- }
58-
59- parts := strings .Split (subOid , "." )
60-
61- if len (parts ) < 3 {
62- return fmt .Errorf ("could not identify entry, column and id in oid: %s" , data .Name )
63- }
64-
65- // entry := parts[0]
66- column := parts [1 ]
67- id := strings .Join (parts [2 :], "." )
68-
69- if _ , ok := t .Values [id ]; ! ok {
70- t .Values [id ] = TableColumns {}
71- }
72-
73- // store data in indexed tree
74- t.Values [id ][column ] = data
75-
76- // keep list of existing columns
77- if _ , ok := t .Columns [column ]; ! ok {
78- t .Columns [column ] = column
79- }
80-
81- return nil
82- }
83-
8442func (t * Table ) GetValue (id string , oid string ) (interface {}, error ) {
8543 parts := strings .Split (oid , "." )
8644 column := parts [len (parts )- 1 ]
@@ -145,3 +103,45 @@ func SortOIDs(list []string) []string {
145103
146104 return list
147105}
106+
107+ // addWalkValue parses the PDU and stored result in an indexed way
108+ //
109+ // The OID part below the table is something like:
110+ // 1.X.Y.Y
111+ //
112+ // 1 entry OID, just a construct to represent the row
113+ // X value OID
114+ // Y.Y actual index part (can be a longer chain)
115+ //
116+ // TODO: this might not apply to all tables
117+ func (t * Table ) addWalkValue (data gosnmp.SnmpPDU ) error {
118+ subOid := GetSubOid (data .Name , t .Oid )
119+ if subOid == "" {
120+ // other data in walk, ignoring it
121+ return nil
122+ }
123+
124+ parts := strings .Split (subOid , "." )
125+
126+ if len (parts ) < 3 {
127+ return fmt .Errorf ("could not identify entry, column and id in oid: %s" , data .Name )
128+ }
129+
130+ // entry := parts[0]
131+ column := parts [1 ]
132+ id := strings .Join (parts [2 :], "." )
133+
134+ if _ , ok := t .Values [id ]; ! ok {
135+ t .Values [id ] = TableColumns {}
136+ }
137+
138+ // store data in indexed tree
139+ t.Values [id ][column ] = data
140+
141+ // keep list of existing columns
142+ if _ , ok := t .Columns [column ]; ! ok {
143+ t .Columns [column ] = column
144+ }
145+
146+ return nil
147+ }
0 commit comments