Collection接口

接口调用时须在请求头中设置agentId,返回内容为 JSON 格式的信息. 其参数为时间类型都以时间戳形式传递。

有些接口调用时需用到hostId、agentId、clusterId、eventId

hostId 在“根据主机名模糊查询主机基本信息”接口处获取。

agentId 在"生成agentId"接口处获取。

eventId 在"获取集群日志信息"接口处找到所需事件的id

clusterId 在“查找mongoDB集群信息数据”接口返回结果集中。

请求头默认格式,特殊情况特殊声明

agentId在"生成agentId"接口处获取。

KEY VALUE
Accept-Encoding gzip,deflate,br
Connection keep-alive
Content-Type application/json
agentId "agentId"


1 保存agent端的日志记录.

1.1 请求路径

POST: http://{Server-Host}:{端口}/api/collection/host/save/log


1.2 请求参数

Name Located in Description Required Schema
agentLogEntity Body 日志信息实体对象 Yes AgentLogEntity


img_2.png


1.3 返回结果

Description Schema
code 状态符:1000成功,其余异常 int
msg 返回消息 String


img_1.png



2 更新agent的mongo文件信息.

2.1 请求路径

POST: http://{Server-Host}:{端口}/api/collection/host/updateAgentMongoFile/


2.2 请求参数

Name Located in Description Required Schema
agentId Path agentId Yes String
mongoFileList Body mongo文件集合 Yes List


img_4.png

Ex. 更新agent的mongo文件信息;其中MongoFileList 如下所示:
 [
        {
            "_id": "62d62a9bbfa6b71dad85b68a",M
            "createTime": "1658202779363",
            "hostId": "62b153a344ba1b7771c42df7",
            "md5": "1",
            "name": "mongodb-linux-x86_64-enterprise-rhel70-4.4.14.tgz",
            "path": "/var/ops/agent/mongodb-linux-x86_64-enterprise-rhel70-4.4.14.tgz",
            "server": false,
            "shortName": "mongodb-linux-x86_64-enterprise-rhel70-4.4.14",
            "size": 133646249,
            "updateTime": "1658202779363"
        }
    ]

2.3 返回结果

Description Schema
code 状态符:1000成功,其余异常 int
msg 返回消息 String


img_30.png



3 根据agentId查询该agent待执行的命令.

3.1 请求路径

GET: http://{Server-Host}:{端口}/api/collection/command/getCommand/


3.2 请求参数

Name Located in Description Required Schema
hostId Path 主机id Yes String


img.png


3.3 返回结果

Description Schema
code 状态符:1000成功,其余异常 int
data 返回数据 List


img_1.png

{
    "code": 1000,
    "data": [
        {
            "id": "632bfca83b74be1d9fe7ddb7",
            "createTime": 1663827112988,
            "updateTime": 1663827112988,
            "hostId": "630eddeff3d9e72e3695ea48",
            "commandType": 101,
            "status": 0,
            "eventId": null,
            "commandNote": "updateHostInfo",
            "content": "\"updateHostInfo\"",
            "execResult": null
        }
    ]
}


4 更新命令实体对象的状态.

4.1 请求路径

PUT: http://{Server-Host}:{端口}/api/collection/command/update


4.2 请求参数

Name Located in Description Required Schema
commandEntity Body 命令实体对象 Yes CommandEntity


img_6.png

Ex. 更新命令实体对象的状态;其中 CommandEntity 如下所示:

{
    "id" : "62c54a395dc04d3d4c13be75",
    "commandNote" : "server100:20190获取集群角色",
    "commandType" : 221,
    "content" : "{}",
    "createTime" : "1657096761802",
    "execResult" : "已完成",
    "hostId" : "62b153a344ba1b7771c42df7",
    "status" : 3,
    "updateTime" :"1657096769089"
}

4.3 返回结果

Description Schema
code 状态符:1000成功,其余异常 int
data 返回消息 String


img_5.png



5 更新agent心跳信息.

5.1 请求路径

GET: http://{Server-Host}:{端口}/api/collection/host/updateRunTime//


5.2 请求参数

Name Located in Description Required Schema
hostId Path 主机id Yes String
timeStamp Path 时间戳 Yes String


img_7.png


5.3 返回结果

Description Schema
code 状态符:1000成功,其余异常 int
msg 返回消息 String


img_7.png



6 保存主机信息

6.1 请求路径

POST: http://{Server-Host}:{端口}/api/collection/hostInfo


6.2 请求参数

Name Located in Description Required Schema
hostInfoMongoEntity Body 主机信息实体对象 Yes HostInfoMongoEntity


