2017-09-15 06:24:41 +00:00
|
|
|
"""
|
|
|
|
Print the size of a typical SSH command line and the bootstrap code sent to new
|
|
|
|
contexts.
|
|
|
|
"""
|
|
|
|
|
|
|
|
import inspect
|
|
|
|
import zlib
|
|
|
|
|
2017-09-21 11:38:57 +00:00
|
|
|
import mitogen.fakessh
|
2017-09-15 06:24:41 +00:00
|
|
|
import mitogen.master
|
2018-02-12 10:02:59 +00:00
|
|
|
import mitogen.parent
|
2017-09-15 06:24:41 +00:00
|
|
|
import mitogen.ssh
|
|
|
|
import mitogen.sudo
|
|
|
|
|
|
|
|
broker = mitogen.master.Broker()
|
|
|
|
|
|
|
|
router = mitogen.core.Router(broker)
|
|
|
|
context = mitogen.master.Context(router, 0)
|
2017-09-27 08:32:01 +00:00
|
|
|
stream = mitogen.ssh.Stream(router, 0, hostname='foo')
|
2017-09-15 06:24:41 +00:00
|
|
|
broker.shutdown()
|
|
|
|
|
|
|
|
print 'SSH command size: %s' % (len(' '.join(stream.get_boot_command())),)
|
|
|
|
print 'Preamble size: %s (%.2fKiB)' % (
|
|
|
|
len(stream.get_preamble()),
|
|
|
|
len(stream.get_preamble()) / 1024.0,
|
|
|
|
)
|
|
|
|
|
|
|
|
for mod in (
|
|
|
|
mitogen.master,
|
2018-02-12 10:02:59 +00:00
|
|
|
mitogen.parent,
|
2017-09-15 06:24:41 +00:00
|
|
|
mitogen.ssh,
|
|
|
|
mitogen.sudo,
|
2017-09-21 11:38:57 +00:00
|
|
|
mitogen.fakessh,
|
2017-09-15 06:24:41 +00:00
|
|
|
):
|
2018-02-12 10:02:59 +00:00
|
|
|
sz = len(zlib.compress(mitogen.parent.minimize_source(inspect.getsource(mod))))
|
2017-09-15 06:24:41 +00:00
|
|
|
print '%s size: %s (%.2fKiB)' % (mod.__name__, sz, sz / 1024.0)
|