def info(self): infra_status = DatabaseInfraStatus( databaseinfra_model=self.databaseinfra) with self.redis() as client: json_server_info = client.info() infra_status.version = json_server_info.get('redis_version', None) infra_status.used_size_in_bytes = json_server_info.get( 'used_memory', 0) for database in self.databaseinfra.databases.all(): database_name = database.name db_status = DatabaseStatus(database) try: if self.check_status(): db_status.is_alive = True except: pass db_status.total_size_in_bytes = 0 db_status.used_size_in_bytes = infra_status.used_size_in_bytes infra_status.databases_status[database_name] = db_status return infra_status
def info(self): infra_status = DatabaseInfraStatus( databaseinfra_model=self.databaseinfra ) with self.redis() as client: json_server_info = client.info() infra_status.version = json_server_info.get( 'redis_version', None ) infra_status.used_size_in_bytes = json_server_info.get( 'used_memory', 0 ) for database in self.databaseinfra.databases.all(): database_name = database.name db_status = DatabaseStatus(database) try: if self.check_status(): db_status.is_alive = True except: pass db_status.total_size_in_bytes = 0 db_status.used_size_in_bytes = infra_status.used_size_in_bytes infra_status.databases_status[database_name] = db_status return infra_status
def info(self): databaseinfra_status = DatabaseInfraStatus(databaseinfra_model=self.databaseinfra) # gambiarra, precisa acertar isto! import pymongo from pprint import pprint client = pymongo.MongoClient(self.databaseinfra.instance.address, int(self.databaseinfra.instance.port)) json_status = client.server_info() print "** GERAL" pprint(json_status) # stdout = unicode(self.run_mongo("serverstatus")).strip() # LOG.debug('Server status return:\n%s', stdout) # json_status = load_mongo_json(stdout) databaseinfra_status.version = json_status.get("version", None) # stdout = unicode(self.run_mongo("listdatabases")).strip() # LOG.debug('List Databases return:\n%s', stdout) # json_status = load_mongo_json(stdout) databaseinfra_status.used_size_in_bytes = json_status.get("fileSize", 0) for database in self.databaseinfra.databases.all(): database_name = database.name db_json_status = getattr(client, database_name).command("dbStats") db_status = DatabaseStatus(database) pprint(db_json_status) db_status.used_size_in_bytes = db_json_status.get("fileSize") databaseinfra_status.databases_status[database_name] = db_status client.disconnect() return databaseinfra_status
def info(self): from logical.models import Database databaseinfra_status = DatabaseInfraStatus( databaseinfra_model=self.databaseinfra) r = self.__query("SELECT VERSION()") databaseinfra_status.version = r[0]['VERSION()'] db_sizes = self.__query( "SELECT s.schema_name 'Database', ifnull(SUM( t.data_length + t.index_length), 0) 'Size' \ FROM information_schema.SCHEMATA s \ left outer join information_schema.TABLES t on s.schema_name = t.table_schema \ GROUP BY s.schema_name") all_dbs = {} for database in db_sizes: all_dbs[database['Database']] = int(database['Size']) list_databases = self.list_databases() for database_name in all_dbs.keys(): database_model = None try: # LOG.debug("checking status for database %s" % database_name) database_model = Database.objects.get( name=database_name, databaseinfra=self.databaseinfra) except Database.DoesNotExist: pass if database_model: db_status = DatabaseStatus(database_model) # is_alive? try: if self.check_status() and (database_name in list_databases): db_status.is_alive = True except Exception as e: LOG.warning("could not retrieve db status for %s: %s" % (database_name, e)) db_status.total_size_in_bytes = 0 db_status.used_size_in_bytes = all_dbs[database_name] databaseinfra_status.databases_status[ database_name] = db_status databaseinfra_status.used_size_in_bytes = sum(all_dbs.values()) return databaseinfra_status
def info(self): from logical.models import Database databaseinfra_status = DatabaseInfraStatus( databaseinfra_model=self.databaseinfra) r = self.__query("SELECT VERSION()") databaseinfra_status.version = r[0]['VERSION()'] db_sizes = self.__query("SELECT s.schema_name 'Database', ifnull(SUM( t.data_length + t.index_length), 0) 'Size' \ FROM information_schema.SCHEMATA s \ left outer join information_schema.TABLES t on s.schema_name = t.table_schema \ GROUP BY s.schema_name") all_dbs = {} for database in db_sizes: all_dbs[database['Database']] = int(database['Size']) list_databases = self.list_databases() for database_name in all_dbs.keys(): database_model = None try: # LOG.debug("checking status for database %s" % database_name) database_model = Database.objects.get( name=database_name, databaseinfra=self.databaseinfra) except Database.DoesNotExist: pass if database_model: db_status = DatabaseStatus(database_model) # is_alive? try: if self.check_status() and (database_name in list_databases): db_status.is_alive = True except Exception as e: LOG.warning( "could not retrieve db status for %s: %s" % (database_name, e)) db_status.total_size_in_bytes = 0 db_status.used_size_in_bytes = all_dbs[database_name] databaseinfra_status.databases_status[ database_name] = db_status databaseinfra_status.used_size_in_bytes = sum(all_dbs.values()) return databaseinfra_status
def info(self): databaseinfra_status = DatabaseInfraStatus( databaseinfra_model=self.databaseinfra) # gambiarra, precisa acertar isto! import pymongo from pprint import pprint client = pymongo.MongoClient(self.databaseinfra.instance.address, int(self.databaseinfra.instance.port)) json_status = client.server_info() print "** GERAL" pprint(json_status) # stdout = unicode(self.run_mongo("serverstatus")).strip() # LOG.debug('Server status return:\n%s', stdout) # json_status = load_mongo_json(stdout) databaseinfra_status.version = json_status.get('version', None) # stdout = unicode(self.run_mongo("listdatabases")).strip() # LOG.debug('List Databases return:\n%s', stdout) # json_status = load_mongo_json(stdout) databaseinfra_status.used_size_in_bytes = json_status.get( 'fileSize', 0) for database in self.databaseinfra.databases.all(): database_name = database.name db_json_status = getattr(client, database_name).command('dbStats') db_status = DatabaseStatus(database) pprint(db_json_status) db_status.used_size_in_bytes = db_json_status.get("fileSize") databaseinfra_status.databases_status[database_name] = db_status client.disconnect() return databaseinfra_status