[Logcheck-commits] CVS logcheck/src

CVS User maks-guest logcheck-devel@lists.alioth.debian.org
Sat, 12 Jun 2004 12:31:32 -0600


Update of /cvsroot/logcheck/logcheck/src
In directory haydn:/tmp/cvs-serv24700/src

Modified Files:
	logcheck 
Log Message:

new logcheck switch (no change inside of logtail for that):
`logcheck -l logfile` processes just this logfile
moved code to be called to new function logoutput()
the code there didn't change, just the logic how we are calling it.
added a debug message there, name change of switches as discussed on devel.
works fine for me, please double check.
hope you like it? :)


--- /cvsroot/logcheck/logcheck/src/logcheck	2004/06/11 09:27:30	1.61
+++ /cvsroot/logcheck/logcheck/src/logcheck	2004/06/12 18:31:32	1.62
@@ -22,7 +22,7 @@
 # along with Logcheck; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-# $Id: logcheck,v 1.61 2004/06/11 09:27:30 alfie Exp $
+# $Id: logcheck,v 1.62 2004/06/12 18:31:32 maks-guest Exp $
 
 
 # Set the umask
@@ -34,7 +34,7 @@
 ATTACK=0
 
 # Set the getopts string
-GETOPTS="c:dhl:opr:RsS:tT:uvw"
+GETOPTS="c:dhl:L:opr:RsS:tT:uvw"
 
 # Get the details for the email message
 # Hostname either fully qualified or not.
@@ -60,7 +60,7 @@
 RULEDIR="/etc/logcheck"
 CONFFILE="/etc/logcheck/logcheck.conf"
 STATEDIR="/var/lib/logcheck"
-LOGFILE="/etc/logcheck/logcheck.logfiles"
+LOGFILES_LIST="/etc/logcheck/logcheck.logfiles"
 LOGTAIL="/usr/sbin/logtail"
 CAT="/bin/cat"
 SYSLOG_SUMMARY="/usr/bin/syslog-summary"
@@ -362,6 +362,44 @@
     fi
 }
 
+logoutput() {
+    file=$1
+
+    # There are some problems with this section.
+    debug "logoutput called with file: $file"
+    if [ -f $file ]; then
+	offsetfile="$STATEDIR/offset$(echo $file|tr / .)"
+	if [ -s $offsetfile ]; then
+	    if [ $(wc -c < $file) -lt $(tail -n 1  $offsetfile) ]; then
+		if [ -e $file.0 ]; then
+	        # assume the log is rotated by savelog(8)
+		    debug "Running logtail on rotated: $file.0"
+		    $LOGTAIL -f $file.0 -o $offsetfile $LOGTAIL_OPTS > \
+			$TMPDIR/logoutput/$(basename $file) \
+			|| error "Could not run logtail or save output"
+		    rm -f $offsetfile \
+		        || error "Could not remove $offsetfile"

[103 lines skipped]