img_8.png

Ex. 保存主机信息;其中 HostInfoMongoEntity 如下所示:
{
    "_id" : "62cbbd7607bebb71b8429e5e",
    "cpuInfo" : " Intel(R) Xeon(R) CPU E5-2670 v2 @ 2.50GHz",
    "cpuNum" : 40,
    "hostId" : "62cbbd7607bebb71b8429e5e",
    "hostName" : "server200",
    "hostNameLong" : "server200",
    "ipInfo" : [
        {
            "ip" : "172.17.0.1",
            "type" : "ipv4"
        }
    ],
    "kernelInfo" : "3.10.0-1062.el7.x86_64",
    "osVersion" : "CentOS Linux release 7.7.1908 (Core)",
    "run" : true,
    "systemPropertyInfo" : {
        "fileSeparator" : "/",
        "javaClassPath" : "agent-collection-1.0.0.jar",
        "javaClassVersion" : "55.0",
        "javaHome" : "/root/jdk-11.0.9",
        "javaIoTmpdir" : "/tmp",
        "javaLibraryPath" : "/usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib",
        "javaSpecificationName" : "Java Platform API Specification",
        "javaSpecificationVendor" : "Oracle Corporation",
        "javaVendor" : "Oracle Corporation",
        "javaVersion" : "11.0.9",
        "javaVmName" : "Java HotSpot(TM) 64-Bit Server VM",
        "javaVmSpecificationName" : "Java Virtual Machine Specification",
        "javaVmSpecificationVersion" : "11",
        "javaVmVendor" : "Oracle Corporation",
        "javaVmVersion" : "11.0.9+7-LTS",
        "lineSeparator" : "\n",
        "oSArch" : "amd64",
        "oSName" : "Linux",
        "oSVersion" : "3.10.0-1062.el7.x86_64",
        "pathSeparator" : ":",
        "userDir" : "/home/jmops",
        "userHome" : "/root",
        "userName" : "root"
    }
}

6.3 返回结果

Description Schema
code 状态符:1000成功,其余异常 int
msg 返回消息 String


img_9.png



7 保存主机实时信息

7.1 请求路径

POST: http://{Server-Host}:{端口}/api/collection/host/addHostRealTimeData


7.2 请求参数

Name Located in Description Required Schema
hostRealTimeDataMongoEntity Body 主机实时信息实体对象 Yes HostRealTimeDataMongoEntity


img_9.png

Ex. 保存主机信息;其中 hostRealTimeDataMongoEntity 如下所示:

{
    "_id": "62c64f99f9872b46f1ce953a",
    "cpuInfo": {
        "hi": 0,
        "id": 98.1,
        "ni": 0,
        "si": 0,
        "st": 0,
        "sy": 0.9,
        "us": 1,
        "wa": 0
    },
    "createTime": "1657163672000",
    "diskInAndOutInfoList": [
        {
            "avgqu_sz": 0.05,
            "avgrq_sz": 18.89,
            "await": 0.34,
            "device": "sda",
            "r_await": 13.32,
            "r_s": 0.17,
            "rkB_s": 10.82,
            "rrqm_s": 0.06,
            "svctm": 0.05,
            "util": 0.75,
            "w_await": 0.32,
            "w_s": 144.65,
            "wkB_s": 1357.06,
            "wrqm_s": 2.03
        }
    ],
    "diskInfoList": [
        {
            "fileSystem": "devtmpfs",
            "mountedOn": "/dev",
            "size": 64349,
            "type": "devtmpfs",
            "used": 0,
            "utilization": 0
        }
    ],
    "hostId": "62b153a344ba1b7771c42df7",
    "hostName": "server100",
    "memoryInfo": {
        "memAvail": 95150,
        "memBuffCache": 26138,
        "memFree": 69641,
        "memTotal": 128722,
        "memUsed": 32942,
        "swapFree": 1958,
        "swapTotal": 4095,
        "swapUsed": 2137
    },
    "netInAndOutInfoList": [
        {
            "io": 0,
            "networkCardName": "em3:",
            "out": 0
        }
    ],
    "timeGranularity": 1,
    "updateTime": "1657163672000"
}

7.3 返回结果

Description Schema
code 状态符:1000成功,其余异常 int
data 返回消息 String


img_11.png



8 agent调用此接口来获取server端的时间

8.1 请求路径

GET: http://{Server-Host}:{端口}/api/collection/util/get/server/date


8.2 请求

img_12.png


8.3 返回结果

Description Schema
code 状态符:1000成功,其余异常 int
data 时间戳 long


img_13.png



