HeadlinesBriefing favicon HeadlinesBriefing.com

GitHub's Sonar CLI Tool Simplifies Localhost Port Management

Hacker News •
×

RasKrebs has launched Sonar, a new CLI tool designed to simplify inspecting and managing services listening on localhost ports. Tired of manually running `lsof -iTCP -sTCP:LISTEN` and parsing results, the developer created Sonar to provide a comprehensive view. It displays all active ports, identifying processes, Docker containers, resource usage, and clickable URLs. Key features include killing processes, tailing logs, attaching to containers, and health checks.

The tool automatically hides non-development services like Figma or Spotify but includes an option to show them with `-a`. Installation is straightforward via a script downloading the binary to `~/.local/bin`. Sonar offers extensive commands like `sonar list`, `sonar kill`, and `sonar watch` for live monitoring. Docker integration is robust, using the Docker Engine API for accurate resource metrics without `--stats` flags.

Profiles allow saving expected project ports for easy startup and teardown. The tool runs on macOS (using `lsof`) and Linux (using `ss`), providing a unified interface across platforms.