]> Cypherpunks.ru repositories - nncp.git/commitdiff
nncp-stat -pkt option
authorSergey Matveev <stargrave@stargrave.org>
Wed, 25 Dec 2019 13:20:15 +0000 (16:20 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Wed, 25 Dec 2019 13:20:15 +0000 (16:20 +0300)
doc/cmds.texi
doc/news.ru.texi
doc/news.texi
src/cmd/nncp-stat/main.go

index c4c6d01f6de38728823a29473b875336320871ab..9fff9e4679f77d1bc951d619b18fe0e8705ff6e3 100644 (file)
@@ -502,13 +502,14 @@ ones. If @option{-seen} option is specified, then delete only
 @section nncp-stat
 
 @example
-$ nncp-stat [options] [-node NODE]
+$ nncp-stat [options] [-pkt] [-node NODE]
 @end example
 
 Print current @ref{Spool, spool} statistics about unsent and unprocessed
 packets. For each node (unless @option{-node} specified) and each
 niceness level there will be printed how many packets (with the total
-size) are in inbound (Rx) and outbound (Tx) queues.
+size) are in inbound (Rx) and outbound (Tx) queues. @option{-pkt} option
+show information about each packet.
 
 @node nncp-toss
 @section nncp-toss
index 813ab2be065e98c8402457bb087883ed873dc016..73614086900f782c20ac8764481d6091c50682cf 100644 (file)
@@ -9,6 +9,10 @@
 Исправлена работоспособность @option{onlinedeadline} с адресами вызова
 использующими внешние команды (@verb{#"|somecmd"#}).
 
+@item
+@command{nncp-stat} имеет опцию @option{-pkt} показывающую информацию по
+каждому пакету в spool.
+
 @end itemize
 
 @node Релиз 5.3.0
index 92ff418e8ea842ea50e7e4b967b84ae2dd262561..697ced820b0f27caa86fc4f0733a5bd6a211c2c3 100644 (file)
@@ -11,6 +11,10 @@ See also this page @ref{Новости, on russian}.
 Fixed @option{onlinedeadline} workability with call addresses that use
 external commands (@verb{#"|somecmd"#}).
 
+@item
+@command{nncp-stat} has @option{-pkt} option displaying information
+about each packet in the spool.
+
 @end itemize
 
 @node Release 5.3.0
index 22eaca0af5376a54198a7dfaf9fa5dcaa1b3f142..09cc63b66e8157ef7e51847b16bf290e21a758d6 100644 (file)
@@ -32,12 +32,23 @@ import (
 func usage() {
        fmt.Fprintf(os.Stderr, nncp.UsageHeader())
        fmt.Fprintf(os.Stderr, "nncp-stat -- show queued Rx/Tx stats\n\n")
-       fmt.Fprintf(os.Stderr, "Usage: %s [options]\nOptions:\n", os.Args[0])
+       fmt.Fprintf(os.Stderr, "Usage: %s [options] [-pkt] [-node NODE]\nOptions:\n", os.Args[0])
        flag.PrintDefaults()
 }
 
+func jobPrint(xx nncp.TRxTx, job nncp.Job) {
+       fmt.Printf(
+               "\t%s %s %s (nice: %s)\n",
+               string(xx),
+               nncp.ToBase32(job.HshValue[:]),
+               humanize.IBytes(uint64(job.Size)),
+               nncp.NicenessFmt(job.PktEnc.Nice),
+       )
+}
+
 func main() {
        var (
+               showPkt   = flag.Bool("pkt", false, "Show packets listing")
                cfgPath   = flag.String("cfg", nncp.DefaultCfgPath, "Path to configuration file")
                nodeRaw   = flag.String("node", "", "Process only that node")
                spoolPath = flag.String("spool", "", "Override path to spool")
@@ -84,10 +95,14 @@ func main() {
                if nodeOnly != nil && *node.Id != *nodeOnly.Id {
                        continue
                }
+               fmt.Println(node.Name)
                rxNums := make(map[uint8]int)
                rxBytes := make(map[uint8]int64)
                for job := range ctx.Jobs(node.Id, nncp.TRx) {
                        job.Fd.Close()
+                       if *showPkt {
+                               jobPrint(nncp.TRx, job)
+                       }
                        rxNums[job.PktEnc.Nice] = rxNums[job.PktEnc.Nice] + 1
                        rxBytes[job.PktEnc.Nice] = rxBytes[job.PktEnc.Nice] + job.Size
                }
@@ -95,10 +110,12 @@ func main() {
                txBytes := make(map[uint8]int64)
                for job := range ctx.Jobs(node.Id, nncp.TTx) {
                        job.Fd.Close()
+                       if *showPkt {
+                               jobPrint(nncp.TRx, job)
+                       }
                        txNums[job.PktEnc.Nice] = txNums[job.PktEnc.Nice] + 1
                        txBytes[job.PktEnc.Nice] = txBytes[job.PktEnc.Nice] + job.Size
                }
-               fmt.Println(node.Name)
                var nice uint8
                for nice = 1; nice > 0; nice++ {
                        rxNum, rxExists := rxNums[nice]