mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-01 23:47:40 +00:00
stash (#5178)
* Dev (#4791) * fix(xpack): 修复last login太长的问题 (#4786) Co-authored-by: ibuler <ibuler@qq.com> * perf: 更新密码中也发送邮件 (#4789) Co-authored-by: ibuler <ibuler@qq.com> * fix(terminal): 修复获取螺旋的异步api * fix(terminal): 修复有的录像存储有问题的导致下载录像的bug * fix(orgs): 修复组织添加用户bug * perf(requirements): 修改jms-storage==0.0.34 (#4797) Co-authored-by: Bai <bugatti_it@163.com> Co-authored-by: fit2bot <68588906+fit2bot@users.noreply.github.com> Co-authored-by: ibuler <ibuler@qq.com> Co-authored-by: Bai <bugatti_it@163.com> * stash * feat(system): 添加系统app * stash * fix: 修复一些bug Co-authored-by: xinwen <coderWen@126.com> Co-authored-by: ibuler <ibuler@qq.com> Co-authored-by: Bai <bugatti_it@163.com> Co-authored-by: Jiangjie.Bai <32935519+BaiJiangJie@users.noreply.github.com>
This commit is contained in:
69
utils/generate_fake_data/resources/system.py
Normal file
69
utils/generate_fake_data/resources/system.py
Normal file
@@ -0,0 +1,69 @@
|
||||
import random
|
||||
|
||||
from .base import FakeDataGenerator
|
||||
from system.models import *
|
||||
|
||||
|
||||
class StatGenerator(FakeDataGenerator):
|
||||
resource = 'stat'
|
||||
|
||||
nodes = [
|
||||
{
|
||||
'node': 'guacamole-01',
|
||||
'ip': '192.168.1.1',
|
||||
'component': 'guacamole'
|
||||
},
|
||||
{
|
||||
'node': 'koko-01',
|
||||
'ip': '192.168.1.2',
|
||||
'component': 'koko'
|
||||
},
|
||||
{
|
||||
'node': 'omnidb-01',
|
||||
'ip': '192.168.1.3',
|
||||
'component': 'omnidb'
|
||||
},
|
||||
{
|
||||
'node': 'core-01',
|
||||
'ip': '192.168.1.4',
|
||||
'component': 'core'
|
||||
}
|
||||
]
|
||||
items_value_range = {
|
||||
'cpu_load': (0, 3.0),
|
||||
'memory_used_percent': (20, 10.0),
|
||||
'disk_used_percent': (30, 80.0),
|
||||
'thread': (100, 100),
|
||||
'goroutine': (200, 500),
|
||||
'replay_upload_health': (0, [0, 1]),
|
||||
'command_upload_health': (0, [0, 1]),
|
||||
'session_active': (100, 50),
|
||||
'session_processed': (400, 400),
|
||||
'session_failed': (50, 100),
|
||||
'session_succeeded': (500, 300)
|
||||
}
|
||||
|
||||
def do_generate(self, batch, batch_size):
|
||||
datetime = timezone.now()
|
||||
for i in batch:
|
||||
datetime = datetime - timezone.timedelta(minutes=1)
|
||||
items = []
|
||||
for node in self.nodes:
|
||||
for key, values in self.items_value_range.items():
|
||||
base, r = values
|
||||
if isinstance(r, int):
|
||||
value = int(random.random() * r)
|
||||
elif isinstance(r, float):
|
||||
value = round(random.random() * r, 2)
|
||||
elif isinstance(r, list):
|
||||
value = random.choice(r)
|
||||
else:
|
||||
continue
|
||||
value += base
|
||||
node.update({
|
||||
'key': key,
|
||||
'value': value,
|
||||
'datetime': datetime
|
||||
})
|
||||
items.append(Stat(**node))
|
||||
Stat.objects.bulk_create(items, ignore_conflicts=True)
|
Reference in New Issue
Block a user