我正在使用tcl和expect为radius服务器编写负载测试脚本。 我从远程服务器上的脚本调用radclient,它与radius服务器一起构建。 脚本确实如下:
获取远程服务器IP - 将ssh生成到远程服务器 - 调用radclient - 使用radclient命令执行负载测试 - 需要将输出结果(如示例输出中所示)收集到变量中 - 从上一步的输出或变量中提取身份验证/秒为每秒事务数(TPS)
最后两步需要帮助:
来自radclient的示例输出:
*--> timetest 20 10 2 1 1
Cycles: 10, Repetitions: 2, Requests per Cycle: 10
Starting User Number: 1, Increment: 1
Current Repetition Number=1
Skipping Accounting On Request
Total Requests=100, Total Responses=100, Total Accepts=0 Total Not Accepts=100
1: Sending 100 requests and getting 100 responses took 449ms, or 0.00 authentications/sec
Current Repetition Number=2
Skipping Accounting On Request
Total Requests=100, Total Responses=100, Total Accepts=0 Total Not Accepts=100
2: Sending 100 requests and getting 100 responses took 471ms, or 0.00 authentications/sec
预期产出:
TPS achieved = 0
答案 0 :(得分:0)
您可以使用以下内容:
expect -re {([\d.]+) authentications/sec}
set authPerSec $expect_out(1,string)
puts "TPS achieved = $authPerSec"
但是,这并不是说提取的信息是正确的信息。例如,当针对您的测试数据运行时,由于所有重复,有两个地方您有authentications/sec
,因此很可能会失败。我们根本没有考虑到这一点!更复杂的模式可能会提取更多信息等等。
expect {
-re {([\d.]+) authentications/sec} {
set authPerSec $expect_out(1,string)
puts "TPS achieved #[incr count] = $authPerSec"
exp_continue
}
"bash$" {
# System prompt means stop expecting; tune for what you've got...
}
}
做正确的事有时会很复杂......