libf 2 years ago
parent
commit
99c2817465
100 changed files with 10003 additions and 1 deletions
  1. 4 1
      .gitignore
  2. 125 0
      serverjs/script/cncc/API/drsp/perf.js
  3. 1 0
      serverjs/script/cncc/API/drsp/test_perf.js
  4. 36 0
      serverjs/script/cncc/API/sample1.js
  5. 15 0
      serverjs/script/cncc/API/sample2.js
  6. 1 0
      serverjs/script/cncc/API/分区CPU.js
  7. 1 0
      serverjs/script/cncc/API/小型机.js
  8. 1 0
      serverjs/script/cncc/CMDB/edges/rack_to_room.js
  9. 1 0
      serverjs/script/cncc/CMDB/edges/trace.log
  10. 1 0
      serverjs/script/cncc/CMDB/test/test_login.js
  11. 48 0
      serverjs/script/cncc/CMDB/x86.js
  12. 36 0
      serverjs/script/cncc/CMDB/业务.js
  13. 50 0
      serverjs/script/cncc/CMDB/分区.js
  14. 42 0
      serverjs/script/cncc/CMDB/小型机.js
  15. 36 0
      serverjs/script/cncc/CMDB/应用.js
  16. 10 0
      serverjs/script/cncc/CMDB/应用类别.js
  17. 27 0
      serverjs/script/cncc/CMDB/数据中心.js
  18. 27 0
      serverjs/script/cncc/CMDB/机房.js
  19. 45 0
      serverjs/script/cncc/CMDB/机柜.js
  20. 29 0
      serverjs/script/cncc/DIEP/test.js
  21. 23 0
      serverjs/script/cncc/DIEP/test_csv.js
  22. 593 0
      serverjs/script/cncc/DIEP/报告参数_POSTMAN.js
  23. 45 0
      serverjs/script/cncc/DIEP/报告参数_文本.js
  24. 309 0
      serverjs/script/cncc/DIEP/接入报告.js
  25. 190 0
      serverjs/script/cncc/ITIL/事件单.js
  26. 444 0
      serverjs/script/cncc/ITIL/变更单.js
  27. 296 0
      serverjs/script/cncc/ITIL/应急演练.js
  28. 118 0
      serverjs/script/cncc/ITIL/报备.js
  29. 294 0
      serverjs/script/cncc/ITIL/数据获取.js
  30. 229 0
      serverjs/script/cncc/ITIL/设备上下电.js
  31. 265 0
      serverjs/script/cncc/ITIL/问题单.js
  32. 133 0
      serverjs/script/cncc/ITIL/项目实施或巡检.js
  33. 457 0
      serverjs/script/cncc/Tivoli/omnibus/columns.js
  34. 1592 0
      serverjs/script/cncc/应用/meta-alarmwall/template/menu.js
  35. 36 0
      serverjs/script/cncc/应用/meta-capacitya/performanceByHost.js
  36. 36 0
      serverjs/script/cncc/应用/meta-capacitya/performanceByVm.js
  37. 228 0
      serverjs/script/cncc/应用/meta-capacitya/summary.js
  38. 299 0
      serverjs/script/cncc/应用/meta-capacitya/summaryByDc.js
  39. 59 0
      serverjs/script/cncc/应用/meta-capacitya/template/apps.js
  40. 49 0
      serverjs/script/cncc/应用/meta-capacitya/template/menus.js
  41. 2 0
      serverjs/script/cncc/应用/meta-capacitya/test.js
  42. 114 0
      serverjs/script/cncc/应用/meta-capacitya/vmListByHost.js
  43. 0 0
      serverjs/script/cncc/应用/meta-event/attachment/8500809039221148163/基线告警 (2).docx
  44. 0 0
      serverjs/script/cncc/应用/meta-event/attachment/8500809039221148163/运维文档 (4)
  45. 884 0
      serverjs/script/cncc/应用/meta-event/attachment/app:demoapp3/z000000000006EJ48jwebtQR/gui-config.json
  46. BIN
      serverjs/script/cncc/应用/meta-event/attachment/biz:开发测试/z000000000005N7R3YeeSISU/rule (1).png
  47. BIN
      serverjs/script/cncc/应用/meta-event/attachment/biz:开发测试/z000000000005N7R3YeeSISU/rule (2).png
  48. BIN
      serverjs/script/cncc/应用/meta-event/attachment/biz:开发测试/z000000000005N7R3YeeSISU/rule (3).png
  49. 184 0
      serverjs/script/cncc/应用/meta-event/attachment/biz:数字国网/z0000000000050znkhAEhdgY1mIFEJNw5utmO/ai-message.vue
  50. BIN
      serverjs/script/cncc/应用/meta-event/attachment/linux:172.26.38.248/17368221814077026651/Export_2021-06-19 17_29_52.xlsx
  51. BIN
      serverjs/script/cncc/应用/meta-event/attachment/linux:node3/alert:10.216.202.66-cpuutilization-5/rule.png
  52. 0 0
      serverjs/script/cncc/应用/meta-event/attachment/pod:tomcat-pod3/alert:100.83.165.231_pot-down_5/基线告警 (2).docx
  53. 38 0
      serverjs/script/cncc/应用/meta-event/attachment/pod:tomcat-pod3/z0000000000060znkhAEhdgY1mHVcfDjVnMLE/eif.20210602.log
  54. BIN
      serverjs/script/cncc/应用/meta-event/attachment/pod:web-demo-j6qxj/z0000000000060znkhAEhdgY1mFhr1U6hW2f3/展示系统接口说明_20180926.docx
  55. 5 0
      serverjs/script/cncc/应用/meta-event/attachment/pod:web-demo-j6qxj/z0000000000060znkhAEhdgY1mTXRj2goMqcu/ETCD_eventbus_2021_3_24下午3_07_02.json
  56. BIN
      serverjs/script/cncc/应用/meta-event/attachment/pod:web-demo-j6qxj/z0000000000060znkhAEhdgY1mTXRj2goMqcu/pexels-juan-733475 (4).jpg
  57. BIN
      serverjs/script/cncc/应用/meta-event/attachment/pod:web-demo-j6qxj/z0000000000060znkhAEhdgY1mTXRj2goMqcu/pexels-juan-733475.jpg
  58. 49 0
      serverjs/script/cncc/应用/meta-event/contextmenu/action.js
  59. 147 0
      serverjs/script/cncc/应用/meta-event/contextmenu/context-menu.json
  60. 13 0
      serverjs/script/cncc/应用/meta-event/contextmenu/getContextMenu.js
  61. 145 0
      serverjs/script/cncc/应用/meta-event/diagnosis/attributeRel.js
  62. 12 0
      serverjs/script/cncc/应用/meta-event/diagnosis/bitlog/getBitlogList.js
  63. 38 0
      serverjs/script/cncc/应用/meta-event/diagnosis/bitlog/getBucketByEntity.js
  64. 28 0
      serverjs/script/cncc/应用/meta-event/diagnosis/bitlog/searchBitlogByTerm.js
  65. 19 0
      serverjs/script/cncc/应用/meta-event/diagnosis/bitlog/searchEntityByClass.js
  66. 137 0
      serverjs/script/cncc/应用/meta-event/diagnosis/eventListBySmartGroup.js
  67. 12 0
      serverjs/script/cncc/应用/meta-event/diagnosis/getBitlogList.js
  68. 148 0
      serverjs/script/cncc/应用/meta-event/diagnosis/history.js
  69. 16 0
      serverjs/script/cncc/应用/meta-event/diagnosis/journal.js
  70. 27 0
      serverjs/script/cncc/应用/meta-event/diagnosis/searchBitlogByTerm.js
  71. 19 0
      serverjs/script/cncc/应用/meta-event/diagnosis/searchEntityByClass.js
  72. 89 0
      serverjs/script/cncc/应用/meta-event/diagnosis/smartGroup.js
  73. 4 0
      serverjs/script/cncc/应用/meta-event/diagnosis/test.js
  74. 39 0
      serverjs/script/cncc/应用/meta-event/diagnosis/tsdb/getBucketByEntity.js
  75. 11 0
      serverjs/script/cncc/应用/meta-event/diagnosis/tsdb/getClassNameById.js
  76. 65 0
      serverjs/script/cncc/应用/meta-event/diagnosis/tsdb/getClassNumberStringKeysByClassName.js
  77. 12 0
      serverjs/script/cncc/应用/meta-event/diagnosis/tsdb/getTsdbList.js
  78. 19 0
      serverjs/script/cncc/应用/meta-event/diagnosis/tsdb/searchEntityByClass.js
  79. 42 0
      serverjs/script/cncc/应用/meta-event/diagnosis/tsdb/searchPerformanceByTerm.js
  80. 303 0
      serverjs/script/cncc/应用/meta-event/event_list.js
  81. 3 0
      serverjs/script/cncc/应用/meta-event/graph/config.json
  82. 5 0
      serverjs/script/cncc/应用/meta-event/graph/edges.js
  83. 147 0
      serverjs/script/cncc/应用/meta-event/graph/graphService.js
  84. 26 0
      serverjs/script/cncc/应用/meta-event/graph/graph_imap_data.js
  85. 15 0
      serverjs/script/cncc/应用/meta-event/job/deleteEvent.js
  86. 88 0
      serverjs/script/cncc/应用/meta-event/job/job_list.js
  87. 14 0
      serverjs/script/cncc/应用/meta-event/message/getMessage.js
  88. 3 0
      serverjs/script/cncc/应用/meta-event/notify/config.json
  89. 80 0
      serverjs/script/cncc/应用/meta-event/notify/getLogList.js
  90. 135 0
      serverjs/script/cncc/应用/meta-event/notify/getRuleList.js
  91. 80 0
      serverjs/script/cncc/应用/meta-event/notify/getTemplateList.js
  92. 54 0
      serverjs/script/cncc/应用/meta-event/notify/getVoiceList.js
  93. 153 0
      serverjs/script/cncc/应用/meta-event/notify/logAction.js
  94. 50 0
      serverjs/script/cncc/应用/meta-event/notify/ruleAction.js
  95. 77 0
      serverjs/script/cncc/应用/meta-event/notify/server/server.json
  96. 98 0
      serverjs/script/cncc/应用/meta-event/notify/setup.js
  97. 94 0
      serverjs/script/cncc/应用/meta-event/notify/situationAction.js
  98. 12 0
      serverjs/script/cncc/应用/meta-event/notify/template/网络告警模版.json
  99. 17 0
      serverjs/script/cncc/应用/meta-event/notify/template/网络告警通知.json
  100. 0 0
      serverjs/script/cncc/应用/meta-event/notify/template/邮件发送模版.json

+ 4 - 1
.gitignore

@@ -32,4 +32,7 @@ __pycache__
 *.class
 *.tmp
 *.zip
