uniex

package module
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 11, 2025 License: BSD-3-Clause Imports: 12 Imported by: 0

README

OVERVIEW

Go Reference Go Report Card Go Build License SemVer
built with nix

paepcke.de/uniex

UNIEX

  • Exports UNIFI Controller Inventory Database (mongoDB) to [csv|json]
  • Adds missing attributes (latest used hostname, latest used ip, latest seen, ...) via parsing all device and stat records
  • Converts Timestamps (eg. unix nano time) into RFC3339 (parseable by excel, human readable) format
  • Fast, even for large corp inventory (in-memory, parallel processing)

SCREENSHOT CLI

UNIEX SAMPLE SCREENSHOT

⚡️QUICK START

go run paepcke.de/uniex/cmd/uniex@main

⚡️PRETTY PRINT CSV OUTPUT VIA BAT

go run paepcke.de/uniex/cmd/uniex@main | bat -l csv

⚡️PRETTY PRINT JSON OUTPUT VIA JQ

UNIEX_FORMAT=json go run paepcke.de/uniex/cmd/uniex@main | jq

⚡️HOW TO INSTALL

go install paepcke.de/uniex/cmd/uniex@main

⚡️PRE-BUILD BINARIES (DOWNLOAD)

https://github.com/paepckehh/uniex/releases

SUPPORTED OPTIONS

# Optional (via env variables)
- UNIEX_MONGODB   - mongodb uri, default: mongodb://127.0.0.1:27117
- UNIEX_FORMAT    - export format, default: csv [csv|json]

DOCS

pkg.go.dev/paepcke.de/uniex

🛡 License

License

This project is licensed under the terms of the BSD 3-Clause License license. See LICENSE for more details.

📃 Citation

@misc{uniex,
  author = {Michael Paepcke},
  title = {Export UNIFI MongoDB Inventory Database},
  year = {2024},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://paepcke.de/uniex}}
}

CONTRIBUTION

Yes, Please! PRs Welcome!

Documentation

Index

Constants

View Source
const SemVer = "v0.1.3"

global

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	MongoDB string // [UNIEX_MONGODB] mongodb uri, default: mongodb://127.0.0.1:27117
	Format  string // [UNIEX_FORMAT]  export format, default: csv [csv|json]
	Scope   string // [UNIEX_SCOPE]   export scope, default: client [client] TODO: infra
}

Config

func NewConfig added in v0.1.3

func NewConfig() *Config

New Config

func (*Config) Export

func (c *Config) Export() ([]byte, error)

Export Data

type Device

type Device struct {
	NAME           string `bson:"name"`
	NOTE           string `bson:"note"`
	HOSTNAME       string // hostname (from stats)
	IP             string // ip address (from stats)
	MAC            string `bson:"mac"`
	OUI            string `bson:"oui"`
	SWITCHNAME     string `bson:"last_uplink_name"`
	SWITCHMAC      string `bson:"last_uplink_mac"`
	SWITCHPORT     string // switch port (from stats)
	VLANNETWORK    string `bson:"last_connection_network_name"`
	FIRSTSEEN      string // rfc3339 timestamp (calculated)
	LASTSEEN       string // rfc3339 timestamp (calculated)
	FIRSTSEEN_UNIX int64  `bson:"first_seen"`
	LASTSEEN_UNIX  int64  `bson:"last_seen"`
}

Device

type Stat

type Stat struct {
	MAC           string `bson:"mac"`
	HOSTNAME      string `bson:"hostname"`
	IP            string `bson:"ip"`
	SWITCHMAC     string `bson:"sw_mac"`
	SWITCHPORT    string `bson:"sw_port"`
	LASTSEEN_UNIX int64  `bson:"time"`
}

Stat

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL