Syslog Interface Broken

A centralized log management solution for storing all your logs from any syslog-enabled device over the network.
Forum rules
1) This is a user forum for Synology users to share experience/help out each other: if you need direct assistance from the Synology technical support team, please use the following form:
https://myds.synology.com/support/suppo ... p?lang=enu
2) To avoid putting users' DiskStation at risk, please don't paste links to any patches provided by our Support team as we will systematically remove them. Our Support team will provide the correct patch for your DiskStation model.

Syslog Interface Broken

Postby burpsmirk » Mon Jan 09, 2012 3:26 pm

Since Diskstation Manager 3.2 was released, I've been using the syslog server package from the Synology repository. Everything was working fine and, although I didn't like the logs being stored in a DB rather than plain text, it was worth it in return for not having to re-install syslog-d everytime I upgrade DSM.

However, since installation the syslog DB has grown to approx 3.8GB and the syslog interface in DSM began first returning results incredibly slowly, and now returns no results at all (after a long delay) regardless of search criteria. The timestamp on the syslog DB is current, implying that syslog events are still logging, but I have no way to view them now the UI is broken.

Any help would be greatly appreciated.

DS is DS109, DSM 3.2-1922 (no newer build indicates a fix fo rthis problem).
burpsmirk
I'm New!
I'm New!
 
Posts: 6
Joined: Mon Jan 09, 2012 3:15 pm

Re: Syslog Interface Broken

Postby burpsmirk » Wed Jan 11, 2012 10:56 am

Well it seems that, whilst the UI continues to show no entries, the 'save to plain text' feature does attempt to share the entire log file.

However, across a wired gigabit LAN, it is downloading at a speed of approximately 120kB/sec, which is hardly practical.

I'll continue to post if I make any further progress...
burpsmirk
I'm New!
I'm New!
 
Posts: 6
Joined: Mon Jan 09, 2012 3:15 pm

Re: Syslog Interface Broken

Postby burpsmirk » Wed Jan 11, 2012 4:05 pm

Tried updating /usr/syno/etc/synosyslog/syslog.d/syno.conf with the following lines and restarted syslog (via rc.d script) to at least send a copy of the syslog events to a readable store, but no joy.

Code: Select all
destination d_router { file("/volume1/logs/router_$YEAR.$MONTH.$DAY.log"); };
log { source(s_syno_net); filter(f_syno_nonemptymsg); destination(d_router); flags(flow_control); };

Can anyone help?
burpsmirk
I'm New!
I'm New!
 
Posts: 6
Joined: Mon Jan 09, 2012 3:15 pm

Re: Syslog Interface Broken

Postby burpsmirk » Wed Jan 11, 2012 4:10 pm

Dowloading the log file in plain text has now slowed to approximately 18kB/sec and after several hours has not even made 200MB yet. 3.8GB is going to take a very long time indeed!

This really needs to be corrected - the previous implementation was more useful than this.
burpsmirk
I'm New!
I'm New!
 
Posts: 6
Joined: Mon Jan 09, 2012 3:15 pm

Re: Syslog Interface Broken

Postby burpsmirk » Mon Feb 13, 2012 12:14 pm

In case anyone else gets the same problem, I had this back from Synology support:

Now this is a known issue and the engineer will improve the syslog server function to avoid this issue. ( slow response and timeout when syslog db reaches 5GB )

Before next formal release, please help us replace attached shell scripts to avoid this issue.

  1. mv /usr/local/synosyslog/scripts/runscript.sh /usr/local/synosyslog/scripts/runscript.sh.bak
  2. cp db-rotate.sh /usr/local/synosyslog/scripts/
  3. cp runscript.sh /usr/local/synosyslog/scripts/
  4. Restart syslog service and log database will start to rotate with size


This worked for me, but I would recommend dropping the ROTATE_SIZE defined in runscript.sh from 5GB to perhaps 2, as even 2 gets a bit slow.

Hopefully DSM 4 will be able to handle large log files. The searching could be improved too... :wink:

runscript.sh:
Code: Select all
#!/bin/sh

#Conf dir/file definition
PATH_SYSLOGNG_CONF=/usr/syno/etc/synosyslog
PATH_SYSLOGNG_PKG_DIR=/usr/local/synosyslog
PATH_SYSLOGNG_CONF_FOLDER=${PATH_SYSLOGNG_CONF}/syslog.d
PATH_SYSLOGNG_TEMPLATE_FOLDER=${PATH_SYSLOGNG_PKG_DIR}/etc/template
PATH_SYSLOGNG_BIN_FOLDER=/usr/sbin
FILE_SYSLOGNG_SETTING=${PATH_SYSLOGNG_CONF}/setting.conf
FILE_SYSLOGNG_PID=/var/run/syslogng.pid
FILE_SYSLOGD_PID=/var/run/syslogd.pid
FILE_LOGMONI_PID=/var/run/logmonitord.pid
FILE_SYSLOGMAIL_PID=/var/run/syslogmaild.pid
FILE_SYNOSYSLOG_CONF=${PATH_SYSLOGNG_CONF_FOLDER}/syno.conf
FILE_SYNOSYSLOG_SQL=${PATH_SYSLOGNG_PKG_DIR}/scripts/loginfo.sql

FILE_SIZEROTATED_PID=/var/run/syslogsvrdbrotate.pid

#Global variables
SYSLOGNG_SERVER_ENABLE=0
SYSLOGNG_SERVER_PORT=1234
SYSLOGNG_SERVER_TRANS_MODE=tcp
SYSLOGNG_SERVER_SSL=0
SYSLOGNG_SERVER_LOG_ROTATE_TIME=0
SYSLOGNG_SERVER_MAIL_ENABLE=0
SYSLOGNG_SERVER_MAIL_FILETER=""
SYSLOGNG_SERVER_DB_LOC=""
SYSLOGNG_SERVER_DB_PATH=""
SYSLOGNG_SERVER_CA_KEY_PATH="/usr/syno/etc/ssl/ssl.key/server.key"
SYSLOGNG_SERVER_CA_FILE_PATH="/usr/syno/etc/ssl/ssl.crt/server.crt"
SYSLOGNG_SERVER_INTER_FILETER=""

PROCESS_ALIVE=0
PROCESS_PID=0

