Skip to content
vamola.devv2.4 · online

kerna

Why is my Linux system slow, hot or draining the battery? A calm terminal tool that explains the cause instead of showing more numbers. Read-only, no root, no network.

GoCLIMIT Licensev0.7.0

Terminal Preview

kerna — kitty
$kerna
● 2 things need attention
Processor 2% CPU wait 0% Disk wait 0% Memory 54% used
● The NVIDIA GPU is awake
› runtime power management is "on": the kernel may not switch it off
$ echo auto | sudo tee /sys/bus/pci/devices/0000:01:00.0/power/control
● The battery is draining fast: 26 W, about 1.4 hours left

The kerna screen in a terminal: a yellow verdict '3 things need attention', live bars for processor, memory, temperature and power, and below them a note that the NVIDIA GPU is awake with the exact command to try.
kerna watch on a laptop: a verdict, a few live lines, and only what needs attention below them.

About

btop, glances and fastfetch show you numbers, and then you have to work out what they mean. kerna reads the same kernel data and says the answer: what is wrong, which program is behind it, and one command to try.

It is built around the kernel's pressure stall information: the share of the last 10 seconds in which programs were actually waiting for the CPU, the disk or memory. That is what you feel as "slow". A busy CPU that nobody waits for is not reported, and when everything is fine, kerna says so in one line.

It is a single Go binary, under 2,000 lines, standard library only. It reads /proc and /sys: no root, no network, nothing on your system is changed. Two commands run another program, and they say so below.


What it finds

FindingHow it knows
Programs are waiting for the CPUCPU stall of 10% or more; the busiest programs, same-name processes added together
Programs are waiting for the diskdisk stall; per-process read and write rate
Memory is running outmemory stall, little free RAM or heavy swap traffic
The CPU is slowing itself down88 °C or more with clocks under 70% of maximum
A discrete GPU is awakeruntime power state, power/control, and for NVIDIA who has the device open
A GPU is working hard, or draws 8 W or more50% busy or 8 W (amdgpu); the programs behind it come from the kernel's DRM fdinfo, for example "Hyprland 25%, Firefox 17%, video decoder 16%"
A GPU is almost fully busy95% or more: gpu_busy_percent (amdgpu), or derived from idle residency (Intel)
Network connections are losing packets3% or more of the sent TCP segments had to be sent again, at least 300 segments
The Wi-Fi signal is weak-75 dBm or worse, when the driver reports it
A performance power profile is active on batteryplatform_profile or the CPU energy preference is performance while discharging
The battery is draining fast15 W or more on battery; suspects ranked by CPU work and wake-ups per second, plus the GPU's own watts (amdgpu)

Every finding has a title, the reason, the evidence and one command. kerna never runs that command itself, and it never suggests pausing parts of your desktop session.

On the laptop it was built on, kerna found within seconds that the NVIDIA GPU's power/control was set to on, so the kernel could never put it to sleep, which can cost battery.


Installation & Usage

bash — install, no root needed
curl -fsSL https://raw.githubusercontent.com/vam0laa/kerna/main/install.sh | sh

The script downloads the latest release, checks its SHA-256 and installs it to ~/.local/bin. The messages are English or Türkçe, chosen from your system language.

bash — use
kerna                      # sample for 2 seconds and explain what is wrong
kerna watch                # live view: q quit, p pause, h history
kerna --json               # the same diagnosis as JSON, for scripts and status bars
kerna history              # problems in the last 24 hours
kerna history --at 03:12   # what was going on at that moment
kerna history --today      # battery, busiest programs and problems of today
kerna sleep                # suspend problems and drain while asleep
kerna why qs               # look closely at one program
kerna check                # what kerna can see on this machine (for bug reports)
kerna completion fish      # shell completion for fish, bash or zsh
kerna service install      # record history in the background
kerna service uninstall    # stop recording
kerna why-froze            # why did the last session end badly?
kerna snapshot             # measure now ... change something ...
kerna compare              # ... and see what got better or worse
kerna waybar               # one JSON line for a Waybar module
kerna ignore dgpu-awake    # mute a finding you do not care about
kerna notify on            # desktop notifications from the recorder

kerna watch keys: q quit, p pause, j/k select a finding, c copy its command, i mute it, t list the busiest programs (CPU, GPU, wake-ups, RAM), h the last 24 hours, d today's summary, ? all keys.

kerna watch is one calm screen on purpose: a verdict on top, six live lines with a short graph, and below them only what is wrong. No process tables, no tabs, no mouse.


