def run_info(self):
     servers = settings.get_redis_servers()
     
     eids = set(())
     for server in servers:
         eid = server['ep']
         eids.add(eid)
         instancename = '%(group)s-%(instance)s' % server
         info=self.threads.get(eid)
         if( info== None):
             info = InfoThread(server["server"], server["port"],
                            instancename,server.get("password", None))
             info.setDaemon(True)
             info.start()
             self.threads[eid] = info
            
             print 'add %s' % eid
         else:
             info.instancename= instancename
         
     for eid, info2 in self.threads.items():
         if(eid not in eids):
             info2.stop()
             self.threads.pop(eid)
             print 'remove %s' % eid
Exemplo n.º 2
0
    def run(self, duration):
        """Monitors all redis servers defined in the config for a certain number
        of seconds.

        Args:
            duration (int): The number of seconds to monitor for.
        """
        redis_servers = settings.get_redis_servers()


        for redis_server in redis_servers:

            redis_password = redis_server.get("password")

            monitor = MonitorThread(redis_server["server"], redis_server["port"], redis_password)
            self.threads.append(monitor)
            monitor.setDaemon(True)
            monitor.start()

            info = InfoThread(redis_server["server"], redis_server["port"], redis_password)
            self.threads.append(info)
            info.setDaemon(True)
            info.start()

        t = Timer(duration, self.stop)
        t.start()

        try:
            while self.active:
                pass
        except (KeyboardInterrupt, SystemExit):
            self.stop()
            t.cancel()
Exemplo n.º 3
0
    def get(self):
        group = self.get_argument("group", None)

        response = {}
        response['data'] = []
        for server in settings.get_redis_servers():
            if (group != None and group != 'all' and server['group'] != group):
                continue

            info = self.getStatsPerServer(
                (server['server'], server['port'], server['password']))

            info.update({
                "addr":
                info.get("server_name")[0].replace(".", "_") +
                str(info.get("server_name")[1]),
            })
            info[
                'show_name'] = server['group'] + '(' + server['instance'] + ')'
            info['group'] = server['group']
            screen_strategy = 'normal'
            if info.get("status") == 'down':
                screen_strategy = 'hidden'

            info.update({
                "screen_strategy": screen_strategy,
            })

            response["data"].append(info)

        self.write(response)
Exemplo n.º 4
0
    def run(self, duration):
        """Monitors all redis servers defined in the config for a certain number
        of seconds.

        Args:
            duration (int): The number of seconds to monitor for.
        """
        redis_servers = settings.get_redis_servers()

        for redis_server in redis_servers:

            redis_password = redis_server.get("password")

            monitor = MonitorThread(redis_server["server"],
                                    redis_server["port"], redis_password)
            self.threads.append(monitor)
            monitor.setDaemon(True)
            monitor.start()

            info = InfoThread(redis_server["server"], redis_server["port"],
                              redis_password)
            self.threads.append(info)
            info.setDaemon(True)
            info.start()

        t = Timer(duration, self.stop)
        t.start()

        try:
            while self.active:
                pass
        except (KeyboardInterrupt, SystemExit):
            self.stop()
            t.cancel()
Exemplo n.º 5
0
    def run_daemon(self):
        redis_servers = settings.get_redis_servers()

        for redis_server in redis_servers:
            
            info = InfoThread(redis_server["server"], redis_server["port"],
                              redis_server.get("password", None))
            self.threads.append(info)
            info.setDaemon(True)
            info.start()
        # In this particular case, running a single MONITOR client can reduce 
        # the throughput by more than 50%. Running more MONITOR clients will 
        # reduce throughput even more.
        try:
            doitems=0
            while self.active:
                time.sleep(1)
                doitems+=1
                stats_provider = RedisLiveDataProvider.get_provider()
                #try collection DB like:redis aofrewrite
                if(doitems %3600==0):
                    stats_provider.collection_database()
                
        except (KeyboardInterrupt, SystemExit):
            self.stop()
Exemplo n.º 6
0
    def read_server_config(self):
        server_list = []
        redis_servers = settings.get_redis_servers()

        for server in redis_servers:
            server_list.append([server['server'],server['port']])

        return server_list
    def read_server_config(self):
        server_list = []
        redis_servers = settings.get_redis_servers()

        for server in redis_servers:
            server["id"] = "%(server)s:%(port)s" % server
            server_list.append(server)

        return server_list
Exemplo n.º 8
0
    def run(self):
        """Monitera all redis servers use ping CMD
        """
        redis_servers = settings.get_redis_servers()

        for redis_server in redis_servers:
            redis_password = redis_server.get("password")
            self.ping(redis_server["server"], redis_server["port"],
                      redis_password)

        if len(self.failedList) > 0:
            self.sendMail()
Exemplo n.º 9
0
    def read_server_config(self):
        """Returns a list of servers with the 'id' field added.
        """
        # TODO: Move this into the settings module so everything benefits.
        server_list = []
        redis_servers = settings.get_redis_servers()

        for server in redis_servers:
            server_id = "%(server)s:%(port)s" % server
            s = dict(server=server['server'], port=server['port'], id=server_id)
            server_list.append(s)

        return server_list
