Get raw data about this worker.

        This is recorded in the :meth:`heartbeat` info, and can be
        retrieved by :meth:`TaskMaster.get_heartbeat`.  The dictionary
        includes keys ``worker_id``, ``host``, ``fqdn``, ``version``,
        ``working_set``, and ``memory``.

def environment(self):
        '''Get raw data about this worker.

        This is recorded in the :meth:`heartbeat` info, and can be
        retrieved by :meth:`TaskMaster.get_heartbeat`.  The dictionary
        includes keys ``worker_id``, ``host``, ``fqdn``, ``version``,
        ``working_set``, and ``memory``.

        '''
        hostname = socket.gethostname()
        aliases = ()
        ipaddrs = ()

        # This sequence isn't 100% reliable.  We might try a socket()
        # sequence like RedisBase._ipaddress(), or just decide that
        # socket.fqdn() and/or socket.gethostname() is good enough.
        try:
            ip = socket.gethostbyname(hostname)
        except socket.herror:
            # If you're here, then $(hostname) doesn't resolve.
            ip = None

        try:
            if ip is not None:
                hostname, aliases, ipaddrs = socket.gethostbyaddr(ip)
        except socket.herror:
            # If you're here, then $(hostname) resolves, but the IP
            # address that results in doesn't reverse-resolve.  This
            # has been observed on OSX at least.
            ipaddrs = (ip,)

        env = dict(
            worker_id=self.worker_id,
            parent=self.parent,
            hostname=hostname,
            aliases=tuple(aliases),
            ipaddrs=tuple(ipaddrs),
            fqdn=socket.getfqdn(),
            version=pkg_resources.get_distribution("rejester").version, # pylint: disable=E1103
            working_set=[(dist.key, dist.version) for dist in pkg_resources.WorkingSet()], # pylint: disable=E1103
            # config_hash=self.config['config_hash'],
            # config_json = self.config['config_json'],
            memory=psutil.virtual_memory(),
            pid=os.getpid(),
        )
        return env