pytbox 0.2.0__py3-none-any.whl → 0.2.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pytbox might be problematic. Click here for more details.
- pytbox/database/victoriametrics.py +32 -1
- pytbox/log/logger.py +7 -6
- {pytbox-0.2.0.dist-info → pytbox-0.2.2.dist-info}/METADATA +1 -1
- {pytbox-0.2.0.dist-info → pytbox-0.2.2.dist-info}/RECORD +7 -7
- {pytbox-0.2.0.dist-info → pytbox-0.2.2.dist-info}/WHEEL +0 -0
- {pytbox-0.2.0.dist-info → pytbox-0.2.2.dist-info}/entry_points.txt +0 -0
- {pytbox-0.2.0.dist-info → pytbox-0.2.2.dist-info}/top_level.txt +0 -0
|
@@ -260,7 +260,38 @@ class VictoriaMetrics:
|
|
|
260
260
|
return ReturnResponse(code=0, msg=f"查询 {sysname} {ifname} 最近 {last_hours} 小时平均速率为 {round(float(rate), 2)} Mbit/s", data=round(float(rate), 2))
|
|
261
261
|
except KeyError:
|
|
262
262
|
return ReturnResponse(code=1, msg=f"查询 {sysname} {ifname} 最近 {last_hours} 小时平均速率为 0 Mbit/s")
|
|
263
|
-
|
|
263
|
+
|
|
264
|
+
def check_interface_max_rate(self,
|
|
265
|
+
direction: Literal['in', 'out'],
|
|
266
|
+
sysname: str,
|
|
267
|
+
ifname:str,
|
|
268
|
+
last_hours: Optional[int] = 24,
|
|
269
|
+
last_minutes: Optional[int] = 5,
|
|
270
|
+
) -> ReturnResponse:
|
|
271
|
+
'''
|
|
272
|
+
_summary_
|
|
273
|
+
|
|
274
|
+
Args:
|
|
275
|
+
direction (Literal['in', 'out']): _description_
|
|
276
|
+
sysname (str): _description_
|
|
277
|
+
ifname (str): _description_
|
|
278
|
+
last_hours (Optional[int], optional): _description_. Defaults to 24.
|
|
279
|
+
last_minutes (Optional[int], optional): _description_. Defaults to 5.
|
|
280
|
+
|
|
281
|
+
Returns:
|
|
282
|
+
ReturnResponse: _description_
|
|
283
|
+
'''
|
|
284
|
+
if direction == 'in':
|
|
285
|
+
query = f'max_over_time(rate(snmp_interface_ifHCInOctets{{sysName="{sysname}", ifName="{ifname}"}}[{last_minutes}m]) * 8 [{last_hours}h:]) / 1e6'
|
|
286
|
+
else:
|
|
287
|
+
query = f'max_over_time(rate(snmp_interface_ifHCOutOctets{{sysName="{sysname}", ifName="{ifname}"}}[{last_minutes}m]) * 8 [{last_hours}h:]) / 1e6'
|
|
288
|
+
r = self.query(query)
|
|
289
|
+
try:
|
|
290
|
+
rate = r.data[0]['value'][1]
|
|
291
|
+
return ReturnResponse(code=0, msg=f"查询 {sysname} {ifname} 最近 {last_hours} 小时最大速率为 {round(float(rate), 2)} Mbit/s", data=round(float(rate), 2))
|
|
292
|
+
except KeyError:
|
|
293
|
+
return ReturnResponse(code=1, msg=f"查询 {sysname} {ifname} 最近 {last_hours} 小时最大速率为 0 Mbit/s")
|
|
294
|
+
|
|
264
295
|
def check_snmp_port_status(self, sysname: str=None, if_name: str=None, last_minute: int=5, dev_file: str=None) -> ReturnResponse:
|
|
265
296
|
'''
|
|
266
297
|
查询端口状态
|
pytbox/log/logger.py
CHANGED
|
@@ -152,12 +152,13 @@ class AppLogger:
|
|
|
152
152
|
f"**function_name**: {caller_function}"
|
|
153
153
|
]
|
|
154
154
|
|
|
155
|
-
self.dida
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
155
|
+
if self.dida:
|
|
156
|
+
self.dida.task_create(
|
|
157
|
+
project_id="65e87d2b3e73517c2cdd9d63",
|
|
158
|
+
title=f"自动化脚本告警: {self.app_name}",
|
|
159
|
+
content="\n".join(dida_content_list),
|
|
160
|
+
tags=['L-程序告警', 't-问题处理']
|
|
161
|
+
)
|
|
161
162
|
|
|
162
163
|
def critical(self, message: str):
|
|
163
164
|
"""记录严重错误级别日志"""
|
|
@@ -43,13 +43,13 @@ pytbox/cli/formatters/__init__.py,sha256=4o85w4j-A-O1oBLvuE9q8AFiJ2C9rvB3MIKsy5V
|
|
|
43
43
|
pytbox/cli/formatters/output.py,sha256=h5WhZlQk1rjmxEj88Jy5ODLcv6L5zfGUhks_3AWIkKU,5455
|
|
44
44
|
pytbox/common/__init__.py,sha256=3JWfgCQZKZuSH5NCE7OCzKwq82pkyop9l7sH5YSNyfU,122
|
|
45
45
|
pytbox/database/mongo.py,sha256=AhJ9nCAQHKrrcL-ujeonOwEf3x2QkmT2VhoCdglqJmU,3478
|
|
46
|
-
pytbox/database/victoriametrics.py,sha256=
|
|
46
|
+
pytbox/database/victoriametrics.py,sha256=t31HuLgB9DCrXzURx3Wm_r7jGkWodiqb1afogbzh8UI,14598
|
|
47
47
|
pytbox/feishu/client.py,sha256=kwGLseGT_iQUFmSqpuS2_77WmxtHstD64nXvktuQ3B4,5865
|
|
48
48
|
pytbox/feishu/endpoints.py,sha256=z3nPOZPC2JGDJlO7SusWBpRA33hZZ4Z-GBhI6F8L_u4,40240
|
|
49
49
|
pytbox/feishu/errors.py,sha256=79qFAHZw7jDj3gnWAjI1-W4tB0q1_aSfdjee4xzXeuI,1179
|
|
50
50
|
pytbox/feishu/helpers.py,sha256=jhSkHiUw4822QBXx2Jw8AksogZdakZ-3QqvC3lB3qEI,201
|
|
51
51
|
pytbox/feishu/typing.py,sha256=3hWkJgOi-v2bt9viMxkyvNHsPgrbAa0aZOxsZYg2vdM,122
|
|
52
|
-
pytbox/log/logger.py,sha256=
|
|
52
|
+
pytbox/log/logger.py,sha256=t5LEvuYTDixh67JOyX0ke1ukb9kT5PEaUSsQnDDck90,8921
|
|
53
53
|
pytbox/log/victorialog.py,sha256=gffEiq38adv9sC5oZeMcyKghd3SGfRuqtZOFuqHQF6E,4139
|
|
54
54
|
pytbox/mail/alimail.py,sha256=njKA3PUbIaiKFaxKvUObmklmEEHg2YA-O5rpgsgT5_w,5147
|
|
55
55
|
pytbox/mail/client.py,sha256=RNgWhhTXFTpD43U4p7hbmnfRdmltuZmbm890gaZTzhI,6278
|
|
@@ -63,8 +63,8 @@ pytbox/utils/response.py,sha256=kXjlwt0WVmLRam2eu1shzX2cQ7ux4cCQryaPGYwle5g,1247
|
|
|
63
63
|
pytbox/utils/richutils.py,sha256=OT9_q2Q1bthzB0g1GlhZVvM4ZAepJRKL6a_Vsr6vEqo,487
|
|
64
64
|
pytbox/utils/timeutils.py,sha256=uSKgwt20mVcgIGKLsH2tNum8v3rcpzgmBibPvyPQFgM,20433
|
|
65
65
|
pytbox/win/ad.py,sha256=-3pWfL3dElz-XoO4j4M9lrgu3KJtlhrS9gCWJBpafAU,1147
|
|
66
|
-
pytbox-0.2.
|
|
67
|
-
pytbox-0.2.
|
|
68
|
-
pytbox-0.2.
|
|
69
|
-
pytbox-0.2.
|
|
70
|
-
pytbox-0.2.
|
|
66
|
+
pytbox-0.2.2.dist-info/METADATA,sha256=A7mmfNATT3wevAc0IulbaLb0_HwpDrDYAeL2zzrjPLI,6319
|
|
67
|
+
pytbox-0.2.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
68
|
+
pytbox-0.2.2.dist-info/entry_points.txt,sha256=YaTOJ2oPjOiv2SZwY0UC-UA9QS2phRH1oMvxGnxO0Js,43
|
|
69
|
+
pytbox-0.2.2.dist-info/top_level.txt,sha256=YADgWue-Oe128ptN3J2hS3GB0Ncc5uZaSUM3e1rwswE,7
|
|
70
|
+
pytbox-0.2.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|