SyslogSettingGet(){
    if [ -f "${FILE_SYSLOGNG_SETTING}" ]; then
   SYSLOGNG_SERVER_ENABLE=`/bin/get_key_value ${FILE_SYSLOGNG_SETTING} server_enable`
   SYSLOGNG_SERVER_PORT=`/bin/get_key_value ${FILE_SYSLOGNG_SETTING} server_port`
   SYSLOGNG_SERVER_TRANS_MODE=`/bin/get_key_value ${FILE_SYSLOGNG_SETTING} server_trans`
   SYSLOGNG_SERVER_SSL=`/bin/get_key_value ${FILE_SYSLOGNG_SETTING} server_ssl`
   SYSLOGNG_SERVER_LOG_ROTATE_TIME=`/bin/get_key_value ${FILE_SYSLOGNG_SETTING} server_log_rotate_time`
   SYSLOGNG_SERVER_MAIL_ENABLE=`/bin/get_key_value ${FILE_SYSLOGNG_SETTING} server_enable_mail`
   SYSLOGNG_SERVER_MAIL_FILETER=`/bin/get_key_value ${FILE_SYSLOGNG_SETTING} server_mail_filter`
   SYSLOGNG_SERVER_DB_LOC=`/bin/get_key_value ${FILE_SYSLOGNG_SETTING} server_db_loc`
   SYSLOGNG_SERVER_DB_PATH=`/bin/get_key_value ${FILE_SYSLOGNG_SETTING} server_db_path`
   SYSLOGNG_SERVER_CA_KEY_PATH=`/bin/get_key_value ${FILE_SYSLOGNG_SETTING} server_ca_key`
   SYSLOGNG_SERVER_CA_FILE_PATH=`/bin/get_key_value ${FILE_SYSLOGNG_SETTING} server_ca_file`
   SYSLOGNG_SERVER_INTER_FILETER=`/bin/get_key_value ${FILE_SYSLOGNG_SETTING} server_internal_filter`
    else
   echo "Syslog setting file does not exist!";
   exit 1;
    fi
}

CheckIfDaemonAlive(){
    PROCESS_ALIVE=0
    if [ -f "$1" ]; then
   PROCESS_PID=`cat $1`
   kill -0 ${PROCESS_PID}
        if [ "0" = "$?" ]; then
       PROCESS_ALIVE=1
   fi
    fi
}

SourceProcess(){
    #Copy syslog system conf
    cp -rf ${PATH_SYSLOGNG_TEMPLATE_FOLDER}/system.conf ${PATH_SYSLOGNG_CONF}

    if [ "tcp" = "${SYSLOGNG_SERVER_TRANS_MODE}" ]; then
   if [ "1" = "${SYSLOGNG_SERVER_SSL}" ]; then
       TEMPLATE_FILE=${PATH_SYSLOGNG_TEMPLATE_FOLDER}/src_net_enc.template
       cat $TEMPLATE_FILE | sed -e "s/__SYNO_PORT__/${SYSLOGNG_SERVER_PORT}/" | sed -e "s=__SYNO_CA_KEY_PATH__=${SYSLOGNG_SERVER_CA_KEY_PATH}=" | sed -e "s=__SYNO_CA_FILE_PATH__=${SYSLOGNG_SERVER_CA_FILE_PATH}=" >> ${FILE_SYNOSYSLOG_CONF}
   else
       TEMPLATE_FILE=${PATH_SYSLOGNG_TEMPLATE_FOLDER}/src_net.template
       cat $TEMPLATE_FILE | sed -e "s/__SYNO_PORT__/${SYSLOGNG_SERVER_PORT}/" >> ${FILE_SYNOSYSLOG_CONF}

   fi
    else
   TEMPLATE_FILE=${PATH_SYSLOGNG_TEMPLATE_FOLDER}/src_net_udp.template
   cat $TEMPLATE_FILE | sed -e "s/__SYNO_PORT__/${SYSLOGNG_SERVER_PORT}/" >> ${FILE_SYNOSYSLOG_CONF}
    fi
}

MailDestProcess(){
    if [ "1" != "${SYSLOGNG_SERVER_MAIL_ENABLE}" ]; then
   return;
    fi
   
    cat ${PATH_SYSLOGNG_TEMPLATE_FOLDER}/dest_mail.template >> ${FILE_SYNOSYSLOG_CONF}
}

DestProcess(){
    cat ${PATH_SYSLOGNG_TEMPLATE_FOLDER}/dest_db.template | sed -e "s=__SYNO_DB_PATH__=${LOGDB_PATH}=" >> ${FILE_SYNOSYSLOG_CONF}
    MailDestProcess;
}

MailLogProcess(){
    if [ "1" != "${SYSLOGNG_SERVER_MAIL_ENABLE}" ]; then
   return;
    fi
 
    if [ ! -z ${SYSLOGNG_PRIOR_STRING} ]; then
   cat ${PATH_SYSLOGNG_TEMPLATE_FOLDER}/log_send_mail.template | sed -e "s=_SYNO_FILTER_=filter(f_syno_mail);=g" >> ${FILE_SYNOSYSLOG_CONF}
    else
   cat ${PATH_SYSLOGNG_TEMPLATE_FOLDER}/log_send_mail.template | sed -e "s/_SYNO_FILTER_//g" >> ${FILE_SYNOSYSLOG_CONF}
    fi

}

InternalLogProcess(){
    if [ -n ${SYSLOGNG_INTERNAL_PRIOR_STRING} ]; then
   cat ${PATH_SYSLOGNG_TEMPLATE_FOLDER}/log_sys_to_db_file.template | sed -e "s=_SYNO_FILTER_=filter(f_syno_internal);=g" >> ${FILE_SYNOSYSLOG_CONF}
    else
   cat ${PATH_SYSLOGNG_TEMPLATE_FOLDER}/log_sys_to_db_file.template | sed -e "s/_SYNO_FILTER_//g" >> ${FILE_SYNOSYSLOG_CONF}
    fi
}

NetLogProcess(){
    cat ${PATH_SYSLOGNG_TEMPLATE_FOLDER}/log_net_to_db.template >> ${FILE_SYNOSYSLOG_CONF}
}

LogProcess(){
    NetLogProcess;
    InternalLogProcess;
    MailLogProcess;
}

MailFilterProcess(){
    if [ "1" != "${SYSLOGNG_SERVER_MAIL_ENABLE}" ]; then
   return;
    fi

    #1. Get mail level setting from setting.conf
    #2. Compose of filter string for syslog-ng
    #3. Generate log conf file for mailing
    SYSLOGNG_PRIOR_LIST=`echo ${SYSLOGNG_SERVER_MAIL_FILETER} | sed 's/,/ /g'`
    SYSLOGNG_PRIOR_STRING=""
    for prio in $SYSLOGNG_PRIOR_LIST
    do
   if [ ! -z "${prio}" ]; then
       if [ -z ${SYSLOGNG_PRIOR_STRING} ]; then
      SYSLOGNG_PRIOR_STRING="${prio}"
       else
      SYSLOGNG_PRIOR_STRING="${SYSLOGNG_PRIOR_STRING},${prio}"
       fi
   fi
    done
   
    if [ ! -z ${SYSLOGNG_PRIOR_STRING} ]; then
   cat ${PATH_SYSLOGNG_TEMPLATE_FOLDER}/filter_prior_mail.template | sed -e "s/_SYNO_PRIORITY_/${SYSLOGNG_PRIOR_STRING}/g" >> ${FILE_SYNOSYSLOG_CONF}
    fi
}

