Skip to content

Commit

Permalink
Merge pull request #3 from uavorg/master
Browse files Browse the repository at this point in the history
merge from uavorg
  • Loading branch information
zxzxzczz authored Jan 11, 2018
2 parents 30d34f3 + 64932c8 commit c85f751
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 16 deletions.
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 @@ -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
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
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,10 @@ private void queryDistinct(UAVHttpMessage data) {

try {
String ipport = data.getRequest("ipport");
AggregationBuilder agg = AggregationBuilders.terms("unique_time").field("time")
// TODO ES aggregation 默认最多查10条, 这里暂时改到1000,待refine
AggregationBuilder agg = AggregationBuilders.terms("unique_time").field("time").size(1000)
.order(Terms.Order.term(false))
.subAggregation(AggregationBuilders.terms("unique_user").field("user"));
.subAggregation(AggregationBuilders.terms("unique_user").field("user").size(1000));

String date = data.getRequest("indexdate");
String currentIndex;
Expand Down

0 comments on commit c85f751

Please sign in to comment.