...
 
Commits (9)
......@@ -4,6 +4,8 @@
# ============================================================================
# ThiesDL1
# --------
#
tester
#
# descriptive text files
*_text.h
......
......@@ -31,6 +31,8 @@
#
# ============================================================================
echo "$0" | /bin/logger -i -t "DL1logger" 2>&1
LOGGERBINARY=$HOME/bin/linux/DL1logger
#DLDEVICE=/dev/ttyUSB0
......@@ -45,9 +47,9 @@ DATATYPES=ascii
MEMORY=$DATADIR/DL1memory
echo stty -F $DLDEVICE $PORTSETTINGS | /bin/logger -i -t "DL1logger $0" 2>&1
stty -F $DLDEVICE $PORTSETTINGS | /bin/logger -i -t "DL1logger $0" 2>&1
stty -F $DLDEVICE -a | /bin/logger -i -t "DL1logger $0" 2>&1
echo stty -F $DLDEVICE $PORTSETTINGS | /bin/logger -i -t "DL1logger" 2>&1
stty -F $DLDEVICE $PORTSETTINGS | /bin/logger -i -t "DL1logger" 2>&1
stty -F $DLDEVICE -a | /bin/logger -i -t "DL1logger" 2>&1
$LOGGERBINARY -port $DLDEVICE -memory $MEMORY \
-datapath $DATAPATH -activepath $ACTIVEPATH \
......
......@@ -2,15 +2,15 @@
# ============================================================================
# configuration file for syslog-ng on DL1 recording host
# ------------------------------------------------------
# 2019-06-07
# 2019-06-19
# ============================================================================
# BFO Thies DL1
destination dl1logall { file("/var/log/dl1logall" fsync(yes) perm(0644)); };
destination dl1log { file("/var/log/dl1log" fsync(yes) perm(0644)); };
destination dl1logremote1 { tcp("192.168.1.41" port(2222)); };
destination dl1logremote2 { tcp("192.168.1.3" port(2222)); };
filter f_dl1 { message("DL1logger"); };
filter f_dl1_notice { message("DL1logger") and not level(info); };
filter f_dl1 { match("DL1logger"); };
filter f_dl1_notice { match("DL1logger") and not level(info); };
log { source(src); filter(f_dl1); destination(dl1logall); };
log { source(src); filter(f_dl1_notice); destination(dl1log); };
log { source(src); filter(f_dl1); destination(dl1logremote1); };
......
......@@ -2,7 +2,7 @@
# ============================================================================
# configuration file for syslog-ng on host receiving messages from DL1
# --------------------------------------------------------------------
# 2014-03-27
# 2019-06-19
# ============================================================================
#
# BFO Thies DL1
......
......@@ -56,7 +56,7 @@ AUTOSRC=DL1logger_longusage_text.cc DL1logger_notes_text.cc \
SUBOBS=$(patsubst %.cc,%.o,$(AUTOSRC) $(SUBSRC))
ALLSRC=$(AUTOSRC) $(SUBSRC) $(MAINSRC)
AUXFILES=Makefile README COPYING
AUXFILES=Makefile README COPYING crontab
#----------------------------------------------------------------------
......
......@@ -28,8 +28,9 @@
#
# ============================================================================
#
echo "check status of time sources" | /bin/logger -i -p user.notice -t "DL1logger $0" 2>&1
/usr/bin/chronyc sources | /bin/logger -i -p user.notice -t "DL1logger $0" 2>&1
/usr/bin/chronyc sourcestats | /bin/logger -i -p user.notice -t "DL1logger $0" 2>&1
echo "$0" | /bin/logger -i -p user.notice -t "DL1logger" 2>&1
echo "check status of time sources" | /bin/logger -i -p user.notice -t "DL1logger" 2>&1
/usr/bin/chronyc sources | /bin/logger -i -p user.notice -t "DL1logger" 2>&1
/usr/bin/chronyc sourcestats | /bin/logger -i -p user.notice -t "DL1logger" 2>&1
# ----- END OF chronyreport.sh -----
......@@ -4,5 +4,6 @@
# ---------------------------
#
10 * * * * /home/dl1/bin/scripts/launchDL1logger.sh 1>>/dev/null 2>&1
50 0 * * * /home/dl1/bin/scripts/ntpreport.sh 1>>/dev/null 2>&1
#50 0 * * * /home/dl1/bin/scripts/ntpreport.sh 1>>/dev/null 2>&1
50 0 * * * /home/dl1/bin/scripts/chronyreport.sh 1>>/dev/null 2>&1
# ----- END OF crontab -----
......@@ -26,11 +26,12 @@
# 19/12/2008 V1.0 Thomas Forbriger
#
# ============================================================================
echo "check logger" | /bin/logger -i -p user.info -t "DL1logger $0" 2>&1
echo "$0" | /bin/logger -i -t "DL1logger" 2>&1
echo "check logger" | /bin/logger -i -p user.info -t "DL1logger" 2>&1
SCRIPTDIR=$HOME/bin/scripts
LOGGERSCRIPT=$SCRIPTDIR/DL1logger.sh
LOGDIR=$HOME/DL1/log
mkdir -pv $LOGDIR | /bin/logger -i -p user.info -t "DL1logger $0" 2>&1
mkdir -pv $LOGDIR | /bin/logger -i -p user.info -t "DL1logger" 2>&1
LOGFILE=$LOGDIR/$(date +'%Y%m%d.%H%M').log
/sbin/checkproc $LOGGERSCRIPT
......@@ -38,7 +39,7 @@ status=$?
if test $status != 0
then
echo "/usr/bin/nohup $LOGGERSCRIPT 2>&1 >> $LOGFILE &" \
| /bin/logger -i -p user.notice -t "DL1logger $0" 2>&1
| /bin/logger -i -p user.notice -t "DL1logger" 2>&1
/usr/bin/nohup $LOGGERSCRIPT >> $LOGFILE 2>&1 &
fi
......
......@@ -27,6 +27,7 @@
#
# ============================================================================
#
echo "check status of NTP peers" | /bin/logger -i -p user.notice -t "DL1logger $0" 2>&1
/usr/sbin/ntpq -p | /bin/logger -i -p user.notice -t "DL1logger $0" 2>&1
echo "$0" | /bin/logger -i -t "DL1logger" 2>&1
echo "check status of NTP peers" | /bin/logger -i -p user.notice -t "DL1logger" 2>&1
/usr/sbin/ntpq -p | /bin/logger -i -p user.notice -t "DL1logger" 2>&1
# ----- END OF ntpreport.sh -----
#!/bin/sh
# this is <syslogtest.sh>
# ----------------------------------------------------------------------------
#
# Copyright (c) 2019 by Thomas Forbriger (BFO Schiltach)
#
# Test syslog configuration
#
# ----
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----
#
# REVISIONS and CHANGES
# 19/06/2019 V1.0 Thomas Forbriger
#
# ============================================================================
#
# produce syslog messages like produced by DL1logger
./tester -syslog "syslog test: $(date)" -v
./tester -syslog "syslog test: $(date)" -loginfo -v
./tester -syslog "syslog test: $(date)" -logemerg -v
#
# produce syslog messages like launchDL1logger.sh and DL1logger.sh
echo "check syslog" | /bin/logger -i -p user.info -t "DL1logger" 2>&1
#
# run chrony check
./chronyreport.sh
#
# ----- END OF syslogtest.sh -----
......@@ -4,11 +4,12 @@
* ----------------------------------------------------------------------------
*
* \author Thomas Forbriger
* \date 24/03/2014
* \since 24/03/2014
* \date 19/06/2019
*
* a small program to test some functions
*
* Copyright (c) 2008, 2014 by Thomas Forbriger (BFO Schiltach)
* Copyright (c) 2008, 2014, 2019 by Thomas Forbriger (BFO Schiltach)
*
* ----
* This program is free software; you can redistribute it and/or modify
......@@ -28,11 +29,12 @@
*
* REVISIONS and CHANGES
* - 28/11/2008 V1.0 Thomas Forbriger
* - 19/06/2019 V1.1 add syslog test function
*
* ============================================================================
*/
#define TESTER_VERSION \
"TESTER V2014-03-24 a small program to test some functions"
"TESTER V2019-06-19 a small program to test some functions"
#include <iostream>
#include <list>
......@@ -42,6 +44,7 @@
#include "thiesdl1.h"
#include "functions.h"
#include "memory.h"
#include "logger.h"
typedef std::list<std::string> Tlistofstring;
......@@ -69,7 +72,8 @@ int main(int iargc, char* argv[])
char usage_text[]=
{
TESTER_VERSION "\n"
"usage: tester" "\n"
"usage: tester [-v] [-pattern p] [-Id] [-checkdatepattern p]" "\n"
" [-checkfileexists f] [-preppath p] [-active]\n"
" or: tester --help|-h" "\n"
};
......@@ -77,6 +81,22 @@ int main(int iargc, char* argv[])
char help_text[]=
{
TESTER_VERSION
"flags:\n"
"-v be verbose\n"
"-active set active flag for dl1::mkpathname in test \"-preppath\"\n"
"-loginfo set syslog level to info\n"
"-logemerg set syslog level to emerg\n"
"\n"
"tests:\n"
"-pattern p test pattern replacement function\n"
" dl1::patsubstdate\n"
"-Id dump list of CVSIDS\n"
"-checkdatepattern p test function\n"
" dl1::datetemplatespresent\n"
"-checkfileexists f test functions in tfxx::file\n"
"-preppath p test function\n"
" dl1::mkpathname\n"
"-syslog s send string \"s\" to syslog\n"
};
// define commandline options
......@@ -99,6 +119,12 @@ int main(int iargc, char* argv[])
{"preppath",arg_yes,"-"},
// 7: set active flag
{"active",arg_no,"-"},
// 8: send string to syslog
{"syslog",arg_yes,"-"},
// 9: set syslog level to info
{"loginfo",arg_no,"-"},
// 10: set syslog level to emerg
{"logemerg",arg_no,"-"},
{NULL}
};
......@@ -121,60 +147,6 @@ int main(int iargc, char* argv[])
exit(0);
}
/*
// dummy operation: print option settings
for (int iopt=0; iopt<2; iopt++)
{
cout << "option: '" << options[iopt].opt_string << "'" << endl;
if (cmdline.optset(iopt)) { cout << " option was set"; }
else { cout << "option was not set"; }
cout << endl;
cout << " argument (string): '" << cmdline.string_arg(iopt) << "'" << endl;
cout << " argument (int): '" << cmdline.int_arg(iopt) << "'" << endl;
cout << " argument (long): '" << cmdline.long_arg(iopt) << "'" << endl;
cout << " argument (float): '" << cmdline.float_arg(iopt) << "'" << endl;
cout << " argument (double): '" << cmdline.double_arg(iopt) << "'" << endl;
cout << " argument (bool): '";
if (cmdline.bool_arg(iopt))
{ cout << "true"; } else { cout << "false"; }
cout << "'" << endl;
}
while (cmdline.extra()) { cout << cmdline.next() << endl; }
// dummy operation: print rest of command line
while (cmdline.extra()) { cout << cmdline.next() << endl; }
*/
/*
std::ostringstream oss;
oss << "This is my first item";
oss << dl1::DL1::EOL;
oss << "This is my second item" << dl1::DL1::EOL;
oss << "and here are some numbers: " << 3 << 6.5 << 1 << dl1::DL1::EOL;
std::string eol(dl1::DL1::EOL);
std::string msg(oss.str());
Tlistofstring v=tfxx::string::split<std::list>(msg, eol, true);
for (Tvecofstring::iterator i=v.begin(); i!=v.end(); ++i)
{
cout << *i << endl;
}
*/
// cout << dl1::dl1samplinginterval.timestring() << endl;
/*
if (cmdline.extra())
{
std::string filename=cmdline.next();
cout << "file " << filename << endl;
dl1::Memory mem(filename);
mem.setdefault("key","Wert");
mem.setdefault("schluessel","Wert und wert und wert");
mem.setdefault("datum","2008/12/05");
}
*/
/*======================================================================*/
if (cmdline.optset(3))
......@@ -239,6 +211,32 @@ int main(int iargc, char* argv[])
cmdline.optset(7));
cout << "file path: " << pathname << endl;
}
/* ====================================================================== */
if (cmdline.optset(8))
{
dl1::Logger::setident("DL1logger");
dl1::Logger::beverbose(cmdline.optset(1));
if (cmdline.optset(9))
{
dl1::Logger(dl1::log_info) << TESTER_VERSION;
dl1::Logger(dl1::log_info) << "logging at info level";
dl1::Logger(dl1::log_info) << cmdline.string_arg(8);
}
else if (cmdline.optset(10))
{
dl1::Logger(dl1::log_emerg) << TESTER_VERSION;
dl1::Logger(dl1::log_emerg) << "logging at emerg level";
dl1::Logger(dl1::log_emerg) << cmdline.string_arg(8);
}
else
{
dl1::Logger() << TESTER_VERSION;
dl1::Logger() << "logging at default level";
dl1::Logger() << cmdline.string_arg(8);
}
}
}
/* ----- END OF tester.cc ----- */