def collect(self, oid, name, schema_dir=None):
     metrics = {}
     for schema_name in self.locator.exists():
         schema = Schema.load_schema(schema_name, schema_dir=schema_dir)
         if schema is None:
             continue
         logger.info('collecting data: %s', schema_name)
         collector = Collector(self.locator.endpoint(schema_name), schema)
         metrics.update(collector.collect(oid, name))
     return metrics
def test_get_available_schemas_default():
    assert set(Schema.get_available_schemas()) == set([
        'hdfs.datanode',
        'hdfs.journalnode',
        'hdfs.namenode',
        'hdfs.secondarynamenode',
        'hdfs.zkfc.jmx',
        'hive.metastore.jmx',
        'hive.server2.jmx',
        'impala.catalog',
        'impala.server',
        'impala.statestore',
        'oozie',
        'oozie.jmx',
        'yarn.history-server.jmx',
        'yarn.node-manager.jmx',
        'yarn.resource-manager',
        'yarn.resource-manager.jmx',
        'zookeeper.jmx',
        ])
 def generate(self, oid, name):
     objects = collections.OrderedDict()
     for schemaname in Schema.get_available_schemas():
         schema = Schema.load_schema(schemaname)
         objects.update(schema.scan(oid, name))
     return objects
def test_load_schema(schema_dir):
    assert isinstance(Schema.load_schema('test', schema_dir), Schema)
def test_load_schema_not_found(schema_dir):
    assert Schema.load_schema('unknown', schema_dir) is None
def test_get_available_schemas(schema_dir):
    assert set(Schema.get_available_schemas(schema_dir)) == set(['test'])
def schema(schema_dir):
    return Schema.load_schema('test', schema_dir)