Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new fields for Lbr Sets #15

Merged
merged 3 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions cmd/log2sql/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ func writeHeader(f io.Writer) {
rpcSnd FLOAT NULL, rpcRcv FLOAT NULL, running INT NULL,
netSyncFilesAdded INT NULL, netSyncFilesUpdated INT NULL, netSyncFilesDeleted INT NULL,
netSyncBytesAdded INT NULL, netSyncBytesUpdated INT NULL,
lbrRcsOpens INT NULL, lbrRcsCloses INT NULL, lbrRcsCheckins INT NULL, lbrRcsExists INT NULL,
lbrRcsReads INT NULL, lbrRcsReadBytes INT NULL, lbrRcsWrites INT NULL, lbrRcsWriteBytes INT NULL,
lbrCompressOpens INT NULL, lbrCompressCloses INT NULL, lbrCompressCheckins INT NULL, lbrCompressExists INT NULL,
lbrCompressReads INT NULL, lbrCompressReadBytes INT NULL, lbrCompressWrites INT NULL, lbrCompressWriteBytes INT NULL,
lbrUncompressOpens INT NULL, lbrUncompressCloses INT NULL, lbrUncompressCheckins INT NULL, lbrUncompressExists INT NULL,
lbrUncompressReads INT NULL, lbrUncompressReadBytes INT NULL, lbrUncompressWrites INT NULL, lbrUncompressWriteBytes INT NULL,
error TEXT NULL,
PRIMARY KEY (processkey, lineNumber));
`)
Expand Down Expand Up @@ -91,8 +97,18 @@ func getProcessStatement() string {
rpcSnd, rpcRcv, running,
netSyncFilesAdded, netSyncFilesUpdated, netSyncFilesDeleted,
netSyncBytesAdded, netSyncBytesAdded,
lbrRcsOpens, lbrRcsCloses, lbrRcsCheckins,
lbrRcsExists, lbrRcsReads, lbrRcsReadBytes,
lbrRcsWrites, lbrRcsWriteBytes, lbrCompressOpens,
lbrCompressCloses, lbrCompressCheckins, lbrCompressExists,
lbrCompressReads, lbrCompressReadBytes,
lbrCompressWrites, lbrCompressWriteBytes,
lbrUncompressOpens, lbrUncompressCloses,
lbrUncompressCheckins, lbrUncompressExists,
lbrUncompressReads, lbrUncompressReadBytes,
lbrUncompressWrites, lbrUncompressWriteBytes,
error)
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`
}

