From 5f2ba43a47246898eabbcb679dd6d711a8dcfda9 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Mon, 13 Sep 2021 19:43:54 -0700 Subject: charts: show ??s when proc_stat->start is unset When libvmon fails to successfully sample proc_stat, it will leave this value as 0, which isn't really otherwise a normal process start value. Handle this by producing "??s" for the Wall time normally derived from (sys_stat->boottime - proc_stat->start), to prevent producing an incorrect Wall time equal to sys_stat->boottime. There should probably be a more robust means of communicating these libvmon sampling failures to vwm/vmon, but I've thus far been resisting adding something like an errno to every sample store, or worse every sample store's datum. It's kind of non-trivial to do without bloating the sample stores, especially since the stores consolidate multiple proc files under a single store/want. Having a single errno in the store would prevent letting the valid portions of the store be usable while ignoring the errored portions. Perhaps just a per-store errno with a bitfield to indicate which subset are errored would suffice... --- src/charts.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/charts.c') diff --git a/src/charts.c b/src/charts.c index 0edb7e6..11680d0 100644 --- a/src/charts.c +++ b/src/charts.c @@ -794,6 +794,8 @@ static void draw_columns(vwm_charts_t *charts, vwm_chart_t *chart, vwm_column_t case VWM_COLUMN_PROC_WALL: /* User Sys Wall times */ if (!row) str_len = snpf(str, sizeof(str), "Wall"); + else if (!proc_stat->start) + str_len = snpf(str, sizeof(str), "??s"); else str_len = snpf(str, sizeof(str), "%.2fs", (float)(sys_stat->boottime - proc_stat->start) / (float)charts->vmon.ticks_per_sec); -- cgit v1.2.3