code: func GetServicesStatus(services []swarm.Service, nodes []swarm.Node, tasks []swarm.Task) map[string]ListInfo {
  	running := map[string]int{}
  	tasksNoShutdown := map[string]int{}
  
  	activeNodes := make(map[string]struct{})
  	for _, n := range nodes {
  		if n.Status.State != swarm.NodeStateDown {
  			activeNodes[n.ID] = struct{}{}
  		}
  	}
  
  	for _, task := range tasks {
  		if task.DesiredState != swarm.TaskStateShutdown {
  			tasksNoShutdown[task.ServiceID]++
  		}
  
  		if _, nodeActive := activeNodes[task.NodeID]; nodeActive && task.Status.State == swarm.TaskStateRunning {
  			running[task.ServiceID]++
  		}
  	}
  
  	info := map[string]ListInfo{}
  	for _, service := range services {
  		info[service.ID] = ListInfo{}
  		if service.Spec.Mode.Replicated != nil && service.Spec.Mode.Replicated.Replicas != nil {
  			if service.Spec.TaskTemplate.Placement != nil && service.Spec.TaskTemplate.Placement.MaxReplicas > 0 {
  				info[service.ID] = ListInfo{
  					Mode:     "replicated",
  					Replicas: fmt.Sprintf("%d/%d (max %d per node)", running[service.ID], *service.Spec.Mode.Replicated.Replicas, service.Spec.TaskTemplate.Placement.MaxReplicas),
  				}
  			} else {
  				info[service.ID] = ListInfo{
  					Mode:     "replicated",
  					Replicas: fmt.Sprintf("%d/%d", running[service.ID], *service.Spec.Mode.Replicated.Replicas),
  				}
  			}
  		} else if service.Spec.Mode.Global != nil {
  			info[service.ID] = ListInfo{
  				Mode:     "global",
  				Replicas: fmt.Sprintf("%d/%d", running[service.ID], tasksNoShutdown[service.ID]),
  			}
  		}
  	}
  	return info
  }
docs: // GetServicesStatus returns a map of mode and replicas