def generate_url(hostname, port, path, ssl):
    """Generate the URL for accessing the BIND XML Statistics."""

    protocol = 'https' if ssl else 'http'
    path = path.lstrip('/')
    url = '{0}://{1}:{2}/{3}'.format(
        protocol,
        hostname,
        str(port),
        path,
        )

    return url