History: what happened at 03:12?

kerna service install starts a small systemd user service that writes one line every 15 seconds to ~/.local/state/kerna/history.jsonl. The file is private to your user and entries older than 7 days are deleted. Nothing is recorded until you install the service, and uninstalling it stops it at once.

bash — kerna history
  Last 24 hours, 2 problems:

Wed 25 Nov
  03:12–03:19 ● Programs were waiting for the CPU  peak stall 71%
                 ffmpeg ×3 270% of one core
  14:02–14:40 ● The battery was draining fast  21 W

Today, and sleep

kerna history --today summarises the day from the recorder: hours recorded, the battery used (an estimate in watt-hours with an hourly sparkline), GPU watts, the busiest programs and the problems. kerna sleep shows the kernel's suspend counters, warns when the machine sleeps in s2idle although deep is available, and lists long gaps in the history on battery with the percent lost per hour. A laptop that is really off drains almost nothing, so a high rate means it was asleep and something kept it busy.

Programs with names people do not recognise get a plain description, for example qs · Quickshell, your desktop shell.


Look closely at one program

kerna why <name|pid> shows how long a program has run, what it uses now compared with its whole life, which of its threads do the work, its GPU time, wake-ups and RAM, and the child programs it started, then says in plain words what the numbers show. The comparison matters: the CPU figure that ps shows for a long-running program is its lifetime average and can be far from what it does right now. When most of the work is in a rendering thread, kerna says the program keeps redrawing the screen. That is how an always-on audio visualizer in a desktop shell showed up on the laptop kerna was built on: the shell used about 50% of a core, and 3% after the visualizer was turned off.


Why did it freeze?

kerna why-froze reads the kernel and system log of the previous and the current boot, checks whether the previous session ended with a normal shutdown, and names the last memory, graphics, thermal or disk error shortly before the end. With the history recorder it also shows what kerna saw in the last minutes. A hard freeze or a power loss leave no trace in any log, and then it says exactly that.

The one command that runs another program

why-froze runs journalctl, read-only, because the log is a binary journal. Your user needs to be allowed to read it (group wheel, adm or systemd-journal). kerna notify on also lets the recording service run notify-send.


Did my change help?

kerna snapshot saves a measurement, kerna compare measures again and shows what got better or worse: battery draw, GPU watts, temperature, waits, and whether a GPU went to sleep. Small changes wobble from one sample to the next, so repeat it before you trust a small difference.


In your bar, and as notifications

~/.config/waybar/config.jsonc
"custom/kerna": { "exec": "kerna waybar", "return-type": "json", "interval": 10, "tooltip": true }

The module's class is ok, note, warn or bad, so plain CSS can colour it, and the tooltip lists the findings. kerna notify on makes the recording service send a desktop notification when a problem lasts more than a minute, at most once every 30 minutes per problem. It is off by default. kerna ignore <id> mutes a finding for good, and ~/.config/kerna/config.json can change the thresholds. For Quickshell there is a small example window in the repository, contrib/quickshell/KernaStatus.qml.


Requirements & Compatibility

PLATFORMLinux (PSI enabled kernel)
ARCHITECTUREx86_64 · arm64
BUILT WITHGo, standard library only
Privacy

Read-only, no network access, no telemetry. The only files it writes are the optional history, snapshots and settings, all in your own home directory and only when you ask for them.

Limitations

Tested on Arch Linux with Hyprland on an AMD + NVIDIA laptop. why-froze was tried on real logs of a clean shutdown; the out-of-memory, graphics and thermal cases, notification timing and the Waybar module were only tested with sample data, not on a live bar or notification daemon. The disk and memory findings and the AMD and Intel GPU paths are tested with fake kernel data, not yet seen under real load on those parts, and the arm64 build has not been run by us. Without root, disk and GPU use is only visible for your own processes, and the kernel gives no watts per program, so battery suspects are ranked by CPU work and wake-ups, never by invented watts. Intel GPU busy is derived from idle residency and was only tested with fake data. The thermal finding is an estimate from temperature and clock speed. The Wi-Fi signal is only available when the driver reports it (not on the MediaTek chip of the test laptop), so there kerna relies on the packet loss finding. There is no per-program network use without root. GPU time per program is readable for your own processes only, NVIDIA's proprietary driver does not publish it, and it was seen on real hardware with amdgpu only. It looks at the last few seconds, plus the history if you turned it on.

Repository Link

Source code and issues are on GitHub. Released under the MIT license.