Skip to content

Instantly share code, notes, and snippets.

@free5ty1e
Last active August 29, 2015 14:11
Show Gist options
  • Save free5ty1e/300adb0800ba45f3fe4e to your computer and use it in GitHub Desktop.
Save free5ty1e/300adb0800ba45f3fe4e to your computer and use it in GitHub Desktop.

Revisions

  1. free5ty1e revised this gist Dec 13, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion xrdpLogMonitor.sh
    Original file line number Diff line number Diff line change
    @@ -38,7 +38,7 @@ while [ 1 -lt 2 ]; do
    #You will need sudo on the pi to cat this xrdp log
    sudo cat $logFileName

    #Uncomment the following line to search, for example, for USER: and display only those lines that contain it:
    #Uncomment the following line to search, for example, for "USER:" and display only those lines that contain it:
    #sudo cat $logFileName | grep USER:

    echo "$(date) <--- this is now"
  2. free5ty1e created this gist Dec 13, 2014.
    46 changes: 46 additions & 0 deletions xrdpLogMonitor.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,46 @@
    #!/bin/bash

    # xrdpLogMonitor.sh <optional timeout in seconds>
    # This script will check and spit out your xrdp log file every X seconds
    # (default 30 if not specified)
    # If the file size has changed since your last check, your terminal will beep (system alert)

    logFileName="/var/log/xrdp.log"

    if [ $# -eq 0 ];
    then
    echo "No arguments supplied, will use default time between log polls (30 seconds)"
    secondsBetweenLogPolls=30
    else
    echo "Using supplied timeout of $1 seconds between log polls"
    secondsBetweenLogPolls=$1
    fi


    function updateLogModifiedTimeAndBeepIfChanged()
    {
    lastLogModifiedTime=$LogModifiedTime
    LogModifiedTime="$(stat --printf="%Z" $logFileName)"
    if [ "$LogModifiedTime" != "$lastLogModifiedTime" ];
    then
    echo NEW LOG ACTIVITY CAPTURED!!!!

    #Below line creates the terminal beep
    echo -ne '\a'
    fi
    }

    while [ 1 -lt 2 ]; do
    updateLogModifiedTimeAndBeepIfChanged
    echo "$(ls -l $logFileName)"
    echo "Polling logfile $logFileName which was last modified at $LogModifiedTime..."

    #You will need sudo on the pi to cat this xrdp log
    sudo cat $logFileName

    #Uncomment the following line to search, for example, for “USER:” and display only those lines that contain it:
    #sudo cat $logFileName | grep USER:

    echo "$(date) <--- this is now"
    sleep $secondsBetweenLogPolls
    done