Example #1
0
def main():
    logging.basicConfig(
        level=logging.INFO,
        format='%(asctime)s %(levelname)s %(message)s',
    )
    alerts.init()
    monitor = QueueMonitor()
    monitor.poll()
Example #2
0
def main():
    logging.basicConfig(
        level=logging.INFO,
        format='%(asctime)s %(levelname)s %(message)s',
    )
    alerts.init()
    monitor = QueueMonitor()
    monitor.poll()
Example #3
0
def init_alerts(**sections):
    wessex.connect_harold = lambda: TestingHarold("localhost", "secret")
    config = {}
    config.update(sections)
    with tempfile.NamedTemporaryFile() as f:
        for section, data in config.iteritems():
            f.write('[%s]\n' % section)
            for name, value in data.iteritems():
                f.write('%s = %s\n' % (name, value))
            f.write('\n')
        f.flush()
        alerts.init(config_path=f.name)
Example #4
0
def init_alerts(**sections):
    wessex.Harold = TestingHarold
    config = dict(harold=dict(host='localhost', port=8888, secret='secret'), )
    config.update(sections)
    with tempfile.NamedTemporaryFile() as f:
        for section, data in config.iteritems():
            f.write('[%s]\n' % section)
            for name, value in data.iteritems():
                f.write('%s = %s\n' % (name, value))
            f.write('\n')
        f.flush()
        alerts.init(config_path=f.name)
Example #5
0
def main():
    # expects a config section like the following
    # [haproxy]
    # threshold = 200
    # interval = 30
    # url.* = url
    alerts.init()
    haproxy_urls = [value for key, value in
                    alerts.config.items(CONFIG_SECTION)
                    if key.startswith("url")]
    threshold = alerts.config.getint(CONFIG_SECTION, "threshold")
    interval = alerts.config.getint(CONFIG_SECTION, "interval")

    watch_request_queues(haproxy_urls, threshold, interval)
Example #6
0
def init_alerts(**sections):
    wessex.Harold = TestingHarold
    config = dict(
        harold=dict(host='localhost', port=8888, secret='secret'),
    )
    config.update(sections)
    with tempfile.NamedTemporaryFile() as f:
        for section, data in config.iteritems():
            f.write('[%s]\n' % section)
            for name, value in data.iteritems():
                f.write('%s = %s\n' % (name, value))
            f.write('\n')
        f.flush()
        alerts.init(config_path=f.name)
Example #7
0
def main():
    # expects a config section like the following
    # [haproxy]
    # threshold = 200
    # interval = 30
    # url.* = url
    alerts.init()
    haproxy_urls = [
        value for key, value in alerts.config.items(CONFIG_SECTION)
        if key.startswith("url")
    ]
    threshold = alerts.config.getint(CONFIG_SECTION, "threshold")
    interval = alerts.config.getint(CONFIG_SECTION, "interval")

    watch_request_queues(haproxy_urls, threshold, interval)
Example #8
0
def main():
    alerts.init()

    haproxy_urls = [value for key, value in
                    alerts.config.items("haproxy")
                    if key.startswith("url")]

    while True:
        try:
            usage_by_pool = fetch_session_counts(haproxy_urls)
        except urllib2.URLError:
            pass
        else:
            notify_graphite(usage_by_pool)
            pretty_print(usage_by_pool)

        time.sleep(1)
Example #9
0
def main():
    alerts.init()

    haproxy_urls = [
        value for key, value in alerts.config.items("haproxy")
        if key.startswith("url")
    ]

    while True:
        try:
            usage_by_pool = fetch_session_counts(haproxy_urls)
        except urllib2.URLError:
            pass
        else:
            notify_graphite(usage_by_pool)
            pretty_print(usage_by_pool)

        time.sleep(1)
	def init(self):
		""" This initializes the application specific items """
		# logger start
		self.logger = logger.Logger()
		self.logger.log(" *** Starting the engine *** ")
		self.logger.log(VERSION)
		# init configuration
		self.configuration = configuration.init()
		# init scheduler
		self.scheduler = scheduler.init()
		# init networking
		self.networking = netio.init()
		# init worker threads
		self.threads = worker.init()
		# init alerts
		self.alerts = alerts.init()
Example #11
0
    def _normalize_key(cls, key):
        key = '_'.join(key.split()).replace('\\', '-')
        return ''.join(cls._VALID_CHAR_PATTERN.findall(key))

    @classmethod
    def _parse_part(cls, key, part):
        # format: <value> '|' <value_type> ('@' <sample_rate>)?
        fields = part.split('|')
        if len(fields) != 2:
            raise ValueError
        value = float(fields[0])
        if '@' in fields[1]:
            fields[1], sample_rate = fields[1].split('@', 1)
            sample_rate = float(sample_rate)
            if not (0.0 < sample_rate <= 1.0):
                raise ValueError
        else:
            sample_rate = 1.0
        if fields[1] == 'ms':
            value_type = cls.TIMER
        else:
            value_type = cls.COUNTER
        return cls(key, value, value_type, sample_rate)

if __name__ == '__main__':
    alerts.init()
    master = Master.from_config(alerts.config, alerts.harold)
    logging.info('Serving...')
    master.start()
    logging.info('Done!')