Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var memoryMax = datas["os.cpu.maxmem"];
var memoryFreeme = datas["os.cpu.freemem"];
var memoryUsed=(memoryMax - memoryFreeme);
var memoryPro = Math.ceil((memoryUsed/ memoryMax) * 100);
//connections
var curconn=datas["os.conn.cur"];
//process total mem
var procMemSum=0;
//process total flux
var inFluxSum=0;
var outFluxSum=0;
// sum real connections from proc's conn
if(datas['node.procs']){
var procs = JSON.parse(datas['node.procs']);
var procConnSum = 0;
for (var k in procs){
if(procs[k].tags.conn){
procConnSum += parseInt(procs[k].tags.conn);
}
if(procs[k].tags.mem){
procMemSum+=parseInt(procs[k].tags.mem)*1024;
}
if(procs[k].tags["in"]){
inFluxSum+=parseFloat(procs[k].tags["in"]);
}
if(procs[k].tags.out){
function getProcInstid(appurl,ip) {
var isJse = appurl.indexOf("http:") == -1?true:false;
var port,pid,pname,infoinfo,jsepid,result;
var result;
for ( var key in nodeData) {
var dataObj = eval("("+nodeData[key]+")");
var infoValue = dataObj["info"];
var ipValue = dataObj["ip"];
if(ip!=ipValue) {
continue;
}
infoinfo = infoValue;
var procs=eval("("+infoinfo["node.procs"]+")");
if(procs==undefined) {
continue;
}
else{
break;
}
}
if (isJse) {
var jseInfo=appurl.split("-");
jsepid=jseInfo[jseInfo.length-1];
for(var key in procs) {
if(jsepid==key) {
pid=key;
pname=procs[key]["name"];
runWindowDelay:function(tag) {
if (window["openlink_"+tag]==undefined) {
return;
}
var info=window["openlink_"+tag];
window["openlink_"+tag]=undefined;
if (tag=="procinfo") {
var pid=info["pid"];
//need find pid by port
if (pid==undefined) {
var macInfo=app.mdata("macinfo")[info["ip"]];
var procs=eval("("+macInfo["node.procs"]+")");
for(var key in procs) {
var proc=procs[key];
var ports=proc["ports"];
for(var i=0;i
runProcessChart: function(ip,pid,forceUpdate,needCache) {
var datas = app.mdata().macinfo[ip];
var procs=eval("("+datas["node.procs"]+")");
var clientTimestamp=datas["clientTimestamp"];
var proc=procs[pid];
if (true!=forceUpdate) {
//only update when there is an update data
if (this.lastClientTimestamp>-1) {
if (clientTimestamp<=this.lastClientTimestamp) {
return;
}
}
}
this.lastClientTimestamp=clientTimestamp;
var procInfo = proc["tags"];
//cpu
var cpuRate=procInfo["cpu"];
buildProcessChartContent : function(resultObj,pid){
var procs=eval("("+resultObj["node.procs"]+")");
var proc=procs[pid];
if (proc==undefined) {
alert("进程号["+pid+"]的进程在["+resultObj["ip"]+"]不存在!")
return;
}
var ports=proc["ports"];
var connSeries=[
{
name:"进程连接数",
color:"#EEEE00",
data:[]
}
];
var fluxSeries=[
updateNodeBox : function(jsonObj){
if(HtmlHelper.id(jsonObj.id)==undefined){
this.addNodeBox(jsonObj);
return;
};
var procState = '';
if(jsonObj['node.pid']){
var procs;
if(jsonObj['node.procs']){
procs = eval("("+jsonObj['node.procs']+")");
}else{
var macinfo=app.mdata("macinfo");
var node=macinfo[jsonObj["ip"]];
var procsStr='{}';
if(node){
procsStr=node["node.procs"];
}
if (procsStr) {
procs = eval("("+procsStr+")");
}
}
if (procs) {
procState = this.buildProcStateHtm(procs[jsonObj['node.pid']]);
}
}
" <span class="\"kvField\"">Http服务</span><span>:</span>"+this.formatter.services(jsonObj["node.services"]) +
" " +
" <div class="\"kv\"">" +
" <span class="\"kvField\"">所属心跳地址</span><span>:</span>"+jsonObj["node.hbserver"] +
" </div>" +
" <div class="\"kv\"">" +
" <span class="\"kvField\"">路径</span><span>:</span>"+jsonObj["node.root"] +
" </div>" +
" <div class="\"kv\"">" +
" <span class="\"kvField\"">版本</span><span>:</span>"+jsonObj["node.version"] +
" </div>" +
" <div class="\"kv\"">" +
" <span class="\"kvField\"">端口</span><span>:</span>";
var macinfo=app.mdata("macinfo");
var procs=eval("("+macinfo[jsonObj["ip"]]["node.procs"]+")");
var pid=jsonObj["node.pid"];
for (var key in procs) {
if (pid==key) {
str+=procs[key]["ports"];
break;
}
}
str+="</div>";
/**
* build control panel
*/
str+="<div class="\"kv\"">"+this.buildNodeCtrlPanel(jsonObj)+"</div>";
return str;
update:function(oldObj,newObj) {
var np=newObj["node.procs"];
var op=oldObj["node.procs"];
var ot=oldObj["clientTimestamp"];
var nt=newObj["clientTimestamp"];
if (this.timestamp==0) {
this.timestamp=ot;
}
if(op==undefined) {
this.timestamp=nt;
return np;
}
if (nt-ot>0&&np!=undefined) {
this.timestamp=nt;
return np;
}
update:function(oldObj,newObj) {
var np=newObj["node.procs"];
var op=oldObj["node.procs"];
var ot=oldObj["clientTimestamp"];
var nt=newObj["clientTimestamp"];
if (this.timestamp==0) {
this.timestamp=ot;
}
if(op==undefined) {
this.timestamp=nt;
return np;
}
if (nt-ot>0&&np!=undefined) {
this.timestamp=nt;
return np;
//node info
var nodes=app.mdata("nodeinfo");
//the monitoragent node info
var maNodeInfo;
for (var nodeKey in nodes) {
var nodeObj=nodes[nodeKey];
if (nodeObj["ip"]==ip) {
divContent+=this.buildMacDetailNodeInfo(nodeObj);
if (nodeObj["node.profile"].indexOf("ma")==0||nodeObj["name"]=="监控代理程序") {
maNodeInfo=nodeObj;
}
}
}
//process info
var procs=eval("("+dObj["node.procs"]+")");
var handler=function(proc) {
//we should deliver the maNodeInfo to the process info panel as we need ctrl the process via MonitorAgent
divContent+=app.controller.buildMacProcessInfo(proc,maNodeInfo);
};
this.handleProcess(procs,handler);
divContent+=this.buildMacDetailEndContent();
return divContent;
},
//Ultron container only