• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Agent类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.newrelic.metrics.publish.Agent的典型用法代码示例。如果您正苦于以下问题:Java Agent类的具体用法?Java Agent怎么用?Java Agent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Agent类属于com.newrelic.metrics.publish包,在下文中一共展示了Agent类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createConfiguredAgent

import com.newrelic.metrics.publish.Agent; //导入依赖的package包/类
@Override
  public Agent createConfiguredAgent(Map<String, Object> properties) throws ConfigurationException {

String agentName = (String) properties.get("agentName");
String reportMetricsToServers = (String) properties.get("reportMetricsToServers");
if (agentName == null)
{
          throw new ConfigurationException("'agentName' in plugin.json file cannot be null.");
}
if (reportMetricsToServers == null)
{
	throw new ConfigurationException("'reportMetricsToServers' in plugin.json file cannot be null");
}
if (Boolean.valueOf(reportMetricsToServers) == null)
{
	throw new ConfigurationException("'reportMetricsToServers' must have the value 'true' or 'false', not " + reportMetricsToServers);
}

      JSONArray scripts = (JSONArray)properties.get("scriptsToExecute");

      return new ScriptAgent(agentName, scriptsToExecute(scripts), Boolean.valueOf(reportMetricsToServers));
  }
 
开发者ID:RicardoJTSantos,项目名称:ScriptAgentNewRelicPlugin,代码行数:23,代码来源:ScriptAgentFactory.java


示例2: createConfiguredAgent

import com.newrelic.metrics.publish.Agent; //导入依赖的package包/类
@Override
public Agent createConfiguredAgent(Map<String, Object> map) throws ConfigurationException {
    String name = (String) map.get(NAME);
    String host = (String) map.get(HOST);
    String port = (String) map.get(PORT);
    String username = isNullOrEmpty(map.get(USERNAME)) ? null : (String)map.get(USERNAME);
    String password = isNullOrEmpty(map.get(PASSWORD)) ? null : (String)map.get(PASSWORD);

    if (name == null || host == null || port == null) {
        throw new ConfigurationException(String.format("'%s', '%s' and '%s' cannot be null.", USERNAME, PASSWORD, PORT));
    }

    String[] hostsRaw = host.split(",");
    List<String> hosts = new ArrayList<>();
    for(String hostRaw : hostsRaw) {
        hosts.add(hostRaw.trim());
    }

    return new CassandraAgent(new JMXRunnerFactory(), name, hosts, port, username, password);
}
 
开发者ID:thoersch,项目名称:new-relic-cassandra,代码行数:21,代码来源:CassandraAgentFactory.java


示例3: createConfiguredAgent

import com.newrelic.metrics.publish.Agent; //导入依赖的package包/类
@Override
public Agent createConfiguredAgent(Map<String, Object> properties) {
    String name = (String) properties.get("name");
    String host = (String) properties.get("host");
    Object portObj = properties.get("port");

    Integer port = null;

    if(portObj != null) {
        port = ((Long)portObj).intValue();
    }
    else {
        port = 11211; // default port for Memcached
    }

    return new MemcachedAgent(name, host, port);
}
 
开发者ID:newrelic-platform,项目名称:newrelic_memcached_java_plugin,代码行数:18,代码来源:MemcachedAgentFactory.java


示例4: createConfiguredAgent

import com.newrelic.metrics.publish.Agent; //导入依赖的package包/类
@Override
public Agent createConfiguredAgent(Map<String, Object> pluginProperties) throws ConfigurationException {
    AgentProperties properties = AgentProperties.parse(pluginProperties);
    logger.info("Creating agent using: ", properties);

    DropwizardAgent agent = new DropwizardAgent(properties.getName());
    registerProbes(properties, agent);
    return agent;
}
 
开发者ID:dbaggott,项目名称:newrelic-dropwizard,代码行数:10,代码来源:DropwizardAgentFactory.java


示例5: shouldCreateAgentWithName

import com.newrelic.metrics.publish.Agent; //导入依赖的package包/类
@Test
public void shouldCreateAgentWithName() throws Exception {
    Agent agent = factory.createConfiguredAgent(ImmutableMap.<String, Object>of(
            "name", "app-name"
    ));

    assertThat(agent.getAgentName(), is("app-name"));
}
 
开发者ID:dbaggott,项目名称:newrelic-dropwizard,代码行数:9,代码来源:DropwizardAgentFactoryTest.java


示例6: createConfiguredAgent

import com.newrelic.metrics.publish.Agent; //导入依赖的package包/类
@Override
public Agent createConfiguredAgent(Map<String, Object> properties) throws ConfigurationException {
    String name = (String) properties.get("name");
    String statusUrl = (String) properties.get("status_url");

    if (name == null || statusUrl == null) {
        throw new ConfigurationException("'name' and 'status_url' cannot be null. Do you have a 'config/plugin.json' file?");
    }

    return new NginxAgent(name, statusUrl);
}
 
开发者ID:rchouinard,项目名称:newrelic-nginx-plugin,代码行数:12,代码来源:NginxAgentFactory.java


示例7: createConfiguredAgent

