Parse the HEALTHCHECK command. https://docs.docker.com/engine/reference/builder/#/healthcheck
4666
function parseHealthcheck(cmd) {
    var words = parseWords(cmd.rest),
        cmdDirectiveIndex = words.indexOf("CMD"),        
        noneDirectiveIndex = words.indexOf("NONE");

    if (cmdDirectiveIndex === -1 && noneDirectiveIndex === -1) {
        cmd.error = 'A HEALTHCHECK instruction must specify either NONE, or a valid CMD and options';
        return false;
    } else if (cmdDirectiveIndex !== -1) {
        // Reject a CMD directive that doesn't preceed an actual command.
        if (cmdDirectiveIndex === words.length - 1) {
            cmd.error = 'A CMD directive must specify a command for the healthcheck to run';
            return false;
        }
        
        cmd.args = { command: words.slice(cmdDirectiveIndex + 1).join(" ") };

        if (cmdDirectiveIndex > 0) {
            // There are options specified, so let's verify they're valid.
            var cmdDirectiveOptions = words.slice(0, cmdDirectiveIndex),
                validCmdOptions = ["interval", "retries", "timeout", "start-period"];

            for (var i = 0; i < cmdDirectiveOptions.length; i++) {
                var match = /--([a-zA-Z0-9_-]+)=(\d+)/.exec(cmdDirectiveOptions[i]);
                if (!match) {
                    cmd.error = '"' + cmdDirectiveOptions[i] + '" isn\'t a syntactically valid CMD option';
                    return false;
                } else if (validCmdOptions.indexOf(match[1]) === -1) {
                    cmd.error = '"' + match[1] + '" isn\'t a valid CMD option';
                    return false;
                }

                cmd.args[match[1]] = match[2];
            }
        }
    } else if (noneDirectiveIndex !== -1) {
        if (words.length > 1) {
            cmd.error = 'The NONE directive doesn\'t support additional options';
            return false;
        }

        cmd.args = { isNone: true };
    }

    return true;
}
908407
def checked_run(cmd):
    """"""
    completed_process = run(cmd)
    if completed_process.returncode > 0:
        print("Command failed!  Hanging around in case someone needs a "
              "docker connection. (Ctrl-C to quit now)")
        time.sleep(300)
        raise RuntimeError
    return completed_process
952888
def diagnostics(self):
        ''
        # The builder's repr is not used in a command to avoid pointlessly
        # invalidating Docker's build cache.
        return self.step('Diagnostics', [
            self.comment('Builder {0}'.format(repr(self))),
            self.run(ShellQuoted('hostname')),
            self.run(ShellQuoted('cat /etc/issue || echo no /etc/issue')),
            self.run(ShellQuoted('g++ --version || echo g++ not installed')),
            self.run(ShellQuoted('cmake --version || echo cmake not installed')),
        ])
541347
def health(self, **kwargs):
        '''
        
        '''
        if not len(kwargs):
            raise ValueError('no resource provided')
        for resource, name in kwargs.iteritems():
            endpoint = 'health/{}/{}'.format(resource, name)
        return self._get(endpoint)
789175
def check_proper_status(hsh)
      proper = hsh[:proper]
      proper_f = hsh[:proper_f]
      status = 'invalid'
      status = proper != proper_f ? 'formatted' : 'unchanged' if proper && proper_f
      hsh[:proper_status] = status if status.present?
      hsh
    end
1097271
def run(self):
        

        result = {
            'help_file': self.help_file,
            'status': None
        }

        help_path = os.path.join(self.workflow.builder.df_dir, self.help_file)

        if not os.path.exists(help_path):
            self.log.info("File %s not found", help_path)
            result['status'] = self.NO_HELP_FILE_FOUND
            return result

        dockerfile = df_parser(self.workflow.builder.df_path, workflow=self.workflow)
        labels = Labels(dockerfile.labels)
        try:
            _, name = labels.get_name_and_value(Labels.LABEL_TYPE_NAME)
        except KeyError:
            name = ''
        maintainer = dockerfile.labels.get('maintainer', '')

        with open(help_path, 'r+') as help_file:
            lines = help_file.readlines()

            if not lines[0].startswith("% "):
                lines.insert(0, "%% %s (1) Container Image Pages\n" % name)
                lines.insert(1, "%% %s\n" % maintainer)
                lines.insert(2, "%% %s\n" % dt.fromtimestamp(atomic_reactor_start_time)
                             .strftime(format="%B %-d, %Y"))

                help_file.seek(0)
                help_file.truncate()
                help_file.writelines(lines)

                self.log.info("added metadata to %s for generating nicer manpages", help_path)

        man_path = os.path.join(self.workflow.builder.df_dir, self.man_filename)

        go_md2man_cmd = ['go-md2man', '-in={}'.format(help_path), '-out={}'.format(man_path)]

        try:
            check_output(go_md2man_cmd, stderr=STDOUT)
        except OSError as e:
            if e.errno == errno.ENOENT:
                raise RuntimeError(
                    "Help file is available, but go-md2man is not present in a buildroot")

            raise
        except CalledProcessError as e:
            raise RuntimeError("Error running %s: %r, exit code: %s, output: '%s'" % (
                e.cmd, e, e.returncode, e.output))

        if not os.path.exists(man_path):
            raise RuntimeError("go-md2man run complete, but man file is not found")

        # Include the help file in the docker file

        lines = dockerfile.lines

        content = 'ADD {0} /{0}'.format(self.man_filename)
        # put it before last instruction
        lines.insert(-1, content + '\n')

        dockerfile.lines = lines

        self.log.info("added %s", man_path)

        result['status'] = self.HELP_GENERATED
        return result
915840
def get_image_command(image):
    ''''''
    info = docker_inspect_or_pull(image)
    try:
        return info['Config']['Cmd']
    except KeyError as ke:
        raise DockerError('Failed to inspect image: JSON result missing key {}'.format(ke))
989715
function checkDocker() {
    if (this.abort || this.skipChecks) return;
    const done = this.async();

    shelljs.exec('docker -v', { silent: true }, (code, stdout, stderr) => {
        if (stderr) {
            this.log(
                chalk.red(
                    'Docker version 1.10.0 or later is not installed on your computer.\n' +
                        '         Read http://docs.docker.com/engine/installation/#installation\n'
                )
            );
            this.abort = true;
        } else {
            const dockerVersion = stdout.split(' ')[2].replace(/,/g, '');
            const dockerVersionMajor = dockerVersion.split('.')[0];
            const dockerVersionMinor = dockerVersion.split('.')[1];
            if (dockerVersionMajor < 1 || (dockerVersionMajor === 1 && dockerVersionMinor < 10)) {
                this.log(
                    chalk.red(
                        `${'Docker version 1.10.0 or later is not installed on your computer.\n' +
                            '         Docker version found: '}${dockerVersion}\n` +
                            '         Read http://docs.docker.com/engine/installation/#installation\n'
                    )
                );
                this.abort = true;
            } else {
                this.log.ok('Docker is installed');
            }
        }
        done();
    });
}
93399
def health():
    """"""
    up_time = time.time() - START_TIME
    response = dict(service=__service_id__,
                    uptime='{:.2f}s'.format(up_time))
    return response, HTTPStatus.OK
1346838
def node_healthy?(hostname, services = [], iterations = 60)
      print "Waiting for #{hostname} to become healthy"
      services = services.reject { |s| get_service_check(s).empty? }.freeze

      iterations.times do
        print '.'

        checks = hostname_health_checks(hostname)

        has_services = (services - checks.map { |c| c['ServiceName'] }).empty?
        passing_checks = checks.all? { |c| c['Status'] == 'passing' }

        if !checks.empty? && has_services && passing_checks
          unless services.empty?
            print " Services: #{services.join(', ').inspect} Healthy and".green
          end

          puts ' Node Healthy!'.green
          return true
        end

        sleep(6)
      end

      false
    end
724980
def parse(command)
      case command.class.name.downcase.to_sym #Array => :array
      when :array
        command.compact.join(' && ')
      when :string
        command.chomp
      else
        raise Trooper::MalformedCommandError, "Command Not a String or Array: #{command.inspect}"
      end
    end
