From 121a5e3e67605971b8c2e6ed9e77329da3908ae2 Mon Sep 17 00:00:00 2001 From: jiutianmuzi Date: Wed, 29 Nov 2017 23:46:18 +0800 Subject: [PATCH 01/25] add dataStore module.database is influxDB --- .idea/vcs.xml | 6 ++ dataStore/__init__.py | 44 +++++++++ dataStore/influxDbUtil/__init__.py | 0 dataStore/influxDbUtil/dbUtil.py | 26 +++++ dataStore/lepdClient/LepdClient.py | 66 +++++++++++++ dataStore/lepdClient/__init__.py | 0 dataStore/modules/__init__.py | 0 dataStore/modules/cpu/__init__.py | 0 dataStore/modules/cpu/cpuPullAndStore.py | 38 ++++++++ dataStore/modules/memory/__init__.py | 0 .../modules/memory/memoryPullAndStore.py | 96 +++++++++++++++++++ dataStore/query/__init__.py | 0 dataStore/query/memory/__init__.py | 0 dataStore/query/memory/queryGetProcMeminfo.py | 23 +++++ 14 files changed, 299 insertions(+) create mode 100644 .idea/vcs.xml create mode 100644 dataStore/__init__.py create mode 100644 dataStore/influxDbUtil/__init__.py create mode 100644 dataStore/influxDbUtil/dbUtil.py create mode 100644 dataStore/lepdClient/LepdClient.py create mode 100644 dataStore/lepdClient/__init__.py create mode 100644 dataStore/modules/__init__.py create mode 100644 dataStore/modules/cpu/__init__.py create mode 100644 dataStore/modules/cpu/cpuPullAndStore.py create mode 100644 dataStore/modules/memory/__init__.py create mode 100644 dataStore/modules/memory/memoryPullAndStore.py create mode 100644 dataStore/query/__init__.py create mode 100644 dataStore/query/memory/__init__.py create mode 100644 dataStore/query/memory/queryGetProcMeminfo.py diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/dataStore/__init__.py b/dataStore/__init__.py new file mode 100644 index 0000000..43660d6 --- /dev/null +++ b/dataStore/__init__.py @@ -0,0 +1,44 @@ +import argparse + +from influxdb import InfluxDBClient + +def main(host='localhost',port=8086): + user = 'root' + password = 'root' + dbname = 'example' + dbuser = 'smly' + dbuser_password = 'my_secret_password' + query = 'select value from cpu_load_short;' + json_body = [{ + "measurement": "cpu_load_short", + "tags":{ + "host":"server01", + "region":"us-west" + }, + "time":"2009-11-10T23:00:00Z", + "fields":{ + "value":0.64 + } + }] + + + client = InfluxDBClient(host,port,user,password,dbname) + client.create_database(dbname) + client.create_retention_policy('awesome_policy','3d',3,default=True) + client.switch_user(dbuser, dbuser_password) + client.write_points(json_body) + result = client.query(query) + print(result) + client.switch_user(user,password) + #client.drop_database(dbname) +def parse_args(): + parser = argparse.ArgumentParser(description='exmple code to play with InfluxDB') + parser.add_argument('--host',type=str,required = False,default='localhost', + help='hostnameof InfluxDB http Api') + parser.add_argument('--port',type=int ,required=False,default=8086, + help='port of InfluxDb http Api') + return parser.parse_args() + +# if __name__ == '__main__': +# args = parse_args() +# main(host=args.host,port=args.port) \ No newline at end of file diff --git a/dataStore/influxDbUtil/__init__.py b/dataStore/influxDbUtil/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/dataStore/influxDbUtil/dbUtil.py b/dataStore/influxDbUtil/dbUtil.py new file mode 100644 index 0000000..bd42e4e --- /dev/null +++ b/dataStore/influxDbUtil/dbUtil.py @@ -0,0 +1,26 @@ +"""Core module for interacting with influxDB""" + +__author__ = "李旭升 " +__copyright__ = "Licensed under GPLv2 or later." + +from influxdb import InfluxDBClient + +''' +myInfluxDbClient是自己封装的InfluxDBClient, +为了插入和读取InfluxDB +''' + + +class myInfluxDbClient: + def __init__(self, influxDBAddress): + self._client = InfluxDBClient(influxDBAddress, 8086, 'root', ",", "lep") + + def write_points(self, server, json_body): + + if self._client.write_points(json_body): + return True + else: + return False + + def query(self, statement): + return self._client.query(statement) diff --git a/dataStore/lepdClient/LepdClient.py b/dataStore/lepdClient/LepdClient.py new file mode 100644 index 0000000..c19b57a --- /dev/null +++ b/dataStore/lepdClient/LepdClient.py @@ -0,0 +1,66 @@ +"""Core module for interacting with LEPD""" + +__author__ = "Copyright (c) 2016, 李旭升 " +__copyright__ = "Licensed under GPLv2 or later." + +import json +import pprint +import socket + +''' +LepdClient请求lepd返回数据 +''' + + +class LepdClient(object): + def __init__(self, server, port=12307, config='release'): + self.server = server + self.port = port + self.bufferSize = 2048 + self.config = config + + self.LEPDENDINGSTRING = 'lepdendstring' + + def sendRequest(self, methodName): + sock = None + try: + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.connect((self.server, self.port)) + + input_data = {} + input_data['method'] = methodName + + dumped_data = json.dumps(input_data) + + sock.send(dumped_data.encode()) + serverResponse = str.encode("") + end = str.encode("lepdendstring") + while True: + data = sock.recv(self.bufferSize) + if end in data: + data = data.replace(end, str.encode("")) + serverResponse = serverResponse + data + break + serverResponse = serverResponse + data + responseJsonDecoded = json.loads(serverResponse.decode()) + return responseJsonDecoded + except Exception as error: + print("dataStore/lepdClient/LepdClient.py.sendRequest() throws an exception\n") + pass + finally: + if (sock): + sock.close() + + def listAllMethods(self): + response = self.sendRequest('ListAllMethod') + if (response == None or 'result' not in response): + return [] + lines = response['result'].strip().split() + return lines + + +if (__name__ == '__main__'): + pp = pprint.PrettyPrinter(indent=2) + client = LepdClient('www.rmlink.cn', config='debug') + + print(client.listAllMethods()) diff --git a/dataStore/lepdClient/__init__.py b/dataStore/lepdClient/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/dataStore/modules/__init__.py b/dataStore/modules/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/dataStore/modules/cpu/__init__.py b/dataStore/modules/cpu/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/dataStore/modules/cpu/cpuPullAndStore.py b/dataStore/modules/cpu/cpuPullAndStore.py new file mode 100644 index 0000000..a75bd77 --- /dev/null +++ b/dataStore/modules/cpu/cpuPullAndStore.py @@ -0,0 +1,38 @@ +__author__ = "李旭升 " +__copyright__ = "Licensed under GPLv2 or later." + + +from dataStore.lepdClient.LepdClient import LepdClient +from dataStore.influxDbUtil.dbUtil import myInfluxDbClient + +import time + + +''' +用lepdClient请求CPU相关数据并把返回的数据用influxDbClient存储到InfluxDB中 +''' +def pullAndStoreGetProcCpuinfo(lepdClient,influxDbClient): + res = lepdClient.sendRequest('GetProcCpuinfo') + + json_body = [ + { + "measurement": "GetProcCpuinfo", + "tags": { + # the address of lepd + "server": lepdClient.server + }, + # "time": "2017-03-12T22:00:00Z", + "fields": { + "cpuInfo":str(res) + } + } + ] + + influxDbClient.write_points('www.rmlink.cn', json_body) + + +if(__name__=='__main__'): + lepdClient = LepdClient('www.rmlink.cn') + influxDbClient = myInfluxDbClient('localhost') + + pullAndStoreGetProcCpuinfo(lepdClient,influxDbClient) diff --git a/dataStore/modules/memory/__init__.py b/dataStore/modules/memory/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/dataStore/modules/memory/memoryPullAndStore.py b/dataStore/modules/memory/memoryPullAndStore.py new file mode 100644 index 0000000..80230a4 --- /dev/null +++ b/dataStore/modules/memory/memoryPullAndStore.py @@ -0,0 +1,96 @@ +__author__ = "李旭升 " +__copyright__ = "Licensed under GPLv2 or later." + +from dataStore.lepdClient.LepdClient import LepdClient +from dataStore.influxDbUtil.dbUtil import myInfluxDbClient + +import time + +''' +用lepdClient请求数据并把返回的数据用influxDbClient存储到InfluxDB中 +''' +def pullAndStoreGetProcMeminfo(lepdClient, influxDbClient): + res = lepdClient.sendRequest('GetProcMeminfo') + print(res) + str = res['result'].split('\n') + data = {} + for x in str: + + x1 = x.replace('kB', '') + x2 = x1.replace(' ', '') + list = x2.split(':') + if (len(list) == 2): + data[list[0]] = list[1] + + # print(data) + + json_body = [ + { + "measurement": "GetProcMeminfo", + "tags": { + # the address of lepd + "server": lepdClient.server + }, + # "time": "2017-03-12T22:00:00Z", + "fields": { + "MemTotal": data['MemTotal'], + "MemFree": data['MemFree'], + # "MemAvailable": data['MemAvailable'], + "Buffers": data['Buffers'], + "Cached": data['Cached'], + "SwapCached": data['MemTotal'], + "Active": data['Active'], + "Inactive": data['Inactive'], + "Active(anon)": data['Active(anon)'], + "Inactive(anon)": data['Inactive(anon)'], + "Active(file)": data['Active(file)'], + "Inactive(file)": data['Inactive(file)'], + "Unevictable": data['Unevictable'], + "Mlocked": data['Mlocked'], + "SwapTotal": data['SwapTotal'], + "SwapFree": data['SwapFree'], + "Dirty": data['Dirty'], + "Writeback": data['Writeback'], + "AnonPages": data['AnonPages'], + "Mapped": data['Mapped'], + "Shmem": data['Shmem'], + "Slab": data['Slab'], + "SReclaimable": data['SReclaimable'], + "SUnreclaim": data['SUnreclaim'], + "KernelStack": data['KernelStack'], + "PageTables": data['PageTables'], + "NFS_Unstable": data['NFS_Unstable'], + "Bounce": data['Bounce'], + "WritebackTmp": data['WritebackTmp'], + "CommitLimit": data['CommitLimit'], + "Committed_AS": data['Committed_AS'], + "VmallocTotal": data['VmallocTotal'], + "VmallocUsed": data['VmallocUsed'], + "VmallocChunk": data['VmallocChunk'], + "HardwareCorrupted": data['HardwareCorrupted'], + "AnonHugePages": data['AnonHugePages'], + # "ShmemHugePages": data['ShmemHugePages'], + # "ShmemPmdMapped": data['ShmemPmdMapped'], + # "CmaTotal": data['CmaTotal'], + # "CmaFree": data['CmaFree'], + "HugePages_Total": data['HugePages_Total'], + "HugePages_Free": data['HugePages_Free'], + "HugePages_Rsvd": data['HugePages_Rsvd'], + "HugePages_Surp": data['HugePages_Surp'], + "Hugepagesize": data['Hugepagesize'], + "DirectMap4k": data['DirectMap4k'], + "DirectMap2M": data['DirectMap2M'], + "DirectMap1G": data['DirectMap1G'] + } + } + ] + + influxDbClient.write_points('www.rmlink.cn', json_body) + + +if (__name__ == '__main__'): + lepdClient = LepdClient('www.rmlink.cn') + influxDbClient = myInfluxDbClient('localhost') + for i in range(1): + pullAndStoreGetProcMeminfo(lepdClient, influxDbClient) + time.sleep(1) diff --git a/dataStore/query/__init__.py b/dataStore/query/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/dataStore/query/memory/__init__.py b/dataStore/query/memory/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/dataStore/query/memory/queryGetProcMeminfo.py b/dataStore/query/memory/queryGetProcMeminfo.py new file mode 100644 index 0000000..87a3686 --- /dev/null +++ b/dataStore/query/memory/queryGetProcMeminfo.py @@ -0,0 +1,23 @@ +__author__ = "李旭升 " +__copyright__ = "Licensed under GPLv2 or later." + + +from dataStore.influxDbUtil.dbUtil import myInfluxDbClient + +import time + +''' +从InfluxDB中查询memory信息 +拼接字段还未完成 +''' +def queryGetProcMeminfo(influxDbClient): + res = influxDbClient.query('select * from GetProcMeminfo limit 1') + print(res) + help(res) + + return None + +if(__name__=='__main__'): + influxDbClient = myInfluxDbClient('127.0.0.1') + queryGetProcMeminfo(influxDbClient) + From 8bd6e48747cbfe1122dcf4f0d82991de054f1b84 Mon Sep 17 00:00:00 2001 From: jiutianmuzi Date: Thu, 30 Nov 2017 12:07:11 +0800 Subject: [PATCH 02/25] create .gitignore --- .gitignore | 2 ++ dataStore/influxDbUtil/dbUtil.py | 12 ++++++------ dataStore/lepdClient/LepdClient.py | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b5072f7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +#IDE +.idea/ diff --git a/dataStore/influxDbUtil/dbUtil.py b/dataStore/influxDbUtil/dbUtil.py index bd42e4e..f7253eb 100644 --- a/dataStore/influxDbUtil/dbUtil.py +++ b/dataStore/influxDbUtil/dbUtil.py @@ -1,19 +1,19 @@ """Core module for interacting with influxDB""" -__author__ = "李旭升 " +__author__ = "" __copyright__ = "Licensed under GPLv2 or later." from influxdb import InfluxDBClient ''' -myInfluxDbClient是自己封装的InfluxDBClient, -为了插入和读取InfluxDB +MyInfluxDbClient is the warpper of InfluxDBClient, +To insert data and to query data can use it ''' -class myInfluxDbClient: - def __init__(self, influxDBAddress): - self._client = InfluxDBClient(influxDBAddress, 8086, 'root', ",", "lep") +class MyInfluxDbClient: + def __init__(self, influxDBAddress,port=8086,username='root',password='',database="lep"): + self._client = InfluxDBClient(influxDBAddress, port,username,password,database) def write_points(self, server, json_body): diff --git a/dataStore/lepdClient/LepdClient.py b/dataStore/lepdClient/LepdClient.py index c19b57a..97747ab 100644 --- a/dataStore/lepdClient/LepdClient.py +++ b/dataStore/lepdClient/LepdClient.py @@ -8,7 +8,7 @@ import socket ''' -LepdClient请求lepd返回数据 +LepdClient pulls data from lepd ''' From d7b6c66c2ee30b314e465e509e6b7eaa41d39215 Mon Sep 17 00:00:00 2001 From: jiutianmuzi <1530830954@qq.com> Date: Thu, 30 Nov 2017 12:27:04 +0800 Subject: [PATCH 03/25] delete a file test --- .idea/uiDesigner.xml | 124 ------------------------------------------- 1 file changed, 124 deletions(-) delete mode 100644 .idea/uiDesigner.xml diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml deleted file mode 100644 index e96534f..0000000 --- a/.idea/uiDesigner.xml +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From 46f97519ff60155243a94fc01660644179f8dd14 Mon Sep 17 00:00:00 2001 From: jiutianmuzi <1530830954@qq.com> Date: Thu, 30 Nov 2017 12:34:10 +0800 Subject: [PATCH 04/25] Delete vcs.xml --- .idea/vcs.xml | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 .idea/vcs.xml diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file From 3cea2c9f7d17dd18d719192ca22dec2a5694450d Mon Sep 17 00:00:00 2001 From: jiutianmuzi Date: Mon, 2 Apr 2018 17:56:16 +0800 Subject: [PATCH 05/25] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=B1=BB=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dataStore/modules/memory/memoryPullAndStore.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dataStore/modules/memory/memoryPullAndStore.py b/dataStore/modules/memory/memoryPullAndStore.py index 80230a4..69a74b1 100644 --- a/dataStore/modules/memory/memoryPullAndStore.py +++ b/dataStore/modules/memory/memoryPullAndStore.py @@ -2,7 +2,7 @@ __copyright__ = "Licensed under GPLv2 or later." from dataStore.lepdClient.LepdClient import LepdClient -from dataStore.influxDbUtil.dbUtil import myInfluxDbClient +from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient import time @@ -89,8 +89,8 @@ def pullAndStoreGetProcMeminfo(lepdClient, influxDbClient): if (__name__ == '__main__'): - lepdClient = LepdClient('www.rmlink.cn') - influxDbClient = myInfluxDbClient('localhost') + lepdClient = LepdClient('localhost') + influxDbClient = MyInfluxDbClient('localhost') for i in range(1): pullAndStoreGetProcMeminfo(lepdClient, influxDbClient) time.sleep(1) From 46981d5ae14c8fc095a93da8a70b8c4784ba6f10 Mon Sep 17 00:00:00 2001 From: lixusheng <1530830954@qq.com> Date: Sat, 21 Apr 2018 20:07:08 +0800 Subject: [PATCH 06/25] =?UTF-8?q?=E8=A7=A3=E6=9E=90=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dataStore/modules/cpu/cpuPullAndStore.py | 16 ++- .../modules/memory/memoryPullAndStore.py | 106 +++++++++--------- 2 files changed, 67 insertions(+), 55 deletions(-) diff --git a/dataStore/modules/cpu/cpuPullAndStore.py b/dataStore/modules/cpu/cpuPullAndStore.py index a75bd77..ee9f8e1 100644 --- a/dataStore/modules/cpu/cpuPullAndStore.py +++ b/dataStore/modules/cpu/cpuPullAndStore.py @@ -3,7 +3,7 @@ from dataStore.lepdClient.LepdClient import LepdClient -from dataStore.influxDbUtil.dbUtil import myInfluxDbClient +from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient import time @@ -13,6 +13,14 @@ ''' def pullAndStoreGetProcCpuinfo(lepdClient,influxDbClient): res = lepdClient.sendRequest('GetProcCpuinfo') + mystr = res['result'].split('\n') + data = {} + for x in mystr: + mylist=x.split('\t:') + if(len(mylist)==2): + data[mylist[0]]=mylist[1] + for key in data: + print(key+':'+data[key]) json_body = [ { @@ -28,11 +36,11 @@ def pullAndStoreGetProcCpuinfo(lepdClient,influxDbClient): } ] - influxDbClient.write_points('www.rmlink.cn', json_body) + # influxDbClient.write_points('localhost', json_body) if(__name__=='__main__'): - lepdClient = LepdClient('www.rmlink.cn') - influxDbClient = myInfluxDbClient('localhost') + lepdClient = LepdClient('localhost') + influxDbClient = MyInfluxDbClient('localhost') pullAndStoreGetProcCpuinfo(lepdClient,influxDbClient) diff --git a/dataStore/modules/memory/memoryPullAndStore.py b/dataStore/modules/memory/memoryPullAndStore.py index 69a74b1..615158e 100644 --- a/dataStore/modules/memory/memoryPullAndStore.py +++ b/dataStore/modules/memory/memoryPullAndStore.py @@ -1,20 +1,23 @@ -__author__ = "李旭升 " +__author__ = "李旭升 programmerli@foxmail.com > " + __copyright__ = "Licensed under GPLv2 or later." + +''' +用lepdClient请求数据并把返回的数据用influxDbClient存储到InfluxDB中 +''' + from dataStore.lepdClient.LepdClient import LepdClient from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient import time -''' -用lepdClient请求数据并把返回的数据用influxDbClient存储到InfluxDB中 -''' def pullAndStoreGetProcMeminfo(lepdClient, influxDbClient): res = lepdClient.sendRequest('GetProcMeminfo') print(res) - str = res['result'].split('\n') + mystr = res['result'].split('\n') data = {} - for x in str: + for x in mystr: x1 = x.replace('kB', '') x2 = x1.replace(' ', '') @@ -22,7 +25,8 @@ def pullAndStoreGetProcMeminfo(lepdClient, influxDbClient): if (len(list) == 2): data[list[0]] = list[1] - # print(data) + + #print(data['Active']) json_body = [ { @@ -33,54 +37,54 @@ def pullAndStoreGetProcMeminfo(lepdClient, influxDbClient): }, # "time": "2017-03-12T22:00:00Z", "fields": { - "MemTotal": data['MemTotal'], - "MemFree": data['MemFree'], + "MemTotal": int(data['MemTotal']), + "MemFree": int(data['MemFree']), # "MemAvailable": data['MemAvailable'], - "Buffers": data['Buffers'], - "Cached": data['Cached'], - "SwapCached": data['MemTotal'], - "Active": data['Active'], - "Inactive": data['Inactive'], - "Active(anon)": data['Active(anon)'], - "Inactive(anon)": data['Inactive(anon)'], - "Active(file)": data['Active(file)'], - "Inactive(file)": data['Inactive(file)'], - "Unevictable": data['Unevictable'], - "Mlocked": data['Mlocked'], - "SwapTotal": data['SwapTotal'], - "SwapFree": data['SwapFree'], - "Dirty": data['Dirty'], - "Writeback": data['Writeback'], - "AnonPages": data['AnonPages'], - "Mapped": data['Mapped'], - "Shmem": data['Shmem'], - "Slab": data['Slab'], - "SReclaimable": data['SReclaimable'], - "SUnreclaim": data['SUnreclaim'], - "KernelStack": data['KernelStack'], - "PageTables": data['PageTables'], - "NFS_Unstable": data['NFS_Unstable'], - "Bounce": data['Bounce'], - "WritebackTmp": data['WritebackTmp'], - "CommitLimit": data['CommitLimit'], - "Committed_AS": data['Committed_AS'], - "VmallocTotal": data['VmallocTotal'], - "VmallocUsed": data['VmallocUsed'], - "VmallocChunk": data['VmallocChunk'], - "HardwareCorrupted": data['HardwareCorrupted'], - "AnonHugePages": data['AnonHugePages'], + "Buffers": int(data['Buffers']), + "Cached": int(data['Cached']), + "SwapCached": int(data['MemTotal']), + "Active": int(data['Active']), + "Inactive": int(data['Inactive']), + "Active(anon)": int(data['Active(anon)']), + "Inactive(anon)": int(data['Inactive(anon)']), + "Active(file)": int(data['Active(file)']), + "Inactive(file)": int(data['Inactive(file)']), + "Unevictable": int(data['Unevictable']), + "Mlocked": int(data['Mlocked']), + "SwapTotal": int(data['SwapTotal']), + "SwapFree": int(data['SwapFree']), + "Dirty": int(data['Dirty']), + "Writeback": int(data['Writeback']), + "AnonPages": int(data['AnonPages']), + "Mapped": int(data['Mapped']), + "Shmem": int(data['Shmem']), + "Slab": int(data['Slab']), + "SReclaimable": int(data['SReclaimable']), + "SUnreclaim": int(data['SUnreclaim']), + "KernelStack": int(data['KernelStack']), + "PageTables": int(data['PageTables']), + "NFS_Unstable": int(data['NFS_Unstable']), + "Bounce": int(data['Bounce']), + "WritebackTmp": int(data['WritebackTmp']), + "CommitLimit": int(data['CommitLimit']), + "Committed_AS": int(data['Committed_AS']), + "VmallocTotal": int(data['VmallocTotal']), + "VmallocUsed": int(data['VmallocUsed']), + "VmallocChunk": int(data['VmallocChunk']), + "HardwareCorrupted": int(data['HardwareCorrupted']), + "AnonHugePages": int(data['AnonHugePages']), # "ShmemHugePages": data['ShmemHugePages'], # "ShmemPmdMapped": data['ShmemPmdMapped'], # "CmaTotal": data['CmaTotal'], # "CmaFree": data['CmaFree'], - "HugePages_Total": data['HugePages_Total'], - "HugePages_Free": data['HugePages_Free'], - "HugePages_Rsvd": data['HugePages_Rsvd'], - "HugePages_Surp": data['HugePages_Surp'], - "Hugepagesize": data['Hugepagesize'], - "DirectMap4k": data['DirectMap4k'], - "DirectMap2M": data['DirectMap2M'], - "DirectMap1G": data['DirectMap1G'] + "HugePages_Total": int(data['HugePages_Total']), + "HugePages_Free": int(data['HugePages_Free']), + "HugePages_Rsvd": int(data['HugePages_Rsvd']), + "HugePages_Surp": int(data['HugePages_Surp']), + "Hugepagesize": int(data['Hugepagesize']), + "DirectMap4k": int(data['DirectMap4k']), + "DirectMap2M": int(data['DirectMap2M']), + "DirectMap1G": int(data['DirectMap1G']) } } ] @@ -91,6 +95,6 @@ def pullAndStoreGetProcMeminfo(lepdClient, influxDbClient): if (__name__ == '__main__'): lepdClient = LepdClient('localhost') influxDbClient = MyInfluxDbClient('localhost') - for i in range(1): + for i in range(60): pullAndStoreGetProcMeminfo(lepdClient, influxDbClient) time.sleep(1) From dff4b8229e12ec97c2b800275171eb0aea494ff2 Mon Sep 17 00:00:00 2001 From: lixusheng <1530830954@qq.com> Date: Sat, 21 Apr 2018 20:17:03 +0800 Subject: [PATCH 07/25] add files --- dataStore/modules/pullAndStoreGetCmdDf.py | 24 +++++ dataStore/modules/pullAndStoreGetCmdDmesg.py | 24 +++++ dataStore/modules/pullAndStoreGetCmdFree.py | 24 +++++ dataStore/modules/pullAndStoreGetCmdIostat.py | 24 +++++ dataStore/modules/pullAndStoreGetCmdIotop.py | 24 +++++ .../modules/pullAndStoreGetCmdIrqInfo.py | 24 +++++ .../modules/pullAndStoreGetCmdMpstat-I.py | 24 +++++ dataStore/modules/pullAndStoreGetCmdMpstat.py | 24 +++++ .../modules/pullAndStoreGetCmdPerfCpuclock.py | 24 +++++ .../modules/pullAndStoreGetCmdPerfFaults.py | 24 +++++ .../modules/pullAndStoreGetCmdPerfFlame.py | 24 +++++ .../modules/pullAndStoreGetCmdProcrank.py | 24 +++++ dataStore/modules/pullAndStoreGetCmdTop.py | 24 +++++ dataStore/modules/pullAndStoreGetCpuInfo.py | 24 +++++ .../modules/pullAndStoreGetProcBuddyinfo.py | 97 +++++++++++++++++++ .../modules/pullAndStoreGetProcDiskstats.py | 24 +++++ .../modules/pullAndStoreGetProcInterrupts.py | 24 +++++ .../modules/pullAndStoreGetProcLoadavg.py | 97 +++++++++++++++++++ .../modules/pullAndStoreGetProcModules.py | 24 +++++ .../modules/pullAndStoreGetProcSlabinfo.py | 24 +++++ .../modules/pullAndStoreGetProcSoftirqs.py | 24 +++++ dataStore/modules/pullAndStoreGetProcStat.py | 24 +++++ dataStore/modules/pullAndStoreGetProcSwaps.py | 24 +++++ .../modules/pullAndStoreGetProcVersion.py | 24 +++++ .../modules/pullAndStoreGetProcVmstat.py | 97 +++++++++++++++++++ .../modules/pullAndStoreGetProcZoneinfo.py | 24 +++++ 26 files changed, 843 insertions(+) create mode 100755 dataStore/modules/pullAndStoreGetCmdDf.py create mode 100755 dataStore/modules/pullAndStoreGetCmdDmesg.py create mode 100755 dataStore/modules/pullAndStoreGetCmdFree.py create mode 100755 dataStore/modules/pullAndStoreGetCmdIostat.py create mode 100755 dataStore/modules/pullAndStoreGetCmdIotop.py create mode 100755 dataStore/modules/pullAndStoreGetCmdIrqInfo.py create mode 100755 dataStore/modules/pullAndStoreGetCmdMpstat-I.py create mode 100755 dataStore/modules/pullAndStoreGetCmdMpstat.py create mode 100755 dataStore/modules/pullAndStoreGetCmdPerfCpuclock.py create mode 100755 dataStore/modules/pullAndStoreGetCmdPerfFaults.py create mode 100755 dataStore/modules/pullAndStoreGetCmdPerfFlame.py create mode 100755 dataStore/modules/pullAndStoreGetCmdProcrank.py create mode 100755 dataStore/modules/pullAndStoreGetCmdTop.py create mode 100755 dataStore/modules/pullAndStoreGetCpuInfo.py create mode 100755 dataStore/modules/pullAndStoreGetProcBuddyinfo.py create mode 100755 dataStore/modules/pullAndStoreGetProcDiskstats.py create mode 100755 dataStore/modules/pullAndStoreGetProcInterrupts.py create mode 100755 dataStore/modules/pullAndStoreGetProcLoadavg.py create mode 100755 dataStore/modules/pullAndStoreGetProcModules.py create mode 100755 dataStore/modules/pullAndStoreGetProcSlabinfo.py create mode 100755 dataStore/modules/pullAndStoreGetProcSoftirqs.py create mode 100755 dataStore/modules/pullAndStoreGetProcStat.py create mode 100755 dataStore/modules/pullAndStoreGetProcSwaps.py create mode 100755 dataStore/modules/pullAndStoreGetProcVersion.py create mode 100755 dataStore/modules/pullAndStoreGetProcVmstat.py create mode 100755 dataStore/modules/pullAndStoreGetProcZoneinfo.py diff --git a/dataStore/modules/pullAndStoreGetCmdDf.py b/dataStore/modules/pullAndStoreGetCmdDf.py new file mode 100755 index 0000000..3ad1ed3 --- /dev/null +++ b/dataStore/modules/pullAndStoreGetCmdDf.py @@ -0,0 +1,24 @@ +__author__ = "" +__copyright__ = "Licensed under GPLv2 or later." + +from app.modules.lepd.LepDClient import LepDClient +from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient + +import time + +''' +fetch data related to GetCmdDf from lepd by lepdClient and +store the returned data into the influxDB by influxDBClient. +''' +def pullAndStoreGetCmdDf(lepdClient, influxDbClient): + res = lepdClient.sendRequest('GetCmdDf') + print(res) + + + +if (__name__ == '__main__'): + lepdClient = LepDClient('www.rmlink.cn') + influxDbClient = MyInfluxDbClient('localhost') + for i in range(1): + pullAndStoreGetCmdDf(lepdClient, influxDbClient) + time.sleep(1) diff --git a/dataStore/modules/pullAndStoreGetCmdDmesg.py b/dataStore/modules/pullAndStoreGetCmdDmesg.py new file mode 100755 index 0000000..e5749e1 --- /dev/null +++ b/dataStore/modules/pullAndStoreGetCmdDmesg.py @@ -0,0 +1,24 @@ +__author__ = "" +__copyright__ = "Licensed under GPLv2 or later." + +from app.modules.lepd.LepDClient import LepDClient +from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient + +import time + +''' +fetch data related to GetCmdDmesg from lepd by lepdClient and +store the returned data into the influxDB by influxDBClient. +''' +def pullAndStoreGetCmdDmesg(lepdClient, influxDbClient): + res = lepdClient.sendRequest('GetCmdDmesg') + print(res) + + + +if (__name__ == '__main__'): + lepdClient = LepDClient('www.rmlink.cn') + influxDbClient = MyInfluxDbClient('localhost') + for i in range(1): + pullAndStoreGetCmdDmesg(lepdClient, influxDbClient) + time.sleep(1) diff --git a/dataStore/modules/pullAndStoreGetCmdFree.py b/dataStore/modules/pullAndStoreGetCmdFree.py new file mode 100755 index 0000000..d7fde60 --- /dev/null +++ b/dataStore/modules/pullAndStoreGetCmdFree.py @@ -0,0 +1,24 @@ +__author__ = "" +__copyright__ = "Licensed under GPLv2 or later." + +from app.modules.lepd.LepDClient import LepDClient +from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient + +import time + +''' +fetch data related to GetCmdFree from lepd by lepdClient and +store the returned data into the influxDB by influxDBClient. +''' +def pullAndStoreGetCmdFree(lepdClient, influxDbClient): + res = lepdClient.sendRequest('GetCmdFree') + print(res) + + + +if (__name__ == '__main__'): + lepdClient = LepDClient('www.rmlink.cn') + influxDbClient = MyInfluxDbClient('localhost') + for i in range(1): + pullAndStoreGetCmdFree(lepdClient, influxDbClient) + time.sleep(1) diff --git a/dataStore/modules/pullAndStoreGetCmdIostat.py b/dataStore/modules/pullAndStoreGetCmdIostat.py new file mode 100755 index 0000000..af0edd5 --- /dev/null +++ b/dataStore/modules/pullAndStoreGetCmdIostat.py @@ -0,0 +1,24 @@ +__author__ = "" +__copyright__ = "Licensed under GPLv2 or later." + +from app.modules.lepd.LepDClient import LepDClient +from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient + +import time + +''' +fetch data related to GetCmdIostat from lepd by lepdClient and +store the returned data into the influxDB by influxDBClient. +''' +def pullAndStoreGetCmdIostat(lepdClient, influxDbClient): + res = lepdClient.sendRequest('GetCmdIostat') + print(res) + + + +if (__name__ == '__main__'): + lepdClient = LepDClient('www.rmlink.cn') + influxDbClient = MyInfluxDbClient('localhost') + for i in range(1): + pullAndStoreGetCmdIostat(lepdClient, influxDbClient) + time.sleep(1) diff --git a/dataStore/modules/pullAndStoreGetCmdIotop.py b/dataStore/modules/pullAndStoreGetCmdIotop.py new file mode 100755 index 0000000..1a00bd7 --- /dev/null +++ b/dataStore/modules/pullAndStoreGetCmdIotop.py @@ -0,0 +1,24 @@ +__author__ = "" +__copyright__ = "Licensed under GPLv2 or later." + +from app.modules.lepd.LepDClient import LepDClient +from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient + +import time + +''' +fetch data related to GetCmdIrqInfo from lepd by lepdClient and +store the returned data into the influxDB by influxDBClient. +''' +def pullAndStoreGetCmdIrqInfo(lepdClient, influxDbClient): + res = lepdClient.sendRequest('GetCmdIrqInfo') + print(res) + + + +if (__name__ == '__main__'): + lepdClient = LepDClient('www.rmlink.cn') + influxDbClient = MyInfluxDbClient('localhost') + for i in range(1): + pullAndStoreGetCmdIrqInfo(lepdClient, influxDbClient) + time.sleep(1) diff --git a/dataStore/modules/pullAndStoreGetCmdIrqInfo.py b/dataStore/modules/pullAndStoreGetCmdIrqInfo.py new file mode 100755 index 0000000..e5749e1 --- /dev/null +++ b/dataStore/modules/pullAndStoreGetCmdIrqInfo.py @@ -0,0 +1,24 @@ +__author__ = "" +__copyright__ = "Licensed under GPLv2 or later." + +from app.modules.lepd.LepDClient import LepDClient +from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient + +import time + +''' +fetch data related to GetCmdDmesg from lepd by lepdClient and +store the returned data into the influxDB by influxDBClient. +''' +def pullAndStoreGetCmdDmesg(lepdClient, influxDbClient): + res = lepdClient.sendRequest('GetCmdDmesg') + print(res) + + + +if (__name__ == '__main__'): + lepdClient = LepDClient('www.rmlink.cn') + influxDbClient = MyInfluxDbClient('localhost') + for i in range(1): + pullAndStoreGetCmdDmesg(lepdClient, influxDbClient) + time.sleep(1) diff --git a/dataStore/modules/pullAndStoreGetCmdMpstat-I.py b/dataStore/modules/pullAndStoreGetCmdMpstat-I.py new file mode 100755 index 0000000..bad5359 --- /dev/null +++ b/dataStore/modules/pullAndStoreGetCmdMpstat-I.py @@ -0,0 +1,24 @@ +__author__ = "" +__copyright__ = "Licensed under GPLv2 or later." + +from app.modules.lepd.LepDClient import LepDClient +from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient + +import time + +''' +fetch data related to GetCmdMpstat-I from lepd by lepdClient and +store the returned data into the influxDB by influxDBClient. +''' +def pullAndStoreGetCmdMpstat_I(lepdClient, influxDbClient): + res = lepdClient.sendRequest('GetCmdMpstat-I') + print(res) + + + +if (__name__ == '__main__'): + lepdClient = LepDClient('www.rmlink.cn') + influxDbClient = MyInfluxDbClient('localhost') + for i in range(1): + pullAndStoreGetCmdMpstat_I(lepdClient, influxDbClient) + time.sleep(1) diff --git a/dataStore/modules/pullAndStoreGetCmdMpstat.py b/dataStore/modules/pullAndStoreGetCmdMpstat.py new file mode 100755 index 0000000..8795784 --- /dev/null +++ b/dataStore/modules/pullAndStoreGetCmdMpstat.py @@ -0,0 +1,24 @@ +__author__ = "" +__copyright__ = "Licensed under GPLv2 or later." + +from app.modules.lepd.LepDClient import LepDClient +from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient + +import time + +''' +fetch data related to GetCmdMpstat from lepd by lepdClient and +store the returned data into the influxDB by influxDBClient. +''' +def pullAndStoreGetCmdMpstat(lepdClient, influxDbClient): + res = lepdClient.sendRequest('GetCmdMpstat') + print(res) + + + +if (__name__ == '__main__'): + lepdClient = LepDClient('www.rmlink.cn') + influxDbClient = MyInfluxDbClient('localhost') + for i in range(1): + pullAndStoreGetCmdMpstat(lepdClient, influxDbClient) + time.sleep(1) diff --git a/dataStore/modules/pullAndStoreGetCmdPerfCpuclock.py b/dataStore/modules/pullAndStoreGetCmdPerfCpuclock.py new file mode 100755 index 0000000..97c65a5 --- /dev/null +++ b/dataStore/modules/pullAndStoreGetCmdPerfCpuclock.py @@ -0,0 +1,24 @@ +__author__ = "" +__copyright__ = "Licensed under GPLv2 or later." + +from app.modules.lepd.LepDClient import LepDClient +from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient + +import time + +''' +fetch data related to GetCmdPerfCpuclock from lepd by lepdClient and +store the returned data into the influxDB by influxDBClient. +''' +def pullAndStoreGetCmdPerfCpuclock(lepdClient, influxDbClient): + res = lepdClient.sendRequest('GetCmdPerfCpuclock') + print(res) + + + +if (__name__ == '__main__'): + lepdClient = LepDClient('www.rmlink.cn') + influxDbClient = MyInfluxDbClient('localhost') + for i in range(1): + pullAndStoreGetCmdPerfCpuclock(lepdClient, influxDbClient) + time.sleep(1) diff --git a/dataStore/modules/pullAndStoreGetCmdPerfFaults.py b/dataStore/modules/pullAndStoreGetCmdPerfFaults.py new file mode 100755 index 0000000..debc94e --- /dev/null +++ b/dataStore/modules/pullAndStoreGetCmdPerfFaults.py @@ -0,0 +1,24 @@ +__author__ = "" +__copyright__ = "Licensed under GPLv2 or later." + +from app.modules.lepd.LepDClient import LepDClient +from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient + +import time + +''' +fetch data related to GetCmdPerfFaults from lepd by lepdClient and +store the returned data into the influxDB by influxDBClient. +''' +def pullAndStoreGetCmdPerfFaults(lepdClient, influxDbClient): + res = lepdClient.sendRequest('GetCmdPerfFaults') + print(res) + + + +if (__name__ == '__main__'): + lepdClient = LepDClient('www.rmlink.cn') + influxDbClient = MyInfluxDbClient('localhost') + for i in range(1): + pullAndStoreGetCmdPerfFaults(lepdClient, influxDbClient) + time.sleep(1) diff --git a/dataStore/modules/pullAndStoreGetCmdPerfFlame.py b/dataStore/modules/pullAndStoreGetCmdPerfFlame.py new file mode 100755 index 0000000..41a2bde --- /dev/null +++ b/dataStore/modules/pullAndStoreGetCmdPerfFlame.py @@ -0,0 +1,24 @@ +__author__ = "" +__copyright__ = "Licensed under GPLv2 or later." + +from app.modules.lepd.LepDClient import LepDClient +from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient + +import time + +''' +fetch data related to GetCmdPerfFlame from lepd by lepdClient and +store the returned data into the influxDB by influxDBClient. +''' +def pullAndStoreGetCmdPerfFlame(lepdClient, influxDbClient): + res = lepdClient.sendRequest('GetCmdPerfFlame') + print(res) + + + +if (__name__ == '__main__'): + lepdClient = LepDClient('www.rmlink.cn') + influxDbClient = MyInfluxDbClient('localhost') + for i in range(1): + pullAndStoreGetCmdPerfFlame(lepdClient, influxDbClient) + time.sleep(1) diff --git a/dataStore/modules/pullAndStoreGetCmdProcrank.py b/dataStore/modules/pullAndStoreGetCmdProcrank.py new file mode 100755 index 0000000..e4f947f --- /dev/null +++ b/dataStore/modules/pullAndStoreGetCmdProcrank.py @@ -0,0 +1,24 @@ +__author__ = "" +__copyright__ = "Licensed under GPLv2 or later." + +from app.modules.lepd.LepDClient import LepDClient +from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient + +import time + +''' +fetch data related to GetCmdProcrank from lepd by lepdClient and +store the returned data into the influxDB by influxDBClient. +''' +def pullAndStoreGetCmdProcrank(lepdClient, influxDbClient): + res = lepdClient.sendRequest('GetCmdProcrank') + print(res) + + + +if (__name__ == '__main__'): + lepdClient = LepDClient('www.rmlink.cn') + influxDbClient = MyInfluxDbClient('localhost') + for i in range(1): + pullAndStoreGetCmdProcrank(lepdClient, influxDbClient) + time.sleep(1) diff --git a/dataStore/modules/pullAndStoreGetCmdTop.py b/dataStore/modules/pullAndStoreGetCmdTop.py new file mode 100755 index 0000000..9930817 --- /dev/null +++ b/dataStore/modules/pullAndStoreGetCmdTop.py @@ -0,0 +1,24 @@ +__author__ = "" +__copyright__ = "Licensed under GPLv2 or later." + +from app.modules.lepd.LepDClient import LepDClient +from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient + +import time + +''' +fetch data related to GetCmdTop from lepd by lepdClient and +store the returned data into the influxDB by influxDBClient. +''' +def pullAndStoreGetCmdTop(lepdClient, influxDbClient): + res = lepdClient.sendRequest('GetCmdTop') + print(res) + + + +if (__name__ == '__main__'): + lepdClient = LepDClient('www.rmlink.cn') + influxDbClient = MyInfluxDbClient('localhost') + for i in range(1): + pullAndStoreGetCmdTop(lepdClient, influxDbClient) + time.sleep(1) diff --git a/dataStore/modules/pullAndStoreGetCpuInfo.py b/dataStore/modules/pullAndStoreGetCpuInfo.py new file mode 100755 index 0000000..f106ab9 --- /dev/null +++ b/dataStore/modules/pullAndStoreGetCpuInfo.py @@ -0,0 +1,24 @@ +__author__ = "" +__copyright__ = "Licensed under GPLv2 or later." + +from dataStore.lepdClient.LepdClient import LepdClient +from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient + +import time + +''' +fetch data related to GetCpuInfo from lepd by lepdClient and +store the returned data into the influxDB by influxDBClient. +''' +def pullAndStoreGetCpuInfo(lepdClient, influxDbClient): + res = lepdClient.sendRequest('GetCpuInfo') + print(res) + + + +if (__name__ == '__main__'): + lepdClient = LepdClient('localhost') + influxDbClient = MyInfluxDbClient('localhost') + for i in range(1): + pullAndStoreGetCpuInfo(lepdClient, influxDbClient) + time.sleep(1) diff --git a/dataStore/modules/pullAndStoreGetProcBuddyinfo.py b/dataStore/modules/pullAndStoreGetProcBuddyinfo.py new file mode 100755 index 0000000..b3b1ca0 --- /dev/null +++ b/dataStore/modules/pullAndStoreGetProcBuddyinfo.py @@ -0,0 +1,97 @@ +__author__ = "" +__copyright__ = "Licensed under GPLv2 or later." + +from app.modules.lepd.LepDClient import LepDClient +from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient + +import time + +''' +fetch data related to GetProcBuddyinfo from lepd by lepdClient and +store the returned data into the influxDB by influxDBClient. +''' +def pullAndStoreGetProcBuddyinfo(lepdClient, influxDbClient): + res = lepdClient.sendRequest('GetProcBuddyinfo') + print(res) + # str = res['result'].split('\n') + # data = {} + # for x in str: + # + # x1 = x.replace('kB', '') + # x2 = x1.replace(' ', '') + # list = x2.split(':') + # if (len(list) == 2): + # data[list[0]] = list[1] + # + # # print(data) + # + # json_body = [ + # { + # "measurement": "GetProcMeminfo", + # "tags": { + # # the address of lepd + # "server": lepdClient.server + # }, + # # "time": "2017-03-12T22:00:00Z", + # "fields": { + # "MemTotal": data['MemTotal'], + # "MemFree": data['MemFree'], + # # "MemAvailable": data['MemAvailable'], + # "Buffers": data['Buffers'], + # "Cached": data['Cached'], + # "SwapCached": data['MemTotal'], + # "Active": data['Active'], + # "Inactive": data['Inactive'], + # "Active(anon)": data['Active(anon)'], + # "Inactive(anon)": data['Inactive(anon)'], + # "Active(file)": data['Active(file)'], + # "Inactive(file)": data['Inactive(file)'], + # "Unevictable": data['Unevictable'], + # "Mlocked": data['Mlocked'], + # "SwapTotal": data['SwapTotal'], + # "SwapFree": data['SwapFree'], + # "Dirty": data['Dirty'], + # "Writeback": data['Writeback'], + # "AnonPages": data['AnonPages'], + # "Mapped": data['Mapped'], + # "Shmem": data['Shmem'], + # "Slab": data['Slab'], + # "SReclaimable": data['SReclaimable'], + # "SUnreclaim": data['SUnreclaim'], + # "KernelStack": data['KernelStack'], + # "PageTables": data['PageTables'], + # "NFS_Unstable": data['NFS_Unstable'], + # "Bounce": data['Bounce'], + # "WritebackTmp": data['WritebackTmp'], + # "CommitLimit": data['CommitLimit'], + # "Committed_AS": data['Committed_AS'], + # "VmallocTotal": data['VmallocTotal'], + # "VmallocUsed": data['VmallocUsed'], + # "VmallocChunk": data['VmallocChunk'], + # "HardwareCorrupted": data['HardwareCorrupted'], + # "AnonHugePages": data['AnonHugePages'], + # # "ShmemHugePages": data['ShmemHugePages'], + # # "ShmemPmdMapped": data['ShmemPmdMapped'], + # # "CmaTotal": data['CmaTotal'], + # # "CmaFree": data['CmaFree'], + # "HugePages_Total": data['HugePages_Total'], + # "HugePages_Free": data['HugePages_Free'], + # "HugePages_Rsvd": data['HugePages_Rsvd'], + # "HugePages_Surp": data['HugePages_Surp'], + # "Hugepagesize": data['Hugepagesize'], + # "DirectMap4k": data['DirectMap4k'], + # "DirectMap2M": data['DirectMap2M'], + # "DirectMap1G": data['DirectMap1G'] + # } + # } + # ] + # + # influxDbClient.write_points('www.rmlink.cn', json_body) + + +if (__name__ == '__main__'): + lepdClient = LepDClient('www.rmlink.cn') + influxDbClient = MyInfluxDbClient('localhost') + for i in range(1): + pullAndStoreGetProcBuddyinfo(lepdClient, influxDbClient) + time.sleep(1) diff --git a/dataStore/modules/pullAndStoreGetProcDiskstats.py b/dataStore/modules/pullAndStoreGetProcDiskstats.py new file mode 100755 index 0000000..bfd4d9a --- /dev/null +++ b/dataStore/modules/pullAndStoreGetProcDiskstats.py @@ -0,0 +1,24 @@ +__author__ = "" +__copyright__ = "Licensed under GPLv2 or later." + +from app.modules.lepd.LepDClient import LepDClient +from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient + +import time + +''' +fetch data related to GetProcDiskstats from lepd by lepdClient and +store the returned data into the influxDB by influxDBClient. +''' +def pullAndStoreGetProcDiskstats(lepdClient, influxDbClient): + res = lepdClient.sendRequest('GetProcDiskstats') + print(res) + + + +if (__name__ == '__main__'): + lepdClient = LepDClient('www.rmlink.cn') + influxDbClient = MyInfluxDbClient('localhost') + for i in range(1): + pullAndStoreGetProcDiskstats(lepdClient, influxDbClient) + time.sleep(1) diff --git a/dataStore/modules/pullAndStoreGetProcInterrupts.py b/dataStore/modules/pullAndStoreGetProcInterrupts.py new file mode 100755 index 0000000..d7f99a5 --- /dev/null +++ b/dataStore/modules/pullAndStoreGetProcInterrupts.py @@ -0,0 +1,24 @@ +__author__ = "" +__copyright__ = "Licensed under GPLv2 or later." + +from app.modules.lepd.LepDClient import LepDClient +from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient + +import time + +''' +fetch data related to GetProcInterrupts from lepd by lepdClient and +store the returned data into the influxDB by influxDBClient. +''' +def pullAndStoreGetProcInterrupts(lepdClient, influxDbClient): + res = lepdClient.sendRequest('GetProcInterrupts') + print(res) + + + +if (__name__ == '__main__'): + lepdClient = LepDClient('www.rmlink.cn') + influxDbClient = MyInfluxDbClient('localhost') + for i in range(1): + pullAndStoreGetProcInterrupts(lepdClient, influxDbClient) + time.sleep(1) diff --git a/dataStore/modules/pullAndStoreGetProcLoadavg.py b/dataStore/modules/pullAndStoreGetProcLoadavg.py new file mode 100755 index 0000000..b495c7b --- /dev/null +++ b/dataStore/modules/pullAndStoreGetProcLoadavg.py @@ -0,0 +1,97 @@ +__author__ = "" +__copyright__ = "Licensed under GPLv2 or later." + +from app.modules.lepd.LepDClient import LepDClient +from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient + +import time + +''' +fetch data related to GetProcLoadavg from lepd by lepdClient and +store the returned data into the influxDB by influxDBClient. +''' +def pullAndStoreGetProcLoadavg(lepdClient, influxDbClient): + res = lepdClient.sendRequest('GetProcLoadavg') + print(res) + # str = res['result'].split('\n') + # data = {} + # for x in str: + # + # x1 = x.replace('kB', '') + # x2 = x1.replace(' ', '') + # list = x2.split(':') + # if (len(list) == 2): + # data[list[0]] = list[1] + # + # # print(data) + # + # json_body = [ + # { + # "measurement": "GetProcMeminfo", + # "tags": { + # # the address of lepd + # "server": lepdClient.server + # }, + # # "time": "2017-03-12T22:00:00Z", + # "fields": { + # "MemTotal": data['MemTotal'], + # "MemFree": data['MemFree'], + # # "MemAvailable": data['MemAvailable'], + # "Buffers": data['Buffers'], + # "Cached": data['Cached'], + # "SwapCached": data['MemTotal'], + # "Active": data['Active'], + # "Inactive": data['Inactive'], + # "Active(anon)": data['Active(anon)'], + # "Inactive(anon)": data['Inactive(anon)'], + # "Active(file)": data['Active(file)'], + # "Inactive(file)": data['Inactive(file)'], + # "Unevictable": data['Unevictable'], + # "Mlocked": data['Mlocked'], + # "SwapTotal": data['SwapTotal'], + # "SwapFree": data['SwapFree'], + # "Dirty": data['Dirty'], + # "Writeback": data['Writeback'], + # "AnonPages": data['AnonPages'], + # "Mapped": data['Mapped'], + # "Shmem": data['Shmem'], + # "Slab": data['Slab'], + # "SReclaimable": data['SReclaimable'], + # "SUnreclaim": data['SUnreclaim'], + # "KernelStack": data['KernelStack'], + # "PageTables": data['PageTables'], + # "NFS_Unstable": data['NFS_Unstable'], + # "Bounce": data['Bounce'], + # "WritebackTmp": data['WritebackTmp'], + # "CommitLimit": data['CommitLimit'], + # "Committed_AS": data['Committed_AS'], + # "VmallocTotal": data['VmallocTotal'], + # "VmallocUsed": data['VmallocUsed'], + # "VmallocChunk": data['VmallocChunk'], + # "HardwareCorrupted": data['HardwareCorrupted'], + # "AnonHugePages": data['AnonHugePages'], + # # "ShmemHugePages": data['ShmemHugePages'], + # # "ShmemPmdMapped": data['ShmemPmdMapped'], + # # "CmaTotal": data['CmaTotal'], + # # "CmaFree": data['CmaFree'], + # "HugePages_Total": data['HugePages_Total'], + # "HugePages_Free": data['HugePages_Free'], + # "HugePages_Rsvd": data['HugePages_Rsvd'], + # "HugePages_Surp": data['HugePages_Surp'], + # "Hugepagesize": data['Hugepagesize'], + # "DirectMap4k": data['DirectMap4k'], + # "DirectMap2M": data['DirectMap2M'], + # "DirectMap1G": data['DirectMap1G'] + # } + # } + # ] + # + # influxDbClient.write_points('www.rmlink.cn', json_body) + + +if (__name__ == '__main__'): + lepdClient = LepDClient('www.rmlink.cn') + influxDbClient = MyInfluxDbClient('localhost') + for i in range(5): + pullAndStoreGetProcLoadavg(lepdClient, influxDbClient) + time.sleep(1) diff --git a/dataStore/modules/pullAndStoreGetProcModules.py b/dataStore/modules/pullAndStoreGetProcModules.py new file mode 100755 index 0000000..e90a491 --- /dev/null +++ b/dataStore/modules/pullAndStoreGetProcModules.py @@ -0,0 +1,24 @@ +__author__ = "" +__copyright__ = "Licensed under GPLv2 or later." + +from app.modules.lepd.LepDClient import LepDClient +from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient + +import time + +''' +fetch data related to GetProcModules from lepd by lepdClient and +store the returned data into the influxDB by influxDBClient. +''' +def pullAndStoreGetProcModules(lepdClient, influxDbClient): + res = lepdClient.sendRequest('GetProcModules') + print(res) + + + +if (__name__ == '__main__'): + lepdClient = LepDClient('www.rmlink.cn') + influxDbClient = MyInfluxDbClient('localhost') + for i in range(1): + pullAndStoreGetProcModules(lepdClient, influxDbClient) + time.sleep(1) diff --git a/dataStore/modules/pullAndStoreGetProcSlabinfo.py b/dataStore/modules/pullAndStoreGetProcSlabinfo.py new file mode 100755 index 0000000..0c3192b --- /dev/null +++ b/dataStore/modules/pullAndStoreGetProcSlabinfo.py @@ -0,0 +1,24 @@ +__author__ = "" +__copyright__ = "Licensed under GPLv2 or later." + +from app.modules.lepd.LepDClient import LepDClient +from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient + +import time + +''' +fetch data related to GetProcSlabinfo from lepd by lepdClient and +store the returned data into the influxDB by influxDBClient. +''' +def pullAndStoreGetProcSlabinfo(lepdClient, influxDbClient): + res = lepdClient.sendRequest('GetProcSlabinfo') + print(res) + + + +if (__name__ == '__main__'): + lepdClient = LepDClient('www.rmlink.cn') + influxDbClient = MyInfluxDbClient('localhost') + for i in range(1): + pullAndStoreGetProcSlabinfo(lepdClient, influxDbClient) + time.sleep(1) diff --git a/dataStore/modules/pullAndStoreGetProcSoftirqs.py b/dataStore/modules/pullAndStoreGetProcSoftirqs.py new file mode 100755 index 0000000..a9f5a9a --- /dev/null +++ b/dataStore/modules/pullAndStoreGetProcSoftirqs.py @@ -0,0 +1,24 @@ +__author__ = "" +__copyright__ = "Licensed under GPLv2 or later." + +from app.modules.lepd.LepDClient import LepDClient +from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient + +import time + +''' +fetch data related to GetProcSoftirqs from lepd by lepdClient and +store the returned data into the influxDB by influxDBClient. +''' +def pullAndStoreGetProcSoftirqs(lepdClient, influxDbClient): + res = lepdClient.sendRequest('GetProcSoftirqs') + print(res) + + + +if (__name__ == '__main__'): + lepdClient = LepDClient('www.rmlink.cn') + influxDbClient = MyInfluxDbClient('localhost') + for i in range(1): + pullAndStoreGetProcSoftirqs(lepdClient, influxDbClient) + time.sleep(1) diff --git a/dataStore/modules/pullAndStoreGetProcStat.py b/dataStore/modules/pullAndStoreGetProcStat.py new file mode 100755 index 0000000..a9075e7 --- /dev/null +++ b/dataStore/modules/pullAndStoreGetProcStat.py @@ -0,0 +1,24 @@ +__author__ = "" +__copyright__ = "Licensed under GPLv2 or later." + +from app.modules.lepd.LepDClient import LepDClient +from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient + +import time + +''' +fetch data related to GetProcStat from lepd by lepdClient and +store the returned data into the influxDB by influxDBClient. +''' +def pullAndStoreGetProcStat(lepdClient, influxDbClient): + res = lepdClient.sendRequest('GetProcStat') + print(res) + + + +if (__name__ == '__main__'): + lepdClient = LepDClient('www.rmlink.cn') + influxDbClient = MyInfluxDbClient('localhost') + for i in range(1): + pullAndStoreGetProcStat(lepdClient, influxDbClient) + time.sleep(1) diff --git a/dataStore/modules/pullAndStoreGetProcSwaps.py b/dataStore/modules/pullAndStoreGetProcSwaps.py new file mode 100755 index 0000000..a55c21f --- /dev/null +++ b/dataStore/modules/pullAndStoreGetProcSwaps.py @@ -0,0 +1,24 @@ +__author__ = "" +__copyright__ = "Licensed under GPLv2 or later." + +from app.modules.lepd.LepDClient import LepDClient +from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient + +import time + +''' +fetch data related to GetProcSwaps from lepd by lepdClient and +store the returned data into the influxDB by influxDBClient. +''' +def pullAndStoreGetProcSwaps(lepdClient, influxDbClient): + res = lepdClient.sendRequest('GetProcSwaps') + print(res) + + + +if (__name__ == '__main__'): + lepdClient = LepDClient('www.rmlink.cn') + influxDbClient = MyInfluxDbClient('localhost') + for i in range(1): + pullAndStoreGetProcSwaps(lepdClient, influxDbClient) + time.sleep(1) diff --git a/dataStore/modules/pullAndStoreGetProcVersion.py b/dataStore/modules/pullAndStoreGetProcVersion.py new file mode 100755 index 0000000..be169aa --- /dev/null +++ b/dataStore/modules/pullAndStoreGetProcVersion.py @@ -0,0 +1,24 @@ +__author__ = "" +__copyright__ = "Licensed under GPLv2 or later." + +from app.modules.lepd.LepDClient import LepDClient +from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient + +import time + +''' +fetch data related to GetProcVersion from lepd by lepdClient and +store the returned data into the influxDB by influxDBClient. +''' +def pullAndStoreGetProcVersion(lepdClient, influxDbClient): + res = lepdClient.sendRequest('GetProcVersion') + print(res) + + + +if (__name__ == '__main__'): + lepdClient = LepDClient('www.rmlink.cn') + influxDbClient = MyInfluxDbClient('localhost') + for i in range(1): + pullAndStoreGetProcVersion(lepdClient, influxDbClient) + time.sleep(1) diff --git a/dataStore/modules/pullAndStoreGetProcVmstat.py b/dataStore/modules/pullAndStoreGetProcVmstat.py new file mode 100755 index 0000000..d25f627 --- /dev/null +++ b/dataStore/modules/pullAndStoreGetProcVmstat.py @@ -0,0 +1,97 @@ +__author__ = "" +__copyright__ = "Licensed under GPLv2 or later." + +from app.modules.lepd.LepDClient import LepDClient +from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient + +import time + +''' +fetch data related to GetProcVmstat from lepd by lepdClient and +store the returned data into the influxDB by influxDBClient. +''' +def pullAndStoreGetProcVmstat(lepdClient, influxDbClient): + res = lepdClient.sendRequest('GetProcVmstat') + print(res) + # str = res['result'].split('\n') + # data = {} + # for x in str: + # + # x1 = x.replace('kB', '') + # x2 = x1.replace(' ', '') + # list = x2.split(':') + # if (len(list) == 2): + # data[list[0]] = list[1] + # + # # print(data) + # + # json_body = [ + # { + # "measurement": "GetProcMeminfo", + # "tags": { + # # the address of lepd + # "server": lepdClient.server + # }, + # # "time": "2017-03-12T22:00:00Z", + # "fields": { + # "MemTotal": data['MemTotal'], + # "MemFree": data['MemFree'], + # # "MemAvailable": data['MemAvailable'], + # "Buffers": data['Buffers'], + # "Cached": data['Cached'], + # "SwapCached": data['MemTotal'], + # "Active": data['Active'], + # "Inactive": data['Inactive'], + # "Active(anon)": data['Active(anon)'], + # "Inactive(anon)": data['Inactive(anon)'], + # "Active(file)": data['Active(file)'], + # "Inactive(file)": data['Inactive(file)'], + # "Unevictable": data['Unevictable'], + # "Mlocked": data['Mlocked'], + # "SwapTotal": data['SwapTotal'], + # "SwapFree": data['SwapFree'], + # "Dirty": data['Dirty'], + # "Writeback": data['Writeback'], + # "AnonPages": data['AnonPages'], + # "Mapped": data['Mapped'], + # "Shmem": data['Shmem'], + # "Slab": data['Slab'], + # "SReclaimable": data['SReclaimable'], + # "SUnreclaim": data['SUnreclaim'], + # "KernelStack": data['KernelStack'], + # "PageTables": data['PageTables'], + # "NFS_Unstable": data['NFS_Unstable'], + # "Bounce": data['Bounce'], + # "WritebackTmp": data['WritebackTmp'], + # "CommitLimit": data['CommitLimit'], + # "Committed_AS": data['Committed_AS'], + # "VmallocTotal": data['VmallocTotal'], + # "VmallocUsed": data['VmallocUsed'], + # "VmallocChunk": data['VmallocChunk'], + # "HardwareCorrupted": data['HardwareCorrupted'], + # "AnonHugePages": data['AnonHugePages'], + # # "ShmemHugePages": data['ShmemHugePages'], + # # "ShmemPmdMapped": data['ShmemPmdMapped'], + # # "CmaTotal": data['CmaTotal'], + # # "CmaFree": data['CmaFree'], + # "HugePages_Total": data['HugePages_Total'], + # "HugePages_Free": data['HugePages_Free'], + # "HugePages_Rsvd": data['HugePages_Rsvd'], + # "HugePages_Surp": data['HugePages_Surp'], + # "Hugepagesize": data['Hugepagesize'], + # "DirectMap4k": data['DirectMap4k'], + # "DirectMap2M": data['DirectMap2M'], + # "DirectMap1G": data['DirectMap1G'] + # } + # } + # ] + # + # influxDbClient.write_points('www.rmlink.cn', json_body) + + +if (__name__ == '__main__'): + lepdClient = LepDClient('www.rmlink.cn') + influxDbClient = MyInfluxDbClient('localhost') + for i in range(1): + pullAndStoreGetProcVmstat(lepdClient, influxDbClient) + time.sleep(1) diff --git a/dataStore/modules/pullAndStoreGetProcZoneinfo.py b/dataStore/modules/pullAndStoreGetProcZoneinfo.py new file mode 100755 index 0000000..4a63423 --- /dev/null +++ b/dataStore/modules/pullAndStoreGetProcZoneinfo.py @@ -0,0 +1,24 @@ +__author__ = "" +__copyright__ = "Licensed under GPLv2 or later." + +from app.modules.lepd.LepDClient import LepDClient +from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient + +import time + +''' +fetch data related to GetProcZoneinfo from lepd by lepdClient and +store the returned data into the influxDB by influxDBClient. +''' +def pullAndStoreGetProcZoneinfo(lepdClient, influxDbClient): + res = lepdClient.sendRequest('GetProcZoneinfo') + print(res) + + + +if (__name__ == '__main__'): + lepdClient = LepDClient('www.rmlink.cn') + influxDbClient = MyInfluxDbClient('localhost') + for i in range(1): + pullAndStoreGetProcZoneinfo(lepdClient, influxDbClient) + time.sleep(1) From 9a887c00a2f4c441a92e6748318b0471a2859350 Mon Sep 17 00:00:00 2001 From: lixusheng <1530830954@qq.com> Date: Wed, 2 May 2018 18:03:56 +0800 Subject: [PATCH 08/25] =?UTF-8?q?=E8=AF=B7=E6=B1=82lepd,=E5=AD=98=E5=85=A5?= =?UTF-8?q?influxdb?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/pullAndStoreGetProcVmstat.py | 208 ++++++++++++------ 1 file changed, 144 insertions(+), 64 deletions(-) diff --git a/dataStore/modules/pullAndStoreGetProcVmstat.py b/dataStore/modules/pullAndStoreGetProcVmstat.py index d25f627..0a8176b 100755 --- a/dataStore/modules/pullAndStoreGetProcVmstat.py +++ b/dataStore/modules/pullAndStoreGetProcVmstat.py @@ -1,9 +1,11 @@ __author__ = "" __copyright__ = "Licensed under GPLv2 or later." -from app.modules.lepd.LepDClient import LepDClient +from dataStore.lepdClient.LepdClient import LepdClient from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient + + import time ''' @@ -12,76 +14,154 @@ ''' def pullAndStoreGetProcVmstat(lepdClient, influxDbClient): res = lepdClient.sendRequest('GetProcVmstat') - print(res) - # str = res['result'].split('\n') - # data = {} - # for x in str: - # - # x1 = x.replace('kB', '') - # x2 = x1.replace(' ', '') - # list = x2.split(':') - # if (len(list) == 2): - # data[list[0]] = list[1] - # - # # print(data) - # + # print(res) + str = res['result'].split('\n') + data = {} + for x in str: + list = x.split(' ') + if (len(list) == 2): + data[list[0]] = list[1] + + print(data) + # json_body = [ # { - # "measurement": "GetProcMeminfo", + # "measurement": "GetProcVmstat", # "tags": { # # the address of lepd # "server": lepdClient.server # }, # # "time": "2017-03-12T22:00:00Z", # "fields": { - # "MemTotal": data['MemTotal'], - # "MemFree": data['MemFree'], - # # "MemAvailable": data['MemAvailable'], - # "Buffers": data['Buffers'], - # "Cached": data['Cached'], - # "SwapCached": data['MemTotal'], - # "Active": data['Active'], - # "Inactive": data['Inactive'], - # "Active(anon)": data['Active(anon)'], - # "Inactive(anon)": data['Inactive(anon)'], - # "Active(file)": data['Active(file)'], - # "Inactive(file)": data['Inactive(file)'], - # "Unevictable": data['Unevictable'], - # "Mlocked": data['Mlocked'], - # "SwapTotal": data['SwapTotal'], - # "SwapFree": data['SwapFree'], - # "Dirty": data['Dirty'], - # "Writeback": data['Writeback'], - # "AnonPages": data['AnonPages'], - # "Mapped": data['Mapped'], - # "Shmem": data['Shmem'], - # "Slab": data['Slab'], - # "SReclaimable": data['SReclaimable'], - # "SUnreclaim": data['SUnreclaim'], - # "KernelStack": data['KernelStack'], - # "PageTables": data['PageTables'], - # "NFS_Unstable": data['NFS_Unstable'], - # "Bounce": data['Bounce'], - # "WritebackTmp": data['WritebackTmp'], - # "CommitLimit": data['CommitLimit'], - # "Committed_AS": data['Committed_AS'], - # "VmallocTotal": data['VmallocTotal'], - # "VmallocUsed": data['VmallocUsed'], - # "VmallocChunk": data['VmallocChunk'], - # "HardwareCorrupted": data['HardwareCorrupted'], - # "AnonHugePages": data['AnonHugePages'], - # # "ShmemHugePages": data['ShmemHugePages'], - # # "ShmemPmdMapped": data['ShmemPmdMapped'], - # # "CmaTotal": data['CmaTotal'], - # # "CmaFree": data['CmaFree'], - # "HugePages_Total": data['HugePages_Total'], - # "HugePages_Free": data['HugePages_Free'], - # "HugePages_Rsvd": data['HugePages_Rsvd'], - # "HugePages_Surp": data['HugePages_Surp'], - # "Hugepagesize": data['Hugepagesize'], - # "DirectMap4k": data['DirectMap4k'], - # "DirectMap2M": data['DirectMap2M'], - # "DirectMap1G": data['DirectMap1G'] + # "compact_stall": data['MemTotal'], + # "balloon_migrate": data['MemFree'], + # "nr_unevictable": data['Buffers'], + # "nr_vmscan_write": data['Cached'], + # "pgskip_movable": data['MemTotal'], + # "thp_fault_fallback": data['Active'], + # "nr_anon_pages": data['Inactive'], + # "numa_other": data['Active(anon)'], + # "thp_split_page": data['Inactive(anon)'], + # "unevictable_pgs_stranded": data['Active(file)'], + # "nr_shmem_pmdmapped": data['Inactive(file)'], + # "nr_shmem": data['Unevictable'], + # "nr_zone_write_pending": data['Mlocked'], + # "compact_migrate_scanned": data['SwapTotal'], + # "nr_zone_active_anon": data['SwapFree'], + # "pglazyfree": data['Dirty'], + # "numa_foreign": data['Writeback'], + # "pglazyfreed": data['AnonPages'], + # "nr_zone_active_file": data['Mapped'], + # "numa_pte_updates": data['Shmem'], + # "pgscan_direct_throttle": data['Slab'], + # "kswapd_low_wmark_hit_quickly": data['SReclaimable'], + # "nr_dirtied": data['SUnreclaim'], + # "htlb_buddy_alloc_fail": data['KernelStack'], + # "nr_dirty_background_threshold": data['PageTables'], + # "pgalloc_dma32": data['NFS_Unstable'], + # "compact_daemon_migrate_scanned": data['Bounce'], + # "unevictable_pgs_culled": data['WritebackTmp'], + # "numa_miss": data['Mapped'], + # "compact_isolated": data['Shmem'], + # "pswpout": data['Slab'], + # "pgsteal_kswapd": data['SReclaimable'], + # "thp_split_pud": data['SUnreclaim'], + # "unevictable_pgs_mlocked": data['KernelStack'], + # "thp_zero_page_alloc": data['PageTables'], + # "workingset_activate": data['NFS_Unstable'], + # "unevictable_pgs_cleared": data['Bounce'], + # "pgalloc_movable": data['WritebackTmp'], + # "pageoutrun": data['Mapped'], + # "pgfault": data['Shmem'], + # "nr_unstable": data['Slab'], + # "kswapd_high_wmark_hit_quickly": data['SReclaimable'], + # "thp_deferred_split_page": data['SUnreclaim'], + # "thp_file_mapped": data['KernelStack'], + # "pgscan_kswapd": data['PageTables'], + # "nr_writeback_temp": data['NFS_Unstable'], + # "nr_dirty_threshold": data['Bounce'], + # "nr_mlock": data['WritebackTmp'], + # "htlb_buddy_alloc_success": data['Mapped'], + # "nr_isolated_anon": data['Shmem'], + # "allocstall_normal": data['Slab'], + # "nr_mapped": data['SReclaimable'], + # "numa_local": data['SUnreclaim'], + # "nr_zone_inactive_anon": data['KernelStack'], + # "pgmajfault": data['PageTables'], + # "thp_fault_alloc": data['NFS_Unstable'], + # "compact_success": data['Bounce'], + # "allocstall_dma": data['WritebackTmp'], + # "thp_split_pmd": data['Mapped'], + # "nr_bounce": data['Shmem'], + # "thp_zero_page_alloc_failed": data['Slab'], + # "pgdeactivate": data['SReclaimable'], + # "allocstall_dma32": data['SUnreclaim'], + # "nr_file_pages": data['KernelStack'], + # "nr_anon_transparent_hugepages": data['PageTables'], + # "compact_fail": data['NFS_Unstable'], + # "nr_page_table_pages": data['Bounce'], + # "numa_hint_faults": data['WritebackTmp'], + # "pgskip_dma32": data['Mapped'], + # "numa_pages_migrated": data['Shmem'], + # "nr_vmscan_immediate_reclaim": data['Slab'], + # "nr_zone_unevictable": data['SReclaimable'], + # "pgmigrate_fail": data['SUnreclaim'], + # "compact_daemon_wake": data['KernelStack'], + # "pgskip_dma": data['PageTables'], + # "nr_active_anon": data['NFS_Unstable'], + # "pgpgout": data['Bounce'], + # "pgskip_normal": data['WritebackTmp'], + # "pginodesteal": data['NFS_Unstable'], + # "nr_zspages": data['Bounce'], + # "unevictable_pgs_rescued": data['WritebackTmp'], + # "pgalloc_dma": data['Mapped'], + # "pswpin": data['Shmem'], + # "thp_collapse_alloc": data['Slab'], + # "nr_writeback": data['SReclaimable'], + # "nr_free_pages": data['SUnreclaim'], + # "pgpgin": data['KernelStack'], + # "pgalloc_normal": data['PageTables'], + # "slabs_scanned": data['NFS_Unstable'], + # "thp_file_alloc": data['Bounce'], + # "nr_written": data['WritebackTmp'], + # "compact_free_scanned": data['NFS_Unstable'], + # "numa_hint_faults_local": data['Bounce'], + # "drop_pagecache": data['WritebackTmp'], + # "thp_split_page_failed": data['Mapped'], + # "nr_zone_inactive_file": data['Shmem'], + # "unevictable_pgs_munlocked": data['Slab'], + # "nr_slab_reclaimable": data['SReclaimable'], + # "allocstall_movable": data['SUnreclaim'], + # "oom_kill": data['KernelStack'], + # "nr_free_cma": data['PageTables'], + # "balloon_inflate": data['NFS_Unstable'], + # "numa_huge_pte_updates": data['Bounce'], + # "unevictable_pgs_scanned": data['WritebackTmp'], "": data['PageTables'], + # "nr_active_file": data['NFS_Unstable'], + # "nr_shmem_hugepages": data['Bounce'], + # "kswapd_inodesteal": data['WritebackTmp'], + # "pgscan_direct": data['Mapped'], + # "numa_interleave": data['Shmem'], + # "nr_slab_unreclaimable": data['Slab'], + # "thp_collapse_alloc_failed": data['SReclaimable'], + # "workingset_refault": data['SUnreclaim'], + # "compact_daemon_free_scanned": data['KernelStack'], + # "zone_reclaim_failed": data['PageTables'], + # "nr_isolated_file": data['NFS_Unstable'], + # "nr_inactive_anon": data['Bounce'], + # "pgrotated": data['WritebackTmp'], "": data['PageTables'], + # "nr_kernel_stack": data['NFS_Unstable'], + # "numa_hit": data['Bounce'], + # "nr_dirty": data['WritebackTmp'], + # "workingset_nodereclaim": data['Mapped'], + # "drop_slab": data['Shmem'], + # "nr_inactive_file": data['Slab'], + # "pgrefill": data['SReclaimable'], + # "pgmigrate_success": data['SUnreclaim'], + # "pgactivate": data['KernelStack'], + # "balloon_deflate": data['PageTables'], + # "pgfree": data['NFS_Unstable'], + # "pgsteal_direct": data['Bounce'] # } # } # ] @@ -90,7 +170,7 @@ def pullAndStoreGetProcVmstat(lepdClient, influxDbClient): if (__name__ == '__main__'): - lepdClient = LepDClient('www.rmlink.cn') + lepdClient = LepdClient('localhost') influxDbClient = MyInfluxDbClient('localhost') for i in range(1): pullAndStoreGetProcVmstat(lepdClient, influxDbClient) From bfb824447864a89744253bfae0d904509c0933c4 Mon Sep 17 00:00:00 2001 From: lixusheng <1530830954@qq.com> Date: Wed, 2 May 2018 23:34:00 +0800 Subject: [PATCH 09/25] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20write=5Fpoints()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dataStore/influxDbUtil/dbUtil.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dataStore/influxDbUtil/dbUtil.py b/dataStore/influxDbUtil/dbUtil.py index f7253eb..0b69c26 100644 --- a/dataStore/influxDbUtil/dbUtil.py +++ b/dataStore/influxDbUtil/dbUtil.py @@ -15,7 +15,7 @@ class MyInfluxDbClient: def __init__(self, influxDBAddress,port=8086,username='root',password='',database="lep"): self._client = InfluxDBClient(influxDBAddress, port,username,password,database) - def write_points(self, server, json_body): + def write_points(self, json_body): if self._client.write_points(json_body): return True From 56f48daa7a2e2bec07d3d54593ba3ac741a8933f Mon Sep 17 00:00:00 2001 From: lixusheng <1530830954@qq.com> Date: Wed, 2 May 2018 23:35:46 +0800 Subject: [PATCH 10/25] =?UTF-8?q?=E5=AE=8C=E6=88=90=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E5=92=8C=E5=AD=98=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/memory/memoryPullAndStore.py | 4 +- .../modules/pullAndStoreGetProcVmstat.py | 289 +++++++++--------- 2 files changed, 147 insertions(+), 146 deletions(-) diff --git a/dataStore/modules/memory/memoryPullAndStore.py b/dataStore/modules/memory/memoryPullAndStore.py index 615158e..c5aa7c3 100644 --- a/dataStore/modules/memory/memoryPullAndStore.py +++ b/dataStore/modules/memory/memoryPullAndStore.py @@ -89,12 +89,12 @@ def pullAndStoreGetProcMeminfo(lepdClient, influxDbClient): } ] - influxDbClient.write_points('www.rmlink.cn', json_body) + influxDbClient.write_points( json_body) if (__name__ == '__main__'): lepdClient = LepdClient('localhost') influxDbClient = MyInfluxDbClient('localhost') - for i in range(60): + for i in range(1): pullAndStoreGetProcMeminfo(lepdClient, influxDbClient) time.sleep(1) diff --git a/dataStore/modules/pullAndStoreGetProcVmstat.py b/dataStore/modules/pullAndStoreGetProcVmstat.py index 0a8176b..55c9973 100755 --- a/dataStore/modules/pullAndStoreGetProcVmstat.py +++ b/dataStore/modules/pullAndStoreGetProcVmstat.py @@ -21,152 +21,153 @@ def pullAndStoreGetProcVmstat(lepdClient, influxDbClient): list = x.split(' ') if (len(list) == 2): data[list[0]] = list[1] - print(data) - # json_body = [ - # { - # "measurement": "GetProcVmstat", - # "tags": { - # # the address of lepd - # "server": lepdClient.server - # }, - # # "time": "2017-03-12T22:00:00Z", - # "fields": { - # "compact_stall": data['MemTotal'], - # "balloon_migrate": data['MemFree'], - # "nr_unevictable": data['Buffers'], - # "nr_vmscan_write": data['Cached'], - # "pgskip_movable": data['MemTotal'], - # "thp_fault_fallback": data['Active'], - # "nr_anon_pages": data['Inactive'], - # "numa_other": data['Active(anon)'], - # "thp_split_page": data['Inactive(anon)'], - # "unevictable_pgs_stranded": data['Active(file)'], - # "nr_shmem_pmdmapped": data['Inactive(file)'], - # "nr_shmem": data['Unevictable'], - # "nr_zone_write_pending": data['Mlocked'], - # "compact_migrate_scanned": data['SwapTotal'], - # "nr_zone_active_anon": data['SwapFree'], - # "pglazyfree": data['Dirty'], - # "numa_foreign": data['Writeback'], - # "pglazyfreed": data['AnonPages'], - # "nr_zone_active_file": data['Mapped'], - # "numa_pte_updates": data['Shmem'], - # "pgscan_direct_throttle": data['Slab'], - # "kswapd_low_wmark_hit_quickly": data['SReclaimable'], - # "nr_dirtied": data['SUnreclaim'], - # "htlb_buddy_alloc_fail": data['KernelStack'], - # "nr_dirty_background_threshold": data['PageTables'], - # "pgalloc_dma32": data['NFS_Unstable'], - # "compact_daemon_migrate_scanned": data['Bounce'], - # "unevictable_pgs_culled": data['WritebackTmp'], - # "numa_miss": data['Mapped'], - # "compact_isolated": data['Shmem'], - # "pswpout": data['Slab'], - # "pgsteal_kswapd": data['SReclaimable'], - # "thp_split_pud": data['SUnreclaim'], - # "unevictable_pgs_mlocked": data['KernelStack'], - # "thp_zero_page_alloc": data['PageTables'], - # "workingset_activate": data['NFS_Unstable'], - # "unevictable_pgs_cleared": data['Bounce'], - # "pgalloc_movable": data['WritebackTmp'], - # "pageoutrun": data['Mapped'], - # "pgfault": data['Shmem'], - # "nr_unstable": data['Slab'], - # "kswapd_high_wmark_hit_quickly": data['SReclaimable'], - # "thp_deferred_split_page": data['SUnreclaim'], - # "thp_file_mapped": data['KernelStack'], - # "pgscan_kswapd": data['PageTables'], - # "nr_writeback_temp": data['NFS_Unstable'], - # "nr_dirty_threshold": data['Bounce'], - # "nr_mlock": data['WritebackTmp'], - # "htlb_buddy_alloc_success": data['Mapped'], - # "nr_isolated_anon": data['Shmem'], - # "allocstall_normal": data['Slab'], - # "nr_mapped": data['SReclaimable'], - # "numa_local": data['SUnreclaim'], - # "nr_zone_inactive_anon": data['KernelStack'], - # "pgmajfault": data['PageTables'], - # "thp_fault_alloc": data['NFS_Unstable'], - # "compact_success": data['Bounce'], - # "allocstall_dma": data['WritebackTmp'], - # "thp_split_pmd": data['Mapped'], - # "nr_bounce": data['Shmem'], - # "thp_zero_page_alloc_failed": data['Slab'], - # "pgdeactivate": data['SReclaimable'], - # "allocstall_dma32": data['SUnreclaim'], - # "nr_file_pages": data['KernelStack'], - # "nr_anon_transparent_hugepages": data['PageTables'], - # "compact_fail": data['NFS_Unstable'], - # "nr_page_table_pages": data['Bounce'], - # "numa_hint_faults": data['WritebackTmp'], - # "pgskip_dma32": data['Mapped'], - # "numa_pages_migrated": data['Shmem'], - # "nr_vmscan_immediate_reclaim": data['Slab'], - # "nr_zone_unevictable": data['SReclaimable'], - # "pgmigrate_fail": data['SUnreclaim'], - # "compact_daemon_wake": data['KernelStack'], - # "pgskip_dma": data['PageTables'], - # "nr_active_anon": data['NFS_Unstable'], - # "pgpgout": data['Bounce'], - # "pgskip_normal": data['WritebackTmp'], - # "pginodesteal": data['NFS_Unstable'], - # "nr_zspages": data['Bounce'], - # "unevictable_pgs_rescued": data['WritebackTmp'], - # "pgalloc_dma": data['Mapped'], - # "pswpin": data['Shmem'], - # "thp_collapse_alloc": data['Slab'], - # "nr_writeback": data['SReclaimable'], - # "nr_free_pages": data['SUnreclaim'], - # "pgpgin": data['KernelStack'], - # "pgalloc_normal": data['PageTables'], - # "slabs_scanned": data['NFS_Unstable'], - # "thp_file_alloc": data['Bounce'], - # "nr_written": data['WritebackTmp'], - # "compact_free_scanned": data['NFS_Unstable'], - # "numa_hint_faults_local": data['Bounce'], - # "drop_pagecache": data['WritebackTmp'], - # "thp_split_page_failed": data['Mapped'], - # "nr_zone_inactive_file": data['Shmem'], - # "unevictable_pgs_munlocked": data['Slab'], - # "nr_slab_reclaimable": data['SReclaimable'], - # "allocstall_movable": data['SUnreclaim'], - # "oom_kill": data['KernelStack'], - # "nr_free_cma": data['PageTables'], - # "balloon_inflate": data['NFS_Unstable'], - # "numa_huge_pte_updates": data['Bounce'], - # "unevictable_pgs_scanned": data['WritebackTmp'], "": data['PageTables'], - # "nr_active_file": data['NFS_Unstable'], - # "nr_shmem_hugepages": data['Bounce'], - # "kswapd_inodesteal": data['WritebackTmp'], - # "pgscan_direct": data['Mapped'], - # "numa_interleave": data['Shmem'], - # "nr_slab_unreclaimable": data['Slab'], - # "thp_collapse_alloc_failed": data['SReclaimable'], - # "workingset_refault": data['SUnreclaim'], - # "compact_daemon_free_scanned": data['KernelStack'], - # "zone_reclaim_failed": data['PageTables'], - # "nr_isolated_file": data['NFS_Unstable'], - # "nr_inactive_anon": data['Bounce'], - # "pgrotated": data['WritebackTmp'], "": data['PageTables'], - # "nr_kernel_stack": data['NFS_Unstable'], - # "numa_hit": data['Bounce'], - # "nr_dirty": data['WritebackTmp'], - # "workingset_nodereclaim": data['Mapped'], - # "drop_slab": data['Shmem'], - # "nr_inactive_file": data['Slab'], - # "pgrefill": data['SReclaimable'], - # "pgmigrate_success": data['SUnreclaim'], - # "pgactivate": data['KernelStack'], - # "balloon_deflate": data['PageTables'], - # "pgfree": data['NFS_Unstable'], - # "pgsteal_direct": data['Bounce'] - # } - # } - # ] - # - # influxDbClient.write_points('www.rmlink.cn', json_body) + json_body = [ + { + "measurement": "GetProcVmstat", + "tags": { + # the address of lepd + "server": lepdClient.server + }, + # "time": "2017-03-12T22:00:00Z", + + + "fields": { + "compact_stall" : int(data['compact_stall']), + "balloon_migrate": int(data['balloon_migrate']), + "nr_unevictable": int(data['nr_unevictable']), + "nr_vmscan_write": int(data['nr_vmscan_write']), + "pgskip_movable": int(data['pgskip_movable']), + "thp_fault_fallback": int(data['thp_fault_fallback']), + "nr_anon_pages": int(data['nr_anon_pages']), + "numa_other": int(data['numa_other']), + "thp_split_page": int(data['thp_split_page']), + "unevictable_pgs_stranded": int(data['unevictable_pgs_stranded']), + "nr_shmem_pmdmapped": int(data['nr_shmem_pmdmapped']), + "nr_shmem": int(data['nr_shmem']), + "nr_zone_write_pending": int(data['nr_zone_write_pending']), + "compact_migrate_scanned": int(data['compact_migrate_scanned']), + "nr_zone_active_anon": int(data['nr_zone_active_anon']), + "pglazyfree": int(data['pglazyfree']), + "numa_foreign": int(data['numa_foreign']), + "pglazyfreed": int(data['pglazyfreed']), + "nr_zone_active_file": int(data['nr_zone_active_file']), + "numa_pte_updates": int(data['numa_pte_updates']), + "pgscan_direct_throttle":int(data['pgscan_direct_throttle']), + "kswapd_low_wmark_hit_quickly": int(data['kswapd_low_wmark_hit_quickly']), + "nr_dirtied": int(data['nr_dirtied']), + "htlb_buddy_alloc_fail": int(data['htlb_buddy_alloc_fail']), + "nr_dirty_background_threshold": int(data['nr_dirty_background_threshold']), + "pgalloc_dma32": int(data['pgalloc_dma32']), + "compact_daemon_migrate_scanned": int(data['compact_daemon_migrate_scanned']), + "unevictable_pgs_culled": int(data['unevictable_pgs_culled']), + "numa_miss": int(data['numa_miss']), + "compact_isolated": int(data['compact_isolated']), + "pswpout": int(data['pswpout']), + "pgsteal_kswapd": int(data['pgsteal_kswapd']), + "thp_split_pud": int(data['thp_split_pud']), + "unevictable_pgs_mlocked": int(data['unevictable_pgs_mlocked']), + "thp_zero_page_alloc": int(data['thp_zero_page_alloc']), + "workingset_activate": int(data['workingset_activate']), + "unevictable_pgs_cleared": int(data['unevictable_pgs_cleared']), + "pgalloc_movable": int(data['pgalloc_movable']), + "pageoutrun": int(data['pageoutrun']), + "pgfault": int(data['pgfault']), + "nr_unstable": int(data['nr_unstable']), + "kswapd_high_wmark_hit_quickly": int(data['kswapd_high_wmark_hit_quickly']), + "thp_deferred_split_page": int(data['thp_deferred_split_page']), + "thp_file_mapped": int(data['thp_file_mapped']), + "pgscan_kswapd": int(data['pgscan_kswapd']), + "nr_writeback_temp": int(data['nr_writeback_temp']), + "nr_dirty_threshold": int(data['nr_dirty_threshold']), + "nr_mlock": int(data['nr_mlock']), + "htlb_buddy_alloc_success": int(data['htlb_buddy_alloc_success']), + "nr_isolated_anon": int(data['nr_isolated_anon']), + "allocstall_normal": int(data['allocstall_normal']), + "nr_mapped": int(data['nr_mapped']), + "numa_local": int(data['numa_local']), + "nr_zone_inactive_anon": int(data['nr_zone_inactive_anon']), + "pgmajfault": int(data['pgmajfault']), + "thp_fault_alloc": int(data['thp_fault_alloc']), + "compact_success": int(data['compact_success']), + "allocstall_dma": int(data['allocstall_dma']), + "thp_split_pmd": int(data['thp_split_pmd']), + "nr_bounce": int(data['nr_bounce']), + "thp_zero_page_alloc_failed": int(data['thp_zero_page_alloc_failed']), + "pgdeactivate": int(data['pgdeactivate']), + "allocstall_dma32": int(data['allocstall_dma32']), + "nr_file_pages": int(data['nr_file_pages']), + "nr_anon_transparent_hugepages": int(data['nr_anon_transparent_hugepages']), + "compact_fail": int(data['compact_fail']), + "nr_page_table_pages": int(data['nr_page_table_pages']), + "numa_hint_faults": int(data['numa_hint_faults']), + "pgskip_dma32": int(data['pgskip_dma32']), + "numa_pages_migrated": int(data['numa_pages_migrated']), + "nr_vmscan_immediate_reclaim": int(data['nr_vmscan_immediate_reclaim']), + "nr_zone_unevictable": int(data['nr_zone_unevictable']), + "pgmigrate_fail": int(data['pgmigrate_fail']), + "compact_daemon_wake": int(data['compact_daemon_wake']), + "pgskip_dma": int(data['pgskip_dma']), + "nr_active_anon": int(data['nr_active_anon']), + "pgpgout": int(data['pgpgout']), + "pgskip_normal": int(data['pgskip_normal']), + "pginodesteal": int(data['pginodesteal']), + "nr_zspages": int(data['nr_zspages']), + "unevictable_pgs_rescued": int(data['unevictable_pgs_rescued']), + "pgalloc_dma": int(data['pgalloc_dma']), + "pswpin": int(data['pswpin']), + "thp_collapse_alloc": int(data['thp_collapse_alloc']), + "nr_writeback": int(data['nr_writeback']), + "nr_free_pages": int(data['nr_free_pages']), + "pgpgin": int(data['pgpgin']), + "pgalloc_normal": int(data['pgalloc_normal']), + "slabs_scanned": int(data['slabs_scanned']), + "thp_file_alloc": int(data['thp_file_alloc']), + "nr_written": int(data['nr_written']), + "compact_free_scanned": int(data['compact_free_scanned']), + "numa_hint_faults_local": int(data['numa_hint_faults_local']), + "drop_pagecache": int(data['drop_pagecache']), + "thp_split_page_failed": int(data['thp_split_page_failed']), + "nr_zone_inactive_file": int(data['nr_zone_inactive_file']), + "unevictable_pgs_munlocked": int(data['unevictable_pgs_munlocked']), + "nr_slab_reclaimable": int(data['nr_slab_reclaimable']), + "allocstall_movable": int(data['allocstall_movable']), + "oom_kill": int(data['oom_kill']), + "nr_free_cma": int(data['nr_free_cma']), + "balloon_inflate": int(data['balloon_inflate']), + "numa_huge_pte_updates": int(data['numa_huge_pte_updates']), + "unevictable_pgs_scanned": int(data['unevictable_pgs_scanned']), + "nr_active_file": int(data['nr_active_file']), + "nr_shmem_hugepages": int(data['nr_shmem_hugepages']), + "kswapd_inodesteal": int(data['kswapd_inodesteal']), + "pgscan_direct": int(data['pgscan_direct']), + "numa_interleave": int(data['numa_interleave']), + "nr_slab_unreclaimable": int(data['nr_slab_unreclaimable']), + "thp_collapse_alloc_failed": int(data['thp_collapse_alloc_failed']), + "workingset_refault": int(data['workingset_refault']), + "compact_daemon_free_scanned": int(data['compact_daemon_free_scanned']), + "zone_reclaim_failed": int(data['zone_reclaim_failed']), + "nr_isolated_file": int(data['nr_isolated_file']), + "nr_inactive_anon": int(data['nr_inactive_anon']), + "pgrotated": int(data['pgrotated']), + "nr_kernel_stack": int(data['nr_kernel_stack']), + "numa_hit": int(data['numa_hit']), + "nr_dirty": int(data['nr_dirty']), + "workingset_nodereclaim": int(data['workingset_nodereclaim']), + "drop_slab": int(data['drop_slab']), + "nr_inactive_file": int(data['nr_inactive_file']), + "pgrefill": int(data['pgrefill']), + "pgmigrate_success": int(data['pgmigrate_success']), + "pgactivate": int(data['pgactivate']), + "balloon_deflate": int(data['balloon_deflate']), + "pgfree": int(data['pgfree']), + "pgsteal_direct": int(data['pgsteal_direct']) + } + } + ] + + influxDbClient.write_points(json_body) if (__name__ == '__main__'): From 76c83f23990b74bf80ffe22c66ec276e9b21043d Mon Sep 17 00:00:00 2001 From: lixusheng <1530830954@qq.com> Date: Mon, 7 May 2018 22:03:58 +0800 Subject: [PATCH 11/25] =?UTF-8?q?=E6=AF=8F=E4=B8=80=E4=B8=AA=E5=91=BD?= =?UTF-8?q?=E4=BB=A4=E7=9A=84=E8=AF=B7=E6=B1=82=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/modules/lepd/LepDClient.py | 2 +- .../modules/memory/memoryPullAndStore.py | 1 + dataStore/modules/pullAndStoreGetCmdDf.py | 21 ++++++- dataStore/modules/pullAndStoreGetCmdDmesg.py | 21 ++++++- dataStore/modules/pullAndStoreGetCmdFree.py | 21 ++++++- dataStore/modules/pullAndStoreGetCmdIostat.py | 21 ++++++- dataStore/modules/pullAndStoreGetCmdIotop.py | 27 ++++++-- .../modules/pullAndStoreGetCmdIrqInfo.py | 27 ++++++-- .../modules/pullAndStoreGetCmdMpstat-I.py | 21 ++++++- dataStore/modules/pullAndStoreGetCmdMpstat.py | 21 ++++++- .../modules/pullAndStoreGetCmdPerfCpuclock.py | 21 ++++++- .../modules/pullAndStoreGetCmdPerfFaults.py | 21 ++++++- .../modules/pullAndStoreGetCmdPerfFlame.py | 21 ++++++- .../modules/pullAndStoreGetCmdProcrank.py | 21 ++++++- dataStore/modules/pullAndStoreGetCmdTop.py | 21 ++++++- dataStore/modules/pullAndStoreGetCpuInfo.py | 17 +++++ .../modules/pullAndStoreGetProcBuddyinfo.py | 6 +- .../modules/pullAndStoreGetProcDiskstats.py | 21 ++++++- .../modules/pullAndStoreGetProcInterrupts.py | 21 ++++++- .../modules/pullAndStoreGetProcLoadavg.py | 6 +- .../modules/pullAndStoreGetProcModules.py | 21 ++++++- .../modules/pullAndStoreGetProcSlabinfo.py | 21 ++++++- .../modules/pullAndStoreGetProcSoftirqs.py | 22 ++++++- dataStore/modules/pullAndStoreGetProcStat.py | 22 ++++++- dataStore/modules/pullAndStoreGetProcSwaps.py | 28 ++++++++- .../modules/pullAndStoreGetProcVersion.py | 20 +++++- .../modules/pullAndStoreGetProcZoneinfo.py | 62 ++++++++++++++++++- 27 files changed, 495 insertions(+), 60 deletions(-) diff --git a/app/modules/lepd/LepDClient.py b/app/modules/lepd/LepDClient.py index ff46500..0330133 100644 --- a/app/modules/lepd/LepDClient.py +++ b/app/modules/lepd/LepDClient.py @@ -8,7 +8,7 @@ import pprint import re import datetime -import click +import clock class LepDClient: diff --git a/dataStore/modules/memory/memoryPullAndStore.py b/dataStore/modules/memory/memoryPullAndStore.py index c5aa7c3..c666fc3 100644 --- a/dataStore/modules/memory/memoryPullAndStore.py +++ b/dataStore/modules/memory/memoryPullAndStore.py @@ -28,6 +28,7 @@ def pullAndStoreGetProcMeminfo(lepdClient, influxDbClient): #print(data['Active']) + json_body = [ { "measurement": "GetProcMeminfo", diff --git a/dataStore/modules/pullAndStoreGetCmdDf.py b/dataStore/modules/pullAndStoreGetCmdDf.py index 3ad1ed3..8ee2f94 100755 --- a/dataStore/modules/pullAndStoreGetCmdDf.py +++ b/dataStore/modules/pullAndStoreGetCmdDf.py @@ -1,7 +1,7 @@ __author__ = "" __copyright__ = "Licensed under GPLv2 or later." -from app.modules.lepd.LepDClient import LepDClient +from dataStore.lepdClient.LepdClient import LepdClient from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient import time @@ -14,10 +14,27 @@ def pullAndStoreGetCmdDf(lepdClient, influxDbClient): res = lepdClient.sendRequest('GetCmdDf') print(res) + # json_body = [ + # { + # "measurement": "GetProcSwaps", + # "tags": { + # # the address of lepd + # "server": lepdClient.server + # }, + # # "time": "2017-03-12T22:00:00Z", + # "fields": { + # "LinuxVersion": mystr, + # "compact_stall": int(data['compact_stall']), + # "balloon_migrate": int(data['balloon_migrate']), + # } + # } + # ] + # + # influxDbClient.write_points(json_body) if (__name__ == '__main__'): - lepdClient = LepDClient('www.rmlink.cn') + lepdClient = LepdClient('localhost') influxDbClient = MyInfluxDbClient('localhost') for i in range(1): pullAndStoreGetCmdDf(lepdClient, influxDbClient) diff --git a/dataStore/modules/pullAndStoreGetCmdDmesg.py b/dataStore/modules/pullAndStoreGetCmdDmesg.py index e5749e1..26a73b4 100755 --- a/dataStore/modules/pullAndStoreGetCmdDmesg.py +++ b/dataStore/modules/pullAndStoreGetCmdDmesg.py @@ -1,7 +1,7 @@ __author__ = "" __copyright__ = "Licensed under GPLv2 or later." -from app.modules.lepd.LepDClient import LepDClient +from dataStore.lepdClient.LepdClient import LepdClient from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient import time @@ -14,10 +14,27 @@ def pullAndStoreGetCmdDmesg(lepdClient, influxDbClient): res = lepdClient.sendRequest('GetCmdDmesg') print(res) + # json_body = [ + # { + # "measurement": "GetProcSwaps", + # "tags": { + # # the address of lepd + # "server": lepdClient.server + # }, + # # "time": "2017-03-12T22:00:00Z", + # "fields": { + # "LinuxVersion": mystr, + # "compact_stall": int(data['compact_stall']), + # "balloon_migrate": int(data['balloon_migrate']), + # } + # } + # ] + # + # influxDbClient.write_points(json_body) if (__name__ == '__main__'): - lepdClient = LepDClient('www.rmlink.cn') + lepdClient = LepdClient('localhost') influxDbClient = MyInfluxDbClient('localhost') for i in range(1): pullAndStoreGetCmdDmesg(lepdClient, influxDbClient) diff --git a/dataStore/modules/pullAndStoreGetCmdFree.py b/dataStore/modules/pullAndStoreGetCmdFree.py index d7fde60..d61c3ef 100755 --- a/dataStore/modules/pullAndStoreGetCmdFree.py +++ b/dataStore/modules/pullAndStoreGetCmdFree.py @@ -1,7 +1,7 @@ __author__ = "" __copyright__ = "Licensed under GPLv2 or later." -from app.modules.lepd.LepDClient import LepDClient +from dataStore.lepdClient.LepdClient import LepdClient from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient import time @@ -13,11 +13,28 @@ def pullAndStoreGetCmdFree(lepdClient, influxDbClient): res = lepdClient.sendRequest('GetCmdFree') print(res) + # json_body = [ + # { + # "measurement": "GetProcSwaps", + # "tags": { + # # the address of lepd + # "server": lepdClient.server + # }, + # # "time": "2017-03-12T22:00:00Z", + # "fields": { + # "LinuxVersion": mystr, + # "compact_stall": int(data['compact_stall']), + # "balloon_migrate": int(data['balloon_migrate']), + # } + # } + # ] + # + # influxDbClient.write_points(json_body) if (__name__ == '__main__'): - lepdClient = LepDClient('www.rmlink.cn') + lepdClient = LepdClient('localhost') influxDbClient = MyInfluxDbClient('localhost') for i in range(1): pullAndStoreGetCmdFree(lepdClient, influxDbClient) diff --git a/dataStore/modules/pullAndStoreGetCmdIostat.py b/dataStore/modules/pullAndStoreGetCmdIostat.py index af0edd5..9e3efd4 100755 --- a/dataStore/modules/pullAndStoreGetCmdIostat.py +++ b/dataStore/modules/pullAndStoreGetCmdIostat.py @@ -1,7 +1,7 @@ __author__ = "" __copyright__ = "Licensed under GPLv2 or later." -from app.modules.lepd.LepDClient import LepDClient +from dataStore.lepdClient.LepdClient import LepdClient from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient import time @@ -14,10 +14,27 @@ def pullAndStoreGetCmdIostat(lepdClient, influxDbClient): res = lepdClient.sendRequest('GetCmdIostat') print(res) + # json_body = [ + # { + # "measurement": "GetProcSwaps", + # "tags": { + # # the address of lepd + # "server": lepdClient.server + # }, + # # "time": "2017-03-12T22:00:00Z", + # "fields": { + # "LinuxVersion": mystr, + # "compact_stall": int(data['compact_stall']), + # "balloon_migrate": int(data['balloon_migrate']), + # } + # } + # ] + # + # influxDbClient.write_points(json_body) if (__name__ == '__main__'): - lepdClient = LepDClient('www.rmlink.cn') + lepdClient = LepdClient('localhost') influxDbClient = MyInfluxDbClient('localhost') for i in range(1): pullAndStoreGetCmdIostat(lepdClient, influxDbClient) diff --git a/dataStore/modules/pullAndStoreGetCmdIotop.py b/dataStore/modules/pullAndStoreGetCmdIotop.py index 1a00bd7..cd42429 100755 --- a/dataStore/modules/pullAndStoreGetCmdIotop.py +++ b/dataStore/modules/pullAndStoreGetCmdIotop.py @@ -1,7 +1,7 @@ __author__ = "" __copyright__ = "Licensed under GPLv2 or later." -from app.modules.lepd.LepDClient import LepDClient +from dataStore.lepdClient.LepdClient import LepdClient from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient import time @@ -10,15 +10,32 @@ fetch data related to GetCmdIrqInfo from lepd by lepdClient and store the returned data into the influxDB by influxDBClient. ''' -def pullAndStoreGetCmdIrqInfo(lepdClient, influxDbClient): - res = lepdClient.sendRequest('GetCmdIrqInfo') +def pullAndStoreGetCmdIotop(lepdClient, influxDbClient): + res = lepdClient.sendRequest('GetCmdIotop') print(res) + # json_body = [ + # { + # "measurement": "GetProcSwaps", + # "tags": { + # # the address of lepd + # "server": lepdClient.server + # }, + # # "time": "2017-03-12T22:00:00Z", + # "fields": { + # "LinuxVersion": mystr, + # "compact_stall": int(data['compact_stall']), + # "balloon_migrate": int(data['balloon_migrate']), + # } + # } + # ] + # + # influxDbClient.write_points(json_body) if (__name__ == '__main__'): - lepdClient = LepDClient('www.rmlink.cn') + lepdClient = LepdClient('localhost') influxDbClient = MyInfluxDbClient('localhost') for i in range(1): - pullAndStoreGetCmdIrqInfo(lepdClient, influxDbClient) + pullAndStoreGetCmdIotop(lepdClient, influxDbClient) time.sleep(1) diff --git a/dataStore/modules/pullAndStoreGetCmdIrqInfo.py b/dataStore/modules/pullAndStoreGetCmdIrqInfo.py index e5749e1..4234703 100755 --- a/dataStore/modules/pullAndStoreGetCmdIrqInfo.py +++ b/dataStore/modules/pullAndStoreGetCmdIrqInfo.py @@ -1,7 +1,7 @@ __author__ = "" __copyright__ = "Licensed under GPLv2 or later." -from app.modules.lepd.LepDClient import LepDClient +from dataStore.lepdClient.LepdClient import LepdClient from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient import time @@ -10,15 +10,32 @@ fetch data related to GetCmdDmesg from lepd by lepdClient and store the returned data into the influxDB by influxDBClient. ''' -def pullAndStoreGetCmdDmesg(lepdClient, influxDbClient): - res = lepdClient.sendRequest('GetCmdDmesg') +def pullAndStoreGetCmdIrqInfo(lepdClient, influxDbClient): + res = lepdClient.sendRequest('GetCmdIrqInfo') print(res) + # json_body = [ + # { + # "measurement": "GetProcSwaps", + # "tags": { + # # the address of lepd + # "server": lepdClient.server + # }, + # # "time": "2017-03-12T22:00:00Z", + # "fields": { + # "LinuxVersion": mystr, + # "compact_stall": int(data['compact_stall']), + # "balloon_migrate": int(data['balloon_migrate']), + # } + # } + # ] + # + # influxDbClient.write_points(json_body) if (__name__ == '__main__'): - lepdClient = LepDClient('www.rmlink.cn') + lepdClient = LepdClient('localhost') influxDbClient = MyInfluxDbClient('localhost') for i in range(1): - pullAndStoreGetCmdDmesg(lepdClient, influxDbClient) + pullAndStoreGetCmdIrqInfo(lepdClient, influxDbClient) time.sleep(1) diff --git a/dataStore/modules/pullAndStoreGetCmdMpstat-I.py b/dataStore/modules/pullAndStoreGetCmdMpstat-I.py index bad5359..526c6dd 100755 --- a/dataStore/modules/pullAndStoreGetCmdMpstat-I.py +++ b/dataStore/modules/pullAndStoreGetCmdMpstat-I.py @@ -1,7 +1,7 @@ __author__ = "" __copyright__ = "Licensed under GPLv2 or later." -from app.modules.lepd.LepDClient import LepDClient +from dataStore.lepdClient.LepdClient import LepdClient from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient import time @@ -13,11 +13,28 @@ def pullAndStoreGetCmdMpstat_I(lepdClient, influxDbClient): res = lepdClient.sendRequest('GetCmdMpstat-I') print(res) + # json_body = [ + # { + # "measurement": "GetProcSwaps", + # "tags": { + # # the address of lepd + # "server": lepdClient.server + # }, + # # "time": "2017-03-12T22:00:00Z", + # "fields": { + # "LinuxVersion": mystr, + # "compact_stall": int(data['compact_stall']), + # "balloon_migrate": int(data['balloon_migrate']), + # } + # } + # ] + # + # influxDbClient.write_points(json_body) if (__name__ == '__main__'): - lepdClient = LepDClient('www.rmlink.cn') + lepdClient = LepdClient('localhost') influxDbClient = MyInfluxDbClient('localhost') for i in range(1): pullAndStoreGetCmdMpstat_I(lepdClient, influxDbClient) diff --git a/dataStore/modules/pullAndStoreGetCmdMpstat.py b/dataStore/modules/pullAndStoreGetCmdMpstat.py index 8795784..5cb7479 100755 --- a/dataStore/modules/pullAndStoreGetCmdMpstat.py +++ b/dataStore/modules/pullAndStoreGetCmdMpstat.py @@ -1,7 +1,7 @@ __author__ = "" __copyright__ = "Licensed under GPLv2 or later." -from app.modules.lepd.LepDClient import LepDClient +from dataStore.lepdClient.LepdClient import LepdClient from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient import time @@ -13,11 +13,28 @@ def pullAndStoreGetCmdMpstat(lepdClient, influxDbClient): res = lepdClient.sendRequest('GetCmdMpstat') print(res) + # json_body = [ + # { + # "measurement": "GetProcSwaps", + # "tags": { + # # the address of lepd + # "server": lepdClient.server + # }, + # # "time": "2017-03-12T22:00:00Z", + # "fields": { + # "LinuxVersion": mystr, + # "compact_stall": int(data['compact_stall']), + # "balloon_migrate": int(data['balloon_migrate']), + # } + # } + # ] + # + # influxDbClient.write_points(json_body) if (__name__ == '__main__'): - lepdClient = LepDClient('www.rmlink.cn') + lepdClient = LepdClient('localhost') influxDbClient = MyInfluxDbClient('localhost') for i in range(1): pullAndStoreGetCmdMpstat(lepdClient, influxDbClient) diff --git a/dataStore/modules/pullAndStoreGetCmdPerfCpuclock.py b/dataStore/modules/pullAndStoreGetCmdPerfCpuclock.py index 97c65a5..7ae2663 100755 --- a/dataStore/modules/pullAndStoreGetCmdPerfCpuclock.py +++ b/dataStore/modules/pullAndStoreGetCmdPerfCpuclock.py @@ -1,7 +1,7 @@ __author__ = "" __copyright__ = "Licensed under GPLv2 or later." -from app.modules.lepd.LepDClient import LepDClient +from dataStore.lepdClient.LepdClient import LepdClient from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient import time @@ -13,11 +13,28 @@ def pullAndStoreGetCmdPerfCpuclock(lepdClient, influxDbClient): res = lepdClient.sendRequest('GetCmdPerfCpuclock') print(res) + # json_body = [ + # { + # "measurement": "GetProcSwaps", + # "tags": { + # # the address of lepd + # "server": lepdClient.server + # }, + # # "time": "2017-03-12T22:00:00Z", + # "fields": { + # "LinuxVersion": mystr, + # "compact_stall": int(data['compact_stall']), + # "balloon_migrate": int(data['balloon_migrate']), + # } + # } + # ] + # + # influxDbClient.write_points(json_body) if (__name__ == '__main__'): - lepdClient = LepDClient('www.rmlink.cn') + lepdClient = LepdClient('localhost') influxDbClient = MyInfluxDbClient('localhost') for i in range(1): pullAndStoreGetCmdPerfCpuclock(lepdClient, influxDbClient) diff --git a/dataStore/modules/pullAndStoreGetCmdPerfFaults.py b/dataStore/modules/pullAndStoreGetCmdPerfFaults.py index debc94e..b3307f3 100755 --- a/dataStore/modules/pullAndStoreGetCmdPerfFaults.py +++ b/dataStore/modules/pullAndStoreGetCmdPerfFaults.py @@ -1,7 +1,7 @@ __author__ = "" __copyright__ = "Licensed under GPLv2 or later." -from app.modules.lepd.LepDClient import LepDClient +from dataStore.lepdClient.LepdClient import LepdClient from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient import time @@ -14,10 +14,27 @@ def pullAndStoreGetCmdPerfFaults(lepdClient, influxDbClient): res = lepdClient.sendRequest('GetCmdPerfFaults') print(res) + # json_body = [ + # { + # "measurement": "GetProcSwaps", + # "tags": { + # # the address of lepd + # "server": lepdClient.server + # }, + # # "time": "2017-03-12T22:00:00Z", + # "fields": { + # "LinuxVersion": mystr, + # "compact_stall": int(data['compact_stall']), + # "balloon_migrate": int(data['balloon_migrate']), + # } + # } + # ] + # + # influxDbClient.write_points(json_body) if (__name__ == '__main__'): - lepdClient = LepDClient('www.rmlink.cn') + lepdClient = LepdClient('localhost') influxDbClient = MyInfluxDbClient('localhost') for i in range(1): pullAndStoreGetCmdPerfFaults(lepdClient, influxDbClient) diff --git a/dataStore/modules/pullAndStoreGetCmdPerfFlame.py b/dataStore/modules/pullAndStoreGetCmdPerfFlame.py index 41a2bde..e2ea371 100755 --- a/dataStore/modules/pullAndStoreGetCmdPerfFlame.py +++ b/dataStore/modules/pullAndStoreGetCmdPerfFlame.py @@ -1,7 +1,7 @@ __author__ = "" __copyright__ = "Licensed under GPLv2 or later." -from app.modules.lepd.LepDClient import LepDClient +from dataStore.lepdClient.LepdClient import LepdClient from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient import time @@ -13,11 +13,28 @@ def pullAndStoreGetCmdPerfFlame(lepdClient, influxDbClient): res = lepdClient.sendRequest('GetCmdPerfFlame') print(res) + # json_body = [ + # { + # "measurement": "GetProcSwaps", + # "tags": { + # # the address of lepd + # "server": lepdClient.server + # }, + # # "time": "2017-03-12T22:00:00Z", + # "fields": { + # "LinuxVersion": mystr, + # "compact_stall": int(data['compact_stall']), + # "balloon_migrate": int(data['balloon_migrate']), + # } + # } + # ] + # + # influxDbClient.write_points(json_body) if (__name__ == '__main__'): - lepdClient = LepDClient('www.rmlink.cn') + lepdClient = LepdClient('localhost') influxDbClient = MyInfluxDbClient('localhost') for i in range(1): pullAndStoreGetCmdPerfFlame(lepdClient, influxDbClient) diff --git a/dataStore/modules/pullAndStoreGetCmdProcrank.py b/dataStore/modules/pullAndStoreGetCmdProcrank.py index e4f947f..34c9b07 100755 --- a/dataStore/modules/pullAndStoreGetCmdProcrank.py +++ b/dataStore/modules/pullAndStoreGetCmdProcrank.py @@ -1,7 +1,7 @@ __author__ = "" __copyright__ = "Licensed under GPLv2 or later." -from app.modules.lepd.LepDClient import LepDClient +from dataStore.lepdClient.LepdClient import LepdClient from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient import time @@ -14,10 +14,27 @@ def pullAndStoreGetCmdProcrank(lepdClient, influxDbClient): res = lepdClient.sendRequest('GetCmdProcrank') print(res) + # json_body = [ + # { + # "measurement": "GetProcSwaps", + # "tags": { + # # the address of lepd + # "server": lepdClient.server + # }, + # # "time": "2017-03-12T22:00:00Z", + # "fields": { + # "LinuxVersion": mystr, + # "compact_stall": int(data['compact_stall']), + # "balloon_migrate": int(data['balloon_migrate']), + # } + # } + # ] + # + # influxDbClient.write_points(json_body) if (__name__ == '__main__'): - lepdClient = LepDClient('www.rmlink.cn') + lepdClient = LepdClient('localhost') influxDbClient = MyInfluxDbClient('localhost') for i in range(1): pullAndStoreGetCmdProcrank(lepdClient, influxDbClient) diff --git a/dataStore/modules/pullAndStoreGetCmdTop.py b/dataStore/modules/pullAndStoreGetCmdTop.py index 9930817..d08107a 100755 --- a/dataStore/modules/pullAndStoreGetCmdTop.py +++ b/dataStore/modules/pullAndStoreGetCmdTop.py @@ -1,7 +1,7 @@ __author__ = "" __copyright__ = "Licensed under GPLv2 or later." -from app.modules.lepd.LepDClient import LepDClient +from dataStore.lepdClient.LepdClient import LepdClient from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient import time @@ -14,10 +14,27 @@ def pullAndStoreGetCmdTop(lepdClient, influxDbClient): res = lepdClient.sendRequest('GetCmdTop') print(res) + # json_body = [ + # { + # "measurement": "GetProcSwaps", + # "tags": { + # # the address of lepd + # "server": lepdClient.server + # }, + # # "time": "2017-03-12T22:00:00Z", + # "fields": { + # "LinuxVersion": mystr, + # "compact_stall": int(data['compact_stall']), + # "balloon_migrate": int(data['balloon_migrate']), + # } + # } + # ] + # + # influxDbClient.write_points(json_body) if (__name__ == '__main__'): - lepdClient = LepDClient('www.rmlink.cn') + lepdClient = LepdClient('localhost') influxDbClient = MyInfluxDbClient('localhost') for i in range(1): pullAndStoreGetCmdTop(lepdClient, influxDbClient) diff --git a/dataStore/modules/pullAndStoreGetCpuInfo.py b/dataStore/modules/pullAndStoreGetCpuInfo.py index f106ab9..4093631 100755 --- a/dataStore/modules/pullAndStoreGetCpuInfo.py +++ b/dataStore/modules/pullAndStoreGetCpuInfo.py @@ -13,6 +13,23 @@ def pullAndStoreGetCpuInfo(lepdClient, influxDbClient): res = lepdClient.sendRequest('GetCpuInfo') print(res) + # json_body = [ + # { + # "measurement": "GetProcSwaps", + # "tags": { + # # the address of lepd + # "server": lepdClient.server + # }, + # # "time": "2017-03-12T22:00:00Z", + # "fields": { + # "LinuxVersion": mystr, + # "compact_stall": int(data['compact_stall']), + # "balloon_migrate": int(data['balloon_migrate']), + # } + # } + # ] + # + # influxDbClient.write_points(json_body) diff --git a/dataStore/modules/pullAndStoreGetProcBuddyinfo.py b/dataStore/modules/pullAndStoreGetProcBuddyinfo.py index b3b1ca0..e51ee4e 100755 --- a/dataStore/modules/pullAndStoreGetProcBuddyinfo.py +++ b/dataStore/modules/pullAndStoreGetProcBuddyinfo.py @@ -1,7 +1,7 @@ __author__ = "" __copyright__ = "Licensed under GPLv2 or later." -from app.modules.lepd.LepDClient import LepDClient +from dataStore.lepdClient.LepdClient import LepdClient from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient import time @@ -86,11 +86,11 @@ def pullAndStoreGetProcBuddyinfo(lepdClient, influxDbClient): # } # ] # - # influxDbClient.write_points('www.rmlink.cn', json_body) + # influxDbClient.write_points( json_body) if (__name__ == '__main__'): - lepdClient = LepDClient('www.rmlink.cn') + lepdClient = LepdClient('localhost') influxDbClient = MyInfluxDbClient('localhost') for i in range(1): pullAndStoreGetProcBuddyinfo(lepdClient, influxDbClient) diff --git a/dataStore/modules/pullAndStoreGetProcDiskstats.py b/dataStore/modules/pullAndStoreGetProcDiskstats.py index bfd4d9a..523f92a 100755 --- a/dataStore/modules/pullAndStoreGetProcDiskstats.py +++ b/dataStore/modules/pullAndStoreGetProcDiskstats.py @@ -1,7 +1,7 @@ __author__ = "" __copyright__ = "Licensed under GPLv2 or later." -from app.modules.lepd.LepDClient import LepDClient +from dataStore.lepdClient.LepdClient import LepdClient from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient import time @@ -15,9 +15,26 @@ def pullAndStoreGetProcDiskstats(lepdClient, influxDbClient): print(res) + # json_body = [ + # { + # "measurement": "GetProcSwaps", + # "tags": { + # # the address of lepd + # "server": lepdClient.server + # }, + # # "time": "2017-03-12T22:00:00Z", + # "fields": { + # "LinuxVersion": mystr, + # "compact_stall": int(data['compact_stall']), + # "balloon_migrate": int(data['balloon_migrate']), + # } + # } + # ] + # + # influxDbClient.write_points(json_body) if (__name__ == '__main__'): - lepdClient = LepDClient('www.rmlink.cn') + lepdClient = LepdClient('localhost') influxDbClient = MyInfluxDbClient('localhost') for i in range(1): pullAndStoreGetProcDiskstats(lepdClient, influxDbClient) diff --git a/dataStore/modules/pullAndStoreGetProcInterrupts.py b/dataStore/modules/pullAndStoreGetProcInterrupts.py index d7f99a5..f41c813 100755 --- a/dataStore/modules/pullAndStoreGetProcInterrupts.py +++ b/dataStore/modules/pullAndStoreGetProcInterrupts.py @@ -1,7 +1,7 @@ __author__ = "" __copyright__ = "Licensed under GPLv2 or later." -from app.modules.lepd.LepDClient import LepDClient +from dataStore.lepdClient.LepdClient import LepdClient from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient import time @@ -15,9 +15,26 @@ def pullAndStoreGetProcInterrupts(lepdClient, influxDbClient): print(res) + # json_body = [ + # { + # "measurement": "GetProcSwaps", + # "tags": { + # # the address of lepd + # "server": lepdClient.server + # }, + # # "time": "2017-03-12T22:00:00Z", + # "fields": { + # "LinuxVersion": mystr, + # "compact_stall": int(data['compact_stall']), + # "balloon_migrate": int(data['balloon_migrate']), + # } + # } + # ] + # + # influxDbClient.write_points(json_body) if (__name__ == '__main__'): - lepdClient = LepDClient('www.rmlink.cn') + lepdClient = LepdClient('localhost') influxDbClient = MyInfluxDbClient('localhost') for i in range(1): pullAndStoreGetProcInterrupts(lepdClient, influxDbClient) diff --git a/dataStore/modules/pullAndStoreGetProcLoadavg.py b/dataStore/modules/pullAndStoreGetProcLoadavg.py index b495c7b..7d235c9 100755 --- a/dataStore/modules/pullAndStoreGetProcLoadavg.py +++ b/dataStore/modules/pullAndStoreGetProcLoadavg.py @@ -1,7 +1,7 @@ __author__ = "" __copyright__ = "Licensed under GPLv2 or later." -from app.modules.lepd.LepDClient import LepDClient +from dataStore.lepdClient.LepdClient import LepdClient from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient import time @@ -86,11 +86,11 @@ def pullAndStoreGetProcLoadavg(lepdClient, influxDbClient): # } # ] # - # influxDbClient.write_points('www.rmlink.cn', json_body) + # influxDbClient.write_points(json_body) if (__name__ == '__main__'): - lepdClient = LepDClient('www.rmlink.cn') + lepdClient = LepdClient('localhost') influxDbClient = MyInfluxDbClient('localhost') for i in range(5): pullAndStoreGetProcLoadavg(lepdClient, influxDbClient) diff --git a/dataStore/modules/pullAndStoreGetProcModules.py b/dataStore/modules/pullAndStoreGetProcModules.py index e90a491..bed5a94 100755 --- a/dataStore/modules/pullAndStoreGetProcModules.py +++ b/dataStore/modules/pullAndStoreGetProcModules.py @@ -1,7 +1,7 @@ __author__ = "" __copyright__ = "Licensed under GPLv2 or later." -from app.modules.lepd.LepDClient import LepDClient +from dataStore.lepdClient.LepdClient import LepdClient from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient import time @@ -13,11 +13,28 @@ def pullAndStoreGetProcModules(lepdClient, influxDbClient): res = lepdClient.sendRequest('GetProcModules') print(res) + # json_body = [ + # { + # "measurement": "GetProcSwaps", + # "tags": { + # # the address of lepd + # "server": lepdClient.server + # }, + # # "time": "2017-03-12T22:00:00Z", + # "fields": { + # "LinuxVersion": mystr, + # "compact_stall": int(data['compact_stall']), + # "balloon_migrate": int(data['balloon_migrate']), + # } + # } + # ] + # + # influxDbClient.write_points(json_body) if (__name__ == '__main__'): - lepdClient = LepDClient('www.rmlink.cn') + lepdClient = LepdClient('localhost') influxDbClient = MyInfluxDbClient('localhost') for i in range(1): pullAndStoreGetProcModules(lepdClient, influxDbClient) diff --git a/dataStore/modules/pullAndStoreGetProcSlabinfo.py b/dataStore/modules/pullAndStoreGetProcSlabinfo.py index 0c3192b..14ef2ab 100755 --- a/dataStore/modules/pullAndStoreGetProcSlabinfo.py +++ b/dataStore/modules/pullAndStoreGetProcSlabinfo.py @@ -1,7 +1,7 @@ __author__ = "" __copyright__ = "Licensed under GPLv2 or later." -from app.modules.lepd.LepDClient import LepDClient +from dataStore.lepdClient.LepdClient import LepdClient from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient import time @@ -13,11 +13,28 @@ def pullAndStoreGetProcSlabinfo(lepdClient, influxDbClient): res = lepdClient.sendRequest('GetProcSlabinfo') print(res) + # json_body = [ + # { + # "measurement": "GetProcSwaps", + # "tags": { + # # the address of lepd + # "server": lepdClient.server + # }, + # # "time": "2017-03-12T22:00:00Z", + # "fields": { + # "LinuxVersion": mystr, + # "compact_stall": int(data['compact_stall']), + # "balloon_migrate": int(data['balloon_migrate']), + # } + # } + # ] + # + # influxDbClient.write_points(json_body) if (__name__ == '__main__'): - lepdClient = LepDClient('www.rmlink.cn') + lepdClient = LepdClient('localhost') influxDbClient = MyInfluxDbClient('localhost') for i in range(1): pullAndStoreGetProcSlabinfo(lepdClient, influxDbClient) diff --git a/dataStore/modules/pullAndStoreGetProcSoftirqs.py b/dataStore/modules/pullAndStoreGetProcSoftirqs.py index a9f5a9a..3800dd5 100755 --- a/dataStore/modules/pullAndStoreGetProcSoftirqs.py +++ b/dataStore/modules/pullAndStoreGetProcSoftirqs.py @@ -1,7 +1,7 @@ __author__ = "" __copyright__ = "Licensed under GPLv2 or later." -from app.modules.lepd.LepDClient import LepDClient +from dataStore.lepdClient.LepdClient import LepdClient from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient import time @@ -13,11 +13,27 @@ def pullAndStoreGetProcSoftirqs(lepdClient, influxDbClient): res = lepdClient.sendRequest('GetProcSoftirqs') print(res) - + # json_body = [ + # { + # "measurement": "GetProcSwaps", + # "tags": { + # # the address of lepd + # "server": lepdClient.server + # }, + # # "time": "2017-03-12T22:00:00Z", + # "fields": { + # "LinuxVersion": mystr, + # "compact_stall": int(data['compact_stall']), + # "balloon_migrate": int(data['balloon_migrate']), + # } + # } + # ] + # + # influxDbClient.write_points(json_body) if (__name__ == '__main__'): - lepdClient = LepDClient('www.rmlink.cn') + lepdClient = LepdClient('localhost') influxDbClient = MyInfluxDbClient('localhost') for i in range(1): pullAndStoreGetProcSoftirqs(lepdClient, influxDbClient) diff --git a/dataStore/modules/pullAndStoreGetProcStat.py b/dataStore/modules/pullAndStoreGetProcStat.py index a9075e7..9ed96ee 100755 --- a/dataStore/modules/pullAndStoreGetProcStat.py +++ b/dataStore/modules/pullAndStoreGetProcStat.py @@ -1,7 +1,7 @@ __author__ = "" __copyright__ = "Licensed under GPLv2 or later." -from app.modules.lepd.LepDClient import LepDClient +from dataStore.lepdClient.LepdClient import LepdClient from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient import time @@ -14,10 +14,26 @@ def pullAndStoreGetProcStat(lepdClient, influxDbClient): res = lepdClient.sendRequest('GetProcStat') print(res) - + # json_body = [ + # { + # "measurement": "GetProcStat", + # "tags": { + # # the address of lepd + # "server": lepdClient.server + # }, + # # "time": "2017-03-12T22:00:00Z", + # "fields": { + # "LinuxVersion": mystr, + # "compact_stall": int(data['compact_stall']), + # "balloon_migrate": int(data['balloon_migrate']), + # } + # } + # ] + # + # influxDbClient.write_points(json_body) if (__name__ == '__main__'): - lepdClient = LepDClient('www.rmlink.cn') + lepdClient = LepdClient('localhost') influxDbClient = MyInfluxDbClient('localhost') for i in range(1): pullAndStoreGetProcStat(lepdClient, influxDbClient) diff --git a/dataStore/modules/pullAndStoreGetProcSwaps.py b/dataStore/modules/pullAndStoreGetProcSwaps.py index a55c21f..1854873 100755 --- a/dataStore/modules/pullAndStoreGetProcSwaps.py +++ b/dataStore/modules/pullAndStoreGetProcSwaps.py @@ -1,7 +1,7 @@ __author__ = "" __copyright__ = "Licensed under GPLv2 or later." -from app.modules.lepd.LepDClient import LepDClient +from dataStore.lepdClient.LepdClient import LepdClient from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient import time @@ -13,11 +13,35 @@ def pullAndStoreGetProcSwaps(lepdClient, influxDbClient): res = lepdClient.sendRequest('GetProcSwaps') print(res) + mystr = res['result'].split('\n') + x1 = mystr[1].split('\t') + for x in x1 : + print(x) + json_body = [ + { + "measurement": "GetProcSwaps", + "tags": { + + # the address of lepd + "server": lepdClient.server + }, + # "time": "2017-03-12T22:00:00Z", + "fields": { + "FilenameType": x1[0], + "Size": int(x1[1]), + "Used": int(x1[2]), + "Priority": int(x1[3]) + } + } + ] + + influxDbClient.write_points(json_body) + if (__name__ == '__main__'): - lepdClient = LepDClient('www.rmlink.cn') + lepdClient = LepdClient('localhost') influxDbClient = MyInfluxDbClient('localhost') for i in range(1): pullAndStoreGetProcSwaps(lepdClient, influxDbClient) diff --git a/dataStore/modules/pullAndStoreGetProcVersion.py b/dataStore/modules/pullAndStoreGetProcVersion.py index be169aa..00ea6e8 100755 --- a/dataStore/modules/pullAndStoreGetProcVersion.py +++ b/dataStore/modules/pullAndStoreGetProcVersion.py @@ -1,7 +1,7 @@ __author__ = "" __copyright__ = "Licensed under GPLv2 or later." -from app.modules.lepd.LepDClient import LepDClient +from dataStore.lepdClient.LepdClient import LepdClient from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient import time @@ -12,12 +12,26 @@ ''' def pullAndStoreGetProcVersion(lepdClient, influxDbClient): res = lepdClient.sendRequest('GetProcVersion') - print(res) + mystr = res['result'] + json_body = [ + { + "measurement": "GetProcVersion", + "tags": { + # the address of lepd + "server": lepdClient.server + }, + # "time": "2017-03-12T22:00:00Z", + "fields": { + "LinuxVersion": mystr + } + } + ] + influxDbClient.write_points(json_body) if (__name__ == '__main__'): - lepdClient = LepDClient('www.rmlink.cn') + lepdClient = LepdClient('localhost') influxDbClient = MyInfluxDbClient('localhost') for i in range(1): pullAndStoreGetProcVersion(lepdClient, influxDbClient) diff --git a/dataStore/modules/pullAndStoreGetProcZoneinfo.py b/dataStore/modules/pullAndStoreGetProcZoneinfo.py index 4a63423..2fa7aa4 100755 --- a/dataStore/modules/pullAndStoreGetProcZoneinfo.py +++ b/dataStore/modules/pullAndStoreGetProcZoneinfo.py @@ -1,9 +1,10 @@ __author__ = "" __copyright__ = "Licensed under GPLv2 or later." -from app.modules.lepd.LepDClient import LepDClient +from dataStore.lepdClient.LepdClient import LepdClient from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient + import time ''' @@ -13,11 +14,68 @@ def pullAndStoreGetProcZoneinfo(lepdClient, influxDbClient): res = lepdClient.sendRequest('GetProcZoneinfo') print(res) + data = {} + + mystr = res['result'].split('\n') + for x in mystr: + x1 = x.strip() + x2 = x1.split(' ') + #把所有参数没有存完 + if (len(x2) == 2): + data[x2[0]]=x2[1] + + + + json_body = [ + { + "measurement": "GetProcZoneinfo", + "tags": { + # the address of lepd + "server": lepdClient.server + }, + # "time": "2017-03-12T22:00:00Z", + "fields": { + "nr_inactive_anon": int(data['nr_inactive_anon']), + "nr_active_anon": int(data['nr_active_anon']), + "nr_inactive_file": int(data['nr_inactive_file']), + "nr_active_file": int(data['nr_active_file']), + "nr_unevictable": int(data['nr_unevictable']), + "nr_slab_reclaimable": int(data['nr_slab_reclaimable']), + "nr_slab_unreclaimable": int(data['nr_slab_unreclaimable']), + "nr_isolated_anon": int(data['nr_isolated_anon']), + "nr_isolated_file": int(data['nr_isolated_file']), + "workingset_refault": int(data['workingset_refault']), + "workingset_activate": int(data['workingset_activate']), + "workingset_nodereclaim": int(data['workingset_nodereclaim']), + "nr_anon_pages": int(data['nr_anon_pages']), + "nr_file_pages": int(data['nr_file_pages']), + "nr_writeback": int(data['nr_writeback']), + "nr_writeback_temp": int(data['nr_writeback_temp']), + "nr_shmem_hugepages": int(data['nr_shmem_hugepages']), + "nr_shmem_pmdmapped": int(data['nr_shmem_pmdmapped']), + "nr_anon_transparent_hugepages": int(data['nr_anon_transparent_hugepages']), + "nr_vmscan_write": int(data['nr_vmscan_write']), + "nr_vmscan_immediate_reclaim": int(data['nr_vmscan_immediate_reclaim']), + "nr_free_pages": int(data['nr_free_pages']), + "nr_zone_inactive_anon": int(data['nr_zone_inactive_anon']), + "nr_zone_active_anon": int(data['nr_zone_active_anon']), + "nr_zone_inactive_file": int(data['nr_zone_inactive_file']), + "nr_zone_active_file": int(data['nr_zone_active_file']), + "nr_zone_unevictable": int(data['nr_zone_unevictable']), + "nr_zone_write_pending": int(data['nr_zone_write_pending']), + "nr_page_table_pages": int(data['nr_page_table_pages']), + "nr_kernel_stack": int(data['nr_kernel_stack']), + "numa_foreign": int(data['numa_foreign']), + "numa_interleave": int(data['numa_interleave']) + } + } + ] + influxDbClient.write_points(json_body) if (__name__ == '__main__'): - lepdClient = LepDClient('www.rmlink.cn') + lepdClient = LepdClient('localhost') influxDbClient = MyInfluxDbClient('localhost') for i in range(1): pullAndStoreGetProcZoneinfo(lepdClient, influxDbClient) From 819cb1354ade77f415b0293cf305b366c0798d49 Mon Sep 17 00:00:00 2001 From: lixusheng <1530830954@qq.com> Date: Thu, 10 May 2018 12:41:10 +0800 Subject: [PATCH 12/25] =?UTF-8?q?add=20run.py=20//=E5=90=8C=E6=97=B6?= =?UTF-8?q?=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/cpu/pullAndStoreGetCmdMpstat.py | 59 ++++++++++++++++++ dataStore/modules/io/__init__.py | 0 .../modules/io/pullAndStoreGetCmdIostat.py | 62 +++++++++++++++++++ dataStore/modules/run.py | 20 ++++++ 4 files changed, 141 insertions(+) create mode 100755 dataStore/modules/cpu/pullAndStoreGetCmdMpstat.py create mode 100644 dataStore/modules/io/__init__.py create mode 100755 dataStore/modules/io/pullAndStoreGetCmdIostat.py create mode 100644 dataStore/modules/run.py diff --git a/dataStore/modules/cpu/pullAndStoreGetCmdMpstat.py b/dataStore/modules/cpu/pullAndStoreGetCmdMpstat.py new file mode 100755 index 0000000..5af8db0 --- /dev/null +++ b/dataStore/modules/cpu/pullAndStoreGetCmdMpstat.py @@ -0,0 +1,59 @@ +__author__ = "" +__copyright__ = "Licensed under GPLv2 or later." + +from dataStore.lepdClient.LepdClient import LepdClient +from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient + +import time + +''' +fetch data related to GetCmdMpstat from lepd by lepdClient and +store the returned data into the influxDB by influxDBClient. +''' +def pullAndStoreGetCmdMpstat(lepdClient, influxDbClient): + res = lepdClient.sendRequest('GetCmdMpstat') + # print(res) + myStr = res['result'].split('\n') + + x1 = myStr[10].split(' ') + x2 = x1[10].split(' ') + # for x in x1: + # print(x) + # for z in x2: + # print(z) + json_body = [ + { + "measurement": "GetCmdMpstat", + "tags": { + # the address of lepd + "server": lepdClient.server + }, + # "time": "2017-03-12T22:00:00Z", + "fields": { + "%usr": float(x1[2]), + "%nice": float(x1[3]), + "%sys": float(x1[4]), + "%iowait": float(x1[5]), + "%irq": float(x1[6]), + "%soft": float(x1[7]), + "%steal": float(x1[8]), + "%guest": float(x1[9]), + "%gnice": float(x2[0]), + "%idle": float(x2[1]) + } + + } + ] + + influxDbClient.write_points(json_body) + + + +if (__name__ == '__main__'): + lepdClient = LepdClient('localhost') + influxDbClient = MyInfluxDbClient('localhost') + for i in range(60): + pullAndStoreGetCmdMpstat(lepdClient, influxDbClient) + time.sleep(1) + + diff --git a/dataStore/modules/io/__init__.py b/dataStore/modules/io/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/dataStore/modules/io/pullAndStoreGetCmdIostat.py b/dataStore/modules/io/pullAndStoreGetCmdIostat.py new file mode 100755 index 0000000..d381b10 --- /dev/null +++ b/dataStore/modules/io/pullAndStoreGetCmdIostat.py @@ -0,0 +1,62 @@ +__author__ = "" +__copyright__ = "Licensed under GPLv2 or later." + +from dataStore.lepdClient.LepdClient import LepdClient +from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient + +import time + +''' +fetch data related to GetCmdIostat from lepd by lepdClient and +store the returned data into the influxDB by influxDBClient. +''' +def pullAndStoreGetCmdIostat(lepdClient, influxDbClient): + res = lepdClient.sendRequest('GetCmdIostat') + # print(res) + mystr = res['result'].split('\n') + # for x in mystr: + # print(x) + # print(mystr[3]) + data = [] + mystr1 = mystr[3].split(' ') + for y in mystr1: + if(y!=''): + data.append(y) + print(data) + + json_body = [ + { + "measurement": "GetCmdIostat", + "tags": { + # the address of lepd + "server": lepdClient.server + }, + # "time": "2017-03-12T22:00:00Z", + "fields": { + "Device": data[0], + "rrqm/s": float(data[1]), + "wrqm/s": float(data[2]), + "r/s": float(data[3]), + "w/s": float(data[4]), + "rkB/s": float(data[5]), + "wkB/s": float(data[6]), + "avgrq-sz": float(data[7]), + "avgqu-sz": float(data[8]), + "await": float(data[9]), + "r_await": float(data[10]), + "w_await": float(data[11]), + "svctm": float(data[12]), + "%util": float(data[13]) + } + } + ] + + influxDbClient.write_points(json_body) + + +if (__name__ == '__main__'): + lepdClient = LepdClient('localhost') + influxDbClient = MyInfluxDbClient('localhost') + for i in range(1): + pullAndStoreGetCmdIostat(lepdClient, influxDbClient) + time.sleep(1) diff --git a/dataStore/modules/run.py b/dataStore/modules/run.py new file mode 100644 index 0000000..a2fb29f --- /dev/null +++ b/dataStore/modules/run.py @@ -0,0 +1,20 @@ +__author__ = "" +__copyright__ = "Licensed under GPLv2 or later." + +from dataStore.lepdClient.LepdClient import LepdClient +from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient +from dataStore.modules.io.pullAndStoreGetCmdIostat import pullAndStoreGetCmdIostat +from dataStore.modules.cpu.pullAndStoreGetCmdMpstat import pullAndStoreGetCmdMpstat +from dataStore.modules.memory.memoryPullAndStore import pullAndStoreGetProcMeminfo + +import time + + +if (__name__ == '__main__'): + lepdClient = LepdClient('localhost') + influxDbClient = MyInfluxDbClient('localhost') + for i in range(60): + pullAndStoreGetCmdIostat(lepdClient, influxDbClient) + pullAndStoreGetProcMeminfo(lepdClient,influxDbClient) + pullAndStoreGetCmdMpstat() + time.sleep(1) From b461495cc544ca80b17504335b149702f263802c Mon Sep 17 00:00:00 2001 From: lixusheng <1530830954@qq.com> Date: Thu, 10 May 2018 12:42:12 +0800 Subject: [PATCH 13/25] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=9B=AE=E5=BD=95=20?= =?UTF-8?q?=20//=E5=90=8C=E6=97=B6=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Store.py => pullAndStoreGetProcCpuinfo.py} | 46 ++++++++++--------- 1 file changed, 24 insertions(+), 22 deletions(-) rename dataStore/modules/{cpu/cpuPullAndStore.py => pullAndStoreGetProcCpuinfo.py} (52%) diff --git a/dataStore/modules/cpu/cpuPullAndStore.py b/dataStore/modules/pullAndStoreGetProcCpuinfo.py similarity index 52% rename from dataStore/modules/cpu/cpuPullAndStore.py rename to dataStore/modules/pullAndStoreGetProcCpuinfo.py index ee9f8e1..26993c0 100644 --- a/dataStore/modules/cpu/cpuPullAndStore.py +++ b/dataStore/modules/pullAndStoreGetProcCpuinfo.py @@ -13,28 +13,30 @@ ''' def pullAndStoreGetProcCpuinfo(lepdClient,influxDbClient): res = lepdClient.sendRequest('GetProcCpuinfo') - mystr = res['result'].split('\n') - data = {} - for x in mystr: - mylist=x.split('\t:') - if(len(mylist)==2): - data[mylist[0]]=mylist[1] - for key in data: - print(key+':'+data[key]) - - json_body = [ - { - "measurement": "GetProcCpuinfo", - "tags": { - # the address of lepd - "server": lepdClient.server - }, - # "time": "2017-03-12T22:00:00Z", - "fields": { - "cpuInfo":str(res) - } - } - ] + print(res) + + # mystr = res['result'].split('\n') + # data = {} + # for x in mystr: + # mylist=x.split('\t:') + # if(len(mylist)==2): + # data[mylist[0]]=mylist[1] + # for key in data: + # print(key+':'+data[key]) + # + # json_body = [ + # { + # "measurement": "GetProcCpuinfo", + # "tags": { + # # the address of lepd + # "server": lepdClient.server + # }, + # # "time": "2017-03-12T22:00:00Z", + # "fields": { + # "cpuInfo":str(res) + # } + # } + # ] # influxDbClient.write_points('localhost', json_body) From cca00303187e0465d937ea1d24abe6bad2d41374 Mon Sep 17 00:00:00 2001 From: lixusheng <1530830954@qq.com> Date: Wed, 16 May 2018 15:37:49 +0800 Subject: [PATCH 14/25] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=AD=98=E5=82=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dataStore/modules/pullAndStoreGetCmdDf.py | 50 ++++++++++++-------- dataStore/modules/pullAndStoreGetCmdDmesg.py | 44 +++++++++-------- dataStore/modules/pullAndStoreGetCmdFree.py | 46 +++++++++++------- dataStore/modules/pullAndStoreGetCmdIotop.py | 43 +++++++++-------- 4 files changed, 108 insertions(+), 75 deletions(-) diff --git a/dataStore/modules/pullAndStoreGetCmdDf.py b/dataStore/modules/pullAndStoreGetCmdDf.py index 8ee2f94..412f30d 100755 --- a/dataStore/modules/pullAndStoreGetCmdDf.py +++ b/dataStore/modules/pullAndStoreGetCmdDf.py @@ -12,25 +12,37 @@ ''' def pullAndStoreGetCmdDf(lepdClient, influxDbClient): res = lepdClient.sendRequest('GetCmdDf') - print(res) - - # json_body = [ - # { - # "measurement": "GetProcSwaps", - # "tags": { - # # the address of lepd - # "server": lepdClient.server - # }, - # # "time": "2017-03-12T22:00:00Z", - # "fields": { - # "LinuxVersion": mystr, - # "compact_stall": int(data['compact_stall']), - # "balloon_migrate": int(data['balloon_migrate']), - # } - # } - # ] - # - # influxDbClient.write_points(json_body) + # print(res) + + str1 = res["result"].split("\n") + str2 = str1[3].split(' ') + data = [] + for x in str2: + if(x!=''): + data.append(x) + # for y in data: + # print(y) + + json_body = [ + { + "measurement": "GetCmdDf", + "tags": { + # the address of lepd + "server": lepdClient.server + }, + # "time": "2017-03-12T22:00:00Z", + "fields": { + "Filesystem": data[0], + "Size": data[1], + "Used": data[2], + "Available": data[3], + "Use%": data[4], + "Mounted on": data[5] + } + } + ] + + influxDbClient.write_points(json_body) if (__name__ == '__main__'): diff --git a/dataStore/modules/pullAndStoreGetCmdDmesg.py b/dataStore/modules/pullAndStoreGetCmdDmesg.py index 26a73b4..82a55d0 100755 --- a/dataStore/modules/pullAndStoreGetCmdDmesg.py +++ b/dataStore/modules/pullAndStoreGetCmdDmesg.py @@ -12,25 +12,31 @@ ''' def pullAndStoreGetCmdDmesg(lepdClient, influxDbClient): res = lepdClient.sendRequest('GetCmdDmesg') - print(res) - - # json_body = [ - # { - # "measurement": "GetProcSwaps", - # "tags": { - # # the address of lepd - # "server": lepdClient.server - # }, - # # "time": "2017-03-12T22:00:00Z", - # "fields": { - # "LinuxVersion": mystr, - # "compact_stall": int(data['compact_stall']), - # "balloon_migrate": int(data['balloon_migrate']), - # } - # } - # ] - # - # influxDbClient.write_points(json_body) + # print(res) + data = res["result"].split("\n") + # for x in data: + # print(x) + + json_body = [ + { + "measurement": "GetCmdDmesg", + "tags": { + # the address of lepd + "server": lepdClient.server + }, + # "time": "2017-03-12T22:00:00Z", + "fields": { + "audit": data[7], + "Adding":data[8], + "NET": data[9], + "e1000":data[12], + "IPv6":data[13] + + } + } + ] + + influxDbClient.write_points(json_body) if (__name__ == '__main__'): diff --git a/dataStore/modules/pullAndStoreGetCmdFree.py b/dataStore/modules/pullAndStoreGetCmdFree.py index d61c3ef..de30815 100755 --- a/dataStore/modules/pullAndStoreGetCmdFree.py +++ b/dataStore/modules/pullAndStoreGetCmdFree.py @@ -12,24 +12,34 @@ ''' def pullAndStoreGetCmdFree(lepdClient, influxDbClient): res = lepdClient.sendRequest('GetCmdFree') - print(res) - # json_body = [ - # { - # "measurement": "GetProcSwaps", - # "tags": { - # # the address of lepd - # "server": lepdClient.server - # }, - # # "time": "2017-03-12T22:00:00Z", - # "fields": { - # "LinuxVersion": mystr, - # "compact_stall": int(data['compact_stall']), - # "balloon_migrate": int(data['balloon_migrate']), - # } - # } - # ] - # - # influxDbClient.write_points(json_body) + # print(res) + str1 = res["result"].split("\n") + str2 = str1[1].split(" ") + data = [] + for x in str2: + if(x!=""): + data.append(x) + + json_body = [ + { + "measurement": "GetCmdFree", + "tags": { + # the address of lepd + "server": lepdClient.server + }, + # "time": "2017-03-12T22:00:00Z", + "fields": { + "total": int(data[1]), + "used": int(data[2]), + "free": int(data[3]), + "shared": int(data[4]), + "buffers": int(data[5]), + "cached": int(data[6]), + } + } + ] + + influxDbClient.write_points(json_body) diff --git a/dataStore/modules/pullAndStoreGetCmdIotop.py b/dataStore/modules/pullAndStoreGetCmdIotop.py index cd42429..941353d 100755 --- a/dataStore/modules/pullAndStoreGetCmdIotop.py +++ b/dataStore/modules/pullAndStoreGetCmdIotop.py @@ -12,25 +12,30 @@ ''' def pullAndStoreGetCmdIotop(lepdClient, influxDbClient): res = lepdClient.sendRequest('GetCmdIotop') - print(res) - - # json_body = [ - # { - # "measurement": "GetProcSwaps", - # "tags": { - # # the address of lepd - # "server": lepdClient.server - # }, - # # "time": "2017-03-12T22:00:00Z", - # "fields": { - # "LinuxVersion": mystr, - # "compact_stall": int(data['compact_stall']), - # "balloon_migrate": int(data['balloon_migrate']), - # } - # } - # ] - # - # influxDbClient.write_points(json_body) + # print(res) + + str1 = res["result"].split("\n") + # for x in str1: + # print(x) + str2 = str1[0].split(" ") + + + json_body = [ + { + "measurement": "GetCmdIotop", + "tags": { + # the address of lepd + "server": lepdClient.server + }, + # "time": "2017-03-12T22:00:00Z", + "fields": { + "Total DISK READ": float(str2[6]), + "Total DISK WRITE": float(str2[15]) + } + } + ] + + influxDbClient.write_points(json_body) if (__name__ == '__main__'): From d2892b9f8be8833e9ab1135f7bf8b16937590c0b Mon Sep 17 00:00:00 2001 From: lixusheng <1530830954@qq.com> Date: Wed, 16 May 2018 18:51:13 +0800 Subject: [PATCH 15/25] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=AD=98=E5=82=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/pullAndStoreGetCmdIrqInfo.py | 43 +++++++++------- .../modules/pullAndStoreGetCmdMpstat-I.py | 51 ++++++++++++------- 2 files changed, 60 insertions(+), 34 deletions(-) diff --git a/dataStore/modules/pullAndStoreGetCmdIrqInfo.py b/dataStore/modules/pullAndStoreGetCmdIrqInfo.py index 4234703..8f18ae0 100755 --- a/dataStore/modules/pullAndStoreGetCmdIrqInfo.py +++ b/dataStore/modules/pullAndStoreGetCmdIrqInfo.py @@ -13,23 +13,32 @@ def pullAndStoreGetCmdIrqInfo(lepdClient, influxDbClient): res = lepdClient.sendRequest('GetCmdIrqInfo') print(res) - # json_body = [ - # { - # "measurement": "GetProcSwaps", - # "tags": { - # # the address of lepd - # "server": lepdClient.server - # }, - # # "time": "2017-03-12T22:00:00Z", - # "fields": { - # "LinuxVersion": mystr, - # "compact_stall": int(data['compact_stall']), - # "balloon_migrate": int(data['balloon_migrate']), - # } - # } - # ] - # - # influxDbClient.write_points(json_body) + str1 = res["result"].split(" ") + x1=str1[0].split(":") + x2=x1[1].split("/") + x3=x2[0] + print(x3) + y1=str1[1].split(":") + y2=y1[1].split("/") + y3=y2[0] + print(y3) + + json_body = [ + { + "measurement": "GetCmdIrqInfo", + "tags": { + # the address of lepd + "server": lepdClient.server + }, + # "time": "2017-03-12T22:00:00Z", + "fields": { + "irq": int(x3), + "softirq": int(y3) + } + } + ] + + influxDbClient.write_points(json_body) diff --git a/dataStore/modules/pullAndStoreGetCmdMpstat-I.py b/dataStore/modules/pullAndStoreGetCmdMpstat-I.py index 526c6dd..acac944 100755 --- a/dataStore/modules/pullAndStoreGetCmdMpstat-I.py +++ b/dataStore/modules/pullAndStoreGetCmdMpstat-I.py @@ -13,23 +13,40 @@ def pullAndStoreGetCmdMpstat_I(lepdClient, influxDbClient): res = lepdClient.sendRequest('GetCmdMpstat-I') print(res) - # json_body = [ - # { - # "measurement": "GetProcSwaps", - # "tags": { - # # the address of lepd - # "server": lepdClient.server - # }, - # # "time": "2017-03-12T22:00:00Z", - # "fields": { - # "LinuxVersion": mystr, - # "compact_stall": int(data['compact_stall']), - # "balloon_migrate": int(data['balloon_migrate']), - # } - # } - # ] - # - # influxDbClient.write_points(json_body) + str1 = res["result"].split("\n") + # for x in str1: + # print(x) + data = [] + str2=str1[27].split(" ") + for y in str2: + if(y!=""): + data.append(y) + json_body = [ + { + "measurement": "GetProcSwaps", + + "tags": { + # the address of lepd + "server": lepdClient.server + }, + # "time": "2017-03-12T22:00:00Z", + "fields": { + "CPU": float(data[1]), + "HI/s": float(data[2]), + "TIMER/s": float(data[3]), + "NET_TX/s": float(data[4]), + "NET_RX/s": float(data[5]), + "BLOCK/s": float(data[6]), + "IRQ_POLL/s": float(data[7]), + "TASKLET/s": float(data[8]), + "SCHED/s": float(data[9]), + "HRTIMER/s": float(data[10]), + "RCU/s": float(data[11]) + } + } + ] + + influxDbClient.write_points(json_body) From 8906013bb55644fef56f9c0076808940c44ab8c6 Mon Sep 17 00:00:00 2001 From: lixusheng <1530830954@qq.com> Date: Wed, 16 May 2018 18:56:58 +0800 Subject: [PATCH 16/25] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=AD=98=E5=82=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dataStore/modules/pullAndStoreGetProcSwaps.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dataStore/modules/pullAndStoreGetProcSwaps.py b/dataStore/modules/pullAndStoreGetProcSwaps.py index 1854873..6a8fa04 100755 --- a/dataStore/modules/pullAndStoreGetProcSwaps.py +++ b/dataStore/modules/pullAndStoreGetProcSwaps.py @@ -12,11 +12,11 @@ ''' def pullAndStoreGetProcSwaps(lepdClient, influxDbClient): res = lepdClient.sendRequest('GetProcSwaps') - print(res) + # print(res) mystr = res['result'].split('\n') x1 = mystr[1].split('\t') - for x in x1 : - print(x) + # for x in x1: + # print(x) From f895943e38742871f723a2a9590ddaa3f7183232 Mon Sep 17 00:00:00 2001 From: lixusheng <1530830954@qq.com> Date: Sat, 19 May 2018 23:21:24 +0800 Subject: [PATCH 17/25] =?UTF-8?q?=20=E4=BF=AE=E6=94=B9=E4=BA=86=E4=B8=8D?= =?UTF-8?q?=E6=96=AD=E8=AF=B7=E6=B1=82=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dataStore/modules/cpu/pullAndStoreGetCmdMpstat.py | 4 ++-- dataStore/modules/io/pullAndStoreGetCmdIostat.py | 2 +- .../modules/{ => io}/pullAndStoreGetCmdIotop.py | 13 +++++++------ ...ullAndStore.py => pullAndStoreGetProcMeminfo.py} | 4 ++-- dataStore/modules/run.py | 8 ++++---- 5 files changed, 16 insertions(+), 15 deletions(-) rename dataStore/modules/{ => io}/pullAndStoreGetCmdIotop.py (84%) rename dataStore/modules/memory/{memoryPullAndStore.py => pullAndStoreGetProcMeminfo.py} (98%) diff --git a/dataStore/modules/cpu/pullAndStoreGetCmdMpstat.py b/dataStore/modules/cpu/pullAndStoreGetCmdMpstat.py index 5af8db0..f0b9170 100755 --- a/dataStore/modules/cpu/pullAndStoreGetCmdMpstat.py +++ b/dataStore/modules/cpu/pullAndStoreGetCmdMpstat.py @@ -18,7 +18,7 @@ def pullAndStoreGetCmdMpstat(lepdClient, influxDbClient): x1 = myStr[10].split(' ') x2 = x1[10].split(' ') # for x in x1: - # print(x) + # print(x) # for z in x2: # print(z) json_body = [ @@ -52,7 +52,7 @@ def pullAndStoreGetCmdMpstat(lepdClient, influxDbClient): if (__name__ == '__main__'): lepdClient = LepdClient('localhost') influxDbClient = MyInfluxDbClient('localhost') - for i in range(60): + for i in range(10): pullAndStoreGetCmdMpstat(lepdClient, influxDbClient) time.sleep(1) diff --git a/dataStore/modules/io/pullAndStoreGetCmdIostat.py b/dataStore/modules/io/pullAndStoreGetCmdIostat.py index d381b10..17c4fe8 100755 --- a/dataStore/modules/io/pullAndStoreGetCmdIostat.py +++ b/dataStore/modules/io/pullAndStoreGetCmdIostat.py @@ -57,6 +57,6 @@ def pullAndStoreGetCmdIostat(lepdClient, influxDbClient): if (__name__ == '__main__'): lepdClient = LepdClient('localhost') influxDbClient = MyInfluxDbClient('localhost') - for i in range(1): + for i in range(10): pullAndStoreGetCmdIostat(lepdClient, influxDbClient) time.sleep(1) diff --git a/dataStore/modules/pullAndStoreGetCmdIotop.py b/dataStore/modules/io/pullAndStoreGetCmdIotop.py similarity index 84% rename from dataStore/modules/pullAndStoreGetCmdIotop.py rename to dataStore/modules/io/pullAndStoreGetCmdIotop.py index 941353d..0b53deb 100755 --- a/dataStore/modules/pullAndStoreGetCmdIotop.py +++ b/dataStore/modules/io/pullAndStoreGetCmdIotop.py @@ -3,6 +3,7 @@ from dataStore.lepdClient.LepdClient import LepdClient from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient +import re import time @@ -15,13 +16,13 @@ def pullAndStoreGetCmdIotop(lepdClient, influxDbClient): # print(res) str1 = res["result"].split("\n") - # for x in str1: - # print(x) - str2 = str1[0].split(" ") + data=re.findall(r"\d+\.?\d*", str1[0]) + # print(data) json_body = [ { + "measurement": "GetCmdIotop", "tags": { # the address of lepd @@ -29,8 +30,8 @@ def pullAndStoreGetCmdIotop(lepdClient, influxDbClient): }, # "time": "2017-03-12T22:00:00Z", "fields": { - "Total DISK READ": float(str2[6]), - "Total DISK WRITE": float(str2[15]) + "Total DISK READ": float(data[0]), + "Total DISK WRITE": float(data[1]) } } ] @@ -41,6 +42,6 @@ def pullAndStoreGetCmdIotop(lepdClient, influxDbClient): if (__name__ == '__main__'): lepdClient = LepdClient('localhost') influxDbClient = MyInfluxDbClient('localhost') - for i in range(1): + for i in range(60): pullAndStoreGetCmdIotop(lepdClient, influxDbClient) time.sleep(1) diff --git a/dataStore/modules/memory/memoryPullAndStore.py b/dataStore/modules/memory/pullAndStoreGetProcMeminfo.py similarity index 98% rename from dataStore/modules/memory/memoryPullAndStore.py rename to dataStore/modules/memory/pullAndStoreGetProcMeminfo.py index c666fc3..31ef740 100644 --- a/dataStore/modules/memory/memoryPullAndStore.py +++ b/dataStore/modules/memory/pullAndStoreGetProcMeminfo.py @@ -14,7 +14,7 @@ def pullAndStoreGetProcMeminfo(lepdClient, influxDbClient): res = lepdClient.sendRequest('GetProcMeminfo') - print(res) + # print(res) mystr = res['result'].split('\n') data = {} for x in mystr: @@ -96,6 +96,6 @@ def pullAndStoreGetProcMeminfo(lepdClient, influxDbClient): if (__name__ == '__main__'): lepdClient = LepdClient('localhost') influxDbClient = MyInfluxDbClient('localhost') - for i in range(1): + for i in range(10): pullAndStoreGetProcMeminfo(lepdClient, influxDbClient) time.sleep(1) diff --git a/dataStore/modules/run.py b/dataStore/modules/run.py index a2fb29f..387e6db 100644 --- a/dataStore/modules/run.py +++ b/dataStore/modules/run.py @@ -3,9 +3,9 @@ from dataStore.lepdClient.LepdClient import LepdClient from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient -from dataStore.modules.io.pullAndStoreGetCmdIostat import pullAndStoreGetCmdIostat +from dataStore.modules.io.pullAndStoreGetCmdIotop import pullAndStoreGetCmdIotop from dataStore.modules.cpu.pullAndStoreGetCmdMpstat import pullAndStoreGetCmdMpstat -from dataStore.modules.memory.memoryPullAndStore import pullAndStoreGetProcMeminfo +from dataStore.modules.memory.pullAndStoreGetProcMeminfo import pullAndStoreGetProcMeminfo import time @@ -14,7 +14,7 @@ lepdClient = LepdClient('localhost') influxDbClient = MyInfluxDbClient('localhost') for i in range(60): - pullAndStoreGetCmdIostat(lepdClient, influxDbClient) + pullAndStoreGetCmdIotop(lepdClient, influxDbClient) pullAndStoreGetProcMeminfo(lepdClient,influxDbClient) - pullAndStoreGetCmdMpstat() + pullAndStoreGetCmdMpstat(lepdClient,influxDbClient) time.sleep(1) From 4c5fc1c99b9109d80b8d36e036ca239079032d12 Mon Sep 17 00:00:00 2001 From: lixusheng <1530830954@qq.com> Date: Mon, 21 May 2018 11:28:10 +0800 Subject: [PATCH 18/25] =?UTF-8?q?=20=E4=BF=AE=E6=94=B9=E4=BA=86=E4=B8=8D?= =?UTF-8?q?=E6=96=AD=E8=AF=B7=E6=B1=82=E5=9B=A0=E6=95=B0=E6=8D=AE=E5=8F=98?= =?UTF-8?q?=E5=8C=96=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/cpu/pullAndStoreGetCmdMpstat.py | 32 +++++++++---------- .../modules/io/pullAndStoreGetCmdIostat.py | 4 +-- .../modules/io/pullAndStoreGetCmdIotop.py | 8 ++--- .../memory/pullAndStoreGetProcMeminfo.py | 2 +- 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/dataStore/modules/cpu/pullAndStoreGetCmdMpstat.py b/dataStore/modules/cpu/pullAndStoreGetCmdMpstat.py index f0b9170..f760fd6 100755 --- a/dataStore/modules/cpu/pullAndStoreGetCmdMpstat.py +++ b/dataStore/modules/cpu/pullAndStoreGetCmdMpstat.py @@ -5,6 +5,7 @@ from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient import time +import re ''' fetch data related to GetCmdMpstat from lepd by lepdClient and @@ -15,12 +16,9 @@ def pullAndStoreGetCmdMpstat(lepdClient, influxDbClient): # print(res) myStr = res['result'].split('\n') - x1 = myStr[10].split(' ') - x2 = x1[10].split(' ') - # for x in x1: - # print(x) - # for z in x2: - # print(z) + data = re.findall(r"\d+\.?\d*", myStr[10]) + + json_body = [ { "measurement": "GetCmdMpstat", @@ -30,16 +28,16 @@ def pullAndStoreGetCmdMpstat(lepdClient, influxDbClient): }, # "time": "2017-03-12T22:00:00Z", "fields": { - "%usr": float(x1[2]), - "%nice": float(x1[3]), - "%sys": float(x1[4]), - "%iowait": float(x1[5]), - "%irq": float(x1[6]), - "%soft": float(x1[7]), - "%steal": float(x1[8]), - "%guest": float(x1[9]), - "%gnice": float(x2[0]), - "%idle": float(x2[1]) + "%usr": float(data[0]), + "%nice": float(data[1]), + "%sys": float(data[2]), + "%iowait": float(data[3]), + "%irq": float(data[4]), + "%soft": float(data[5]), + "%steal": float(data[6]), + "%guest": float(data[7]), + "%gnice": float(data[8]), + "%idle": float(data[9]) } } @@ -52,7 +50,7 @@ def pullAndStoreGetCmdMpstat(lepdClient, influxDbClient): if (__name__ == '__main__'): lepdClient = LepdClient('localhost') influxDbClient = MyInfluxDbClient('localhost') - for i in range(10): + for i in range(30): pullAndStoreGetCmdMpstat(lepdClient, influxDbClient) time.sleep(1) diff --git a/dataStore/modules/io/pullAndStoreGetCmdIostat.py b/dataStore/modules/io/pullAndStoreGetCmdIostat.py index 17c4fe8..f12b5e0 100755 --- a/dataStore/modules/io/pullAndStoreGetCmdIostat.py +++ b/dataStore/modules/io/pullAndStoreGetCmdIostat.py @@ -22,7 +22,7 @@ def pullAndStoreGetCmdIostat(lepdClient, influxDbClient): for y in mystr1: if(y!=''): data.append(y) - print(data) + # print(data) json_body = [ { @@ -57,6 +57,6 @@ def pullAndStoreGetCmdIostat(lepdClient, influxDbClient): if (__name__ == '__main__'): lepdClient = LepdClient('localhost') influxDbClient = MyInfluxDbClient('localhost') - for i in range(10): + for i in range(120): pullAndStoreGetCmdIostat(lepdClient, influxDbClient) time.sleep(1) diff --git a/dataStore/modules/io/pullAndStoreGetCmdIotop.py b/dataStore/modules/io/pullAndStoreGetCmdIotop.py index 0b53deb..a5ad99e 100755 --- a/dataStore/modules/io/pullAndStoreGetCmdIotop.py +++ b/dataStore/modules/io/pullAndStoreGetCmdIotop.py @@ -30,8 +30,8 @@ def pullAndStoreGetCmdIotop(lepdClient, influxDbClient): }, # "time": "2017-03-12T22:00:00Z", "fields": { - "Total DISK READ": float(data[0]), - "Total DISK WRITE": float(data[1]) + "Total_DISK_READ": float(data[0]), + "Total_DISK_WRITE": float(data[1]) } } ] @@ -42,6 +42,6 @@ def pullAndStoreGetCmdIotop(lepdClient, influxDbClient): if (__name__ == '__main__'): lepdClient = LepdClient('localhost') influxDbClient = MyInfluxDbClient('localhost') - for i in range(60): + for i in range(120): pullAndStoreGetCmdIotop(lepdClient, influxDbClient) - time.sleep(1) + # time.sleep(0.3) diff --git a/dataStore/modules/memory/pullAndStoreGetProcMeminfo.py b/dataStore/modules/memory/pullAndStoreGetProcMeminfo.py index 31ef740..0913872 100644 --- a/dataStore/modules/memory/pullAndStoreGetProcMeminfo.py +++ b/dataStore/modules/memory/pullAndStoreGetProcMeminfo.py @@ -96,6 +96,6 @@ def pullAndStoreGetProcMeminfo(lepdClient, influxDbClient): if (__name__ == '__main__'): lepdClient = LepdClient('localhost') influxDbClient = MyInfluxDbClient('localhost') - for i in range(10): + for i in range(60): pullAndStoreGetProcMeminfo(lepdClient, influxDbClient) time.sleep(1) From a2477e657ac9d0a7eead3202a9efabf63e09f342 Mon Sep 17 00:00:00 2001 From: lixusheng <1530830954@qq.com> Date: Mon, 21 May 2018 11:33:18 +0800 Subject: [PATCH 19/25] =?UTF-8?q?=E5=90=8C=E6=97=B6=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=EF=BC=8C=E4=BF=9D=E5=AD=98CQ?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dataStore/modules/influx | 44 ++++++++++++++++++++++++++++++++++++++++ dataStore/modules/run.py | 4 +++- 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 dataStore/modules/influx diff --git a/dataStore/modules/influx b/dataStore/modules/influx new file mode 100644 index 0000000..97f2dc6 --- /dev/null +++ b/dataStore/modules/influx @@ -0,0 +1,44 @@ +CREATE CONTINUOUS QUERY cp_1_week_GetCmdIotop ON lep BEGIN SELECT mean("Total_DISK_READ") AS "meanTDR" ,mean("Total_DISK_WRITE") +AS "meanTDW" INTO lep."1_week".GetCmdIotop FROM lep."12_hours".GetCmdIotop GROUP BY time(60s) END + + + + +CREATE CONTINUOUS QUERY cp_1_week_GetCmdMpstat ON lep BEGIN +SELECT +mean("%usr") AS meanusr,mean("%nice") AS meannice, +mean("%sys") AS meansys,mean("%iowait") AS meaniowait, +mean("%irq") AS meanirq,mean("%soft") AS meansoft, +mean("%steal")AS meansteal,mean("%guest") AS meanguest, +mean("%gnice") AS meangnice,mean("%idle") AS meanidle +INTO lep."1_week".GetCmdMpstat FROM lep."12_hours".GetCmdMpstat +GROUP BY time(60s) END + + +CREATE CONTINUOUS QUERY cp_1_month_GetCmdMpstat ON lep BEGIN +SELECT +mean("%usr") AS meanusr,mean("%nice") AS meannice, +mean("%sys") AS meansys,mean("%iowait") AS meaniowait, +mean("%irq") AS meanirq,mean("%soft") AS meansoft, +mean("%steal")AS meansteal,mean("%guest") AS meanguest, +mean("%gnice") AS meangnice,mean("%idle") AS meanidle +INTO lep."1_month".GetCmdMpstat FROM lep."12_hours".GetCmdMpstat +GROUP BY time(600s) END + + +CREATE CONTINUOUS QUERY cp_1_year_GetCmdMpstat ON lep BEGIN +SELECT +mean("%usr") AS meanusr,mean("%nice") AS meannice, +mean("%sys") AS meansys,mean("%iowait") AS meaniowait, +mean("%irq") AS meanirq,mean("%soft") AS meansoft, +mean("%steal")AS meansteal,mean("%guest") AS meanguest, +mean("%gnice") AS meangnice,mean("%idle") AS meanidle +INTO lep."1_year".GetCmdMpstat FROM lep."12_hours".GetCmdMpstat +GROUP BY time(1800s) END + + + +CREATE CONTINUOUS QUERY cp_1_week_GetCmdIostat ON lep BEGIN SELECT mean("rrqm/s") AS meanrrqm,mean("wrqm/s") AS meanwrqm, mean("r/s") AS meanr, mean("w/s") AS meanw, mean("rkB/s") AS meanrkB,mean("wkB/s") AS meanwkb,mean("avgrq-sz") AS meanavgrq, +mean("avgqu-sz") AS meanavgqu,mean("await") AS meanawait,mean("r_await") AS meanr_await,mean("w_await") AS meanw_await,mean("svctm") AS meansvctm,mean("%util") As meanutil INTO lep."1_week".GetCmdIostat FROM lep."12_hours".GetCmdIostat GROUP BY time(60s) END + + diff --git a/dataStore/modules/run.py b/dataStore/modules/run.py index 387e6db..a50c9be 100644 --- a/dataStore/modules/run.py +++ b/dataStore/modules/run.py @@ -6,6 +6,7 @@ from dataStore.modules.io.pullAndStoreGetCmdIotop import pullAndStoreGetCmdIotop from dataStore.modules.cpu.pullAndStoreGetCmdMpstat import pullAndStoreGetCmdMpstat from dataStore.modules.memory.pullAndStoreGetProcMeminfo import pullAndStoreGetProcMeminfo +from dataStore.modules.io.pullAndStoreGetCmdIostat import pullAndStoreGetCmdIostat import time @@ -13,8 +14,9 @@ if (__name__ == '__main__'): lepdClient = LepdClient('localhost') influxDbClient = MyInfluxDbClient('localhost') - for i in range(60): + for i in range(120): pullAndStoreGetCmdIotop(lepdClient, influxDbClient) + pullAndStoreGetCmdIostat(lepdClient,influxDbClient) pullAndStoreGetProcMeminfo(lepdClient,influxDbClient) pullAndStoreGetCmdMpstat(lepdClient,influxDbClient) time.sleep(1) From 4bb4a67f85467b36b644d7e006d546a3b99fc4d4 Mon Sep 17 00:00:00 2001 From: lixusheng <1530830954@qq.com> Date: Tue, 22 May 2018 11:23:58 +0800 Subject: [PATCH 20/25] =?UTF-8?q?=E5=AE=8C=E6=88=90=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E5=AD=98=E5=82=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/pullAndStoreGetCmdProcrank.py | 46 ++++++++++++------- dataStore/modules/pullAndStoreGetCpuInfo.py | 43 +++++++++-------- 2 files changed, 54 insertions(+), 35 deletions(-) diff --git a/dataStore/modules/pullAndStoreGetCmdProcrank.py b/dataStore/modules/pullAndStoreGetCmdProcrank.py index 34c9b07..c4b53dd 100755 --- a/dataStore/modules/pullAndStoreGetCmdProcrank.py +++ b/dataStore/modules/pullAndStoreGetCmdProcrank.py @@ -5,6 +5,7 @@ from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient import time +import re ''' fetch data related to GetCmdProcrank from lepd by lepdClient and @@ -13,24 +14,35 @@ def pullAndStoreGetCmdProcrank(lepdClient, influxDbClient): res = lepdClient.sendRequest('GetCmdProcrank') print(res) + str1 = res["result"].split("\n") + # for x in str1: + # print(x) + # print(str1[-2]) - # json_body = [ - # { - # "measurement": "GetProcSwaps", - # "tags": { - # # the address of lepd - # "server": lepdClient.server - # }, - # # "time": "2017-03-12T22:00:00Z", - # "fields": { - # "LinuxVersion": mystr, - # "compact_stall": int(data['compact_stall']), - # "balloon_migrate": int(data['balloon_migrate']), - # } - # } - # ] - # - # influxDbClient.write_points(json_body) + data = re.findall(r"\d+\.?\d*", str1[-2]) + print(data) + + json_body = [ + { + "measurement": "GetCmdProcrank", + "tags": { + # the address of lepd + "server": lepdClient.server + }, + # "time": "2017-03-12T22:00:00Z", + "fields": { + "total": int(data[0]), + "free": int(data[1]), + "buffers": int(data[2]), + "cached": int(data[3]), + "shmem": int(data[4]), + "slab": int(data[5]) + + } + } + ] + + influxDbClient.write_points(json_body) if (__name__ == '__main__'): diff --git a/dataStore/modules/pullAndStoreGetCpuInfo.py b/dataStore/modules/pullAndStoreGetCpuInfo.py index 4093631..851bdaf 100755 --- a/dataStore/modules/pullAndStoreGetCpuInfo.py +++ b/dataStore/modules/pullAndStoreGetCpuInfo.py @@ -12,24 +12,31 @@ ''' def pullAndStoreGetCpuInfo(lepdClient, influxDbClient): res = lepdClient.sendRequest('GetCpuInfo') - print(res) - # json_body = [ - # { - # "measurement": "GetProcSwaps", - # "tags": { - # # the address of lepd - # "server": lepdClient.server - # }, - # # "time": "2017-03-12T22:00:00Z", - # "fields": { - # "LinuxVersion": mystr, - # "compact_stall": int(data['compact_stall']), - # "balloon_migrate": int(data['balloon_migrate']), - # } - # } - # ] - # - # influxDbClient.write_points(json_body) + # print(res) + str1 = res["result"].split("\n") + data1 = str1[0].split(": ") + data2 = str1[1].split(": ") + # for x in data1: + # print(x) + # for x in data2: + # print(x) + json_body = [ + { + "measurement": "GetCpuInfo", + "tags": { + # the address of lepd + "server": lepdClient.server + }, + # "time": "2017-03-12T22:00:00Z", + "fields": { + "cpunr": int(data1[1]), + "cpu_name": data2[1] + + } + } + ] + + influxDbClient.write_points(json_body) From f69db83e5db190443a0e4aaf0f196406fdd7a738 Mon Sep 17 00:00:00 2001 From: lixusheng <1530830954@qq.com> Date: Tue, 22 May 2018 11:55:38 +0800 Subject: [PATCH 21/25] =?UTF-8?q?=E5=AE=8C=E6=88=90=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E5=AD=98=E5=82=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/pullAndStoreGetProcBuddyinfo.py | 97 +++++-------------- .../modules/pullAndStoreGetProcCpuinfo.py | 46 ++++----- 2 files changed, 43 insertions(+), 100 deletions(-) diff --git a/dataStore/modules/pullAndStoreGetProcBuddyinfo.py b/dataStore/modules/pullAndStoreGetProcBuddyinfo.py index e51ee4e..dd7231f 100755 --- a/dataStore/modules/pullAndStoreGetProcBuddyinfo.py +++ b/dataStore/modules/pullAndStoreGetProcBuddyinfo.py @@ -12,81 +12,28 @@ ''' def pullAndStoreGetProcBuddyinfo(lepdClient, influxDbClient): res = lepdClient.sendRequest('GetProcBuddyinfo') - print(res) - # str = res['result'].split('\n') - # data = {} - # for x in str: - # - # x1 = x.replace('kB', '') - # x2 = x1.replace(' ', '') - # list = x2.split(':') - # if (len(list) == 2): - # data[list[0]] = list[1] - # - # # print(data) - # - # json_body = [ - # { - # "measurement": "GetProcMeminfo", - # "tags": { - # # the address of lepd - # "server": lepdClient.server - # }, - # # "time": "2017-03-12T22:00:00Z", - # "fields": { - # "MemTotal": data['MemTotal'], - # "MemFree": data['MemFree'], - # # "MemAvailable": data['MemAvailable'], - # "Buffers": data['Buffers'], - # "Cached": data['Cached'], - # "SwapCached": data['MemTotal'], - # "Active": data['Active'], - # "Inactive": data['Inactive'], - # "Active(anon)": data['Active(anon)'], - # "Inactive(anon)": data['Inactive(anon)'], - # "Active(file)": data['Active(file)'], - # "Inactive(file)": data['Inactive(file)'], - # "Unevictable": data['Unevictable'], - # "Mlocked": data['Mlocked'], - # "SwapTotal": data['SwapTotal'], - # "SwapFree": data['SwapFree'], - # "Dirty": data['Dirty'], - # "Writeback": data['Writeback'], - # "AnonPages": data['AnonPages'], - # "Mapped": data['Mapped'], - # "Shmem": data['Shmem'], - # "Slab": data['Slab'], - # "SReclaimable": data['SReclaimable'], - # "SUnreclaim": data['SUnreclaim'], - # "KernelStack": data['KernelStack'], - # "PageTables": data['PageTables'], - # "NFS_Unstable": data['NFS_Unstable'], - # "Bounce": data['Bounce'], - # "WritebackTmp": data['WritebackTmp'], - # "CommitLimit": data['CommitLimit'], - # "Committed_AS": data['Committed_AS'], - # "VmallocTotal": data['VmallocTotal'], - # "VmallocUsed": data['VmallocUsed'], - # "VmallocChunk": data['VmallocChunk'], - # "HardwareCorrupted": data['HardwareCorrupted'], - # "AnonHugePages": data['AnonHugePages'], - # # "ShmemHugePages": data['ShmemHugePages'], - # # "ShmemPmdMapped": data['ShmemPmdMapped'], - # # "CmaTotal": data['CmaTotal'], - # # "CmaFree": data['CmaFree'], - # "HugePages_Total": data['HugePages_Total'], - # "HugePages_Free": data['HugePages_Free'], - # "HugePages_Rsvd": data['HugePages_Rsvd'], - # "HugePages_Surp": data['HugePages_Surp'], - # "Hugepagesize": data['Hugepagesize'], - # "DirectMap4k": data['DirectMap4k'], - # "DirectMap2M": data['DirectMap2M'], - # "DirectMap1G": data['DirectMap1G'] - # } - # } - # ] - # - # influxDbClient.write_points( json_body) + # print(res) + str1 = res["result"].split("\n") + # for x in str1: + # print(x) + + + json_body = [ + { + "measurement": "GetProcBuddyinfo", + "tags": { + # the address of lepd + "server": lepdClient.server + }, + # "time": "2017-03-12T22:00:00Z", + "fields": { + "DMA": str1[0], + "DMA32": str1[1] + } + } + ] + + influxDbClient.write_points( json_body) if (__name__ == '__main__'): diff --git a/dataStore/modules/pullAndStoreGetProcCpuinfo.py b/dataStore/modules/pullAndStoreGetProcCpuinfo.py index 26993c0..1e39744 100644 --- a/dataStore/modules/pullAndStoreGetProcCpuinfo.py +++ b/dataStore/modules/pullAndStoreGetProcCpuinfo.py @@ -14,31 +14,27 @@ def pullAndStoreGetProcCpuinfo(lepdClient,influxDbClient): res = lepdClient.sendRequest('GetProcCpuinfo') print(res) - - # mystr = res['result'].split('\n') - # data = {} - # for x in mystr: - # mylist=x.split('\t:') - # if(len(mylist)==2): - # data[mylist[0]]=mylist[1] - # for key in data: - # print(key+':'+data[key]) - # - # json_body = [ - # { - # "measurement": "GetProcCpuinfo", - # "tags": { - # # the address of lepd - # "server": lepdClient.server - # }, - # # "time": "2017-03-12T22:00:00Z", - # "fields": { - # "cpuInfo":str(res) - # } - # } - # ] - - # influxDbClient.write_points('localhost', json_body) + str1 = res["result"].split("\n") + + str='' + for i in range(27): + str=str+str1[i] + # print(str) + json_body = [ + { + "measurement": "GetProcCpuinfo", + "tags": { + # the address of lepd + "server": lepdClient.server + }, + # "time": "2017-03-12T22:00:00Z", + "fields": { + "cpuInfo":str + } + } + ] + + influxDbClient.write_points(json_body) if(__name__=='__main__'): From 4c559c430a3b7d3ee02f8919123f302f135ae542 Mon Sep 17 00:00:00 2001 From: lixusheng <1530830954@qq.com> Date: Tue, 22 May 2018 12:17:40 +0800 Subject: [PATCH 22/25] =?UTF-8?q?=E5=AE=8C=E6=88=90=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E5=AD=98=E5=82=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/pullAndStoreGetProcDiskstats.py | 39 ++++---- .../modules/pullAndStoreGetProcLoadavg.py | 97 ++++--------------- .../modules/pullAndStoreGetProcModules.py | 38 ++++---- 3 files changed, 60 insertions(+), 114 deletions(-) diff --git a/dataStore/modules/pullAndStoreGetProcDiskstats.py b/dataStore/modules/pullAndStoreGetProcDiskstats.py index 523f92a..ff354bf 100755 --- a/dataStore/modules/pullAndStoreGetProcDiskstats.py +++ b/dataStore/modules/pullAndStoreGetProcDiskstats.py @@ -12,26 +12,25 @@ ''' def pullAndStoreGetProcDiskstats(lepdClient, influxDbClient): res = lepdClient.sendRequest('GetProcDiskstats') - print(res) - - - # json_body = [ - # { - # "measurement": "GetProcSwaps", - # "tags": { - # # the address of lepd - # "server": lepdClient.server - # }, - # # "time": "2017-03-12T22:00:00Z", - # "fields": { - # "LinuxVersion": mystr, - # "compact_stall": int(data['compact_stall']), - # "balloon_migrate": int(data['balloon_migrate']), - # } - # } - # ] - # - # influxDbClient.write_points(json_body) + # print(res) + + + + json_body = [ + { + "measurement": "GetProcDiskstats", + "tags": { + # the address of lepd + "server": lepdClient.server + }, + # "time": "2017-03-12T22:00:00Z", + "fields": { + "Diskstats": res["result"] + } + } + ] + + influxDbClient.write_points(json_body) if (__name__ == '__main__'): lepdClient = LepdClient('localhost') diff --git a/dataStore/modules/pullAndStoreGetProcLoadavg.py b/dataStore/modules/pullAndStoreGetProcLoadavg.py index 7d235c9..68a03ae 100755 --- a/dataStore/modules/pullAndStoreGetProcLoadavg.py +++ b/dataStore/modules/pullAndStoreGetProcLoadavg.py @@ -12,86 +12,31 @@ ''' def pullAndStoreGetProcLoadavg(lepdClient, influxDbClient): res = lepdClient.sendRequest('GetProcLoadavg') - print(res) - # str = res['result'].split('\n') - # data = {} - # for x in str: - # - # x1 = x.replace('kB', '') - # x2 = x1.replace(' ', '') - # list = x2.split(':') - # if (len(list) == 2): - # data[list[0]] = list[1] - # - # # print(data) - # - # json_body = [ - # { - # "measurement": "GetProcMeminfo", - # "tags": { - # # the address of lepd - # "server": lepdClient.server - # }, - # # "time": "2017-03-12T22:00:00Z", - # "fields": { - # "MemTotal": data['MemTotal'], - # "MemFree": data['MemFree'], - # # "MemAvailable": data['MemAvailable'], - # "Buffers": data['Buffers'], - # "Cached": data['Cached'], - # "SwapCached": data['MemTotal'], - # "Active": data['Active'], - # "Inactive": data['Inactive'], - # "Active(anon)": data['Active(anon)'], - # "Inactive(anon)": data['Inactive(anon)'], - # "Active(file)": data['Active(file)'], - # "Inactive(file)": data['Inactive(file)'], - # "Unevictable": data['Unevictable'], - # "Mlocked": data['Mlocked'], - # "SwapTotal": data['SwapTotal'], - # "SwapFree": data['SwapFree'], - # "Dirty": data['Dirty'], - # "Writeback": data['Writeback'], - # "AnonPages": data['AnonPages'], - # "Mapped": data['Mapped'], - # "Shmem": data['Shmem'], - # "Slab": data['Slab'], - # "SReclaimable": data['SReclaimable'], - # "SUnreclaim": data['SUnreclaim'], - # "KernelStack": data['KernelStack'], - # "PageTables": data['PageTables'], - # "NFS_Unstable": data['NFS_Unstable'], - # "Bounce": data['Bounce'], - # "WritebackTmp": data['WritebackTmp'], - # "CommitLimit": data['CommitLimit'], - # "Committed_AS": data['Committed_AS'], - # "VmallocTotal": data['VmallocTotal'], - # "VmallocUsed": data['VmallocUsed'], - # "VmallocChunk": data['VmallocChunk'], - # "HardwareCorrupted": data['HardwareCorrupted'], - # "AnonHugePages": data['AnonHugePages'], - # # "ShmemHugePages": data['ShmemHugePages'], - # # "ShmemPmdMapped": data['ShmemPmdMapped'], - # # "CmaTotal": data['CmaTotal'], - # # "CmaFree": data['CmaFree'], - # "HugePages_Total": data['HugePages_Total'], - # "HugePages_Free": data['HugePages_Free'], - # "HugePages_Rsvd": data['HugePages_Rsvd'], - # "HugePages_Surp": data['HugePages_Surp'], - # "Hugepagesize": data['Hugepagesize'], - # "DirectMap4k": data['DirectMap4k'], - # "DirectMap2M": data['DirectMap2M'], - # "DirectMap1G": data['DirectMap1G'] - # } - # } - # ] - # - # influxDbClient.write_points(json_body) + # print(res) + + + + json_body = [ + { + "measurement": "GetProcLoadavg", + "tags": { + # the address of lepd + "server": lepdClient.server + }, + # "time": "2017-03-12T22:00:00Z", + "fields": { + "loadavg": res["result"] + + } + } + ] + + influxDbClient.write_points(json_body) if (__name__ == '__main__'): lepdClient = LepdClient('localhost') influxDbClient = MyInfluxDbClient('localhost') - for i in range(5): + for i in range(1): pullAndStoreGetProcLoadavg(lepdClient, influxDbClient) time.sleep(1) diff --git a/dataStore/modules/pullAndStoreGetProcModules.py b/dataStore/modules/pullAndStoreGetProcModules.py index bed5a94..204d54a 100755 --- a/dataStore/modules/pullAndStoreGetProcModules.py +++ b/dataStore/modules/pullAndStoreGetProcModules.py @@ -12,24 +12,26 @@ ''' def pullAndStoreGetProcModules(lepdClient, influxDbClient): res = lepdClient.sendRequest('GetProcModules') - print(res) - # json_body = [ - # { - # "measurement": "GetProcSwaps", - # "tags": { - # # the address of lepd - # "server": lepdClient.server - # }, - # # "time": "2017-03-12T22:00:00Z", - # "fields": { - # "LinuxVersion": mystr, - # "compact_stall": int(data['compact_stall']), - # "balloon_migrate": int(data['balloon_migrate']), - # } - # } - # ] - # - # influxDbClient.write_points(json_body) + # print(res) + # str1 = res["result"].split("\n") + # for x in str1: + # print(x) + json_body = [ + { + "measurement": "GetProcModules", + "tags": { + # the address of lepd + "server": lepdClient.server + }, + # "time": "2017-03-12T22:00:00Z", + "fields": { + "modules": res["result"] + + } + } + ] + + influxDbClient.write_points(json_body) From 6fac70143e75734eafa5692c579083521dc98822 Mon Sep 17 00:00:00 2001 From: lixusheng <1530830954@qq.com> Date: Tue, 22 May 2018 12:30:36 +0800 Subject: [PATCH 23/25] =?UTF-8?q?=E5=AE=8C=E6=88=90=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E5=AD=98=E5=82=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dataStore/modules/pullAndStoreGetCmdTop.py | 36 +++++++++---------- dataStore/modules/pullAndStoreGetProcStat.py | 37 ++++++++++---------- 2 files changed, 37 insertions(+), 36 deletions(-) diff --git a/dataStore/modules/pullAndStoreGetCmdTop.py b/dataStore/modules/pullAndStoreGetCmdTop.py index d08107a..96d66d4 100755 --- a/dataStore/modules/pullAndStoreGetCmdTop.py +++ b/dataStore/modules/pullAndStoreGetCmdTop.py @@ -12,25 +12,25 @@ ''' def pullAndStoreGetCmdTop(lepdClient, influxDbClient): res = lepdClient.sendRequest('GetCmdTop') - print(res) + # print(res) + # str1 = res["result"].split("\n") + # for x in str1: + # print(x) + json_body = [ + { + "measurement": "GetCmdTop", + "tags": { + # the address of lepd + "server": lepdClient.server + }, + # "time": "2017-03-12T22:00:00Z", + "fields": { + "top": res["result"] + } + } + ] - # json_body = [ - # { - # "measurement": "GetProcSwaps", - # "tags": { - # # the address of lepd - # "server": lepdClient.server - # }, - # # "time": "2017-03-12T22:00:00Z", - # "fields": { - # "LinuxVersion": mystr, - # "compact_stall": int(data['compact_stall']), - # "balloon_migrate": int(data['balloon_migrate']), - # } - # } - # ] - # - # influxDbClient.write_points(json_body) + influxDbClient.write_points(json_body) if (__name__ == '__main__'): diff --git a/dataStore/modules/pullAndStoreGetProcStat.py b/dataStore/modules/pullAndStoreGetProcStat.py index 9ed96ee..f0e5b54 100755 --- a/dataStore/modules/pullAndStoreGetProcStat.py +++ b/dataStore/modules/pullAndStoreGetProcStat.py @@ -12,25 +12,26 @@ ''' def pullAndStoreGetProcStat(lepdClient, influxDbClient): res = lepdClient.sendRequest('GetProcStat') - print(res) + # print(res) + # str1 = res["result"].split("\n") + # for x in str1: + # print(x) + json_body = [ + { + "measurement": "GetProcStat", + "tags": { + # the address of lepd + "server": lepdClient.server + }, + # "time": "2017-03-12T22:00:00Z", + "fields": { + "procstat": res["result"] - # json_body = [ - # { - # "measurement": "GetProcStat", - # "tags": { - # # the address of lepd - # "server": lepdClient.server - # }, - # # "time": "2017-03-12T22:00:00Z", - # "fields": { - # "LinuxVersion": mystr, - # "compact_stall": int(data['compact_stall']), - # "balloon_migrate": int(data['balloon_migrate']), - # } - # } - # ] - # - # influxDbClient.write_points(json_body) + } + } + ] + + influxDbClient.write_points(json_body) if (__name__ == '__main__'): lepdClient = LepdClient('localhost') From 6ba206eba6641773a346a4b279228aa409249354 Mon Sep 17 00:00:00 2001 From: lixusheng <1530830954@qq.com> Date: Tue, 22 May 2018 12:43:18 +0800 Subject: [PATCH 24/25] =?UTF-8?q?=E5=AE=8C=E6=88=90=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E5=AD=98=E5=82=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/pullAndStoreGetProcInterrupts.py | 38 +++++++++---------- .../modules/pullAndStoreGetProcSlabinfo.py | 38 ++++++++++--------- .../modules/pullAndStoreGetProcSoftirqs.py | 37 +++++++++--------- 3 files changed, 58 insertions(+), 55 deletions(-) diff --git a/dataStore/modules/pullAndStoreGetProcInterrupts.py b/dataStore/modules/pullAndStoreGetProcInterrupts.py index f41c813..b26328a 100755 --- a/dataStore/modules/pullAndStoreGetProcInterrupts.py +++ b/dataStore/modules/pullAndStoreGetProcInterrupts.py @@ -12,26 +12,26 @@ ''' def pullAndStoreGetProcInterrupts(lepdClient, influxDbClient): res = lepdClient.sendRequest('GetProcInterrupts') - print(res) - - - # json_body = [ - # { - # "measurement": "GetProcSwaps", - # "tags": { - # # the address of lepd - # "server": lepdClient.server - # }, - # # "time": "2017-03-12T22:00:00Z", - # "fields": { - # "LinuxVersion": mystr, - # "compact_stall": int(data['compact_stall']), - # "balloon_migrate": int(data['balloon_migrate']), - # } - # } - # ] + # print(res) # - # influxDbClient.write_points(json_body) + # str1 = res["result"].split("\n") + # for x in str1: + # print(x) + json_body = [ + { + "measurement": "GetProcInterrupts", + "tags": { + # the address of lepd + "server": lepdClient.server + }, + # "time": "2017-03-12T22:00:00Z", + "fields": { + "interrupts": res["result"] + } + } + ] + + influxDbClient.write_points(json_body) if (__name__ == '__main__'): lepdClient = LepdClient('localhost') diff --git a/dataStore/modules/pullAndStoreGetProcSlabinfo.py b/dataStore/modules/pullAndStoreGetProcSlabinfo.py index 14ef2ab..0ac8adb 100755 --- a/dataStore/modules/pullAndStoreGetProcSlabinfo.py +++ b/dataStore/modules/pullAndStoreGetProcSlabinfo.py @@ -12,24 +12,26 @@ ''' def pullAndStoreGetProcSlabinfo(lepdClient, influxDbClient): res = lepdClient.sendRequest('GetProcSlabinfo') - print(res) - # json_body = [ - # { - # "measurement": "GetProcSwaps", - # "tags": { - # # the address of lepd - # "server": lepdClient.server - # }, - # # "time": "2017-03-12T22:00:00Z", - # "fields": { - # "LinuxVersion": mystr, - # "compact_stall": int(data['compact_stall']), - # "balloon_migrate": int(data['balloon_migrate']), - # } - # } - # ] - # - # influxDbClient.write_points(json_body) + # print(res) + # str1 = res["result"].split("\n") + # for x in str1: + # print(x) + json_body = [ + { + "measurement": "GetProcSlabinfo", + "tags": { + # the address of lepd + "server": lepdClient.server + }, + # "time": "2017-03-12T22:00:00Z", + "fields": { + "slabinfo": res["result"] + + } + } + ] + + influxDbClient.write_points(json_body) diff --git a/dataStore/modules/pullAndStoreGetProcSoftirqs.py b/dataStore/modules/pullAndStoreGetProcSoftirqs.py index 3800dd5..54475fc 100755 --- a/dataStore/modules/pullAndStoreGetProcSoftirqs.py +++ b/dataStore/modules/pullAndStoreGetProcSoftirqs.py @@ -12,24 +12,25 @@ ''' def pullAndStoreGetProcSoftirqs(lepdClient, influxDbClient): res = lepdClient.sendRequest('GetProcSoftirqs') - print(res) - # json_body = [ - # { - # "measurement": "GetProcSwaps", - # "tags": { - # # the address of lepd - # "server": lepdClient.server - # }, - # # "time": "2017-03-12T22:00:00Z", - # "fields": { - # "LinuxVersion": mystr, - # "compact_stall": int(data['compact_stall']), - # "balloon_migrate": int(data['balloon_migrate']), - # } - # } - # ] - # - # influxDbClient.write_points(json_body) + # print(res) + # str1 = res["result"].split("\n") + # for x in str1: + # print(x) + json_body = [ + { + "measurement": "GetProcSoftirqs", + "tags": { + # the address of lepd + "server": lepdClient.server + }, + # "time": "2017-03-12T22:00:00Z", + "fields": { + "softirqs": res["result"] + } + } + ] + + influxDbClient.write_points(json_body) if (__name__ == '__main__'): From d6f8bef130491c9e745434d49b10645f7586fb86 Mon Sep 17 00:00:00 2001 From: lixusheng <1530830954@qq.com> Date: Tue, 22 May 2018 13:25:32 +0800 Subject: [PATCH 25/25] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E7=BB=93=E6=9E=84=EF=BC=8C=E5=85=A8=E9=83=A8=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dataStore/modules/others/__init__.py | 0 .../{ => others}/pullAndStoreGetCmdDf.py | 0 .../{ => others}/pullAndStoreGetCmdDmesg.py | 0 .../{ => others}/pullAndStoreGetCmdFree.py | 0 .../{io => others}/pullAndStoreGetCmdIotop.py | 0 .../{ => others}/pullAndStoreGetCmdIrqInfo.py | 0 .../pullAndStoreGetCmdMpstat-I.py | 0 .../pullAndStoreGetCmdProcrank.py | 0 .../{ => others}/pullAndStoreGetCpuInfo.py | 0 .../pullAndStoreGetProcBuddyinfo.py | 0 .../pullAndStoreGetProcCpuinfo.py | 0 .../{ => others}/pullAndStoreGetProcSwaps.py | 0 .../{ => others}/pullAndStoreGetProcVmstat.py | 0 .../pullAndStoreGetProcZoneinfo.py | 0 dataStore/modules/perf/__init__.py | 0 .../pullAndStoreGetCmdPerfCpuclock.py | 0 .../pullAndStoreGetCmdPerfFaults.py | 0 .../{ => perf}/pullAndStoreGetCmdPerfFlame.py | 0 dataStore/modules/pullAndStoreGetCmdIostat.py | 41 ------------- dataStore/modules/pullAndStoreGetCmdMpstat.py | 41 ------------- dataStore/modules/raw/__init__.py | 0 .../{ => raw}/pullAndStoreGetCmdTop.py | 0 .../{ => raw}/pullAndStoreGetProcDiskstats.py | 0 .../pullAndStoreGetProcInterrupts.py | 0 .../{ => raw}/pullAndStoreGetProcLoadavg.py | 0 .../{ => raw}/pullAndStoreGetProcModules.py | 0 .../{ => raw}/pullAndStoreGetProcSlabinfo.py | 0 .../{ => raw}/pullAndStoreGetProcSoftirqs.py | 0 .../{ => raw}/pullAndStoreGetProcStat.py | 0 .../{ => raw}/pullAndStoreGetProcVersion.py | 4 +- dataStore/modules/run.py | 2 - dataStore/myGUI/__init__.py | 0 dataStore/myGUI/mywindows | 59 +++++++++++++++++++ dataStore/query/memory/queryGetProcMeminfo.py | 6 +- dataStore/runall.py | 35 +++++++++++ 35 files changed, 99 insertions(+), 89 deletions(-) create mode 100644 dataStore/modules/others/__init__.py rename dataStore/modules/{ => others}/pullAndStoreGetCmdDf.py (100%) rename dataStore/modules/{ => others}/pullAndStoreGetCmdDmesg.py (100%) rename dataStore/modules/{ => others}/pullAndStoreGetCmdFree.py (100%) rename dataStore/modules/{io => others}/pullAndStoreGetCmdIotop.py (100%) rename dataStore/modules/{ => others}/pullAndStoreGetCmdIrqInfo.py (100%) rename dataStore/modules/{ => others}/pullAndStoreGetCmdMpstat-I.py (100%) rename dataStore/modules/{ => others}/pullAndStoreGetCmdProcrank.py (100%) rename dataStore/modules/{ => others}/pullAndStoreGetCpuInfo.py (100%) rename dataStore/modules/{ => others}/pullAndStoreGetProcBuddyinfo.py (100%) rename dataStore/modules/{ => others}/pullAndStoreGetProcCpuinfo.py (100%) rename dataStore/modules/{ => others}/pullAndStoreGetProcSwaps.py (100%) rename dataStore/modules/{ => others}/pullAndStoreGetProcVmstat.py (100%) rename dataStore/modules/{ => others}/pullAndStoreGetProcZoneinfo.py (100%) create mode 100644 dataStore/modules/perf/__init__.py rename dataStore/modules/{ => perf}/pullAndStoreGetCmdPerfCpuclock.py (100%) rename dataStore/modules/{ => perf}/pullAndStoreGetCmdPerfFaults.py (100%) rename dataStore/modules/{ => perf}/pullAndStoreGetCmdPerfFlame.py (100%) delete mode 100755 dataStore/modules/pullAndStoreGetCmdIostat.py delete mode 100755 dataStore/modules/pullAndStoreGetCmdMpstat.py create mode 100644 dataStore/modules/raw/__init__.py rename dataStore/modules/{ => raw}/pullAndStoreGetCmdTop.py (100%) rename dataStore/modules/{ => raw}/pullAndStoreGetProcDiskstats.py (100%) rename dataStore/modules/{ => raw}/pullAndStoreGetProcInterrupts.py (100%) rename dataStore/modules/{ => raw}/pullAndStoreGetProcLoadavg.py (100%) rename dataStore/modules/{ => raw}/pullAndStoreGetProcModules.py (100%) rename dataStore/modules/{ => raw}/pullAndStoreGetProcSlabinfo.py (100%) rename dataStore/modules/{ => raw}/pullAndStoreGetProcSoftirqs.py (100%) rename dataStore/modules/{ => raw}/pullAndStoreGetProcStat.py (100%) rename dataStore/modules/{ => raw}/pullAndStoreGetProcVersion.py (94%) create mode 100644 dataStore/myGUI/__init__.py create mode 100644 dataStore/myGUI/mywindows create mode 100644 dataStore/runall.py diff --git a/dataStore/modules/others/__init__.py b/dataStore/modules/others/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/dataStore/modules/pullAndStoreGetCmdDf.py b/dataStore/modules/others/pullAndStoreGetCmdDf.py similarity index 100% rename from dataStore/modules/pullAndStoreGetCmdDf.py rename to dataStore/modules/others/pullAndStoreGetCmdDf.py diff --git a/dataStore/modules/pullAndStoreGetCmdDmesg.py b/dataStore/modules/others/pullAndStoreGetCmdDmesg.py similarity index 100% rename from dataStore/modules/pullAndStoreGetCmdDmesg.py rename to dataStore/modules/others/pullAndStoreGetCmdDmesg.py diff --git a/dataStore/modules/pullAndStoreGetCmdFree.py b/dataStore/modules/others/pullAndStoreGetCmdFree.py similarity index 100% rename from dataStore/modules/pullAndStoreGetCmdFree.py rename to dataStore/modules/others/pullAndStoreGetCmdFree.py diff --git a/dataStore/modules/io/pullAndStoreGetCmdIotop.py b/dataStore/modules/others/pullAndStoreGetCmdIotop.py similarity index 100% rename from dataStore/modules/io/pullAndStoreGetCmdIotop.py rename to dataStore/modules/others/pullAndStoreGetCmdIotop.py diff --git a/dataStore/modules/pullAndStoreGetCmdIrqInfo.py b/dataStore/modules/others/pullAndStoreGetCmdIrqInfo.py similarity index 100% rename from dataStore/modules/pullAndStoreGetCmdIrqInfo.py rename to dataStore/modules/others/pullAndStoreGetCmdIrqInfo.py diff --git a/dataStore/modules/pullAndStoreGetCmdMpstat-I.py b/dataStore/modules/others/pullAndStoreGetCmdMpstat-I.py similarity index 100% rename from dataStore/modules/pullAndStoreGetCmdMpstat-I.py rename to dataStore/modules/others/pullAndStoreGetCmdMpstat-I.py diff --git a/dataStore/modules/pullAndStoreGetCmdProcrank.py b/dataStore/modules/others/pullAndStoreGetCmdProcrank.py similarity index 100% rename from dataStore/modules/pullAndStoreGetCmdProcrank.py rename to dataStore/modules/others/pullAndStoreGetCmdProcrank.py diff --git a/dataStore/modules/pullAndStoreGetCpuInfo.py b/dataStore/modules/others/pullAndStoreGetCpuInfo.py similarity index 100% rename from dataStore/modules/pullAndStoreGetCpuInfo.py rename to dataStore/modules/others/pullAndStoreGetCpuInfo.py diff --git a/dataStore/modules/pullAndStoreGetProcBuddyinfo.py b/dataStore/modules/others/pullAndStoreGetProcBuddyinfo.py similarity index 100% rename from dataStore/modules/pullAndStoreGetProcBuddyinfo.py rename to dataStore/modules/others/pullAndStoreGetProcBuddyinfo.py diff --git a/dataStore/modules/pullAndStoreGetProcCpuinfo.py b/dataStore/modules/others/pullAndStoreGetProcCpuinfo.py similarity index 100% rename from dataStore/modules/pullAndStoreGetProcCpuinfo.py rename to dataStore/modules/others/pullAndStoreGetProcCpuinfo.py diff --git a/dataStore/modules/pullAndStoreGetProcSwaps.py b/dataStore/modules/others/pullAndStoreGetProcSwaps.py similarity index 100% rename from dataStore/modules/pullAndStoreGetProcSwaps.py rename to dataStore/modules/others/pullAndStoreGetProcSwaps.py diff --git a/dataStore/modules/pullAndStoreGetProcVmstat.py b/dataStore/modules/others/pullAndStoreGetProcVmstat.py similarity index 100% rename from dataStore/modules/pullAndStoreGetProcVmstat.py rename to dataStore/modules/others/pullAndStoreGetProcVmstat.py diff --git a/dataStore/modules/pullAndStoreGetProcZoneinfo.py b/dataStore/modules/others/pullAndStoreGetProcZoneinfo.py similarity index 100% rename from dataStore/modules/pullAndStoreGetProcZoneinfo.py rename to dataStore/modules/others/pullAndStoreGetProcZoneinfo.py diff --git a/dataStore/modules/perf/__init__.py b/dataStore/modules/perf/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/dataStore/modules/pullAndStoreGetCmdPerfCpuclock.py b/dataStore/modules/perf/pullAndStoreGetCmdPerfCpuclock.py similarity index 100% rename from dataStore/modules/pullAndStoreGetCmdPerfCpuclock.py rename to dataStore/modules/perf/pullAndStoreGetCmdPerfCpuclock.py diff --git a/dataStore/modules/pullAndStoreGetCmdPerfFaults.py b/dataStore/modules/perf/pullAndStoreGetCmdPerfFaults.py similarity index 100% rename from dataStore/modules/pullAndStoreGetCmdPerfFaults.py rename to dataStore/modules/perf/pullAndStoreGetCmdPerfFaults.py diff --git a/dataStore/modules/pullAndStoreGetCmdPerfFlame.py b/dataStore/modules/perf/pullAndStoreGetCmdPerfFlame.py similarity index 100% rename from dataStore/modules/pullAndStoreGetCmdPerfFlame.py rename to dataStore/modules/perf/pullAndStoreGetCmdPerfFlame.py diff --git a/dataStore/modules/pullAndStoreGetCmdIostat.py b/dataStore/modules/pullAndStoreGetCmdIostat.py deleted file mode 100755 index 9e3efd4..0000000 --- a/dataStore/modules/pullAndStoreGetCmdIostat.py +++ /dev/null @@ -1,41 +0,0 @@ -__author__ = "" -__copyright__ = "Licensed under GPLv2 or later." - -from dataStore.lepdClient.LepdClient import LepdClient -from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient - -import time - -''' -fetch data related to GetCmdIostat from lepd by lepdClient and -store the returned data into the influxDB by influxDBClient. -''' -def pullAndStoreGetCmdIostat(lepdClient, influxDbClient): - res = lepdClient.sendRequest('GetCmdIostat') - print(res) - - # json_body = [ - # { - # "measurement": "GetProcSwaps", - # "tags": { - # # the address of lepd - # "server": lepdClient.server - # }, - # # "time": "2017-03-12T22:00:00Z", - # "fields": { - # "LinuxVersion": mystr, - # "compact_stall": int(data['compact_stall']), - # "balloon_migrate": int(data['balloon_migrate']), - # } - # } - # ] - # - # influxDbClient.write_points(json_body) - - -if (__name__ == '__main__'): - lepdClient = LepdClient('localhost') - influxDbClient = MyInfluxDbClient('localhost') - for i in range(1): - pullAndStoreGetCmdIostat(lepdClient, influxDbClient) - time.sleep(1) diff --git a/dataStore/modules/pullAndStoreGetCmdMpstat.py b/dataStore/modules/pullAndStoreGetCmdMpstat.py deleted file mode 100755 index 5cb7479..0000000 --- a/dataStore/modules/pullAndStoreGetCmdMpstat.py +++ /dev/null @@ -1,41 +0,0 @@ -__author__ = "" -__copyright__ = "Licensed under GPLv2 or later." - -from dataStore.lepdClient.LepdClient import LepdClient -from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient - -import time - -''' -fetch data related to GetCmdMpstat from lepd by lepdClient and -store the returned data into the influxDB by influxDBClient. -''' -def pullAndStoreGetCmdMpstat(lepdClient, influxDbClient): - res = lepdClient.sendRequest('GetCmdMpstat') - print(res) - # json_body = [ - # { - # "measurement": "GetProcSwaps", - # "tags": { - # # the address of lepd - # "server": lepdClient.server - # }, - # # "time": "2017-03-12T22:00:00Z", - # "fields": { - # "LinuxVersion": mystr, - # "compact_stall": int(data['compact_stall']), - # "balloon_migrate": int(data['balloon_migrate']), - # } - # } - # ] - # - # influxDbClient.write_points(json_body) - - - -if (__name__ == '__main__'): - lepdClient = LepdClient('localhost') - influxDbClient = MyInfluxDbClient('localhost') - for i in range(1): - pullAndStoreGetCmdMpstat(lepdClient, influxDbClient) - time.sleep(1) diff --git a/dataStore/modules/raw/__init__.py b/dataStore/modules/raw/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/dataStore/modules/pullAndStoreGetCmdTop.py b/dataStore/modules/raw/pullAndStoreGetCmdTop.py similarity index 100% rename from dataStore/modules/pullAndStoreGetCmdTop.py rename to dataStore/modules/raw/pullAndStoreGetCmdTop.py diff --git a/dataStore/modules/pullAndStoreGetProcDiskstats.py b/dataStore/modules/raw/pullAndStoreGetProcDiskstats.py similarity index 100% rename from dataStore/modules/pullAndStoreGetProcDiskstats.py rename to dataStore/modules/raw/pullAndStoreGetProcDiskstats.py diff --git a/dataStore/modules/pullAndStoreGetProcInterrupts.py b/dataStore/modules/raw/pullAndStoreGetProcInterrupts.py similarity index 100% rename from dataStore/modules/pullAndStoreGetProcInterrupts.py rename to dataStore/modules/raw/pullAndStoreGetProcInterrupts.py diff --git a/dataStore/modules/pullAndStoreGetProcLoadavg.py b/dataStore/modules/raw/pullAndStoreGetProcLoadavg.py similarity index 100% rename from dataStore/modules/pullAndStoreGetProcLoadavg.py rename to dataStore/modules/raw/pullAndStoreGetProcLoadavg.py diff --git a/dataStore/modules/pullAndStoreGetProcModules.py b/dataStore/modules/raw/pullAndStoreGetProcModules.py similarity index 100% rename from dataStore/modules/pullAndStoreGetProcModules.py rename to dataStore/modules/raw/pullAndStoreGetProcModules.py diff --git a/dataStore/modules/pullAndStoreGetProcSlabinfo.py b/dataStore/modules/raw/pullAndStoreGetProcSlabinfo.py similarity index 100% rename from dataStore/modules/pullAndStoreGetProcSlabinfo.py rename to dataStore/modules/raw/pullAndStoreGetProcSlabinfo.py diff --git a/dataStore/modules/pullAndStoreGetProcSoftirqs.py b/dataStore/modules/raw/pullAndStoreGetProcSoftirqs.py similarity index 100% rename from dataStore/modules/pullAndStoreGetProcSoftirqs.py rename to dataStore/modules/raw/pullAndStoreGetProcSoftirqs.py diff --git a/dataStore/modules/pullAndStoreGetProcStat.py b/dataStore/modules/raw/pullAndStoreGetProcStat.py similarity index 100% rename from dataStore/modules/pullAndStoreGetProcStat.py rename to dataStore/modules/raw/pullAndStoreGetProcStat.py diff --git a/dataStore/modules/pullAndStoreGetProcVersion.py b/dataStore/modules/raw/pullAndStoreGetProcVersion.py similarity index 94% rename from dataStore/modules/pullAndStoreGetProcVersion.py rename to dataStore/modules/raw/pullAndStoreGetProcVersion.py index 00ea6e8..1c200f4 100755 --- a/dataStore/modules/pullAndStoreGetProcVersion.py +++ b/dataStore/modules/raw/pullAndStoreGetProcVersion.py @@ -12,7 +12,7 @@ ''' def pullAndStoreGetProcVersion(lepdClient, influxDbClient): res = lepdClient.sendRequest('GetProcVersion') - mystr = res['result'] + json_body = [ { @@ -23,7 +23,7 @@ def pullAndStoreGetProcVersion(lepdClient, influxDbClient): }, # "time": "2017-03-12T22:00:00Z", "fields": { - "LinuxVersion": mystr + "LinuxVersion": res['result'] } } ] diff --git a/dataStore/modules/run.py b/dataStore/modules/run.py index a50c9be..69f8259 100644 --- a/dataStore/modules/run.py +++ b/dataStore/modules/run.py @@ -3,7 +3,6 @@ from dataStore.lepdClient.LepdClient import LepdClient from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient -from dataStore.modules.io.pullAndStoreGetCmdIotop import pullAndStoreGetCmdIotop from dataStore.modules.cpu.pullAndStoreGetCmdMpstat import pullAndStoreGetCmdMpstat from dataStore.modules.memory.pullAndStoreGetProcMeminfo import pullAndStoreGetProcMeminfo from dataStore.modules.io.pullAndStoreGetCmdIostat import pullAndStoreGetCmdIostat @@ -15,7 +14,6 @@ lepdClient = LepdClient('localhost') influxDbClient = MyInfluxDbClient('localhost') for i in range(120): - pullAndStoreGetCmdIotop(lepdClient, influxDbClient) pullAndStoreGetCmdIostat(lepdClient,influxDbClient) pullAndStoreGetProcMeminfo(lepdClient,influxDbClient) pullAndStoreGetCmdMpstat(lepdClient,influxDbClient) diff --git a/dataStore/myGUI/__init__.py b/dataStore/myGUI/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/dataStore/myGUI/mywindows b/dataStore/myGUI/mywindows new file mode 100644 index 0000000..0e3a10c --- /dev/null +++ b/dataStore/myGUI/mywindows @@ -0,0 +1,59 @@ +from tkinter import * +import tkinter.messagebox as messagebox + +class config(Frame): + def __init__(self,master=None): + Frame.__init__(self, master) + self.pack() + self.createWidgets() + def createWidgets(self): + self.ipLabel = Label(self, text="ipAddress:") + self.ipLabel.pack() + self.ipInput = Entry(self) + self.ipInput.pack() + self.portLabel = Label(self,text="port:") + self.portLabel.pack() + self.portInput= Entry(self) + self.portInput.pack() + + + +class Application(Frame): + def __init__(self, master=None): + self.username="admin" + self.password="admin" + Frame.__init__(self, master) + self.pack() + self.createWidgets() + + + + def createWidgets(self): + self.name = Label(self,text='username') + self.name.pack() + self.nameInput = Entry(self) + self.nameInput.pack() + self.passwd = Label(self, text='password') + self.passwd.pack() + self.passwdInput = Entry(self) + self.passwdInput.pack() + + self.alertButton = Button(self, text='login', command=self.hello) + self.alertButton.pack() + + def hello(self): + + name = self.nameInput.get() + passwd = self.passwdInput.get() + if(name==self.username and passwd==self.password): + app1 = config() + app1.master.title('config') + app1.mainloop() + else: + messagebox.showerror("error","login error") + +app = Application() +# 设置窗口标题: +app.master.title('store') +# 主消息循环: +app.mainloop() \ No newline at end of file diff --git a/dataStore/query/memory/queryGetProcMeminfo.py b/dataStore/query/memory/queryGetProcMeminfo.py index 87a3686..be7dcfd 100644 --- a/dataStore/query/memory/queryGetProcMeminfo.py +++ b/dataStore/query/memory/queryGetProcMeminfo.py @@ -2,7 +2,7 @@ __copyright__ = "Licensed under GPLv2 or later." -from dataStore.influxDbUtil.dbUtil import myInfluxDbClient +from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient import time @@ -13,11 +13,11 @@ def queryGetProcMeminfo(influxDbClient): res = influxDbClient.query('select * from GetProcMeminfo limit 1') print(res) - help(res) + # help(res) return None if(__name__=='__main__'): - influxDbClient = myInfluxDbClient('127.0.0.1') + influxDbClient = MyInfluxDbClient('127.0.0.1') queryGetProcMeminfo(influxDbClient) diff --git a/dataStore/runall.py b/dataStore/runall.py new file mode 100644 index 0000000..db372d5 --- /dev/null +++ b/dataStore/runall.py @@ -0,0 +1,35 @@ +__author__ = "" +__copyright__ = "Licensed under GPLv2 or later." + +from dataStore.lepdClient.LepdClient import LepdClient +from dataStore.influxDbUtil.dbUtil import MyInfluxDbClient + +from dataStore.modules.cpu.pullAndStoreGetCmdMpstat import pullAndStoreGetCmdMpstat +from dataStore.modules.io.pullAndStoreGetCmdIostat import pullAndStoreGetCmdIostat +from dataStore.modules.memory.pullAndStoreGetProcMeminfo import pullAndStoreGetProcMeminfo + + + +from dataStore.modules.others.pullAndStoreGetCmdDf import pullAndStoreGetCmdDf +from dataStore.modules.others.pullAndStoreGetCmdDmesg import pullAndStoreGetCmdDmesg +from dataStore.modules.others.pullAndStoreGetCmdFree import pullAndStoreGetCmdFree +from dataStore.modules.others.pullAndStoreGetCmdIotop import pullAndStoreGetCmdIotop +from dataStore.modules.others.pullAndStoreGetCmdIrqInfo import pullAndStoreGetCmdIrqInfo + + + + +import time + + +if (__name__ == '__main__'): + lepdClient = LepdClient('localhost') + influxDbClient = MyInfluxDbClient('localhost') + for i in range(1): + + pullAndStoreGetCmdIostat(lepdClient,influxDbClient) + pullAndStoreGetProcMeminfo(lepdClient,influxDbClient) + pullAndStoreGetCmdMpstat(lepdClient,influxDbClient) + + + time.sleep(1)