analyze

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2025 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const TimeFormat = time.DateTime

Variables

This section is empty.

Functions

func AdjacentPrefix

func AdjacentPrefix(p netip.Prefix) netip.Prefix

func OpenFile

func OpenFile(filename string) (io.ReadCloser, error)

func TruncateFilenameLen

func TruncateFilenameLen(input string, target int) string

func TruncateURLPath

func TruncateURLPath(input string) string

func TruncateURLPathLen

func TruncateURLPathLen(input string, target int) string

Types

type Analyzer

type Analyzer struct {
	Config AnalyzerConfig
	// contains filtered or unexported fields
}

func NewAnalyzer

func NewAnalyzer(c AnalyzerConfig) (*Analyzer, error)

func (*Analyzer) AnalyzeFile

func (a *Analyzer) AnalyzeFile(filename string) error

func (*Analyzer) GetActiveConns

func (a *Analyzer) GetActiveConns(activeConn map[netip.Prefix]int)

func (*Analyzer) GetCurrentServers

func (a *Analyzer) GetCurrentServers() []string

func (*Analyzer) IPPrefix

func (a *Analyzer) IPPrefix(ip netip.Addr) netip.Prefix

func (*Analyzer) OpenLogFile

func (a *Analyzer) OpenLogFile() error

func (*Analyzer) OpenTailIterator

func (a *Analyzer) OpenTailIterator(filename string) (fileiter.Iterator, error)

func (*Analyzer) PrintTopValues

func (a *Analyzer) PrintTopValues(displayRecord map[netip.Prefix]time.Time, sortBy SortByFlag, serverFilter string)

func (*Analyzer) PrintTotal

func (a *Analyzer) PrintTotal()

func (*Analyzer) RunLoop

func (a *Analyzer) RunLoop(iter fileiter.Iterator) error

func (*Analyzer) RunLoopWithMultipleIterators

func (a *Analyzer) RunLoopWithMultipleIterators(iters []fileiter.Iterator) error

func (*Analyzer) SortedKeys

func (a *Analyzer) SortedKeys(sortBy SortByFlag, serverFilter string) []StatKey

SortedKeys returns stat keys sorted by value

func (*Analyzer) TailFile

func (a *Analyzer) TailFile(filename string) error

type AnalyzerConfig

type AnalyzerConfig struct {
	Absolute   bool
	Group      bool
	LogOutput  string
	NoNetstat  bool
	Parser     string
	PrefixV4   int
	PrefixV6   int
	PrintDelta SizeFlag
	RefreshSec int
	Server     string
	SortBy     SortByFlag
	Threshold  SizeFlag
	TopN       int
	Truncate   bool
	Truncate2  int
	Whole      bool

	Analyze bool
	Daemon  bool
}

func DefaultConfig

func DefaultConfig() AnalyzerConfig

func (*AnalyzerConfig) InstallFlags

func (c *AnalyzerConfig) InstallFlags(flags *pflag.FlagSet, cmdname string)

func (*AnalyzerConfig) UseLock

func (c *AnalyzerConfig) UseLock() bool

type IPStats

type IPStats struct {
	Size     uint64
	Requests uint64
	LastURL  string

	// Used with daemon mode only
	LastSize  uint64
	FirstSeen time.Time

	// Record time of last URL change
	LastURLUpdate time.Time

	// Record time of last URL access
	LastURLAccess time.Time

	// User-agent
	UAStore map[UAKeyType]struct{}
}

func (IPStats) MergeWith

func (i IPStats) MergeWith(other IPStats) IPStats

func (IPStats) UpdateWith

func (i IPStats) UpdateWith(item parser.LogItem) IPStats

type SizeFlag

type SizeFlag uint64

func (*SizeFlag) Set

func (s *SizeFlag) Set(value string) error

func (SizeFlag) String

func (s SizeFlag) String() string

func (SizeFlag) Type

func (s SizeFlag) Type() string

type SortByFlag

type SortByFlag string
const (
	SortBySize     SortByFlag = "size"
	SortByRequests SortByFlag = "requests"
)

func ListSortFuncs

func ListSortFuncs() []SortByFlag

func (*SortByFlag) Set

func (s *SortByFlag) Set(value string) error

func (SortByFlag) String

func (s SortByFlag) String() string

func (SortByFlag) Type

func (s SortByFlag) Type() string

type SortFunc

type SortFunc func(l, r StatKey) int

func GetSortFunc

func GetSortFunc(name SortByFlag, i map[StatKey]IPStats) SortFunc

type StatKey

type StatKey struct {
	Server string
	Prefix netip.Prefix
}

type UAKeyType added in v0.1.1

type UAKeyType = unique.Handle[string]

Jump to

Keyboard shortcuts

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