886707
def get_services_health(self) -> dict:
        
        # Initialise
        services_health = {}

        # Get Service IDs
        services_ids = self._get_services()

        for service_id in services_ids:
            service_name = DC.get_service_name(service_id)

            # Check if the current and actual replica levels are the same
            if DC.get_replicas(service_id) != \
                    DC.get_actual_replica(service_id):
                services_health[service_name] = "Unhealthy"
            else:
                services_health[service_name] = "Healthy"

        return services_health
1326137
def health_check(self):
        """"""
        logger.debug('Health Check on file for: {namespace}'.format(
            namespace=self.namespace
        ))

        return os.path.isfile(self.data_file)
1216055
def health
      if state == "STARTED"
        healthy_count = running_instances
        expected = total_instances

        if expected > 0
          ratio = healthy_count / expected.to_f
          if ratio == 1.0
            "RUNNING"
          else
            "#{(ratio * 100).to_i}%"
          end
        else
          "N/A"
        end
      else
        state
      end
    rescue CFoundry::StagingError, CFoundry::NotStaged
      "STAGING FAILED"
    end
643131
def parse_procheck(quality_directory):
    

    # TODO: save as dict instead, offer df as option
    # TODO: parse for one file instead

    procheck_summaries = glob.glob(os.path.join(quality_directory, '*.sum'))

    if len(procheck_summaries) == 0:
        return pd.DataFrame()

    all_procheck = {}
    for summ in procheck_summaries:
        structure_id = os.path.basename(summ).split('.sum')[0]
        procheck_dict = {}
        with open(summ) as f_in:
            lines = (line.rstrip() for line in f_in) # All lines including the blank ones
            lines = (line for line in lines if line) # Non-blank lines
            for line in lines:
                if len(line.split()) > 1:
                    if line.split()[1] == 'Ramachandran':
                        procheck_dict['procheck_rama_favored'] = percentage_to_float(line.split()[3])
                        procheck_dict['procheck_rama_allowed'] = percentage_to_float(line.split()[5])
                        procheck_dict['procheck_rama_allowed_plus'] = percentage_to_float(line.split()[7])
                        procheck_dict['procheck_rama_disallowed'] = percentage_to_float(line.split()[9])
                    if line.split()[1] == 'G-factors':
                        procheck_dict['procheck_gfac_dihedrals'] = line.split()[3]
                        procheck_dict['procheck_gfac_covalent'] = line.split()[5]
                        procheck_dict['procheck_gfac_overall'] = line.split()[7]
        all_procheck[structure_id] = procheck_dict

    DF_PROCHECK = pd.DataFrame.from_dict(all_procheck, orient='index')

    return DF_PROCHECK
12352
public function doctorCheck() {
    $status = $this->getInspector()->getStatus();
    $this->printArrayAsTable($status);

    $checks = [
      AcsfCheck::class,
      BehatCheck::class,
      ComposerCheck::class,
      ConfigCheck::class,
      DbCheck::class,
      DevDesktopCheck::class,
      DrupalCheck::class,
      DrupalVmCheck::class,
      DrushCheck::class,
      FileSystemCheck::class,
      NodeCheck::class,
      PhpCheck::class,
      SettingsFilesCheck::class,
      SimpleSamlPhpCheck::class,
      WebUriCheck::class,
    ];

    $success = TRUE;
    foreach ($checks as $class) {
      /** @var \Acquia\Blt\Robo\Commands\Doctor\DoctorCheck $object */
      $object = new $class($this->getConfig(), $this->getInspector(), $this->getContainer()->get('executor'), $status);
      $object->performAllChecks();
      $this->problems = array_merge($this->problems, $object->getProblems());
      if ($object->wasErrorLogged()) {
        $success = FALSE;
      }
    }

    $this->printArrayAsTable($this->problems, ['Check', "Problem"]);
    if (!$success) {
      throw new BltException("BLT Doctor discovered one or more critical issues.");
    }
  }
90374
function parseDriveHealthData(driveHealthData) {
        var lines = driveHealthData.trim().split('\n');
        var statusArr = [];
        for (var i = 0; i < lines.length; i+=1) {
            var items = lines[i].trim().split(',');
            if (items[2] !== 'ok') {
                continue;
            }
            statusArr.push({
                name: items.shift(),
                status: items.pop() || 'Not Present' //if empty means drive not present
            });
        }
        return statusArr;
    }