Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ on:
paths:
- "docs/**"
- "mkdocs.yml"
- "overrides/**"
- ".github/workflows/docs.yml"
pull_request:
paths:
- "docs/**"
- "mkdocs.yml"
- "overrides/**"
- ".github/workflows/docs.yml"
workflow_dispatch:

Expand Down
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,18 @@
</tr>
</table>

Log the CPU and RAM a process uses — **and every process it spawns**, including
children that daemonize and detach themselves. Or follow the busiest processes
of the whole machine, as a service from boot to shutdown.
Track the CPU and RAM usage of a process — **and every process it spawns**,
including children that daemonize and detach themselves. Or follow the busiest
processes of the whole machine, as a service from boot to shutdown.

treehawk is a free, open-source resource usage monitor for Linux and macOS:

- **Track CPU usage** and **track RAM usage** of any command, script or running
process, including its child processes.
- **Log resource usage over time** and get peak and average memory and CPU.
- **Find memory leaks** and CPU spikes across the whole machine.
- **Get a PDF report** with charts of CPU and memory usage.
- Tracking GPU usage is planned.

**Documentation: <https://ibadrather.github.io/treehawk/>**

Expand Down
10 changes: 10 additions & 0 deletions docs/development.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
---
title: Develop treehawk
description: >-
Build, test and extend treehawk, the open-source Python process CPU and memory monitor: checks, project layout, and where to add metrics like GPU.
keywords:
- python process monitor
- open source resource monitor
- track gpu usage
---

# Development

```bash
Expand Down
14 changes: 13 additions & 1 deletion docs/how-it-works.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
---
title: How treehawk tracks process CPU and memory
description: >-
How treehawk finds every process in a workload, even daemons that detach, and measures CPU and memory with RSS, PSS and cgroups. Limits included.
keywords:
- monitor detached processes
- process memory rss pss
- cgroup memory usage
- monitor child processes
---

# How it works

The first four sections cover `watch` and `run`; [Whole-machine
Expand Down Expand Up @@ -121,4 +132,5 @@ named again only after growing another 25%.
treehawk keeps on screen and for the summary is capped.
- A spike needs 15 s of history for that process, and a leak suspect needs 30
minutes of steady growth.
- GPU usage is not collected yet. The `top` log already has a column for it.
- Tracking GPU usage is planned but not collected yet. The `top` log already
has a column for it.
22 changes: 17 additions & 5 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
---
title: Introduction
title: Track CPU and RAM usage of a process and its children
description: >-
treehawk tracks CPU and RAM usage of a process and every child it spawns, even detached daemons. Free resource usage monitor for Linux and macOS.
keywords:
- track cpu usage
- track ram usage
- track memory usage
- track resource usage
- monitor process cpu and memory
- monitor child processes
- log cpu usage over time
- python process monitor
---

<div class="hero" markdown>

<img src="assets/brand/logo.svg" alt="">
<img src="assets/brand/logo.svg" alt="treehawk logo">

<h1>tree<span>hawk</span></h1>

Log the CPU and RAM a process uses, and every process it spawns,
Track the CPU and RAM usage of a process and every process it spawns,
**including children that daemonize and detach themselves**.

[Get started](#quick-tour){ .md-button .md-button--primary }
[How it works](how-it-works.md){ .md-button }

</div>

Point treehawk at something already running, or let it start the command. It
treehawk is a free, open-source resource usage monitor for the command line.
Point it at something already running, or let it start the command. It
samples until the workload ends, then leaves a log you can summarise in the
terminal or turn into a PDF report. It can also follow the busiest processes of
the whole machine, as a service from boot to shutdown.
Expand All @@ -25,7 +37,7 @@ It runs on Linux and macOS, including Apple Silicon, and reads the kernel
directly. The two platforms differ in what the kernel will total up for you: see
[Platforms](platforms.md).

![The treehawk live dashboard](assets/output/dashboard.svg)
![The treehawk live dashboard tracking CPU and memory usage](assets/output/dashboard.svg)

## Why

Expand Down
15 changes: 13 additions & 2 deletions docs/install.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
---
title: Install treehawk on Linux and macOS
description: >-
Install treehawk, the CPU and memory usage monitor, on Linux and macOS (including Apple Silicon) with one command. Upgrade and uninstall steps too.
keywords:
- install cpu monitor linux
- install memory monitor macos
- track cpu usage
- track ram usage
---

# Install

treehawk runs on Linux and macOS, including Apple Silicon, with Python 3.10 or
newer.
treehawk, the CPU and RAM usage tracker, runs on Linux and macOS, including
Apple Silicon, with Python 3.10 or newer.

```bash
curl -LsSf https://github.com/ibadrather/treehawk/releases/latest/download/install.sh | sh
Expand Down
17 changes: 15 additions & 2 deletions docs/machine.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
---
title: Monitor top processes and memory leaks
description: >-
Monitor the top processes by CPU and memory on the whole machine, catch CPU spikes and find memory leaks. Runs as a systemd service from boot.
keywords:
- monitor top processes
- find memory leaks
- track resource usage
- systemd resource monitoring
- top processes logger
- cpu spike detection
---