-*.txt
+*.txt
+
+*/.DS_Store
+*/*/.DS_Store

+ 125 - 0
serverjs/script/cncc/API/drsp/perf.js

@@ -0,0 +1,125 @@
+
+// 输入输出参数格式化
+input = INPUT;
+output = {};
+try {
+    input = decodeURIComponent(input);
+} catch (e) { }
+try {
+    input = base64.decode(input);
+} catch (e) { }
+try {
+    input = JSON.parse(input);
+    input = JSON.parse(input); // 解析可能存在的重复编码
+} catch (e) { }
+
+// 环境配置参数,配置定义在 etcd:/matrix/data/api/cfg.json
+cfg = {};
+try {
+    cfg = JSON.parse(etcd.get("/api/cfg.json"));
+} catch (e) { }
+
+// 函数定义
+// 从 ODB 获取数据
+function getData(type, tms, tme) {
+    var data = [];
+    // TODO:从 ODB 获取数据
+    if (cfg.env == "test") {
+        // 测试生成假数据
+        for (var t = tms; t <= tme; t += 60 * 1000) {
+            data.push({
+                type: type,
+                time: new Date(t),
+                RV: parseInt(Math.random() * 500 + 1000), // 交易量 
+                RS: Math.random() * 5 + 95,               // 系统成功率 
+                RD: parseInt(Math.random() * 500 + 100),  // 平均响应时间 
+                RR: Math.random() * 5 + 95,               // 交易响应率 
+                FV: parseInt(Math.random() * 10),         // 失败笔数 
+            });
+        }
+    }
+    return data;
+}
+
+// 格式化数据
+function formatData(data) {
+    if (data.length == 0) {
+        // 无数据返回 {}
+        return {};
+    }
+    for (var i = 0; i < data.length; i++) {
+        data[i].time = data[i].time.toJSON().replace(/[TZ]/mg, " ").substring(0, 16); // 时间格式:yyyy-MM-dd HH:mm
+        data[i].RV = "" + parseInt(data[i].RV);             // 交易量,1分钟统计周期内,总交易笔数
+        data[i].RS = "" + parseInt(data[i].RS * 100) / 100; // 系统成功率,四舍五入保留2位小数,系统成功率<=100
+        data[i].RD = "" + parseInt(data[i].RD);             // 平均响应时间,单位ms,四舍五入取整数
+        data[i].RR = "" + parseInt(data[i].RR * 100) / 100; // 交易响应率,四舍五入保留2位小数,交易响应率<=100
+        data[i].FV = "" + parseInt(data[i].FV);             // 失败笔数,1分钟统计周期内,失败交易笔数
+    }
+    if (data.length == 1) {
+        // 单条数据直接返回对象
+        data = data[0];
+    }
+    return data
+}
+
+// 解析时间字符串 格式为 yyyyMMddHHmm
+function parseTime(ymdhm) {
+    try {
+        if (!/^\d{12}$/.test(ymdhm)) {
+            throw ("format error");
+        }
+        var d = new Date(
+            parseInt(ymdhm.substring(0, 4)),
+            parseInt(ymdhm.substring(4, 6)) - 1,
+            parseInt(ymdhm.substring(6, 8)),
+            parseInt(ymdhm.substring(8, 10)),
+            parseInt(ymdhm.substring(10, 12))
+        );
+        d.setMinutes(d.getMinutes() - d.getTimezoneOffset());
+        return d;
+    } catch (e) {
+        throw ("时间格式错误,正确格式是 yyyyMMddHHmm");
+    }
+}
+
+// 主执行阶段
+try {
+    // 参数检查
+    var type = input.type;
+    if (!type) {
+        throw ("必须指定参数 type,如:HVPS,BEPS,IBPS,FXPS");
+    }
+    var starttime = input.time;
+    if (!starttime) {
+        throw ("必须指定参数 time,格式为 yyyyMMddHHmm");
+    }
+    var endtime = input.endtime; // 可选参数,指定结束时间,可以获取一段时间的数据
+    if (!endtime) {
+        endtime = input.time;
+    }
+    // 参数解析
+    var tms = parseTime("" + starttime).getTime();
+    var tme = parseTime("" + endtime).getTime();
+    // 数据获取
+    var data = getData(type, tms, tme);
+    // 数据格式化
+    data = formatData(data);
+    // 数据输出
+    output.data = data;
+} catch (e) {
+    // 错误信息输出处理,抛出 ok 表示正常结束    
+    if (e != "ok") {
+        if (typeof (e) == "object") {
+            output.error = e;
+        } else if (typeof (e) == "string") {
+            output.error = "错误:" + e;
+        } else {
+            output.error = JSON.stringify(e);
+        }
+        log.error(output.error);
+        STATUS = "error";
+    }
+}
+
+// 返回输出信息
+OUTPUT = output;

+ 1 - 0
serverjs/script/cncc/API/drsp/test_perf.js

@@ -0,0 +1 @@
+null

+ 36 - 0
serverjs/script/cncc/API/sample1.js

@@ -0,0 +1,36 @@
+// 输入输出参数格式化
+input = INPUT;
+output = {};
+try {
+    input = decodeURIComponent(input);
+} catch (e) { }
+try {
+    input = base64.decode(input);
+} catch (e) { }
+try {
+    input = JSON.parse(input);
+    input = JSON.parse(input); // 解析可能存在的重复编码
+} catch (e) { }
+// 主执行阶段
+try {
+    // 示例处理过程,返回输入信息
+    output.sampledata = {
+        input: input,
+    };
+} catch (e) {
+    // 错误信息输出处理,抛出 ok 表示正常结束    
+    if (e != "ok") {
+        if (typeof (e) == "object") {
+            output.error = e;
+        } else if (typeof (e) == "string") {
+            output.error = "错误:" + e;
+        } else {
+            output.error = JSON.stringify(e);
+        }
+        log.error(output.error);
+        STATUS = "error";
+    }
+}
+// 返回输出信息
+OUTPUT = output;
+

+ 15 - 0
serverjs/script/cncc/API/sample2.js

@@ -0,0 +1,15 @@
+
+eval(dfs.read('/script/matrix/wframe/init.js'));
+
+function main(input) {
+    try {
+        x = "test3";
+        function a(){ return x; }
+        return {
+            input: input,
+            info: a(),
+        };
+    } catch(e) {
+        throw(e);
+    }
+}

+ 1 - 0
serverjs/script/cncc/API/分区CPU.js

@@ -0,0 +1 @@
+OUTPUT=odb.mql("select id,name,performance from /cncc/entity/os/linux limit 500");

+ 1 - 0
serverjs/script/cncc/API/小型机.js

@@ -0,0 +1 @@
+OUTPUT= odb.mql("select id,name,manageip,rack,cpu,cpufree,cpuused,memall,memfree,memunused,memused from power").data

+ 1 - 0
serverjs/script/cncc/CMDB/edges/rack_to_room.js

@@ -0,0 +1 @@
+dfs.write("/script/cncc/CMDB/edges/trace.log",_.now()+"")

+ 1 - 0
serverjs/script/cncc/CMDB/edges/trace.log

@@ -0,0 +1 @@
+1663520403771

+ 1 - 0
serverjs/script/cncc/CMDB/test/test_login.js

@@ -0,0 +1 @@
+null

+ 48 - 0
serverjs/script/cncc/CMDB/x86.js

@@ -0,0 +1,48 @@
+// 日志输出
+var trace = function(name, value, ext){
+  try{
+      dfs.write("/script/cncc/CMDB/trace/" + name + "." + ext, value);
+  }  catch(err){
+      log.error(err);
+  }
+};
+
+// do: Http request
+// params: method<string>, url<string>, header<object>, body<string>, successfunc<function>, errfunc<function>
+// return: none
+http.do("POST", "http://17.194.0.81/cmdb/dataSet/execute", {"Content-Type":"application/json"}, '{"password": "bW9uaXRvcipZd3h0YkA2Ng==","pageSize": 1000,"ciClass": "x86主机","type": 2,"pageNum": 1,"username": "monitor"}', function(message){
+    // success func
+    OUTPUT = message.data;
+    var traceArr = [];
+    _.forEach(message.data.data.data,function(v){
+       
+        var comp = _.template("insert into /cncc/entity/x86 (id,name,autofindtime,cpu,cpufreq,cpukernel,cpumodel,datasource,disk,hostid,hytype,manageip,memory,smvid,storage) values ('<%=id %>','<%=name %>','<%=autofindtime %>',<%=cpu %>,<%=cpufreq %>,'<%=cpukernel %>','<%=cpumodel %>','<%=datasource %>',<%=disk %>,<%=hostid %>,'<%=hytype %>','<%=manageip %>',<%=memory %>,'<%=smvid %>',<%=storage %>)");
+        var attrs = v.attrs;
+        
+        var mql = comp({
+            id: "x86:"+attrs['主机名称'],
+            name:attrs['主机名称'],
+            datasource:attrs['数据来源'],
+        	autofindtime:attrs['自动发现更新时间'],
+        	cpu:  attrs['CPU个数']?attrs['CPU个数']:0,
+        	cpufreq: attrs['CPU频率']?attrs['CPU频率']:0,
+        	cpukernel:  attrs['CPU核数']?attrs['CPU核数']:0,
+        	cpumodel: attrs['CPU型号'],
+        	datasource:attrs['来源平台'],
+        	disk: attrs['磁盘大小']?attrs['磁盘大小']:0,
+        	hostid: attrs['主机ID']?attrs['主机ID']:0,
+        	hytype:attrs['服务器支持的HY类型'],
+        	manageip:attrs['管理IP'],
+        	memory: attrs['内存大小']?attrs['内存大小']:0,
+        	smvid:attrs['SMVID'],
+        	storage: attrs['存储容量']?attrs['存储容量']:0
+        })
+        traceArr.push(mql);
+        odb.mql(mql);
+    });
+    
+    trace("x86主机",traceArr.join(";\n"),"txt");
+}, function(message){
+    // error func
+    log.info(message.data);
+})

+ 36 - 0
serverjs/script/cncc/CMDB/业务.js

@@ -0,0 +1,36 @@
+// do: Http request
+// params: method<string>, url<string>, header<object>, body<string>, successfunc<function>, errfunc<function>
+// return: none
+http.do("POST", "http://17.194.0.81/cmdb/dataSet/execute", {"Content-Type":"application/json"}, '{"password": "bW9uaXRvcipZd3h0YkA2Ng==","pageSize": 1000,"ciClass": "应用系统","type": 2,"pageNum": 1,"username": "monitor"}', function(message){
+    // success func
+   OUTPUT = message.data;
+    _.forEach(message.data.data.data,function(v){
+       
+        var comp = _.template("insert into /cncc/entity/biz (id,name,bizstatus, catalog, company, datasource, department, detail, number, org, smvid, title) values ('<%=id %>','<%=name %>','<%=bizstatus %>','<%=catalog %>','<%=company %>','<%=datasource %>','<%=department %>','<%=detail %>',<%=number %>,'<%=org %>','<%=smvid %>','<%=title %>')");
+        var attrs = v.attrs;
+       
+        //业务定义
+        if(attrs['组织机构'] !== '支付系统' || attrs['应用系统类别'] !== '交易类') return;
+         
+        var mql = comp({
+            id: "biz:"+attrs['软件名称'],
+            name:attrs['软件名称'],
+            bizstatus:attrs['STATUS'],
+        	catalog:attrs['应用系统类别'],
+        	company:  attrs['承建单位'],
+        	datasource: attrs['CPU频率'],
+        	department:  attrs['所属部门'],
+        	detail: attrs['应用简介'],
+        	datasource:attrs['数据来源'],
+        	number: attrs['显示顺序'],
+        	org: attrs['组织机构'],
+        	smvid:attrs['SMVID'],
+        	title:attrs['应用系统名称']
+        })
+        log.info(mql)
+        odb.mql(mql);
+    });
+}, function(message){
+    // error func
+    log.info(message.data);
+})

File diff suppressed because it is too large
+ 50 - 0
serverjs/script/cncc/CMDB/分区.js


File diff suppressed because it is too large
+ 42 - 0
serverjs/script/cncc/CMDB/小型机.js


+ 36 - 0
serverjs/script/cncc/CMDB/应用.js

@@ -0,0 +1,36 @@
+// do: Http request
+// params: method<string>, url<string>, header<object>, body<string>, successfunc<function>, errfunc<function>
+// return: none
+http.do("POST", "http://17.194.0.81/cmdb/dataSet/execute", {"Content-Type":"application/json"}, '{"password": "bW9uaXRvcipZd3h0YkA2Ng==","pageSize": 2000,"ciClass": "应用系统","type": 2,"pageNum": 1,"username": "monitor"}', function(message){
+    // success func
+   OUTPUT = message.data;
+   _.forEach(message.data.data.data,function(v){
+       
+        var comp = _.template("insert into /cncc/entity/app (id,name,appstatus, catalog, company, datasource, department, detail, number, org, smvid, title) values ('<%=id %>','<%=name %>','<%=appstatus %>','<%=catalog %>','<%=company %>','<%=datasource %>','<%=department %>','<%=detail %>',<%=number %>,'<%=org %>','<%=smvid %>','<%=title %>')");
+        var attrs = v.attrs;
+       
+        //应用定义
+        if(attrs['组织机构'] === '支付系统' || attrs['应用系统类别'] === '交易类') return;
+         
+        var mql = comp({
+            id: "app:"+attrs['软件名称'],
+            name:attrs['软件名称'],
+            appstatus:attrs['STATUS'],
+        	catalog:attrs['应用系统类别'],
+        	company:  attrs['承建单位'],
+        	datasource: attrs['CPU频率'],
+        	department:  attrs['所属部门'],
+        	detail: attrs['应用简介'],
+        	datasource:attrs['数据来源'],
+        	number: attrs['显示顺序'],
+        	org: attrs['组织机构'],
+        	smvid:attrs['SMVID'],
+        	title:attrs['应用系统名称']
+        })
+        log.info(mql)
+        odb.mql(mql);
+    });
+}, function(message){
+    // error func
+    log.info(message.data);
+})

+ 10 - 0
serverjs/script/cncc/CMDB/应用类别.js

@@ -0,0 +1,10 @@
+// do: Http request
+// params: method<string>, url<string>, header<object>, body<string>, successfunc<function>, errfunc<function>
+// return: none
+http.do("POST", "http://17.194.0.81/cmdb/dataSet/execute", {"Content-Type":"application/json"}, '{"password": "bW9uaXRvcipZd3h0YkA2Ng==","pageSize": 1000,"ciClass": "应用系统类别","type": 2,"pageNum": 1,"username": "monitor"}', function(message){
+    // success func
+   OUTPUT = message.data;
+}, function(message){
+    // error func
+    log.info(message.data);
+})

+ 27 - 0
serverjs/script/cncc/CMDB/数据中心.js

@@ -0,0 +1,27 @@
+// do: Http request
+// params: method<string>, url<string>, header<object>, body<string>, successfunc<function>, errfunc<function>
+// return: none
+
+http.do("POST", "http://17.194.0.81/cmdb/dataSet/execute", {"Content-Type":"application/json"}, '{"password": "bW9uaXRvcipZd3h0YkA2Ng==","pageSize": 1000,"ciClass": "数据中心","type": 2,"pageNum": 1,"username": "monitor"}', function(message){
+    // success func
+   
+  _.forEach(message.data.data.data,function(v){
+      log.info(v)
+    var comp = _.template("insert into /cncc/entity/datacenter (id,name,datasource,dcstatus,org,smvid) values ('<%=id %>','<%=name %>','<%=datasource %>','<%=dcstatus %>','<%=org %>','<%=smvid %>')");
+    var attrs = v.attrs;
+    
+    var mql = comp({
+        id: "dc:"+attrs['IDUNIQUE'],
+        name:attrs['名称'],
+        datasource:attrs['数据来源'],
+        dcstatus:attrs['STATUS'],
+        org:attrs['组织机构'],
+        smvid:attrs['IDUNIQUE']
+    })
+    // log.info(mql)
+    odb.mql(mql);
+  });
+}, function(message){
+    // error func
+    log.info(message.data);
+})

+ 27 - 0
serverjs/script/cncc/CMDB/机房.js

@@ -0,0 +1,27 @@
+// do: Http request
+// params: method<string>, url<string>, header<object>, body<string>, successfunc<function>, errfunc<function>
+// return: none
+http.do("POST", "http://17.194.0.81/cmdb/dataSet/execute", {"Content-Type":"application/json"}, '{"password": "bW9uaXRvcipZd3h0YkA2Ng==","pageSize": 1000,"ciClass": "机房","type": 2,"pageNum": 1,"username": "monitor"}', function(message){
+    // success func
+   OUTPUT = message.data.data.data;
+    _.forEach(message.data.data.data,function(v){
+    
+    var comp = _.template("INSERT INTO /cncc/entity/room (id,name,building, datacenter, floor,smvid,title)  values ('<%=id %>','<%=name %>','<%=building %>','<%=datacenter %>','<%=floor %>','<%=smvid %>','<%=title %>')");
+    var attrs = v.attrs;
+    
+    var mql = comp({
+        id: "room:"+attrs['机房编号'],
+        name:attrs['机房编号'],
+        building:attrs['楼栋'], 
+        datacenter:attrs['数据中心'], 
+        floor:attrs['楼层'], 
+        smvid:attrs['SMVID'], 
+        title:attrs['机房名称']
+    })
+     log.info(mql)
+    odb.mql(mql);
+ })
+}, function(message){
+    // error func
+    log.info(message.data);
+})

File diff suppressed because it is too large
+ 45 - 0
serverjs/script/cncc/CMDB/机柜.js


+ 29 - 0
serverjs/script/cncc/DIEP/test.js

@@ -0,0 +1,29 @@
+ var param = JSON.stringify({"apikey":"API_META_LARGE_MONTH_TYPICAL_SUMMIT_DAY","param":{"extparam":{"settdate":"20181017"}}});
+          
+var token = (function(){
+    var rtn = null;
+    var bodyContent = JSON.stringify({
+        "username":"meta",
+        "password":"meta"
+    });
+    http.do("POST", "http://111.1.12.155:9086/bdosservice/login", {"Authorization": "Basic cGJjczpwYmNz","Content-Type": "application/json"}, bodyContent, function(message){
+        // success func
+        //OUTPUT = message.data;
+        //log.debug(message.data.data)
+        rtn = message.data.data.token;
+    }, function(message){
+        // error func
+        log.error(message.data);
+    })
+    return rtn;
+})();
+ 
+ http.do("POST", "http://111.1.12.155:9086/bdosservice/query/list", {"X-Token": token,"Content-Type": "application/json"}, param, function(message){
+    // success func
+    OUTPUT =  message.data;
+    //dfs.write(file, message.data);
+}, function(message){
+    // error func
+    log.error(message.data);
+    return;
+},300)  

File diff suppressed because it is too large
+ 23 - 0
serverjs/script/cncc/DIEP/test_csv.js


+ 593 - 0
serverjs/script/cncc/DIEP/报告参数_POSTMAN.js

@@ -0,0 +1,593 @@
+var postman = {
+	"info": {
+		"_postman_id": "aa3caf6a-6204-4b70-84c0-6b98ae0b596f",
+		"name": "生产对外",
+		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
+	},
+	"item": [
+		{
+			"name": "网银热点账户统计",
+			"item": [
+				{
+					"name": "每日网银热点账户截图示例-网银分时",
+					"request": {
+						"method": "POST",
+						"header": [
+							{
+								"key": "Content-Type",
+								"name": "Content-Type",
+								"type": "text",
+								"value": "application/json"
+							},
+							{
+								"key": "X-Token",
+								"value": "tokens408c5b07-7026-42a5-9f94-8f449230ea01",
+								"type": "text"
+							}
+						],
+						"body": {
+							"mode": "raw",
+							"raw": "{\n\t\"apikey\":\"API_META_EBANK_TIME_SHARING\",\n\t\"param\":{\n\t\t\"extparam\":{\n\t\t\t\"recvdate\":\"20221021\",\n\t\t\t\"nodecode\":\"011523017044\"\n\t\t}\n\t}\n}"
+						},
+						"url": {
+							"raw": "111.1.12.155:9086/bdosservice/query/list",
+							"host": [
+								"111",
+								"1",
+								"12",
+								"155"
+							],
+							"port": "9086",
+							"path": [
+								"bdosservice",
+								"query",
+								"list"
+							]
+						}
+					},
+					"response": []
+				},
+				{
+					"name": "网银热点账户业务量示例",
+					"request": {
+						"method": "POST",
+						"header": [
+							{
+								"key": "Content-Type",
+								"name": "Content-Type",
+								"value": "application/json",
+								"type": "text"
+							},
+							{
+								"key": "X-Token",
+								"value": "tokens9896d396-6278-410f-b297-d1e8b32d238c",
+								"type": "text"
+							}
+						],
+						"body": {
+							"mode": "raw",
+							"raw": "{\n\t\"apikey\":\"API_META_EBANK_ACCOUNT\",\n\t\"param\":{\n\t\t\"extparam\":{\n\t\t\t\"netdate\":\"20160506\"\n\t\t}\n\t}\n}"
+						},
+						"url": {
+							"raw": "111.1.12.155:9086/bdosservice/query/list",
+							"host": [
+								"111",
+								"1",
+								"12",
+								"155"
+							],
+							"port": "9086",
+							"path": [
+								"bdosservice",
+								"query",
+								"list"
+							]
+						}
+					},
+					"response": []
+				},
+				{
+					"name": "每日网银热点账户截图示例-网银累计",
+					"request": {
+						"method": "POST",
+						"header": [
+							{
+								"key": "Content-Type",
+								"name": "Content-Type",
+								"type": "text",
+								"value": "application/json"
+							},
+							{
+								"key": "X-Token",
+								"value": "tokens408c5b07-7026-42a5-9f94-8f449230ea01",
+								"type": "text"
+							}
+						],
+						"body": {
+							"mode": "raw",
+							"raw": "{\n\t\"apikey\":\"API_META_EBANK_CUMULATIVE\",\n\t\"param\":{\n\t\t\"extparam\":{\n\t\t\t\"recvdate\":\"20221021\",\n\t\t\t\"nodecode\":\"011523017044\"\n\t\t}\n\t}\n}"
+						},
+						"url": {
+							"raw": "111.1.12.155:9086/bdosservice/query/list",
+							"host": [
+								"111",
+								"1",
+								"12",
+								"155"
+							],
+							"port": "9086",
+							"path": [
+								"bdosservice",
+								"query",
+								"list"
+							]
+						}
+					},
+					"response": []
+				}
+			]
+		},
+		{
+			"name": "业务系统高峰时段业务量统计",
+			"item": [
+				{
+					"name": "大额",
+					"request": {
+						"method": "POST",
+						"header": [
+							{
+								"key": "Content-Type",
+								"name": "Content-Type",
+								"type": "text",
+								"value": "application/json"
+							},
+							{
+								"key": "X-Token",
+								"value": "tokens9209c082-9d46-4d23-a24d-1d969555b79b",
+								"type": "text"
+							}
+						],
+						"body": {
+							"mode": "raw",
+							"raw": "{\n\t\"apikey\":\"API_META_LARGE_PEAK_STATEMENT\",\n\t\"param\":{\n\t\t\"extparam\":{\n\t\t\t\"settdate\":\"20181017\",\n\t\t\t\"timeid\":\"32\"\n\t\t}\n\t}\n}"
+						},
+						"url": {
+							"raw": "111.1.12.155:9086/bdosservice/query/list",
+							"host": [
+								"111",
+								"1",
+								"12",
+								"155"
+							],
+							"port": "9086",
+							"path": [
+								"bdosservice",
+								"query",
+								"list"
+							]
+						}
+					},
+					"response": []
+				},
+				{
+					"name": "小额",
+					"request": {
+						"method": "POST",
+						"header": [
+							{
+								"key": "Content-Type",
+								"name": "Content-Type",
+								"value": "application/json",
+								"type": "text"
+							},
+							{
+								"key": "X-Token",
+								"value": "tokens9209c082-9d46-4d23-a24d-1d969555b79b",
+								"type": "text"
+							}
+						],
+						"body": {
+							"mode": "raw",
+							"raw": "{\n\t\"apikey\":\"API_META_SMALL_PEAK_STATEMENT\",\n\t\"param\":{\n\t\t\"extparam\":{\n\t\t\t\"netdate\":\"20220501\",\n\t\t\t\"timeid\":\"32\"\n\t\t}\n\t}\n}"
+						},
+						"url": {
+							"raw": "111.1.12.155:9086/bdosservice/query/list",
+							"host": [
+								"111",
+								"1",
+								"12",
+								"155"
+							],
+							"port": "9086",
+							"path": [
+								"bdosservice",
+								"query",
+								"list"
+							]
+						}
+					},
+					"response": []
+				},
+				{
+					"name": "网银",
+					"request": {
+						"method": "POST",
+						"header": [
+							{
+								"key": "Content-Type",
+								"name": "Content-Type",
+								"value": "application/json",
+								"type": "text"
+							},
+							{
+								"key": "X-Token",
+								"value": "tokens9209c082-9d46-4d23-a24d-1d969555b79b",
+								"type": "text"
+							}
+						],
+						"body": {
+							"mode": "raw",
+							"raw": "{\n\t\"apikey\":\"API_META_EBANK_PEAK_STATEMENT\",\n\t\"param\":{\n\t\t\"extparam\":{\n\t\t\t\"netdate\":\"20160506\",\n\t\t\t\"timeid\":\"32\"\n\t\t}\n\t}\n}"
+						},
+						"url": {
+							"raw": "111.1.12.155:9086/bdosservice/query/list",
+							"host": [
+								"111",
+								"1",
+								"12",
+								"155"
+							],
+							"port": "9086",
+							"path": [
+								"bdosservice",
+								"query",
+								"list"
+							]
+						}
+					},
+					"response": []
+				}
+			]
+		},
+		{
+			"name": "大额、小额、网银系统典型日期分时业务量数据",
+			"item": [
+				{
+					"name": "大额",
+					"request": {
+						"method": "POST",
+						"header": [
+							{
+								"key": "Content-Type",
+								"name": "Content-Type",
+								"value": "application/json",
+								"type": "text"
+							},
+							{
+								"key": "X-Token",
+								"value": "tokens597631f0-9ea7-4eef-9ac6-6afc34bb2a2a",
+								"type": "text"
+							}
+						],
+						"body": {
+							"mode": "raw",
+							"raw": "{\n\t\"apikey\":\"API_META_LARGE_MONTH_TYPICAL_SUMMIT_DAY\",\n\t\"param\":{\n\t\t\"extparam\":{\n\t\t\t\"settdate\":\"20181017\"\n\t\t}\n\t}\n}"
+						},
+						"url": {
+							"raw": "111.1.12.155:9086/bdosservice/query/list",
+							"host": [
+								"111",
+								"1",
+								"12",
+								"155"
+							],
+							"port": "9086",
+							"path": [
+								"bdosservice",
+								"query",
+								"list"
+							]
+						}
+					},
+					"response": []
+				},
+				{
+					"name": "小额",
+					"request": {
+						"method": "POST",
+						"header": [
+							{
+								"key": "Content-Type",
+								"name": "Content-Type",
+								"value": "application/json",
+								"type": "text"
+							},
+							{
+								"key": "X-Token",
+								"value": "tokens597631f0-9ea7-4eef-9ac6-6afc34bb2a2a",
+								"type": "text"
+							}
+						],
+						"body": {
+							"mode": "raw",
+							"raw": "{\n\t\"apikey\":\"API_META_SMALL_MONTH_TYPICAL_SUMMIT_DAY\",\n\t\"param\":{\n\t\t\"extparam\":{\n\t\t\t\"netdate\":\"20220526\"\n\t\t}\n\t}\n}"
+						},
+						"url": {
+							"raw": "111.1.12.155:9086/bdosservice/query/list",
+							"host": [
+								"111",
+								"1",
+								"12",
+								"155"
+							],
+							"port": "9086",
+							"path": [
+								"bdosservice",
+								"query",
+								"list"
+							]
+						}
+					},
+					"response": []
+				},
+				{
+					"name": "网银",
+					"request": {
+						"method": "POST",
+						"header": [
+							{
+								"key": "Content-Type",
+								"name": "Content-Type",
+								"value": "application/json",
+								"type": "text"
+							},
+							{
+								"key": "X-Token",
+								"value": "tokens597631f0-9ea7-4eef-9ac6-6afc34bb2a2a",
+								"type": "text"
+							}
+						],
+						"body": {
+							"mode": "raw",
+							"raw": "{\n\t\"apikey\":\"API_META_EBANK_MONTH_TYPICAL_SUMMIT_DAY\",\n\t\"param\":{\n\t\t\"extparam\":{\n\t\t\t\"netdate\":\"20160506\"\n\t\t}\n\t}\n}"
+						},
+						"url": {
+							"raw": "111.1.12.155:9086/bdosservice/query/list",
+							"host": [
+								"111",
+								"1",
+								"12",
+								"155"
+							],
+							"port": "9086",
+							"path": [
+								"bdosservice",
+								"query",
+								"list"
+							]
+						}
+					},
+					"response": []
+				}
+			]
+		},
+		{
+			"name": "企业信息联网核查日报",
+			"request": {
+				"method": "POST",
+				"header": [
+					{
+						"key": "Content-Type",
+						"name": "Content-Type",
+						"value": "application/json",
+						"type": "text"
+					},
+					{
+						"key": "X-Token",
+						"value": "tokens0b966e52-dc44-4ad1-80ce-a8746f2d56f1",
+						"type": "text"
+					}
+				],
+				"body": {
+					"mode": "raw",
+					"raw": "{\n  \"apikey\":\"API_META_BDPSAS_REPORT\",\n  \"param\": {\n  \t\"starttime\":\"20211201\",\n  \t\"endtime\":\"20220730\",\n    \"tpname\":\"MIVS日报(系统一部)\"\n  }\n}"
+				},
+				"url": {
+					"raw": "111.1.12.155:9086/bdosservice/query/streamdata",
+					"host": [
+						"111",
+						"1",
+						"12",
+						"155"
+					],
+					"port": "9086",
+					"path": [
+						"bdosservice",
+						"query",
+						"streamdata"
+					]
+				}
+			},
+			"response": []
+		},
+		{
+			"name": "系统运行质量日报",
+			"request": {
+				"method": "POST",
+				"header": [
+					{
+						"key": "Content-Type",
+						"name": "Content-Type",
+						"type": "text",
+						"value": "application/json"
+					},
+					{
+						"key": "X-Token",
+						"type": "text",
+						"value": "tokens9896d396-6278-410f-b297-d1e8b32d238c"
+					}
+				],
+				"body": {
+					"mode": "raw",
+					"raw": "{\n  \"apikey\":\"API_META_BDPSAS_REPORT\",\n  \"param\": {\n  \t\"starttime\":\"20211201\",\n  \t\"endtime\":\"20220730\",\n    \"tpname\":\"MIVS日报(系统一部)\"\n  }\n}"
+				},
+				"url": {
+					"raw": "111.1.12.155:9086/bdosservice/query/streamdata",
+					"host": [
+						"111",
+						"1",
+						"12",
+						"155"
+					],
+					"port": "9086",
+					"path": [
+						"bdosservice",
+						"query",
+						"streamdata"
+					]
+				}
+			},
+			"response": []
+		},
+		{
+			"name": "七大行每日发起峰值统计",
+			"request": {
+				"method": "POST",
+				"header": [
+					{
+						"key": "Content-Type",
+						"name": "Content-Type",
+						"type": "text",
+						"value": "application/json"
+					},
+					{
+						"key": "X-Token",
+						"type": "text",
+						"value": "tokens408c5b07-7026-42a5-9f94-8f449230ea01"
+					}
+				],
+				"body": {
+					"mode": "raw",
+					"raw": "{\n\t\"apikey\":\"API_META_SEVEN_DAILY_APEX\",\n\t\"param\":{\n\t\t\"extparam\":{\n\t\t\t\"syscode\":\"IBPS\",\n\t\t\t\"nodecode\":\"0000\",\n\t\t\t\"caldate\":\"20221021\"\n\t\t}\n\t}\n}"
+				},
+				"url": {
+					"raw": "111.1.12.155:9086/bdosservice/query/list",
+					"host": [
+						"111",
+						"1",
+						"12",
+						"155"
+					],
+					"port": "9086",
+					"path": [
+						"bdosservice",
+						"query",
+						"list"
+					]
+				}
+			},
+			"response": []
+		},
+		{
+			"name": "业务月报数据获取",
+			"request": {
+				"method": "POST",
+				"header": [
+					{
+						"key": "Content-Type",
+						"name": "Content-Type",
+						"type": "text",
+						"value": "application/json"
+					},
+					{
+						"key": "X-Token",
+						"value": "tokens14f0121e-d476-418b-bd98-eee12850a254",
+						"type": "text"
+					}
+				],
+				"body": {
+					"mode": "raw",
+					"raw": "{\n  \"apikey\":\"API_META_BDPSAS_REPORT\",\n  \"param\": {\n  \t\"starttime\":\"20211201\",\n  \t\"endtime\":\"20220730\",\n    \"tpname\":\"MIVS日报(系统一部)\"\n  }\n}"
+				},
+				"url": {
+					"raw": "111.1.12.155:9086/bdosservice/query/streamdata",
+					"host": [
+						"111",
+						"1",
+						"12",
+						"155"
+					],
+					"port": "9086",
+					"path": [
+						"bdosservice",
+						"query",
+						"streamdata"
+					]
+				}
+			},
+			"response": []
+		},
+		{
+			"name": "票据获取",
+			"request": {
+				"method": "POST",
+				"header": [
+					{
+						"key": "Content-Type",
+						"name": "Content-Type",
+						"value": "application/json",
+						"type": "text"
+					}
+				],
+				"body": {
+					"mode": "raw",
+					"raw": "{\n\t\"username\":\"meta\",\n\t\"password\":\"meta\"\n}"
+				},
+				"url": {
+					"raw": "111.1.12.155:9086/bdosservice/login",
+					"host": [
+						"111",
+						"1",
+						"12",
+						"155"
+					],
+					"port": "9086",
+					"path": [
+						"bdosservice",
+						"login"
+					]
+				}
+			},
+			"response": []
+		}
+	]
+};
+
+OUTPUT = _.map(postman.item,function(v){
+    var item = {};
+    item['name'] = v.name || null;
+    item['items'] = v.item ? _.map(v.item,function(val){
+        var o = {};
+        
+        o['name'] = val.name;
+        o['type'] = val.request.url.raw.indexOf('streamdata') != -1 ? 'docx' : 'csv'
+        o['method'] = val.request.method;
+        
+        var params = JSON.parse(val.request.body.raw);
+        o['param'] = params;
+        o['url'] = val.request.url.raw;
+        return o;
+    }) : _.map([v.request],function(val){
+        var o = {};
+        
+        o['name'] = val.name || null;
+        o['type'] = val.url.raw.indexOf('streamdata') != -1 ? 'docx' : 'csv'
+        o['method'] = val.method;
+        
+        var params = JSON.parse(val.body.raw);
+        o['param'] = params;
+        o['url'] = val.url.raw;
+        return o;
+    })
+    return item;
+})

+ 45 - 0
serverjs/script/cncc/DIEP/报告参数_文本.js

@@ -0,0 +1,45 @@
+OUTPUT = ["支付系统业务数据统计报告","系统运行质量日报_大额平行(北京)",
+    "系统运行质量日报_SCPS(北京)",
+    "系统运行质量日报_PMTS(无锡)",
+    "系统运行质量日报_PMTS(北京)",
+    "系统运行质量日报_PMTS(上海)",
+    "系统运行质量日报_MIVS(北京)",
+    "系统运行质量日报_FXCC(上海)",
+    "系统运行质量日报_IBPS_Power实例(无锡)",
+    "系统运行质量日报_SCPS(上海)",
+    "系统运行质量日报_PN2N(无锡)",
+    "系统运行质量日报_IMGS(北京)",
+    "系统运行质量日报_IMGS(上海)",
+    "系统运行质量日报_FXCC(北京)",
+    "系统运行质量日报_CIPSGW(无锡)",
+    "系统运行质量日报_CIPS(上海)",
+    "系统运行质量日报_MAPS(上海)",
+    "系统运行质量日报_MAPS(北京)",
+    "系统运行质量日报_PN2N(上海)",
+    "系统运行质量日报_PN2N(北京)",
+    "系统运行质量日报_HVPS(上海)",
+    "系统运行质量日报_HVPS(北京)",
+    "系统运行质量日报_BEPS(上海)",
+    "系统运行质量日报_BEPS(北京)",
+    "系统运行质量日报_IBPS_Power实例(上海)",
+    "系统运行质量日报_IBPS_Power实例(北京)",
+    "系统运行质量日报_IBPS主机实例(上海)",
+    "系统运行质量日报_IBPS主机实例(北京)",
+    "系统运行质量日报_NETS(上海)",
+    "系统运行质量日报_NETS(北京)",
+    "系统运行质量日报_SAPS(上海)",
+    "系统运行质量日报_SAPS(北京)",
+    "系统运行质量日报_CIPS(无锡)",
+    "系统运行质量日报_CIPSGW(上海)",
+    "系统运行质量日报_ELCS(上海)",
+    "系统运行质量日报_ELCS(北京)",
+    "系统运行质量日报_MIVS(上海)"].map(function(v){
+        return {
+                "apikey":"API_META_BDPSAS_REPORT",
+                "param":{
+                    "starttime":"20211201",
+                    "endtime":"20221025",
+                    "tpname": v
+                }
+        }
+    })

+ 309 - 0
serverjs/script/cncc/DIEP/接入报告.js

@@ -0,0 +1,309 @@
+var ipport = "27.192.140.126:9082"
+var input =  [
+    {
+      "items": [
+        {
+          "method": "POST",
+          "name": "每日网银热点账户截图示例-网银分时",
+          "param": {
+            "apikey": "API_META_EBANK_TIME_SHARING",
+            "param": {
+              "extparam": {
+                "nodecode": "011523017044",
+                "recvdate": "20221021"
+              }
+            }
+          },
+          "type": "csv",
+          "url": ipport+"/bdosservice/query/list"
+        },
+        {
+          "method": "POST",
+          "name": "网银热点账户业务量示例",
+          "param": {
+            "apikey": "API_META_EBANK_ACCOUNT",
+            "param": {
+              "extparam": {
+                "netdate": "20160506"
+              }
+            }
+          },
+          "type": "csv",
+          "url": ipport+"/bdosservice/query/list"
+        },
+        {
+          "method": "POST",
+          "name": "每日网银热点账户截图示例-网银累计",
+          "param": {
+            "apikey": "API_META_EBANK_CUMULATIVE",
+            "param": {
+              "extparam": {
+                "nodecode": "011523017044",
+                "recvdate": "20221021"
+              }
+            }
+          },
+          "type": "csv",
+          "url": ipport+"/bdosservice/query/list"
+        }
+      ],
+      "name": "网银热点账户统计"
+    },
+    {
+      "items": [
+        {
+          "method": "POST",
+          "name": "大额",
+          "param": {
+            "apikey": "API_META_LARGE_PEAK_STATEMENT",
+            "param": {
+              "extparam": {
+                "settdate": "20181017",
+                "timeid": "32"
+              }
+            }
+          },
+          "type": "csv",
+          "url": ipport+"/bdosservice/query/list"
+        },
+        {
+          "method": "POST",
+          "name": "小额",
+          "param": {
+            "apikey": "API_META_SMALL_PEAK_STATEMENT",
+            "param": {
+              "extparam": {
+                "netdate": "20220501",
+                "timeid": "32"
+              }
+            }
+          },
+          "type": "csv",
+          "url": ipport+"/bdosservice/query/list"
+        },
+        {
+          "method": "POST",
+          "name": "网银",
+          "param": {
+            "apikey": "API_META_EBANK_PEAK_STATEMENT",
+            "param": {
+              "extparam": {
+                "netdate": "20160506",
+                "timeid": "32"
+              }
+            }
+          },
+          "type": "csv",
+          "url": ipport+"/bdosservice/query/list"
+        }
+      ],
+      "name": "业务系统高峰时段业务量统计"
+    },
+    {
+      "items": [
+        {
+          "method": "POST",
+          "name": "大额",
+          "param": {
+            "apikey": "API_META_LARGE_MONTH_TYPICAL_SUMMIT_DAY",
+            "param": {
+              "extparam": {
+                "settdate": "20181017"
+              }
+            }
+          },
+          "type": "csv",
+          "url": ipport+"/bdosservice/query/list"
+        },
+        {
+          "method": "POST",
+          "name": "小额",
+          "param": {
+            "apikey": "API_META_SMALL_MONTH_TYPICAL_SUMMIT_DAY",
+            "param": {
+              "extparam": {
+                "netdate": "20220526"
+              }
+            }
+          },
+          "type": "csv",
+          "url": ipport+"/bdosservice/query/list"
+        },
+        {
+          "method": "POST",
+          "name": "网银",
+          "param": {
+            "apikey": "API_META_EBANK_MONTH_TYPICAL_SUMMIT_DAY",
+            "param": {
+              "extparam": {
+                "netdate": "20160506"
+              }
+            }
+          },
+          "type": "csv",
+          "url": ipport+"/bdosservice/query/list"
+        }
+      ],
+      "name": "大额、小额、网银系统典型日期分时业务量数据"
+    },
+    {
+      "items": [
+        {
+          "method": "POST",
+          "name": null,
+          "param": {
+            "apikey": "API_META_BDPSAS_REPORT",
+            "param": {
+              "endtime": "20220730",
+              "starttime": "20211201",
+              "tpname": "MIVS日报(系统一部)"
+            }
+          },
+          "type": "docx",
+          "url": ipport+"/bdosservice/query/streamdata"
+        }
+      ],
+      "name": "企业信息联网核查日报"
+    },
+    {
+      "items": [
+        {
+          "method": "POST",
+          "name": null,
+          "param": {
+            "apikey": "API_META_BDPSAS_REPORT",
+            "param": {
+              "endtime": "20220730",
+              "starttime": "20211201",
+              "tpname": "MIVS日报(系统一部)"
+            }
+          },
+          "type": "docx",
+          "url": ipport+"/bdosservice/query/streamdata"
+        }
+      ],
+      "name": "系统运行质量日报"
+    },
+    {
+      "items": [
+        {
+          "method": "POST",
+          "name": null,
+          "param": {
+            "apikey": "API_META_SEVEN_DAILY_APEX",
+            "param": {
+              "extparam": {
+                "caldate": "20221021",
+                "nodecode": "0000",
+                "syscode": "IBPS"
+              }
+            }
+          },
+          "type": "csv",
+          "url": ipport+"/bdosservice/query/list"
+        }
+      ],
+      "name": "七大行每日发起峰值统计"
+    },
+    {
+      "items": [
+        {
+          "method": "POST",
+          "name": null,
+          "param": {
+            "apikey": "API_META_BDPSAS_REPORT",
+            "param": {
+              "endtime": "20220730",
+              "starttime": "20211201",
+              "tpname": "MIVS日报(系统一部)"
+            }
+          },
+          "type": "docx",
+          "url": ipport+"/bdosservice/query/streamdata"
+        }
+      ],
+      "name": "业务月报数据获取"
+    }
+  ];
+
+var DFS_PATH = "/opt/knowledge/DIEP";
+
+// JSON to CSV Converter
+function ConvertToCSV(objArray) {
+    var array = typeof objArray != 'object' ? JSON.parse(objArray) : objArray;
+    var str = '';
+
+    for (var i = 0; i < array.length; i++) {
+        var line = '';
+        for (var index in array[i]) {
+            if (line != '') line += ','
+
+            line += array[i][index];
+        }
+
+        str += line + '\r\n';
+    }
+
+    return str;
+};
+
+var token = (function(){
+    var rtn = null;
+    var bodyContent = JSON.stringify({
+        "username":"meta",
+        "password":"meta"
+    });
+    http.do("POST", "http://"+ipport+"/bdosservice/login", {"Authorization": "Basic cGJjczpwYmNz","Content-Type": "application/json"}, bodyContent, function(message){
+        // success func
+        //OUTPUT = message.data;
+        //log.debug(message.data.data)
+        rtn = message.data.data.token;
+    }, function(message){
+        // error func
+        log.error(message.data);
+    })
+    return rtn;
+})();
+
+var main = function(){
+    
+    _.forEach(input,function(re){
+        
+        var curDay = new Date().toJSON().substring(0,10)
+        _.forEach(re.items,function(subFile){
+            if(subFile.type === 'docx') {
+                var fileName = subFile.param.param.tpname + "_" + subFile.param.param.starttime + "-" + subFile.param.param.endtime + ".docx";
+                var file = [DFS_PATH, curDay, re.name, fileName].join("/");
+                log.debug(111, file, subFile.method, subFile.url, JSON.stringify(subFile.param))
+                http.do(subFile.method, "http://"+subFile.url, {"X-Token": token,"Content-Type": "application/json"}, JSON.stringify(subFile.param), function(message){
+                    // success func
+                    //OUTPUT = file;
+                    dfs.write(file, message.data);
+                }, function(message){
+                    // error func
+                    log.error(message.data);
+                },300)  
+            } else{
+                var fileName = (subFile.name || re.name) + ".csv";
+                var file = [DFS_PATH, curDay, re.name, fileName].join("/");
+                var param = subFile.param ? JSON.stringify(subFile.param) : null;
+                log.debug(222,  "http://"+subFile.url, file, param)
+                http.do(subFile.method, "http://"+subFile.url, {"X-Token": token,"Content-Type": "application/json"}, param, function(message){
+                    // success func
+                    OUTPUT =  message.data;
+                    dfs.write(file, message.data ? JSON.stringify(message.data) : "");
+                }, function(message){
+                    // error func
+                    log.error(message.data);
+                    return;
+                },300)  
+            }
+        })
+    })
+    
+}
+
+
+
+
+main();

File diff suppressed because it is too large
+ 190 - 0
serverjs/script/cncc/ITIL/事件单.js


File diff suppressed because it is too large
+ 444 - 0
serverjs/script/cncc/ITIL/变更单.js


File diff suppressed because it is too large
+ 296 - 0
serverjs/script/cncc/ITIL/应急演练.js


+ 118 - 0
serverjs/script/cncc/ITIL/报备.js

@@ -0,0 +1,118 @@
+// /cncc/action/report JSON数据导入程序
+// 2022-10-24 23:02:38.444 由 JsonImportGen.js 自动生成,请勿手动修改
+
+// 输入输出参数格式化
+input = INPUT;
+try {
+    input = decodeURIComponent(input);
+} catch (e) { }
+try {
+    input = base64.decode(input);
+} catch (e) { }
+try {
+    input = JSON.parse(input);
+    input = JSON.parse(input);
+} catch (e) { }
+output = {};
+
+testcfg = {};
+try {
+    testcfg = JSON.parse(etcd.get("/api/test.json"));
+} catch (e) { }
+function teststoredfs() {
+    // 输入JSON临时存入DFS
+    dir = "/opt/cncc/action/report";
+    d = new Date();
+    d.setMinutes(d.getMinutes() - d.getTimezoneOffset());
+    dtm = d.toJSON().replace(/[\-\:\.TZ ]/mg, "");
+    fn = dir + "/" + dtm;
+    if (input.id) {
+        fn += "." + input.id;
+    } else {
+        fn += "_" + _.random(0, 1000000);
+    }
+    fn += ".json";
+    dfs.write(fn, JSON.stringify(input, " ", 4));
+    output.filename = fn;
+    // 刪除旧交件
+    files = dfs.readdir(dir);
+    dt = Date.now() - 1000 * 3600 * 24 * 10;
+    for (var i = files.length - 1; i >= 0; i--) {
+        if (files[i].mtime < dt) {
+            dfs.remove(files[i].fullname);
+            files.splice(i, 1);
+        }
+    }
+    // 留最后10个
+    files.sort(function (a, b) { return a.mtime - b.mtime; });
+    for (var i = 0; i < files.length - 10; i++) {
+        dfs.remove(files[i].fullname);
+    }
+}
+// 主执行阶段
+try {
+    if (!input["--testing--"]) {
+        if (testcfg.storedfs) {
+            teststoredfs();
+        }
+        if (testcfg.checkfields) {
+            eval(dfs.read("/script/matrix/utils/ajs/checkfields.js"));
+            var newkeys = checkfields(input, {"changeSummary":"j_change_summary","id":"jid","idUnique":"j_id_unique","name":"j_name"});
+            if (newkeys) {
+                eval(dfs.read("/script/matrix/utils/ajs/JsonImporterFuncs.js"));
+                var result = runServerJS("/matrix/utils/ajs/InitJsonImporter.js", { classname: "/cncc/action/report" });
+                for (var k in result) {
+                    output[k] = result[k];
+                }
+                output.newkeys = newkeys;
+                throw ("ok");
+            }
+        }
+    }
+    // 数据合法性检查
+    if (!input.id) {
+        throw ("输入参数必须为对象,且指定属性id");
+    }
+    if (!input.idUnique) {
+        throw ("输入参数必须为对象,且指定属性idUnique");
+    }
+    // mql定义
+    mql = `insert into /cncc/action/report (
+j_change_summary,
+j_id_unique,
+j_name,
+jid
+) values (
+?,
+?,
+?,
+?
+)`;
+    // 执行mql
+    ret = odb.mql(mql, 
+        input.changeSummary?input.changeSummary:'', // test from itil 报备
+        input.idUnique?input.idUnique:'', // test20221024113142
+        input.name?input.name:'', // test from itil 报备
+        input.id // 20221024113141
+    );
+    // 打印完成信息
+    output.info = {
+        id: input.id,
+        idUnique: input.idUnique
+    };
+    log.info(output.info);
+} catch (e) {
+    if (e != "ok") {
+        if (typeof (e) == "object") {
+            output.error = e;
+        } else if (typeof (e) == "string") {
+            output.error = "插库错误:" + e;
+        } else {
+            output.error = JSON.stringify(e);
+        }
+        log.error(output.error);
+    }
+}
+
+// 返回输出信息
+OUTPUT = output;

File diff suppressed because it is too large
+ 294 - 0
serverjs/script/cncc/ITIL/数据获取.js


File diff suppressed because it is too large
+ 229 - 0
serverjs/script/cncc/ITIL/设备上下电.js


File diff suppressed because it is too large
+ 265 - 0
serverjs/script/cncc/ITIL/问题单.js


+ 133 - 0
serverjs/script/cncc/ITIL/项目实施或巡检.js

@@ -0,0 +1,133 @@
+// /cncc/action/implement JSON数据导入程序
+// 2022-10-24 23:02:42.692 由 JsonImportGen.js 自动生成,请勿手动修改
+
+// 输入输出参数格式化
+input = INPUT;
+try {
+    input = decodeURIComponent(input);
+} catch (e) { }
+try {
+    input = base64.decode(input);
+} catch (e) { }
+try {
+    input = JSON.parse(input);
+    input = JSON.parse(input);
+} catch (e) { }
+output = {};
+
+testcfg = {};
+try {
+    testcfg = JSON.parse(etcd.get("/api/test.json"));
+} catch (e) { }
+function teststoredfs() {
+    // 输入JSON临时存入DFS
+    dir = "/opt/cncc/action/implement";
+    d = new Date();
+    d.setMinutes(d.getMinutes() - d.getTimezoneOffset());
+    dtm = d.toJSON().replace(/[\-\:\.TZ ]/mg, "");
+    fn = dir + "/" + dtm;
+    if (input.id) {
+        fn += "." + input.id;
+    } else {
+        fn += "_" + _.random(0, 1000000);
+    }
+    fn += ".json";
+    dfs.write(fn, JSON.stringify(input, " ", 4));
+    output.filename = fn;
+    // 刪除旧交件
+    files = dfs.readdir(dir);
+    dt = Date.now() - 1000 * 3600 * 24 * 10;
+    for (var i = files.length - 1; i >= 0; i--) {
+        if (files[i].mtime < dt) {
+            dfs.remove(files[i].fullname);
+            files.splice(i, 1);
+        }
+    }
+    // 留最后10个
+    files.sort(function (a, b) { return a.mtime - b.mtime; });
+    for (var i = 0; i < files.length - 10; i++) {
+        dfs.remove(files[i].fullname);
+    }
+}
+// 主执行阶段
+try {
+    if (!input["--testing--"]) {
+        if (testcfg.storedfs) {
+            teststoredfs();
+        }
+        if (testcfg.checkfields) {
+            eval(dfs.read("/script/matrix/utils/ajs/checkfields.js"));
+            var newkeys = checkfields(input, {"changeSummary":"j_change_summary","createTime":"j_create_time","createUserId":"j_create_user_id","createUserRealName":"j_create_user_real_name","id":"jid","idUnique":"j_id_unique","isValid":"j_is_valid","name":"j_name","updateTime":"j_update_time"});
+            if (newkeys) {
+                eval(dfs.read("/script/matrix/utils/ajs/JsonImporterFuncs.js"));
+                var result = runServerJS("/matrix/utils/ajs/InitJsonImporter.js", { classname: "/cncc/action/implement" });
+                for (var k in result) {
+                    output[k] = result[k];
+                }
+                output.newkeys = newkeys;
+                throw ("ok");
+            }
+        }
+    }
+    // 数据合法性检查
+    if (!input.id) {
+        throw ("输入参数必须为对象,且指定属性id");
+    }
+    if (!input.idUnique) {
+        throw ("输入参数必须为对象,且指定属性idUnique");
+    }
+    // mql定义
+    mql = `insert into /cncc/action/implement (
+j_change_summary,
+j_create_time,
+j_create_user_id,
+j_create_user_real_name,
+j_id_unique,
+j_is_valid,
+j_name,
+j_update_time,
+jid
+) values (
+?,
+?,
+?,
+?,
+?,
+?,
+?,
+?,
+?
+)`;
+    // 执行mql
+    ret = odb.mql(mql, 
+        input.changeSummary?input.changeSummary:'', // test from itil 项目实施或巡检
+        input.createTime, // 2020-04-03 23:12:25
+        input.createUserId, // 2
+        input.createUserRealName?input.createUserRealName:'', // 周杰
+        input.idUnique?input.idUnique:'', // test20221024113143
+        input.isValid, // 0
+        input.name?input.name:'', // test from itil 项目实施或巡检
+        input.updateTime, // 2020-04-03 23:12:25
+        input.id // 299
+    );
+    // 打印完成信息
+    output.info = {
+        id: input.id,
+        idUnique: input.idUnique
+    };
+    log.info(output.info);
+} catch (e) {
+    if (e != "ok") {
+        if (typeof (e) == "object") {
+            output.error = e;
+        } else if (typeof (e) == "string") {
+            output.error = "插库错误:" + e;
+        } else {
+            output.error = JSON.stringify(e);
+        }
+        log.error(output.error);
+    }
+}
+
+// 返回输出信息
+OUTPUT = output;

+ 457 - 0
serverjs/script/cncc/Tivoli/omnibus/columns.js

@@ -0,0 +1,457 @@
+var columns = [{
+				"name":	"Identifier",
+				"type":	"string",
+				"size":	255
+			}, {
+				"name":	"Serial",
+				"type":	"integer",
+				"size":	4
+			}, {
+				"name":	"Node",
+				"type":	"string",
+				"size":	64
+			}, {
+				"name":	"NodeAlias",
+				"type":	"string",
+				"size":	64
+			}, {
+				"name":	"Manager",
+				"type":	"string",
+				"size":	64
+			}, {
+				"name":	"Agent",
+				"type":	"string",
+				"size":	64
+			}, {
+				"name":	"AlertGroup",
+				"type":	"string",
+				"size":	255
+			}, {
+				"name":	"AlertKey",
+				"type":	"string",
+				"size":	255
+			}, {
+				"name":	"Severity",
+				"type":	"integer",
+				"size":	4
+			}, {
+				"name":	"Summary",
+				"type":	"string",
+				"size":	1255
+			}, {
+				"name":	"StateChange",
+				"type":	"utc",
+				"size":	4
+			}, {
+				"name":	"FirstOccurrence",
+				"type":	"utc",
+				"size":	4
+			}, {
+				"name":	"LastOccurrence",
+				"type":	"utc",
+				"size":	4
+			}, {
+				"name":	"InternalLast",
+				"type":	"utc",
+				"size":	4
+			}, {
+				"name":	"Poll",
+				"type":	"integer",
+				"size":	4
+			}, {
+				"name":	"Type",
+				"type":	"integer",
+				"size":	4
+			}, {
+				"name":	"Tally",
+				"type":	"integer",
+				"size":	4
+			}, {
+				"name":	"Class",
+				"type":	"integer",
+				"size":	4
+			}, {
+				"name":	"Grade",
+				"type":	"integer",
+				"size":	4
+			}, {
+				"name":	"Location",
+				"type":	"string",
+				"size":	64
+			}, {
+				"name":	"OwnerUID",
+				"type":	"integer",
+				"size":	4
+			}, {
+				"name":	"OwnerGID",
+				"type":	"integer",
+				"size":	4
+			}, {
+				"name":	"Acknowledged",
+				"type":	"integer",
+				"size":	4
+			}, {
+				"name":	"Flash",
+				"type":	"integer",
+				"size":	4
+			}, {
+				"name":	"EventId",
+				"type":	"string",
+				"size":	255
+			}, {
+				"name":	"ExpireTime",
+				"type":	"integer",
+				"size":	4
+			}, {
+				"name":	"ProcessReq",
+				"type":	"integer",
+				"size":	4
+			}, {
+				"name":	"SuppressEscl",
+				"type":	"integer",
+				"size":	4
+			}, {
+				"name":	"Customer",
+				"type":	"string",
+				"size":	64
+			}, {
+				"name":	"Service",
+				"type":	"string",
+				"size":	64
+			}, {
+				"name":	"PhysicalSlot",
+				"type":	"integer",
+				"size":	4
+			}, {
+				"name":	"PhysicalPort",
+				"type":	"integer",
+				"size":	4
+			}, {
+				"name":	"PhysicalCard",
+				"type":	"string",
+				"size":	64
+			}, {
+				"name":	"TaskList",
+				"type":	"integer",
+				"size":	4
+			}, {
+				"name":	"NmosSerial",
+				"type":	"string",
+				"size":	64
+			}, {
+				"name":	"NmosObjInst",
+				"type":	"integer",
+				"size":	4
+			}, {
+				"name":	"NmosCauseType",
+				"type":	"integer",
+				"size":	4
+			}, {
+				"name":	"NmosDomainName",
+				"type":	"string",
+				"size":	64
+			}, {
+				"name":	"NmosEntityId",
+				"type":	"integer",
+				"size":	4
+			}, {
+				"name":	"NmosManagedStatus",
+				"type":	"integer",
+				"size":	4
+			}, {
+				"name":	"NmosEventMap",
+				"type":	"string",
+				"size":	64
+			}, {
+				"name":	"LocalNodeAlias",
+				"type":	"string",
+				"size":	64
+			}, {
+				"name":	"LocalPriObj",
+				"type":	"string",
+				"size":	255
+			}, {
+				"name":	"LocalSecObj",
+				"type":	"string",
+				"size":	255
+			}, {
+				"name":	"LocalRootObj",
+				"type":	"string",
+				"size":	255
+			}, {
+				"name":	"RemoteNodeAlias",
+				"type":	"string",
+				"size":	64
+			}, {
+				"name":	"RemotePriObj",
+				"type":	"string",
+				"size":	255
+			}, {
+				"name":	"RemoteSecObj",
+				"type":	"string",
+				"size":	255
+			}, {
+				"name":	"RemoteRootObj",
+				"type":	"string",
+				"size":	255
+			}, {
+				"name":	"X733EventType",
+				"type":	"integer",
+				"size":	4
+			}, {
+				"name":	"X733ProbableCause",
+				"type":	"integer",
+				"size":	4
+			}, {
+				"name":	"X733SpecificProb",
+				"type":	"string",
+				"size":	64
+			}, {
+				"name":	"X733CorrNotif",
+				"type":	"string",
+				"size":	255
+			}, {
+				"name":	"ServerName",
+				"type":	"string",
+				"size":	64
+			}, {
+				"name":	"ServerSerial",
+				"type":	"integer",
+				"size":	4
+			}, {
+				"name":	"URL",
+				"type":	"string",
+				"size":	1024
+			}, {
+				"name":	"ExtendedAttr",
+				"type":	"string",
+				"size":	4096
+			}, {
+				"name":	"OldRow",
+				"type":	"integer",
+				"size":	4
+			}, {
+				"name":	"ProbeSubSecondId",
+				"type":	"integer",
+				"size":	4
+			}, {
+				"name":	"BSM_Identity",
+				"type":	"string",
+				"size":	1024
+			}, {
+				"name":	"DeviceType",
+				"type":	"string",
+				"size":	32
+			}, {
+				"name":	"DeviceModel",
+				"type":	"string",
+				"size":	64
+			}, {
+				"name":	"DevicePurpose",
+				"type":	"string",
+				"size":	128
+			}, {
+				"name":	"DeviceLocation",
+				"type":	"string",
+				"size":	64
+			}, {
+				"name":	"Contact",
+				"type":	"string",
+				"size":	12
+			}, {
+				"name":	"Phone",
+				"type":	"string",
+				"size":	32
+			}, {
+				"name":	"ImpactFlag",
+				"type":	"integer",
+				"size":	4
+			}, {
+				"name":	"AlertType",
+				"type":	"string",
+				"size":	255
+			}, {
+				"name":	"AlertSubType",
+				"type":	"string",
+				"size":	255
+			}, {
+				"name":	"NodeName",
+				"type":	"string",
+				"size":	32
+			}, {
+				"name":	"Subsystem",
+				"type":	"string",
+				"size":	32
+			}, {
+				"name":	"MaintainStatus",
+				"type":	"integer",
+				"size":	4
+			}, {
+				"name":	"CNSummary",
+				"type":	"string",
+				"size":	2048
+			}, {
+				"name":	"UpgradeFlag",
+				"type":	"integer",
+				"size":	4
+			}, {
+				"name":	"PhysicalLocation",
+				"type":	"string",
+				"size":	32
+			}, {
+				"name":	"Platform",
+				"type":	"string",
+				"size":	32
+			}, {
+				"name":	"RecordTime",
+				"type":	"utc",
+				"size":	4
+			}, {
+				"name":	"EventStatus",
+				"type":	"integer",
+				"size":	4
+			}, {
+				"name":	"Duration",
+				"type":	"integer",
+				"size":	4
+			}, {
+				"name":	"OrgCode",
+				"type":	"string",
+				"size":	64
+			}, {
+				"name":	"OriginalSeverity",
+				"type":	"integer",
+				"size":	4
+			}, {
+				"name":	"EventTime",
+				"type":	"string",
+				"size":	64
+			}, {
+				"name":	"Idname",
+				"type":	"string",
+				"size":	64
+			}, {
+				"name":	"Explain",
+				"type":	"string",
+				"size":	128
+			}, {
+				"name":	"Resolve",
+				"type":	"string",
+				"size":	128
+			}, {
+				"name":	"LPAR",
+				"type":	"string",
+				"size":	16
+			}, {
+				"name":	"Sysplex",
+				"type":	"string",
+				"size":	16
+			}, {
+				"name":	"EventClass",
+				"type":	"string",
+				"size":	32
+			}, {
+				"name":	"Msg_id",
+				"type":	"string",
+				"size":	32
+			}, {
+				"name":	"Instance",
+				"type":	"string",
+				"size":	32
+			}, {
+				"name":	"CCPC",
+				"type":	"integer",
+				"size":	4
+			}, {
+				"name":	"NodeType",
+				"type":	"string",
+				"size":	10
+			}, {
+				"name":	"CCPCBANK",
+				"type":	"string",
+				"size":	20
+			}, {
+				"name":	"SysCode",
+				"type":	"string",
+				"size":	64
+			}, {
+				"name":	"MachineId",
+				"type":	"string",
+				"size":	24
+			}, {
+				"name":	"Status",
+				"type":	"string",
+				"size":	5
+			}, {
+				"name":	"Evtproccode",
+				"type":	"string",
+				"size":	10
+			}, {
+				"name":	"tiggerflag",
+				"type":	"integer",
+				"size":	4
+			}, {
+				"name":	"Flag",
+				"type":	"integer",
+				"size":	4
+			}, {
+				"name":	"Submodel",
+				"type":	"string",
+				"size":	32
+			}, {
+				"name":	"BName",
+				"type":	"string",
+				"size":	64
+			}, {
+				"name":	"SMSFlag",
+				"type":	"integer",
+				"size":	4
+			}, {
+				"name":	"PlatEng",
+				"type":	"string",
+				"size":	64
+			}, {
+				"name":	"TSRMFlag",
+				"type":	"integer",
+				"size":	4
+			}, {
+				"name":	"PhysicalCabinet",
+				"type":	"string",
+				"size":	32
+			}, {
+				"name":	"N_MAINTENANCE_STATUS",
+				"type":	"integer",
+				"size":	4
+			}, {
+				"name":	"RowSerial",
+				"type":	"integer",
+				"size":	4
+			}];
+var type = function(value){
+    if(value === 'string'){
+        return 'varchar';
+    }  
+    
+    if(value === 'integer'){
+        return 'integer';
+    }
+    
+    if(value === 'utc'){
+        return 'timestamp';
+    }
+};
+
+
+var action = function(){
+    var rtn = [];
+    rtn.push("create class if not exists alerts_status:/cncc/action (");
+    _.forEach(columns,function(v){
+        rtn.push( v.name.toLowerCase() + "        " + type(v.type) + "        '" + v.name + "',");
+    });
+    rtn.push(`keys( id_unique) ,`);
+    rtn.push(`)with ttl=3 day , autosearch=false , version=true , key=manu, alias='omnibus告警事件' , namespace='cncc'`);
+    
+    dfs.write("/script/cncc/Tivoli/omnibus/alerts_status.mql", rtn.join("\n"));
+};
+
+OUTPUT = action();

File diff suppressed because it is too large
+ 1592 - 0
serverjs/script/cncc/应用/meta-alarmwall/template/menu.js


+ 36 - 0
serverjs/script/cncc/应用/meta-capacitya/performanceByHost.js

@@ -0,0 +1,36 @@
+var input = JSON.parse(decodeURIComponent(INPUT));
+
+
+
+var perf = function(){
+    var rtn = {};
+    try{
+        var classBy = input.id.split(":")[0];
+        var data = null;
+        var currentDay = new Date().toJSON().slice(0,10);
+        var yesterday = new Date(new Date().setDate(new Date().getDate() - 1)).toJSON().slice(0,10);
+        input.timerange[0] = yesterday;
+        input.timerange[1] = currentDay;
+        var mqlCpu = "select id,performance.time('"+input.timerange[0]+"','"+input.timerange[1]+"').find(name='cpuRate') from "+classBy+" where id='"+input.id+"'";
+         data = _.map(odb.mql(mqlCpu).data,'performance')[0];
+         _.extend(rtn,{cpuRate: data});
+        
+        var mqlMem = "select id,performance.time('"+input.timerange[0]+"','"+input.timerange[1]+"').find(name='memRate') from "+classBy+" where id='"+input.id+"'";
+        data = _.map(odb.mql(mqlMem).data,'performance')[0];
+        _.extend(rtn,{memRate: data});
+        
+        var mqlDisk = "select id,performance.time('"+input.timerange[0]+"','"+input.timerange[1]+"').find(name='diskRateMax') from "+classBy+" where id='"+input.id+"'";
+        data = _.map(odb.mql(mqlDisk).data,'performance')[0];
+        _.extend(rtn,{diskRate: data});
+        
+        
+        
+    }catch(err){
+        log.error(err)
+    }
+    return rtn;
+};
+
+
+
+OUTPUT = perf();

+ 36 - 0
serverjs/script/cncc/应用/meta-capacitya/performanceByVm.js

@@ -0,0 +1,36 @@
+var input = JSON.parse(decodeURIComponent(INPUT));
+
+
+
+var perf = function(){
+    var rtn = {};
+    try{
+        var classBy = input.id.split(":")[0];
+        var data = null;
+        var currentDay = new Date().toJSON().slice(0,10);
+        var yesterday = new Date(new Date().setDate(new Date().getDate() - 1)).toJSON().slice(0,10);
+        input.timerange[0] = yesterday;
+        input.timerange[1] = currentDay;
+        var mqlCpu = "select id,performance.time('"+input.timerange[0]+"','"+input.timerange[1]+"').find(name='cpu_busy') from "+classBy+" where id='"+input.id+"'";
+         data = _.map(odb.mql(mqlCpu).data,'performance')[0];
+         _.extend(rtn,{cpuRate: data});
+        
+        var mqlMem = "select id,performance.time('"+input.timerange[0]+"','"+input.timerange[1]+"').find(name='memRate') from "+classBy+" where id='"+input.id+"'";
+        data = _.map(odb.mql(mqlMem).data,'performance')[0];
+        _.extend(rtn,{memRate: data});
+        
+        var mqlDisk = "select id,performance.time('"+input.timerange[0]+"','"+input.timerange[1]+"').find(name='diskRateMax') from "+classBy+" where id='"+input.id+"'";
+        data = _.map(odb.mql(mqlDisk).data,'performance')[0];
+        _.extend(rtn,{diskRate: data});
+        
+        
+        
+    }catch(err){
+        log.error(err)
+    }
+    return rtn;
+};
+
+
+
+OUTPUT = perf();

+ 228 - 0
serverjs/script/cncc/应用/meta-capacitya/summary.js

@@ -0,0 +1,228 @@
+
+
+
+var datacenters = (function(){
+    var rtn = {};
+    
+    try{
+        var mql = "select id,name,datasource,org from /cncc/entity/datacenter limit -1";
+        var tmp = odb.mql(mql).data;
+        var grouped = _.groupBy(tmp,'datasource');
+         
+        _.forEach(grouped,function(v,k){
+            
+            if(k==='NPC'){
+                var g = _.groupBy(v,'name');
+                _.forEach(g,function(vv,vk){
+                    var o = {};
+                    o[vk] = vv;
+                    _.extend(rtn,o);
+                })
+            }else{
+                var o = {};
+                o[k]=v;
+                _.extend(rtn,o);
+            }
+            
+        });
+        
+    }catch(err){
+        log.error(err);
+    }
+    
+    return rtn;
+})();
+
+
+
+var server_power = (function(){
+    try{
+        var data = odb.mql("select count(*) from /cncc/entity/power limit -1").data;
+        return data[0].count;    
+    }catch(err){
+        return 0;
+    }
+    
+})();
+
+var server_x86 = (function(){
+    try{
+        var data = odb.mql("select count(*) from /cncc/entity/x86 limit -1").data;
+        return data[0].count;    
+    }catch(err){
+        return 0;
+    }
+})();
+
+var hostsByDc = (function(){
+    try{
+        var allHostList = [];
+        
+        var x86List = odb.mql("select id,name,cpu,memory,disk,datacenter from /cncc/entity/x86 limit -1").data;
+        allHostList = allHostList.concat(x86List);
+        
+        var powerList = odb.mql("select id,name,cpu,memory,disk,datacenter from /cncc/entity/power limit -1").data;
+        allHostList = allHostList.concat(powerList);
+        
+        return _.extend(_.groupBy(allHostList,'datacenter'), {"CCPC":[], "央行云":[]});
+    }catch(err){
+        log.error(err)
+        return null;
+    }
+})();
+
+
+// 统计当前DC里所有服务器的分区容量数据
+var vmSummaryByHosts = function(hosts){
+    var rtn = {};
+    try{
+        var summaryList = [];
+        
+        _.forEach(hosts,function(host){
+            var sp = host.id.split(":");
+            var classBy = sp[0]=='/cncc/entity/x86'?'/cncc/entity/os/linux':'/cncc/entity/os/aix';
+            var mql = "select id,cpu,memory,disk from "+ classBy +" where deploy='"+host.id+"' limit -1";
+            log.info(mql)
+            var data = odb.mql(mql);
+            if(data){
+                summaryList = summaryList.concat(data.data);
+            }
+        })
+        
+        _.extend(rtn, {
+                        cpu_allocated: _.reduce(summaryList,function(memo, val) {
+                            return memo + val.cpu;
+                        },0),
+                        mem_allocated:  _.reduce(summaryList,function(memo, val) {
+                            return memo + val.memory;
+                        },0),
+                        disk_allocated:  _.reduce(summaryList,function(memo, val) {
+                            return memo + val.disk;
+                        },0)
+        });
+        
+        
+        
+    }catch(err){
+        log.error(11,err);
+        rtn = null;
+    }
+    return rtn;
+};
+
+
+OUTPUT = _.map(datacenters,function(v,k){
+    
+    var o = {
+        name: k,
+        title:k,
+        
+        cpu_used_pert: 0,
+        mem_used_pert: 0,
+        
+        cpu_total: 0,
+        cpu_allocated: 0,
+        cpu_unallocated: 0,
+        cpu_allocated_rate: 0,
+        
+        mem_total: 0,
+        mem_allocated: 0,
+        mem_unallocated: 0,
+        mem_allocated_rate: 0,
+        
+        disk_total: 0,
+        disk_allocated: 0,
+        disk_unallocated: 0,
+        disk_allocated_rate: 0,
+        
+        storage_total: 0,
+        storage_allocated: 0,
+        storage_unallocated: 0,
+        storage_allocated_rate: 0,
+        
+        server_power: 0,
+        server_x86: 0,
+        
+        severity: 0,
+        status: 0
+    };
+    
+    var dc_hosts = hostsByDc[k];
+    
+    if(_.isEmpty(dc_hosts)) {
+        return o;
+    } else{
+        var vmSummary = vmSummaryByHosts(dc_hosts);
+        
+        var cpu_total = _.reduce(dc_hosts,function(memo, val) {
+                            return memo + val.cpu;
+                        },0);
+        
+        var cpu_allocated = vmSummary.cpu_allocated;
+        var cpu_unallocated = cpu_total - cpu_allocated;
+        var cpu_allocated_rate = cpu_allocated/cpu_total * 100;
+        
+        var mem_total = _.reduce(dc_hosts,function(memo, val) {
+                            return memo + val.memory;
+                        },0);
+        var mem_allocated = vmSummary.mem_allocated;
+        var mem_unallocated = mem_total - mem_allocated;
+        var mem_allocated_rate =  mem_allocated/mem_total*100;
+        
+        var disk_total = _.reduce(dc_hosts,function(memo, val) {
+                            return memo + val.disk;
+                        },0);
+        var disk_allocated = vmSummary.disk_allocated;
+        var disk_unallocated = disk_total - disk_allocated;
+        var disk_allocated_rate = disk_total>0?disk_allocated/disk_total*100:0;
+        
+        var storage_total = 10;
+        var storage_allocated = 1;
+        var storage_unallocated = 1;
+        var storage_allocated_rate = 1;//storage_allocated/storage_total * 100;
+        
+        var server_power = _.countBy(dc_hosts,function(v){
+            return v.id.split(":")[0];
+        })
+        
+        _.extend(o,{
+            
+            cpu_used_pert: 0,
+            mem_used_pert: 0,
+            
+            cpu_total: cpu_total,
+            cpu_allocated: cpu_allocated,
+            cpu_unallocated: cpu_unallocated,
+            cpu_allocated_rate: Math.round(cpu_allocated_rate,2),
+            
+            mem_total: Math.round(mem_total/1024/1024,2),
+            mem_allocated: Math.round(mem_allocated/1024/1024,2),
+            mem_unallocated: Math.round(mem_unallocated/1024/1024,2),
+            mem_allocated_rate: Math.round(mem_allocated_rate,2),
+            
+            disk_total: Math.round(disk_total/1024/1024,2),
+            disk_allocated: Math.round(disk_allocated/1024/1024,2),
+            disk_unallocated: Math.round(disk_unallocated/1024/1024,2),
+            disk_allocated_rate: Math.round(disk_allocated_rate,2),
+            
+            storage_total: storage_total,
+            storage_allocated: storage_allocated,
+            storage_unallocated: storage_unallocated,
+            storage_allocated_rate: Math.round(storage_allocated_rate,2),
+            
+            server_power: server_power['power'],
+            server_x86: server_power['x86'],
+            
+            severity: 0,
+            status: 0,
+            
+            dc_hosts:dc_hosts
+        });
+        
+        
+        return o;    
+    }
+    
+})
+
+

+ 299 - 0
serverjs/script/cncc/应用/meta-capacitya/summaryByDc.js

@@ -0,0 +1,299 @@
+var input = decodeURIComponent(INPUT);
+
+var datacenters = (function(){
+    var rtn = {};
+    try{
+        var mql = "select id,name,datasource,org from /cncc/entity/datacenter where name='"+input+"' limit -1";
+        var tmp = odb.mql(mql).data;
+        var grouped = _.groupBy(tmp,'datasource');
+         
+        _.forEach(grouped,function(v,k){
+            
+            if(k==='NPC'){
+                var g = _.groupBy(v,'name');
+                _.forEach(g,function(vv,vk){
+                    var o = {};
+                    o[vk] = vv;
+                    _.extend(rtn,o);
+                })
+            }else{
+                var o = {};
+                o[k]=v;
+                _.extend(rtn,o);
+            }
+            
+        });
+        
+    }catch(err){
+        log.error(err);
+    }
+    return rtn;
+})();
+
+
+
+var server_power = (function(){
+    try{
+        var data = odb.mql("select count(*) from power limit -1").data;
+        return data[0].count;    
+    }catch(err){
+        return 0;
+    }
+    
+})();
+
+var server_x86 = (function(){
+    try{
+        var data = odb.mql("select count(*) from x86 limit -1").data;
+        return data[0].count;    
+    }catch(err){
+        return 0;
+    }
+})();
+
+var hostsByDc = (function(){
+    try{
+        var allHostList = [];
+        
+        var x86List = odb.mql("select id,name,cpu,memory,disk,datacenter,hypervisor,performance from x86 limit -1").data;
+        allHostList = allHostList.concat(x86List);
+        
+        var powerList = odb.mql("select id,name,cpu,memory,disk,datacenter,performance from power limit -1").data;
+        var powerListA = _.map(powerList,function(v){
+            return _.extend(v,{hypervisor:'HMC'});
+        })
+        allHostList = allHostList.concat(powerListA);
+        
+        return _.extend(_.groupBy(allHostList,'datacenter'), {"CCPC":[], "央行云":[]});
+    }catch(err){
+        log.error(err)
+        return null;
+    }
+})();
+
+
+// 统计当前DC里所有服务器的分区容量数据
+var vmSummaryByHosts = function(hosts){
+    var rtn = {};
+    try{
+        var summaryList = [];
+        
+        _.forEach(hosts,function(host){
+            var sp = host.id.split(":");
+            var classBy = sp[0]=='x86'?'linux':'aix';
+            var mql = "select id,cpu,memory,disk from "+ classBy +" where deploy='"+host.id+"' limit -1";
+            //log.info(mql)
+            var data = odb.mql(mql);
+            if(data){
+                summaryList = summaryList.concat(data.data);
+            }
+        })
+        
+        _.extend(rtn, {
+                        cpu_allocated: _.reduce(summaryList,function(memo, val) {
+                            return memo + val.cpu;
+                        },0),
+                        mem_allocated:  _.reduce(summaryList,function(memo, val) {
+                            return memo + val.memory;
+                        },0),
+                        disk_allocated:  _.reduce(summaryList,function(memo, val) {
+                            return memo + val.disk;
+                        },0)
+        });
+        
+        
+        
+    }catch(err){
+        log.error(11,err);
+        rtn = null;
+    }
+    return rtn;
+};
+
+
+// 统计当前服务器的分区容量数据
+var vmSummaryByHost = function(host){
+    var rtn = {};
+    try{
+        var summaryList = [];
+        
+        
+        var sp = host.id.split(":");
+        var classBy = sp[0]=='x86'?'linux':'aix';
+        var mql = "select id,cpu,memory,disk from "+ classBy +" where deploy='"+host.id+"' limit -1"
+        var data = odb.mql(mql);
+        
+        if(data){
+            summaryList = data.data;
+        }
+        
+        _.extend(rtn, {
+                       
+                        cpu_allocated: _.reduce(summaryList,function(memo, val) {
+                            return memo + val.cpu;
+                        },0),
+                        mem_allocated:  _.reduce(summaryList,function(memo, val) {
+                            return memo + val.memory;
+                        },0),
+                        disk_allocated:  _.reduce(summaryList,function(memo, val) {
+                            return memo + val.disk;
+                        },0)
+        });
+        
+        
+        
+    }catch(err){
+        log.error(11,err);
+        rtn = null;
+    }
+    return rtn;
+};
+
+
+OUTPUT = _.map(datacenters,function(v,k){
+    
+    var o = {
+        name: k,
+        title:k,
+        
+        cpu_used_pert: 0,
+        mem_used_pert: 0,
+        
+        cpu_total: 0,
+        cpu_allocated: 0,
+        cpu_unallocated: 0,
+        cpu_allocated_rate: 0,
+        
+        mem_total: 0,
+        mem_allocated: 0,
+        mem_unallocated: 0,
+        mem_allocated_rate: 0,
+        
+        disk_total: 0,
+        disk_allocated: 0,
+        disk_unallocated: 0,
+        disk_allocated_rate: 0,
+        
+        storage_total: 0,
+        storage_allocated: 0,
+        storage_unallocated: 0,
+        storage_allocated_rate: 0,
+        
+        server_power: 0,
+        server_x86: 0,
+        
+        severity: 0,
+        status: 0,
+        
+        hosts: []
+    };
+    
+    var dc_hosts = hostsByDc[k];
+    
+    
+    if(_.isEmpty(dc_hosts)) {
+        return o;
+    } else{
+        var vmSummary = vmSummaryByHosts(dc_hosts);
+        
+        var cpu_total = _.reduce(dc_hosts,function(memo, val) {
+                            return memo + val.cpu;
+                        },0);
+        
+        var cpu_allocated = vmSummary.cpu_allocated;
+        var cpu_unallocated = cpu_total - cpu_allocated;
+        var cpu_allocated_rate = cpu_allocated/cpu_total * 100;
+        
+        var mem_total = _.reduce(dc_hosts,function(memo, val) {
+                            return memo + val.memory;
+                        },0);
+        var mem_allocated = vmSummary.mem_allocated;
+        var mem_unallocated = mem_total - mem_allocated;
+        var mem_allocated_rate =  mem_allocated/mem_total*100;
+        
+        var disk_total = _.reduce(dc_hosts,function(memo, val) {
+                            return memo + val.disk;
+                        },0);
+        var disk_allocated = vmSummary.disk_allocated;
+        var disk_unallocated = disk_total - disk_allocated;
+        var disk_allocated_rate = disk_total>0?disk_allocated/disk_total*100:0;
+        
+        var storage_total = 10;
+        var storage_allocated = 1;
+        var storage_unallocated = 1;
+        var storage_allocated_rate = 1;//storage_allocated/storage_total * 100;
+        
+        var server_power = _.countBy(dc_hosts,function(v){
+            return v.id.split(":")[0];
+        })
+        
+        _.extend(o,{
+            
+            cpu_used_pert: 0,
+            mem_used_pert: 0,
+            
+            cpu_total: cpu_total,
+            cpu_allocated: cpu_allocated,
+            cpu_unallocated: cpu_unallocated,
+            cpu_allocated_rate: Math.round(cpu_allocated_rate,2),
+            
+            mem_total: Math.round(mem_total/1024/1024,2),
+            mem_allocated: Math.round(mem_allocated/1024/1024,2),
+            mem_unallocated: Math.round(mem_unallocated/1024/1024,2),
+            mem_allocated_rate: Math.round(mem_allocated_rate,2),
+            
+            disk_total: Math.round(disk_total/1024/1024,2),
+            disk_allocated: Math.round(disk_allocated/1024/1024,2),
+            disk_unallocated: Math.round(disk_unallocated/1024/1024,2),
+            disk_allocated_rate: Math.round(disk_allocated_rate,2),
+            
+            storage_total: storage_total,
+            storage_allocated: storage_allocated,
+            storage_unallocated: storage_unallocated,
+            storage_allocated_rate: Math.round(storage_allocated_rate,2),
+            
+            server_power: server_power['power'],
+            server_x86: server_power['x86'],
+            
+            severity: 0,
+            status: 0,
+            
+            hosts: _.map(dc_hosts,function(host){
+                        
+                        var detail = vmSummaryByHost(host);
+                        
+                        var o = {};
+                        o['cpu_total'] = host.cpu;
+                        o['mem_total'] = Math.round(host.memory/1024,2);
+                        o['disk_total'] = Math.round(host.disk/1024,2);
+                        
+                        o['cpu_allocated'] = detail.cpu_allocated;
+                        o['mem_allocated'] = Math.round((detail.mem_allocated)/1024,2);
+                        o['disk_allocated'] = Math.round((detail.disk_allocated)/1024,2);
+                        
+                        o['cpu_unallocated'] = host.cpu - detail.cpu_allocated;
+                        o['mem_unallocated'] = Math.round((host.memory - detail.mem_allocated)/1024,2);
+                        o['disk_unallocated'] = Math.round((host.disk - detail.disk_allocated)/1024,2);
+                        
+                        
+                        var perf = host.performance;
+                        if(_.isEmpty(perf)){
+                            o['cpuRate'] = 0;
+                            o['memRate'] = 0;
+                            o['diskRate'] = 0;
+                        } else{
+                            o['cpuRate'] = perf[0][2];
+                            o['memRate'] = perf[1][2];
+                            o['diskRate'] = perf[2][2];
+                        }
+                        
+                        _.extend(detail,o);
+                        return _.extend(host,detail);
+                    })
+        });
+        
+        
+        return o;    
+    }
+    
+})

+ 59 - 0
serverjs/script/cncc/应用/meta-capacitya/template/apps.js

@@ -0,0 +1,59 @@
+var hostList = (function(){
+    var rtn = null;
+    //  autofindtime	varchar	"自动发现更新时间",
+    // 	cpu				double	"CPU个数",
+    // 	cpufreq			double	"CPU频率",
+    // 	cpukernel		int	"CPU核数",
+    // 	cpumodel		varchar	"CPU型号",
+    // 	datasource		varchar	"来源平台",
+    // 	disk			double	"磁盘大小",
+    // 	diskconfig		text	"磁盘配置",
+    // 	hostid			int	"主机ID",
+    // 	hypervisor		varchar	"虚拟化管理平台",
+    // 	hytype			varchar	"服务器支持的HY类型",
+    // 	manageip		varchar	"管理IP",
+    // 	memory			double	"内存大小",
+    // 	performance		bucket 		{
+    // 			"ttl": 3,
+    // 			"type": "promdb"
+    // 	}	"performance",
+    // 	smvid				varchar	"SMVID",
+    // 	storage			double	"存储容量",
+    // 	storageconfig		text	"共享存储配置",
+    try{
+        var mql = "select id, name as title, cpu,memory,disk,manageip as name,storage,storageconfig, hypervisor from /cncc/entity/x86 limit -1";
+        var tmp = odb.mql(mql).data;
+        rtn = tmp;
+    }  catch(err){
+        log.error(err);
+    }
+    return rtn;
+    
+})();
+
+
+OUTPUT = _.map(hostList,function(v,k){
+    var round1 = Math.round(Math.random()*5);
+    var round5 = Math.round(Math.random()*10);
+    var round10 = Math.round(Math.random()*15);
+    var round15 = Math.round(Math.random()*20);
+    var round20 = Math.round(Math.random()*25);
+    var capacity = {
+        cpu_total: v.cpu,
+        cpu_allocated: round10,
+        cpu_unallocated: round15,
+        memory_total: v.memory,
+        memory_allocated: round10,
+        memory_unallocated: round15,
+        storage_total: v.disk,
+        storage_allocated: round10,
+        storage_unallocated: round15
+    };
+    var performance = {
+        cpu_usage_pert: round20,
+        mem_usage_pert: round15,
+        storage_usage_pert: round20,
+    };
+    var type = round1;
+    return _.extend(v, {severity:round5, count:round10, ctime:_.now(), capacity:capacity, performance:performance, type:type});
+});

+ 49 - 0
serverjs/script/cncc/应用/meta-capacitya/template/menus.js

@@ -0,0 +1,49 @@
+webcontext.admin(true);
+OUTPUT = [{
+    "name": "capacity",
+    "id": "capacity",
+    "title": "资源池",
+    "icon": "el-icon-office-building",
+    "group": false,
+    "children": [{
+        "id": "summary",
+        "name": "/summary",
+        "title": "整体概览",
+        "icon": "el-icon-school",
+        "group": false,
+        "children": []
+    },
+    {
+        "id": "shnpc",
+        "name": "/node/上海NPC",
+        "title": "上海NPC",
+        "icon": "el-icon-school",
+        "group": true,
+        "children": []
+    },
+    {
+        "id": "bjnpc",
+        "name": "/node/北京NPC",
+        "title": "北京NPC",
+        "icon": "el-icon-school",
+        "group": false,
+        "children": []
+    },
+    {
+        "id": "wxnpc",
+        "name": "/node/无锡NPC",
+        "title": "无锡NPC",
+        "icon": "el-icon-school",
+        "group": false,
+        "children": []
+    },
+    {
+        "id": "ccpc",
+        "name": "/node/CCPC",
+        "title": "CCPC",
+        "icon": "el-icon-school",
+        "group": false,
+        "children": []
+    }]
+}];
+webcontext.admin(false);

File diff suppressed because it is too large
+ 2 - 0
serverjs/script/cncc/应用/meta-capacitya/test.js


+ 114 - 0
serverjs/script/cncc/应用/meta-capacitya/vmListByHost.js

@@ -0,0 +1,114 @@
+var input = INPUT ?  decodeURIComponent(INPUT) : null;
+
+
+var hostList = (function(host){
+    var rtn = null;
+    //  appname			varchar	"应用系统英文名称",
+    // 	cpu				double	"CPU",
+    // 	datasource		varchar	"NPC",
+    // 	department		varchar	"所属部门",
+    // 	manageip		varchar	"管理IP",
+    // 	manageiparea	varchar	"管理IP网络区域",
+    // 	memory			double	"内存",
+    // 	node			varchar	"站点",
+    // 	org				varchar	"组织机构",
+    // 	os				varchar	"操作系统类型",
+    // 	autofindtime	varchar	"自动发现更新时间",
+    // 	osversion		varchar	"操作系统版本",
+    // 	purpose			varchar	"分区用途",
+    // 	serviceip		varchar	"服务IP",
+    // 	smvis			varchar	"SMVID",
+    // 	title			varchar	"金融大数据分析与服务平台",
+    try{
+        var sp = host.split(":")[0];
+        var classBy = sp === 'x86' ? 'linux' : 'aix';
+        var mql = "select * from "+classBy+" where deploy='"+host+"' limit -1";
+        log.info(mql)
+        var tmp = odb.mql(mql).data;
+        rtn = tmp;
+    }  catch(err){
+        log.error(err);
+    }
+    return rtn;
+    
+})(input);
+
+var columns = [
+        {field: "name", title: "主机名", width: "180"},
+        {field: "manageip", title: "管理IP", width: "120"},
+        {field: "serviceip", title: "业务IP", width: "120"},
+        
+        {field: "cpu", title: "CPU", width: "80", render: `var s=function(row, column, cellValue, index){ try {
+                                                    return '<b style="color:#000;font-size:14px;">'+cellValue+'</b>';
+                                                } catch(err) { 
+                                                    return null; 
+                                                }
+        };eval(s);`},
+        {field: "memory", title: "MEM", width: "80", render: `var s=function(row, column, cellValue, index){ try {
+                                                    return '<b style="color:#000;font-size:14px;">'+Math.round(cellValue/1024,2) + '</b>';
+                                                } catch(err) { 
+                                                    return null; 
+                                                }
+        };eval(s);`},
+        {field: "disk", title: "DISK", width: "80", render: `var s=function(row, column, cellValue, index){ try {
+                                                    return '<b style="color:#000;font-size:14px;">'+Math.round(cellValue/1024,2) + '</b>';
+                                                } catch(err) { 
+                                                    return null; 
+                                                }
+        };eval(s);`},
+        {field: "cpu_busy", title: "CPU利用率", width: "180", render: `var s=function(row, column, cellValue, index){ try {
+                                                    if(row.performance){
+                                                        return '<b style="color:#000;font-size:14px;">'+ row.performance[0][2] + '</b> ' + new Date(row.performance[0][0]).toLocaleString();    
+                                                    }else{
+                                                        return null;
+                                                    }
+                                                    
+                                                } catch(err) { 
+                                                    return null; 
+                                                }
+        };eval(s);`},
+        {field: "memRate", title: "内存使用率",visible:false,  width: "120", render: `var s=function(row, column, cellValue, index){ try {
+                                                    return cellValue;
+                                                } catch(err) { 
+                                                    return null; 
+                                                }
+        };eval(s);`},
+        {field: "diskRate", title: "磁盘利用率", visible:false, width: "120", render: `var s=function(row, column, cellValue, index){ try {
+                                                    return cellValue;
+                                                } catch(err) { 
+                                                    return null; 
+                                                }
+        };eval(s);`},
+        {field: "os", title: "操作系统", width: "120"},
+        {field: "osversion", title: "操作系统版本", width: "220"},
+        {field: "purpose", title: "用途", width: "220"},
+        {field: "severity", title: "告警级别", width: "120", render: `var s=function(row, column, cellValue, index){ 
+            try{ 
+                /* by row */
+                var el = document.querySelector('.event-console-row-'+index);
+                /* by column */
+                /* var el = document.querySelector('.event-console-row-'+index+' >.'+column.id+' > .cell');*/
+                el.style.backgroundColor = global.register.event.severity[cellValue][2];
+                el.style.color = '#ffffff';
+                el.style.textAlign = 'center';
+                return global.register.event.severity[cellValue][1]; 
+            } catch(err) { 
+                return null; 
+            }
+        };eval(s);`},
+        {field: "status", title: "状态", width: "80", render: `var s=function(row, column, cellValue, index){ try {
+                                                    return global.register.event.status[cellValue][1];
+                                                } catch(err) { 
+                                                    return null; 
+                                                }
+        };eval(s);`},
+        {field: "vtime", title: "发生时间", width: "160", render: 'var s=function(row, column, cellValue, index){return moment(cellValue).format("YYYY-MM-DD HH:mm:ss");};eval(s);', visible:false},
+        {field: "tags", title: "标签", width: "180", visible:false},
+        {field: "id", title: "ID", width: "80", visible:false},
+        {field: "class", title: "类", width: "80", visible:false}
+        
+    ];
+
+var rows = hostList;
+
+OUTPUT = {rows:rows, columns:columns};

+ 0 - 0
serverjs/script/cncc/应用/meta-event/attachment/8500809039221148163/基线告警 (2).docx


+ 0 - 0
serverjs/script/cncc/应用/meta-event/attachment/8500809039221148163/运维文档 (4)


+ 884 - 0
serverjs/script/cncc/应用/meta-event/attachment/app:demoapp3/z000000000006EJ48jwebtQR/gui-config.json

@@ -0,0 +1,884 @@
+{
+    "configs": [
+        {
+            "server": "de1-1.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u5fb7\u56fd-DE1-1,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "de1-2.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u5fb7\u56fd-DE1-2,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "de1-3.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u5fb7\u56fd-DE1-3,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "de1-4.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u5fb7\u56fd-DE1-4,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "de2-1.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u5fb7\u56fd-DE2-1,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "de2-2.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u5fb7\u56fd-DE2-2,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "de2-3.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u5fb7\u56fd-DE2-3,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "de2-4.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u5fb7\u56fd-DE2-4,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "ee1-1.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u7231\u6c99\u5c3c\u4e9a-EE1-1,\u6d41\u91cf\u500d\u7387:0.10"
+        },
+        {
+            "server": "ee1-2.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u7231\u6c99\u5c3c\u4e9a-EE1-2,\u6d41\u91cf\u500d\u7387:0.10"
+        },
+        {
+            "server": "ee1-3.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u7231\u6c99\u5c3c\u4e9a-EE1-3,\u6d41\u91cf\u500d\u7387:0.10"
+        },
+        {
+            "server": "ee1-4.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u7231\u6c99\u5c3c\u4e9a-EE1-4,\u6d41\u91cf\u500d\u7387:0.10"
+        },
+        {
+            "server": "us1-1.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u7f8e\u56fd-US1-1,\u6d41\u91cf\u500d\u7387:1.50"
+        },
+        {
+            "server": "us1-2.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u7f8e\u56fd-US1-2,\u6d41\u91cf\u500d\u7387:1.50"
+        },
+        {
+            "server": "us1-3.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u7f8e\u56fd-US1-3,\u6d41\u91cf\u500d\u7387:1.50"
+        },
+        {
+            "server": "us1-4.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u7f8e\u56fd-US1-4,\u6d41\u91cf\u500d\u7387:1.50"
+        },
+        {
+            "server": "us2-1.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u7f8e\u56fd-US2-1,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "us2-2.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u7f8e\u56fd-US2-2,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "us2-3.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u7f8e\u56fd-US2-3,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "us2-4.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u7f8e\u56fd-US2-4,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "hk1-1.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u9999\u6e2f-HK1-1,\u6d41\u91cf\u500d\u7387:0.50"
+        },
+        {
+            "server": "hk1-2.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u9999\u6e2f-HK1-2,\u6d41\u91cf\u500d\u7387:0.50"
+        },
+        {
+            "server": "hk1-3.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u9999\u6e2f-HK1-3,\u6d41\u91cf\u500d\u7387:0.50"
+        },
+        {
+            "server": "hk1-4.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u9999\u6e2f-HK1-4,\u6d41\u91cf\u500d\u7387:0.50"
+        },
+        {
+            "server": "hk1-5.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u9999\u6e2f-HK1-5,\u6d41\u91cf\u500d\u7387:0.50"
+        },
+        {
+            "server": "hk1-6.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u9999\u6e2f-HK1-6,\u6d41\u91cf\u500d\u7387:0.50"
+        },
+        {
+            "server": "hk1-7.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u9999\u6e2f-HK1-7,\u6d41\u91cf\u500d\u7387:0.50"
+        },
+        {
+            "server": "hk1-8.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u9999\u6e2f-HK1-8,\u6d41\u91cf\u500d\u7387:0.50"
+        },
+        {
+            "server": "tw1-1.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u53f0\u6e7e-TW1-1,\u6d41\u91cf\u500d\u7387:0.50"
+        },
+        {
+            "server": "tw1-2.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u53f0\u6e7e-TW1-2,\u6d41\u91cf\u500d\u7387:0.50"
+        },
+        {
+            "server": "tw1-3.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u53f0\u6e7e-TW1-3,\u6d41\u91cf\u500d\u7387:0.50"
+        },
+        {
+            "server": "tw1-4.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u53f0\u6e7e-TW1-4,\u6d41\u91cf\u500d\u7387:0.50"
+        },
+        {
+            "server": "ty1-1.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u65e5\u672c-TY1-1,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "ty1-2.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u65e5\u672c-TY1-2,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "ty1-3.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u65e5\u672c-TY1-3,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "ty1-4.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u65e5\u672c-TY1-4,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "ty2-1.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u65e5\u672c-TY2-1,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "ty2-2.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u65e5\u672c-TY2-2,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "ty2-3.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u65e5\u672c-TY2-3,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "ty2-4.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u65e5\u672c-TY2-4,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "ty2-5.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u65e5\u672c-TY2-5,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "ty2-6.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u65e5\u672c-TY2-6,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "ty2-7.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u65e5\u672c-TY2-7,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "ty2-8.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u65e5\u672c-TY2-8,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "os1-1.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u65e5\u672c-OS1-1,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "os1-2.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u65e5\u672c-OS1-2,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "os1-3.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u65e5\u672c-OS1-3,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "os1-4.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u65e5\u672c-OS1-4,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "os1-5.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u65e5\u672c-OS1-5,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "os1-6.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u65e5\u672c-OS1-6,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "os1-7.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u65e5\u672c-OS1-7,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "os1-8.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u65e5\u672c-OS1-8,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "os2-1.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u65e5\u672c-OS2-1,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "os2-2.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u65e5\u672c-OS2-2,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "os2-3.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u65e5\u672c-OS2-3,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "os2-4.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u65e5\u672c-OS2-4,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "os2-5.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u65e5\u672c-OS2-5,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "os2-6.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u65e5\u672c-OS2-6,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "os2-7.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u65e5\u672c-OS2-7,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "os2-8.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u65e5\u672c-OS2-8,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "nl1-1.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u8377\u5170-NL1-1,\u6d41\u91cf\u500d\u7387:0.50"
+        },
+        {
+            "server": "nl1-2.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u8377\u5170-NL1-2,\u6d41\u91cf\u500d\u7387:0.50"
+        },
+        {
+            "server": "nl1-3.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u8377\u5170-NL1-3,\u6d41\u91cf\u500d\u7387:0.50"
+        },
+        {
+            "server": "nl1-4.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u8377\u5170-NL1-4,\u6d41\u91cf\u500d\u7387:0.50"
+        },
+        {
+            "server": "nl1-5.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u8377\u5170-NL1-5,\u6d41\u91cf\u500d\u7387:0.50"
+        },
+        {
+            "server": "nl1-6.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u8377\u5170-NL1-6,\u6d41\u91cf\u500d\u7387:0.50"
+        },
+        {
+            "server": "nl1-7.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u8377\u5170-NL1-7,\u6d41\u91cf\u500d\u7387:0.50"
+        },
+        {
+            "server": "nl1-8.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u8377\u5170-NL1-8,\u6d41\u91cf\u500d\u7387:0.50"
+        },
+        {
+            "server": "uk1-1.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u82f1\u56fd-UK1-1,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "uk1-2.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u82f1\u56fd-UK1-2,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "uk1-3.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u82f1\u56fd-UK1-3,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "uk1-4.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u82f1\u56fd-UK1-4,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "au1-1.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u6fb3\u5927\u5229\u4e9a-AU1-1,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "au1-2.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u6fb3\u5927\u5229\u4e9a-AU1-2,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "au1-3.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u6fb3\u5927\u5229\u4e9a-AU1-3,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "au1-4.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u6fb3\u5927\u5229\u4e9a-AU1-4,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "v6-1.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u7f8e\u56fd-V6-1,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "v6-2.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u65e5\u672c-V6-2,\u6d41\u91cf\u500d\u7387:1.00"
+        },
+        {
+            "server": "v6-3.troiecloud.com",
+            "server_port": 443,
+            "password": "x4AdSgxysZffR7qX3J",
+            "tcp_fast_open": false,
+            "verify": true,
+            "verify_certificate": true,
+            "verify_hostname": true,
+            "type": "trojan",
+            "remarks": "\u9999\u6e2f-V6-3,\u6d41\u91cf\u500d\u7387:0.50"
+        }
+    ],
+    "localPort": 1080,
+    "index": 0,
+    "global": false,
+    "enabled": true,
+    "isDefault": false,
+    "socks5_address": "127.0.0.1",
+    "socks5_port": 1080,
+    "http_address": "127.0.0.1",
+    "http_port": 1081,
+    "pac_address": "127.0.0.1",
+    "pac_port": 8070
+}

BIN
serverjs/script/cncc/应用/meta-event/attachment/biz:开发测试/z000000000005N7R3YeeSISU/rule (1).png


BIN
serverjs/script/cncc/应用/meta-event/attachment/biz:开发测试/z000000000005N7R3YeeSISU/rule (2).png


BIN
serverjs/script/cncc/应用/meta-event/attachment/biz:开发测试/z000000000005N7R3YeeSISU/rule (3).png


+ 184 - 0
serverjs/script/cncc/应用/meta-event/attachment/biz:数字国网/z0000000000050znkhAEhdgY1mIFEJNw5utmO/ai-message.vue

@@ -0,0 +1,184 @@
+Vue.component("matrix-ai-message", {
+    delimiters: ['#{', '}#'],
+    props: {
+        model: Object
+    },
+    data(){
+        return {
+            message: {
+                term: "",
+                defaultSubject: [],
+                subject: [],
+                ws: null,
+            }
+        }
+    },
+    template:   `<el-container>
+                    <span slot="label">
+                        <a href="javascript:void(0);">消息 <span class="badge" style="position: absolute;background: rgb(255, 0, 0);" v-if="allMsg>0">#{allMsg}#</span></a>
+                    </span>
+                    <el-aside width="34%" style="height:100%;overflow: auto;background: transparent;">
+                        <div class="media" :class="[index==0?'selected':'']" :id="objectHash.sha1(item)" v-for="(item,index) in message.subject" style="border-bottom: 1px solid rgb(221, 221, 221);padding: 5px;cursor: pointer;margin: 0px;" @click="clickMe(item)">
+                            <div class="media-left">
+                                <span class="fas fa-circle" style="position: absolute;left:40px;color: rgb(255, 0, 0);transform: scale(.7);" v-if="item.msgs.length>0"></span>
+                                <a href="#">
+                                    <img class="media-object" :src="'/static/assets/images/robot/png/'+item.icon + '.png'" style="width: 42px;height: 42px;">
+                                </a>
+                            </div>
+                            <div class="media-body" style="text-align: left;">
+                                <h5 class="media-heading">#{item.title}#</h5>
+                                <span class="date-time">#{moment(item.vtime).format("LLL")}#</span>
+                            </div>
+                        </div>
+                    </el-aside>
+                    <el-container>
+                        <el-main style="padding:0px;text-align: center;line-height: 30px;background:rgb(228, 231, 237);overflow:hidden auto;" id="subject-msgs">
+                            <ul class="chats">
+                                <li :class="item.type" v-for="item in message.defaultSubject.msgs">
+                                    <span class="date-time">#{moment(item.ctime).format("LLL")}#</span>
+                                    <a href="javascript:;" class="name">#{item.icon}#</a>
+                                    <a href="javascript:;" class="image">
+                                        <img alt="" :src="'/static/assets/images/robot/png/'+item.icon + '.png'" style="width: 42px;height: 42px;" />
+                                    </a>
+                                    <div class="message animated pulse" contenteditable="false" style="outline:none;">
+                                        #{item.msg}#
+                                    </div>
+                                </li>
+                            </ul>
+                        </el-main>
+                        <el-footer>
+                            <div class="input-group" style="padding:5px 10px;">
+                                <input type="text" class="form-control" placeholder="消息输入" v-model="message.term" @keyup.13="sendMsg"/>
+                                <span class="input-group-btn">
+                                    <a class="btn btn-grey" href="javascript:void(0);" @click="sendMsg"><i class="fas fa-paper-plane"></i></a>
+                                </span>
+                            </div>
+                        </el-footer>
+                    </el-container>
+                </el-container>`,
+    computed: {
+        allMsg(){
+            return _.sumBy(this.message.subject,function(v){ return v.msgs.length; });
+        }
+    },
+    created: function(){
+        const self = this;
+
+        eventHub.$on("WIN-CLOSE-EVENT",self.wsClose);
+
+        // 初始化主题
+        self.message.subject = fsHandler.callFsJScript("/matrix/ai/subscribe.js", null).message;
+        
+    },
+    mounted: function(){
+        const self = this;
+        
+        // 默认主题消息
+        let item = _.first(self.message.subject);
+        let message = fsHandler.callFsJScript("/matrix/ai/getMessage.js", encodeURIComponent(JSON.stringify(item)) ).message;
+        self.message.defaultSubject = _.extend(item, {msgs:message});
+
+        // 初始化默认WS
+        self.initWs(item);
+
+        // 消息列表滚动到最底部
+        self.scrollSmoothToBottom('subject-msgs');
+
+        self.$nextTick(function(){
+            
+        })
+    },
+    destroyed: function(){
+        this.message.ws.close(self.message.ws);
+    },
+    methods: {
+        initWs(item) {
+            const self = this;
+            
+            if(this.message.ws) {
+                this.message.ws.close(this.message.ws);
+            }
+
+            try {
+                if(!this.message.ws){
+                    this.message.ws = new WebSocket(`ws://${document.location.host}/websocket/${item.subject}?source=${item.source}&title=${item.title}`);
+                }
+
+                this.message.ws.onopen = function(evt) {
+                    console.log("已打开: " + JSON.stringify(evt), self.message.ws);
+                };
+                this.message.ws.onclose = function (evt) {
+                    console.log("已关闭: " + JSON.stringify(evt));
+                };
+                this.message.ws.onerror = function (evt) {
+                    console.log("错误: " + JSON.stringify(evt));
+                };
+                this.message.ws.onmessage = function (evt) {
+                    let wsMsg = evt.data;
+                    
+                    if (wsMsg.indexOf("error") > 0) {
+                        console.log("错误: " + wsMsg.error + "\r\n");
+                    } else {
+                        console.log("收到: " + wsMsg + "\r\n");
+                        self.message.defaultSubject.msgs.push(_.merge(JSON.parse(wsMsg),{icon:'event',type:'from'}));
+                        // 消息列表滚动到最底部
+                        self.scrollSmoothToBottom('subject-msgs');
+                    }
+                };
+            } catch (err) {
+                console.error(err);
+            }
+
+        },
+        sendMessage(){
+            const self = this;
+
+            if (self.message.ws.readyState === 1) {
+                self.message.ws.send(`事件来了 ${moment().format("hh:mm:ss a")} 来自 ${self.message.wsUrl}`);
+            }
+        },
+        apply(){
+            const self = this;
+
+            if(self.message.ws){
+
+                this.ws.close(self.message.ws);
+
+                self.init();
+
+                $('#wsSetup').collapse('hide');
+            }
+        },
+        // 切换主题,获取相应消息
+        clickMe(item){
+            
+            // 选择主题效果
+            $(this.$el).find(".selected").removeClass("selected");
+            $(`#${objectHash.sha1(item)}`).addClass("selected");
+            
+            // 获取最新主题消息
+            let message = fsHandler.callFsJScript("/matrix/ai/getMessage.js", encodeURIComponent(JSON.stringify(item)) ).message;
+            this.message.defaultSubject = _.extend(item, {msgs: message});
+
+            // 接收消息
+            this.initWs(item);
+        },
+        sendMsg(){
+            
+            if(!this.message.term) return false;
+
+            this.message.defaultSubject.msgs.push({icon:'wzd', time:_.now(), msg:this.message.term, type: 'to'});
+
+            // 消息列表滚动到最底部
+            this.scrollSmoothToBottom('subject-msgs');
+
+            this.message.term = "";
+        },
+        scrollSmoothToBottom (id) {
+            var div = document.getElementById(id);
+            $('#' + id).animate({
+                scrollTop: div.scrollHeight// - div.clientHeight
+            }, 500);
+        }
+    },
+});

