def check_red_hat_firewall_issue():
    '''
    Checking if a firewall is found on the device if firewall was found,
        trying to see if the agent port was added as exception
            if so restart the firewall
    :return:
    '''
    print_notice("Checking if firewalld is installed.")
    print_notice("systemctl status firewalld")
    firewall_status = subprocess.Popen(["systemctl", "status", "firewalld"], stdout=subprocess.PIPE)
    o, e = firewall_status.communicate()
    if e is not None:
        print_error("Error: could not check CentOS / RHEL 7 firewalld status.")
    else:
        if "running" in str(o):
            print_warning(
                "Warning: you have a firewall running on your linux machine this can prevent communication between the syslog daemon and the omsagent.")
            print_notice("Checking if firewall has exception for omsagent port [" + agent_port + "]")
            if validate_rh_firewall_exception():
                print_ok("Found exception in the firewalld for the omsagent port.[" + agent_port + "]")
            else:
                print_warning("Warning: no exception found for omsagent in the firewall")
                print_warning(
                    "You can add exception for the agent port[" + agent_port + "] by using the following commands:")
                print_warning("Add exception:")
                print_notice("sudo firewall-cmd --direct --permanent --add-rule ipv4 filter INPUT 0 -p tcp --dport " + agent_port + "  -j ACCEPT")
                print_warning("Reload the firewall:")
                print_notice("sudo firewall-cmd --reload")
                print_warning("Validate the exception was added in the configuration:")
                print_notice("sudo firewall-cmd --direct --get-rules ipv4 filter INPUT")
                print_warning("You can disable your firewall by using this command - not recommended:")
                print_notice("sudo systemctl stop firewalld")

    Checking if a firewall is found on the device if firewall was found,
        trying to see if the agent port was added as exception
            if so restart the firewall
    :return:
    
DataConnectors/CEF/cef_troubleshoot.py