r/swift • • 12d ago

Sysbar: a menu bar system monitor built with SwiftPM only (no .xcodeproj), AppKit + SwiftUI, IOKit/Mach APIs. Open source, plus a few lessons learned

Post image

Sysbar is a small menu bar app for macOS that shows CPU, GPU, memory, disk, network and top processes. It's written in Swift with no dependencies and uses about 35 MB of RAM.

Since the last few versions it can also serve `/metrics` for Prometheus.

The metric names follow node_exporter, so dashboards like Node Exporter Full work as they are, and it adds what node_exporter can't see on a Mac: GPU, E/P core usage, memory pressure and battery health. It's off by default and only listens where you choose (localhost or Tailscale, for example). A Grafana dashboard is included in the repo.

Download (DMG): https://github.com/rodrigotrombeta/Sysbar/releases/latest

Source (Apache-2.0): https://github.com/rodrigotrombeta/Sysbar

It isn't notarized, so macOS will block it on the first launch. The README explains how to allow it, but basically it is:

xattr -dr com.apple.quarantine /Applications/Sysbar.app

Feedback is welcome, especially from anyone who knows AppKit well

9 Upvotes

11 comments sorted by

-1

u/ThanhDongNguyen 12d ago

Nice that it's all public APIs and no helper. A few things I'd check:

  • proc_pid_rusage on processes owned by other users (root stuff like WindowServer or mds) fails with a permission error when you're not root, I think. So the top processes list may quietly miss the exact processes that eat CPU or power. Worth testing.
  • for the E/P split, are you relying on core order? sysctl hw.perflevel0.logicalcpu and hw.perflevel1.logicalcpu give the P and E counts per machine, safer across base, Pro and Max chips.
  • the DMG is ad-hoc signed, so people downloading it on recent macOS get the "can't be opened" dialog and have to go to Privacy & Security > Open Anyway. I'd at least put that in the README, or go Developer ID + notarytool if you want it smooth.

1

u/Affectionate_Pea3516 11d ago

Thanks for your valuable comments, u/ThanhDongNguyen . I don't have a Developer account, so better if I add to README some details regarding that will help.

1

u/Affectionate_Pea3516 11d ago

Regarding:
proc_pid_rusage: yes, it fails for processes owned by other users, and Sysbar currently just skips them. As far as I know there's no unprivileged workaround (Activity Monitor relies on a privileged service, and ps is setuid root). I'll add a small note in the processes section so it's clear system processes aren't included.

E/P split: the counts already come from hw.nperflevels / hw.perflevel1.logicalcpu, but you're right that mapping which cores are E still assumes the E cluster comes first. That holds on every Apple Silicon chip so far, but it's a convention, not a guarantee. Reading cluster-type from the CPU nodes in the IORegistry would make it explicit, so I'll look into that

1

u/honestly_i 6d ago

Jesus christ it's an ai post with ai comments
This is hell

1

u/Affectionate_Pea3516 5d ago

Lol could be worse. I was obligated to make that AI written given that everywhere on Reddit that I want to tell about my project it obligated me to write as the dict..moderator wants it to be written. It's kind of ridiculous from my pov (and I don't intend to have anyone agreement on that). Try to post your idea in line 3 to 4 communities here and you will see the nightmare it is, being moderated because of irrelevant things.

But anyway, I've implemented a few changes that makes sysbar an exporter for Prometheus metrics. It's now more than usefull to me, given that it now have a second great purpose

-2

u/[deleted] 12d ago

[removed] — view removed comment

1

u/Affectionate_Pea3516 11d ago

Thanks! It surprised me too. Before switching to Shapes, a pinned panel would climb by tens of MB, mostly GPU-backed buffers that Canvas re-rendered on every tick.

I measured it with [Activity Monitor's Memory column / Instruments Allocations / footprint -p <pid>], comparing the same pinned panel with Canvas and with Shapes.

When the panels are closed, the per-process scan stops entirely (it only runs while a panel that shows processes is visible), and only the menu bar icon gets redrawn. I haven't done a proper long run with everything closed yet, though, so I can't say for sure that it stays flat. That's next on my list, and I'll post the numbers here.

1

u/Affectionate_Pea3516 11d ago

Not sure why this got downvoted. It's a fair question, and it pointed at something I hadn't verified

-2

u/rhysmorgan iOS 11d ago

AI slop comment.