From d6e309aa0133e0934eb16ca6000fabab060759cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 17 Aug 2021 15:29:38 +0200 Subject: [PATCH] Show alert count in lotus-miner info --- cmd/lotus-miner/info.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cmd/lotus-miner/info.go b/cmd/lotus-miner/info.go index f37952057..4c3d25e7b 100644 --- a/cmd/lotus-miner/info.go +++ b/cmd/lotus-miner/info.go @@ -32,6 +32,7 @@ import ( "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/types" lcli "github.com/filecoin-project/lotus/cli" + "github.com/filecoin-project/lotus/journal/alerting" ) var infoCmd = &cli.Command{ @@ -116,6 +117,21 @@ func infoCmdAct(cctx *cli.Context) error { fmt.Println() + alerts, err := minerApi.LogAlerts(ctx) + if err != nil { + return xerrors.Errorf("getting alerts: %w", err) + } + + activeAlerts := make([]alerting.Alert, 0) + for _, alert := range alerts { + if alert.Active { + activeAlerts = append(activeAlerts, alert) + } + } + if len(activeAlerts) > 0 { + fmt.Printf("%s (check %s)\n", color.RedString("⚠ %d Active alerts", len(activeAlerts)), color.YellowString("lotus-miner log alerts")) + } + err = handleMiningInfo(ctx, cctx, fullapi, minerApi) if err != nil { return err