code: func (d *Daemon) CheckServiceTasksInState(service string, state swarm.TaskState, message string) func(*check.C) (interface{}, check.CommentInterface) {
  	return func(c *check.C) (interface{}, check.CommentInterface) {
  		tasks := d.GetServiceTasks(c, service)
  		var count int
  		for _, task := range tasks {
  			if task.Status.State == state {
  				if message == "" || strings.Contains(task.Status.Message, message) {
  					count++
  				}
  			}
  		}
  		return count, nil
  	}
  }
docs: // CheckServiceTasksInState returns the number of tasks with a matching state,
  // and optional message substring.