Skip to content

Commit

Permalink
Fix crash if login/password is incorrect in rabbitmq plugin. Closes i…
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugene Dementiev committed Oct 13, 2015
1 parent 0bc76f0 commit e4e3e67
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions plugins/rabbitmq/rabbitmq.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}
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)

Expand Down

0 comments on commit e4e3e67

Please sign in to comment.