Sign up to create your own snipts, or login.

Public snipts » logs The latest public logs snipts.

showing 1-11 of 11 snipts for logs
  • Script that acts as a login shell replacement to log everything an user does
    #!/bin/bash
    #
    # spy shell by mcree@tricon.hu
    #
    # This is a shell wrapper for the script program from bsdutils
    # that can be used in /etc/passwd as a login shell to log
    # everything an user does.
    #
    # Protected by the General Public License v2
    #
     
    export SHELL="/bin/bash"
    script="/usr/bin/script"
     
    mydir="/var/log/spyshell"
    whoami=`/usr/bin/whoami`
    date=`/bin/date +%s.%N`
    mytty=`/bin/ps hTotty | head -n1 | tr '/' '_'`
     
    myprefix="$mydir/$whoami/$date.$mytty.$$"
    mkdir -p "$mydir/$whoami"
     
    mycompress() {
        gzip -9 "$myprefix".* 2>/dev/null
        exit 0
    }
    trap mycompress 0
     
    if [ "$TERM" = "dumb" ]; then    #noninteractive
        #set > $myprefix.dumb.env
        #echo "$*" > $myprefix.dumb.params
        #gzip "$myprefix".*
        ##strace -f -o $myprefix.strace /bin/bash "$@"
        exec $SHELL "$@"
    else			         #interactive
        if [ -z "$SPYSHELL" ]; then
    	export SPYSHELL=yes
    	set > $myprefix.env
            echo "$*" > $myprefix.params
    	$script -f -q -t $myprefix.log 2>$myprefix.timing
        else
    	#set > $myprefix.dumber.env
    	#echo "$*" > $myprefix.dumber.params
    	#gzip "$myprefix".*
    	exec $SHELL "$@"
        fi
    fi
    

    copy | embed

    0 comments - tagged in  posted by d1s4st3r on Apr 07, 2010 at 8:23 a.m. EDT
  • Apache Log File Retriever via FTP
    #!/bin/bash
    
    ## GLOBAL CONFIGS ##
    LOG=$(date +"%Y%m")
    let DAY=$(date +"%d")-1
    
    SITES=( [0]="domain1.tld" [1]="domain2.tld" [2]="domain3.tld" )
    USERS=( [0]="user1" [1]="user2" [2]="user3" )
    PASSW=( [0]="passw1" [1]="passw2" [2]="passw3" )
    FILES=( [0]="www.$LOG$DAY" [1]="www.$LOG$DAY.gz" [2]="www.$LOG$DAY" )
    
    for index in 0 1
    do
    	[ ! -d /srv_admin/remote_logs/${SITES[index]} ] && mkdir -p /srv_admin/remote_logs/${SITES[index]} || :
    	ftp -in ${SITES[index]}<<FTPEOF
    quote USER ${USERS[index]}
    quote PASS ${PASSW[index]}
    cd www_logs
    lcd /srv_admin/remote_logs/${SITES[index]}
    binary
    verbose
    passive
    get ${FILES[index]}
    exit
    FTPEOF
    done
    

    copy | embed

    0 comments - tagged in  posted by john_clarke on Nov 29, 2009 at 12:36 a.m. EST
  • Bash Log Rotator
    #!/bin/bash
    
    ## GLOBAL CONFIGURATIONS
    LOGS=( [0]="/usr/home/morpheus/cron/cron.log" )
    DATE=$(date +"%y_%m_%d")
    
    for index in 0
    do
    	cp ${LOGS[index]} ${LOGS[index]}.${DATE}
    	gzip -m9 ${LOGS[index]}.${DATE}
    	cat /dev/null > ${LOGS[index]}
    	printf "Log file rotated :)\n ============== \n" > ${LOGS[index]}
    done
    

    copy | embed

    0 comments - tagged in  posted by john_clarke on Nov 29, 2009 at 12:32 a.m. EST
  • Log file error histogram analysis
    #!/usr/bin/python
    
    # Useful spotting patterns in errors logged to files. Intended to be used 
    # on rolled log files where the filename contains the date or some other 
    # unique index or sequence.
    #
    # Example:
    #  foo-2009-04-23.log
    #  foo-2009-04-24.log
    #  foo-2009-04-25.log
    #
    # Use grep to generate the input for this script. Use a pattern which will 
    # match a variety of possible events. This works best when only one such 
    # event is reported per line.
    #
    # Use the '-o' flag to output only the matched section:
    #
    # > grep -o "\b\w*Exception\b" *
    #
    #   foo-2009-04-23.log:RuntimeException
    #   foo-2009-04-23.log:IOException
    #   foo-2009-04-23.log:IOException
    #   foo-2009-04-23.log:IOException
    #   foo-2009-04-24.log:FileNotFoundException
    #   foo-2009-04-24.log:IOException
    #   foo-2009-04-25.log:OutOfMemoryException
    #
    # Pipe this output to this script and you will get cross-referenced 
    # histograms of:
    #
    # By input file (date):
    #   Count for each error type
    #
    # By Error type:
    #   Count for each day of ocurrence
    #
    # Number of errors (per file/date) - descending order
    #
    # Number of errors (per error type) - descending order
    
    
    import sys
    from math import log
    
    date_exception = dict()
    exception_date = dict()
    exception_all = dict()
    date_all = dict()
    
    def splitlines():
        input = sys.stdin.readlines()
        
        for line in input:
            (date, exception) = line.strip().split(":")
    
            if (not date_all.has_key(date)):
                date_all[date] = 0
            
            date_all[date] += 1
            
            if (not exception_all.has_key(exception)):
                exception_all[exception] = 0
                
            exception_all[exception] += 1
            
            if (not date_exception.has_key(date)):
                date_exception[date] = dict()
    
            count_map = date_exception[date]
    
            if (not count_map.has_key(exception)):
                count_map[exception] = 0
    
            count_map[exception] += 1
    
            if (not exception_date.has_key(exception)):
                exception_date[exception] = dict()
    
            count_map = exception_date[exception]
    
            if (not count_map.has_key(date)):
                count_map[date] = 0
    
            count_map[date] += 1
    
    def print_bar(prefix, label, value):
        print prefix + "%-30s (%5d) %s" % (label, value, "#" * int(log(value+1)*3))
    
    if __name__ == '__main__':
        splitlines()
        
        print "\n"
        for k in date_exception.keys():
            d = date_exception[k]
            print k
            
            l = sorted(d.iteritems(), key=lambda (k,v): (v,k), reverse=True)
            for item in l:
                print_bar("    ", item[0], item[1])
                
        print "\n"        
        for k in exception_date.keys():
            d = exception_date[k]
            print k
            
            l = sorted(d.iteritems(), key=lambda (k,v): (v,k), reverse=True)
            for item in l:
                print_bar("    ", item[0], item[1])
    
        print "\n"
        for s in sorted(exception_all.iteritems(), key=lambda (k,v): (v,k), reverse=True):
            print_bar("", s[0], s[1])
    
        print "\n"
        for s in sorted(date_all.iteritems(), key=lambda (k,v): (v,k), reverse=True):
            print_bar("", s[0], s[1])
    
            
    

    copy | embed

    0 comments - tagged in  posted by tweakt on Oct 08, 2009 at 6:23 p.m. EDT
  • path, dv2
    Logs -/home/httpd/vhosts/mt-example.com/statistics/logs
    

    copy | embed

    0 comments - tagged in  posted by AvidDeville on Apr 17, 2009 at 7:37 p.m. EDT
  • commandline search server logs for activity in time frame
    # following date/time is day/month/year:hour:min:sec
    # as in 02/Feb/2009:23:59:59
    # leave off more for a broader range like:
    # 02/Feb/2009:0   ...here's mine:   [your structure may vary]
    grep -rn "26/Sep/2008:01:" /usr/local/apache/domlogs/*
    

    copy | embed

    0 comments - tagged in  posted by swbratcher on Feb 21, 2009 at 5:31 p.m. EST
  • Watch Apache Error Log
    tail -f /usr/local/apache/logs/error_log
    

    copy | embed

    0 comments - tagged in  posted by bhubbard on Feb 02, 2009 at 11:08 p.m. EST
  • View MySQL Log
    less /var/log/mysqld.log
    

    copy | embed

    0 comments - tagged in  posted by bhubbard on Feb 02, 2009 at 10:57 p.m. EST
  • For a typical qmail installation with Plesk, you can monitor the logs with the following command:
    tail -f /usr/local/psa/var/log/maillog
    

    copy | embed

    0 comments - tagged in  posted by bhubbard on Feb 02, 2009 at 9:19 p.m. EST
  • Clearing log files (without deleting them)
    find /var/log/ -name '*.*' -not \( -type d \) -print0 | xargs -0i sh -c "cat /dev/null > "{}""
    

    copy | embed

    0 comments - tagged in  posted by drewrockshard on Dec 31, 2008 at 6:36 a.m. EST
  • watch the last 50 lines of a file
    tail -f --lines=50 system.log
    

    copy | embed

    0 comments - tagged in  posted by cwpollock on Dec 19, 2008 at 9:26 a.m. EST
Sign up to create your own snipts, or login.