diff --git a/bin/lib/api/notify/index.js b/bin/lib/api/notify/index.js index 536e62dc..a103e6ab 100644 --- a/bin/lib/api/notify/index.js +++ b/bin/lib/api/notify/index.js @@ -29,20 +29,20 @@ this.SendMail = function(opt) { opt = Deferred.extend({ 'appKey': '', 'sysId': 0, - 'EmailType': 1, // 邮件类型,可选值0(外部邮件),1(内部邮件),2(约会邮件) - 'From': '', // 邮件发送人 - 'To': '', // 邮件接收人 - 'Title': '', // 邮件标题 - 'Content': '', // 邮件内容 - 'Priority': 0, // 邮件优先级,-1低优先级,0普通,1高优先级 - 'BodyFormat': 0, // 邮件格式,0 文本、1 Html - - 'CC': '', // 邮件抄送人 - 'Bcc': '', // 邮件密送人 - 'Location': '', // 当邮件为约会邮件时,约会地点 - 'Organizer': '', // 当邮件为约会邮件时,约会组织者 - 'StartTime': '', // 当邮件为约会邮件时,约会开始时间 - 'EndTime': '', // 当邮件为约会邮件时,约会结束时间 + 'emailType': 1, // 邮件类型,可选值0(外部邮件),1(内部邮件),2(约会邮件) + 'from': '', // 邮件发送人 + 'to': '', // 邮件接收人 + 'title': '', // 邮件标题 + 'content': '', // 邮件内容 + 'priority': 0, // 邮件优先级,-1低优先级,0普通,1高优先级 + 'bodyFormat': 0, // 邮件格式,0 文本、1 Html + + 'cc': '', // 邮件抄送人 + 'bcc': '', // 邮件密送人 + 'location': '', // 当邮件为约会邮件时,约会地点 + 'organizer': '', // 当邮件为约会邮件时,约会组织者 + 'startTime': '', // 当邮件为约会邮件时,约会开始时间 + 'endTime': '', // 当邮件为约会邮件时,约会结束时间 'attachment': '' // 邮件附件的文件名以及文件的内容(在发送请求时,文件内容是二进制数据流的形式发送) }, opt); @@ -57,10 +57,10 @@ this.SendWeiXin = function(opt) { opt = Deferred.extend({ 'appKey': '', 'sysId': 0, - 'MsgInfo': '', // 内容 - 'Priority': 0, // 优先级,-1低优先级,0普通,1高优先级 - 'Receiver': '', // 接收人,英文名,多人用英文分号分隔 - 'Sender': '' // 发送人 + 'msgInfo': '', // 内容 + 'priority': 0, // 优先级,-1低优先级,0普通,1高优先级 + 'receiver': '', // 接收人,英文名,多人用英文分号分隔 + 'sender': '' // 发送人 }, opt); const defer = Deferred.create(); @@ -74,10 +74,10 @@ this.SendSMS = function(opt) { opt = Deferred.extend({ 'appKey': '', 'sysId': 0, - 'MsgInfo': '', // 内容 - 'Priority': 0, // 优先级,-1低优先级,0普通,1高优先级 - 'Receiver': '', // 接收人,英文名,多人用英文分号分隔 - 'Sender': '' // 发送人 + 'msgInfo': '', // 内容 + 'priority': 0, // 优先级,-1低优先级,0普通,1高优先级 + 'receiver': '', // 接收人,英文名,多人用英文分号分隔 + 'sender': '' // 发送人 }, opt); const defer = Deferred.create(); diff --git a/bin/lib/util/mail/mail.js b/bin/lib/util/mail/mail.js index b24e6931..9bef0e7e 100644 --- a/bin/lib/util/mail/mail.js +++ b/bin/lib/util/mail/mail.js @@ -21,7 +21,6 @@ this.SendMail = function(key, group, second, oriOpt) { const opt = Deferred.extend({}, oriOpt); const data = {}; const now = new Date(); - let prefix = '[runtime]'; if (isWindows.isWindows) { return; @@ -33,24 +32,12 @@ this.SendMail = function(key, group, second, oriOpt) { return; } - if (context.title) { - opt.Title = `[${context.title}]${opt.Title}`; - } - - if (config.isTest) { - prefix += '[测试环境]'; - } else { - if (opt.runtimeType) { - prefix += `[${opt.runtimeType}][考核]`; - } - } - - opt.Title = prefix + opt.Title; - - data.Title = opt.Title || ''; + data.title = opt.title || ''; + data.oriTitle = oriOpt.title || ''; + data.ctxTitle = context.title || ''; data.isTest = ~~config.isTest; - data.Content = opt.Content || ''; - data.MsgInfo = opt.MsgInfo || ''; + data.content = opt.content || ''; + data.msgInfo = opt.msgInfo || ''; data.intranetIp = serverInfo.intranetIp || ''; data.second = second || ''; data.idc = config.idc || ''; diff --git a/bin/lib/util/mail/src/mail.tmpl.html b/bin/lib/util/mail/src/mail.tmpl.html index 27ac6d10..e33752ba 100644 --- a/bin/lib/util/mail/src/mail.tmpl.html +++ b/bin/lib/util/mail/src/mail.tmpl.html @@ -27,7 +27,7 @@
-<%=data.Content%>
+<%=data.content%>
服务器IP: <%=data.intranetIp%>
进程名字: <%=tmpl.encodeHtml(data.processTitle)%>
@@ -57,7 +57,7 @@ var window = context.window || {}; %> -<%=data.MsgInfo%> +<%=data.msgInfo%> <%='\r\n\r\n'%> 服务器IP:<%=data.intranetIp%><%='\r\n'%> 进程名字: <%=tmpl.encodeHtml(process.title)%><%='\r\n'%> diff --git a/bin/lib/util/mail/tmpl.js b/bin/lib/util/mail/tmpl.js index 8d8a4c03..25778c6a 100644 --- a/bin/lib/util/mail/tmpl.js +++ b/bin/lib/util/mail/tmpl.js @@ -20,7 +20,7 @@ define(function(require, exports, module) { const window = context.window || {}; __p.push('\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n'); - _p(data.Content); + _p(data.content); __p.push('
\n服务器IP: '); _p(data.intranetIp); __p.push('
\n\n进程名字: '); @@ -65,7 +65,7 @@ define(function(require, exports, module) { const window = context.window || {}; - _p(data.MsgInfo); + _p(data.msgInfo); _p('\r\n\r\n'); __p.push('服务器IP:'); _p(data.intranetIp); diff --git a/bin/proxy/http.proxy.js b/bin/proxy/http.proxy.js index 9801e742..f2708be9 100644 --- a/bin/proxy/http.proxy.js +++ b/bin/proxy/http.proxy.js @@ -402,7 +402,7 @@ function heartBeat() { timeout: 5000 }, function(err, data, errData) { // eslint-disable-line handle-callback-err const key = `cpu80.v4:${serverInfo.intranetIp}`; - let Content = `单核CPU${serverInfo.cpu}使用率为:${cpuUsed},超过80%, 最近5秒钟CPU Profiler见附件`; + let content = `单核CPU${serverInfo.cpu}使用率为:${cpuUsed},超过80%, 最近5秒钟CPU Profiler见附件`; let str = ''; if (data) { @@ -410,7 +410,7 @@ function heartBeat() { str = str.replace(/'); - Content += '
进程快照:
' + str + ''; + content += '
进程快照:
' + str + ''; } @@ -433,11 +433,11 @@ function heartBeat() { recordTime: 5000 }, result => { mail.SendMail(key, 'js', 600, { - 'To': config.mailTo, - 'CC': owner, - 'MsgInfo': business.module + '[CPU]' + serverInfo.intranetIp + '单核CPU' + serverInfo.cpu + '使用率为:' + cpuUsed + ',超过80%', - 'Title': business.module + '[CPU]' + serverInfo.intranetIp + '单核CPU' + serverInfo.cpu + '使用率为:' + cpuUsed + ',超过80%', - 'Content': Content, + 'to': config.mailTo, + 'cc': owner, + 'msgInfo': business.module + '[CPU]' + serverInfo.intranetIp + '单核CPU' + serverInfo.cpu + '使用率为:' + cpuUsed + ',超过80%', + 'title': business.module + '[CPU]' + serverInfo.intranetIp + '单核CPU' + serverInfo.cpu + '使用率为:' + cpuUsed + ',超过80%', + 'content': content, 'attachment': result ? { fileType: true, dispositionType: 'attachment', diff --git a/bin/proxy/http.route.js b/bin/proxy/http.route.js index 13743c55..0a3d0e97 100644 --- a/bin/proxy/http.route.js +++ b/bin/proxy/http.route.js @@ -152,7 +152,7 @@ module.exports = function(req, res) { return; } - if (errorIgnore[err || err.message] === 'ignore') { + if (err && err.message && errorIgnore[err.message] === 'ignore') { logger.warn(err && err.stack); return; } @@ -224,12 +224,12 @@ module.exports = function(req, res) { } const key = err.message; - const Content = `
错误堆栈
${err.stack}
`;
+ const content = `错误堆栈
${err.stack}
`;
mail.SendMail(key, 'js', 600, {
- 'Title': key,
+ 'title': key,
'runtimeType': 'Error',
- 'MsgInfo': err.stack || err.message,
- 'Content': Content
+ 'msgInfo': err.stack || err.message,
+ 'content': content
});
}
});
diff --git a/bin/proxy/master.js b/bin/proxy/master.js
index b783e0c2..edf6679f 100644
--- a/bin/proxy/master.js
+++ b/bin/proxy/master.js
@@ -35,15 +35,15 @@ process.on('uncaughtException', function(e) {
process.on('warning', function(warning) {
const key = String(warning);
const errStr = warning && warning.stack || String(warning);
- const Content = `错误堆栈
${errStr}
`;
+ const content = `错误堆栈
${errStr}
`;
logger.error(errStr);
setImmediate(function() {
require('util/mail/mail.js').SendMail(key, 'js', 600, {
- 'Title': key,
+ 'title': key,
'runtimeType': 'warning',
- 'Content': Content
+ 'content': content
});
});
});
@@ -52,7 +52,7 @@ process.on('warning', function(warning) {
process.on('unhandledRejection', (errorOrReason, currPromise) => {
const errStr = String(errorOrReason && errorOrReason.stack || JSON.stringify(errorOrReason));
const key = String(errorOrReason && errorOrReason.message);
- const Content = `错误堆栈
${errStr}
`;
+ const content = `错误堆栈
${errStr}
`;
// 恢复上下文
if (currPromise && currPromise.domain) {
@@ -60,9 +60,9 @@ process.on('unhandledRejection', (errorOrReason, currPromise) => {
logger.error(`unhandledRejection reason: ${errStr}`);
setImmediate(function() {
require('util/mail/mail.js').SendMail(key, 'js', 600, {
- 'Title': key,
+ 'title': key,
'runtimeType': 'unhandledRejection',
- 'Content': Content
+ 'content': content
});
});
});
diff --git a/bin/tsw/ajax/ajax.js b/bin/tsw/ajax/ajax.js
index 1c6cf4b5..de8ca63a 100644
--- a/bin/tsw/ajax/ajax.js
+++ b/bin/tsw/ajax/ajax.js
@@ -905,8 +905,6 @@ Ajax.prototype.doRequest = function(opt) {
responseText,
buffer,
code;
- let key,
- Content;
this.removeAllListeners('close');
this.removeAllListeners('end');
@@ -1065,19 +1063,13 @@ Ajax.prototype.doRequest = function(opt) {
times: times
});
- key = [window.request.headers.host, context.mod_act, parseErr.message].join(':');
-
- Content = [
- '错误堆栈
', - '',
- parseErr.stack,
- '
',
- ].join('');
+ const key = [window.request.headers.host, context.mod_act, parseErr.message].join(':');
+ const content = `错误堆栈
${parseErr.stack}
`;
require('util/mail/mail.js').SendMail(key, 'js data', 1800, {
- 'Title': key,
- 'Content': Content,
- 'MsgInfo': '错误堆栈:\n' + parseErr.stack
+ 'title': key,
+ 'content': content,
+ 'msgInfo': '错误堆栈:\n' + parseErr.stack
});
return;
diff --git a/bin/tsw/runtime/CCFinder.js b/bin/tsw/runtime/CCFinder.js
index 3679ab58..ddbe4b9d 100644
--- a/bin/tsw/runtime/CCFinder.js
+++ b/bin/tsw/runtime/CCFinder.js
@@ -112,7 +112,7 @@ this.check = function(req, res) {
const userIp = httpUtil.getUserIp(req);
const userIp24 = httpUtil.getUserIp24(req);
- let Content;
+ let content;
const info = {
userIp: userIp,
@@ -203,7 +203,7 @@ this.check = function(req, res) {
// 发现目标,发邮件
const key = `[AVG_TSW_IP_STD_X10]:${serverInfo.intranetIp}`;
- Content = '';
+ content = '';
Object.keys(cache.ipCacheLast).forEach(function(ip, i) {
@@ -216,21 +216,21 @@ this.check = function(req, res) {
) {
num = String(cache.ipCacheLast[ip].list.length);
num = (num + 'XXXXXX').slice(0, 8).replace(/X/g, ' ');
- Content += `服务器IP:' + serverInfo.intranetIp + '
' + 'to': config.mailTo, + 'cc': config.mailCC, + 'title': `[IP聚集告警][${cache.ipCacheLast.StdX10}%]${serverInfo.intranetIp}`, + 'content': '服务器IP:' + serverInfo.intranetIp + '
' + 'IP聚集度:' + cache.ipCacheLast.StdX10 + '%
' + '告警阀值:' + CCIPLimit + '
' + '正常值:5-50
' + '检测耗时:' + parseInt((cache.ipCacheLast.end - cache.ipCacheLast.start) / 1000, 10) + 's
' + '证据列表:
' - + Content + + content });