code: private Double fetchInstancesOnlineRatio(ObjectId collectorItemId) {
      int totalInstances = 0, totalInstancesOnline = 0;
      Double instancesOnlineScore = null;
  
      List<EnvironmentStatus> statuses = environmentStatusRepository
        .findByCollectorItemId(collectorItemId);
  
      if (null == statuses || statuses.isEmpty()) {
        return null;
      }
  
      for (EnvironmentStatus environmentStatus : statuses) {
        totalInstances++;
        if (environmentStatus.isOnline()) {
          totalInstancesOnline++;
        }
      }
      instancesOnlineScore = ((totalInstancesOnline * 100) / (double) totalInstances);
      LOGGER.info("totalInstances " + totalInstances + " totalInstancesOnline " + totalInstancesOnline + " instancesOnlineScore " + instancesOnlineScore);
  
      return instancesOnlineScore;
    }
docs: Calculate percentage of instances online
  
  @param collectorItemId Collector Item Id of deploy
  @return percentage of instances online