What are the commands for automatically repairing potential risks in the cluster when using TiUP deployment (recommended)?

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 关于使用 TiUP 部署(推荐)中 自动修复集群存在的潜在风险的命令包括哪些

| username: wangxunye

Regarding the commands for automatically repairing potential risks in the cluster when using TiUP deployment (recommended), do the following operations need to be done manually, or can they be completed automatically?
Check and configure operating system optimization parameters

| username: ddhe9527 | Original post link

The configurations that can be automatically fixed are all in the fixFailedChecks function. Those not in this function cannot be fixed automatically and must be configured manually.

| username: Raymond | Original post link

Excuse me, teacher, what does the function fixFailedChecks do with :operator.CheckNameSysService? What is it repairing?

| username: ddhe9527 | Original post link

// CheckServices checks if a service is running on the host
func CheckServices(ctx context.Context, e ctxt.Executor, host, service string, disable bool) *CheckResult {
    result := &CheckResult{
        Name: CheckNameSysService,
    }

    // check if the service exist before checking its status, ignore when non-exist
    stdout, _, err := e.Execute(
        ctx,
        fmt.Sprintf(
            "systemctl list-unit-files --type service | grep -i %s.service | wc -l", service),
        true)
    if err != nil {
        result.Err = err
        return result
    }
    if cnt, _ := strconv.Atoi(strings.Trim(string(stdout), "\
")); cnt == 0 {
        if !disable {
            result.Err = fmt.Errorf("service %s not found, should be installed and started", service)
        }
        result.Msg = fmt.Sprintf("service %s not found, ignore", service)
        return result
    }

    active, err := GetServiceStatus(ctx, e, service+".service")
    if err != nil {
        result.Err = err
    }

    switch disable {
    case false:
        if !strings.Contains(active, "running") {
            result.Err = fmt.Errorf("service %s is not running", service)
            result.Msg = fmt.Sprintf("start %s.service", service)
        }
    case true:
        if strings.Contains(active, "running") {
            result.Err = fmt.Errorf("service %s is running but should be stopped", service)
            result.Msg = fmt.Sprintf("stop %s.service", service)
        }
    }

    return result
}
| username: Raymond | Original post link

This should be to check whether there are any related TiDB component services on the relevant server, such as whether tidb-4000.service exists.