-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsqltest.py
120 lines (93 loc) · 3 KB
/
sqltest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# sqltest,this is a test file
#
from sqlitedb.sqlitedb import sqlClass
from oracledb.oradb import sqlClass
from app import get_txt_ip
import time
from datetime import datetime, timedelta
sql = sqlClass()
def select_time():
sql_l1 = "select * from progress where ip = 'test1' "
res = sql.define_self(sql_l1)
for i in res[1]:
print(i)
def more_info_pro():
sql_1 = "select * from systeminfo where ip ='test1'"
res = sql.define_self(sql_1)
for i in res[1]:
print(i[0])
def insert_test():
sql.insertInfo()
# 获取平均负载
def get_load_avg():
try:
import subprocess
tmp = subprocess.getstatusoutput('uptime')
load_avg = tmp[-1].split(',')[-2].strip()
except Exception as e:
load_avg = 0
print(load_avg)
return load_avg
def get_1():
sql_1 = "select tim from systeminfo where ip ='test1' order by tim desc limit 10"
res = sql.define_self(sql_1)
print(res)
def get_c1(ip_sub ='test1'):
# sql_c1 = "select cpuUsed,memoryUsed from SYSTEMINFO where ip = 'test1' order by tim desc limit 1 "
sql_c1 = "select * from SYSTEMINFO where ip = '" +ip_sub +"' order by tim desc limit 1 "
print(sql_c1)
res = sql.define_self(sql_c1)
print(res[1])
# for i in res[1]:
# print(i[0])
# print(i[1])
def del_pro_info():
sql_del = "delete from PROGRESS where ip ='test1'"
sql.define_del(sql_del)
def c1():
sql_r1 = "select * from (select realTimeRcvd,realTimeSent,tim from SYSTEMINFO where ip = '192.168.103.163' order by tim desc) where rownum <37"
res = sql.define_self(sql_r1)
for i in res[1]:
print(i[0])
print(i[1])
print(i[2])
# realTimeRcvd.append(i[0])
# realTimeSent.append(i[1])
# time.append(i[2])
def select_te():
# ip = 192.168.103.163''
# sql2 = "select * from progress where ip ='192.168.103.163'"
sql1 = 'select * from (select cpuused,tim from systeminfo order by tim desc) where rownum <5'
# print(sql1)
res= sql.define_self(sql1)
content = res[1]
for i in res[1]:
print(i[1])
tim = timeStamp(i[1])
print(tim)
def gettime():
# dtim = 44152.0146412037
# dtim = 1637734322.6554823
# print(type(dtim))
# DateObj = datetime(year=1900, month=1, day=1)
# DateObj += timedelta(days=dtim) # 转换datetime格式,这里的datetime就是float,值为上面注释的
# dateTime = DateObj.strftime("%H:%M:%S")
# print(dateTime)
#1637734322.6554823
tim = time.strftime('%H:%M:%S',time.localtime(time.time()))
print(tim)
# 输入毫秒级的时间,转出正常格式的时间
def timeStamp(timeNum):
timeStamp = float(timeNum / 1000)
timeArray = time.localtime(timeStamp)
otherStyleTime = time.strftime("%H:%M:%S", timeArray)
return otherStyleTime
if __name__ == '__main__':
# select_time()
# more_info_pro()
# get_load_avg()
# get_c1()
# del_pro_info()
c1()
# select_te()
# timeStamp(1637734322.6554823)