# Track the whole machine

`treehawk top` looks at **every** process on the machine and logs the top N by
CPU and the top N by memory. It runs until it is stopped. It also logs two kinds
`treehawk top` monitors **every** process on the machine and logs the top N by
CPU and the top N by memory (RAM). It runs until it is stopped. It also logs two kinds
of trouble for any process, whether or not it ranks:

- **spike**: a reading far above that process' own recent baseline, such as
Expand Down
9 changes: 8 additions & 1 deletion docs/platforms.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
---
title: Platforms
title: Monitor CPU and memory on Linux and macOS
description: >-
How treehawk tracks CPU and memory usage on Linux (procfs, cgroups) and macOS including Apple Silicon (libproc), and what differs between them.
keywords:
- monitor cpu usage macos
- process memory monitor linux
- apple silicon cpu monitor
- cgroup memory usage
---

# Platforms
Expand Down
20 changes: 16 additions & 4 deletions docs/results.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
---
title: CPU and memory usage report in the terminal or PDF
description: >-
Turn a treehawk log into a CPU and memory usage report: a terminal summary, JSON, or a PDF with charts of CPU and RAM usage over time.
keywords:
- cpu usage report pdf
- memory usage report
- log cpu usage over time
- peak memory usage
- resource usage charts
---

# Read the results

