Documentation ¶
Overview ¶
Package p4dlog parses Perforce Hexlix Core Server text logs (not structured logs).
These are logs created by p4d, as documented by:
https://community.perforce.com/s/article/2525
It assumes you have set configurable server=3 (or greater) You may also have decided to set track=1 to get more detailed usage of access to different tables.
See p4dlog_test.go for examples of log entries.
Index ¶
- Variables
- func FlagSet(flag int, level DebugLevel) bool
- type Block
- type Command
- type DebugLevel
- type P4dFileParser
- func (fp *P4dFileParser) CmdsPendingCount() int
- func (fp *P4dFileParser) LogParser(ctx context.Context, linesChan <-chan string, timeChan <-chan time.Time) chan interface{}
- func (fp *P4dFileParser) SetDebugMode(level int)
- func (fp *P4dFileParser) SetDebugPID(pid int64, cmdName string)
- func (fp *P4dFileParser) SetDurations(outputDuration, debugDuration time.Duration)
- func (fp *P4dFileParser) SetNoCompletionRecords()
- type ServerEvent
- type Table
Constants ¶
This section is empty.
Variables ¶
var BlockEndPrefixes = []string{
"Rpc himark:",
"server to client",
"server to inter",
"Forwarder set trusted client address",
"NetSslTransport::SendOrReceive",
}
Various line prefixes that both can end a block, and should be ignored - see ignoreLine
Functions ¶
func FlagSet ¶ added in v0.8.0
func FlagSet(flag int, level DebugLevel) bool
FlagSet - true if specified level set
Types ¶
type Block ¶
type Block struct {
// contains filtered or unexported fields
}
Block is a block of lines parsed from a file
type Command ¶
type Command struct { ProcessKey string `json:"processKey"` Cmd string `json:"cmd"` Pid int64 `json:"pid"` LineNo int64 `json:"lineNo"` User string `json:"user"` Workspace string `json:"workspace"` StartTime time.Time `json:"startTime"` EndTime time.Time `json:"endTime"` ComputeLapse float32 `json:"computeLapse"` CompletedLapse float32 `json:"completedLapse"` Paused float32 `json:"paused"` // How long command was paused IP string `json:"ip"` App string `json:"app"` Args string `json:"args"` Running int64 `json:"running"` UCpu int64 `json:"uCpu"` SCpu int64 `json:"sCpu"` DiskIn int64 `json:"diskIn"` DiskOut int64 `json:"diskOut"` IpcIn int64 `json:"ipcIn"` IpcOut int64 `json:"ipcOut"` MaxRss int64 `json:"maxRss"` PageFaults int64 `json:"pageFaults"` MemMB int64 `json:"memMB"` MemPeakMB int64 `json:"memPeakMB"` RPCMsgsIn int64 `json:"rpcMsgsIn"` RPCMsgsOut int64 `json:"rpcMsgsOut"` RPCSizeIn int64 `json:"rpcSizeIn"` RPCSizeOut int64 `json:"rpcSizeOut"` RPCHimarkFwd int64 `json:"rpcHimarkFwd"` RPCHimarkRev int64 `json:"rpcHimarkRev"` RPCSnd float32 `json:"rpcSnd"` RPCRcv float32 `json:"rpcRcv"` FileTotalsSnd int64 `json:"fileTotalsSnd` FileTotalsRcv int64 `json:"fileTotalsRcv` FileTotalsSndMBytes int64 `json:"fileTotalsSndMBytes` FileTotalsRcvMBytes int64 `json:"fileTotalsRcvMBytes` NetFilesAdded int64 `json:"netFilesAdded"` // Valid for syncs and network estimates records NetFilesUpdated int64 `json:"netFilesUpdated"` NetFilesDeleted int64 `json:"netFilesDeleted"` NetBytesAdded int64 `json:"netBytesAdded"` NetBytesUpdated int64 `json:"netBytesUpdated"` LbrRcsOpens int64 `json:"lbrRcsOpens"` // Required for processing lbr records LbrRcsCloses int64 `json:"lbrRcsCloses"` LbrRcsCheckins int64 `json:"lbrRcsCheckins"` LbrRcsExists int64 `json:"lbrRcsExists"` LbrRcsReads int64 `json:"lbrRcsReads"` LbrRcsReadBytes int64 `json:"lbrRcsReadBytes"` LbrRcsWrites int64 `json:"lbrRcsWrites"` LbrRcsWriteBytes int64 `json:"lbrRcsWriteBytes"` LbrRcsDigests int64 `json:"lbrRcsDigests"` LbrRcsFileSizes int64 `json:"lbrRcsFileSizes"` LbrRcsModTimes int64 `json:"lbrRcsModTimes"` LbrRcsCopies int64 `json:"lbrRcsCopies"` LbrBinaryOpens int64 `json:"lbrBinaryOpens"` LbrBinaryCloses int64 `json:"lbrBinaryCloses"` LbrBinaryCheckins int64 `json:"lbrBinaryCheckins"` LbrBinaryExists int64 `json:"lbrBinaryExists"` LbrBinaryReads int64 `json:"lbrBinaryReads"` LbrBinaryReadBytes int64 `json:"lbrBinaryReadBytes"` LbrBinaryWrites int64 `json:"lbrBinaryWrites"` LbrBinaryWriteBytes int64 `json:"lbrBinaryWriteBytes"` LbrBinaryDigests int64 `json:"lbrBinaryDigests"` LbrBinaryFileSizes int64 `json:"lbrBinaryFileSizes"` LbrBinaryModTimes int64 `json:"lbrBinaryModTimes"` LbrBinaryCopies int64 `json:"lbrBinaryCopies"` LbrCompressOpens int64 `json:"lbrCompressOpens"` LbrCompressCloses int64 `json:"lbrCompressCloses"` LbrCompressCheckins int64 `json:"lbrCompressCheckins"` LbrCompressExists int64 `json:"lbrCompressExists"` LbrCompressReads int64 `json:"lbrCompressReads"` LbrCompressReadBytes int64 `json:"lbrCompressReadBytes"` LbrCompressWrites int64 `json:"lbrCompressWrites"` LbrCompressWriteBytes int64 `json:"lbrCompressWriteBytes"` LbrCompressDigests int64 `json:"lbrCompressDigests"` LbrCompressFileSizes int64 `json:"lbrCompressFileSizes"` LbrCompressModTimes int64 `json:"lbrCompressModTimes"` LbrCompressCopies int64 `json:"lbrCompressCopies"` LbrUncompressOpens int64 `json:"lbrUncompressOpens"` LbrUncompressCloses int64 `json:"lbrUncompressCloses"` LbrUncompressCheckins int64 `json:"lbrUncompressCheckins"` LbrUncompressExists int64 `json:"lbrUncompressExists"` LbrUncompressReads int64 `json:"lbrUncompressReads"` LbrUncompressReadBytes int64 `json:"lbrUncompressReadBytes"` LbrUncompressWrites int64 `json:"lbrUncompressWrites"` LbrUncompressWriteBytes int64 `json:"lbrUncompressWriteBytes"` LbrUncompressDigests int64 `json:"lbrUncompressDigests"` LbrUncompressFileSizes int64 `json:"lbrUncompressFileSizes"` LbrUncompressModTimes int64 `json:"lbrUncompressModTimes"` LbrUncompressCopies int64 `json:"lbrUncompressCopies"` CmdError bool `json:"cmderror"` Tables map[string]*Table // contains filtered or unexported fields }
Command is a command found in the block
func (*Command) MarshalJSON ¶
MarshalJSON - handle time formatting
type DebugLevel ¶ added in v0.8.0
type DebugLevel int
DebugLevel - for different levels of debugging
const ( DebugBasic DebugLevel = 1 << iota DebugDatabase DebugJSON DebugCommands DebugAddCommands DebugTrackRunning DebugUnrecognised DebugPending DebugPendingCounts DebugTrackPaused DebugMetricStats DebugLines )
type P4dFileParser ¶
type P4dFileParser struct { CmdsCount int //Count of commands processed ServerEventsCount int // Count of server event records processed // contains filtered or unexported fields }
P4dFileParser - manages state
func NewP4dFileParser ¶
func NewP4dFileParser(logger *logrus.Logger) *P4dFileParser
NewP4dFileParser - create and initialise properly
func (*P4dFileParser) CmdsPendingCount ¶ added in v0.0.3
func (fp *P4dFileParser) CmdsPendingCount() int
CmdsPendingCount - count of unmatched commands
func (*P4dFileParser) LogParser ¶
func (fp *P4dFileParser) LogParser(ctx context.Context, linesChan <-chan string, timeChan <-chan time.Time) chan interface{}
LogParser - interface to be run on a go routine - commands are returned on cmdchan
func (*P4dFileParser) SetDebugMode ¶ added in v0.1.0
func (fp *P4dFileParser) SetDebugMode(level int)
SetDebugMode - turn on debugging - very verbose!
func (*P4dFileParser) SetDebugPID ¶ added in v0.8.0
func (fp *P4dFileParser) SetDebugPID(pid int64, cmdName string)
SetDebugPID - turn on debugging for a PID
func (*P4dFileParser) SetDurations ¶ added in v0.1.0
func (fp *P4dFileParser) SetDurations(outputDuration, debugDuration time.Duration)
SetDurations - for debugging
func (*P4dFileParser) SetNoCompletionRecords ¶ added in v0.12.3
func (fp *P4dFileParser) SetNoCompletionRecords()
SetNoCompletionRecords - don't expect completion records
type ServerEvent ¶ added in v0.13.0
type ServerEvent struct { EventTime time.Time `json:"eventTime"` LineNo int64 `json:"lineNo"` ActiveThreads int64 `json:"activeThreads"` ActiveThreadsMax int64 `json:"activeThreadsMax"` PausedThreads int64 `json:"pausedThreads"` PausedThreadsMax int64 `json:"pausedThreadsMax"` PausedErrorCount int64 `json:"pausedErrorCount"` PauseRateCPU int64 `json:"pauseRateCPU"` // Percentage 1-100 PauseRateMem int64 `json:"pauseRateMem"` // Percentage 1-100 CPUPressureState int64 `json:"cpuPressureState"` // 0-2 MemPressureState int64 `json:"memPressureState"` // 0-2 }
ServerEvent
func (*ServerEvent) MarshalJSON ¶ added in v0.13.0
func (s *ServerEvent) MarshalJSON() ([]byte, error)
MarshalJSON - handle formatting
func (*ServerEvent) String ¶ added in v0.13.0
func (s *ServerEvent) String() string
type Table ¶ added in v0.0.2
type Table struct { TableName string `json:"tableName"` PagesIn int64 `json:"pagesIn"` PagesOut int64 `json:"pagesOut"` PagesCached int64 `json:"pagesCached"` PagesSplitInternal int64 `json:"pagesSplitInternal"` PagesSplitLeaf int64 `json:"pagesSplitLeaf"` ReadLocks int64 `json:"readLocks"` WriteLocks int64 `json:"writeLocks"` GetRows int64 `json:"getRows"` PosRows int64 `json:"posRows"` ScanRows int64 `json:"scanRows"` PutRows int64 `json:"putRows"` DelRows int64 `json:"delRows"` TotalReadWait int64 `json:"totalReadWait"` TotalReadHeld int64 `json:"totalReadHeld"` TotalWriteWait int64 `json:"totalWriteWait"` TotalWriteHeld int64 `json:"totalWriteHeld"` MaxReadWait int64 `json:"maxReadWait"` MaxReadHeld int64 `json:"maxReadHeld"` MaxWriteWait int64 `json:"maxWriteWait"` MaxWriteHeld int64 `json:"maxWriteHeld"` PeekCount int64 `json:"peekCount"` TotalPeekWait int64 `json:"totalPeekWait"` TotalPeekHeld int64 `json:"totalPeekHeld"` MaxPeekWait int64 `json:"maxPeekWait"` MaxPeekHeld int64 `json:"maxPeekHeld"` TriggerLapse float32 `json:"triggerLapse"` }
Table stores track information per table (part of Command)