2
0
mirror of https://github.com/hibiken/asynq.git synced 2024-12-25 23:32:17 +08:00

Update asynqmon

This commit is contained in:
Ken Hibino 2019-12-05 17:14:35 -08:00
parent f3b9745228
commit 5626670007
2 changed files with 10 additions and 12 deletions

3
.gitignore vendored
View File

@ -13,3 +13,6 @@
# Ignore examples for now # Ignore examples for now
/examples /examples
# Ignore command binary
/cmd/asynqmon/asynqmon

View File

@ -1,19 +1,17 @@
package main package main
import ( import (
"flag"
"fmt" "fmt"
"log" "log"
"os" "os"
"strings" "strings"
"text/tabwriter" "text/tabwriter"
"time"
"github.com/go-redis/redis/v7" "github.com/go-redis/redis/v7"
"github.com/hibiken/asynq/internal/rdb" "github.com/hibiken/asynq/internal/rdb"
) )
var pollInterval = flag.Duration("interval", 3*time.Second, "polling interval") // Example usage: watch -n5 asynqmon
func main() { func main() {
c := redis.NewClient(&redis.Options{ c := redis.NewClient(&redis.Options{
@ -22,15 +20,12 @@ func main() {
}) })
r := rdb.NewRDB(c) r := rdb.NewRDB(c)
for {
stats, err := r.CurrentStats() stats, err := r.CurrentStats()
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
printStats(stats) printStats(stats)
fmt.Println() fmt.Println()
time.Sleep(*pollInterval)
}
} }
func printStats(s *rdb.Stats) { func printStats(s *rdb.Stats) {