BIN
serverjs/script/cncc/应用/meta-event/attachment/linux:172.26.38.248/17368221814077026651/Export_2021-06-19 17_29_52.xlsx


BIN
serverjs/script/cncc/应用/meta-event/attachment/linux:node3/alert:10.216.202.66-cpuutilization-5/rule.png


+ 0 - 0
serverjs/script/cncc/应用/meta-event/attachment/pod:tomcat-pod3/alert:100.83.165.231_pot-down_5/基线告警 (2).docx


File diff suppressed because it is too large
+ 38 - 0
serverjs/script/cncc/应用/meta-event/attachment/pod:tomcat-pod3/z0000000000060znkhAEhdgY1mHVcfDjVnMLE/eif.20210602.log


BIN
serverjs/script/cncc/应用/meta-event/attachment/pod:web-demo-j6qxj/z0000000000060znkhAEhdgY1mFhr1U6hW2f3/展示系统接口说明_20180926.docx


File diff suppressed because it is too large
+ 5 - 0
serverjs/script/cncc/应用/meta-event/attachment/pod:web-demo-j6qxj/z0000000000060znkhAEhdgY1mTXRj2goMqcu/ETCD_eventbus_2021_3_24下午3_07_02.json


BIN
serverjs/script/cncc/应用/meta-event/attachment/pod:web-demo-j6qxj/z0000000000060znkhAEhdgY1mTXRj2goMqcu/pexels-juan-733475 (4).jpg


