OpenText product name changes coming to the community soon! Learn more.

Wikis - Page

How to log novell-named service messages into one single file /var/opt/novell/log/named/named.run

2 Likes

 

Environment


Novell Open Enterprise Server 2018 SP2

Novell Open Enterprise Server 2018 SP1


Situation


novell-named service logs messages to /var/opt/novell/log/named/named.run and and also to syslog. Currently there is no way to disable logging messages of novell-named service to syslog.


Resolution


The shell script given here modifies the rsyslog configuration and stops the messages from novell-named service from getting logged into /var/log/messages. This script provides a way to disable messages to syslog. Messages will continue to be logged into /var/opt/novell/log/named/named.run


Examples


./control_named_system_logs.sh -d: To disable capturing of novell-named logs in /var/log/messages ./control_named_system_logs.sh -e: To enable capturing of novell-named logs in /var/log/messages ./control_named_system_logs.sh -h: Help

# This script updates the rsyslog configuration in a way that

# Whether for service novell-named, the logs are captured under /var/log/messages

# New configuration file, which gets created in process

FILE="/etc/rsyslog.d/dns-query-log.conf"

conf_changed=0



conf_already_exists(){

    if test -f "$FILE"; then

        return 1

    fi

   return 0

}



# Writing the logic into configuration file, to obstruct logs to /var/log/messages

write_configuration_file(){

    touch $FILE

    cat > $FILE <<EOF

if (\$programname contains 'named' or \$syslogtag == '[NCPL]:')

then {

     stop

}

EOF

[ $? -eq 0 ] && return 1 || return 0

}


main(){

    conf_already_exists

    exists=$?

    if [ "$exists" == "1"  ]; then

        rm $FILE

    fi  



    if [ "$ACTION" == "DISABLE" ]; then

        write_configuration_file

        conf_changed=$?

    elif [ "$ACTION" == "ENABLE" ]; then

        conf_changed=1

    fi



    if [ "$conf_changed" == "1" ]; then

        systemctl restart rsyslog.service

        if [ $? != 0 ]; then

            echo " Failure in rsyslog service restart, try it manually. "

        fi

    else

        echo " Failure in configuration change. Re-run the script"

    fi

}



case $1 in

    -e) ACTION=ENABLE

        ;;

    -d) ACTION=DISABLE

        ;;

    -h) echo "Options : "

        echo "  -e : To enable capturing of novell-named logs in /var/log/messages"

        echo "  -d : To disable capturing of novell-named logs in /var/log/messages"

        exit 0

        ;;

     *) echo " script usage: $(basename $0) [-e] [-d] [-h for help]" >&2

        exit 1

        ;;

esac


main

Extra information:

The above script can be downloaded from below link:

Labels:

Support Tips/Knowledge Docs
Support Tip
Comment List
Related
Recommended