Esempio n. 1
0
    def run(self):
        parser = OptionParser(usage='usage: firetower options args')
        parser.add_option(
                '-c', '--conf', action='store', dest='conf_path',
                help='Path to YAML configuration file.')

        (options, args) = parser.parse_args()

        if len(args) > 1:
            parser.error('Please supply some arguments')

        conf = config.Config(options.conf_path)

        alert_time = None
        queue = Redis(host=conf.redis_host, port=conf.redis_port)
        cls = classifier.Levenshtein(queue)
        alert = alerts.Alert(queue)
        while 1:
            now = datetime.datetime.now()
            err = queue.pop(conf.queue_key)
            if not alert_time:
                alert_time = datetime.timedelta(minutes=conf.alert_time) + now
            elif alert_time < now:
                alert.check(conf.error_signatures, conf.timeslices)
                alert_time = datetime.timedelta(minutes=conf.alert_time) + now
            if err:
                parsed = json.loads(err)
                cls.classify(parsed)
            else:
                time.sleep(1)
Esempio n. 2
0
class Display(object):

    def __init__(self, conf):
        self.r = Redis(conf.redis_host, conf.redis_port)
        self.conf = conf

    def dump_data(self, tracked_keys):
        counts = self.r.get_counts(tracked_keys)
        pprint.pprint(counts)
        lastlogs = []
        log_keys = self.r.conn.keys()
        print "These are the log_keys"
        pprint.pprint(log_keys)
        for key in log_keys:
            #Because we don't want to regurgitate the count keys
            data_key = 'data_%' % (key,)
            if data_key in tracked_keys:
                last_hour = time.time() - datetime.timedelta(minutes=60)
                error_data = self.r.conn.zrangebyscore(
                        data_key, last_hour, "inf", limit=1, withscores=True)
                lastlogs.append(error_data)

        pprint.pprint(lastlogs)

    def dump_incoming(self):
        """Display length of incoming queue and its contents."""
        print 'Incoming queue length: ', self.r.len_incoming(self.conf.queue_key)
        print self.r.dump_incoming(self.conf.queue_key)
Esempio n. 3
0
    def run(self):
        parser = OptionParser(usage="usage: firetower options args")
        parser.add_option("-c", "--conf", action="store", dest="conf_path", help="Path to YAML configuration file.")

        (options, args) = parser.parse_args()

        conf = config.Config(options.conf_path)

        alert_time = None
        queue = Redis(host=conf.redis_host, port=conf.redis_port)
        cls = classifier.Levenshtein(queue)
        alert = alerts.Alert(queue)
        while 1:
            now = datetime.datetime.now()
            err = queue.pop(conf.queue_key)
            if not alert_time:
                alert_time = datetime.timedelta(minutes=conf.alert_time) + now
            elif alert_time < now:
                alert.check(conf.error_signatures, conf.timeslices)
                alert_time = datetime.timedelta(minutes=conf.alert_time) + now
            if err:
                parsed = json.loads(err)
                cls.classify(parsed, conf.class_thresh)
            else:
                time.sleep(1)
Esempio n. 4
0
 def run(self, conf):
     queue = Redis(host=conf.redis_host, port=conf.redis_port)
     print queue.conn.keys()
     for i in xrange(0, 50):
         try:
             # Semi-randomly seed the 'sig' key in our fake errors
             FAKE_DATA["sig"] = random.choice(FAKE_SIGS)
             print FAKE_DATA
             encoded = json.dumps(FAKE_DATA)
             err = queue.push(conf.queue_key, encoded)
         except:
             print "Something went wrong storing value from redis"
Esempio n. 5
0
 def __init__(self, conf):
     self.r = Redis(conf.redis_host, conf.redis_port)
     self.conf = conf