如何自定义概览导出mqtt的输出?

2024-04-19 00:58:44 发布

您现在位置:Python中文网/ 问答频道 /正文

我想定制Gleases export mqtt的输出。 使用psutil v5.6.7https://pypi.org/project/Glances/浏览v3.1.3

当前形成的输出:

METRIC/hostname/cpu_user_careful/cpu_user_careful 50.0
METRIC/hostname/cpu_iowait_warning/cpu_iowait_warning 11.25
METRIC/hostname/cpu_user_warning/cpu_user_warning 70.0
METRIC/hostname/time_since_update/time_since_update 1.18965816498
METRIC/hostname/cpu_system_warning/cpu_system_warning 70.0
METRIC/hostname/syscalls/syscalls 0
METRIC/hostname/history_size/history_size 28800.0
METRIC/hostname/cpu_steal_careful/cpu_steal_careful 50.0
METRIC/hostname/total/total 15.1
METRIC/hostname/cpu_iowait_critical/cpu_iowait_critical 12.5

我不想要这个输出

我希望它以这种方式输出

glances --stdout now, CPU, mem

now: 2019-12-11 11:46:20 +03
cpu: {'softirq': 0.6, 'iowait': 0.0, 'interrupts': 1311, 'system': 5.6, 'guest': 0.0, 'soft_interrupts': 1139, 'time_since_update': 0.2078418731689453, 'idle': 84.0, 'user': 9.9, 'guest_nice': 0.0, 'irq': 0.0, 'cpucore': 8, 'syscalls': 0, 'total': 17.2, 'steal': 0.0, 'ctx_switches': 2394, 'nice': 0.0}
mem: {'available': 20221001728, 'used': 4801884160, 'cached': 4999942144, 'percent': 19.2, 'free': 20221001728, 'inactive': 3005779968, 'active': 4919730176, 'shared': 711999488, 'total': 25022885888, 'buffers': 516206592}

如何将这样的输出发送到Gleases export mqtt


Tags: timeupdatecpumetricsystemhostnametotalwarning