def check_collections(self):
        result = {
            'state' : 'OK',
            'messages' : {
                'info' : [],
                'error': [],
                'warn' : [],
            }
        }

        databases = self.connection.database_names()

        if not databases:
            result['state'] = 'WARN'
            result['messages']['warn'].append('No databases found')

        # Check each database and it's collections
        for database in databases:
            db = self.connection[database]
            collections = db.collection_names()

            if self.empty_collections and not collections:
                # No collections in database - WARN and continue
                if database == 'local':
                    # ignore on database local - it's OK to be empty
                    if result['state'] not in ['ERROR', 'WARN']:
                        result['state'] = 'OK'
                    result['messages']['info'].append('Database %s: no collections found but it is expected' % database)
                    continue
                else:
                    if result['state'] != 'ERROR':
                        result['state'] = 'WARN'
                    result['messages']['warn'].append('Database %s: no collections found, empty database' % database)
                    continue

            # Validate collections
            if self.validate_collections:
                for collection in collections:
                    validation = db.validate_collection(collection)
                    if validation['valid']:
                        result['messages']['info'].append('Database %s: collection %s is valid' % (database, collection))
                        if result['state'] not in ['ERROR', 'WARN']:
                            result['state'] = 'OK'
                    else:
                        for e in validation['errors']:
                            result['messages']['error'].append('Database %s: %s' % (database, e))
                        result['state'] = 'ERROR'
            else:
                if result['state'] not in ['ERROR', 'WARN']:
                    result['state'] = 'OK'
                result['messages']['info'].append('Database %s: %d collections found' % (database, len(collections)))

        return result
A JSON string representation of this twitter.Status instance.
dataset/ETHPy150Open gooddata/smoker/smoker/server/plugins/mongo.py/Plugin.check_collections--crossover with--dataset/ETHPy150Open livid/v2ex/twitter/twitter.py/Status.AsJsonString