Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
AppMonitorSubscriber
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nongyingchen
AppMonitorSubscriber
Commits
c209fe6f
Commit
c209fe6f
authored
May 24, 2019
by
trace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update showing mode, add release update
parent
46a84a67
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
12 deletions
+40
-12
play.js
+40
-12
No files found.
play.js
View file @
c209fe6f
let
version
=
'1.0'
let
release
=
`<div><br/>
<br/>1. <br/>
加入对贷超 MGT 的支持. 支持点击"<贷超名MGT>"打开贷超对应管理系统, 点击包名 ID 打开 GooglePlay<br/>
<br/>2. <br/>
在线列表上下线颜色区分. 上线: 绿色, 下线: 红色.<br/>
<br/>other:<br/>
当监控中有上下线变化才会发送邮件, 并且会带上当前在线下线列表<br/>
上下线通知邮件中第一行, "《》" 中的是 VTPM 本次监控情况涉及 APP 数量, "【】" 中是本次监控通知中贷超 APP 涉及数量<br/>
<div/>
<br/>
<br/>
<br/>
`
// 依赖
var
gplay
=
require
(
'google-play-scraper'
)
var
gplay
=
require
(
'google-play-scraper'
)
var
nodemailer
=
require
(
'nodemailer'
)
var
nodemailer
=
require
(
'nodemailer'
)
// 工具
var
fs
=
require
(
'fs'
)
var
fs
=
require
(
'fs'
)
var
username
=
require
(
'os'
).
userInfo
().
username
var
username
=
require
(
'os'
).
userInfo
().
username
var
request
=
require
(
'request'
)
var
request
=
require
(
'request'
)
var
util
=
require
(
'util'
)
var
util
=
require
(
'util'
)
var
getPromiss
=
util
.
promisify
(
request
.
get
)
var
getPromiss
=
util
.
promisify
(
request
.
get
)
// 地址
let
subApi
=
"https://git.starwin.tech/nongyingchen/AppMonitorSubscriber/raw/master/subscriber.json"
let
subApi
=
"https://git.starwin.tech/nongyingchen/AppMonitorSubscriber/raw/master/subscriber.json"
log
(
`当前奔跑在:
${
username
}
`
)
log
(
`当前奔跑在:
${
username
}
`
)
let
ding
=
'https://oapi.dingtalk.com/robot/send?access_token='
let
ding
=
'https://oapi.dingtalk.com/robot/send?access_token='
let
debugDingding
=
`
${
ding
}
bf03c69128b771107b8715911b8a76db61a55cbd8b00e1a2c955578c2a3da719`
let
debugDingding
=
`
${
ding
}
bf03c69128b771107b8715911b8a76db61a55cbd8b00e1a2c955578c2a3da719`
let
notifyDingding
=
`
${
ding
}
61403ec65efd7a9e40cb6d490e1bfab8aff28800696918a23ec4dffdf5aa1315`
let
notifyDingding
=
`
${
ding
}
61403ec65efd7a9e40cb6d490e1bfab8aff28800696918a23ec4dffdf5aa1315`
let
daichao
=
`admin/loan/listactive?current=0&size=10000&descs%5B0%5D=priority&packageId=10002`
let
daichao
=
`admin/loan/listactive?current=0&size=10000&descs%5B0%5D=priority&packageId=10002`
let
daichaoRegion
=
[
let
daichaoRegion
=
{
'http://admin.uuang.co.id/'
,
'http://admin.uuang.co.id/'
:
'印尼贷超'
,
'http://admin.ph.g-cashing.com/'
,
'http://admin.ph.g-cashing.com/'
:
'菲律宾贷超'
,
'http://admin.a.vaylaco.com/'
'http://admin.a.vaylaco.com/'
:
'越南贷超'
]
}
// Config ------------------------------------------------------------
// Config ------------------------------------------------------------
let
sec
=
1000
;
let
sec
=
1000
;
...
@@ -130,6 +150,7 @@ let permissionChange = {} // 权限变化
...
@@ -130,6 +150,7 @@ let permissionChange = {} // 权限变化
let
failedApps
=
[]
// 获取失败的
let
failedApps
=
[]
// 获取失败的
let
newTopMonitorNames
=
{}
let
newTopMonitorNames
=
{}
let
errorLog
=
[]
// 错误记录
let
errorLog
=
[]
// 错误记录
let
newDeploy
=
true
log
(
'log 打开'
)
log
(
'log 打开'
)
...
@@ -141,13 +162,16 @@ if (isTest()) {
...
@@ -141,13 +162,16 @@ if (isTest()) {
startMonitor
()
startMonitor
()
}
}
sendEmail
(
`
爬虫部署成功,
开始监控-----------------------`
)
sendEmail
(
`开始监控-----------------------`
)
async
function
startMonitor
()
{
async
function
startMonitor
()
{
log
(
'开始监控'
)
log
(
'开始监控'
)
while
(
start
)
{
while
(
start
)
{
log
(
`抓取一圈`
)
log
(
`抓取一圈`
)
await
getConfig
()
await
getConfig
()
.
then
(()
=>
{
// 部署通知, 更新说明
sendEmail
(
`<div>爬虫部署版本:
${
version
}
</div>更新说明:
${
release
}
`
)
})
.
then
(
getDaichao
)
.
then
(
getDaichao
)
.
then
(
getTop100
)
.
then
(
getTop100
)
.
then
(()
=>
fs
.
writeFileSync
(
monitorApps
,
JSON
.
stringify
(
monitorNames
)))
// 保存到本地
.
then
(()
=>
fs
.
writeFileSync
(
monitorApps
,
JSON
.
stringify
(
monitorNames
)))
// 保存到本地
...
@@ -218,8 +242,9 @@ function generateDailyOnlineReport() {
...
@@ -218,8 +242,9 @@ function generateDailyOnlineReport() {
async
function
getDaichao
()
{
async
function
getDaichao
()
{
let
allRegionDaichaoApps
=
[]
let
allRegionDaichaoApps
=
[]
for
(
index
in
daichaoRegion
)
{
for
(
region
in
daichaoRegion
)
{
let
region
=
daichaoRegion
[
index
]
// for (index in Object.keys(daichaoRegion)) {
// let region = daichaoRegion[index]
daichaoApiUrl
=
region
+
daichao
daichaoApiUrl
=
region
+
daichao
log
(
` 贷超 url:
${
daichaoApiUrl
}
`
)
log
(
` 贷超 url:
${
daichaoApiUrl
}
`
)
await
getPromiss
(
daichaoApiUrl
)
await
getPromiss
(
daichaoApiUrl
)
...
@@ -238,7 +263,8 @@ async function getDaichao() {
...
@@ -238,7 +263,8 @@ async function getDaichao() {
daichaoAppInfoes
[
app
.
packageName
]
=
{
daichaoAppInfoes
[
app
.
packageName
]
=
{
name
:
app
.
name
,
name
:
app
.
name
,
daichaoId
:
app
.
id
,
daichaoId
:
app
.
id
,
mgt
:
`
${
region
}
#/loan/`
mgt
:
`
${
region
}
#/loan/`
,
region
:
daichaoRegion
[
region
]
}
}
}
}
if
(
isTest
())
{
if
(
isTest
())
{
...
@@ -662,6 +688,8 @@ function genMail() {
...
@@ -662,6 +688,8 @@ function genMail() {
}
}
// 有变化也发送当前监控在线情况
// 有变化也发送当前监控在线情况
emailContent
+=
'<br/><br/><br/>'
emailContent
+=
'在线/下线 情况:'
emailContent
+=
generateDailyOnlineReport
()
emailContent
+=
generateDailyOnlineReport
()
emailContent
+=
nowGenerate
emailContent
+=
nowGenerate
...
@@ -675,14 +703,14 @@ function genMail() {
...
@@ -675,14 +703,14 @@ function genMail() {
errorLog
=
[]
errorLog
=
[]
newTopMonitorNames
=
{}
newTopMonitorNames
=
{}
return
`<div>
${
firstLine
}
</div><br/>
${
emailContent
}
`
return
`<div>
${
firstLine
}
</div><br/>
${
emailContent
}
<br/>version:
${
version
}
`
}
}
function
isOurs
(
name
,
countOurs
)
{
function
isOurs
(
name
,
countOurs
)
{
let
prefix
=
''
let
prefix
=
''
if
(
daichaoApps
.
includes
(
name
))
{
if
(
daichaoApps
.
includes
(
name
))
{
prefix
=
`<a href="
${
daichaoAppInfoes
[
name
].
mgt
}${
daichaoAppInfoes
[
name
]
&&
prefix
=
`
🏦(贷超.
${
daichaoAppInfoes
[
name
].
region
}
[
${
daichaoAppInfoes
[
name
].
daichaoId
}
]__
<a href="
${
daichaoAppInfoes
[
name
].
mgt
}${
daichaoAppInfoes
[
name
]
&&
daichaoAppInfoes
[
name
].
daichaoId
||
''
}
">
🏦(贷超 [
${
daichaoAppInfoes
[
name
].
daichaoId
}
] _
<
${
daichaoAppInfoes
[
name
].
name
}
>(->MGT)) | </a>`
daichaoAppInfoes
[
name
].
daichaoId
||
''
}
"> <
${
daichaoAppInfoes
[
name
].
name
}
>(->MGT)) | </a>`
}
}
if
(
ourAppIds
.
includes
(
name
))
{
if
(
ourAppIds
.
includes
(
name
))
{
if
(
prefix
!=
''
)
{
if
(
prefix
!=
''
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment