Skip to content

Commit

Permalink
Merge pull request #6 from uavorg/master
Browse files Browse the repository at this point in the history
merge with master
  • Loading branch information
zhuang16384 authored Dec 29, 2017
2 parents 60a7f99 + 9fd759f commit 182c513
Show file tree
Hide file tree
Showing 24 changed files with 365 additions and 334 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -314,21 +314,30 @@ private String getIODiskInfo() throws Exception {
else {
Map<String, Map<String, String>> resultMap = new HashMap<String, Map<String, String>>();
String diskResult;
String inodeResult;
try {
String shellParentPath = this.getConfigManager().getContext(IConfigurationManager.METADATAPATH) + "sh";
diskResult = RuntimeHelper.exeShell("df -P", shellParentPath);
inodeResult = RuntimeHelper.exeShell("df -Pi", shellParentPath);
}
catch (Exception e) {
return "{}";
}
String lines[] = diskResult.split("\n");
String linesInode[] = inodeResult.split("\n");
for (int i = 1; i < lines.length; i++) {
String[] args = lines[i].split("\\s+");
String[] argsInode = linesInode[i].split("\\s+");
Map<String, String> temp = new HashMap<String, String>();
temp.put("total", args[1]);
temp.put("use", args[2]);
temp.put("free", args[3]);
temp.put("useRate", args[4]);
// inode
temp.put("totalInode", argsInode[1]);
temp.put("useInode", argsInode[2]);
temp.put("freeInode", argsInode[3]);
temp.put("useRateInode", argsInode[4]);
resultMap.put(args[5], temp);
}
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

package com.creditease.agent.feature.logagent;

import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -375,6 +376,9 @@ public List<Map> doProcess(List<Event> events, boolean backoffWithoutNL) throws

public void pubLogFilterAndRule(String id, LogFilterAndRule lfar) {

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

logcollection.put(id, lfar);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,32 +540,40 @@ private List<Map> wearClothes(String logid, List<Map> ilist) {
return result;
}

private void closeTailFiles() throws IOException, InterruptedException {
private void closeTailFiles() {

for (long inode : idleInodes) {
TailFile tf = reader.getTailFiles().get(inode);
if (tf.getRaf() != null) { // when file has not closed yet
if (TailLogContext.getInstance().getBoolean("MutiThread.enable")) {
@SuppressWarnings("rawtypes")
Map<TailFile, List<Map>> serverlogs = tailFileProcessSeprate(tf, true);
if (!(serverlogs.isEmpty())) {
this.sendLogDataBatch(serverlogs);
try {
for (long inode : idleInodes) {
TailFile tf = reader.getTailFiles().get(inode);
if (tf.getRaf() != null) { // when file has not closed yet
if (TailLogContext.getInstance().getBoolean("MutiThread.enable")) {
@SuppressWarnings("rawtypes")
Map<TailFile, List<Map>> serverlogs = tailFileProcessSeprate(tf, true);
if (!(serverlogs.isEmpty())) {
this.sendLogDataBatch(serverlogs);
}
else {
if (log.isDebugEnable()) {
log.debug(this, "serverlogs is emptry!!!");
}
}
}
else {
if (log.isDebugEnable()) {
log.debug(this, "serverlogs is emptry!!!");
}
tailFileProcess(tf, true);
}
}
else {
tailFileProcess(tf, true);
}

tf.close();
log.info(this, "Closed file: " + tf.getPath() + ", inode: " + inode + ", pos: " + tf.getPos());
tf.close();
log.info(this, "Closed file: " + tf.getPath() + ", inode: " + inode + ", pos: " + tf.getPos());
}
}
}
idleInodes.clear();
catch (Throwable t) {
log.err(this, "Uncaught exception in IdleFileChecker thread", t);
}
finally {
idleInodes.clear();
}

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,9 @@ function APMTool(app) {
params.ipport = pNode.getElementsByTagName("td")[7].id;
params.appid = pNode.getElementsByTagName("td")[8].id;
var appurl = "http://"+params.ipport+"/"+params.appid+"/";
if(params.appid=="ROOT"){
appurl = "http://"+params.ipport+"/";
}
AjaxHelper.call({
url: '../../rs/godeye/profile/q/cache',
data: {"fkey":"appurl","fvalue":appurl},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,9 @@ function AppServiceStream(app) {
/**
* app client
*/
if (true==options["needClientAccess"]) {

//the needClientNode is undefine when appurl and cpt.services's ip is different(case container)
if (true==options["needClientAccess"]&&needClientNode!=undefined) {
this.onAppClientUpdate(needClientNode,appInst,options["fromWhere"]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1909,7 +1909,19 @@ var mvcObj={
var free="<span class='kvSubValue'>"+CommonHelper.getKB2Human(disk[path]["free"],true)+"</span>";
var use="<span class='kvSubValue'>"+CommonHelper.getKB2Human(disk[path]["use"],true)+"</span>";
var useRate="<span class='kvSubValue'>"+disk[path]["useRate"]+"</span>";
sb.append("<div class='kvField'>"+"<span class='kvSubField' style='display:inline-block;width:130px;'>"+path+"</span>"+":&nbsp;使用率"+useRate+",&nbsp;使用量"+use+",&nbsp;剩余量"+free+",&nbsp;总量"+total+"</div>");

if(disk[path]["totalInode"]!=undefined){
//linux
var totalInode="<span class='kvSubValue'>"+disk[path]["totalInode"]+"</span>";
var useInode="<span class='kvSubValue'>"+disk[path]["useInode"]+"</span>";
var freeInode="<span class='kvSubValue'>"+disk[path]["freeInode"]+"</span>";
var useRateInode="<span class='kvSubValue'>"+disk[path]["useRateInode"]+"</span>";
sb.append("<div class='kvField'>"+"<span class='kvSubField' style='display:inline-block;width:130px;'>"+path+"</span>"+":&nbsp;使用率"+useRate+",&nbsp;使用量"+use+",&nbsp;剩余量"+free+",&nbsp;总量"+total+";&nbsp;&nbsp;&nbsp;inode使用率"+useRateInode+",&nbsp;inode使用量"+useInode+",&nbsp;inode剩余量"+freeInode+",&nbsp;inode总量"+totalInode+"</div>");
}
else{
//windows
sb.append("<div class='kvField'>"+"<span class='kvSubField' style='display:inline-block;width:130px;'>"+path+"</span>"+":&nbsp;使用率"+useRate+",&nbsp;使用量"+use+",&nbsp;剩余量"+free+",&nbsp;总量"+total+"</div>");
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public String getDeadProcsInfoAsString() {
private static final String CRASH_PROCS_DETAIL = "rtnotify.dead.procs.detail";
private static final long LOCK_TIMEOUT = 30 * 1000;
private static final long DEFAULT_CRASH_TIMEOUT = 5 * 60 * 1000;
private static final long MIN_RANDOM_port = 32768;
private static final long MIN_RANDOM_PORT = 32768;

private CacheManager cm;
private CacheLock lock;
Expand Down Expand Up @@ -325,7 +325,6 @@ private void judgeProcCrash() {
String[] procKeyArray = procKey.split("_", -1);
String ip = procKeyArray[0];
String name = procKeyArray[1];
List<String> ports = new ArrayList<String>(Arrays.asList(procKeyArray[2].split(":")));

if (procKeyArray[2].equals("")) {
// 不存在固定端口的进程
Expand All @@ -336,6 +335,8 @@ private void judgeProcCrash() {
continue;
}

List<String> ports = new ArrayList<String>(Arrays.asList(procKeyArray[2].split("#")));

boolean hasNewProc = false;
// 存在固定端口的进程,判断是否有ip、name相同但固定端口不完全相同的进程
for (Entry<String, String> enBak : allProcs.entrySet()) {
Expand Down Expand Up @@ -591,10 +592,17 @@ private String genProcHashKey(String ip, Map<String, Object> m) {
StringBuilder psb = new StringBuilder();
@SuppressWarnings("unchecked")
List<String> ports = (List<String>) m.get("ports");
// 对端口排序,保证端口不变时key相同
Collections.sort(ports);
for (String port : ports) {
if (Integer.parseInt(port) < MIN_RANDOM_port) {// 过滤随机端口
psb.append(port).append(":");
String portKey = port;
// 考虑Container拼接的端口为ip:port的形式
if (port.contains(":")) {
port = port.split(":", -1)[1];
}

if (Integer.parseInt(port) < MIN_RANDOM_PORT) {// 过滤随机端口
psb.append(portKey).append("#");
}
}

Expand Down Expand Up @@ -635,7 +643,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)) {
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 @@ -101,7 +101,7 @@ public void afterDoCap(InvokeChainContext context, Object[] args) {
*/
private String parseParams(Object[] args) {

if (args == null) {
if (args == null || args.length == 0) {
return "";
}
StringBuilder stringBuilder = new StringBuilder();
Expand Down
2 changes: 2 additions & 0 deletions com.creditease.uav.hook.httpclients/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<classifier>async</classifier>
<includes>
<include>**/com/creditease/uav/hook/httpclients/async/**</include>
<include>**/com/creditease/uav/hook/httpclients/AbstractHttpClientAdapter*</include>
</includes>
</configuration>
</execution>
Expand All @@ -64,6 +65,7 @@
<classifier>sync</classifier>
<includes>
<include>**/com/creditease/uav/hook/httpclients/sync/**</include>
<include>**/com/creditease/uav/hook/httpclients/AbstractHttpClientAdapter*</include>
</includes>
</configuration>
</execution>
Expand Down
Loading

0 comments on commit 182c513

Please sign in to comment.