From 9b87f7c1f136a7c63ccc92f91eec22f8fd8fcea3 Mon Sep 17 00:00:00 2001 From: Ken Hibino Date: Wed, 25 Dec 2019 20:29:58 -0800 Subject: [PATCH] Show processed/failed count and error rate in asynqmon stats command --- asynq.go | 1 - tools/asynqmon/cmd/stats.go | 16 +++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/asynq.go b/asynq.go index 4064f9d..59409d6 100644 --- a/asynq.go +++ b/asynq.go @@ -7,7 +7,6 @@ TODOs: - [P0] asynqmon kill , asynqmon killall - [P0] Pagination for `asynqmon ls` command - [P0] Show elapsed time for InProgress tasks (asynqmon ls inprogress) -- [P0] Processed, Failed count for today - [P0] Go docs + CONTRIBUTION.md + Github issue template + License comment - [P0] Redis Sentinel support - [P1] Add Support for multiple queues and priority diff --git a/tools/asynqmon/cmd/stats.go b/tools/asynqmon/cmd/stats.go index 7b2a0c5..fd3424f 100644 --- a/tools/asynqmon/cmd/stats.go +++ b/tools/asynqmon/cmd/stats.go @@ -58,14 +58,19 @@ func stats(cmd *cobra.Command, args []string) { os.Exit(1) } fmt.Println("QUEUES") + printQueues(stats) + fmt.Println() + + fmt.Printf("STATS FOR %s UTC\n", stats.Timestamp.UTC().Format("2006-01-02")) printStats(stats) fmt.Println() + fmt.Println("REDIS INFO") printInfo(info) fmt.Println() } -func printStats(s *rdb.Stats) { +func printQueues(s *rdb.Stats) { format := strings.Repeat("%v\t", 5) + "\n" tw := new(tabwriter.Writer).Init(os.Stdout, 0, 8, 2, ' ', 0) fmt.Fprintf(tw, format, "InProgress", "Enqueued", "Scheduled", "Retry", "Dead") @@ -74,6 +79,15 @@ func printStats(s *rdb.Stats) { tw.Flush() } +func printStats(s *rdb.Stats) { + format := strings.Repeat("%v\t", 3) + "\n" + tw := new(tabwriter.Writer).Init(os.Stdout, 0, 8, 2, ' ', 0) + fmt.Fprintf(tw, format, "Processed", "Failed", "Error Rate") + fmt.Fprintf(tw, format, "---------", "------", "----------") + fmt.Fprintf(tw, format, s.Processed, s.Failed, fmt.Sprintf("%.2f%%", float64(s.Failed)/float64(s.Processed)*100)) + tw.Flush() +} + func printInfo(info map[string]string) { format := strings.Repeat("%v\t", 5) + "\n" tw := new(tabwriter.Writer).Init(os.Stdout, 0, 8, 2, ' ', 0)