Example #1
0
 def _collect_until(self, oid, oid_prefix, lines, index, direction):
     # type: (OID, OID, List[str], int, int) -> SNMPRowInfo
     rows = []
     # Handle case, where we run after the end of the lines list
     if index >= len(lines):
         if direction > 0:
             return []
         else:
             index -= 1
     while True:
         line = lines[index]
         parts = line.split(None, 1)
         o = parts[0]
         if o.startswith('.'):
             o = o[1:]
         if o == oid or o.startswith(oid_prefix + "."):
             if len(parts) > 1:
                 value = cmk.base.agent_simulator.process(parts[1])
             else:
                 value = ""
             # Fix for missing starting oids
             rows.append(('.' + o, classic_snmp.strip_snmp_value(value)))
             index += direction
             if index < 0 or index >= len(lines):
                 break
         else:
             break
     return rows
Example #2
0
def test_strip_snmp_value(value, expected):
    assert classic_snmp.strip_snmp_value(value) == expected