func getTableUseStatement() string {
Expand Down Expand Up @@ -120,6 +136,12 @@ func preparedInsert(logger *logrus.Logger, stmtProcess, stmtTableuse *sqlite3.St
float64(cmd.RPCSnd), float64(cmd.RPCRcv), cmd.Running,
cmd.NetFilesAdded, cmd.NetFilesUpdated, cmd.NetFilesDeleted,
cmd.NetBytesAdded, cmd.NetBytesUpdated,
cmd.LbrRcsOpens, cmd.LbrRcsCloses, cmd.LbrRcsCheckins, cmd.LbrRcsExists,
cmd.LbrRcsReads, cmd.LbrRcsReadBytes, cmd.LbrRcsWrites, cmd.LbrRcsWriteBytes,
cmd.LbrCompressOpens, cmd.LbrCompressCloses, cmd.LbrCompressCheckins, cmd.LbrCompressExists,
cmd.LbrCompressReads, cmd.LbrCompressReadBytes, cmd.LbrCompressWrites, cmd.LbrCompressWriteBytes,
cmd.LbrUncompressOpens, cmd.LbrUncompressCloses, cmd.LbrUncompressCheckins, cmd.LbrUncompressExists,
cmd.LbrUncompressReads, cmd.LbrUncompressReadBytes, cmd.LbrUncompressWrites, cmd.LbrUncompressWriteBytes,
cmd.CmdError)
if err != nil {
logger.Errorf("Process insert: %v pid %d, lineNo %d, %s",
Expand All @@ -146,7 +168,10 @@ func writeSQL(f io.Writer, cmd *p4dlog.Command) int64 {
rows := 1
fmt.Fprintf(f, `INSERT INTO process VALUES ("%s",%d,%d,"%s","%s",%0.3f,%0.3f,`+
`"%s","%s","%s","%s","%s","%s",%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,`+
`%.3f,%.3f,%d,%d,%d,%d,%d,%d,"%v");`+"\n",
`%.3f,%.3f,%d,%d,%d,%d,%d,%d,`+
`%d,%d,%d,%d,%d,%d,%d,%d,`+
`%d,%d,%d,%d,%d,%d,%d,%d,`+
`%d,%d,%d,%d,%d,%d,%d,%d,"%v");`+"\n",
cmd.GetKey(), cmd.LineNo, cmd.Pid, dateStr(cmd.StartTime), dateStr(cmd.EndTime),
cmd.ComputeLapse, cmd.CompletedLapse,
cmd.User, cmd.Workspace, cmd.IP, cmd.App, cmd.Cmd, cmd.Args,
Expand All @@ -156,6 +181,12 @@ func writeSQL(f io.Writer, cmd *p4dlog.Command) int64 {
cmd.RPCSnd, cmd.RPCRcv, cmd.Running,
cmd.NetFilesAdded, cmd.NetFilesUpdated, cmd.NetFilesDeleted,
cmd.NetBytesAdded, cmd.NetBytesUpdated,
cmd.LbrRcsOpens, cmd.LbrRcsCloses, cmd.LbrRcsCheckins, cmd.LbrRcsExists,
cmd.LbrRcsReads, cmd.LbrRcsReadBytes, cmd.LbrRcsWrites, cmd.LbrRcsWriteBytes,
cmd.LbrCompressOpens, cmd.LbrCompressCloses, cmd.LbrCompressCheckins, cmd.LbrCompressExists,
cmd.LbrCompressReads, cmd.LbrCompressReadBytes, cmd.LbrCompressWrites, cmd.LbrCompressWriteBytes,
cmd.LbrUncompressOpens, cmd.LbrUncompressCloses, cmd.LbrUncompressCheckins, cmd.LbrUncompressExists,
cmd.LbrUncompressReads, cmd.LbrUncompressReadBytes, cmd.LbrUncompressWrites, cmd.LbrUncompressWriteBytes,
cmd.CmdError)
for _, t := range cmd.Tables {
rows++
Expand Down
4 changes: 2 additions & 2 deletions p4dlog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,7 @@ Perforce server info:

func TestForLbrAndTable(t *testing.T) {
testInput := `
Perforce server info:
Perforce server info:
2023/07/01 02:00:02 pid 1871637 build@cmdr-tools-change-155476395 127.0.0.1/10.5.64.108 [p4/2018.1/LINUX26X86_64/1957529 (brokered)] 'user-transmit -t1871630 -b8 -s524288 -p'

Perforce server info:
Expand Down Expand Up @@ -1032,7 +1032,7 @@ Perforce server info:
output := parseLogLines(testInput)
assert.Equal(t, 1, len(output))
//assert.Equal(t, "", output[0])
assert.JSONEq(t, `{"processKey":"c64b38c5e71582bd477ffcaab5b3514d","cmd":"user-transmit","pid":1871637,"lineNo":5,"user":"build","workspace":"cmdr-tools-change-155476395","computeLapse":0,"completedLapse":0.011,"ip":"127.0.0.1/10.5.64.108","app":"p4/2018.1/LINUX26X86_64/1957529 (brokered)","args":"-t1871630 -b8 -s524288 -p","startTime":"2023/07/01 02:00:02","endTime":"2023/07/01 02:00:02","running":0,"uCpu":5,"sCpu":4,"diskIn":0,"diskOut":8,"ipcIn":0,"ipcOut":0,"maxRss":10364,"pageFaults":0,"rpcMsgsIn":2,"rpcMsgsOut":74,"rpcSizeIn":0,"rpcSizeOut":0,"rpcHimarkFwd":97604,"rpcHimarkRev":318788,"rpcSnd":0,"rpcRcv":0.001,"netFilesAdded":0,"netFilesUpdated":0,"netFilesDeleted":0,"netBytesAdded":0,"netBytesUpdated":0,"lbrRcsOpens":8,"lbrRcsCloses":8,"lbrRcsCheckins":0,"lbrRcsExists":0,"lbrRcsReads":16,"lbrRcsReadBytes":202547,"lbrRcsWrites":0,"lbrRcsWriteBytes":0,"lbrCompressOpens":16,"lbrCompressCloses":16,"lbrCompressCheckins":0,"lbrCompressExists":0,"lbrCompressReads":32,"lbrCompressReadBytes":142028,"lbrCompressWrites":0,"lbrCompressWriteBytes":0,"lbrUncompressOpens":0,"lbrUncompressCloses":0,"lbrUncompressCheckins":0,"lbrUncompressExists":0,"lbrUncompressReads":0,"lbrUncompressReadBytes":0,"lbrUncompressWrites":0,"lbrUncompressWriteBytes":0,"cmdError":false,"tables":[{"tableName":"monitor","pagesIn":2,"pagesOut":4,"pagesCached":4096,"pagesSplitInternal":0,"pagesSplitLeaf":0,"readLocks":0,"writeLocks":2,"getRows":0,"posRows":0,"scanRows":0,"putRows":2,"delRows":0,"totalReadWait":0,"totalReadHeld":0,"totalWriteWait":1,"totalWriteHeld":0,"maxReadWait":0,"maxReadHeld":0,"maxWriteWait":1,"maxWriteHeld":0,"peekCount":0,"totalPeekWait":0,"totalPeekHeld":0,"maxPeekWait":0,"maxPeekHeld":0,"triggerLapse":0},{"tableName":"topology","pagesIn":5,"pagesOut":0,"pagesCached":4,"pagesSplitInternal":0,"pagesSplitLeaf":0,"readLocks":1,"writeLocks":0,"getRows":0,"posRows":1,"scanRows":1,"putRows":0,"delRows":0,"totalReadWait":0,"totalReadHeld":0,"totalWriteWait":0,"totalWriteHeld":0,"maxReadWait":0,"maxReadHeld":0,"maxWriteWait":0,"maxWriteHeld":0,"peekCount":0,"totalPeekWait":0,"totalPeekHeld":0,"maxPeekWait":0,"maxPeekHeld":0,"triggerLapse":0}]}`,
assert.JSONEq(t, `{"processKey":"c64b38c5e71582bd477ffcaab5b3514d","cmd":"user-transmit","pid":1871637,"lineNo":2,"user":"build","workspace":"cmdr-tools-change-155476395","computeLapse":0,"completedLapse":0.011,"ip":"127.0.0.1/10.5.64.108","app":"p4/2018.1/LINUX26X86_64/1957529 (brokered)","args":"-t1871630 -b8 -s524288 -p","startTime":"2023/07/01 02:00:02","endTime":"2023/07/01 02:00:02","running":1,"uCpu":5,"sCpu":4,"diskIn":0,"diskOut":8,"ipcIn":0,"ipcOut":0,"maxRss":10364,"pageFaults":0,"rpcMsgsIn":2,"rpcMsgsOut":74,"rpcSizeIn":0,"rpcSizeOut":0,"rpcHimarkFwd":97604,"rpcHimarkRev":318788,"rpcSnd":0,"rpcRcv":0.001,"netFilesAdded":0,"netFilesUpdated":0,"netFilesDeleted":0,"netBytesAdded":0,"netBytesUpdated":0,"lbrRcsOpens":8,"lbrRcsCloses":8,"lbrRcsCheckins":0,"lbrRcsExists":0,"lbrRcsReads":16,"lbrRcsReadBytes":202547,"lbrRcsWrites":0,"lbrRcsWriteBytes":0,"lbrCompressOpens":16,"lbrCompressCloses":16,"lbrCompressCheckins":0,"lbrCompressExists":0,"lbrCompressReads":32,"lbrCompressReadBytes":142028,"lbrCompressWrites":0,"lbrCompressWriteBytes":0,"lbrUncompressOpens":0,"lbrUncompressCloses":0,"lbrUncompressCheckins":0,"lbrUncompressExists":0,"lbrUncompressReads":0,"lbrUncompressReadBytes":0,"lbrUncompressWrites":0,"lbrUncompressWriteBytes":0,"cmdError":false,"tables":[{"tableName":"monitor","pagesIn":2,"pagesOut":4,"pagesCached":4096,"pagesSplitInternal":0,"pagesSplitLeaf":0,"readLocks":0,"writeLocks":2,"getRows":0,"posRows":0,"scanRows":0,"putRows":2,"delRows":0,"totalReadWait":0,"totalReadHeld":0,"totalWriteWait":1,"totalWriteHeld":0,"maxReadWait":0,"maxReadHeld":0,"maxWriteWait":1,"maxWriteHeld":0,"peekCount":0,"totalPeekWait":0,"totalPeekHeld":0,"maxPeekWait":0,"maxPeekHeld":0,"triggerLapse":0},{"tableName":"topology","pagesIn":5,"pagesOut":0,"pagesCached":4,"pagesSplitInternal":0,"pagesSplitLeaf":0,"readLocks":1,"writeLocks":0,"getRows":0,"posRows":1,"scanRows":1,"putRows":0,"delRows":0,"totalReadWait":0,"totalReadHeld":0,"totalWriteWait":0,"totalWriteHeld":0,"maxReadWait":0,"maxReadHeld":0,"maxWriteWait":0,"maxWriteHeld":0,"peekCount":0,"totalPeekWait":0,"totalPeekHeld":0,"maxPeekWait":0,"maxPeekHeld":0,"triggerLapse":0}]}`,
output[0])
}

Expand Down