InternalFilterProcess(){
    #1. Get internal level setting from setting.conf
    #2. Compose of filter string for syslog-ng
    #3. Generate log conf file for mailing
    SYSLOGNG_INTERNAL_PRIOR_LIST=`echo ${SYSLOGNG_SERVER_INTER_FILETER} | sed 's/,/ /g'`
    SYSLOGNG_INTERNAL_PRIOR_STRING=""
    for prio in $SYSLOGNG_INTERNAL_PRIOR_LIST
    do
   if [ -n "${prio}" ]; then
       if [ -z ${SYSLOGNG_INTERNAL_PRIOR_STRING} ]; then
      SYSLOGNG_INTERNAL_PRIOR_STRING="${prio}"
       else
      SYSLOGNG_INTERNAL_PRIOR_STRING="${SYSLOGNG_INTERNAL_PRIOR_STRING},${prio}"
       fi
   fi
    done
   
    if [ -n ${SYSLOGNG_INTERNAL_PRIOR_STRING} ]; then
   cat ${PATH_SYSLOGNG_TEMPLATE_FOLDER}/filter_prior_internal.template | sed -e "s/_SYNO_PRIORITY_/${SYSLOGNG_INTERNAL_PRIOR_STRING}/g" >> ${FILE_SYNOSYSLOG_CONF}
    fi
}

FilterProcess(){
    InternalFilterProcess;
    MailFilterProcess;
}

SyslogdStop(){
    if [ -e ${FILE_SYSLOGD_PID} ]; then
   SYSLOGD_PID=`cat ${FILE_SYSLOGD_PID}`
   kill -0 ${SYSLOGD_PID}
        if [ "0" = "$?" ]; then
       kill ${SYSLOGD_PID}
       sleep 1
   fi
   rm -rf ${FILE_SYSLOGD_PID} > /dev/null 2>&1
    fi
   
}

SyslogdStart(){
     if [ -e ${FILE_SYSLOGD_PID} ]; then
   SYSLOGD_PID=`cat ${FILE_SYSLOGD_PID}`
   kill -0 ${SYSLOGD_PID}
        if [ "0" = "$?" ]; then
       return;
   fi
   rm -rf ${FILE_SYSLOGD_PID} > /dev/null 2>&1
    fi

    if [ ! -L /dev/log ]; then
   # might complain for r/o root f/s
   ln -sf /var/run/log /dev/log
    fi

    /sbin/syslogd -S
}

SyslogngStart(){
    /sbin/syslog-ng --module-path=/lib/syslogmod --pidfile=${FILE_SYSLOGNG_PID} --cfgfile=${PATH_SYSLOGNG_CONF}/system.conf --persist-file="/tmp/syslog-ng.persist" --control="/tmp/syslog-ng.ctl"
}

LogMoniStart(){
    ${PATH_SYSLOGNG_BIN_FOLDER}/logmonitord
}

LogMailStart(){
    ${PATH_SYSLOGNG_BIN_FOLDER}/syslogmaild
}

SizeRotatedStart(){
   CHK_INTERVAL=60;
   ROTATE_SIZE=5368709120;
   ${PATH_SYSLOGNG_PKG_DIR}/scripts/db-rotate.sh "$SYSLOGNG_SERVER_DB_PATH" "$CHK_INTERVAL" "$ROTATE_SIZE" &
}
SizeRotatedStop(){
   CheckIfDaemonAlive ${FILE_SIZEROTATED_PID}
   if [ "1" = "$PROCESS_ALIVE" ]; then
      kill -9 ${PROCESS_PID}
      sleep 1;
   fi
}

ConfDataClear(){
    rm -rf ${PATH_SYSLOGNG_CONF_FOLDER} > /dev/null 2>&1
    rm -rf ${PATH_SYSLOGNG_CONF}/system.conf > /dev/null 2>&1
}

ConfFolderCreate(){
    mkdir -p ${PATH_SYSLOGNG_CONF_FOLDER}
}

ShareExistCheck(){
   SHARE_EXIST=0
   SHARE_PATH=`/usr/syno/sbin/synoshare --get "${SYSLOGNG_SERVER_DB_LOC}" | grep "Path ......" | sed -e 's/^.*\[\(.*\)\]/\1/g'`
   if [ -n "${SHARE_PATH}" ]; then
      SHARE_EXIST=1
      LOGDB_PATH="${SHARE_PATH}/.SYNOSYSLOGDB"
      if [ -d "${SHARE_PATH}" ]; then
         if [ "$LOGDB_PATH" = "$SYSLOGNG_SERVER_DB_PATH" ]; then
            if [ ! -f "$SYSLOGNG_SERVER_DB_PATH" ]; then
               /usr/syno/bin/sqlite3 "$SYSLOGNG_SERVER_DB_PATH" < "$FILE_SYNOSYSLOG_SQL" > /dev/null 2>&1
            fi
         fi
      fi
   fi

   LOGDB_PATH="$SYSLOGNG_SERVER_DB_PATH"
}

#At begining, acquire all server settings
SyslogSettingGet;

