You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

基于Vega-Lite构建WireGuard用户实时在线甘特图技术问询

基于Vega-Lite构建WireGuard用户实时在线甘特图技术问询

大家好,我现在想做一个甘特图,用来实时监控WireGuard的用户在线状态。日志是我自己用Python脚本生成的,所以如果需要调整日志的格式或者输出内容,我完全可以修改脚本。

先跟大家说明下相关的信息:

  • 日志里的log_in_time和log_out_time都是Unix时间戳格式,其中log_out_time为0的时候表示用户当前还在线
  • 目前的日志示例是这样的:
May 10 15:49:13 wireguard: erste has logged_in log_in_time 1715356153 log_out_time 0 from 172.17.0.180 port 56750
May 10 15:52:13 wireguard: erste has logged_out log_in_time 1715356153 log_out_time 1715356333 from 172.17.0.180 port 65242
May 10 16:25:16 wireguard: erste has logged_in log_in_time 1715358316 log_out_time 0 from 172.17.0.180 port 65242

我已经写了一部分Vega-Lite的代码,不过还没完成,片段如下:

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "title": "Gantt diagram users online using VPN",
  "data": {
    "url": {
      "%context%": true,
      "%path%": "/var/log/wireguard/wireguard.log"
    },
    // 这里还需要添加日志解析的逻辑,以及后续的可视化配置
  }
}

现在我遇到的问题主要有两个:

  1. 怎么把这些日志数据正确解析成甘特图需要的结构?比如将每个用户的登录时间作为时段起始点,登出时间(如果是0的话就用当前时间)作为结束点,还要把同一个用户的多次登录事件区分开。
  2. 怎么实现甘特图的实时更新?让它能自动刷新最新的日志状态。

有没有大佬能给我一些思路或者示例代码参考呀?

备注:内容来源于stack exchange,提问作者user24806047

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.17 07:48:00