【Chaos Mesh官方文档】Simulate Process Faults

本文详细介绍了如何使用Chaosd在命令行和服务模式下创建实验,模拟进程被杀死或停止的情况。涉及kill和stop操作的配置、命令示例以及通过API进行服务模式下的故障注入。特别指出,只有使用SIGSTOP信号的实验可以恢复。
摘要由CSDN通过智能技术生成

This document describes how to use Chaosd to simulate process faults. The process faults use the Golang interface of the kill command to simulate the scenarios that the process is killed or stopped. You can create experiments either in the command-line mode or service mode.
Create experiments using the command-line mode​

Before creating an experiment, you can run the following command to see the process fault types that are supported by Chaosd:

chaosd attack process -h

The result is as follows:

Process attack related commands

Usage:
chaosd attack process [command]

Available Commands:
kill kill process, default signal 9
stop stop process, this action will stop the process with SIGSTOP

Flags:
-h, --help help for process

Global Flags:
–log-level string the log level of chaosd, the value can be ‘debug’, ‘info’, ‘warn’ and ‘error’

Use “chaosd attack process [command] --help” for more information about a command.

Currently, Chaosd supports simulating that a process is killed or stopped.
Killing a process using the command-line mode​
Commands for killing a process​

chaosd attack process kill -h

The result is as follows:

kill process, default signal 9

Usage:
chaosd attack process kill [flags]

Flags:
-h, --help help for kill
-p, --process string The process name or the process ID
-s, --signal int The signal number to send (default 9)

Global Flags:
–log-level string the log level of chaosd, the value can be ‘debug’, ‘info’, ‘warn’ and ‘error’

Configuration description for killing a process​
Configuration item Abbreviation Description Value
process p The name or the identifier of the process to be injected faults string; the default value is “”.
signal s The provided value of the process signal int; the default value is 9. Currently, only SIGKILL, SIGTERM, and SIGSTOP are supported.
Example for killing a process​

chaosd attack process kill -p python

The result is as follows:

Attack process python successfully, uid: 10e633ac-0a37-41ba-8b4a-cd5ab92099f9

note

Only the experiments whose signal is SIGSTOP can be recovered.
Stopping a process using the command-line mode​
Command for stopping a process​

chaosd attack process stop -h

The result is as follows:

stop process, this action will stop the process with SIGSTOP

Usage:
chaosd attack process stop [flags]

Flags:
-h, --help help for stop
-p, --process string The process name or the process ID

Global Flags:
–log-level string the log level of chaosd, the value can be ‘debug’, ‘info’, ‘warn’ and ‘error’

Configuration description of stopping a process​
Configuration item Abbreviation Description Value
process p The name or the identifier of the process to be stopped string; the default value is “”.
Example for stopping a process​

chaosd attack process stop -p python

The result is as follows:

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

Create experiments using the service mode​

To create experiments using the service mode, follow the instructions below:

Run Chaosd in the service mode:

chaosd server --port 31767

Send a POST HTTP request to the /api/attack/process path of the Chaosd service.

curl -X POST 172.16.112.130:31767/api/attack/process -H “Content-Type:application/json” -d ‘{fault-configuration}’

In the above command, you need to configure fault-configuration according to the fault types. For the corresponding parameters, refer to the parameters and examples of each fault type in the following sections.

note

When running an experiment, remember to record the UID of the experiment. When you want to end the experiment corresponding to the UID, you need to send a DELETE HTTP request to the /api/attack/{uid} path of the Chaosd service.
Simulate process faults using the service mode​
Parameters for simulating process faults​
Parameter Description Value
process The name or the identifier of the process to be injected faults string; the default value is “”.
signal The provided value of the process signal int; the default value is 9
Examples for simulating process faults using the service mode​

curl -X POST 172.16.112.130:31767/api/attack/process -H “Content-Type:application/json” -d ‘{“process”:“12345”,“signal”:15}’

The result is as follows:

{“status”:200,“message”:“attack successfully”,“uid”:“c3c519bf-819a-4a7b-97fb-e3d0814481fa”}

note

Only the experiments whose signal is SIGSTOP can be recovered.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值