case $1 in
    start)
   echo "Syslog-ng server start..."

   #Check if server is enable
   case ${SYSLOGNG_SERVER_ENABLE} in
   [Yy][Ee][Ss])
      #Restart syslog-ng daemon
      CheckIfDaemonAlive ${FILE_SYSLOGNG_PID}
      if [ "1" = "$PROCESS_ALIVE" ]; then
         kill ${PROCESS_PID}
         sleep 1;
      fi
      ShareExistCheck;
      if [ "0" = "${SHARE_EXIST}" ]; then
         logger -p 3 "Syslog-ng has no usable share!"
      fi
      ConfDataClear;
      ConfFolderCreate;
      SourceProcess;
      FilterProcess;
      DestProcess;
      LogProcess;
      SyslogdStop;
      SyslogngStart;

      #Restart log monitor daemon
      CheckIfDaemonAlive ${FILE_LOGMONI_PID}
      if [ "1" = "$PROCESS_ALIVE" ]; then
         kill ${PROCESS_PID}
         sleep 1;
      fi
      LogMoniStart;

      #Restart log mail daemon
      CheckIfDaemonAlive ${FILE_SYSLOGMAIL_PID}
      if [ "1" = "$PROCESS_ALIVE" ]; then
         kill ${PROCESS_PID}
         sleep 1;
      fi
      LogMailStart;

        SizeRotatedStop;
       SizeRotatedStart;
   ;;
   *)
       exit 0;
   ;;
   esac
    ;;
    stop)
   echo "Syslog-ng server stop..."
   CheckIfDaemonAlive ${FILE_SYSLOGNG_PID}
   if [ "1" = "$PROCESS_ALIVE" ]; then
       kill ${PROCESS_PID}
       sleep 1;
   fi
   
   CheckIfDaemonAlive ${FILE_LOGMONI_PID}   
   if [ "1" = "$PROCESS_ALIVE" ]; then
       kill ${PROCESS_PID}
       sleep 1;
   fi
      
   CheckIfDaemonAlive ${FILE_SYSLOGMAIL_PID}   
   if [ "1" = "$PROCESS_ALIVE" ]; then
       kill ${PROCESS_PID}
       sleep 1;
   fi

    SizeRotatedStop;
   
   ConfDataClear;
   SyslogdStart;
    ;;
    restart)
   echo "Syslog-ng server restart..."

   #Check if server is enable
   case ${SYSLOGNG_SERVER_ENABLE} in
   [Yy][Ee][Ss])
       ConfDataClear;
       ConfFolderCreate;
       ShareExistCheck;
       if [ "0" = "${SHARE_EXIST}" ]; then
      logger -p 3 "Syslog-ng has no usable share!"
       fi

       SourceProcess;
       FilterProcess;
       DestProcess;
       LogProcess;
       SyslogdStop;
       CheckIfDaemonAlive ${FILE_SYSLOGNG_PID};
       if [ "1" = "${PROCESS_ALIVE}" ]; then
      kill -HUP ${PROCESS_PID}
       else
      SyslogngStart;
       fi
   
       CheckIfDaemonAlive ${FILE_LOGMONI_PID}   
       if [ "1" = "${PROCESS_ALIVE}" ]; then
      kill -HUP ${PROCESS_PID}
       else
      LogMoniStart;
       fi
      
       CheckIfDaemonAlive ${FILE_SYSLOGMAIL_PID}   
       if [ "1" = "${PROCESS_ALIVE}" ]; then
      kill ${PROCESS_PID}
      sleep 1;
       fi

       if [ "1" == ${SYSLOGNG_SERVER_MAIL_ENABLE} ]; then
      LogMailStart;
       fi

        SizeRotatedStop;
       SizeRotatedStart;
   ;;
   *)
       exit 0
   ;;
   esac
    ;;
    *)
   echo "Usage: $0 start|stop|restart"
    ;;
esac


db-rotate.sh:
Code: Select all
#!/bin/sh

trap 'echo "Syslog svr db rotation is traped"; rm -rf "${PID_PATH}"; exit 0' SIGINT SIGTERM

PID_PATH=/var/run/syslogsvrdbrotate.pid
SYSLOGNG_PID_PATH=/var/run/syslogng.pid

PATH_SYSLOGNG_PKG_DIR=/usr/local/synosyslog
FILE_SYNOSYSLOG_SQL=${PATH_SYSLOGNG_PKG_DIR}/scripts/loginfo.sql

DB_PATH=$1
CHK_INTERVAL=$2
SIZE_LIMIT=$3

if [ "3" != "$#" ]; then
   echo "Invalid argument!";
   echo "$0& <DB_PATH> <CHK_INTERVAL(sec)> <SIZE_LIMIT(byte)>"
   exit 1;
fi

check_if_process_exist()
{
   if [ -e ${PID_PATH} ]; then
       local PID=`cat "$PID_PATH"`
       kill -0 $PID
       if [ "0" == "$?" ]; then
          return 1;
       else
          return 0;
       fi
   fi
}

gen_pidfile()
{
   echo $$ > ${PID_PATH};
}

#main function

check_if_process_exist;
if [ "1" = "$?" ]; then
   echo "process exist!";
   exit 1;
fi

gen_pidfile;

while [ 1 ]
do
   local cur_size=0;
   
   if [ -f "${DB_PATH}" ]; then
      cur_size=`stat -t "$DB_PATH" | awk -F " " '{print $2;}'`
      if [ ${cur_size} -ge ${SIZE_LIMIT} ]; then
         echo "Rotate syslog db file";
                        IDX=0;
                        while [ 1 ]; do
                            if [ -f "${DB_PATH}.${IDX}" ]; then
                                IDX=$(($IDX+1))
                            else
                                break;
                            fi
                        done
                        mv "${DB_PATH}" "${DB_PATH}.${IDX}"

         echo "Create new database";
         /usr/syno/bin/sqlite3 "${DB_PATH}" < "$FILE_SYNOSYSLOG_SQL" > /dev/null 2>&1

         echo "HUP syslog-ng";
         kill -HUP `cat "$SYSLOGNG_PID_PATH"`
      fi
   fi

   sleep ${CHK_INTERVAL};
done



burpsmirk
I'm New!
I'm New!
 
Posts: 6
Joined: Mon Jan 09, 2012 3:15 pm

Re: Syslog Interface Broken

Postby burpsmirk » Sun May 20, 2012 10:52 pm

I'm still not happy with the DB logging. It's slow and unreliable.

I've managed to hack the runscript.sh to output syslog events to flat file, as well as to the DB.

Replace the runscript at /usr/syno/syslogclient/scripts/runscript.sh with this:

Code: Select all
#!/bin/sh

#Conf dir/file definition
PATH_SYSLOGNG_PKG_DIR=/var/packages/SyslogServer/target
PATH_SYSLOGNG_BIN_FOLDER=${PATH_SYSLOGNG_PKG_DIR}/sbin
PATH_SYSLOGNG_TEMPLATE_FOLDER=${PATH_SYSLOGNG_PKG_DIR}/etc/template
FILE_SYNOSYSLOG_SQL=${PATH_SYSLOGNG_PKG_DIR}/scripts/loginfo.sql

PATH_SYSLOGNG_CONF=/usr/syno/etc/synosyslog
PATH_SYSLOGNG_CONF_FOLDER=${PATH_SYSLOGNG_CONF}/syslog.d
FILE_SYSLOGNG_SETTING=/var/packages/SyslogServer/etc/setting.conf
FILE_SYSLOGNG_PID=/var/run/syslogng.pid
FILE_SYSLOGD_PID=/var/run/syslogd.pid
FILE_LOGMONI_PID=/var/run/logmonitord.pid
FILE_SYSLOGMAIL_PID=/var/run/syslogmaild.pid
FILE_SYNOSYSLOG_CONF=${PATH_SYSLOGNG_CONF_FOLDER}/syno.conf

