模拟进程故障

    在创建进程故障实验前,可运行以下命令行查看 Chaosd 支持的进程故障类型:

    输出结果如下所示:

    1. Process attack related commands
    2. Usage:
    3. chaosd attack process [command]
    4. Available Commands:
    5. stop stop process, this action will stop the process with SIGSTOP
    6. Flags:
    7. -h, --help help for process
    8. Global Flags:
    9. --log-level string the log level of chaosd, the value can be 'debug', 'info', 'warn' and 'error'
    10. Use "chaosd attack process [command] --help" for more information about a command.

    目前 Chaosd 支持模拟进程被终止或暂停的故障。

    模拟进程被终止命令

    1. chaosd attack process kill -h

    输出结果如下所示:

    1. kill process, default signal 9
    2. Usage:
    3. chaosd attack process kill [flags]
    4. Flags:
    5. -h, --help help for kill
    6. -r, --recover-cmd string The command to be run when recovering experiment
    7. -s, --signal int The signal number to send (default 9)
    8. --log-level string the log level of chaosd. The value can be 'debug', 'info', 'warn' and 'error'
    9. --uid string the experiment ID

    模拟进程被终止相关配置说明

    模拟进程被终止示例

    1. chaosd attack process kill -p python

    输出结果如下所示:

    只有 signalSIGSTOP 的实验支持被恢复。

    模拟进程被暂停命令

    1. chaosd attack process stop -h

    输出结果如下所示:

    1. stop process, this action will stop the process with SIGSTOP
    2. Usage:
    3. chaosd attack process stop [flags]
    4. -h, --help help for stop
    5. -p, --process string The process name or the process ID
    6. Global Flags:
    7. --log-level string the log level of chaosd, the value can be 'debug', 'info', 'warn' and 'error'

    模拟进程被暂停相关配置说明

    模拟进程被暂停示例

    1. chaosd attack process stop -p python

    输出结果如下所示:

    1. Attack process python successfully, uid: 9cb6b3be-4f5b-4ecb-ae05-51050fcd0010

    使用服务模式创建实验

    要使用服务模式创建实验,请进行以下操作:

    1. 以服务模式运行 Chaosd。

      1. curl -X POST 172.16.112.130:31767/api/attack/process -H "Content-Type:application/json" -d '{fault-configuration}'

    在上述命令中,你需要按照故障类型在 fault-configuration 中进行配置。有关对应的配置参数,请参考下文中各个类型故障的相关参数说明和命令示例。

    注意

    在运行实验时,请注意保存实验的 UID 信息。当要结束 UID 对应的实验时,需要向 Chaosd 服务的路径 /api/attack/{uid} 发送 DELETE HTTP 请求。

    进程故障相关参数说明

    使用服务模式模拟进程故障示例

    进程被终止
    1. curl -X POST 172.16.112.130:31767/api/attack/process -H "Content-Type:application/json" -d '{"process":"12345","signal":15}'

    输出如下所示:

      进程被暂停
      1. curl -X POST 172.16.112.130:31767/api/attack/process -H "Content-Type:application/json" -d '{"process":"12345","signal":19}'

      输出如下所示:

      只有 signalSIGSTOP 的实验支持被恢复。