9 agent通过调用此接口来获取请求agent的ip

9.1 请求路径

GET: http://{Server-Host}:{端口}/api/collection/util/get/agent/ip


9.2 请求

img_14.png


9.3 返回结果

Description Schema
code 状态符:1000成功,其余异常 int
data 返回数据:ip String


img_15.png



10 mongo进行日志记录

10.1 请求路径

POST: http://{Server-Host}:{端口}/api/collection/mongodb/insertMongoClusterLog//


10.2 请求参数

Name Located in Description Required Schema
clusterId Path 集群id Yes String
eventId Path 事件id Yes String
logList Body 日志列表 Yes List


img_10.png


10.3 返回结果

Description Schema
code 状态符:1000成功,其余异常 int
data 返回消息 String


img_1.png



11 插入mongo成员日志

11.1 请求路径

POST: http://{Server-Host}:{端口}/api/collection/mongodb/insertMongoMemberLog///


11.2 请求参数

Name Located in Description Required Schema
clusterId Path 集群id Yes String
memberInfo Path 成员信息 Yes String
eventId Path 事件id Yes String
logList Body 日志列表 Yes List


img_11.png


11.3 返回结果

Description Schema
code 状态符:1000成功,其余异常 int
data 返回消息 String


img_3.png



12 更新mongo节点信息

12.1 请求路径

POST: http://{Server-Host}:{端口}/api/collection/mongodb/updateMongoMember


12.2 请求参数

Name Located in Description Required Schema
mongoMember Body mongo集群成员 Yes MongoMember


img_13.png