#Global variables
SYSLOGNG_SERVER_ENABLE=0
SYSLOGNG_SERVER_PORT=1234
SYSLOGNG_SERVER_TRANS_MODE=tcp
SYSLOGNG_SERVER_SSL=0
SYSLOGNG_SERVER_LOG_ROTATE_TIME=0
SYSLOGNG_SERVER_MAIL_ENABLE=0
SYSLOGNG_SERVER_MAIL_FILETER=""
SYSLOGNG_SERVER_DB_LOC=""
SYSLOGNG_SERVER_DB_PATH=""
SYSLOGNG_SERVER_CA_KEY_PATH="/usr/syno/etc/ssl/ssl.key/server.key"
SYSLOGNG_SERVER_CA_FILE_PATH="/usr/syno/etc/ssl/ssl.crt/server.crt"
SYSLOGNG_SERVER_INTER_FILETER=""

PROCESS_ALIVE=0
PROCESS_PID=0

###########################################################################
# Syslog Client part
###########################################################################

FILE_SYSLOGNG_CLIENT_SETTING=/etc/synosyslog.conf
PATH_SYSLOGNG_CLIENT_CONFIG_FOLDER=/usr/syno/syslogclient/etc
PATH_SYSLOGNG_CLIENT_TEMPLATE_FOLDER=/usr/syno/syslogclient/etc/template
PATH_SYSLOGNG_CLINET_CONF_FOLDER=${PATH_SYSLOGNG_CONF}/client
FILE_SYNOSYSLOG_CLIENT_CONF=${PATH_SYSLOGNG_CLINET_CONF_FOLDER}/syno.conf

SYSLOGNG_CLIENT_ENABLE=0
SYSLOGNG_CLIENT_IP=""
SYSLOGNG_CLIENT_PORT=1234
SYSLOGNG_CLIENT_TRANS_MODE=tcp
SYSLOGNG_CLIENT_SSL=0
SYSLOGNG_CLIENT_FAC_FILTER=""
SYSLOGNG_CLIENT_SEV_FILTER=""

SyslogClientSettingGet(){
    #Copy syslog system conf (share same system.conf with Syslog Server)
    cp -rf ${PATH_SYSLOGNG_CLIENT_CONFIG_FOLDER}/system.conf ${PATH_SYSLOGNG_CONF}

    if [ -f "${FILE_SYSLOGNG_CLIENT_SETTING}" ]; then
        SYSLOGNG_CLIENT_ENABLE=`/bin/get_key_value ${FILE_SYSLOGNG_CLIENT_SETTING} server_enable`
        SYSLOGNG_CLIENT_IP=`/bin/get_key_value ${FILE_SYSLOGNG_CLIENT_SETTING} server_addr`
        SYSLOGNG_CLIENT_PORT=`/bin/get_key_value ${FILE_SYSLOGNG_CLIENT_SETTING} server_port`
        SYSLOGNG_CLIENT_TRANS_MODE=`/bin/get_key_value ${FILE_SYSLOGNG_CLIENT_SETTING} server_trans`
        SYSLOGNG_CLIENT_SSL=`/bin/get_key_value ${FILE_SYSLOGNG_CLIENT_SETTING} server_ssl`
        SYSLOGNG_CLIENT_FAC_FILTER=`/bin/get_key_value ${FILE_SYSLOGNG_CLIENT_SETTING} server_facfilter`
        SYSLOGNG_CLIENT_SEV_FILTER=`/bin/get_key_value ${FILE_SYSLOGNG_CLIENT_SETTING} server_sevfilter`
        SYSLOGNG_CLIENT_CA_FILE_PATH=`/bin/get_key_value ${FILE_SYSLOGNG_CLIENT_SETTING} server_ca_path`
    else
        echo "Syslog client setting file does not exist!";
        exit 1;
    fi
}

ClientConfDataClear(){
    rm -rf ${PATH_SYSLOGNG_CLINET_CONF_FOLDER} > /dev/null 2>&1
}

ClientConfFolderCreate(){
    mkdir -p ${PATH_SYSLOGNG_CLINET_CONF_FOLDER}
}

