X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=src%2Fcmd%2Fnncp-stat%2Fmain.go;h=241201f46d0db886c50fecfe21d446f35c378704;hb=0367cce2741e1ce6a89a49fd5c4e9df6005c9744;hp=09cc63b66e8157ef7e51847b16bf290e21a758d6;hpb=2ddf5ecd4af39298d7e210448cca7b6456408778;p=nncp.git diff --git a/src/cmd/nncp-stat/main.go b/src/cmd/nncp-stat/main.go index 09cc63b..241201f 100644 --- a/src/cmd/nncp-stat/main.go +++ b/src/cmd/nncp-stat/main.go @@ -1,6 +1,6 @@ /* NNCP -- Node to Node copy, utilities for store-and-forward data exchange -Copyright (C) 2016-2020 Sergey Matveev +Copyright (C) 2016-2022 Sergey Matveev This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,7 +26,7 @@ import ( "sort" "github.com/dustin/go-humanize" - "go.cypherpunks.ru/nncp/v5" + "go.cypherpunks.ru/nncp/v8" ) func usage() { @@ -36,11 +36,11 @@ func usage() { flag.PrintDefaults() } -func jobPrint(xx nncp.TRxTx, job nncp.Job) { +func jobPrint(xx nncp.TRxTx, job nncp.Job, suffix string) { fmt.Printf( - "\t%s %s %s (nice: %s)\n", + "\t%s %s%s %s (nice: %s)\n", string(xx), - nncp.ToBase32(job.HshValue[:]), + nncp.Base32Codec.EncodeToString(job.HshValue[:]), suffix, humanize.IBytes(uint64(job.Size)), nncp.NicenessFmt(job.PktEnc.Nice), ) @@ -56,6 +56,7 @@ func main() { version = flag.Bool("version", false, "Print version information") warranty = flag.Bool("warranty", false, "Print warranty information") ) + log.SetFlags(log.Lshortfile) flag.Usage = usage flag.Parse() if *warranty { @@ -98,39 +99,75 @@ func main() { fmt.Println(node.Name) rxNums := make(map[uint8]int) rxBytes := make(map[uint8]int64) + noCKNums := make(map[uint8]int) + noCKBytes := make(map[uint8]int64) + partNums := 0 + partBytes := int64(0) for job := range ctx.Jobs(node.Id, nncp.TRx) { - job.Fd.Close() if *showPkt { - jobPrint(nncp.TRx, job) + jobPrint(nncp.TRx, job, "") } rxNums[job.PktEnc.Nice] = rxNums[job.PktEnc.Nice] + 1 rxBytes[job.PktEnc.Nice] = rxBytes[job.PktEnc.Nice] + job.Size } + for job := range ctx.JobsNoCK(node.Id) { + if *showPkt { + jobPrint(nncp.TRx, job, ".nock") + } + noCKNums[job.PktEnc.Nice] = noCKNums[job.PktEnc.Nice] + 1 + noCKBytes[job.PktEnc.Nice] = noCKBytes[job.PktEnc.Nice] + job.Size + } + for job := range ctx.JobsPart(node.Id) { + if *showPkt { + fmt.Printf( + "\t%s %s.part %s\n", + string(nncp.TRx), + nncp.Base32Codec.EncodeToString(job.HshValue[:]), + humanize.IBytes(uint64(job.Size)), + ) + } + partNums++ + partBytes += job.Size + } txNums := make(map[uint8]int) txBytes := make(map[uint8]int64) for job := range ctx.Jobs(node.Id, nncp.TTx) { - job.Fd.Close() if *showPkt { - jobPrint(nncp.TRx, job) + jobPrint(nncp.TTx, job, "") } txNums[job.PktEnc.Nice] = txNums[job.PktEnc.Nice] + 1 txBytes[job.PktEnc.Nice] = txBytes[job.PktEnc.Nice] + job.Size } var nice uint8 + if partNums > 0 { + fmt.Printf( + "\tpart: % 10s, % 3d pkts\n", + humanize.IBytes(uint64(partBytes)), partNums, + ) + } for nice = 1; nice > 0; nice++ { rxNum, rxExists := rxNums[nice] txNum, txExists := txNums[nice] - if !(rxExists || txExists) { + noCKNum, noCKExists := noCKNums[nice] + if !(rxExists || txExists || noCKExists) { continue } fmt.Printf( - "\tnice:% 4s | Rx: % 10s, % 3d pkts | Tx: % 10s, % 3d pkts\n", + "\tnice:% 4s | Rx: % 10s, % 3d pkts | Tx: % 10s, % 3d pkts", nncp.NicenessFmt(nice), humanize.IBytes(uint64(rxBytes[nice])), rxNum, humanize.IBytes(uint64(txBytes[nice])), txNum, ) + if noCKExists { + fmt.Printf( + " | NoCK: % 10s, % 3d pkts", + humanize.IBytes(uint64(noCKBytes[nice])), + noCKNum, + ) + } + fmt.Printf("\n") } } }