import com.newrelic.metrics.publish.Agent; //导入依赖的package包/类
@Override
public Agent createConfiguredAgent(Map<String, Object> properties) throws ConfigurationException {
    if (!properties.containsKey("name")) {
        throw new ConfigurationException("The 'name' attribute is required. Have you configured the 'config/plugin.json' file?");
    }

    // agent name
    String name = (String) properties.get("name");

    // stats
    VarnishStats stats = new VarnishStats();
    if (properties.containsKey("instance")) {
        stats.setInstance((String) properties.get("instance"));
    }
    if (properties.containsKey("user") || properties.containsKey("host")) {
        stats.setSshCommand(buildSshCommand(properties));
    }
    if (!stats.isValid()) {
        throw new ConfigurationException("Executing '" + stats.getCommand() + "' failed: " + stats.getError() + ". Please check the 'config/plugin.json' file.");
    }

    // metrics meta
    JSONObject metrics = Config.getValue("metric_units");
    if (null == metrics) {
        throw new ConfigurationException("The 'metric_units' attribute is required. Have you configured the 'config/plugin.json' file?");
    }
    Map<String, MetricMeta> meta = buildMetricMeta(metrics);

    // custom labels
    JSONObject labels = Config.getValue("custom_labels");
    Map<String, String> customLabels = new HashMap<String, String>();
    if (null != labels) {
        buildCustomLabels(customLabels, labels);
    }

    return new VarnishAgent(name, stats, meta, customLabels);
}
 
开发者ID:Bauer-Xcel-Media,项目名称:newrelic_varnish_plugin,代码行数:38,代码来源:VarnishAgentFactory.java


示例8: createConfiguredAgent

import com.newrelic.metrics.publish.Agent; //导入依赖的package包/类
@Override
public Agent createConfiguredAgent(final Map<String, Object> properties) throws ConfigurationException {
	String name = (String) properties.get("name");
	String pidfile = (String) properties.get("pidfile");
	String jmap = (String) properties.get("jmap");

	if (name == null || pidfile == null) {
		throw new ConfigurationException("'name' and 'pidfile' cannot be null. Do you have a 'config/plugin.json' file?");
	}

	return new JVMAgent(name, runtime, pidfile, jmap);
}
 
开发者ID:sfultongv,项目名称:newrelic-plugin,代码行数:13,代码来源:JVMAgentFactory.java


示例9: createConfiguredAgent

import com.newrelic.metrics.publish.Agent; //导入依赖的package包/类
@Override
public Agent createConfiguredAgent(Map<String, Object> properties) throws ConfigurationException {
  String broker = (String) properties.get("kafka.broker");
  String topic = (String) properties.get("kafka.topic");
  String zkHost = (String) properties.get("storm.zk.host");
  String zkPath = (String) properties.get("storm.zk.path");
  String name = (String) properties.get("name");
  return new StormKafkaAgent(name, getHost(broker), getPort(broker), topic, zkHost, zkPath);
}
 
开发者ID:ghais,项目名称:newrelic_storm_kafka,代码行数:10,代码来源:StormKafkaAgentFactory.java


示例10: createConfiguredAgent

import com.newrelic.metrics.publish.Agent; //导入依赖的package包/类
@Override
public Agent createConfiguredAgent(Map<String, Object> properties) throws ConfigurationException {
    String name = (String) properties.get("name");
    String host = (String) properties.get("host");
    
    if (name == null || host == null) {
        throw new ConfigurationException("'name' and 'host' cannot be null. Do you have a 'config/plugin.json' file?");
    }
    
    return new WikipediaAgent(name, host);
}
 
开发者ID:newrelic-platform,项目名称:newrelic_java_wikipedia_plugin,代码行数:12,代码来源:WikipediaAgentFactory.java


示例11: createConfiguredAgent

import com.newrelic.metrics.publish.Agent; //导入依赖的package包/类
@Override
public Agent createConfiguredAgent(Map<String, Object> properties) {
	String name = (String) properties.get("name");
	int sawtoothMax = ((Long) properties.get("sawtoothMax")).intValue();
	int squarewaveMax = ((Long) properties.get("squarewaveMax")).intValue();
	
	return new Waveform(name, sawtoothMax, squarewaveMax);
}
 
开发者ID:newrelic-platform,项目名称:waveform_example_plugin,代码行数:9,代码来源:WaveformFactory.java


示例12: createConfiguredAgent

import com.newrelic.metrics.publish.Agent; //导入依赖的package包/类
/**
 * Configure an agent based on an entry in the properties file. There may be
 * multiple agents per plugin
 */
@Override
public Agent createConfiguredAgent(Map<String, Object> properties) throws ConfigurationException {
    String name = (String) properties.get("name");
    String host = (String) properties.get("host");
    String user = (String) properties.get("user");
    String passwd = (String) properties.get("passwd");
    String conn_properties = (String) properties.get("properties");
    String metrics = (String) properties.get("metrics");

    if (name == null || EMPTY_STRING.equals(name)) {
        throw new ConfigurationException("The 'name' attribute is required. Have you configured the 'config/plugin.json' file?");
    }
    
    /**
     * Use pre-defined defaults to simplify configuration
     */
    if (host == null || EMPTY_STRING.equals(host)) {
        host = MySQLAgent.AGENT_DEFAULT_HOST;
    }
    if (user == null || EMPTY_STRING.equals(user)) {
        user = MySQLAgent.AGENT_DEFAULT_USER;
    }
    if (passwd == null) {
        passwd = MySQLAgent.AGENT_DEFAULT_PASSWD;
    }
    if (conn_properties == null || EMPTY_STRING.equals(conn_properties)) {
        conn_properties = MySQLAgent.AGENT_DEFAULT_PROPERTIES;
    }
    if (metrics == null || EMPTY_STRING.equals(metrics)) {
        metrics = MySQLAgent.AGENT_DEFAULT_METRICS;
    }

    return new MySQLAgent(name, host, user, passwd, conn_properties,
            processMetricCategories(metrics), readCategoryConfiguration());
}
 
开发者ID:newrelic-platform,项目名称:newrelic_mysql_java_plugin,代码行数:40,代码来源:MySQLAgentFactory.java



注:本文中的com.newrelic.metrics.publish.Agent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Hand类代码示例发布时间:2022-05-21
下一篇:
Java SearchService类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap