【Chaos Mesh官方文档】Simulate Time Faults

这篇文档详细介绍了如何利用Chaosd工具来模拟时间偏移场景。实验可以在命令行模式或服务模式下创建。提供了创建时间故障实验的步骤,包括检查时间故障选项、创建实验的示例以及配置模拟时间故障的参数。例如,通过`chaosd attack clock -p $PID -t 11s`命令可以攻击指定进程并设置11秒的时间偏移。
摘要由CSDN通过智能技术生成

This document describes how to use Chaosd to simulate a time offset scenario. You can create experiments either in command-line mode or service mode.
Create experiments using command-line mode​

This section describes how to create time fault experiments using commands.

Before creating an experiment, you can run the following command to check the options of time faults:

chaosd attack clock -h

The result is as follows:

$ chaosd attack clock -h

clock skew

Usage:
chaosd attack clock attack [flags]

Flags:
-c, --clock-ids-slice string The identifier of the particular clock on which to act.More clock description in linux kernel can be found in man page of clock_getres, clock_gettime, clock_settime.Muti clock ids should be split with “,” (default “CLOCK_REALTIME”)
-h, --help help for clock
-p, --pid int Pid of target program.
-t, --time-offset string Specifies the length of time offset.

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

Quick Example​

Prepare test program:

cat > time.c << EOF
#include <stdio.h>
#include <time.h>
#include <unistd.h>
#include <sys/types.h>

int main() {
printf(“PID : %ld\n”, (long)getpid());
struct timespec ts;
for(;😉 {
clock_gettime(CLOCK_REALTIME, &ts);
printf(“Time : %lld.%.9ld\n”, (long long)ts.tv_sec, ts.tv_nsec);
sleep(10);
}
}
EOF

gcc -o get_time ./time.c

Then execute get_time and try to attack it. The following is an example:

chaosd attack clock -p $PID -t 11s

Configurations of simulating time faults​
Parameter Type Note Default value Required Example
timeOffset string Specifies the length of time offset. None Yes -5m
clockIds []string Specifies the ID of clock that will be offset. See the clock_gettime documentation for details. [“CLOCK_REALTIME”] No [“CLOCK_REALTIME”, “CLOCK_MONOTONIC”]
pid string The identifier of the process. None Yes 1
Create experiments using service mode​

(ongoing update)

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值