Skip to content

Commit

Permalink
Merge pull request #148 from fyb007/yongbiaofeng
Browse files Browse the repository at this point in the history
FIX windows can‘t collect logs
  • Loading branch information
zxy0728 authored Jan 5, 2018
2 parents 5169fad + 4209b44 commit a14da33
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 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 @@ -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

0 comments on commit a14da33

Please sign in to comment.