Exemplo n.º 1
0
def scatter3d():
    ga = Gauge('CPU监控')
    ga.use_theme('roma')
    range_color = [
        '#313695', '#4575b4', '#74add1', '#abd9e9', '#e0f3f8', '#ffffbf',
        '#fee090', '#fdae61', '#f46d43', '#d73027', '#a50026'
    ]
    ga.add('CPU 核心数 {} '.format(getCPUState()[0]),
           'CPU 使用率',
           getCPUState()[1],
           visual_range_color=range_color)
    return ga
Exemplo n.º 2
0
def getCPUState(interval=1):
    cpuCount = psutil.cpu_count()
    cpuPercent = psutil.cpu_percent(interval)
    return (str(cpuCount), str(cpuPercent))

# def gauge_color() -> Gauge:
#     c = (
#         Gauge()
#         .add(
#             "业务指标",
#             [("完成率", 55.5)],
#             axisline_opts=opts.AxisLineOpts(
#                 linestyle_opts=opts.LineStyleOpts(
#                     color=[(0.3, "#67e0e3"), (0.7, "#37a2da"), (1, "#fd666d")], width=30
#                 )
#             ),
#         )
#         .set_global_opts(
#             title_opts=opts.TitleOpts(title="Gauge-不同颜色"),
#             legend_opts=opts.LegendOpts(is_show=False),
#         )
#     )
#     return c

ga = Gauge('CPU监控')
ga.use_theme('roma')
ga.add('CPU 核心数 {} '.format(getCPUState()[0]),'CPU 使用率',getCPUState()[1])
ga.render('6.html')