Testing if stats is present and it is a map

This commit is contained in:
Diptanu Choudhury
2016-05-14 01:20:51 -07:00
parent f2de4f2019
commit 9c60703e52

View File

@@ -2,6 +2,7 @@ package command
import (
"fmt"
"reflect"
"strconv"
"strings"
"time"
@@ -68,6 +69,10 @@ func (c *AgentCheckCommand) Run(args []string) int {
c.Ui.Output(fmt.Sprintf("unable to query agent info: %v", err))
return HealthCritical
}
if stats, ok := info["stats"]; !ok && (reflect.TypeOf(stats).Kind() == reflect.Map) {
c.Ui.Error("error getting stats from the agent api")
return 1
}
if _, ok := info["stats"]["nomad"]; ok {
return c.checkServerHealth(info["stats"], minPeers)
}