More usable relative timestamps

Something that has been bothering me for years and has not been fixed (or suggested) are the relative timestamps.

They are very useful at first glance, but when troubleshooting issues, the absolute timestamp is often needed. One could edit the dashboard, but having a mouseover containing the absolute timestamp would be very user friendly.

If this request would be appreciated in the form of a pull request, I will give it a try.

Kind regards,
RubenB

Not sure about the dashboard, but in most views you can adjust the display options to set timestamp to “both”. Perhaps this already helps. Tooltips still sound like a nice idea, though.

I’ve not found a way to do this in dashboards and I’m not sure this would be user friendly: Using the ‘both’ option would take away precious horizontal real screen real estate, especially in dashboard.py which has two tables next to each other.

It should not be a hard fix, I’ve done it in /plugins/views/utils.py in the paint_age method in two lines of (not that good) code. Placing the last return in a span with a title element containing the absolute time would fix this.

As a suggestion:

Index: cmk/gui/plugins/views/utils.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- cmk/gui/plugins/views/utils.py	(revision 51d6681632923c91c832160fcfbae6c47ab8cbb4)
+++ cmk/gui/plugins/views/utils.py	(date 1624749083351)
@@ -1371,7 +1371,14 @@
     else:
         age_class = "age"
 
-    return age_class, prefix + (output_format % cmk.utils.render.approx_age(age)) + warn_txt
+    output_text = '<span title="{mouse_over}">{text}</span>'.format(
+        mouse_over=time.strftime(
+            request.var("po_ts_date", painter_options.get("ts_date")) + " %H:%M:%S",
+            time.localtime(timestamp)
+        ),
+        text=prefix + (output_format % cmk.utils.render.approx_age(age)) + warn_txt
+    )
+    return age_class, output_text
 
 
 def paint_nagiosflag(row: Row, field: ColumnName, bold_if_nonzero: bool) -> CellSpec:

1 Like