ClientSourceProcess(){
    touch ${FILE_SYNOSYSLOG_CLIENT_CONF}

    TEMPLATE_FILE=${PATH_SYSLOGNG_CLIENT_TEMPLATE_FOLDER}/src_socket.template
    cat $TEMPLATE_FILE >> ${FILE_SYNOSYSLOG_CLIENT_CONF}
}
ClientFilterProcess(){
    #Facility filter
    SYSLOGNG_FAC_FILTER_LIST=`echo ${SYSLOGNG_CLIENT_FAC_FILTER} | sed 's/,/ /g'`
    SYSLOGNG_FAC_FILTER_STRING=""
    FAC_STRING=""
    for fac in $SYSLOGNG_FAC_FILTER_LIST
    do
       if [ -n "${fac}" ]; then
           if [ -z ${SYSLOGNG_FAC_FILTER_STRING} ]; then
              SYSLOGNG_FAC_FILTER_STRING="program(${fac})"
           else
              SYSLOGNG_FAC_FILTER_STRING="${SYSLOGNG_FAC_FILTER_STRING} or program(${fac})"
           fi
       fi
    done

    if [ "" = "${SYSLOGNG_FAC_FILTER_STRING}" ]; then
        SYSLOGNG_FAC_FILTER_STRING="program(no_fac)"
    fi

    TEMPLATE_FILE=${PATH_SYSLOGNG_CLIENT_TEMPLATE_FOLDER}/filter_fac.template
    cat $TEMPLATE_FILE | sed -e "s/__SYSLOG_FAC_FILTER__/${SYSLOGNG_FAC_FILTER_STRING}/" >> ${FILE_SYNOSYSLOG_CLIENT_CONF}

    #Severity filter
    SYSLOGNG_SEV_FILTER_LIST=`echo ${SYSLOGNG_CLIENT_SEV_FILTER} | sed 's/,/ /g'`
    SYSLOGNG_SEV_FILTER_STRING=""
    PRIO_STRING=""
    for prio in $SYSLOGNG_SEV_FILTER_LIST
    do
       if [ -n "${prio}" ]; then
            if [ "error" = "${prio}" ]; then
                PRIO_STRING="emerg,alert,crit,err"
            elif [ "warning" = "${prio}" ]; then
                PRIO_STRING="warning"
            elif [ "info" = "${prio}" ]; then
                PRIO_STRING="notice,info"
            fi

           if [ -z ${SYSLOGNG_SEV_FILTER_STRING} ]; then
              SYSLOGNG_SEV_FILTER_STRING="${PRIO_STRING}"
           else
              SYSLOGNG_SEV_FILTER_STRING="${SYSLOGNG_SEV_FILTER_STRING},${PRIO_STRING}"
           fi
       fi
    done

    TEMPLATE_FILE=${PATH_SYSLOGNG_CLIENT_TEMPLATE_FOLDER}/filter_sev.template
    cat $TEMPLATE_FILE | sed -e "s/__SYSLOG_SEV_FILTER__/${SYSLOGNG_SEV_FILTER_STRING}/" >> ${FILE_SYNOSYSLOG_CLIENT_CONF}
}
ClientDestProcess(){
    if [ "tcp" = "${SYSLOGNG_CLIENT_TRANS_MODE}" ]; then
       if [ "1" = "${SYSLOGNG_CLIENT_SSL}" ]; then
           TEMPLATE_FILE=${PATH_SYSLOGNG_CLIENT_TEMPLATE_FOLDER}/dest_net_enc.template
           cat $TEMPLATE_FILE | sed -e "s/__SYSLOG_SERVER_IP__/${SYSLOGNG_CLIENT_IP}/" | sed -e "s/__SYSLOG_SERVER_PORT__/${SYSLOGNG_CLIENT_PORT}/" | sed -e "s=__SYSLOG_SERVER_CA__=${SYSLOGNG_CLIENT_CA_FILE_PATH}=" >> ${FILE_SYNOSYSLOG_CLIENT_CONF}
       else
           TEMPLATE_FILE=${PATH_SYSLOGNG_CLIENT_TEMPLATE_FOLDER}/dest_net_tcp.template
           cat $TEMPLATE_FILE | sed -e "s/__SYSLOG_SERVER_IP__/${SYSLOGNG_CLIENT_IP}/" | sed -e "s/__SYSLOG_SERVER_PORT__/${SYSLOGNG_CLIENT_PORT}/" >> ${FILE_SYNOSYSLOG_CLIENT_CONF}
       fi
    else
       TEMPLATE_FILE=${PATH_SYSLOGNG_CLIENT_TEMPLATE_FOLDER}/dest_net_udp.template
       cat $TEMPLATE_FILE | sed -e "s/__SYSLOG_SERVER_IP__/${SYSLOGNG_CLIENT_IP}/" | sed -e "s/__SYSLOG_SERVER_PORT__/${SYSLOGNG_CLIENT_PORT}/" >> ${FILE_SYNOSYSLOG_CLIENT_CONF}
    fi
}
ClientLogProcess(){
    TEMPLATE_FILE=${PATH_SYSLOGNG_CLIENT_TEMPLATE_FOLDER}/log_socket_to_net.template
    cat $TEMPLATE_FILE >> ${FILE_SYNOSYSLOG_CLIENT_CONF}
}

###########################################################################
# End of Syslog Client part
###########################################################################

SyslogSettingGet(){
    if [ -f "${FILE_SYSLOGNG_SETTING}" ]; then
       SYSLOGNG_SERVER_ENABLE=`/bin/get_key_value ${FILE_SYSLOGNG_SETTING} server_enable`
       SYSLOGNG_SERVER_PORT=`/bin/get_key_value ${FILE_SYSLOGNG_SETTING} server_port`
       SYSLOGNG_SERVER_TRANS_MODE=`/bin/get_key_value ${FILE_SYSLOGNG_SETTING} server_trans`
       SYSLOGNG_SERVER_SSL=`/bin/get_key_value ${FILE_SYSLOGNG_SETTING} server_ssl`
       SYSLOGNG_SERVER_LOG_ROTATE_TIME=`/bin/get_key_value ${FILE_SYSLOGNG_SETTING} server_log_rotate_time`
       SYSLOGNG_SERVER_MAIL_ENABLE=`/bin/get_key_value ${FILE_SYSLOGNG_SETTING} server_enable_mail`
       SYSLOGNG_SERVER_MAIL_FILETER=`/bin/get_key_value ${FILE_SYSLOGNG_SETTING} server_mail_filter`
       SYSLOGNG_SERVER_DB_LOC=`/bin/get_key_value ${FILE_SYSLOGNG_SETTING} server_db_loc`
       SYSLOGNG_SERVER_DB_PATH=`/bin/get_key_value ${FILE_SYSLOGNG_SETTING} server_db_path`
       SYSLOGNG_SERVER_CA_KEY_PATH=`/bin/get_key_value ${FILE_SYSLOGNG_SETTING} server_ca_key`
       SYSLOGNG_SERVER_CA_FILE_PATH=`/bin/get_key_value ${FILE_SYSLOGNG_SETTING} server_ca_file`
       SYSLOGNG_SERVER_INTER_FILETER=`/bin/get_key_value ${FILE_SYSLOGNG_SETTING} server_internal_filter`
    else
       echo "Syslog setting file does not exist!";
       # Server configuration may not exist (Syslog Server package is never installed)
    fi
}

CheckIfDaemonAlive(){
    PROCESS_ALIVE=0
    if [ -f "$1" ]; then
       PROCESS_PID=`cat $1`
   kill -0 ${PROCESS_PID}
        if [ "0" = "$?" ]; then
           PROCESS_ALIVE=1
       fi
    fi
}

SourceProcess(){
    #Copy syslog system conf
    cp -rf ${PATH_SYSLOGNG_CLIENT_CONFIG_FOLDER}/system.conf ${PATH_SYSLOGNG_CONF}

    if [ "tcp" = "${SYSLOGNG_SERVER_TRANS_MODE}" ]; then
       if [ "1" = "${SYSLOGNG_SERVER_SSL}" ]; then
           TEMPLATE_FILE=${PATH_SYSLOGNG_TEMPLATE_FOLDER}/src_net_enc.template
           cat $TEMPLATE_FILE | sed -e "s/__SYNO_PORT__/${SYSLOGNG_SERVER_PORT}/" | sed -e "s=__SYNO_CA_KEY_PATH__=${SYSLOGNG_SERVER_CA_KEY_PATH}=" | sed -e "s=__SYNO_CA_FILE_PATH__=${SYSLOGNG_SERVER_CA_FILE_PATH}=" >> ${FILE_SYNOSYSLOG_CONF}
       else
           TEMPLATE_FILE=${PATH_SYSLOGNG_TEMPLATE_FOLDER}/src_net.template
           cat $TEMPLATE_FILE | sed -e "s/__SYNO_PORT__/${SYSLOGNG_SERVER_PORT}/" >> ${FILE_SYNOSYSLOG_CONF}
   
       fi
    else
       TEMPLATE_FILE=${PATH_SYSLOGNG_TEMPLATE_FOLDER}/src_net_udp.template
       cat $TEMPLATE_FILE | sed -e "s/__SYNO_PORT__/${SYSLOGNG_SERVER_PORT}/" >> ${FILE_SYNOSYSLOG_CONF}
    fi
}

MailDestProcess(){
    if [ "1" != "${SYSLOGNG_SERVER_MAIL_ENABLE}" ]; then
       return;
    fi
   
    cat ${PATH_SYSLOGNG_TEMPLATE_FOLDER}/dest_mail.template >> ${FILE_SYNOSYSLOG_CONF}
}

DestProcess(){
    cat ${PATH_SYSLOGNG_TEMPLATE_FOLDER}/dest_db.template | sed -e "s=__SYNO_DB_PATH__=${LOGDB_PATH}=" >> ${FILE_SYNOSYSLOG_CONF}
    MailDestProcess;
}

AddFileProcess(){
   echo 'destination d_file { file("/volume1/logs/syslog_$YEAR.$MONTH.$DAY.log"); };' >> ${FILE_SYNOSYSLOG_CONF}
   echo 'log { source(s_syno_net); filter(f_syno_nonemptymsg); destination(d_file); flags(flow_control); };' >> ${FILE_SYNOSYSLOG_CONF}
}
MailLogProcess(){
    if [ "1" != "${SYSLOGNG_SERVER_MAIL_ENABLE}" ]; then
       return;
    fi
 
    if [ ! -z ${SYSLOGNG_PRIOR_STRING} ]; then
       cat ${PATH_SYSLOGNG_TEMPLATE_FOLDER}/log_send_mail.template | sed -e "s=_SYNO_FILTER_=filter(f_syno_mail);=g" >> ${FILE_SYNOSYSLOG_CONF}
    else
       cat ${PATH_SYSLOGNG_TEMPLATE_FOLDER}/log_send_mail.template | sed -e "s/_SYNO_FILTER_//g" >> ${FILE_SYNOSYSLOG_CONF}
    fi

}

NetLogProcess(){
    cat ${PATH_SYSLOGNG_TEMPLATE_FOLDER}/log_net_to_db.template >> ${FILE_SYNOSYSLOG_CONF}
}

LogProcess(){
    NetLogProcess;
    MailLogProcess;
}

MailFilterProcess(){
    if [ "1" != "${SYSLOGNG_SERVER_MAIL_ENABLE}" ]; then
       return;
    fi

    #1. Get mail level setting from setting.conf
    #2. Compose of filter string for syslog-ng
    #3. Generate log conf file for mailing
    SYSLOGNG_PRIOR_LIST=`echo ${SYSLOGNG_SERVER_MAIL_FILETER} | sed 's/,/ /g'`
    SYSLOGNG_PRIOR_STRING=""
    for prio in $SYSLOGNG_PRIOR_LIST
    do
       if [ ! -z "${prio}" ]; then
           if [ -z ${SYSLOGNG_PRIOR_STRING} ]; then
              SYSLOGNG_PRIOR_STRING="${prio}"
           else
              SYSLOGNG_PRIOR_STRING="${SYSLOGNG_PRIOR_STRING},${prio}"
           fi
       fi
    done
   
    if [ ! -z ${SYSLOGNG_PRIOR_STRING} ]; then
       cat ${PATH_SYSLOGNG_TEMPLATE_FOLDER}/filter_prior_mail.template | sed -e "s/_SYNO_PRIORITY_/${SYSLOGNG_PRIOR_STRING}/g" >> ${FILE_SYNOSYSLOG_CONF}
    fi
}

InternalFilterProcess(){
    #1. Get internal level setting from setting.conf
    #2. Compose of filter string for syslog-ng
    #3. Generate log conf file for mailing
    SYSLOGNG_INTERNAL_PRIOR_LIST=`echo ${SYSLOGNG_SERVER_INTER_FILETER} | sed 's/,/ /g'`
    SYSLOGNG_INTERNAL_PRIOR_STRING=""
    for prio in $SYSLOGNG_INTERNAL_PRIOR_LIST
    do
       if [ -n "${prio}" ]; then
           if [ -z ${SYSLOGNG_INTERNAL_PRIOR_STRING} ]; then
              SYSLOGNG_INTERNAL_PRIOR_STRING="${prio}"
           else
              SYSLOGNG_INTERNAL_PRIOR_STRING="${SYSLOGNG_INTERNAL_PRIOR_STRING},${prio}"
           fi
       fi
    done
   
    if [ -n ${SYSLOGNG_INTERNAL_PRIOR_STRING} ]; then
       cat ${PATH_SYSLOGNG_TEMPLATE_FOLDER}/filter_prior_internal.template | sed -e "s/_SYNO_PRIORITY_/${SYSLOGNG_INTERNAL_PRIOR_STRING}/g" >> ${FILE_SYNOSYSLOG_CONF}
    fi
}

FilterProcess(){
    InternalFilterProcess;
    MailFilterProcess;
}

# Service control
SyslogngStart(){
    /sbin/syslog-ng --module-path=/lib/syslogmod --pidfile=${FILE_SYSLOGNG_PID} --cfgfile=${PATH_SYSLOGNG_CONF}/system.conf --persist-file="/tmp/syslog-ng.persist" --control="/tmp/syslog-ng.ctl"
}
SyslogngStop(){
    CheckIfDaemonAlive ${FILE_SYSLOGNG_PID}
    if [ "1" = "$PROCESS_ALIVE" ]; then
        kill ${PROCESS_PID}
        sleep 1;
    fi
}

LogMoniStart(){
    ${PATH_SYSLOGNG_BIN_FOLDER}/logmonitord
}
LogMoniStop(){
    CheckIfDaemonAlive ${FILE_LOGMONI_PID}
    if [ "1" = "$PROCESS_ALIVE" ]; then
        kill ${PROCESS_PID}
        sleep 1;
    fi
}

LogMailStart(){
    ${PATH_SYSLOGNG_BIN_FOLDER}/syslogmaild
}
LogMailStop(){
    CheckIfDaemonAlive ${FILE_SYSLOGMAIL_PID}
    if [ "1" = "$PROCESS_ALIVE" ]; then
        kill ${PROCESS_PID}
        sleep 1;
    fi
}

ConfDataClear(){
    rm -rf ${PATH_SYSLOGNG_CONF_FOLDER} > /dev/null 2>&1
}

ConfFolderCreate(){
    mkdir -p ${PATH_SYSLOGNG_CONF_FOLDER}
}

