Skip to content

AveragePaintEnjoyer/gomac

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gomac

gomac is a lightweight SNMP-based switch monitoring tool written in Go.
It allows you to monitor switch ports and MAC addresses via a web interface.

The main purpose of go-mac is to help track and document complex or poorly documented enterprise networks, showing which ports are active and what devices are connected to them.

Features

  • Polls switches using SNMP (supports Generic and UniFi systems)
  • Tracks port status (UP / DOWN) and status change count
  • Tracks MAC addresses on each port, including VLANs (if supported)
  • Web dashboard displaying switches and ports in a "switch front panel" style
  • Clickable ports to view detailed status and MAC tables
  • Admin interface to add, remove, or edit switches and sites
  • MAC search page for finding which switch/port a MAC address is on
  • Configurable via .env for:
    • Web server port
    • Polling interval
    • Database location

Installation

  1. Add user
sudo useradd -r -m -d /home/gomac gomac
  1. Install necessary tools

Make sure to install current supported go version from golang website directly on to your system.

sudo apt update
sudo apt install build-essential libsqlite3-dev
  1. Clone repo
su gomac
cd /home/gomac/gomac

git clone https://github.com/AveragePaintEnjoyer/gomac
cd gomac
  1. Compile

When compiling, use this flag:

go mod tidy

export CGO_ENABLED=1
go build -o gomac ./cmd/server
  1. Set up .env file (example provided in .config/.env.example):
WEB_HOST=0.0.0.0
WEB_PORT=8080
POLL_INTERVAL=600
DB_PATH=/home/gomac/gomac/gomac.db
  1. Run the server manually:
./gomac

The web interface will be available at http://localhost:8080.

  1. Add systemd service (example provided in .config/gomac.service)
sudo nano /etc/systemd/system/gomac.service
  1. Start
sudo systemctl daemon-reload
sudo systemctl enable gomac
sudo systemctl start gomac
sudo journalctl -u gomac -f 

Usage

Dashboard: View all switches, port status, and MAC addresses.

MAC Search: Search for a MAC address to see which switch and port it’s on.

Admin: Add or remove switches and configure port counts.

Dependencies

  • Go 1.20+
  • Fiber web framework
  • GORM for SQLite
  • GoSNMP for SNMP polling
  • Tailwind CSS for UI styling (embedded in HTML templates)

About

gomac is a lightweight SNMP-based switch monitoring tool written in Go. It allows you to monitor switch ports and MAC addresses via a web interface. The main purpose of go-mac is to help track and document complex or poorly documented enterprise networks, showing which ports are active and what devices are connected to them.

Topics

Resources

License

Stars

Watchers

Forks

Contributors