pytbox 0.2.1__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.

@@ -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
  查询端口状态
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pytbox
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: A collection of Python integrations and utilities (Feishu, Dida365, VictoriaMetrics, ...)
5
5
  Author-email: mingming hou <houm01@foxmail.com>
6
6
  License-Expression: MIT
@@ -43,7 +43,7 @@ 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=othAjqn7Cmgc-cp-TK-LIX5fGLT6fkgn6RVr4b4e2Mg,13007
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
@@ -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.1.dist-info/METADATA,sha256=pkJirfIq1qpvhesBTwKN49MGnAikmQsWoPUHGvswZH0,6319
67
- pytbox-0.2.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
68
- pytbox-0.2.1.dist-info/entry_points.txt,sha256=YaTOJ2oPjOiv2SZwY0UC-UA9QS2phRH1oMvxGnxO0Js,43
69
- pytbox-0.2.1.dist-info/top_level.txt,sha256=YADgWue-Oe128ptN3J2hS3GB0Ncc5uZaSUM3e1rwswE,7
70
- pytbox-0.2.1.dist-info/RECORD,,
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