def check_registration(threshold_percentage): mesos_state = get_mesos_master().state autoscaling_resources = load_system_paasta_config().get_cluster_autoscaling_resources() for resource in autoscaling_resources.values(): if resource['type'] == 'aws_spot_fleet_request': resource['sfr'] = get_sfr(resource['id'], region=resource['region']) instances = get_spot_fleet_instances(resource['id'], region=resource['region']) resource['sfr']['ActiveInstances'] = instances slaves = get_sfr_slaves(resource, mesos_state) if len(instances) == 0: continue else: percent_registered = float(float(len(slaves)) / float(len(instances))) * 100 if percent_registered < float(threshold_percentage): print "CRIT: Only found {0}% of instances in {1} registered in mesos. "\ "Please check for puppet or AMI baking problems!".format(percent_registered, resource['id']) return False print "OK: Found more than {0}% of instances registered for all paasta resources in this "\ "superregion".format(threshold_percentage) return True