def _get_match_groups(ping_output, regex):
    """
    Get groups by matching regex in output from ping command.
    """
    match = regex.search(ping_output)
    if not match:
        raise Exception('Invalid PING output:\n' + ping_output)
    return match.groups()