Exemplo n.º 1
0
    def __init__(self, config, generator):
        """
        couch - instance of CouchServer class

        """
        BasePoller.__init__(self, config, generator)
        self.couch = None
        self._query = "/_stats" # couch query to retrieve statistics
        self._setUp()
Exemplo n.º 2
0
    def __init__(self, config, generator):
        """
        couch - instance of CouchServer class

        """
        BasePoller.__init__(self, config, generator)
        self.couch = None
        self._query = "/_stats"  # couch query to retrieve statistics
        self._setUp()
Exemplo n.º 3
0
    def __init__(self, config, generator, unitSelection = 3):
        """
        Size units selection:
        0 = Bytes, 1 = kiloBytes, , 2 = MegaBytes, 3 = GigaBytes

        """
        BasePoller.__init__(self, config, generator)
        # set size units
        self._unitSelection = unitSelection
        self._sizeUnitsAll = ("B", "kB", "MB", "GB")
        self._prefixBytesFactor = float(1024 ** self._unitSelection)
        self._currSizeUnit = self._sizeUnitsAll[self._unitSelection]
        self._myName = self.__class__.__name__
Exemplo n.º 4
0
 def testBasePollerHandleFailedPolling(self):
     config = getConfig("/tmp")
     # create some non-sence config section. just need a bunch of values defined        
     config.AlertGenerator.section_("bogusPoller")
     config.AlertGenerator.bogusPoller.soft = 5 # [percent]
     config.AlertGenerator.bogusPoller.critical = 50 # [percent] 
     config.AlertGenerator.bogusPoller.pollInterval = 2  # [second]
     config.AlertGenerator.bogusPoller.period = 10
     
     generator = utils.AlertGeneratorMock(config)
     poller = BasePoller(config.AlertGenerator.bogusPoller, generator)
     ex = Exception("test exception")
     class Sender(object):
         def __call__(self, alert):
             self.alert = alert
     poller.sender = Sender()
     poller._handleFailedPolling(ex)
     self.assertEqual(poller.sender.alert["Source"], "BasePoller")
Exemplo n.º 5
0
 def testBasePollerBasic(self):
     config = getConfig("/tmp")
     # create some non-sence config section. just need a bunch of values defined        
     config.AlertGenerator.section_("bogusPoller")
     config.AlertGenerator.bogusPoller.soft = 5 # [percent]
     config.AlertGenerator.bogusPoller.critical = 50 # [percent] 
     config.AlertGenerator.bogusPoller.pollInterval = 2  # [second]
     config.AlertGenerator.bogusPoller.period = 10
     
     generator = utils.AlertGeneratorMock(config)
     poller = BasePoller(config.AlertGenerator.bogusPoller, generator)
     # define dummy check method
     poller.check = lambda: 1+1
     p = Process(target = poller.poll, args = ())
     p.start()
     # poller now runs
     time.sleep(0.1)
     p.terminate()
     poller.shutdown()
Exemplo n.º 6
0
    def testBasePollerHandleFailedPolling(self):
        config = getConfig("/tmp")
        # create some non-sence config section. just need a bunch of values defined
        config.AlertGenerator.section_("bogusPoller")
        config.AlertGenerator.bogusPoller.soft = 5  # [percent]
        config.AlertGenerator.bogusPoller.critical = 50  # [percent]
        config.AlertGenerator.bogusPoller.pollInterval = 2  # [second]
        config.AlertGenerator.bogusPoller.period = 10

        generator = utils.AlertGeneratorMock(config)
        poller = BasePoller(config.AlertGenerator.bogusPoller, generator)
        ex = Exception("test exception")

        class Sender(object):
            def __call__(self, alert):
                self.alert = alert

        poller.sender = Sender()
        poller._handleFailedPolling(ex)
        self.assertEqual(poller.sender.alert["Source"], "BasePoller")
Exemplo n.º 7
0
    def testBasePollerBasic(self):
        config = getConfig("/tmp")
        # create some non-sence config section. just need a bunch of values defined
        config.AlertGenerator.section_("bogusPoller")
        config.AlertGenerator.bogusPoller.soft = 5  # [percent]
        config.AlertGenerator.bogusPoller.critical = 50  # [percent]
        config.AlertGenerator.bogusPoller.pollInterval = 2  # [second]
        config.AlertGenerator.bogusPoller.period = 10

        generator = utils.AlertGeneratorMock(config)
        poller = BasePoller(config.AlertGenerator.bogusPoller, generator)
        # define dummy check method
        poller.check = lambda: 1 + 1
        poller.start()
        # poller now runs
        time.sleep(config.AlertGenerator.bogusPoller.pollInterval * 2)
        poller.terminate()
        while poller.is_alive():
            time.sleep(0.2)
            print "%s waiting for test poller to terminate" % inspect.stack(
            )[0][3]
Exemplo n.º 8
0
 def testBasePollerBasic(self):
     config = getConfig("/tmp")
     # create some non-sence config section. just need a bunch of values defined        
     config.AlertGenerator.section_("bogusPoller")
     config.AlertGenerator.bogusPoller.soft = 5 # [percent]
     config.AlertGenerator.bogusPoller.critical = 50 # [percent] 
     config.AlertGenerator.bogusPoller.pollInterval = 2  # [second]
     config.AlertGenerator.bogusPoller.period = 10
     
     generator = utils.AlertGeneratorMock(config)
     poller = BasePoller(config.AlertGenerator.bogusPoller, generator)
     # define dummy check method
     poller.check = lambda: 1+1
     poller.start()
     # poller now runs
     time.sleep(config.AlertGenerator.bogusPoller.pollInterval * 2)
     poller.terminate()
     while poller.is_alive():
         time.sleep(0.2)
         print "%s waiting for test poller to terminate" % inspect.stack()[0][3]
Exemplo n.º 9
0
 def __init__(self, config, generator):
     BasePoller.__init__(self, config, generator)