chef-handler-elapsed-time 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +23 -19
- data/lib/chef/handler/elapsed_time.rb +14 -5
- metadata +1 -1
data/README.md
CHANGED
@@ -49,25 +49,29 @@ Example:
|
|
49
49
|
$ chef-client
|
50
50
|
...
|
51
51
|
...
|
52
|
-
[2012-10-
|
53
|
-
[2012-10-
|
54
|
-
[2012-10-
|
55
|
-
[2012-10-
|
56
|
-
[2012-10-
|
57
|
-
[2012-10-
|
58
|
-
[2012-10-
|
59
|
-
[2012-10-
|
60
|
-
[2012-10-
|
61
|
-
[2012-10-
|
62
|
-
[2012-10-
|
63
|
-
[2012-10-
|
64
|
-
[2012-10-
|
65
|
-
[2012-10-
|
66
|
-
[2012-10-
|
67
|
-
[2012-10-
|
68
|
-
[2012-10-
|
69
|
-
[2012-10-
|
70
|
-
[2012-10-
|
52
|
+
[2012-10-25T21:41:10+00:00] INFO: Chef Run complete in 5.067115612 seconds
|
53
|
+
[2012-10-25T21:41:10+00:00] INFO: Running report handlers
|
54
|
+
[2012-10-25T21:41:10+00:00] INFO: Resource Elapsed Time(0.02s per unit)
|
55
|
+
[2012-10-25T21:41:10+00:00] INFO: ======== ============
|
56
|
+
[2012-10-25T21:41:10+00:00] INFO: remote_directory[/srv/chef/handlers] -
|
57
|
+
[2012-10-25T21:41:10+00:00] INFO: chef_gem[chef-handler-elapsed-time]
|
58
|
+
[2012-10-25T21:41:10+00:00] INFO: chef_handler[Chef::Handler::ElapsedTime]
|
59
|
+
[2012-10-25T21:41:10+00:00] INFO: package[ntp] -------------------
|
60
|
+
[2012-10-25T21:41:10+00:00] INFO: package[ntpdate] -------------------
|
61
|
+
[2012-10-25T21:41:10+00:00] INFO: directory[/var/lib/ntp] -
|
62
|
+
[2012-10-25T21:41:10+00:00] INFO: directory[/var/log/ntpstats/] -
|
63
|
+
[2012-10-25T21:41:10+00:00] INFO: service[ntp] ------------------------------
|
64
|
+
[2012-10-25T21:41:10+00:00] INFO: template[/etc/ntp.conf] -----
|
65
|
+
[2012-10-25T21:41:10+00:00] INFO: execute[apt-get-update]
|
66
|
+
[2012-10-25T21:41:10+00:00] INFO: execute[apt-get update]
|
67
|
+
[2012-10-25T21:41:10+00:00] INFO: package[update-notifier-common] -------------------
|
68
|
+
[2012-10-25T21:41:10+00:00] INFO: execute[apt-get-update-periodic]
|
69
|
+
[2012-10-25T21:41:10+00:00] INFO: directory[/var/cache/local] -
|
70
|
+
[2012-10-25T21:41:10+00:00] INFO: directory[/var/cache/local/preseeding] -
|
71
|
+
[2012-10-25T21:41:10+00:00] INFO:
|
72
|
+
[2012-10-25T21:41:10+00:00] INFO: * '+' denotes a resource which updated this run
|
73
|
+
[2012-10-25T21:41:10+00:00] INFO: * '-' denotes a resource which did not update this run
|
74
|
+
[2012-10-25T21:41:10+00:00] INFO: Report handlers complete
|
71
75
|
|
72
76
|
Licence
|
73
77
|
=======
|
@@ -18,23 +18,32 @@ class Chef
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def report
|
21
|
-
max_time = all_resources.max_by{ |r| r.elapsed_time}.elapsed_time
|
22
|
-
|
23
|
-
max_resource_length
|
24
|
-
Chef::Log.info "%-#{max_resource_length}s Elapsed Time(%.2fs per unit)"%["Resource", max_time]
|
21
|
+
@max_time = all_resources.max_by{ |r| r.elapsed_time}.elapsed_time
|
22
|
+
@max_resource = all_resources.max_by{ |r| full_name(r).length}
|
23
|
+
Chef::Log.info "%-#{max_resource_length}s %s"%["Resource", "Elapsed Time"]
|
25
24
|
Chef::Log.info "%-#{max_resource_length}s %s"%["========", "============"]
|
26
25
|
all_resources.each do |r|
|
27
26
|
char = if r.updated then "+" else "-" end
|
28
|
-
bar = char * ( @config[:max_width] * (r.elapsed_time
|
27
|
+
bar = char * ( @config[:max_width] * (r.elapsed_time/@max_time))
|
29
28
|
Chef::Log.info "%-#{max_resource_length}s %s"%[full_name(r), bar]
|
30
29
|
end
|
31
30
|
Chef::Log.info ""
|
31
|
+
Chef::Log.info "Slowest Resource : #{full_name(@max_resource)} (%.6fs)"%[@max_time]
|
32
|
+
Chef::Log.info "Scale : %.6fs per unit width"%[unit_width]
|
32
33
|
Chef::Log.info " * '+' denotes a resource which updated this run"
|
33
34
|
Chef::Log.info " * '-' denotes a resource which did not update this run"
|
34
35
|
end
|
35
36
|
|
36
37
|
end
|
37
38
|
|
39
|
+
def unit_width
|
40
|
+
@max_time/@config[:max_width]
|
41
|
+
end
|
42
|
+
|
43
|
+
def max_resource_length
|
44
|
+
full_name(@max_resource).length
|
45
|
+
end
|
46
|
+
|
38
47
|
def full_name(resource)
|
39
48
|
"#{resource.resource_name}[#{resource.name}]"
|
40
49
|
end
|