<commit_before>#!/bin/bash

# check-system-configuration.sh: see if config and log files exist and
# log entries actually appear

#
# Check rsyslog configuration
#
# This assumes rsyslogd.
#
# Rsyslogd can drop debug messages from Machinekit when coming in a too
# high a rate.  This is controlled by the SystemLogRateLimitBurst
# parameter.
get-conf-files() {
    conf_files="$*"
    local conflist=""
    for i in $conf_files; do
	conflist+=" $(readlink -e $i)"
    done
    echo $conflist
}

check-rsyslog() {
    local logfile=/var/log/linuxcnc.log
    local logconfigs="$(get-conf-files /etc/rsyslog.conf /etc/rsyslog.d/*.conf)"

    local res=0
    local nologfile=false
    if test ! -f $logfile
    then
	echo "Warning:  Logfile '$logfile' does not exist."
	echo
	echo "          rsyslogd does not create non-existent log files; be"
	echo "          sure the (possibly empty) logfile exists and"
	echo "          restart rsyslogd"
	echo
	echo "          Hint:"
	echo "            $ sudo touch /var/log/linuxcnc.log"
	echo "            $ sudo service rsyslog restart"
	echo
	echo "          Gurus:  If you intentionally log to another file,"
	echo "          please be aware of where Machinekit logs go for"
	echo "          debugging purposes"
	echo
	res=1
	nologfile=true
    fi

    if test -z "$logconfigs"; then
	echo "Warning:  No rsyslog.conf found; system log daemon not rsyslogd?"
	echo
	echo "          Please check your syslog configuration for"
	echo "          rate limiting; an example for rsyslogd can be found in"
	echo "          src/rtapi/rsyslogd-linuxcnc.conf"
	echo
    elif ! grep -q SystemLogRateLimitBurst $logconfigs; then
	res=1
	echo "Warning:  No rate limit in rsyslogd is set."
	echo
	echo "          The 'rsyslogd' daemon drops logs when incoming at"
	echo "          higher than the rate configured by"
	echo "          'SystemLogRateLimitBurst'.  The default rate is lower"
	echo "          than Machinekit requires when running in debug mode."
	echo
	echo "          Hint:"
	echo "            $ sudo cp rtapi/rsyslogd-linuxcnc.conf" \
			     "/etc/rsyslog.d/linuxcnc.conf"
	echo "            $ sudo service rsyslogd restart"
	echo
    fi
    test $res -ne 0 && return 1

    tag=logtest:`echo $$|md5sum|tr -d '-'`

    logger -p local1.debug $tag
    sleep 0.5<commit_msg>corrects a typo, fixes #344<commit_after>#!/bin/bash

# check-system-configuration.sh: see if config and log files exist and
# log entries actually appear

#
# Check rsyslog configuration
#
# This assumes rsyslogd.
#
# Rsyslogd can drop debug messages from Machinekit when coming in a too
# high a rate.  This is controlled by the SystemLogRateLimitBurst
# parameter.
get-conf-files() {
    conf_files="$*"
    local conflist=""
    for i in $conf_files; do
	conflist+=" $(readlink -e $i)"
    done
    echo $conflist
}

check-rsyslog() {
    local logfile=/var/log/linuxcnc.log
    local logconfigs="$(get-conf-files /etc/rsyslog.conf /etc/rsyslog.d/*.conf)"

    local res=0
    local nologfile=false
    if test ! -f $logfile
    then
	echo "Warning:  Logfile '$logfile' does not exist."
	echo
	echo "          rsyslogd does not create non-existent log files; be"
	echo "          sure the (possibly empty) logfile exists and"
	echo "          restart rsyslogd"
	echo
	echo "          Hint:"
	echo "            $ sudo touch /var/log/linuxcnc.log"
	echo "            $ sudo service rsyslog restart"
	echo
	echo "          Gurus:  If you intentionally log to another file,"
	echo "          please be aware of where Machinekit logs go for"
	echo "          debugging purposes"
	echo
	res=1
	nologfile=true
    fi

    if test -z "$logconfigs"; then
	echo "Warning:  No rsyslog.conf found; system log daemon not rsyslogd?"
	echo
	echo "          Please check your syslog configuration for"
	echo "          rate limiting; an example for rsyslogd can be found in"
	echo "          src/rtapi/rsyslogd-linuxcnc.conf"
	echo
    elif ! grep -q SystemLogRateLimitBurst $logconfigs; then
	res=1
	echo "Warning:  No rate limit in rsyslogd is set."
	echo
	echo "          The 'rsyslogd' daemon drops logs when incoming at"
	echo "          higher than the rate configured by"
	echo "          'SystemLogRateLimitBurst'.  The default rate is lower"
	echo "          than Machinekit requires when running in debug mode."
	echo
	echo "          Hint:"
	echo "            $ sudo cp rtapi/rsyslogd-linuxcnc.conf" \
			     "/etc/rsyslog.d/linuxcnc.conf"
	echo "            $ sudo service rsyslog restart"
	echo
    fi
    test $res -ne 0 && return 1

    tag=logtest:`echo $$|md5sum|tr -d '-'`

    logger -p local1.debug $tag
    sleep 0.5
{'fraction_non_alphanumeric': 0.0892433714162535, 'fraction_numerical': 0.004526837680534598, 'mean_word_length': 2.470456245325355, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3296168', 'n_tokens_mistral': 1547, 'n_tokens_neox': 1491, 'n_words': 517}