浏览代码

add 飞书监控

DevYK 3 年之前
父节点
当前提交
4b2e8a1f4f
共有 5 个文件被更改,包括 33 次插入3 次删除
  1. 5 0
      README.md
  2. 22 0
      model/feishu.js
  3. 2 0
      model/logger.js
  4. 2 1
      model/report.js
  5. 2 2
      routes/sdk.js

+ 5 - 0
README.md

@@ -45,6 +45,10 @@ ssh -i /home/ubuntu/denet-security.pem   ubuntu@10.0.1.25
 pm2 logs
 
 ```
+
+监控:
+https://open.feishu.cn/open-apis/bot/v2/hook/18dfe21f-b1bd-46ca-a8c7-c85e1c84f02d
+
 ## 文档
 - [moralis 中文版](https://www.w3cschool.cn/moralis/moralis-39s73nzu.html)
 - [moralis 英文版](https://docs.moralis.io/moralis-dapp/web3-api/rate-limit)
@@ -55,3 +59,4 @@ pm2 logs
 - [moralis server](https://admin.moralis.io/servers)
 - [node 服务文档 ](https://st94nif1cq.feishu.cn/docs/doccnNxG2UwHPCdZXbywgbdy13f#)
 - [测试币准备](https://st94nif1cq.feishu.cn/docs/doccn2G0r0HOH0L1Z05uaJDFA2g#)
+- [监控预警](https://github.com/zhangky01/feishu-robot)

+ 22 - 0
model/feishu.js

@@ -0,0 +1,22 @@
+
+const axios = require('axios');
+
+const url = 'https://open.feishu.cn/open-apis/bot/v2/hook/18dfe21f-b1bd-46ca-a8c7-c85e1c84f02d'
+
+const sendMessage = async (params) => {
+    console.log('sendMessage',params)
+    var data = {
+        msg_type: "text",
+        content: { text: params }
+    }
+    axios.post(url, data)
+        .then(res => {
+            console.log('res=>', res.status, res.data);
+        }).catch(err => {
+            console.error('http_request_post error ', err);
+        });
+}
+
+module.exports = {
+    sendMessage
+}

+ 2 - 0
model/logger.js

@@ -4,6 +4,7 @@
 
 const log4js = require('log4js')
 var { logger_config } = require('../config/config.js')
+var feishu = require('./feishu')
 
 const BASE_PATH = logger_config.BASE_PATH
 
@@ -77,6 +78,7 @@ module.exports = {
     },
     error() {
         errorLogger.error.call(errorLogger, ...arguments)
+        feishu.sendMessage(...arguments)
     },
     fatal() {
         errorLogger.fatal.call(errorLogger, ...arguments)

+ 2 - 1
model/report.js

@@ -11,7 +11,8 @@ const logger = require('./logger')
 const REPORT_TYPE = {
     transfer_record: 'transfer_record',
     collect_coins: 'collect_coins',
-    withdraw: 'withdraw'
+    withdraw: 'withdraw',
+    monitor: 'monitor'
 }
 
 

+ 2 - 2
routes/sdk.js

@@ -33,7 +33,7 @@ async function getTransfers(ctx) {
 
     var temp_obj = { ...obj }
     var index = 0
-    for (let index = 0; index < 30; index++) {
+    // for (let index = 0; index < 30; index++) {
         await moralis.getTokenTransfers(obj).then((result) => {
             logger.log('getTransfers response','index='+index, result)
             ctx.body = result;
@@ -69,7 +69,7 @@ async function getTransfers(ctx) {
                 }
             }
         })
-    }
+    // }
 }