first, enter chef-shell:
$ chef-shell
loading configuration: none (standalone session)
Session type: standalone
Loading.........done.
This is the chef-shell.
Chef Version: 14.3.37
https://www.chef.io/
https://docs.chef.io/
run `help' for help, `exit' or ^D to quit.
Ohai2u irving@irving02.popovetsky.com!
chef (14.3.37)>
Let's see the total node object size:
chef (14.3.37)> node.to_s.bytesize
=> 29
What keys do we have?
chef (14.3.37)> node.keys
=> ["tags", "uptime_seconds", "uptime", "chef_packages", "languages", "network", "counters", "ipaddress", "macaddress", "ip6address", "kernel", "os", "os_version", "platform", "platform_version", "platform_build", "platform_family", "cpu", "memory", "dmi", "hostname", "machinename", "fqdn", "domain", "time", "command", "root_group", "hardware", "virtualization", "filesystem", "keys", "shells", "etc", "current_user", "docker", "ohai_time", "system_profile", "cloud", "chef_guid", "name", "chef_environment", "recipes", "expanded_run_list", "roles"]
How big are those keys, in bytes?
chef (14.3.37)> node.keys.each { |key| puts "key: #{key}, bytes: #{key.bytesize}" }
key: tags, bytes: 4
key: uptime_seconds, bytes: 14
key: uptime, bytes: 6
key: chef_packages, bytes: 13
key: languages, bytes: 9
key: network, bytes: 7
key: counters, bytes: 8
key: ipaddress, bytes: 9
key: macaddress, bytes: 10
key: ip6address, bytes: 10
key: kernel, bytes: 6
key: os, bytes: 2
key: os_version, bytes: 10
key: platform, bytes: 8
key: platform_version, bytes: 16
key: platform_build, bytes: 14
key: platform_family, bytes: 15
key: cpu, bytes: 3
key: memory, bytes: 6
key: dmi, bytes: 3
key: hostname, bytes: 8
key: machinename, bytes: 11
key: fqdn, bytes: 4
key: domain, bytes: 6
key: time, bytes: 4
key: command, bytes: 7
key: root_group, bytes: 10
key: hardware, bytes: 8
key: virtualization, bytes: 14
key: filesystem, bytes: 10
key: keys, bytes: 4
key: shells, bytes: 6
key: etc, bytes: 3
key: current_user, bytes: 12
key: docker, bytes: 6
key: ohai_time, bytes: 9
key: system_profile, bytes: 14
key: cloud, bytes: 5
key: chef_guid, bytes: 9
key: name, bytes: 4
key: chef_environment, bytes: 16
key: recipes, bytes: 7
key: expanded_run_list, bytes: 17
key: roles, bytes: 5
which are the largest keys?
Chef (14.3.37)> sorted_size = node.keys.sort { |key| key.to_s.bytesize }
=> ["languages", "fqdn", "tags", "domain", "uptime_seconds", "time", "uptime", "command", "ipaddress", "root_group", "kernel", "current_user", "cpu", "filesystem", "machinename", "cloud", "os", "hardware", "dmi", "shells", "platform_build", "ohai_time", "network", "name", "ip6address", "roles", "memory", "virtualization", "platform_version", "keys", "hostname", "etc", "macaddress", "docker", "chef_packages", "system_profile", "platform_family", "chef_guid", "counters", "chef_environment", "platform", "expanded_run_list", "os_version", "recipes"]