Exemplo n.º 10
0
    def get(self):
        """Serves a GET request.
        """
        server = self.get_argument("server").split(':')

        for redis_server in settings.get_redis_servers():
            if (redis_server["server"] == server[0]) and (int(
                    redis_server["port"]) == int(server[1])):
                break
        redis_info = self.getStatsPerServer(server)
        uptime_seconds = redis_info['uptime_in_seconds']
        redis_info['uptime'] = self.shorten_time(uptime_seconds)
        redis_info['total_commands_processed_human'] = redis_info[
            'total_commands_processed']
        self.write(redis_info)
Exemplo n.º 11
0
 def get(self):
     server_list=""
     for server in settings.get_redis_servers():
         server_list+= "%(server)s:%(port)s %(group)s %(instance)s\r\n" % server
     
     sms_repl=0;
     sms_stats=0;
     try:
         sms=settings.get_master_slave_sms_type()
         sms=sms.split(',')
         sms_repl=(int)(sms[0])
         sms_stats=(int)(sms[1])
     except:
         pass
         
     servers = {"servers": server_list,"sms1":sms_repl,"sms2":sms_stats}
     self.write(servers)
Exemplo n.º 12
0
    def get(self):
        server_list = ""
        for server in settings.get_redis_servers():
            server_list += "%(server)s:%(port)s %(group)s %(instance)s\r\n" % server

        sms_repl = 0
        sms_stats = 0
        try:
            sms = settings.get_master_slave_sms_type()
            sms = sms.split(',')
            sms_repl = (int)(sms[0])
            sms_stats = (int)(sms[1])
        except:
            pass

        servers = {"servers": server_list, "sms1": sms_repl, "sms2": sms_stats}
        self.write(servers)
    def get(self):
        """Serves a GET request.
        """

        server = self.get_argument("server").split(':')

	password = None
	
	for redis_server in settings.get_redis_servers():
	  if (redis_server["server"] == server[0]) and (int(redis_server["port"]) == int(server[1])):
            password = redis_server["password"]
	    break
 
        redis_info = self.getStatsPerServer(server, password)
        databases=[]

        for key in sorted(redis_info.keys()):
            if key.startswith("db"):
                database = redis_info[key]
                database['name']=key
                databases.append(database)

        total_keys=0
        for database in databases:
            total_keys+=database.get("keys")

        if(total_keys==0):
            databases=[{"name" : "db0", "keys" : "0", "expires" : "0"}]

        redis_info['databases'] = databases
        redis_info['total_keys']= self.shorten_number(total_keys)

        uptime_seconds = redis_info['uptime_in_seconds']
        redis_info['uptime'] = self.shorten_time(uptime_seconds)

        commands_processed = redis_info['total_commands_processed']
        commands_processed = self.shorten_number(commands_processed)
        redis_info['total_commands_processed_human'] = commands_processed
       
        self.write(redis_info)
Exemplo n.º 14
0
    def get(self):
        group = self.get_argument("group", None)

        response = {}
        response["data"] = []
        for server in settings.get_redis_servers():
            if group != None and group != "all" and server["group"] != group:
                continue

            info = self.getStatsPerServer((server["server"], server["port"]))

            info.update({"addr": info.get("server_name")[0].replace(".", "_") + str(info.get("server_name")[1])})
            info["show_name"] = server["group"] + "(" + server["instance"] + ")"
            info["group"] = server["group"]
            screen_strategy = "normal"
            if info.get("status") == "down":
                screen_strategy = "hidden"

            info.update({"screen_strategy": screen_strategy})

            response["data"].append(info)

        self.write(response)
Exemplo n.º 15
0
    def get(self):
        group = self.get_argument("group", None)
        
        response = {}
        response['data']=[]
        for server in settings.get_redis_servers():
            if(group !=None and group!='all' and server['group'] != group):
                continue;
            
            info=self.getStatsPerServer((server['server'],server['port']))
            
            info.update({"addr" : info.get("server_name")[0].replace(".", "_") +  str(info.get("server_name")[1]),
            })
            info['show_name']=server['group']+'('+server['instance']+')'
            info['group']= server['group']
            screen_strategy = 'normal'
            if info.get("status") == 'down':
                screen_strategy = 'hidden'
    
            info.update({ "screen_strategy": screen_strategy,})

            response["data"].append(info)

        self.write(response)
Exemplo n.º 16
0
    def get(self):
        """Serves a GET request.
        """
        server = self.get_argument("server")
        redis_servers = settings.get_redis_servers()
        currentRedis = {}
        for rserver in redis_servers:
           if server == rserver.get('ep'):
               currentRedis = rserver
        redis_info = self.getStatsPerServer(currentRedis)
        databases=[]

        for key in sorted(redis_info.keys()):
            if key.startswith("db"):
                database = redis_info[key]
                database['name']=key
                databases.append(database)

        total_keys=0
        for database in databases:
            total_keys+=database.get("keys")

        if(total_keys==0):
            databases=[{"name" : "db0", "keys" : "0", "expires" : "0"}]

        redis_info['databases'] = databases
        redis_info['total_keys']= self.shorten_number(total_keys)

        uptime_seconds = redis_info['uptime_in_seconds']
        redis_info['uptime'] = self.shorten_time(uptime_seconds)

        commands_processed = redis_info['total_commands_processed']
        commands_processed = self.shorten_number(commands_processed)
        redis_info['total_commands_processed_human'] = commands_processed
       
        self.write(redis_info)