有时,实例的性能不如我们希望的那样,而 cloud-init 封装了一个简单的工具来检查在启动和设置期间哪些操作花费了 cloud-init 的时间最长。

本主题将讨论在已部署实例上测试和调试 cloud-init 的一般方法。

启动时间分析 - cloud-init 分析

有时,实例的性能不如我们希望的那样,而 cloud-init 封装了一个简单的工具来检查在启动和设置期间哪些操作花费了 cloud-init 的时间最长。

脚本/usr/bin/cloud-init有一个 analyze 子命令analyze 将任何 cloud-init.log 文件解析为格式化和排序的事件。它允许对最昂贵的 cloud-init 操作进行详细分析,以确定 cloud-init 配置和设置中的长杆。这些子命令默认读取 /var/log/cloud-init.log。

  • analyze show 按阶段解析和组织 cloud-init.log 事件,并将每个子阶段粒度包含在时间增量报告中。
$ cloud-init analyze show -i my-cloud-init.log
-- Boot Record 01 --
The total time elapsed since completing an event is printed after the "@"
character.
The time the event takes is printed after the "+" character.

Starting stage: modules-config
|`->config-emit_upstart ran successfully @05.47600s +00.00100s
|`->config-snap_config ran successfully @05.47700s +00.00100s
|`->config-ssh-import-id ran successfully @05.47800s +00.00200s
|`->config-locale ran successfully @05.48000s +00.00100s
...
  • analyze dump 将 cloud-init.log 解析为事件记录并返回可用于其他报告需求的字典列表。
$ cloud-init analyze dump -i my-cloud-init.log
[
 {
           
  "description": "running config modules",
  "event_type": "start",
  "name": "modules-config",
  "origin": "cloudinit",
  "timestamp": 1510807493.0
 },...
  • analyze blame 将 cloud-init.log 解析为事件记录,并根据最高时间成本对其进行排序,以便快速评估可能需要改进的 cloud-init 区域。
$ cloud-init analyze blame -i my-cloud-init.log
-- Boot Record 11 --
     00.01300s (modules-final/config-scripts-per-boot)
     00.00400s (modules-final/config-final-message)
<
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值