BIN
serverjs/script/cncc/应用/meta-event/attachment/pod:web-demo-j6qxj/z0000000000060znkhAEhdgY1mTXRj2goMqcu/pexels-juan-733475.jpg


+ 49 - 0
serverjs/script/cncc/应用/meta-event/contextmenu/action.js

@@ -0,0 +1,49 @@
+var input = JSON.parse(INPUT);
+
+var update = function(){
+    var rtn = null;
+    try{
+        var mql = null;
+        if(input.value == 13)
+        {
+            mql = "delete from /matrix/devops/ where id in ('"+input.id.join("','") +"')";
+        }
+        else if(input.value == 12)
+        {
+            var firstoccurrencemql = "select id,firstoccurrence from /matrix/devops/alert_status where id in ('"+input.id.join("','") +"')";
+            var firstoccurrencertn = odb.mql(firstoccurrencemql)
+            
+            _.forEach(firstoccurrencertn.data,function(v){
+                var myid = v.id;
+                var tmp = JSON.stringify(v.firstoccurrence).replace(/"\"/g,"").replace(/"/g,"");
+
+                log.info((new Date()).getTime())
+
+                log.info((new Date(tmp)).getTime())
+                var myduration =(new Date()).getTime() - (new Date(tmp)).getTime();
+                if(mql !== null)
+                {
+                    mql = mql + "\nupdate /matrix/devops/ set status = " + input.value + ",duration = "+ myduration + " where id = '"+ myid +"';";
+                }
+                else
+                {
+                    mql = "update /matrix/devops/ set status = " + input.value + ",duration = "+ myduration + " where id = '"+ myid +"';";
+                }
+            });
+            
+        }
+        else
+        {
+            mql = "update /matrix/devops/ set status= " + input.value + " where id in ('"+input.id.join("','") +"')";
+        }
+        log.info(mql)
+        rtn = odb.mql(mql);
+    }catch(err){
+        log.error(err);
+        rtn = null;
+    }
+    log.info(rtn);
+    return rtn;
+};
+
+OUTPUT = update();