Ex. 更新mongo节点信息;其中 MongoMember 如下所示:
{
  "id": "62f76749e011b442d7c91ec6",
  "createTime": 0,
  "updateTime": 1660466332000,
  "memberName": "server200:39801",
  "hostName": "server200",
  "hostId": "62ecda96dce5916b2b6f1b39",
  "port": "39801",
  "version": "6.0.1",
  "upgradeVersion": null,
  "userName": "root",
  "password": "123456",
  "authDbName": "admin",
  "currentTimeMillis": 1660381001974,
  "dataDirectory": "/var/ops/mongodb1660381001974/data/",
  "logFile": "/home/guanfei/data2/sharding8/data/mongos/data1/mongos.log",
  "confPath": "/home/guanfei/data2/sharding8/config/mongos/mongos1.conf",
  "authAble": true,
  "runShCmd": "/home/guanfei/data2/server/mongodb-linux-x86_64-enterprise-rhel70-6.0.0/bin/mongos -f /home/guanfei/data2/sharding8/config/mongos/mongos1.conf",
  "type": 61,
  "status": "正在运行",
  "monitorServerStatus": false,
  "monitorTopAndOp": false,
  "collectMongoLog": false,
  "mongoLogFileOffset": 0,
  "operaLogTemp": [],
  "votes": 1,
  "priority": 1,
  "delay": 0,
  "buildIndexes": true,
  "procId": "46797",
  "clusterId": "62f76747fe07726988b75f6b",
  "replId": null,
  "clusterName": null,
  "tags": {},
  "configurationOptions": {
    "systemLog_destination": "file",
    "systemLog_path": "/home/guanfei/data2/sharding8/data/mongos/data1/mongos.log",
    "processManagement_fork": "true",
    "systemLog_logAppend": "true",
    "security_keyFile": "/home/guanfei/data2/sharding8/keyfile",
    "net_bindIp": "0.0.0.0",
    "net_port": "39801",
    "securityKeyFileValue": "BeP6Mbxj23i1jaGsGiRwKmHed2mCqDhlH4ZudHjiftZBoh26OQrCOaX+cAe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ion": 5723
}

12.3 返回结果

Description Schema
code 状态符:1000成功,其余异常 int
data 返回消息 String


img_5.png



13 更新复制集信息

13.1 请求路径

POST: http://{Server-Host}:{端口}/api/collection/mongodb/updateMongoRepl/


13.2 请求参数

Name Located in Description Required Schema
isUpdateMemberList Path 是否更新成员列表 Yes boolean
mongoReplica Body mongo复制集 Yes MongoReplica


img_14.png


13.3 返回结果

Description Schema
code 状态符:1000成功,其余异常 int
data 返回消息 String


img_7.png



14 更新集群信息

14.1 请求路径

POST: http://{Server-Host}:{端口}/api/collection/mongodb/updateCluster


14.2 请求参数

Name Located in Description Required Schema
mongoClusterInformation Body mongo集群信息实体对象 Yes MongoClusterInformation


img_15.png


14.3 返回结果

Description Schema
code 状态符:1000成功,其余异常 int
data 返回消息 String


img_9.png



15 保存mongo成员的实时信息

15.1 请求路径

POST: http://{Server-Host}:{端口}/api/collection/mongodb/realtime


15.2 请求参数

Name Located in Description Required Schema
tableName Path 表名 Yes String
mongodbNodeMetrics Body mongo实时数据对象 Yes MongodbNodeMetrics


img_16.png

Ex. 保存mongo成员的实时信息;MongodbNodeMetrics 如下所示:
{
    "anAssert" : {
        "msg" : 0,
        "regular" : 0,
        "user" : 0,
        "warning" : 0
    },
    "cacheFlow" : {
        "brin" : 8717624,
        "bwfr" : 6421369
    }
    "createTime" : "1660469450000",
    "databaseLock" : {
        "r" : 0.00,
        "r_i" : 0.00,
        "w" : 0.00,
        "w_i" : 0.00
    },
    "deletedDocument" : {
        "deleted" : 103,
        "deletedByTTL" : 35
    },
    "documentOp" : {
        "inserted" : 26,
        "returned" : 0,
        "updated" : 0
    },
    "hostId" : "62cbbd7607bebb71b8429e5e",
    "hostName" : "server200",
    "latency" : {
        "r" : 717.90,
        "w" : 3252.41
    }
    "timeGranularity" : 0,
    "transactionCondition" : {
        "currActive" : 0,
        "currInactive" : 0,
        "totalAborted" : 0,
        "totalCommitted" : 0
    },
    "updateTime" : "1660469450000"
}

15.3 返回结果

Description Schema
code 状态符:1000成功,其余异常 int
data 返回消息 String


img_11.png



Deprecated 已弃用

16 保存一批监控数据到数据库中

16.1 请求路径

POST: http://{Server-Host}:{端口}/api/collection/mongodb/realtime/save/many


16.2 请求参数

Name Located in Description Required Schema
mongoDBRealtimeDataEntityList Body 保存mongo成员的实时信息集合 Yes List


img_12.png


16.3 返回结果

Description Schema
code 状态符:1000成功,其余异常 int
data 返回消息 String


img_13.png



17 获取agent实例上的mongo节点信息

17.1 请求路径

POST http://{Server-Host}:{端口}/api/collection/mongodb/getAgentMongoMember/


17.2 请求参数

Name Located in Description Required Schema
agentId Path agentId Yes String


img_17.png


17.3 返回结果

Description Schema
code 状态符:1000成功,其余异常 int
data 返回数据 List


{
    "code": 1000,
    "data": [
        {
            "id": "62d6506ec5b6206027b99052",
            "createTime": 1658212462005,
            "updateTime": 1658302192001,
            "memberName": "chen:56902",
            "hostName": "chen",
            "hostId": "62bbfbe9a46517610435d615",
            "port": "56902",
            "version": "4.2.21",
            "upgradeVersion": null,
            "userName": "lhp1234",
            "password": "123456",
            "authDbName": "admin",
            "currentTimeMillis": 1658212462005,
            "dataDirectory": "/home/chen/data56902/data/",
            "logFile": "/home/chen/data56902/data/log.log",
            "confPath": "/home/chen/data56902/data/chen_56902.conf",
            "deleteDataAndLogAble": false,
            "authAble": true,
            "runShCmd": "",
            "type": 45,
            "status": "正在运行",
            "monitorServerStatus": true,
            "monitorTopAndOp": true,
            "collectMongoLog": true,
            "mongoLogFileOffset": 0,
            "operaLogTemp": [],
            "votes": 1,
            "priority": 1.0,
            "delay": 0,
            "buildIndexes": true,
            "procId": "5599",
            "clusterId": "62d65068561b4a25b8339740",
            "replId": "62d6506dc5b6206027b99050",
            "clusterName": null,
            "tags": {},
            "configurationOptions": {
                "sharding_clusterRole": "configsvr",
                "security_keyFile": "",
                "security_authorization": "enabled",
                "systemLog_destination": "file",
                "storage_wiredTiger_engineConfig_cacheSizeGB": "0.3",
                "systemLog_Path": "/home/chen/data56902/data/log.log",
                "processManagement_fork": "true",
                "storage_dbPath": "/home/chen/data56902/data/",
                "systemLog_logAppend": "true",
                "net_bindIp": "0.0.0.0",
                "net_port": "56902",
                "replication_replSetName": "test_lhp_shard_config",
                "securityKeyFileValue":""
            },
            "operateVersion": 8168
        }
    ]
}


18 保存mongo.log日志

18.1 请求路径

POST: http://{Server-Host}:{端口}/api/collection/mongodb/save/mongoLog//


18.2 请求参数

Name Located in Description Required Schema
mongoMemberId Path mongo成员id Yes String
fileOffset Path 文件偏移 Yes long
logList Body 日志列表 Yes List


img_18.png


18.3 返回结果

Description Schema
code 状态符:1000成功,其余异常 int
data 文件偏移量 long


img_16.png



19 保存 mongo top and op

19.1 请求路径

POST: http://{Server-Host}:{端口}/api/collection/mongodb/save/mongoTopAndOp


19.2 请求参数

Name Located in Description Required Schema
documentList Body Document列表 Yes List


img_19.png


19.3 返回结果

Description Schema
code 状态符:1000成功,其余异常 int
data 返回消息 String


img_18.png



20 更新fcv

20.1 请求路径

GET: http://{Server-Host}:{端口}/api/collection/mongodb/updateFCV//


20.2 请求参数

Name Located in Description Required Schema
clusterId Path 集群id Yes String
fcv Path fcv Yes String


img_19.png


20.3 返回结果

Description Schema
code 状态符:1000成功,其余异常 int
data 返回消息 String


img_20.png



21 保存mongodb集合

21.1 请求路径

POST: http://{Server-Host}:{端口}/api/collection/mongodb/saveMongoDBCollections


21.2 请求参数

Name Located in Description Required Schema
mongoDBCollections Body mongo实集合 Yes MongoDBCollections


Ex. 保存mongodb集合;其中 MongoDBCollections 如下所示:
{
    "_id" : "62ea1db298c0825187aee96e",
    "clusterId" : "62ea1db298c0825187aee96e",
    "createTime" : "1659686288006",
    "dbTables" : [
        {
            "name" : "fs.files",
            "type" : "collection",
            "options" : {

            },
            "info" : {
                "readOnly" : false,
                "uuid" : {
                    "type" : 4,
                    "data" : "q/X3q+2aQVC9dGCnS4wKZA=="
                }
            },
            "idIndex" : {
                "v" : 2,
                "key" : {
                    "_id" : 1
                },
                "name" : "_id_",
                "ns" : "record.fs.files"
            },
            "storageSize" : 20,
            "size" : 16,
            "ns" : "record.fs.files"
        }
    ],
    "fromServerExe" : false,
    "updateTime" : 0
}

img_12.png


21.3 返回结果

Description Schema
code 状态符:1000成功,其余异常 int
data 返回消息 String


img_22.png



22 保存mongo成员用户

22.1 请求路径

POST: http://{Server-Host}:{端口}/api/collection/mongodb/saveMongoDBClusterUser/


22.2 请求参数

Name Located in Description Required Schema
clusterId Path 集群id Yes String
list Body document列表 Yes List


img_23.png

Ex. 保存mongo成员用户;其中 List 如下所示:
[{
    "name" : "hostRealTimeDataMongoEntity",
    "type" : "collection",
    "options" : {    
    },
    "storageSize" : 8836,
    "size" : 44721,
    "ns" : "ops.hostRealTimeDataMongoEntity",
    "indexSizes" : {
        "_id_" : 248,
        "createTime_1" : 152,
        "hostId_1" : 84,
        "hostId_1_createTime_1_timeGranularity_1" : 172
    }
}]

22.3 返回结果

Description Schema
code 状态符:1000成功,其余异常 int
data 返回消息 String


img_24.png



23 保存mongo成员角色

23.1 请求路径

POST: http://{Server-Host}:{端口}/api/collection/mongodb/saveMongoDBClusterRole/


23.2 请求参数

Name Located in Description Required Schema
clusterId Path 集群id Yes String
list Body document列表 Yes List


img_25.png


23.3 返回结果

Description Schema
code 状态符:1000成功,其余异常 int
data 返回消息 String


img_26.png


24 保存诊断数据.

24.1 请求路径

POST: http://{Server-Host}:9601/api/collection/mdiag/saveMdiagLog


24.2 请求参数

Name Located in Description Required Schema
document Body 巡检日志 Yes Document


img_20.png


24.3 返回结果

Description Schema
code 状态符:1000成功,其余异常 int
data 返回消息 String


img_21.png



24 获取config信息.

24.1 请求路径

GET http://{Server-Host}:9601/api/collection/config/getConfig


24.2 请求参


img_22.png


24.3 返回结果

Description Schema
code 状态符:1000成功,其余异常 int
data 返回数据 ConfigEntity

img_23.png


---

results matching ""

    No results matching ""