Skip to content

Commit c47f599

Browse files
authored
Merge pull request #3 from SmilingPixel/feature/0620-scraper
feat: implement scraper ang analyzer
2 parents f508670 + 0e83707 commit c47f599

File tree

11 files changed

+1293
-1
lines changed

11 files changed

+1293
-1
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Python virtual environment
2+
.venv/

README.md

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Introduction
12
mactop-scraper is a lightweight client tool designed to collect, store, and analyze system metrics from mactop running in server mode on Apple Silicon Macs. It periodically fetches real-time performance data via the Prometheus-compatible HTTP endpoint exposed by mactop, enabling you to build custom datasets for monitoring, analysis, or visualization.
23

34
Typical use cases include:
@@ -6,4 +7,73 @@ Typical use cases include:
67
- Local or remote metric storage for later analysis
78
- Integrating MacBook hardware telemetry into your own workflows
89

9-
> Note: This project assumes you have `mactop` installed and running with its server functionality enabled.
10+
> Note: This project assumes you have `mactop` installed and running with its server functionality enabled.
11+
12+
13+
# Features
14+
15+
- Real-time Metric Collection: Periodically fetches performance data from mactop.
16+
17+
- Prometheus-compatible Endpoint: Integrates seamlessly with mactop's exposed HTTP endpoint.
18+
19+
- Customizable Data Storage: Supports output to JSON files.
20+
21+
- Flexible Data Analysis: Generates summaries of collected metrics.
22+
23+
- Lightweight and Efficient: Designed for minimal system overhead
24+
25+
26+
# Prerequisites
27+
28+
- mactop: You must have [mactop](https://github.com/context-labs/mactop) installed and running in server mode on your Apple Silicon Mac.
29+
30+
- Python: mactop-analyzer requires Python 3.13, and we strongly recommend [uv](https://github.com/astral-sh/uv) to manage environment and packages.
31+
32+
- Golang (Optional): We have released binaries for scraper, you can download and run directly. Alternatively, you can build from source code, and go >= 1.24 is recommended.
33+
34+
35+
# Usage
36+
37+
## Scraper
38+
39+
Scraper is a command-line tool that collects metrics from mactop's HTTP endpoint and stores them in JSON files.
40+
41+
Assuming you have downloaded the released binary as `scraper`, you can run it with the following command:
42+
43+
```bash
44+
./scraper --duration 60 --interval 5 --output-dir "./metrics_data" --mactop-url "http://192.168.1.5:2211"
45+
```
46+
47+
You can find more details about the command-line options by running:
48+
49+
```bash
50+
./scraper --help
51+
```
52+
53+
## Analyzer
54+
55+
Analyzer is a Python script that processes the collected JSON files and generates summaries of the metrics.
56+
57+
Before running the analyzer, make sure you have installed the required Python packages. You can do this using `uv`:
58+
59+
```bash
60+
uv sync
61+
```
62+
63+
Then, you can run the analyzer with the following command:
64+
65+
```bash
66+
uv run analyzer.py --input-dir "./metrics_data"
67+
```
68+
69+
Then, you can get a report of the collected metrics. You can also get graphs of the metrics by adding `--plot` option.
70+
71+
72+
# License
73+
74+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
75+
76+
77+
# Contributing
78+
79+
Contributions are welcome! Please feel free to submit issues or pull requests. For major changes, please open an issue first to discuss what you would like to change.

analyzer/.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.13

0 commit comments

Comments
 (0)