+ 147 - 0
serverjs/script/cncc/应用/meta-event/contextmenu/context-menu.json

@@ -0,0 +1,147 @@
+[
+  {
+    "component": {
+      "name": "DiagnosisView"
+    },
+    "icon": "",
+    "id": 1,
+    "name": "告警分析",
+    "type": "component"
+  },
+  {
+    "icon": "",
+    "id": 11,
+    "name": "流程系统",
+    "type": "url",
+    "url": {
+      "target": "_blank",
+      "value": "http://www.baidu.com"
+    }
+  },
+  {
+    "name": "12",
+    "type": "divider"
+  },
+  {
+    "action": {
+      "name": "this.m3.callFS('/cncc/meta-faulta/contextmenu/action.js', term);",
+      "value": 10
+    },
+    "icon": "",
+    "id": 3,
+    "name": "打开",
+    "type": "action"
+  },
+  {
+    "action": {
+      "name": "this.m3.callFS('/cncc/meta-faulta/contextmenu/action.js', term);",
+      "value": 11
+    },
+    "icon": "",
+    "id": 4,
+    "name": "确认",
+    "type": "action"
+  },
+  {
+    "action": {
+      "name": "this.m3.callFS('/cncc/meta-faulta/contextmenu/action.js', term);",
+      "value": 12
+    },
+    "icon": "",
+    "id": 5,
+    "name": "关闭",
+    "type": "action"
+  },
+  {
+    "action": {
+      "name": "this.m3.callFS('/cncc/meta-faulta/contextmenu/action.js', term);",
+      "value": 13
+    },
+    "icon": "",
+    "id": 6,
+    "name": "删除",
+    "type": "action"
+  },
+  {
+    "action": {
+      "name": "this.m3.callFS('/cncc/meta-faulta/contextmenu/action.js', term);",
+      "value": 14
+    },
+    "icon": "",
+    "id": 61,
+    "name": "上报",
+    "type": "action"
+  },
+  {
+    "name": "",
+    "type": "divider"
+  },
+  {
+    "icon": "",
+    "id": 7,
+    "name": "附件",
+    "type": "attachment"
+  },
+  {
+    "id": 1620616262499,
+    "name": 1620616262499,
+    "type": "divider"
+  },
+  {
+    "action": {
+      "name": "",
+      "value": null
+    },
+    "icon": "",
+    "id": 8,
+    "name": "短信发送",
+    "type": "action"
+  },
+  {
+    "action": {
+      "name": "",
+      "value": null
+    },
+    "icon": "",
+    "id": 9,
+    "name": "邮件发送",
+    "type": "action"
+  },
+  {
+    "action": {
+      "name": "",
+      "value": null
+    },
+    "icon": "",
+    "id": 10,
+    "name": "生成工单",
+    "type": "action"
+  },
+  {
+    "id": 1620622426073,
+    "name": 1620622426073,
+    "type": "divider"
+  },
+  {
+    "icon": "",
+    "id": 11,
+    "name": "标签",
+    "type": "tag"
+  },
+  {
+    "id": 1620615628340,
+    "name": 1620615628340,
+    "type": "divider"
+  },
+  {
+    "icon": "",
+    "id": 1620616806756,
+    "name": "官网",
+    "type": "url",
+    "url": {
+      "param": "",
+      "target": "_top",
+      "value": "http://wecise.com"
+    }
+  }
+]

+ 13 - 0
serverjs/script/cncc/应用/meta-event/contextmenu/getContextMenu.js

@@ -0,0 +1,13 @@
+var getContextMenu = function(){
+    var rtn = null;
+    
+    try{
+        var tmp = dfs.read("/script/cncc/meta-faulta/contextmenu/context-menu.json");
+        rtn = JSON.parse(tmp);
+    } catch(err){
+        rtn = null;
+    }
+    return rtn;
+};
+
+OUTPUT = getContextMenu();

+ 145 - 0
serverjs/script/cncc/应用/meta-event/diagnosis/attributeRel.js

@@ -0,0 +1,145 @@
+var input = decodeURIComponent(INPUT);
+
+// 默认视图配置
+var view = (function(){
+    try{
+        var CONFIG_PATH = "/script/cncc/meta-faulta/view/config.json";
+        return JSON.parse(dfs.read(JSON.parse(dfs.read(CONFIG_PATH)).defaultView)).datasource;
+    }catch(err){
+        return null
+    }
+})();
+
+var rows = (function(){
+    var rtn = null;
+    
+    try{
+        var term = [];
+        term[0]="#"+view.class;
+        term[1]=input.replace(/"/gi,"");
+        term[2]="top 500";
+        var mql = _.compact(term).join(" | ");
+        log.debug(mql)
+        rtn = odb.search(mql).data;
+    }catch(err){
+        rtn = [];
+    }
+    return rtn;
+})();
+
+
+// 常用渲染表达式
+var render_columns = [
+    {field: "rootCause", title: "根原因", width: "80", render: `var s=function(row, column, cellValue, index){
+                try{
+                    if(cellValue == 1){
+                         var el = document.querySelector('.attributeRelEvent-row-'+index+' >.'+column.id+' > .cell');
+                         el.classList.add('el-icon-star-on','animate__animated', 'animate__flash','flash-red');
+                         el.style.color='#ff0000';
+                         el.style.fontSize='18px';
+                        return "";
+                    } else {
+                        return "";
+                    }
+                } catch(err){
+                    return "";
+                }
+            };eval(s);`},
+    {field: "severity", title: "级别", width: "80", render: `var s=function(row, column, cellValue, index){ 
+        try{ 
+            /* by row */
+            var el = document.querySelector('.attributeRelEvent-row-'+index);
+            /* by column */
+            /* var el = document.querySelector('.attributeRelEvent-row-'+index+' >.'+column.id+' > .cell');*/
+            if(row.status=='11'){
+                el.style.backgroundColor = m3.utils.adjustColor(global.register.event.severity[cellValue][2], -100);
+            }else{
+                el.style.backgroundColor = global.register.event.severity[cellValue][2];
+            }
+            el.style.color = '#ffffff';
+            el.style.textAlign = 'center';
+            return global.register.event.severity[cellValue][1]; 
+        } catch(err) { 
+            return null; 
+        }
+    };eval(s);`},
+    {field: "status", title: "状态", width: "80", render: `var s=function(row, column, cellValue, index){ try {
+                                                return global.register.event.status[cellValue][1];
+                                            } catch(err) { 
+                                                return null; 
+                                            }
+    };eval(s);`}
+];
+
+// default template
+var default_columns = 
+    [
+        {field: "rootCause", title: "根原因", width: "80", render: `var s=function(row, column, cellValue, index){
+                try{
+                    if(cellValue == 1){
+                         var el = document.querySelector('.attributeRelEvent-row-'+index+' >.'+column.id+' > .cell');
+                         el.classList.add('el-icon-star-on','animate__animated', 'animate__flash','flash-red');
+                         el.style.color='#ff0000';
+                         el.style.fontSize='18px';
+                        return "";
+                    } else {
+                        return "";
+                    }
+                } catch(err){
+                    return "";
+                }
+            };eval(s);`},
+        {field: "severity", title: "级别", width: "80", render: `var s=function(row, column, cellValue, index){ 
+            try{ 
+                /* by row */
+                var el = document.querySelector('.attributeRelEvent-row-'+index);
+                /* by column */
+                /*var el = document.querySelector('.attributeRelEvent-row-'+index+' >.'+column.id+' > .cell');*/
+                el.style.backgroundColor = global.register.event.severity[cellValue][2];
+                el.style.color = '#ffffff';
+                el.style.textAlign = 'center';
+                return global.register.event.severity[cellValue][1]; 
+            } catch(err) { 
+                return null; 
+            }
+        };eval(s);`},
+        {field: "biz", title: "业务", width: "120"},
+        {field: "app", title: "系统", width: "120"},
+        {field: "ip", title: "IP地址", width: "120"},
+        {field: "tally", title: "告警次数", width: "120"},
+        {field: "host", title: "主机名", width: "120"},
+        {field: "status", title: "状态", width: "80", render: `var s=function(row, column, cellValue, index){ try {
+                                                    return global.register.event.status[cellValue][1];
+                                                } catch(err) { 
+                                                    return null; 
+                                                }
+        };eval(s);`},
+        {field: "vtime", title: "发生时间", width: "160", render: 'var s=function(row, column, cellValue, index){return moment(cellValue).format("YYYY-MM-DD HH:mm:ss");};eval(s);'},
+        {field: "msg", title: "告警内容", width: "380"},
+        {field: "during", title: "耗时", width: "80"},
+        {field: "admin", title: "管理员", width: "80"},
+        {field: "location", title: "地点", width: "80"},
+        {field: "tags", title: "标签", width: "80"},
+        {field: "entity", title: "实体", width: "180", visible:false},
+        {field: "id", title: "ID", width: "80", visible:false},
+        {field: "class", title: "类", width: "80", visible:false}
+        
+    ];
+    
+// columns
+var columns = (function(){
+    if(view){
+        // 如果用户自定义了属性
+        if(view.fields){
+            return view.fields.concat(render_columns);
+        } else {
+            return default_columns;
+        }
+    }else{
+        return default_columns;
+    }
+})();
+
+var summary = {all: rows.length, groupbBySeverity:null};
+
+OUTPUT =  {columns:columns,rows:rows, summary:summary};

+ 12 - 0
serverjs/script/cncc/应用/meta-event/diagnosis/bitlog/getBitlogList.js

@@ -0,0 +1,12 @@
+var bitlog = function(){
+    var rtn = null;
+    try{
+        var mql = "select * from /system/bitlog";
+        rtn = odb.mql(mql).data;
+    } catch(err){
+        rtn = [];
+    }
+    return rtn;
+};
+
+OUTPUT = bitlog();

+ 38 - 0
serverjs/script/cncc/应用/meta-event/diagnosis/bitlog/getBucketByEntity.js

@@ -0,0 +1,38 @@
+var input = decodeURIComponent(INPUT);
+
+var entity = (function(){
+    var rtn = null;
+    
+    try{
+        var mql = "select * from /matrix/entity/ where id='"+ input +"'";
+        rtn = odb.mql(mql).data[0];
+        
+    }catch(err){
+        log.error(err);
+        rtn = [];
+    }
+    
+    return rtn;
+})();
+
+var getBucket = function(){
+  var rtn = null;
+  
+  try{
+      var mql = "select * from /system/bitlog where class = '"+ entity.class +"'";
+    //   log.debug(mql)
+      rtn = odb.mql(mql).data;
+      
+  }catch(err){
+      log.error(err);
+      rtn = [];
+  }
+  
+  return rtn;
+  
+};
+
+OUTPUT = { 
+            entity: [entity],
+            bucket: getBucket()
+        };

+ 28 - 0
serverjs/script/cncc/应用/meta-event/diagnosis/bitlog/searchBitlogByTerm.js

@@ -0,0 +1,28 @@
+var input = JSON.parse(decodeURIComponent(INPUT));
+
+var search = function(){
+    var rtn = null;
+    var mqlStr = "";
+    try{
+        
+        var compiled = _.template("SELECT <%= bucket%><%= key%>.time('<%= time%>')<%= words%><%= limit%> FROM <%= className%> where id='<%= id%>'");
+        
+        mqlStr = compiled({
+                bucket: input.field,
+                key: input.file?"['"+input.file+"']":'',
+                time: input.time.join("','"),
+                className: input.class,
+                id: input.id,
+                words: input.words.length>0?".find('"+input.words.join("','")+"')":'',
+                limit: '.limit(2000)'
+        });
+        log.debug(mqlStr)
+        rtn = {result:odb.mql(mqlStr).data[0][input.field],mql:mqlStr};
+        
+    }catch(err){
+        return {result:err,mql:mqlStr};
+    }
+    return rtn;
+}
+
+OUTPUT = search();

+ 19 - 0
serverjs/script/cncc/应用/meta-event/diagnosis/bitlog/searchEntityByClass.js

@@ -0,0 +1,19 @@
+var input = JSON.parse(decodeURIComponent(INPUT));
+
+var search = function(){
+    var rtn = null;
+    
+    try{
+        var mql = ["#" + input.class, "top 500"];
+        if(input.term){
+            mql = ["#" + input.class, input.term, "top 500"];
+        }
+        rtn = odb.search(mql.join(" | ")).data;
+    }catch(err){
+        rtn = [];
+    }
+    
+    return rtn;
+};
+
+OUTPUT = search();

+ 137 - 0
serverjs/script/cncc/应用/meta-event/diagnosis/eventListBySmartGroup.js

@@ -0,0 +1,137 @@
+var input = JSON.parse(decodeURIComponent(INPUT));
+
+// 默认视图配置
+var view = (function(){
+    try{
+        var CONFIG_PATH = "/script/cncc/meta-faulta/view/config.json";
+        return JSON.parse(dfs.read(JSON.parse(dfs.read(CONFIG_PATH)).defaultView)).datasource;
+    }catch(err){
+        return null
+    }
+})();
+
+var rows = (function(){
+    var rtn = null;
+    try{
+        var mql = "select * from "+view.class+" where id in ('" + input.join("','") + "')";
+        log.debug(mql)
+        rtn = odb.mql(mql).data;
+    }catch(err){
+        rtn = [];
+    }
+    return rtn;
+})();
+
+// 常用渲染表达式
+var render_columns = [
+    {field: "rootCause", title: "根原因", width: "80", render: `var s=function(row, column, cellValue, index){
+                try{
+                    if(cellValue == 1){
+                         var el = document.querySelector('.smartGroupEvent-row-'+index+' >.'+column.id+' > .cell');
+                         el.classList.add('el-icon-star-on','animate__animated', 'animate__flash','flash-red');
+                         el.style.color='#ff0000';
+                         el.style.fontSize='18px';
+                        return "";
+                    } else {
+                        return "";
+                    }
+                } catch(err){
+                    return "";
+                }
+            };eval(s);`},
+    {field: "severity", title: "级别", width: "80", render: `var s=function(row, column, cellValue, index){ 
+        try{ 
+            /* by row */
+            var el = document.querySelector('.smartGroupEvent-row-'+index);
+            /* by column */
+            /* var el = document.querySelector('.smartGroupEvent-row-'+index+' >.'+column.id+' > .cell');*/
+            if(row.status=='11'){
+                el.style.backgroundColor = m3.utils.adjustColor(global.register.event.severity[cellValue][2], -100);
+            }else{
+                el.style.backgroundColor = global.register.event.severity[cellValue][2];
+            }
+            el.style.color = '#ffffff';
+            el.style.textAlign = 'center';
+            return global.register.event.severity[cellValue][1]; 
+        } catch(err) { 
+            return null; 
+        }
+    };eval(s);`},
+    {field: "status", title: "状态", width: "80", render: `var s=function(row, column, cellValue, index){ try {
+                                                return global.register.event.status[cellValue][1];
+                                            } catch(err) { 
+                                                return null; 
+                                            }
+    };eval(s);`}
+];
+
+// default template
+var default_columns = 
+    [
+        {field: "rootCause", title: "根原因", width: "80", render: `var s=function(row, column, cellValue, index){
+                try{
+                    if(cellValue == 1){
+                         var el = document.querySelector('.smartGroupEvent-row-'+index+' >.'+column.id+' > .cell');
+                         el.classList.add('el-icon-star-on','animate__animated', 'animate__flash','flash-red');
+                         el.style.color='#ff0000';
+                         el.style.fontSize='18px';
+                        return "";
+                    } else {
+                        return "";
+                    }
+                } catch(err){
+                    return "";
+                }
+            };eval(s);`},
+        {field: "severity", title: "级别", width: "80", render: `var s=function(row, column, cellValue, index){ 
+            try{ 
+                /* by row */
+                var el = document.querySelector('.smartGroupEvent-row-'+index);
+                /* by column */
+                /*var el = document.querySelector('.row-'+index+' >.'+column.id+' > .cell');*/
+                el.style.backgroundColor = global.register.event.severity[cellValue][2];
+                el.style.color = '#ffffff';
+                el.style.textAlign = 'center';
+                return global.register.event.severity[cellValue][1]; 
+            } catch(err) { 
+                return null; 
+            }
+        };eval(s);`},
+        {field: "biz", title: "业务", width: "120"},
+        {field: "app", title: "系统", width: "120"},
+        {field: "ip", title: "IP地址", width: "120"},
+        {field: "tally", title: "告警次数", width: "120"},
+        {field: "host", title: "主机名", width: "120"},
+        {field: "status", title: "状态", width: "80", render: `var s=function(row, column, cellValue, index){ try {
+                                                    return global.register.event.status[cellValue][1];
+                                                } catch(err) { 
+                                                    return null; 
+                                                }
+        };eval(s);`},
+        {field: "vtime", title: "发生时间", width: "160", render: 'var s=function(row, column, cellValue, index){return moment(cellValue).format("YYYY-MM-DD HH:mm:ss");};eval(s);'},
+        {field: "msg", title: "告警内容", width: "380"},
+        {field: "during", title: "耗时", width: "80"},
+        {field: "admin", title: "管理员", width: "80"},
+        {field: "location", title: "地点", width: "80"},
+        {field: "tags", title: "标签", width: "80"},
+        {field: "entity", title: "实体", width: "180", visible:false},
+        {field: "id", title: "ID", width: "80", visible:false},
+        {field: "class", title: "类", width: "80", visible:false}
+        
+    ];
+    
+// columns
+var columns = (function(){
+    if(view){
+        // 如果用户自定义了属性
+        if(view.fields){
+            return view.fields.concat(render_columns);
+        } else {
+            return default_columns;
+        }
+    }else{
+        return default_columns;
+    }
+})();
+
+OUTPUT =  {columns:columns,rows:rows};

+ 12 - 0
serverjs/script/cncc/应用/meta-event/diagnosis/getBitlogList.js

@@ -0,0 +1,12 @@
+var bitlog = function(){
+    var rtn = null;
+    try{
+        var mql = "select * from /system/bitlog";
+        rtn = odb.mql(mql).data;
+    } catch(err){
+        rtn = [];
+    }
+    return rtn;
+};
+
+OUTPUT = bitlog();

+ 148 - 0
serverjs/script/cncc/应用/meta-event/diagnosis/history.js

@@ -0,0 +1,148 @@
+var input = decodeURIComponent(INPUT);
+
+// 默认视图配置
+var view = (function(){
+    try{
+        var CONFIG_PATH = "/script/cncc/meta-faulta/view/config.json";
+        return JSON.parse(dfs.read(JSON.parse(dfs.read(CONFIG_PATH)).defaultView)).datasource;
+    }catch(err){
+        return null
+    }
+})();
+
+var rows = (function(){
+    var rtn = null;
+    
+    try{
+        var term = [];
+        // 不能增加#,查询版本数据
+        term[0]=view.class;
+        term[1]=input.replace(/"/gi,"");
+        term[2]="top 5000";
+        var mql = _.compact(term).join(" | ");
+        log.debug(mql)
+        rtn = odb.search(mql).data;
+    }catch(err){
+        rtn = [];
+    }
+    return rtn;
+})();
+
+
+// 常用渲染表达式
+var render_columns = [
+    {field: "rootCause", title: "根原因", width: "80", render: `var s=function(row, column, cellValue, index){
+                try{
+                    if(cellValue == 1){
+                         var el = document.querySelector('.historySameEvent-row-'+index+' >.'+column.id+' > .cell');
+                         el.classList.add('el-icon-star-on','animate__animated', 'animate__flash','flash-red');
+                         el.style.color='#ff0000';
+                         el.style.fontSize='18px';
+                        return "";
+                    } else {
+                        return "";
+                    }
+                } catch(err){
+                    return "";
+                }
+            };eval(s);`},
+    {field: "severity", title: "级别", width: "80", render: `var s=function(row, column, cellValue, index){ 
+        try{ 
+            /* by row */
+            var el = document.querySelector('.historySameEvent-row-'+index);
+            /* by column */
+            /* var el = document.querySelector('.historySameEvent-row-'+index+' >.'+column.id+' > .cell');*/
+            if(row.status=='11'){
+                el.style.backgroundColor = m3.utils.adjustColor(global.register.event.severity[cellValue][2], -100);
+            }else{
+                el.style.backgroundColor = global.register.event.severity[cellValue][2];
+            }
+            el.style.color = '#ffffff';
+            el.style.textAlign = 'center';
+            return global.register.event.severity[cellValue][1]; 
+        } catch(err) { 
+            return null; 
+        }
+    };eval(s);`},
+    {field: "status", title: "状态", width: "80", render: `var s=function(row, column, cellValue, index){ try {
+                                                return global.register.event.status[cellValue][1];
+                                            } catch(err) { 
+                                                return null; 
+                                            }
+    };eval(s);`}
+];
+
+// default template
+var default_columns = 
+    [
+        {field: "rootCause", title: "根原因", width: "80", render: `var s=function(row, column, cellValue, index){
+                try{
+                    if(cellValue == 1){
+                         var el = document.querySelector('.historySameEvent-row-'+index+' >.'+column.id+' > .cell');
+                         el.classList.add('el-icon-star-on','animate__animated', 'animate__flash','flash-red');
+                         el.style.color='#ff0000';
+                         el.style.fontSize='18px';
+                        return "";
+                    } else {
+                        return "";
+                    }
+                } catch(err){
+                    return "";
+                }
+            };eval(s);`},
+        {field: "severity", title: "级别", width: "80", render: `var s=function(row, column, cellValue, index){ 
+            try{ 
+                /* by row */
+                var el = document.querySelector('.historySameEvent-row-'+index);
+                /* by column */
+                /*var el = document.querySelector('.historySameEvent-row-'+index+' >.'+column.id+' > .cell');*/
+                el.style.backgroundColor = global.register.event.severity[cellValue][2];
+                el.style.color = '#ffffff';
+                el.style.textAlign = 'center';
+                return global.register.event.severity[cellValue][1]; 
+            } catch(err) { 
+                return null; 
+            }
+        };eval(s);`},
+        {field: "biz", title: "业务", width: "120"},
+        {field: "app", title: "系统", width: "120"},
+        {field: "ip", title: "IP地址", width: "120"},
+        {field: "tally", title: "告警次数", width: "120"},
+        {field: "host", title: "主机名", width: "120"},
+        {field: "status", title: "状态", width: "80", render: `var s=function(row, column, cellValue, index){ try {
+                                                    return global.register.event.status[cellValue][1];
+                                                } catch(err) { 
+                                                    return null; 
+                                                }
+        };eval(s);`},
+        {field: "vtime", title: "发生时间", width: "160", render: 'var s=function(row, column, cellValue, index){return moment(cellValue).format("YYYY-MM-DD HH:mm:ss");};eval(s);'},
+        {field: "msg", title: "告警内容", width: "380"},
+        {field: "during", title: "耗时", width: "80"},
+        {field: "admin", title: "管理员", width: "80"},
+        {field: "location", title: "地点", width: "80"},
+        {field: "tags", title: "标签", width: "80"},
+        {field: "entity", title: "实体", width: "180", visible:false},
+        {field: "id", title: "ID", width: "80", visible:false},
+        {field: "class", title: "类", width: "80", visible:false}
+        
+    ];
+    
+// columns
+var columns = (function(){
+    if(view){
+        // 如果用户自定义了属性
+        if(view.fields){
+            return view.fields.concat(render_columns);
+        } else {
+            return default_columns;
+        }
+    }else{
+        return default_columns;
+    }
+})();
+
+var summary = {all: rows.length, groupbBySeverity:null};
+
+OUTPUT =  {columns:columns,rows:rows, summary:summary};
+
+

+ 16 - 0
serverjs/script/cncc/应用/meta-event/diagnosis/journal.js

@@ -0,0 +1,16 @@
+var input = JSON.parse(decodeURIComponent(INPUT));
+
+var journal = function(){
+    var rtn = null;
+    try{
+        var mql = "select * from /matrix/ where id='"+input.id+"'  order by vtime desc with version limit 100";
+        var tmp = odb.mql(mql).data;
+        rtn = tmp;
+    }catch(err){
+        rtn = null;
+    }
+    
+    return rtn;
+};
+
+OUTPUT = journal();

+ 27 - 0
serverjs/script/cncc/应用/meta-event/diagnosis/searchBitlogByTerm.js

@@ -0,0 +1,27 @@
+var input = JSON.parse(decodeURIComponent(INPUT));
+
+var search = function(){
+    var rtn = null;
+    var mqlStr = "";
+    try{
+        
+        var compiled = _.template("SELECT <%= bucket%><%= key%>.time('<%= time%>')<%= words%> FROM <%= className%> where id='<%= id%>'");
+        
+        mqlStr = compiled({
+                bucket: input.field,
+                key: input.file?"['"+input.file+"']":'',
+                time: input.time.join("','"),
+                className: input.class,
+                id: input.id,
+                words: input.words.length>0?".find('"+input.words.join("','")+"')":''
+        });
+        
+        rtn = {result:odb.mql(mqlStr).data[0][input.field],mql:mqlStr};
+        
+    }catch(err){
+        return {result:err,mql:mqlStr};
+    }
+    return rtn;
+}
+
+OUTPUT = search();

+ 19 - 0
serverjs/script/cncc/应用/meta-event/diagnosis/searchEntityByClass.js

@@ -0,0 +1,19 @@
+var input = JSON.parse(decodeURIComponent(INPUT));
+
+var search = function(){
+    var rtn = null;
+    
+    try{
+        var mql = ["#" + input.class, "top 500"];
+        if(input.term){
+            mql = ["#" + input.class, input.term, "top 500"];
+        }
+        rtn = odb.search(mql.join(" | ")).data;
+    }catch(err){
+        rtn = [];
+    }
+    
+    return rtn;
+};
+
+OUTPUT = search();

+ 89 - 0
serverjs/script/cncc/应用/meta-event/diagnosis/smartGroup.js

@@ -0,0 +1,89 @@
+var input = JSON.parse(decodeURIComponent(INPUT));
+
+// 默认视图配置
+var view = (function(){
+    try{
+        var CONFIG_PATH = "/script/cncc/meta-faulta/view/config.json";
+        return JSON.parse(dfs.read(JSON.parse(dfs.read(CONFIG_PATH)).defaultView)).datasource;
+    }catch(err){
+        log.error(err)
+        return null
+    }
+})();
+
+// 获取事件列表
+var eventListByGroup = (function(){
+    var rtn = null;
+    try {
+        var mqlStr = "#"+view.class+" | " + input.join(";") + " | entity!=null | status<12 | print id, biz, severity, entity | group  with topo | top 1000";
+        log.debug(mqlStr)
+        rtn = odb.search(mqlStr).data[0];
+    }catch(err){
+        log.error(err)
+    }
+    return rtn;
+})();
+
+
+// rows
+var rows = _.sortBy(_.map(eventListByGroup,function(v,k){
+    
+    var s5 = _.filter(v,function(v){
+        if(v.severity >= 5){
+            return v;
+        }
+    }).length;
+    var s4 =  _.where(v,{severity:4}).length;
+    var s3 =  v.length - s5 - s4;
+    return { 
+                type: 1, 
+                group: Number(k) < 10 ? '分组0'+k : '分组'+k, 
+                app: _.uniq(_.chain(v).where('biz').map('biz').value()).join(" "), 
+                severity: [s5,s4,s3], 
+                ids: _.chain(v).where('id').map('id').value().join(";"),
+                list: v
+    };
+        
+}),'group');
+
+// datatable列名
+var columns = [
+                {field:'type',title:'类型', width:'80', render: `var s=function(row, column, cellValue, index){
+                            return cellValue==1?'自动分组':'手动分组';
+                        };eval(s);`,visible: false},
+                {field:'group',title:'分组名称',width:'120'},
+                {field:'app',title:'影响应用系统', width:'140'},
+                {field:'severity',title:'告警级别统计', width:'120', render:`var s = function(row, column, cellValue, index){
+                    return '<a href="javascript:void(0);" class="btn btn-link" style="width:30px;padding: 2px 4px;background:'+global.register.event.severity[5][2]+'">'+cellValue[0]+'</a>
+                        <a href="javascript:void(0);" class="btn btn-link" style="width:30px;padding: 2px 4px;background:'+global.register.event.severity[4][2]+'">'+cellValue[1]+'</a>
+                        <a href="javascript:void(0);" class="btn btn-link" style="width:30px;padding: 2px 4px;background:'+global.register.event.severity[3][2]+'">'+cellValue[2]+'</a>';};eval(s);`
+                },
+                {field:'ids',title:'IDS', width:'80', visible: false}
+        ];
+
+
+var template = [
+                {field:'type',title:'类型', width:'80', render: `var s=function(row, column, cellValue, index){
+                             return cellValue==1?'自动分组':'手动分组';
+                        };eval(s);`,visible: false},
+                {field:'group',title:'分组名称',width:'120'},
+                {field:'app',title:'影响应用系统', width:'140'},
+                {field:'severity',title:'告警级别统计', width:'120', render:`var s = function(row, column, cellValue, index){
+                    return '<a href="javascript:void(0);" class="btn btn-link" style="width:30px;padding: 2px 4px;background:'+global.register.event.severity[5][2]+'">'+cellValue[0]+'</a>
+                        <a href="javascript:void(0);" class="btn btn-link" style="width:30px;padding: 2px 4px;background:'+global.register.event.severity[4][2]+'">'+cellValue[1]+'</a>
+                        <a href="javascript:void(0);" class="btn btn-link" style="width:30px;padding: 2px 4px;background:'+global.register.event.severity[3][2]+'">'+cellValue[2]+'</a>';};eval(s);`
+                },
+                {field:'ids',title:'IDS', width:'80', visible: false}
+    ];
+
+
+var summary = {all: rows.length, groupbBySeverity:null};
+
+var rtn = {
+    rows: rows,
+    columns: columns,
+    template: template,
+    summary:summary
+};
+
+OUTPUT = rtn;

File diff suppressed because it is too large
+ 4 - 0
serverjs/script/cncc/应用/meta-event/diagnosis/test.js


+ 39 - 0
serverjs/script/cncc/应用/meta-event/diagnosis/tsdb/getBucketByEntity.js

@@ -0,0 +1,39 @@
+var input = decodeURIComponent(INPUT);
+
+var entity = (function(){
+    var rtn = null;
+    
+    try{
+        var mql = "select * from /matrix/entity/ where id='"+ input +"'";
+        log.debug(mql)
+        rtn = odb.mql(mql).data[0];
+        
+    }catch(err){
+        log.error(err);
+        rtn = [];
+    }
+    
+    return rtn;
+})();
+
+var getBucket = function(){
+  var rtn = null;
+  
+  try{
+      var mql = "select * from /system/tsdb where class = '"+ entity.class +"'";
+      log.debug(mql)
+      rtn = odb.mql(mql).data;
+      
+  }catch(err){
+      log.error(err);
+      rtn = [];
+  }
+  
+  return rtn;
+  
+};
+
+OUTPUT = { 
+            entity: [entity],
+            bucket: getBucket()
+        };

+ 11 - 0
serverjs/script/cncc/应用/meta-event/diagnosis/tsdb/getClassNameById.js

@@ -0,0 +1,11 @@
+var input = decodeURIComponent(INPUT);
+
+var getClassName = function(){
+    try{
+        return odb.mql("select class('"+input+"') from /").data[0].class;
+    } catch(err){
+        return null
+    }
+}
+
+OUTPUT = getClassName();

+ 65 - 0
serverjs/script/cncc/应用/meta-event/diagnosis/tsdb/getClassNumberStringKeysByClassName.js

@@ -0,0 +1,65 @@
+var input = JSON.parse(decodeURIComponent(INPUT));
+
+// 查出指定类的bucket属性
+var classKeysList = function(){
+    try{
+        var rtn = _.filter(_.map(odb.classfields(input.class),function(v){
+            // 获取bucket属性
+            //  && !v.Name.match(/_baseline/)
+            if(v.Btype == 'tsdb' && v.Name && v.Ftype == 'bucket'){
+                
+                var subKeys = [];
+                var subKeysMql = "";
+                // 获取子对象
+                // 根据index查看是否有crc定义
+                var item = v.Params[v['CRC']];
+                if(!_.isEmpty(item)){
+                    // 子对象
+                    subKeys = getSubObj(v.Name, item.Name).result;
+                    // debug用
+                    subKeysMql = getSubObj(v.Name, item.Name).mql;
+                }
+                
+                var params = _.filter(_.map(v.Params,function(val,idx){
+                    if(val.Type != 'string'){
+                        return {value: val.Name, label:val.Name, ftype:val.Type, unit: val.Unit?val.Unit:"" };
+                    }
+                    
+                }),null);
+                
+                return {value: v.Name, label: v.Name, ftype: v.Ftype, children:params, subKeys: subKeys, trace: subKeysMql};
+            }
+        }),null);
+        return rtn;
+    } catch(err){
+        return err;
+    }
+};
+
+
+// 获取子对象
+// meta中定义的crc,指定了哪个bucket属性有子对象
+// SELECT id,disk1_perf[1].time('2020-06-01','').distinct() FROM /matrix/entity/it/it_aix where id='it_aix:192.168.190.175'
+var getSubObj  = function(bucket,bucketKey){
+    
+    var mql = "";
+    
+    try{
+        // 当月
+        var current_month = new Date().toISOString().slice(0, 7);
+        
+        mql = "SELECT "+bucket+"['"+bucketKey+"'].time('"+current_month+"','').distinct() FROM "+input.class+" where id='"+input.entity+"'";
+        
+        var rtn = _.map(_.flatten(odb.mql(mql).data[0][bucket]),function(v){
+            return  {name:v, value: bucketKey+"='"+v+"'"};
+        });
+        
+        return {result:rtn, mql:mql};
+        
+    } catch(err){
+        return {result:[], mql:mql};;
+    }
+    
+}
+
+OUTPUT = classKeysList();

+ 12 - 0
serverjs/script/cncc/应用/meta-event/diagnosis/tsdb/getTsdbList.js

@@ -0,0 +1,12 @@
+var tsdb = function(){
+    var rtn = null;
+    try{
+        var mql = "select * from /system/tsdb";
+        rtn = odb.mql(mql).data;
+    } catch(err){
+        rtn = [];
+    }
+    return rtn;
+};
+
+OUTPUT = tsdb();

+ 19 - 0
serverjs/script/cncc/应用/meta-event/diagnosis/tsdb/searchEntityByClass.js

@@ -0,0 +1,19 @@
+var input = JSON.parse(decodeURIComponent(INPUT));
+
+var search = function(){
+    var rtn = null;
+    
+    try{
+        var mql = ["#" + input.class, "top 500"];
+        if(input.term){
+            mql = ["#" + input.class, input.term, "top 500"];
+        }
+        rtn = odb.search(mql.join(" | ")).data;
+    }catch(err){
+        rtn = [];
+    }
+    
+    return rtn;
+};
+
+OUTPUT = search();

+ 42 - 0
serverjs/script/cncc/应用/meta-event/diagnosis/tsdb/searchPerformanceByTerm.js

@@ -0,0 +1,42 @@
+var input = JSON.parse(decodeURIComponent(INPUT));
+
+var search = function(){
+    var rtn = null;
+    var mqlStr = "";
+    try{
+        
+        // 有子对象
+        if(input.defaultSubKey){
+            var compiled = _.template("SELECT <%= bucket%>['<%= key%>'].time('<%= time%>').find(<%= defaultSubKey%>) FROM <%= className%> where id='<%= id%>'");
+        
+            mqlStr = compiled({
+                    bucket: input.bucket,
+                    key: input.key,
+                    time: input.time.join("','"),
+                    className: input.class,
+                    id: input.id,
+                    defaultSubKey: input.defaultSubKey
+            }); 
+        } 
+        // 没有子对象
+        else{
+            var compiled = _.template("SELECT <%= bucket%>['<%= key%>'].time('<%= time%>') FROM <%= className%> where id='<%= id%>'");
+        
+            mqlStr = compiled({
+                    bucket: input.bucket,
+                    key: input.key,
+                    time: input.time.join("','"),
+                    className: input.class,
+                    id: input.id
+            });
+        }
+        
+        
+        rtn = {result:odb.mql(mqlStr).data[0][input.bucket],mql:mqlStr};
+    }catch(err){
+        return {result:err,mql:mqlStr};
+    }
+    return rtn;
+}
+
+OUTPUT = search();

+ 303 - 0
serverjs/script/cncc/应用/meta-event/event_list.js

@@ -0,0 +1,303 @@
+
+var input = JSON.parse(decodeURIComponent(INPUT));
+
+var TEMPLATE_PATH = "/script/cncc/meta-faulta/view/template/"
+var TRACE = "";
+// 是否启用root cause
+var ROOT_CAUSE=false;
+
+// 获取视图配置
+var view = (function(){
+    var rtn = null;
+    try{
+        return JSON.parse(dfs.read(TEMPLATE_PATH + input.view + ".json"));
+    }catch(err){
+        log.error(err);
+        return null;
+    }
+})();
+
+// 事件统计
+var summary = (function(){
+    try {
+        var term = [];
+        var param = [];
+        
+        if(view.datasource.class) {
+            term[0]="#"+view.datasource.class;
+        }
+        
+        if(view.datasource.filter) {
+            term.push(view.datasource.filter);
+        }
+        
+        if(view.datasource.top) {
+            term.push("top " + view.datasource.top);
+        }
+        
+        term.push(" print id, severity");
+        
+        var tmp = _.compact(term).join(" | ");
+        
+        tmp.split("|").forEach(function(v,idx){
+            if(v.indexOf("top") > -1){
+                param[10]=v;
+            } else {
+                param[idx]=v;
+            }
+        })
+        
+        var summaryStr = _.compact(param).join(" | ");
+        var summary = {all:0, groupBySeverity:{}};
+        
+        log.info(summaryStr);
+        var result = odb.search(summaryStr).data || [];
+        
+        // All
+        summary.all = result.length;
+        
+        // Group by Severity
+        _.forEach(_.groupBy(result,'severity'),function(v,k){
+            var o = {};
+            o[k] = v.length;
+            _.extend(summary.groupBySeverity, o);
+            return o;
+        });
+        
+        return summary;
+        ;
+    }catch(err){
+        log.error(err);
+        return null;
+    }
+})();
+
+// 获取事件列表
+var eventList = (function(){
+    try {
+        var term = [];
+        var param = [];
+        
+        if(view.datasource.class) {
+            term[0]="#"+view.datasource.class;
+        }
+        
+        if(view.datasource.filter) {
+            term.push(view.datasource.filter);
+        }
+        
+        if(view.datasource.top) {
+            term.push("top " + view.datasource.top);
+        }
+        
+        if(!_.isEmpty(term)){
+            term.push(input.term);
+        }
+        
+        // var fields = " print entity,vtime,status,severity, " + _.map(view.datasource.fields,'field').join(", ");
+        // log.info(2,fields)
+        // term.push(fields);
+        
+        
+        var tmp = _.compact(term).join(" | ");
+        
+        tmp.split("|").forEach(function(v,idx){
+            if(v.indexOf("top") > -1){
+                param[10]=v;
+            } else {
+                param[idx]=v;
+            }
+        })
+        
+        var termStr = _.compact(param).join(" | ");
+        
+        TRACE = termStr;
+        
+        return odb.search(termStr);     
+    }catch(err){
+        log.error(err);
+        return null;
+    }
+})();
+
+// 根原因查找实例
+var rootCauseList = (function(){
+    
+    if(!ROOT_CAUSE) return false;
+    
+    try {
+        var currentAlerts = odb.mql("select distinct entity from " + view.datasource.class + " where severity>3 limit -1").data;
+        var entityIDs = "";
+        _.forEach(currentAlerts,function(v){
+            entityIDs=entityIDs+"'"+ v.entity + "',"
+        })
+                
+        var reg=/,$/gi;
+        
+        var content = graphalg.endpoints("match (" + entityIDs.replace(reg,"") + ")-[*]->(" + entityIDs.replace(reg,"") + ")");
+        
+        return content;
+    } catch(err){
+        return null;
+    }
+    
+})();
+
+// rows
+var rows = (function(){
+    
+    if(_.isEmpty(eventList)) return [];
+    
+    try{
+         if(ROOT_CAUSE){
+            return _.sortBy(_.map(eventList.data,function(v){
+                    return _.extend(v, {rootCause: (_.include(rootCauseList,v.entity) && v.severity > 3)?1:0} );
+                }), function(v){
+                return v.rootCause * -1;
+            }); 
+        } else {
+            return  _.sortBy(eventList.data,function(v){
+                    return v.rootCause * -1;
+                });
+        }
+    } catch(err){
+        return _.sortBy(eventList.data,function(v){
+                    return v.rootCause * -1;
+                });
+    }
+    
+})();
+
+// 常用渲染表达式
+var render_columns = [
+    {field: "rootCause", title: "根原因", width: "80", render: `var s=function(row, column, cellValue, index){
+                try{
+                    if(cellValue == 1){
+                         var el = document.querySelector('.event-console-row-'+index+' >.'+column.id+' > .cell');
+                         el.classList.add('el-icon-star-on','animate__animated', 'animate__flash','flash-red');
+                         el.style.color='#ff0000';
+                         el.style.fontSize='18px';
+                        return "";
+                    } else {
+                        return "";
+                    }
+                } catch(err){
+                    return "";
+                }
+            };eval(s);`},
+    {field: "severity", title: "级别", width: "80", render: `var s=function(row, column, cellValue, index){ 
+        try{ 
+            /* by row */
+            var el = document.querySelector('.event-console-row-'+index);
+            /* by column */
+            /* var el = document.querySelector('.event-console-row-'+index+' >.'+column.id+' > .cell');*/
+            if(row.status==11){
+                el.style.backgroundColor = m3.utils.adjustColor(global.register.event.severity[cellValue][2], -100);
+            }else{
+                el.style.backgroundColor = global.register.event.severity[cellValue][2];
+            }
+            
+            el.style.color = m3.utils.adjustColor(global.register.event.severity[cellValue][2], 1000);;
+            el.style.textAlign = 'center';
+            return global.register.event.severity[cellValue][1]; 
+        } catch(err) {
+            return null; 
+        }
+    };eval(s);`},
+    {field: "status", title: "状态", width: "80", render: `var s=function(row, column, cellValue, index){ try {
+                                                return global.register.event.status[cellValue][1];
+                                            } catch(err) { 
+                                                return null; 
+                                            }
+    };eval(s);`}
+];
+
+// default template
+var default_columns = 
+    [
+        {field: "rootCause", title: "根原因", width: "80", render: `var s=function(row, column, cellValue, index){
+                try{
+                    if(cellValue == 1){
+                         var el = document.querySelector('.event-console-row-'+index+' >.'+column.id+' > .cell');
+                         el.classList.add('el-icon-star-on','animate__animated', 'animate__flash','flash-red');
+                         el.style.color='#ff0000';
+                         el.style.fontSize='18px';
+                        return "";
+                    } else {
+                        return "";
+                    }
+                } catch(err){
+                    return "";
+                }
+            };eval(s);`},
+        {field: "severity", title: "级别", width: "80", render: `var s=function(row, column, cellValue, index){ 
+            try{ 
+                /* by row */
+                var el = document.querySelector('.event-console-row-'+index);
+                /* by column */
+                /* var el = document.querySelector('.event-console-row-'+index+' >.'+column.id+' > .cell');*/
+                el.style.backgroundColor = global.register.event.severity[cellValue][2];
+                el.style.color = '#ffffff';
+                el.style.textAlign = 'center';
+                return global.register.event.severity[cellValue][1]; 
+            } catch(err) { 
+                return null; 
+            }
+        };eval(s);`},
+        {field: "biz", title: "业务", width: "120"},
+        {field: "app", title: "系统", width: "120"},
+        {field: "ip", title: "IP地址", width: "120"},
+        {field: "tally", title: "告警次数", width: "120"},
+        {field: "host", title: "主机名", width: "120"},
+        {field: "status", title: "状态", width: "80", render: `var s=function(row, column, cellValue, index){ try {
+                                                    return global.register.event.status[cellValue][1];
+                                                } catch(err) { 
+                                                    return null; 
+                                                }
+        };eval(s);`},
+        {field: "vtime", title: "发生时间", width: "160", render: 'var s=function(row, column, cellValue, index){return moment(cellValue).format("YYYY-MM-DD HH:mm:ss");};eval(s);'},
+        {field: "msg", title: "告警内容", width: "380"},
+        {field: "during", title: "耗时", width: "80"},
+        {field: "admin", title: "管理员", width: "80"},
+        {field: "location", title: "地点", width: "80"},
+        {field: "tags", title: "标签", width: "180"},
+        {field: "entity", title: "实体", width: "180", visible:false},
+        {field: "id", title: "ID", width: "80", visible:false},
+        {field: "class", title: "类", width: "80", visible:false}
+        
+    ];
+    
+// columns
+var columns = (function(){
+    if(eventList && view.datasource){
+        // 如果用户自定义了属性
+        if(view.datasource.fields){
+            return _.map(view.datasource.fields,function(v){
+                var p = _.find(render_columns,{field:v.field});
+                if(p){
+                    return _.extend(v,p);
+                }else{
+                    return v;
+                }
+            });
+        } else {
+            if(view.datasource.class){
+                return eventList.meta.columns[view.datasource.class];   
+            }
+        }
+    }else{
+        return default_columns;
+    }
+})();
+
+var notify = (function(){
+    return summary.groupBySeverity[3] + summary.groupBySeverity[4] + summary.groupBySeverity[5];
+})();
+    
+OUTPUT = {
+            rows: rows,
+            columns: columns,
+            summary: summary,
+            notify: notify,
+            trace: TRACE
+        };

+ 3 - 0
serverjs/script/cncc/应用/meta-event/graph/config.json

@@ -0,0 +1,3 @@
+{
+    "match": "match ('<%= ids %>') union ('<%= ids %>') <-[*1]-() union () <- [*1] - ('<%= ids %>')"
+}

+ 5 - 0
serverjs/script/cncc/应用/meta-event/graph/edges.js

@@ -0,0 +1,5 @@
+var s = function(){
+    return _.sortBy([].concat([{name:"", remedy: "所有"}],odb.mql("select * from /system/relation").data),"name");
+}
+
+OUTPUT = s();

+ 147 - 0
serverjs/script/cncc/应用/meta-event/graph/graphService.js

@@ -0,0 +1,147 @@
+var input = decodeURIComponent(INPUT).trim();
+
+var words = [
+    '查询所有应用的关联信息',
+    '查询应用wecise的关联信息',
+    '查询所有业务的关联信息',
+    '查询查账系统的关联信息',
+    '数字国网的关联信息',
+    '运行在linux服务器wecise上的服务',
+            'cassandra',
+            '集群',
+            'DB2',
+            'vmware',
+            'etcd',
+            'HA',
+            'http',
+            'linux',
+            'mysql',
+            '队列',
+            'oracle',
+            'pod',
+            '路由器',
+            'san存储',
+            'san交换机',
+            '交换机',
+            'tomcat',
+            'weblogic'
+];
+var syntax = [
+    'match ("app:*") <- [*1]-()',
+    'match ("app:web_wecise") - [*1]->()',
+    'match ("biz:*") - [*1]->()',
+    'match ("biz:查账系统") - [*1]->()',
+    'match ("biz:数字国网") - [*1]->()',
+    'match ()-[*]->("linux:wecise")',
+                'cassandra',
+                'cluster',
+                'db2',
+                'esx',
+                'etcd',
+                'ha',
+                'http',
+                'linux',
+                'mysql',
+                'nats',
+                'oracle',
+                'pod',
+                'router',
+                'sanstorage',
+                'sanswitch',
+                'switch',
+                'tomcat',
+                'weblogic'
+];
+
+// 根据ID获取实体信息
+var getEntity = function(ids){
+    
+    try {
+        return odb.mql("select id,class,name from /matrix/entity/ where id in " + ids + " limit -1").data;
+    } catch(err){
+        return []
+    }
+}
+
+var bak = (function(){
+    var template = [{
+                  "graph": {
+                    "nodes": [],
+                    "edges": [],
+                    "paths": null,
+                    "diff": null,
+                    "pathtags": null
+                  }
+                }];
+    try{
+        var tmp = input.slice(input.indexOf("(")+1,input.indexOf(")")).replace(/"/g,"").split(",");
+        var nodes = getEntity("('"+tmp.join("','")+"')");
+        
+        return  [{graph:_.extend(template[0].graph, {nodes:_.map(nodes,function(v){
+                    return {_icon: _.last(v.class.split("/")),class: v.class, id: v.id};
+                })})}]
+    }catch(err){
+        return [];
+    }
+})()
+
+
+//hashcode
+var hashCode = function(str){
+    return str.split("").reduce(function(a,b){a=((a<<5)-a)+b.charCodeAt(0);return a&a},0);
+}
+
+log.info(input)
+var s = (function(param){
+    var rtn = null;
+    try{
+        
+        var idx = -1;
+        
+        _.forEach(words,function(v,index){
+            if(v.search(input) != -1){
+                idx = index;
+            }
+        })
+        
+        if(idx == -1){
+            log.info(param)
+            rtn = odb.mql(param).data;    
+        } else {
+            rtn = odb.mql(syntax[idx]).data;
+        }
+        
+        
+        if(_.isEmpty(rtn)){
+            rtn = bak;
+        }
+    } catch(err){
+        rtn = bak;
+    } finally{
+        // try{
+        //     // 缓存搜索语句
+        //     var name = hashCode(input);
+        //     var account = webcontext.user();
+        //     var hisFile = "/home/"+account.username + "/Documents/history/graph-match-history.json";
+        //     var tmp = JSON.parse(dfs.read(hisFile)) || [];
+        //     var index = _.findIndex(tmp,{name:name});
+            
+        //     // limit 30
+        //     if(tmp.lenght > 20) tmp.slice(1);
+            
+        //     if(index === -1){
+        //         tmp.push({name:name,value:input,ctime:_.now()});
+        //     } else {
+        //         tmp = _.reject(tmp,{name:name});
+        //         tmp.push({name:name,value:input,ctime:_.now()});
+        //     }
+        //     dfs.write(hisFile,JSON.stringify(tmp,null,2))
+        // } catch(err){
+        //     log.error(err)
+        // }
+    }
+  
+    return rtn;
+})(input);
+
+OUTPUT = s;

+ 26 - 0
serverjs/script/cncc/应用/meta-event/graph/graph_imap_data.js

@@ -0,0 +1,26 @@
+// Input
+var input = JSON.parse(decodeURIComponent(INPUT));
+
+// 根据输入生成条件
+var entityIds = (function(){
+    return "('" + _.map(input,function(v,k){ return v.gid; }).join("','")+("')")
+    
+})();
+
+// 根据条件查询实体状态
+var entityStatusTmp = (function(){
+    webcontext.admin(true);
+    try {
+        return odb.mql("select id as gid,status from /matrix/entity/ where id in " + entityIds + " limit -1").data;
+    } catch(err){
+        return [];
+    }
+    webcontext.admin(false);
+})();
+
+var rtn = _.map(entityStatusTmp, function(v){
+    return _.extend(v, {statusTitle: v.status==5?'重大告警':v.status==4?'严重告警':'一般告警'})
+})
+
+// Output
+OUTPUT = rtn;

+ 15 - 0
serverjs/script/cncc/应用/meta-event/job/deleteEvent.js

@@ -0,0 +1,15 @@
+var deleteclosed = function(){
+    var rtn = null;
+    try{
+        var mql = "delete from /matrix/devops/ where status = 12";
+        log.info(mql)
+        rtn = odb.mql(mql);
+    }catch(err){
+        log.error(err);
+        rtn = null;
+    }
+    log.info(rtn);
+    return rtn;
+};
+
+OUTPUT = deleteclosed();

+ 88 - 0
serverjs/script/cncc/应用/meta-event/job/job_list.js

@@ -0,0 +1,88 @@
+var input = JSON.parse(decodeURIComponent(INPUT));
+
+var mqlStr = "";
+var s = function(param){
+    try{
+        // 过滤删除状态
+        mqlStr = param + " | status < 9 |  facet status as status_状态维度, class as class_类维度, tags as tags_标签维度,vtime as vtime_时间维度";
+        // log.info(mqlStr)
+        return odb.search(mqlStr);  
+    } catch(err){
+        log.error(err);
+        return null;
+    }
+};
+
+var message = s(input.term);
+
+// datatable数据 搜索返回多个子类,前端按root class类显示
+var rows = message.data;
+
+// datatable列名
+var columns = message.meta;
+// 供前端选择类显示
+var classes = message.meta.classes;
+
+// 默认显示root class类
+var rootClass = message.meta.rootclass
+
+var template = [
+        {field: "status", title: "状态", width: 90, render:`var s=function(row,column,cellValue,index){ 
+                try{ 
+                /* by row */
+                var el = document.querySelector('#pane-jobView .row-'+index);
+                /* by column */
+                /* var el = document.querySelector('.row-'+index+' >.'+column.id+' > .cell');*/
+                el.style.backgroundColor = global.register.jobs.status[cellValue][2];
+                el.style.color = '#ffffff';
+                el.style.textAlign = 'center';
+                return global.register.jobs.status[cellValue][1]; 
+                
+            } catch(err) { 
+                return null; 
+            }
+        };eval(s);`},
+        {field: "name", title: "作业名称", width:160},
+        {field: "dir", title: "目录", width:260},
+        {field: "type", title: "类型", width:90,render:`var s=function(row,column,cellValue,index){ 
+                try{ 
+                var el = document.querySelector('#pane-jobView .row-'+index);
+                el.style.textAlign = 'center';
+                return global.register.jobs.type[cellValue][1]; 
+            } catch(err) { 
+                return null; 
+            }
+        };eval(s);`},
+        {field: "stime", title: "开始时间", width:160, render: 'var s=function(row,column,cellValue,index){return moment(cellValue).format("YYYY-MM-DD HH:mm:ss.sss");};eval(s);'},
+        {field: "etime", title: "结束时间", width:160, render: 'var s=function(row,column,cellValue,index){return moment(cellValue).format("YYYY-MM-DD HH:mm:ss.sss");};eval(s);'},
+        {field: "utime", title: "耗时", width:160, render: `var s=function(row,column,cellValue,index){
+            var timeDiff = moment(row.etime).diff(moment(row.stime), "millisecond");
+            if(timeDiff > 1000){
+                return moment(row.etime).diff(moment(row.stime), "seconds") + ' 秒';    
+            } else {
+                return timeDiff + ' 毫秒';    
+            }
+        };eval(s);`},
+        {field: "cmds", title: "命令", width:80},
+        {field: "runid", title: "RUNID", width:260},
+        {field: "sid", title: "SID", width:260},
+        {field: "author", title: "管理员"},
+        {field: "vtime", title: "发生时间", width:160, render: 'var s=function(row,column,cellValue,index){return moment(cellValue).format("YYYY-MM-DD HH:MM:SS");};eval(s);'},
+        {field: "tags", title: "标签"},
+        {field: "id", title: "ID",visible:false},
+        {field: "day", title: "DAY",visible:false},
+        {field: "class", title: "类",visible:false}
+        
+];
+
+var rtn = {
+    rows: rows,
+    columns: columns,
+    classes: classes,
+    rootClass: '/matrix/jobs/jobrun',
+    template: template,
+    meta: message.meta,
+    trace: mqlStr
+};
+
+OUTPUT = rtn;

+ 14 - 0
serverjs/script/cncc/应用/meta-event/message/getMessage.js

@@ -0,0 +1,14 @@
+var getMessage = function(){
+    var rtn = null;
+    
+    try{
+        var mql = "select * from  /matrix/system/operationlog order by vtime desc limit 30";
+        rtn = odb.mql(mql).data;
+    } catch(err){
+        rtn = [];
+    }
+    
+    return rtn;
+};
+
+OUTPUT = getMessage();

+ 3 - 0
serverjs/script/cncc/应用/meta-event/notify/config.json

@@ -0,0 +1,3 @@
+{
+  "voice": "/assets/audio/notification.mp3"
+}

+ 80 - 0
serverjs/script/cncc/应用/meta-event/notify/getLogList.js

@@ -0,0 +1,80 @@
+//var input = INPUT;
+
+var voiceList = function(){
+    var rtn = null;
+    try{
+        rtn = odb.mql("SELECT class,content,day,id,name,objectid,rule,sendstatus,sendtime,status,tags,vtime FROM /matrix/notification/log order by sendtime desc limit -1").data;
+    } catch(err){
+        log.error(err);
+        rtn = [];
+    }
+    return rtn;
+};
+
+var columns = [
+				{
+					field: "id",
+					title: "ID",
+					width: 120,
+					visible:false
+				},
+				{
+					field: "class",
+					title: "CLASS",
+					width: 120,
+					visible:false
+				},
+				{
+					field: "sendstatus",
+					title: "状态",
+					width: 160,
+					visible: true
+				},
+				{
+					field: "objectid",
+					title: "事件ID",
+					width: 160,
+					visible: true
+				},
+				{
+					field: "rule",
+					title: "规则名称",
+					visible: true
+				},
+				{
+					field: "rule",
+					title: "接收人",
+					width: 160,
+					visible: true
+				},
+				{
+					field: "rule",
+					title: "接收人电话",
+					width: 160,
+					visible: true
+				},
+				{
+					field: "rule",
+					title: "接收人邮件",
+					width: 160,
+					visible: true
+				},
+				{
+					field: "rule",
+					title: "引用模板",
+					width: 160,
+					visible: true
+				},
+				{
+					field: "sendtime",
+					title: "发送时间",
+					width: 160,
+					visible: true,
+					render: `var s=function(row, column, cellValue, index){
+					    return moment(cellValue).format("YYYY-MM-DD HH:mm:ss");};eval(s);`
+				}];
+
+OUTPUT = {
+            rows: voiceList(),
+            columns:columns
+        };

+ 135 - 0
serverjs/script/cncc/应用/meta-event/notify/getRuleList.js

@@ -0,0 +1,135 @@
+var situationList = (function(pids){
+    try{
+        var mql = "select * from /matrix/notification/situation limit -1";
+        return odb.mql(mql).data;
+    } catch(err){
+        rtn = [];
+    }
+})();
+
+var ruleList = function(){
+    var rtn = null;
+    try{
+        var tmp = odb.mql("select * from /matrix/notification/rule limit -1").data;
+        rtn = _.map(tmp,function(v){
+            var people = [];
+            var phones = [];
+            var emails = [];
+            var personInfo = getPersonInfo(v.persons);
+            _.forEach(personInfo,function(p){
+                if(!_.isEmpty(p.mobile)){
+                    phones.push(p.mobile);    
+                }
+                if(!_.isEmpty(p.email)){
+                    emails.push(p.email);
+                }
+                if(!_.isEmpty(p.firstname) && !_.isEmpty(p.lastname)){
+                    people.push(p.firstname+p.lastname+','+p.mobile+','+p.email);
+                }else{
+                    people.push(p.username+','+p.mobile+','+p.email);
+                }
+            })
+            var situation = _.find(situationList,{id:v.situation});
+            return _.extend(v, {people: JSON.stringify(people), phones: phones.join(","), emails: emails.join(","), situationName: situation.name });
+        })
+    } catch(err){
+        rtn = err;
+    }
+    return rtn;
+};
+
+var getPersonInfo = function(pids){
+    var rtn = null;
+    try{
+        var mql = "select mobile,email,firstname,lastname,username from /matrix/ldap where id in ('"+pids.join("','")+"') limit -1";
+        log.debug(mql)
+        rtn = odb.mql(mql).data;
+        
+    } catch(err){
+        rtn = [];
+    }
+    return rtn;
+}
+
+var columns = [
+				{
+					field: "status",
+					title: "状态",
+					width: 80,
+					visible: true,
+					render: `var s=function(row,column,cellValue,index){
+					    if(cellValue==0){
+					        return '<i class="el-icon-video-pause" style="font-size: 16px; color: rgb(255, 0, 0);"></i>';
+					    } else {
+					        return '<i class="el-icon-video-play" style="font-size: 16px; color: rgb(76, 175, 80);"></i>';
+					    }
+					};eval(s);`
+				},
+				{
+					field: "id",
+					title: "ID",
+					width: 120,
+					visible:false
+				},
+				{
+					field: "class",
+					title: "CLASS",
+					width: 120,
+					visible:false
+				},
+				{
+					field: "name",
+					title: "策略名称",
+					width: 220,
+					visible: true
+				},
+				{
+					field: "people",
+					title: "接收人员",
+					width: 300,
+					visible: true
+				},
+				{
+					field: "phones",
+					title: "接收人员电话",
+					width: 220,
+					visible: false
+				},
+				{
+					field: "emails",
+					title: "接收人员邮件",
+					width: 220,
+					visible: false
+				},
+				{
+					field: "rtype",
+					title: "通知方式",
+					width: 200,
+					visible: true
+				},
+				{
+					field: "situationName",
+					title: "通知规则",
+					visible: true,
+					width: 220
+				},
+				{
+					field: "template",
+					title: "通知模板",
+					visible: true,
+					width: 220,
+					render: `var s=function(row,column,cellValue,index){
+					    return cellValue?Object.keys(cellValue)[0].replace(/.json/,''):'';
+					};eval(s);`
+				},
+				{
+					field: "tags",
+					title: "标签",
+					visible: true,
+					width: 200
+				}];
+
+OUTPUT = {
+            rows: ruleList(),
+            columns:columns
+        };

+ 80 - 0
serverjs/script/cncc/应用/meta-event/notify/getTemplateList.js

@@ -0,0 +1,80 @@
+
+var rows = (function(){
+    
+    try{
+        var tmp = dfs.readdir("/script/cncc/meta-faulta/notify/template");
+        
+        return _.map(tmp,function(v){
+            
+            if(typeof v.attr === 'object'){
+                var keys = Object.keys(v.attr);
+                if(Array.prototype.isPrototypeOf(keys) && keys.length === 0){
+                    _.extend(v,{attr: {"status":'0'}});
+                }
+            }else{
+                v.attr = JSON.parse(v.attr);
+            }
+            
+            return _.extend(v,{
+                        status: v.attr["status"],
+                        content: dfs.read(v.fullname),
+                        title: v.name.split(".")[0]
+            });
+        })
+        
+    } catch(err){
+        log.error(err)
+        return [];
+    }
+    
+})();
+
+var columns = [
+				{
+					field: "status",
+					title: "状态",
+					width: 80,
+					visible: false,
+					render: `var s=function(row,column,cellValue,index){
+					    if(cellValue==0){
+					        return '<i class="el-icon-video-pause" style="font-size: 16px; color: rgb(255, 0, 0);"></i>';
+					    } else {
+					        return '<i class="el-icon-video-play" style="font-size: 16px; color: rgb(76, 175, 80);"></i>';
+					    }
+					};eval(s);`
+				},
+				{
+					field: "title",
+					title: "模板名称",
+					visible: true,
+					render: `var s=function(row,column,cellValue,index){
+					    return cellValue;
+					};eval(s);`
+				},
+				{
+					field: "tags",
+					title: "标签",
+					width: 160,
+					visible: true
+				},
+				{
+					field: "ctime",
+					title: "创建时间",
+					width: 260,
+					visible: true,
+					render: `var s=function(row, column, cellValue, index){
+					    return moment(cellValue).format("YYYY-MM-DD HH:mm:ss");};eval(s);`
+				},
+				{
+					field: "vtime",
+					title: "修改时间",
+					width: 260,
+					visible: true,
+					render: `var s=function(row, column, cellValue, index){
+					    return moment(cellValue).format("YYYY-MM-DD HH:mm:ss");};eval(s);`
+				}];
+
+OUTPUT ={
+            rows: rows,
+            columns:columns
+        };

+ 54 - 0
serverjs/script/cncc/应用/meta-event/notify/getVoiceList.js

@@ -0,0 +1,54 @@
+//var input = INPUT;
+
+var voiceList = function(){
+    var rtn = null;
+    try{
+        rtn = _.map(dfs.readdir("/assets/audio"),function(v){
+            return _.extend(v, {ifPlay:false});
+        });
+    } catch(err){
+        rtn = [];
+    }
+    return rtn;
+};
+
+
+
+var columns = [
+				{
+					field: "id",
+					title: "ID",
+					width: 120,
+					visible:false
+				},
+				{
+					field: "class",
+					title: "CLASS",
+					width: 120,
+					visible:false
+				},
+				{
+					field: "name",
+					title: "声音名称",
+					visible: true
+				},
+				{
+					field: "size",
+					title: "声音大小",
+					width: 160,
+					visible: true,
+					render: `var s=function(row,column,cellValue,index){
+					       return m3.bytesToSize(cellValue);
+					};eval(s);`
+				},
+				{
+					field: "remark",
+					title: "备注",
+					width: 300,
+					visible: true
+				}];
+
+OUTPUT = {
+            rows: voiceList(),
+            columns:columns
+        };

+ 153 - 0
serverjs/script/cncc/应用/meta-event/notify/logAction.js

@@ -0,0 +1,153 @@
+var input = JSON.parse(decodeURIComponent(INPUT));
+
+var getSerial = function(id){
+    try{
+        var mql = "select serverserial from /matrix/devops/ where id='"+id+"'";
+        
+        return odb.mql(mql).data[0]['serverserial'];
+    }catch(err){
+        log.error(err);
+        return null;
+    }
+}
+
+var getLdap = function(param){
+    try{
+        var rtn = [];
+        param.forEach(function(v){
+            var mql = "select firstname,lastname,email,mobile,wechat from /matrix/ldap where username='"+v.name+"'";
+            log.info(mql)
+            var p = odb.mql(mql).data[0];
+            var rt = [];
+            rt.push(p.firstname + p.lastname);
+            rt.push(p.email.join(","));
+            rt.push(p.mobile.join(","));
+            rt.push(p.wechat);
+            _.compact(rt)
+            rtn.push(rt.join(","))
+        })
+        
+        return _.compact(rtn);
+    }catch(err){
+        log.error(err);
+        return null;
+    }
+}
+
+var columns = [{
+                field: "serverserial",
+                title: "告警ID",
+                width: "160"
+            },
+            {
+                field: "people",
+                title: "接收人",
+                width: "160"
+            },
+            {
+                field: "rule",
+                title: "通知策略",
+                width: "160"
+            },
+            {
+                field: "msg",
+                title: "通知内容"
+            },
+            {
+                field: "sendtime",
+                title: "发送时间",
+                width: "160",
+                render: 'var s=function(row, column, cellValue, index){return moment(cellValue).format("YYYY-MM-DD HH:mm:ss");};eval(s);'
+            },
+            {
+                field: "sendstatus",
+                title: "发送状态",
+                render: 'var s=function(row, column, cellValue, index){ return cellValue.status; };eval(s);',
+                visible: false
+            },
+            {
+                field: "tags",
+                title: "标签",
+                width: "180",
+                visible: false
+            },
+            {
+                field: "name",
+                title: "名称",
+                width: "120",
+                visible: false
+            },
+            {
+                field: "id",
+                title: "ID",
+                width: "80",
+                visible: false
+            },
+            {
+                field: "class",
+                title: "类",
+                width: "80",
+                visible: false
+            }
+
+            ];
+
+var logList = function(data) {
+    try {
+        var rt = [];
+        data.forEach(function(v){
+            var content = JSON.parse(v.content);
+            var sendstatus = JSON.parse(v.sendstatus);
+            content.forEach(function(val){
+                var status = _.find(sendstatus,{id:val.id}) || null;
+                var serverserial = getSerial(val.id);
+                var people = getLdap(val.to)
+                rt.push( { id:val.id, serverserial: serverserial, rule:val.rule, msg:val.msg, people: people, sendstatus:status, sendtime:v.sendtime } )
+            })
+        })
+        return rt;
+
+    }catch(err) {
+        log.error(err);
+        return [];
+    }
+};
+
+var actions = function() {
+
+    try {
+        if (input.action === 'search') {
+            var params = [];
+            if(input.data.time){
+                params.push(['window '+input.data.time[0] + ' to ' + input.data.time[1] + ' for sendtime']);
+            }
+            if(input.data.id){
+                params.push(input.data.id);
+            }
+            if(input.data.person){
+                params.push(input.data.person);
+            }
+            params.push("top 20")
+            var mql = "#/matrix/notification/log | " + params.join(" | ") + " | sort by sendtime desc";
+            log.info(mql)
+            var rows =  logList(odb.search(mql).data);
+            return {
+                rows: rows,
+                columns: columns
+            };
+        } else {
+            var mql = "select * from /matrix/notification/log  limit 20 order by vtime desc";
+            var rows = logList(odb.mql(mql).data);
+            return {
+                rows: rows,
+                columns: columns
+            };
+        }
+    } catch(err) {
+        log.error(err);
+        return err;
+    }
+
+}
+
+OUTPUT = actions();

+ 50 - 0
serverjs/script/cncc/应用/meta-event/notify/ruleAction.js

@@ -0,0 +1,50 @@
+var input = JSON.parse(decodeURIComponent(INPUT));
+
+var actions = function(){
+    var rtn = null;
+    
+    try{
+        if(input.action == 'check'){
+            
+            try{
+                var mql = "select count(*) from /matrix/notification/rule where name='"+input.model.name+"'";
+                rtn = odb.mql(mql).data[0].count > 0 ? true : false;
+            }catch(err){
+                log.error(err);
+                rtn = false;
+            }
+            
+        } else if(input.action == 'add'){
+            
+            var persons = JSON.stringify(_.flatten(input.model.persons));
+            var rtype = JSON.stringify(input.model.rtype);
+            var template = JSON.stringify(input.model.template.value);
+            var status = input.model.status?1:0;
+            var mql = "insert into /matrix/notification/rule (name,persons,rtype,situation,template,status) values('"+input.model.name+"', " + persons + "," +  rtype + ", '"+input.model.situation+"'," + template + ", " + status + ")";
+            log.debug(mql);
+            odb.mql(mql);   
+            
+        } else if(input.action == 'update'){
+            var persons = JSON.stringify(_.flatten(input.model.persons));
+            var rtype = JSON.stringify(input.model.rtype);
+            var template = JSON.stringify(input.model.template.value);
+            var status = input.model.status?1:0;
+            var mql = "update /matrix/notification/rule set persons="+persons+",rtype="+rtype+",situation='"+input.model.situation+"',template="+template+",status="+status+"  where id='"+input.model.id+"'";
+            log.debug(mql);
+            odb.mql(mql);
+            
+        } else if(input.action == 'delete'){
+            
+            var mql = "delete from /matrix/notification/rule where id='"+input.model.id+"'";
+            log.debug(mql)
+            odb.mql(mql);   
+            
+        }
+    } catch(err){
+        log.error(err);
+        return err;
+    }
+    return rtn;
+}
+
+OUTPUT = actions();

+ 77 - 0
serverjs/script/cncc/应用/meta-event/notify/server/server.json

@@ -0,0 +1,77 @@
+{
+  "base": {
+    "name": "base",
+    "title": "发送配置",
+    "cron": "*/5 * * * *",
+    "group": "mxsvr",
+    "log_console": true,
+    "log_dir": "/opt/matrix/var/logs/alert",
+    "log_level": "INFO",
+    "retry_interval": 5,
+    "retry_num": 3,
+    "send_num": 5000,
+    "status": true,
+    "send_type": [
+      "wechat",
+      "email",
+      "sms",
+      "setOmnibusStatus"
+    ],
+    "send_fields": {
+      "name": "setOmnibusStatus",
+      "path": "./alert_cmd/setOmnibusStatus.sh",
+      "params": "serverserial"
+    }
+  },
+  "setOmnibusStatus": {
+    "name": "setOmnibusStatus",
+    "title": "重置",
+    "status": true
+  },
+  "sms": {
+    "name": "sms",
+    "title": "短信",
+    "type": "netgate",
+    "status": true,
+    "cmd": "sms",
+    "cmdPath": "./alert_cmd/send_sms.py",
+    "netgate": {
+      "protocol": "http",
+      "address": "10.1.81.124",
+      "port": "8888",
+      "svcId": "100001",
+      "srvId": "2800",
+      "chanNo": "28",
+      "brNo": "99200"
+    },
+    "jdbc": {},
+    "rest": {
+      "url": "http://47.92.151.165",
+      "username": "",
+      "password": ""
+    }
+  },
+  "email": {
+    "name": "email",
+    "title": "邮件",
+    "smtp": "smtp.mxhichina.com",
+    "port": "80",
+    "subject": "邮件告警通知",
+    "username": "wangzd@wecise.com",
+    "password": "1qaZ2wsX",
+    "html": true,
+    "status": true,
+    "cmd": "email",
+    "cmdPath": "email"
+  },
+  "wechat": {
+    "name": "wechat",
+    "title": "企业微信",
+    "agentid": 1000002,
+    "corpid": "ww0635074636be973e",
+    "corpsecret": "dvAodiJ0x9msZchun-s7G16SdP3wywWtE9woEjEkdIQ",
+    "status": false,
+    "cmd": "wechat",
+    "cmdPath": "ls -rtl"
+  }
+}

+ 98 - 0
serverjs/script/cncc/应用/meta-event/notify/setup.js

@@ -0,0 +1,98 @@
+var input = JSON.parse(JSON.parse( decodeURIComponent(INPUT) ));
+
+var action = function(){
+    
+    try{
+        var send_cmd = {};
+        var send_user_field = {};
+        
+        var cmds = _.values(input);
+        
+        cmds.forEach(function(v){
+            
+            // send_cmd
+            if(v.status && v.cmd && v.cmdPath){
+                
+                var cmdPath = v.cmdPath;
+                var field = "";
+                if(v.name==='email'){
+                    var args = _.template("<%= cmd %> -from <%= username %> -pass <%= password %> -server <%= smtp %> -port <%= port %> -subject '<%= subject %>' <%= html %>");
+                    cmdPath = args({
+                        cmd:v.cmdPath,
+                        username: v.username,
+                        password: v.password,
+                        smtp: v.smtp,
+                        port: v.port,
+                        subject: v.subject,
+                        html: v.html? '--html':''
+                    });
+                    
+                    field = "email";
+                }
+                if(v.name==='sms'){
+                    var args = _.template("<%= cmd %> '<%= args %>'");
+                    cmdPath = args({
+                        cmd:v.cmdPath,
+                        args: JSON.stringify(v)
+                    });
+                    
+                    field = "mobile";
+                }
+                if(v.name==='wechat'){
+                    var args = _.template("<%= cmd %>  -c '<%= args %>'");
+                    cmdPath = args({
+                        cmd:v.cmdPath,
+                        args: JSON.stringify(v)
+                    });
+                    
+                    field = "wechat";
+                }
+                
+                // send_user_field
+                var o = {};
+                o[v.cmd]=field;
+                _.extend(send_user_field, o);
+                
+                // send_cmd
+                var p = {};
+                p[v.cmd]=cmdPath;
+                _.extend(send_cmd, p);
+            }
+        })
+        
+        var compiled = _.template("insert into /matrix/notification/alert_config(create_cron,create_group,log_console,log_dir,log_level,retry_interval,retry_num,send_cmd,send_num,send_user_field,send_fields) values('<%= create_cron %>', '<%= create_group %>',<%= log_console %>,'<%= log_dir %>', '<%= log_level %>',<%= retry_interval %>,<%= retry_num %>,<%= send_cmd %>,<%= send_num %>,<%= send_user_field %>,<%= send_fields %>)");
+        
+        // base 执行后调用第三方命令
+        var p = {};
+        p[input.base.send_fields.name]=input.base.send_fields.path;
+        _.extend(send_cmd, p);
+        
+        var send_fields = {};
+        send_fields[input.base.send_fields.name]=input.base.send_fields.params;
+        
+        var mql = compiled({
+            create_cron: input.base.cron,
+            create_group: input.base.group,
+            log_console: input.base.log_console,
+            log_dir: input.base.log_dir,
+            log_level: input.base.log_level,
+            retry_interval: input.base.retry_interval,
+            retry_num: input.base.retry_num,
+            send_num: input.base.send_num,
+            send_user_field: JSON.stringify(send_user_field),
+            send_cmd: JSON.stringify(send_cmd),
+            send_fields: JSON.stringify(send_fields)
+            
+        })
+        
+       log.debug(mql);
+       return odb.mql(mql);
+        
+    }catch(err){
+        log.error(err);
+        return err;
+    }
+
+};
+
+OUTPUT = action();

+ 94 - 0
serverjs/script/cncc/应用/meta-event/notify/situationAction.js

@@ -0,0 +1,94 @@
+var input = JSON.parse(decodeURIComponent(INPUT));
+
+var actions = function(){
+    var rtn = null;
+    
+    try{
+        if(input.action == 'namecheck'){
+            
+            try{
+                var mql = "select count(*) from /matrix/notification/situation where name='"+input.model.name+"'";
+                log.info(mql)
+                rtn = odb.mql(mql).data[0].count > 0 ? true : false;
+            }catch(err){
+                log.error(err);
+                rtn = false;
+            }
+            
+        } else if(input.action == 'add'){
+            
+            var str = "insert into /matrix/notification/situation (name,parent,situation,status,sourceconfig) values( '<%= name %>', '<%= parent %>','<%= situation  %>', <%= status %>, <%= sourceconfig %>)";
+            var compiled = _.template(str);
+            var mql = compiled({
+                name: input.model.name,
+                parent: input.model.parent,
+                situation: input.model.situation,
+                status: input.model.status,
+                sourceconfig: JSON.stringify(input.model.sourceconfig)
+            })
+            log.debug(mql);
+            odb.mql(mql);   
+            
+        } else if(input.action == 'update'){
+            var str = "update /matrix/notification/situation set name='<%= name %>',parent='<%= parent %>',situation='<%= situation %>',status=<%= status %>,sourceconfig=<%= sourceconfig %>  where id='<%= id %>'";
+            var compiled = _.template(str);
+            var mql = compiled({
+                name: input.model.name,
+                parent: input.model.parent,
+                situation: input.model.situation,
+                status: input.model.status,
+                sourceconfig: JSON.stringify(input.model.sourceconfig),
+                id: input.model.id
+            });
+            
+            log.debug(mql);
+            odb.mql(mql);
+            
+        } else if(input.action == 'delete'){
+            
+            var mql = "delete from /matrix/notification/situation where id='"+input.model.id+"'";
+            log.debug(mql)
+            odb.mql(mql);   
+            
+        } else if(input.action == 'check'){
+            
+            var mql = "select count(*) from /matrix/notification/rule where situation='"+input.model.id+"'";
+            log.debug(mql)
+            rtn = odb.mql(mql).data[0].count;   
+            
+        }  else {
+            
+            var mql = "select * from /matrix/notification/situation limit -1";
+            log.debug(mql)
+            rtn = {
+                rows:odb.mql(mql).data,
+                columns: [
+                            {field: "status", title: "状态", width: "80", visible:false, render: `var s=function(row, column, cellValue, index){ try {
+                                                                        if(cellValue==0){
+					        return '<i class="el-icon-video-pause" style="font-size: 16px; color: rgb(255, 0, 0);"></i>';
+					    } else {
+					        return '<i class="el-icon-video-play" style="font-size: 16px; color: rgb(76, 175, 80);"></i>';
+					    }
+                                                                    } catch(err) { 
+                                                                        return '禁用'; 
+                                                                    }
+                            };eval(s);`},
+                            {field: "name", title: "规则名称", width: "220"},
+                            {field: "situation", title: "规则定义"},
+                            {field: "vtime", title: "创建时间", width: "160", render: 'var s=function(row, column, cellValue, index){return moment(cellValue).format("YYYY-MM-DD HH:mm:ss");};eval(s);'},
+                            {field: "tags", title: "标签", width: "180"},
+                            {field: "id", title: "ID", width: "80", visible:false},
+                            {field: "class", title: "类", width: "80", visible:false}
+                            
+                        ]
+            }
+            
+        }
+    } catch(err){
+        log.error(err);
+        return null;
+    }
+    return rtn;
+}
+
+OUTPUT = actions();

+ 12 - 0
serverjs/script/cncc/应用/meta-event/notify/template/网络告警模版.json

@@ -0,0 +1,12 @@
+{
+  "class": "/matrix/devops/alert_status",
+  "fields": [
+    "summary"
+  ],
+  "compression": {
+    "keys": [],
+    "timer": 0,
+    "enable":false
+  },
+  "template": "<p>SUMMARY:{{.summary}}</p>"
+}

+ 17 - 0
serverjs/script/cncc/应用/meta-event/notify/template/网络告警通知.json

@@ -0,0 +1,17 @@
+{
+  "class": "/matrix/devops/alert_status",
+  "fields": [
+    "firstoccurrence",
+    "node",
+    "platform",
+    "serverserial",
+    "summary",
+    "tally"
+  ],
+  "compression":{
+      "keys":[],
+      "timer":0
+  },
+  "html":false,
+  "template": "<p>FIRSTOCCURRENCE:{{.firstoccurrence}}</p><p>NODE:{{.node}}</p><p>PLATFORM:{{.platform}}</p><p>SERVERSERIAL:{{.serverserial}}</p><p>SUMMARY:{{.summary}}</p><p>TALLY:{{.tally}}</p>"
+}

+ 0 - 0
serverjs/script/cncc/应用/meta-event/notify/template/邮件发送模版.json


Some files were not shown because too many files changed in this diff