gpt4 book ai didi

time - 运行ansible-playbook时如何测量和显示任务所花费的时间?

转载 作者:行者123 更新时间:2023-12-04 11:38:20 43 4
gpt4 key购买 nike

我有一本剧本,在这本剧本中,有很多任务。我需要知道哪个任务花费了多少时间?

有什么解决办法吗?

最佳答案

添加 callback_whitelist = profile_tasks[default] ansible.cfg 中的部分

这是我的 ansible.cfg

[defaults]
inventory = hosts
callback_whitelist = profile_tasks
deprecation_warnings = False

这是我的剧本
- hosts: localhost
gather_facts: true
tasks:
- name: Sleep for 10 Sec
command: sleep 10

- name: Sleep for 5 Sec
command: sleep 5

- name: Sleep for 2 Sec
command: sleep 2

这是我的播放输出。
PLAY [localhost] ***************************************

TASK [Gathering Facts] *********************************
Thursday 28 May 2020 09:36:04 +0000 (0:00:00.038) 0:00:00.038 **********
ok: [localhost]

TASK [Sleep for 10 Sec] ********************************
Thursday 28 May 2020 09:36:07 +0000 (0:00:03.695) 0:00:03.733 **********
changed: [localhost]

TASK [Sleep for 5 Sec] *********************************
Thursday 28 May 2020 09:36:18 +0000 (0:00:11.166) 0:00:14.899 **********
changed: [localhost]

TASK [Sleep for 2 Sec] *********************************
Thursday 28 May 2020 09:36:24 +0000 (0:00:05.965) 0:00:20.865 **********
changed: [localhost]

PLAY RECAP *********************************************
localhost : ok=4 changed=3 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0

Thursday 28 May 2020 09:36:27 +0000 (0:00:02.878) 0:00:23.744 **********
===============================================================================
Sleep for 10 Sec------------------------------------------------ 11.17s
Sleep for 5 Sec------------------------------------------------- 5.97s
Gathering Facts------------------------------------------------- 3.70s
Sleep for 2 Sec ------------------------------------------------- 2.88s

这里最后显示了每个任务需要多少时间来完成游戏。

关于参数 callback_whitelist = profile_tasks的说明在官方ansible doc中找到...

https://docs.ansible.com/ansible/latest/plugins/callback.html#enabling-callback-plugins

https://docs.ansible.com/ansible/latest/plugins/callback.html#plugin-list

https://docs.ansible.com/ansible/latest/plugins/callback/profile_tasks.html

关于time - 运行ansible-playbook时如何测量和显示任务所花费的时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61948417/

43 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com