Every run leaves a log. `report` summarises it in the terminal, and `pdf` turns
it into a report. Both work on either kind of log (a `watch`/`run` log or a
Every run leaves a log of CPU and memory usage over time. `report` summarises it
in the terminal, and `pdf` turns it into a report with charts. Both work on either kind of log (a `watch`/`run` log or a
`top` directory) and tell them apart by the log's header. They also work on the
log of an interrupted run, because the summary is recomputed from the samples
that were written.
Expand Down Expand Up @@ -52,9 +64,9 @@ A workload log becomes eight pages, each answering one question.
Pages that need per-process detail are left out of an `--aggregate-only` log
rather than printed blank.

![Overview page](assets/output/pdf-page-1.png)
![Overview page of the CPU and memory usage PDF report](assets/output/pdf-page-1.png)

![CPU over time page](assets/output/pdf-page-2.png)
![CPU usage over time page](assets/output/pdf-page-2.png)

![Process lifetimes page](assets/output/pdf-page-4.png)

Expand Down
17 changes: 15 additions & 2 deletions docs/workload.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
---
title: Track CPU and memory usage of a command
description: >-
Track CPU and RAM usage of a command or a running process, including every child process it spawns. Log resource usage over time until it exits.
keywords:
- track cpu usage of a process
- track memory usage of a command
- monitor child processes
- monitor detached processes
- ml training resource usage
- peak memory usage
---

# Track a workload

`watch` and `run` follow one workload, meaning a process and everything it
spawns, and write a log you read back with [`report` and `pdf`](results.md).
`watch` and `run` track the CPU and memory usage of one workload, meaning a
process and everything it spawns, and write a log you read back with [`report` and `pdf`](results.md).
Both sample until the workload ends. `Ctrl-C` or a `SIGTERM` stops them early,
and the log still ends with a complete summary.

Expand Down
28 changes: 27 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
site_name: treehawk
site_description: Log the CPU and RAM of a process and every process it spawns, including ones that detach.
site_description: >-
Track CPU and RAM usage of a process and every process it spawns, even
detached daemons. A free command-line resource usage monitor for Linux and
macOS, with a live dashboard, logs and PDF reports.
site_author: Ibad Rather
site_url: https://ibadrather.github.io/treehawk/
repo_url: https://github.com/ibadrather/treehawk
repo_name: ibadrather/treehawk
edit_uri: edit/main/docs/

theme:
name: material
custom_dir: overrides
logo: assets/brand/logo.svg
favicon: assets/brand/logo.svg
font: false # brand fonts are loaded by stylesheets/extra.css
Expand All @@ -29,6 +34,27 @@ theme:
icon: material/brightness-4
name: Switch to light mode

extra:
author: Ibad Rather
# Paste the codes from Google Search Console / Bing Webmaster Tools here.
google_site_verification: ""
bing_site_verification: ""
social_image: assets/output/pdf-page-1.png
social_image_alt: A treehawk PDF report of CPU and memory usage over time
keywords:
- track cpu usage
- track ram usage
- track memory usage
- track resource usage
- monitor process cpu and memory
- log cpu usage over time
- monitor child processes
- process memory monitor linux
- monitor cpu usage macos
- find memory leaks
- peak memory usage
- python process monitor

extra_css:
- stylesheets/extra.css

Expand Down
55 changes: 55 additions & 0 deletions overrides/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{% extends "base.html" %}

{#- Search and social metadata. The title and description come from each
page's front matter, falling back to the site's; keywords likewise. -#}
{% block extrahead %}
{%- set seo_title = (page.meta.title ~ " - " ~ config.site_name) if page.meta and page.meta.title else config.site_name -%}
{%- set seo_description = page.meta.description if page.meta and page.meta.description else config.site_description -%}
{%- set seo_keywords = page.meta.keywords if page.meta and page.meta.keywords else config.extra.keywords -%}
{%- set seo_image = config.site_url ~ config.extra.social_image -%}
{%- if seo_keywords %}
<meta name="keywords" content="{{ seo_keywords if seo_keywords is string else seo_keywords | join(', ') }}">
{%- endif %}
{%- if config.extra.google_site_verification %}
<meta name="google-site-verification" content="{{ config.extra.google_site_verification }}">
{%- endif %}
{%- if config.extra.bing_site_verification %}
<meta name="msvalidate.01" content="{{ config.extra.bing_site_verification }}">
{%- endif %}
<meta name="robots" content="index, follow">
<meta property="og:type" content="{{ 'website' if page.is_homepage else 'article' }}">
<meta property="og:site_name" content="{{ config.site_name }}">
<meta property="og:title" content="{{ seo_title }}">
<meta property="og:description" content="{{ seo_description }}">
<meta property="og:url" content="{{ page.canonical_url }}">
<meta property="og:image" content="{{ seo_image }}">
<meta property="og:image:alt" content="{{ config.extra.social_image_alt }}">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="{{ seo_title }}">
<meta name="twitter:description" content="{{ seo_description }}">
<meta name="twitter:image" content="{{ seo_image }}">
{%- if page.is_homepage %}
<script type="application/ld+json">
{{ {
"@context": "https://schema.org",
"@type": "SoftwareApplication",
"name": config.site_name,
"alternateName": "treehawk process monitor",
"description": config.site_description,
"url": config.site_url,
"downloadUrl": config.repo_url ~ "/releases/latest",
"codeRepository": config.repo_url,
"applicationCategory": "DeveloperApplication",
"applicationSubCategory": "System monitoring",
"operatingSystem": "Linux, macOS",
"programmingLanguage": "Python",
"license": "https://opensource.org/licenses/MIT",
"isAccessibleForFree": true,
"keywords": config.extra.keywords | join(", "),
"image": seo_image,
"author": {"@type": "Person", "name": config.extra.author, "url": "https://github.com/ibadrather"},
"offers": {"@type": "Offer", "price": "0", "priceCurrency": "USD"}
} | tojson }}
</script>
{%- endif %}
{% endblock %}
30 changes: 26 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,34 @@
[project]
name = "treehawk"
version = "0.8.0"
description = "Log CPU and RAM usage of a process and every process it spawns, detached or not."
version = "0.8.1"
description = "Track CPU and RAM usage of a process and every process it spawns, detached or not. A resource usage monitor for Linux and macOS."
readme = "README.md"
license = "MIT"
license-files = ["LICENSE"]
authors = [{ name = "Ibad Rather", email = "ibad.rather.ir@gmail.com" }]
requires-python = ">=3.10"
keywords = ["monitoring", "cpu", "memory", "process", "cgroup", "procfs", "macos", "libproc"]
keywords = [
"cpu-usage",
"memory-usage",
"ram-usage",
"resource-usage",
"resource-monitor",
"process-monitor",
"system-monitor",
"cpu-monitor",
"memory-monitor",
"memory-leak",
"monitoring",
"cpu",
"memory",
"ram",
"process",
"linux",
"macos",
"cgroup",
"procfs",
"libproc",
]
classifiers = [
"Development Status :: 3 - Alpha",
"Environment :: Console",
Expand All @@ -33,7 +54,8 @@ dependencies = [
]

[project.urls]
Homepage = "https://github.com/ibadrather/treehawk"
Homepage = "https://ibadrather.github.io/treehawk/"
Documentation = "https://ibadrather.github.io/treehawk/"
Repository = "https://github.com/ibadrather/treehawk"
Issues = "https://github.com/ibadrather/treehawk/issues"
Releases = "https://github.com/ibadrather/treehawk/releases"
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading