A Linux Time Travel Tool

Hi everyone

I’ve been working in a Linux flight recorder tool for the past few months and I wanted to share it with this awesome Linux community with the hope to spark your curiosity and for some feedback.

The tool is called clifr (command line flight recorder).

It is a tool that continuously records system activity, counters, events, open files descriptors, etc. and then it allows the administrator to reconstruct the output of popular diagnostics commands from any point in the past.

It can accurately piece together the output of command such as top, htop, atop, iotop, ps, ss, netstat, sar, vmstat, df, mount, dmesg and many more (more than 50).

Notice that you do not need to have any of these tools installed in the system as clifr does not execute anything; rather it synthesizes the output from the recorded data.

It is very lightweight and its purpose is to allow the user to see the state of the system before an event occurred (like a crash, an oom kill or an intrusion, for example). However, it has many other applications too.

It comes with a terminal user interface. However, it currently covers only a limited number of commands, but it is still very powerful.

It is very efficient and lightweight: On a regular desktop with around 500 processes running it will use only around 20MiB of disk space per day, 0.35% of a single CPU core and only around 90 MiB of RAM. For busy servers, benchmark information is available on the project’s page.

By default clifr only keeps records for the last 72 hrs. but this can be changed to fit your needs.

It is open-source and you can see it in action in: GitHub - jlruedab/clifr: clifr is a Linux System Flight Recorder (SFR) that continuously captures processes, connections, open files and system counters, then shows accurate ps, ss, lsof, top (and 30+ other) tools' full-output for any past moment; tamper-proof and with very low-overhead. · GitHub

Hopefully some of you may give it a try and if that is the case, I will appreciate any feedback and if clifr saved you time or helped you diagnose your system, please consider giving it a star. It helps others discover the project.

All your questions and suggestions are welcome.

Thanks.

3 Likes

That looks like interesting and useful idea>task>tool. And it immediately rises some questions:

  • Could you please highlight difference between sar @ systat suite and your approach?
  • Mere reproduction of some commands may not be the most convenient way to investigate an event within its context. Have you considered showing more holistic system state at the considered moment?
  • Certainly, eBPF may rise stability/security concerns among Linux administrators. Is there something to soothe them?
2 Likes

I’m glad that you find it interesting. These are the responses to your very good questions. Thanks!

  • sar vs clifr. sar records system-wide counters (CPU, memory, disks, network) and is very cheap. clifr records those too (clifr sar even prints sar’s reports), plus what sar doesn’t keep: every process with its command line, including ones that live a few milliseconds, every TCP connection with the process that owned it, open files, mounts, kernel messages and systemd units. sar tells you the disk got busy at 02:40. clifr can also tell you which process was writing and what it had open. The cost is higher though.

  • A more holistic view. Agreed, single commands aren’t enough on their own. clifr tui shows a timeline (CPU, memory, load, I/O pressure, processes) with OOM kills, boots and failed units marked. A pane shows top, ps, ss, lsof or events at the cursor, and you can diff two moments. clifr events gives one timeline of process starts and exits, OOM kills and mount changes. You can see a description of the interface in this link: https://www.youtube.com/watch?v=OEtYb0B2fYE. Also clifr is AI agent friendly (via the --json option). Allowing an AI assistant to query clifr can potentially provide a more complete picture of a past issue.

  • eBPF. The programs only observe: tracepoints (kprobes only on old kernels where there’s no tracepoint), no changes to packets or return values, checked by the kernel verifier, built once with CO-RE (no module, no compiler on the server). It’s tested on kernels from RHEL 8’s 4.18 up to 7.0. eBPF is also optional: with process_events: proc_connector and tcp: sample nothing is loaded into the kernel, at the price of missing very short-lived processes and connections. sudo clifrd doctor shows what your kernel supports first.

It’s still a prototype, so feedback from anyone who tries it on a test box is very welcome.

Thanks for reading my post.

4 Likes