Exemplo n.º 1
0
 def test_opentsdb_walk_metric_with_ranges(self):
     mdata = self.walkmetric
     mdata["min_val"] = 10
     mdata["max_val"] = 19
     mdata["device"] = self.mockdevice
     m = Metric(**mdata)
     walkdata = m._get_walk(self.mockdevice.snmp)
     result = m._process_walk_data(walkdata, self.time)
     eq_(1, len(result))
Exemplo n.º 2
0
    def test_opentsdb_walk_metric_with_ignore_zeros(self):
        mdata = self.walkmetric
        mdata["ignore_zeros"] = True
        mdata["device"] = self.mockdevice
        m = Metric(**mdata)
        walkdata = m._get_walk(self.mockdevice.snmp)
        result = m._process_walk_data(walkdata, self.time)

        eq_(2, len(result))
Exemplo n.º 3
0
 def test_opentsdb_walk_metric(self, mocktime):
     mocktime.return_value = self.time
     mdata = {
         'metric': 'interface.packets',
         'oid': '.1.3.6.1.2.1.31.1.1.1.9',
         'type': 'walk',
         'tags': {
             'direction': "in",
             'type': 'broadcast'
         },
         'resolver': 'cisco_ifname'
     }
     m = Metric(
         data=mdata,
         device=self.mockdevice
     )
     #test _tags_to_str with empty tags
     eq_("", m._tags_to_str({}))
     walkdata = m._get_walk()
     eq_(10, walkdata["1"])
     eq_(20, walkdata["2"])
     eq_(
         "put interface.packets "
         + str(int(self.time)) +
         " 20 index=2 direction=in type=broadcast host=foo",
         m._process_dp(20, 2)
     )
     result = m._process_walk_data(walkdata)
     eq_(2, len(result))
     eq_(
         'put interface.packets '
         + str(int(self.time)) +
         ' 10 index=1 direction=in type=broadcast host=foo',
         result[0]
     )
     result = m.get_opentsdb_commands()
     eq_(2, len(result))
     eq_(
         'put interface.packets '
         + str(int(self.time)) +
         ' 10 index=1 direction=in type=broadcast host=foo',
         result[0]
     )
Exemplo n.º 4
0
 def test_opentsdb_walk_metric(self, mocktime):
     mocktime.return_value = self.time
     metric = self.walkmetric
     metric["device"] = self.mockdevice
     m = Metric(**metric)
     #test _tags_to_str with empty tags
     eq_("", m._tags_to_str({}))
     walkdata = m._get_walk(self.mockdevice.snmp)
     eq_(10, walkdata["1"])
     eq_(20, walkdata["2"])
     eq_("0", walkdata["3"])
     eq_(
         "put interface.packets.in.foo " + str(int(self.time)) +
         " 2.0 index=2 type=broadcast", m._process_dp(20, self.time, key=2))
     result = m._process_walk_data(walkdata, self.time)
     eq_(3, len(result))
     eq_(
         'put interface.packets.in.foo ' + str(int(self.time)) +
         ' 1.0 index=1 type=broadcast', result[0])
     result = m.get_opentsdb_commands(self.mockdevice.snmp, self.time)
     eq_(3, len(result))
     eq_(
         'put interface.packets.in.foo ' + str(int(self.time)) +
         ' 1.0 index=1 type=broadcast', result[0])