ShareExistCheck(){
    SHARE_EXIST=0
    SHARE_PATH=`/usr/syno/sbin/synoshare --get "${SYSLOGNG_SERVER_DB_LOC}" | grep "Path ......" | sed -e 's/^.*\[\(.*\)\]/\1/g'`
    if [ -n "${SHARE_PATH}" ]; then
        SHARE_EXIST=1
        LOGDB_PATH="${SHARE_PATH}/.SYNOSYSLOGDB"
        if [ -d "${SHARE_PATH}" ]; then
            if [ "$LOGDB_PATH" = "$SYSLOGNG_SERVER_DB_PATH" ]; then
                if [ ! -f "$SYSLOGNG_SERVER_DB_PATH" ]; then
                    /usr/syno/bin/sqlite3 "$SYSLOGNG_SERVER_DB_PATH" < "$FILE_SYNOSYSLOG_SQL" > /dev/null 2>&1
                fi
            fi
        fi
    fi
   
    LOGDB_PATH="$SYSLOGNG_SERVER_DB_PATH"
}

ProcessServerConfig() {
    ConfDataClear;
    ConfFolderCreate;
    SourceProcess;
    FilterProcess;
    DestProcess;
    AddFileProcess;
    LogProcess;
}

ProcessClientConfig() {
    ClientConfDataClear;
    ClientConfFolderCreate;
    ClientSourceProcess;
    ClientFilterProcess;
    ClientDestProcess;
    ClientLogProcess;
}

#At begining, acquire all server settings
SyslogSettingGet;

#At begining, acquire all client settings
SyslogClientSettingGet;

case $1 in
    start)
       echo "Syslog-ng server start..."

        #Service enable check
        if [ "yes" != "${SYSLOGNG_SERVER_ENABLE}" -a "yes" != "${SYSLOGNG_CLIENT_ENABLE}" ]; then
            echo "Client/Server is both disabled"
            return;
        fi

        #Restart syslog-ng daemon
        SyslogngStop;

        #Process server config if enabled
        if [ "yes" == "${SYSLOGNG_SERVER_ENABLE}" ]; then
            #Storage check
            ShareExistCheck;
          if [ "0" = "${SHARE_EXIST}" ]; then
             logger -p 3 "Syslog-ng has no usable share!"
          fi

            #Process configuration for Syslog Server
          ProcessServerConfig;
        else
            #Make sure config is clear
            ConfDataClear;
            ConfFolderCreate;
        fi

        #Process client config if enabled
        if [ "yes" == "${SYSLOGNG_CLIENT_ENABLE}" ]; then
            #Process configuration for Syslog Client
            ProcessClientConfig;
        else
            #Make sure config is clear
            ClientConfDataClear;
            ClientConfFolderCreate;
        fi
   
        #Start syslog-ng daemon
        SyslogngStart;

        if [ "yes" == "${SYSLOGNG_SERVER_ENABLE}" ]; then
            #Restart log monitor daemon
          LogMoniStop;
          LogMoniStart;
   
          #Restart log mail daemon
          LogMailStop;
          LogMailStart;
        fi
    ;;
    stop)
        echo "Syslog-ng server restart by configuration..."
        #Service enable check
        if [ "yes" != "${SYSLOGNG_SERVER_ENABLE}" -a "yes" != "${SYSLOGNG_CLIENT_ENABLE}" ]; then
            #Server/Client are all disabled, stop syslog-ng daemon
            #Invoke hardstop
            $0 hardstop
        elif [ "yes" != "${SYSLOGNG_SERVER_ENABLE}" ]; then
            #Syslog Server is disabled
            ConfDataClear;
            ConfFolderCreate;

            #Invoke restart
            $0 restart
        elif [ "yes" != "${SYSLOGNG_CLIENT_ENABLE}" ]; then
            #Client is disabled
            ClientConfDataClear;
            ClientConfFolderCreate;

            #Invoke restart
            $0 restart
        fi
    ;;
    hardstop)
        echo "Syslog-ng server stop..."

        #Stop syslog-ng daemon
       SyslogngStop;
   
       #Stop log monitor daemon
       LogMoniStop;
   
       #Stop log mail daemon
       LogMailStop;

       #Clear configuration
       ConfDataClear;
        ClientConfDataClear;
    ;;
    restart)
        echo "Syslog-ng server restart..."

        #Process server config if enabled
        if [ "yes" == "${SYSLOGNG_SERVER_ENABLE}" ]; then
            ShareExistCheck;
           if [ "0" = "${SHARE_EXIST}" ]; then
              logger -p 3 "Syslog-ng has no usable share!"
           fi

            ProcessServerConfig;
        fi

        #Process client config if enabled
        if [ "yes" == "${SYSLOGNG_CLIENT_ENABLE}" ]; then
            ProcessClientConfig;
        fi

        #Hup syslog-ng daemon
        CheckIfDaemonAlive ${FILE_SYSLOGNG_PID};
        if [ "1" = "${PROCESS_ALIVE}" ]; then
            kill -HUP ${PROCESS_PID}
        else
            SyslogngStart;
        fi

       if [ "yes" == "${SYSLOGNG_SERVER_ENABLE}" ]; then
            #Hup log monitor daemon
           CheckIfDaemonAlive ${FILE_LOGMONI_PID}   
           if [ "1" = "${PROCESS_ALIVE}" ]; then
              kill -HUP ${PROCESS_PID}
           else
              LogMoniStart;
           fi

           #Hup mail daemon
           CheckIfDaemonAlive ${FILE_SYSLOGMAIL_PID}   
           if [ "1" = "${PROCESS_ALIVE}" ]; then
              kill ${PROCESS_PID}
              sleep 1;
           fi
           if [ "1" == ${SYSLOGNG_SERVER_MAIL_ENABLE} ]; then
              LogMailStart;
           fi
        fi
    ;;
    *)
       echo "Usage: $0 start|stop|hardstop|restart"
    ;;
esac


...notice the change to the ProcessServerConfig() function, and the addition of the AddFileProcess() function to append some extra syslog-ng config. You will need to tweak the lines in AddFileProcess for your own setup (ie set the path to somewhere that exists on your diskstation).

Obviously this will need to be re-applied after any DSM update (until Synology sort the problem out, at least).

Tested on DSM v4.0-2219.
burpsmirk
I'm New!
I'm New!
 
Posts: 6
Joined: Mon Jan 09, 2012 3:15 pm

Re: Syslog Interface Broken

Postby ecylcje » Wed Sep 05, 2012 2:18 pm

Version: DSM 4.1-2636

Hi,

I'm wondering if anyone has got this issue fixed. My syslog DB is currently at 16Gb, and it is completely unviewable via teh GUI and has been for quite a while.

Thanks,

Chris
ecylcje
Trainee
Trainee
 
Posts: 18
Joined: Wed Sep 05, 2012 2:04 pm


Return to Syslog Server

Who is online

Users browsing this forum: No registered users and 0 guests