Skip to content

Commit

Permalink
Merge pull request #7 from uavorg/master
Browse files Browse the repository at this point in the history
merge from master
  • Loading branch information
zhuang16384 authored Jan 5, 2018
2 parents 182c513 + a14da33 commit 2db6739
Show file tree
Hide file tree
Showing 11 changed files with 114 additions and 18 deletions.
1 change: 1 addition & 0 deletions com.creditease.uav.agent.heartbeat/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/target
/logs
/metadata
/bin/
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ public LogFilterAndRuleBuilder newBuilder() {

protected List<LogFilterAndRule> getAidLogFilterAndRuleList(String id) {

id = id.replace('\\', '/');
// id = id.replace('\\', '/');
return aidlogcollection.getIfPresent(id);
}

// this key should be absFilePath --- by hongqiang
public LogFilterAndRule getLogFilterAndRule(String id) {

id = id.replace('\\', '/');
// id = id.replace('\\', '/');
LogFilterAndRule lfar = null;

lfar = logcollection.getIfPresent(id);
Expand Down Expand Up @@ -275,9 +275,10 @@ public LogFilterAndRule build(String classname) {
AppLogPatternInfoCollection profileMap = logAgent.getLatestLogProfileDataMap();
LogPatternInfo logPatternInfo = profileMap.get(serverid + "-" + appid,
serverid + "-" + appid + "-" + logid);
logcollection.put(logPatternInfo.getAbsolutePath(), mainLogFAR);
if (aidLogFARlist != null)
aidlogcollection.put(logPatternInfo.getAbsolutePath(), aidLogFARlist);
pubLogFilterAndRule(logPatternInfo.getAbsolutePath(), mainLogFAR);
if (aidLogFARlist != null) {
pubAidLogFilterAndRule(logPatternInfo.getAbsolutePath(), aidLogFARlist);
}
return mainLogFAR;
}

Expand Down Expand Up @@ -382,6 +383,14 @@ public void pubLogFilterAndRule(String id, LogFilterAndRule lfar) {
logcollection.put(id, lfar);
}

public void pubAidLogFilterAndRule(String id, List<LogFilterAndRule> lfar) {

// 保证路径不存在多余的'/'等
id = new File(id).getAbsolutePath();

aidlogcollection.put(id, lfar);
}

public boolean hasLogFilterAndRule(String id) {

LogFilterAndRule lfar = logcollection.getIfPresent(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ private void getSpringMVCURLs(String springMVCBaseUrl, Map<String, Set<String>>

// check if there is suffix, such as *.do
if (allIndex != realSpringMVCBaseUrl.length() - 1) {
suffix = realSpringMVCBaseUrl.substring(allIndex + 1);
suffix = realSpringMVCBaseUrl.substring(allIndex + 1, realSpringMVCBaseUrl.length() - 1);
}

// get the real access path
Expand Down Expand Up @@ -946,7 +946,9 @@ private void getSpringMVCURLs(String springMVCBaseUrl, Map<String, Set<String>>
methodServiceURL = formatRelativePath(serviceURL + "/" + methodRelativePath);
}
else {
methodServiceURL = formatRelativePath(serviceURL + "/" + methodRelativePath + suffix);
// endwith "#" means the suffix is added from springMVCBaseUrl,should be removed while on query
methodServiceURL = formatRelativePath(
serviceURL + "/" + methodRelativePath + suffix + "#");
}

compServicesURLs.add(methodServiceURL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,17 @@
!text-shadow: rgba(0,0,0,0.5) 0px 1px 1px;
text-align:left;
background:#f8f8f8;
height:25px;
}

.GroupTag {
font-size: 12px;
color:#888;
display:inline-block;
background:#fff;
padding-left:5px;
padding-right:5px;
border:1px solid #a8a8a8;
border-radius:10px;
height:16px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,16 @@ function AppHubTabList(_config) {
if (groupObjs[groupId]==undefined) {
var groupElemId=config["id"]+"-group-"+groupId;
groupDiv=HtmlHelper.newElem("div",{"id":groupElemId,"class":"AppHubTabListGroup"});
groupDiv.innerHTML="<div class='GroupTitle' id='"+groupElemId+"_title'>"+groupId+"</div>";
groupDiv.innerHTML="<div class='GroupTitle' id='"+groupElemId+"_title'>"+groupId+"<span class='GroupTag' id='"+groupElemId+"_tag'></span></div>";
groupObjs[groupId]={id:groupId,
elem:function() {

return HtmlHelper.id(groupElemId);

},members:new Map(),elemTitle:function() {
return HtmlHelper.id(groupElemId+"_title");
},elemTag:function() {
return HtmlHelper.id(groupElemId+"_tag");
}};

mdiv.appendChild(groupDiv);
Expand Down Expand Up @@ -160,7 +162,7 @@ function AppHubTabList(_config) {
}
}

//delete group withour any member
//delete group without any member
for(var key in groupObjs) {

var gpElemId=config.id+"-group-"+key;
Expand All @@ -172,6 +174,20 @@ function AppHubTabList(_config) {
delete groupObjs[key];
}
}

//show group tag
for(var key in groupObjs) {

var gpElemId=config.id+"-group-"+key;

var gpElem=HtmlHelper.id(gpElemId);

var childNum=gpElem.children.length-1;

var groupObj=groupObjs[key];

groupObj.elemTag().innerHTML=childNum;
}
};

this.doGroupClick=function(groupId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4192,7 +4192,7 @@ var mvcObj={
* App Service URL 性能显示
*/
sb.append("<div class='indexItem'>");
sb.append("<div class='indexItemHead'><span class='indexItemTag'>"+(i+1)+"</span><span class='indexItemId'>"+url+"</span></div>");
sb.append("<div class='indexItemHead'><span class='indexItemTag'>"+(i+1)+"</span><span class='indexItemId'>"+url.replace("#","")+"</span></div>");
sb.append("<div class='indexItemContent'>");
sb.append("QPM<span class='osRate' id='"+url+"_appservicechart_QPS'>-</span>&nbsp;&nbsp;" +
"全程平均响应(ms)<span class='osRate' id='"+url+"_appservicechart_RT'>-</span>&nbsp;&nbsp;" +
Expand Down Expand Up @@ -4240,6 +4240,21 @@ var mvcObj={
*/
monitorCfg.url.ip=sObj.ip;
monitorCfg.url.svrid=sObj.svrid;

//url以"#"结尾意味着需要去除后缀,
for(var i=0;i<sObj.urls.length;i++){

if(!sObj.urls[i].endsWith("#")){
continue;
}

var lastSeparatorIndex = sObj.urls[i].lastIndexOf("/");
var suffixIndex = sObj.urls[i].lastIndexOf(".");
//最后一个分隔符'/'之后的点认为是后缀
if(suffixIndex > lastSeparatorIndex){
sObj.urls[i] = sObj.urls[i].substring(0,suffixIndex);
}
}
monitorCfg.url.urls=sObj.urls;
/**
* Step 2: refresh service url
Expand All @@ -4265,6 +4280,21 @@ var mvcObj={

var urlMO=urlMOs[key];

//正常情况下返回结果的key应该在appURLQPSCfg.seriesMap,若不在说明做了后缀的截取,需要恢复
if(!(key in appURLQPSCfg.seriesMap)){
for(var seriesMapKey in appURLQPSCfg.seriesMap){
//按照去除后缀的逻辑把seriesMapKey里的后缀去掉,若与当前key相同说明是同一个url
var lastSeparatorIndex = seriesMapKey.lastIndexOf("/");
var suffixIndex = seriesMapKey.lastIndexOf(".");
if(suffixIndex > lastSeparatorIndex && key == seriesMapKey.substring(0,suffixIndex)){
//将key替换成含有后缀的形式,保证数据可以正确设置
key = seriesMapKey;
//将urlMO["id"]替换成含有后缀形式,保证数据可以正常显示
urlMO["id"]=key;
break;
}
}
}
var tps = urlMO["tps"];
var tavg = urlMO["tavg"];
var err = urlMO["err"];
Expand Down Expand Up @@ -4718,7 +4748,7 @@ var mvcObj={

for(var i=0;i<cptservice.length;i++) {

sb.append("<div class='kvSubField'>"+cptservice[i]+"</div>");
sb.append("<div class='kvSubField'>"+cptservice[i].replace("#","")+"</div>");

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,13 +346,14 @@ private void judgeProcCrash() {
String[] procKeyBakArray = procKeyBak.split("_", -1);
String ipBak = procKeyBakArray[0];
String nameBak = procKeyBakArray[1];
List<String> portsBak = new ArrayList<String>(Arrays.asList(procKeyBakArray[2].split(":")));

if (procKeyBakArray[2].equals("") || !(ipBak + nameBak).equals(ip + name)
|| procKeyBak.equals(procKey) || delKeys.contains(procKeyBak)) {
continue;
}

List<String> portsBak = new ArrayList<String>(Arrays.asList(procKeyBakArray[2].split(":")));

for (String port : ports) {
if (portsBak.contains(port)) {
if (time >= timeBak) {
Expand Down Expand Up @@ -579,7 +580,7 @@ private Map<String, Object> buildMDF(String node) {
/**
* 拼接判断进程死亡所用的key
*
* 1.存在固定端口进程 ip_name_port:port:__
* 1.存在固定端口进程 ip_name_port#port#__
*
* 2.不存在固定端口的非java进程 ip_name___
*
Expand Down Expand Up @@ -643,7 +644,7 @@ private void putDiskInfo(Map<String, Object> infoMap) {
Map<String, Object> dv = (Map<String, Object>) disk.get(dk);
for (String dvk : dv.keySet()) {
String dvv = dv.get(dvk).toString();
if ("useRate".equals(dvk)||"useRateInode".equals(dvk)) {
if ("useRate".equals(dvk) || "useRateInode".equals(dvk)) {
dvv = dvv.replace("%", ""); // cut '%'
}
infoMap.put("os.io.disk" + pk + dvk, dvv);
Expand Down
2 changes: 1 addition & 1 deletion com.creditease.uav.hook.redis/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<dependencies>
<dependency>
<groupId>com.creditease.moniter</groupId>
<artifactId>com.creditease.uav.base</artifactId>
<artifactId>com.creditease.uav.monitorframework</artifactId>

</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,13 @@ public void handleEvent(InterceptContext context) {
}
}

@SuppressWarnings("unchecked")
private void initHookFactory() {

String config = System.getProperty("com.creditease.uav.hookfactory.config");

hookConfig = JSONHelper.toObjectArray(config, Map.class);
// make an ordered JSONObject cause by "adapts" must be ordered on injecting
hookConfig = JSONHelper.toObject(config, List.class, true);

String hookFactoryClassStr = System
.getProperty("com.creditease.uav." + vendor.toString().toLowerCase() + ".hookfactory");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,18 @@ public boolean match(String targetUrl) {
}

/**
* Step 3: if the targetUrl possible has path param, need check if the path param count match
* Step 3: if there is a suffix such as xxx.do,remove the suffix and try to match again
*/
int suffixIndex = targetUrl.lastIndexOf(".");
if (suffixIndex > -1) {
String targetUrlWithoutSuffix = targetUrl.substring(0, suffixIndex);
if (targetUrlWithoutSuffix.endsWith(this.pathPattern) == true) {
return true;
}
}

/**
* Step 4: if the targetUrl possible has path param, need check if the path param count match
*/
String pathParamStr = targetUrl.substring(index + this.pathPattern.length());

Expand All @@ -111,7 +122,7 @@ public boolean match(String targetUrl) {
}

/**
* Step 4: check if allow abMatch,if yes, as part, then return true, mostly for servlet or filter
* Step 5: check if allow abMatch,if yes, as part, then return true, mostly for servlet or filter
*/
if (this.allowAbMatch == true) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,20 @@ public static String getApplicationId(String contextroot, String basePath) {
appid = contextroot;
}

// 去除最开始的"/"
if (appid.indexOf("/") == 0) {
appid = appid.substring(1);
}
/**
* tomcat等容器在配置了多层虚拟路径以后,appid会存在特殊字符"/",如:
* <Context docBase="/data/source" path="/test/test" reloadable="true" /> 由于存在使用appid创建文件的情况,此处统一将特殊字符进行转义
*/
if (appid.indexOf("/") > -1) {
appid = appid.replace("/", "--");
}
if (appid.indexOf("\\") > -1) {
appid = appid.replace("\\", "--");
}

return appid;
}
Expand Down

0 comments on commit 2db6739

Please sign in to comment.