Fix crash if login/password is incorrect in rabbitmq plugin. Closes #260

Closes #260
This commit is contained in:
Eugene Dementiev 2015-10-13 21:15:12 +03:00 committed by Cameron Sparr
parent 2a9f31bfea
commit ccfa913186
1 changed files with 7 additions and 5 deletions

View File

@ -119,6 +119,10 @@ func (r *RabbitMQ) gatherServer(serv *Server, acc plugins.Accumulator) error {
return err
}
if overview.QueueTotals == nil || overview.ObjectTotals == nil || overview.MessageStats == nil {
return fmt.Errorf("Wrong answer from rabbitmq. Probably auth issue")
}
tags := map[string]string{"url": serv.URL}
if serv.Name != "" {
tags["name"] = serv.Name
@ -134,11 +138,9 @@ func (r *RabbitMQ) gatherServer(serv *Server, acc plugins.Accumulator) error {
acc.Add("exchanges", overview.ObjectTotals.Exchanges, tags)
acc.Add("queues", overview.ObjectTotals.Queues, tags)
if overview.MessageStats != nil {
acc.Add("messages_acked", overview.MessageStats.Ack, tags)
acc.Add("messages_delivered", overview.MessageStats.Deliver, tags)
acc.Add("messages_published", overview.MessageStats.Publish, tags)
}
nodes := make([]Node, 0)