analyze

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2025 License: MIT Imports: 25 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 GetFirstDirectory added in v0.1.3

func GetFirstDirectory(url string) string

func HumanizeAgo added in v0.1.4

func HumanizeAgo(d time.Duration) string

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) DirAnalyze added in v0.1.3

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

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 util.SizeFlag
	RefreshSec int
	RepeatWarn time.Duration
	SortBy     SortByFlag
	TopN       int
	Truncate   bool
	Truncate2  int
	Whole      bool
	Filter     grep.Filter

	Analyze    bool
	Daemon     bool
	DirAnalyze bool

	CpuProfile string
	MemProfile string
}

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 DirectoryStats added in v0.1.3

type DirectoryStats struct {
	Size     uint64
	Requests uint64
}

type DirectoryTotalStats added in v0.1.3

type DirectoryTotalStats struct {
	Size          uint64
	Requests      uint64
	IPCount       map[netip.Prefix]struct{}
	LastURLUpdate time.Time
	LastURLAccess time.Time
}

type IPStats

type IPStats struct {
	Size     uint64
	Requests uint64
	LastURL  string

	// Directory statistics
	DirStats map[string]*DirectoryStats

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

	// Time of last URL change
	LastURLUpdate time.Time

	// Time of last URL access
	LastURLAccess time.Time

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

func (IPStats) MergeWith

func (i IPStats) MergeWith(other IPStats) IPStats

func (IPStats) UpdateWith

func (i IPStats) UpdateWith(item parser.LogItem, dirStats bool) IPStats

type SortByFlag

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

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