本文整理汇总了Java中scouter.server.core.AgentManager类的典型用法代码示例。如果您正苦于以下问题:Java AgentManager类的具体用法?Java AgentManager怎么用?Java AgentManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AgentManager类属于scouter.server.core包,在下文中一共展示了AgentManager类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: xlog
import scouter.server.core.AgentManager; //导入依赖的package包/类
@ServerPlugin(PluginConstants.PLUGIN_SERVER_XLOG)
public void xlog(XLogPack pack) {
try {
int elapsedThreshold = conf.getInt("ext_plugin_elapsed_time_threshold", 0);
if (elapsedThreshold != 0 && pack.elapsed > elapsedThreshold) {
String serviceName = TextRD.getString(DateUtil.yyyymmdd(pack.endTime), TextTypes.SERVICE, pack.service);
AlertPack ap = new AlertPack();
ap.level = AlertLevel.WARN;
ap.objHash = pack.objHash;
ap.title = "Elapsed time exceed a threshold.";
ap.message = "[" + AgentManager.getAgentName(pack.objHash) + "] "
+ pack.service + "(" + serviceName + ") "
+ "elapsed time(" + pack.elapsed + " ms) exceed a threshold.";
ap.time = System.currentTimeMillis();
ap.objType = AgentManager.getAgent(pack.objHash).objType;
alert(ap);
}
} catch (Exception e) {
Logger.printStackTrace(e);
}
}
开发者ID:scouter-project,项目名称:scouter-plugin-server-alert-email,代码行数:27,代码来源:EmailPlugin.java
示例2: objType
import scouter.server.core.AgentManager; //导入依赖的package包/类
public String objType(XLogPack p) {
ObjectPack a = AgentManager.getAgent(p.objHash);
if (a != null) {
return a.objType;
}
return null;
}
开发者ID:scouter-project,项目名称:scouter,代码行数:8,代码来源:IXLog.java
示例3: getObjName
import scouter.server.core.AgentManager; //导入依赖的package包/类
@ConfigDesc("get current object name.")
public String getObjName() {
if (_objName != null)
return _objName;
ObjectPack a = AgentManager.getAgent(_objHash);
if (a != null && a.objName != null) {
_objName = a.objName;
}
return _objName;
}
开发者ID:scouter-project,项目名称:scouter,代码行数:11,代码来源:RealCounter.java
示例4: getObjType
import scouter.server.core.AgentManager; //导入依赖的package包/类
@ConfigDesc("get current object type name.")
public String getObjType() {
ObjectPack a = AgentManager.getAgent(_objHash);
if (a == null)
return _objType;
if (a.objType != null) {
_objType = a.objType;
}
return _objType;
}
开发者ID:scouter-project,项目名称:scouter,代码行数:11,代码来源:RealCounter.java
示例5: counter
import scouter.server.core.AgentManager; //导入依赖的package包/类
@ServerPlugin(PluginConstants.PLUGIN_SERVER_COUNTER)
public void counter(PerfCounterPack pack) {
String objName = pack.objName;
int objHash = HashUtil.hash(objName);
String objType = null;
String objFamily = null;
if (AgentManager.getAgent(objHash) != null) {
objType = AgentManager.getAgent(objHash).objType;
}
if (objType != null) {
objFamily = CounterManager.getInstance().getCounterEngine().getObjectType(objType).getFamily().getName();
}
try {
// in case of objFamily is javaee
if (CounterConstants.FAMILY_JAVAEE.equals(objFamily)) {
// save javaee type's objHash
if (!javaeeObjHashList.contains(objHash)) {
javaeeObjHashList.add(objHash);
}
if (pack.timetype == TimeTypeEnum.REALTIME) {
long gcTimeThreshold = conf.getLong("ext_plugin_gc_time_threshold", 0);
long gcTime = pack.data.getLong(CounterConstants.JAVA_GC_TIME);
if (gcTimeThreshold != 0 && gcTime > gcTimeThreshold) {
AlertPack ap = new AlertPack();
ap.level = AlertLevel.WARN;
ap.objHash = objHash;
ap.title = "GC time exceed a threshold.";
ap.message = objName + "'s GC time(" + gcTime + " ms) exceed a threshold.";
ap.time = System.currentTimeMillis();
ap.objType = objType;
alert(ap);
}
}
}
} catch (Exception e) {
Logger.printStackTrace(e);
}
}
开发者ID:scouter-project,项目名称:scouter-plugin-server-alert-line,代码行数:46,代码来源:LinePlugin.java
示例6: counter
import scouter.server.core.AgentManager; //导入依赖的package包/类
/**
* PerfCounterPack 발생 시 처리
* @param pack
*/
@ServerPlugin(PluginConstants.PLUGIN_SERVER_COUNTER)
public void counter(PerfCounterPack pack) {
String objName = pack.objName;
int objHash = HashUtil.hash(objName);
String objType = null;
String objFamily = null;
if (AgentManager.getAgent(objHash) != null) {
objType = AgentManager.getAgent(objHash).objType;
}
if (objType != null) {
try {
objFamily = CounterManager.getInstance().getCounterEngine().getObjectType(objType).getFamily().getName();
} catch (Exception e) {
objFamily = objType;
}
}
// objFamily가 host인 경우
if (CounterConstants.FAMILY_HOST.equals(objFamily)) {
if (hostAgentStatMap.get(objHash) == null) {
hostAgentStatMap.put(objHash, new HostAgentStat(objHash));
}
if (pack.timetype == TimeTypeEnum.REALTIME) {
hostAgentStatMap.get(objHash).addMax(pack.data.getFloat(CounterConstants.HOST_CPU),
pack.data.getInt(CounterConstants.HOST_MEM_TOTAL),
pack.data.getFloat(CounterConstants.HOST_MEM),
pack.data.getInt(CounterConstants.HOST_MEM_USED),
pack.data.getInt(CounterConstants.HOST_NET_TX_BYTES),
pack.data.getInt(CounterConstants.HOST_NET_RX_BYTES),
pack.data.getInt(CounterConstants.HOST_DISK_READ_BYTES),
pack.data.getInt(CounterConstants.HOST_DISK_WRITE_BYTES));
} else if (pack.timetype == TimeTypeEnum.FIVE_MIN) {
// NET_TX, NET_RX, DISK_READ, DISK_WRITE 정보는 FIVE_MIN에 포함되지 않음.
hostAgentStatMap.get(objHash).addAvg(pack.data.getFloat(CounterConstants.HOST_CPU),
pack.data.getFloat(CounterConstants.HOST_MEM),
pack.data.getInt(CounterConstants.HOST_MEM_USED));
}
}
// objFamily가 javaee인 경우
if (CounterConstants.FAMILY_JAVAEE.equals(objFamily)) {
if (javaAgentStatMap.get(objHash) == null) {
javaAgentStatMap.put(objHash, new JavaAgentStat(objHash));
}
if (pack.timetype == TimeTypeEnum.REALTIME) {
// JAVA_HEAP_TOT_USAGE 정보가 없는 PerfCounterPack은 host agent가 동작중에 PROC_CPU 정보를 보내주는 경우와, FIVE_MIN 밖에 없음.
// PROC_CPU 정보는 수집 대상이 아님.
ListValue lv = pack.data.getList(CounterConstants.JAVA_HEAP_TOT_USAGE);
if (lv != null && lv.size() > 0) {
javaAgentStatMap.get(objHash).addMax(pack.data.getInt(CounterConstants.WAS_ACTIVE_SERVICE),
lv.getFloat(0),
pack.data.getFloat(CounterConstants.JAVA_HEAP_USED),
pack.data.getInt(CounterConstants.WAS_RECENT_USER),
pack.data.getInt(CounterConstants.WAS_SERVICE_COUNT),
pack.data.getFloat(CounterConstants.WAS_APICALL_TPS),
pack.data.getFloat(CounterConstants.WAS_SQL_TPS),
pack.data.getFloat(CounterConstants.WAS_TPS));
}
} else if (pack.timetype == TimeTypeEnum.FIVE_MIN) {
if (pack.data.toMap().get(CounterConstants.PROC_CPU) == null) {
javaAgentStatMap.get(objHash).addAvg(pack.data.getInt(CounterConstants.WAS_ACTIVE_SERVICE),
pack.data.getFloat(CounterConstants.JAVA_HEAP_USED),
pack.data.getInt(CounterConstants.WAS_RECENT_USER),
pack.data.getInt(CounterConstants.WAS_SERVICE_COUNT),
pack.data.getFloat(CounterConstants.WAS_APICALL_TPS),
pack.data.getFloat(CounterConstants.WAS_SQL_TPS),
pack.data.getFloat(CounterConstants.WAS_TPS));
}
}
}
}
开发者ID:OpenSourceConsulting,项目名称:scouter-plugin-server-reporting,代码行数:81,代码来源:ReportingPlugin.java
示例7: object
import scouter.server.core.AgentManager; //导入依赖的package包/类
/**
* ObjectPack 발생 시 처리
* @param pack
*/
@ServerPlugin(PluginConstants.PLUGIN_SERVER_OBJECT)
public void object(ObjectPack pack) {
if (!pack.objType.equals(CounterConstants.REQUESTPROCESS)) {
AgentInfo agentInfo = null;
ObjectPack op = AgentManager.getAgent(pack.objHash);
boolean isExist = true;
boolean isDownState = false;
// Plugin의 loading이 채 끝나기 전에 agent로부터 heartbeat 메시지가 수신되는 경우
// 해당 Agent의 구동 정보가 누락될 수 있기 때문에 매번 agent의 상태를 조회한다.
agentInfo = selectAgentInfo(pack.objHash);
if (agentInfo == null) {
agentInfo = new AgentInfo();
isExist = false;
} else {
Date lastDownTime = agentInfo.getLast_down_time();
Date lastUpTime = agentInfo.getLast_up_time();
if (lastDownTime != null && lastUpTime != null) {
if (lastDownTime.getTime() - lastUpTime.getTime() > 0) {
isDownState = true;
}
}
}
if ((op == null && pack.wakeup == 0L) || op.alive == false || !isExist || isDownState) {
println("[AgentInfo] : " + agentInfo);
agentInfo.setObject_hash(pack.objHash);
agentInfo.setObject_name(pack.objName);
agentInfo.setObject_type(pack.objType);
if (pack.objType != null) {
String object_family;
try {
object_family = CounterManager.getInstance().getCounterEngine().getObjectType(pack.objType).getFamily().getName();
} catch (Exception e) {
object_family = pack.objType;
}
agentInfo.setObject_family(object_family);
}
agentInfo.setIp_address(pack.address);
agentInfo.setLast_up_time(new Date(System.currentTimeMillis()));
if (isExist) {
updateAgentInfo(agentInfo);
} else {
insertAgentInfo(agentInfo);
}
}
}
}
开发者ID:OpenSourceConsulting,项目名称:scouter-plugin-server-reporting,代码行数:61,代码来源:ReportingPlugin.java
示例8: EmailPlugin
import scouter.server.core.AgentManager; //导入依赖的package包/类
public EmailPlugin() {
if (ai.incrementAndGet() == 1) {
ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
// thread count check
executor.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
for (int objHash : javaeeObjHashList) {
try {
if (AgentManager.isActive(objHash)) {
ObjectPack objectPack = AgentManager.getAgent(objHash);
MapPack mapPack = new MapPack();
mapPack.put("objHash", objHash);
mapPack = AgentCall.call(objectPack, RequestCmd.OBJECT_THREAD_LIST, mapPack);
int threadCountThreshold = conf.getInt("ext_plugin_thread_count_threshold", 0);
int threadCount = mapPack.getList("name").size();
if (threadCountThreshold != 0 && threadCount > threadCountThreshold) {
AlertPack ap = new AlertPack();
ap.level = AlertLevel.WARN;
ap.objHash = objHash;
ap.title = "Thread count exceed a threshold.";
ap.message = objectPack.objName + "'s Thread count(" + threadCount + ") exceed a threshold.";
ap.time = System.currentTimeMillis();
ap.objType = objectPack.objType;
alert(ap);
}
}
} catch (Exception e) {
// ignore
}
}
}
},
0, 5, TimeUnit.SECONDS);
}
}
开发者ID:scouter-project,项目名称:scouter-plugin-server-alert-email,代码行数:43,代码来源:EmailPlugin.java
示例9: SlackPlugin
import scouter.server.core.AgentManager; //导入依赖的package包/类
public SlackPlugin() {
if (ai.incrementAndGet() == 1) {
ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
// thread count check
executor.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
for (int objHash : javaeeObjHashList) {
try {
if (AgentManager.isActive(objHash)) {
ObjectPack objectPack = AgentManager.getAgent(objHash);
MapPack mapPack = new MapPack();
mapPack.put("objHash", objHash);
mapPack = AgentCall.call(objectPack, RequestCmd.OBJECT_THREAD_LIST, mapPack);
int threadCountThreshold = conf.getInt("ext_plugin_thread_count_threshold", 0);
int threadCount = mapPack.getList("name").size();
if (threadCountThreshold != 0 && threadCount > threadCountThreshold) {
AlertPack ap = new AlertPack();
ap.level = AlertLevel.WARN;
ap.objHash = objHash;
ap.title = "Thread count exceed a threshold.";
ap.message = objectPack.objName + "'s Thread count(" + threadCount + ") exceed a threshold.";
ap.time = System.currentTimeMillis();
ap.objType = objectPack.objType;
alert(ap);
}
}
} catch (Exception e) {
// ignore
}
}
}
},
0, 5, TimeUnit.SECONDS);
}
}
开发者ID:scouter-project,项目名称:scouter-plugin-server-alert-slack,代码行数:43,代码来源:SlackPlugin.java
示例10: counter
import scouter.server.core.AgentManager; //导入依赖的package包/类
@ServerPlugin(PluginConstants.PLUGIN_SERVER_COUNTER)
public void counter(PerfCounterPack pack) {
String objName = pack.objName;
int objHash = HashUtil.hash(objName);
String objType = null;
String objFamily = null;
if (AgentManager.getAgent(objHash) != null) {
objType = AgentManager.getAgent(objHash).objType;
}
if (objType != null) {
objFamily = CounterManager.getInstance().getCounterEngine().getObjectType(objType).getFamily().getName();
}
try {
// in case of objFamily is javaee
if (CounterConstants.FAMILY_JAVAEE.equals(objFamily)) {
// save javaee type's objHash
if (!javaeeObjHashList.contains(objHash)) {
javaeeObjHashList.add(objHash);
}
if (pack.timetype == TimeTypeEnum.REALTIME) {
long gcTimeThreshold = conf.getLong("ext_plugin_gc_time_threshold", 0);
long gcTime = pack.data.getLong(CounterConstants.JAVA_GC_TIME);
if (gcTimeThreshold != 0 && gcTime > gcTimeThreshold) {
AlertPack ap = new AlertPack();
ap.level = AlertLevel.WARN;
ap.objHash = objHash;
ap.title = "GC time exceed a threshold.";
ap.message = objName + "'s GC time(" + gcTime + " ms) exceed a threshold.";
ap.time = System.currentTimeMillis();
ap.objType = objType;
alert(ap);
}
}
}
} catch (Exception e) {
Logger.printStackTrace(e);
}
}
开发者ID:scouter-project,项目名称:scouter-plugin-server-alert-slack,代码行数:46,代码来源:SlackPlugin.java
示例11: counter
import scouter.server.core.AgentManager; //导入依赖的package包/类
@ServerPlugin(PluginConstants.PLUGIN_SERVER_COUNTER)
public void counter(final PerfCounterPack pack) {
if (!enabled) {
return;
}
if(pack.timetype != TimeTypeEnum.REALTIME) {
return;
}
try {
String objName = pack.objName;
int objHash = HashUtil.hash(objName);
String objType = AgentManager.getAgent(objHash).objType;
String objFamily = CounterManager.getInstance().getCounterEngine().getObjectType(objType).getFamily().getName();
Point.Builder builder = Point.measurement(measurementName)
.time(pack.time, TimeUnit.MILLISECONDS)
.tag(tagObjName, objName)
.tag(tagObjType, objType)
.tag(tagObjFamily, objFamily);
Map<String, Value> dataMap = pack.data.toMap();
for (Map.Entry<String, Value> field : dataMap.entrySet()) {
Value valueOrigin = field.getValue();
if (valueOrigin == null) {
continue;
}
Object value = valueOrigin.toJavaObject();
if(!(value instanceof Number)) {
continue;
}
String key = field.getKey();
if("time".equals(key)) {
continue;
}
builder.addField(key, (Number)value);
}
Point point = builder.build();
if (isUdp) {
String line = point.lineProtocol();
udpAgent.write(line);
//System.out.println(line);
} else { // http
influx.write(dbName, retentionPolicy, point);
}
} catch (Exception e) {
if (conf._trace) {
Logger.printStackTrace("IFLX001", e);
} else {
Logger.println("IFLX002", e.getMessage());
}
}
}
开发者ID:scouter-project,项目名称:scouter-plugin-server-influxdb,代码行数:56,代码来源:InfluxdbPlugin.java
示例12: objName
import scouter.server.core.AgentManager; //导入依赖的package包/类
public String objName(XLogPack p) {
return AgentManager.getAgentName(p.objHash);
}
开发者ID:scouter-project,项目名称:scouter,代码行数:4,代码来源:IXLog.java
注:本文中的scouter.server.core.AgentManager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论