本文整理汇总了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));
}
示例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);
}
示例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);
}
示例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;
}
示例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"));
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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());
}