Results 1 to 4 of 4

Thread: Installation and operation of Squint

  1. #1
    Join Date
    Jun 2009
    Posts
    404

    Installation and operation of Squint

    I tried desperately to install Squint-0.3.18 server on IPCOP 1.4.21 and I encounter some "concerns" with the script squint.cron.sh.

    What I do:

    1) I unpacks the archive
    tar-zxvf squint.tgz

    2) I copy and squint.pl squint.cron.sh in / usr / local / bin
    squint.pl squint.cron.sh cp / usr / local / bin

    3) I created the directory squint in / home / httpd / html /
    mkdir squint

    4) I publish squint.cron.sh and I change the variables
    BASEDIR = / home / httpd / html \
    LOGDIR = / var / log / squid \
    HTTPDCONF = / etc / httpd / conf / httpd.conf

    5) As indicated in the doc I squint launches squint.cron.sh init command to create entries in the Tables cron and a few hives of statements ... and there the trouble begins!
    The system sends me a "/ usr / local / bin / squint.cron.sh: line 61: tty: command not found" most ominous!

    I decided to edit the file squint.cron.sh and comment out the lines with the function in question:

    # If we are not on a tty, then log to file
    # tty-s | | {
    # Exec> & $ BASEDIR / squint.log
    # Date
    # Trap "date" EXIT
    #}

    I raise the squint.cron.sh init command, and there are no errors. I see the creation of directories squint in / home / httpd / html / and all in / home / httpd / html / squint, as well as several files index.html. However, no entry in fcrontab (fcrontab-l), which after verification seems normal because the script squint.cron.sh seeks to modify the crontab file and not fcrontab.

    checkcrontab function ()
    {
    # Install CRONTAB if crontab is writable
    CRONTAB = "/ etc / crontab"
    [-W $ CRONTAB] | | return

    grep-q "squint" $ crontab | |
    echo "# squint squid reports
    # Weekly on Mondays
    00 01 * Monday * root / usr / local / bin / squint.cron.sh weekly
    # Monthly, on the first day of the month
    00 02 1 * * root / usr / local / bin / monthly squint.cron.sh
    # Daily at 3am
    00 03 * * * root / usr / local / bin / squint.cron.sh daily ">> $ crontab -1 & & killall crond cron 2> / dev / null
    }

    Still referring me to the doc (brief) I start to squint squint.cron.sh order to generate all the statements from the squid logs. This time the 'system says a "/ usr / local / bin / squint.cron.sh: line 140: xargs: command not found"

    I decided to pass me the script and I squint.cron.sh directly generates the states with the command cat / var / log / squid / access.log |. / Squint.pl / home / httpd / html / squint /.

    Everything works so perfectly, the states are generated and accessible via the browser https: / / IPCOP: XXX / squint / index.html. However, I must run this command manually every day and I can not generate reports from acces.log archived files.

    I leave it up to you to bring me some help and answer my questions:

    Why is my version of IPCOP does not have the command "TTY"? Why is my version of IPCOP does not command "xargs"? How do I change the script so that it modifies squint.cron.sh fcrontab not the crontab? More generally, this version of squint (0.3.18) is it supported by V IPCOP 1.4.21?

  2. #2
    Join Date
    May 2008
    Posts
    2,945

    Re: Installation and operation of Squint

    Perhaps you should clarify the subject:

    - Squint is a generator status from the logs of proxy (squid).

    Squint uses bash and perl to work and relies on a system cron jobs.

    The website indicates
    Technical note: Squint is quite resource intensive. It takes around 15 minutes to 1 week analysis of web traffic for 50 users. The size of the generated reports is also considerably larger than the size of the original data.
    1st question: Are there cron on IPCop?
    Whether that's the case but I think it's not (as elsewhere in pfSense).

    2nd question: are there alternatives to Squint?
    I use on other systems (Debian and pfSense) LightSquid the progam and I am satisfied.

  3. #3
    Join Date
    Jun 2009
    Posts
    404

    Re: Installation and operation of Squint

    Thank you for your prompt response.

    It seems that the "prerequisites" required for Squint is available under IPCOP: Squid, Perl (?), Bash, local web server (instead of Apache), but lacks actual cron, replaced by the binary fcron.

    Regarding the alternatives I tried Sarg, but very very very greedy in terms of space. Lightsquid is already installed on the server but does not meet all the demand in particular for connection time thing is very well Squint.

    Squint works well, it is "fair" to adapt the script squint.cron.sh automation and generation of reports, but in this area I am unfortunately not a crack!


    / bin / bash

    # Squint.cron.sh - Quick and Dirty squid log analysis
    #
    # Assemble squid logs, and send through squint.pl. This script gets run on a
    # Regular basis. It will install itself in crontab if you give it a chance.

    REVISION = '$ Id: squint.cron.sh, v 1.26 2005/09/30 10:06:40 andrewm Exp $'
    SHORTREVISION = "$ (REVISION / *, v)"
    SHORTREVISION = "$ (SHORTREVISION / *)"

    # You can override automatic 'detection' by editing this, or by setting
    # Environment year variable:
    # BASEDIR = "/ usr / local / httpd / htdocs / squint"
    # LOGDIR = "/ var / log / squid"
    SQUINT = "$ (SQUINT: nice = / usr / local / bin / squint.pl)"
    # If you run setuphtaccess
    HTTPDCONF = / etc / httpd / conf / httpd.conf

    # Irix does not have-maxdepth 1 we find, so we'll work around it
    FINDOPTS = "-maxdepth 1"
    find / dev / null $ FINDOPTS> & / dev / null | FINDOPTS =

    # Find a nice place to put the output - Semi-automatic nonsense that is bound
    # To fail sooner or later. If you do not like this, you can change and BASEDIR
    # LOGDIR above
    [ "$ BASEDIR"] | |
    for DIR in \
    / home / httpd / html / squint \
    / var / www \
    / usr / local / httpd / htdocs \
    / var / www / htdocs \
    / var / www / html \
    / srv / www / htdocs \
    / var / www / htdocs \
    ; Do
    if [-d $ DIR] then BASEDIR = $ DIR / squint; fi
    done
    [ "$ LOGDIR"] | |
    for DIR in \
    / var / squid / logs \
    / var / log / squid \
    / usr / local / squid / var / logs \
    ; Do
    if [-d $ DIR] then LOGDIR = $ DIR; fi
    done
    [ "$ BASEDIR"] | | (echo 1> & 2 "Please set BASEDIR in $ 0"; exit 1; )
    [ "$ LOGDIR"] | | (echo 1> & 2 "Please set LOGDIR in $ 0"; exit 1; )
    umask 002

    # If we are not on a tty, then log to file
    tty-s | | {
    exec> & $ BASEDIR / squint.log
    date
    trap "date" EXIT
    }

    # Print a header
    htmlHead function ()
    {
    HEADING = "$ 1"
    echo "<HTML>
    <HEAD>
    <TITLE> $ HEADING </ TITLE>
    </ HEAD>
    <BODY>
    <H1> $ Heading </ H1> ";
    }

    htmlfooter function ()
    {
    echo "<HR> <FONT size=-4> Generated by <a
    href = http://www.ledge.co.za/software/squint/> squint </a> at `date`
    by $ HOSTNAME $ <br> REVIEW <br> </ FONT> </BODY> </HTML> ";
    }

    checkcrontab function ()
    {
    # Install CRONTAB if crontab is writable
    CRONTAB = "/ etc / crontab"
    [-W $ CRONTAB] | | return

    grep-q "squint" $ crontab | |
    echo "# squint squid reports
    # Weekly on Mondays
    00 01 * Monday * root / usr / local / bin / squint.cron.sh weekly
    # Monthly, on the first day of the month
    00 02 1 * * root / usr / local / bin / monthly squint.cron.sh
    # Daily at 3am
    00 03 * * * root / usr / local / bin / squint.cron.sh daily ">> $ crontab -1 & & killall crond cron 2> / dev / null
    }

    # Create file index.html
    doupdateindex function ()
    {
    mkdir-p $ REPORTDIR
    # Write the file index.html
    {
    htmlHead "Squint reports";
    if [-f $ REPORTDIR / daily / range.txt] then
    echo "<H2> Daily report </ H2>"
    echo "<A href=daily/index.html> Daily (` cat $ REPORTDIR / daily / range.txt `) </ A> <BR>";
    fi

    echo "<H2> Weekly reports </ H2>";
    for NUM in 0 1 2 3 4 5 6; # do some bash versions dislike 'for ((a = 0; a <7; has ++))..'
    if [-f $ REPORTDIR / weekly $ NUM / range.txt] then
    echo "<A href=weekly$NUM/index.html>` cat $ REPORTDIR / weekly $ NUM / range.txt `</ A> <BR>"
    fi
    done

    echo "<H2> Monthly reports </ H2>";
    for NUM in 0 1 2 3 4 5 6; do
    if [-f $ REPORTDIR / monthly $ NUM / range.txt] then
    echo "<A href=monthly$NUM/index.html>` cat $ REPORTDIR / monthly $ NUM / range.txt `</ A> <BR>"
    fi
    done

    htmlfooter

    }> $ REPORTDIR / index.html

    checkcrontab
    } # End of function doupdateindex

    # Find the access logs, and concatenate them to stdout in the right order
    # (Ie. in the order In which the events happened)
    cataccesslogs function ()
    {
    $ find $ LOGDIR FINDOPTS-name 'access.log *'-mtime - $ DAYS |
    xargs ls-tr / dev / null |
    while read LOGFILE; do
    [-R "$ LOGFILE"] & &
    case "$ LOGFILE" in
    *. gz) zcat "$ LOGFILE";;
    *. bz2) bzcat "$ LOGFILE";;
    *) Cat "$ LOGFILE";;
    esac
    done
    }

    DoReport function ()
    {
    # DoReport FROMTIME-WHEN DESTINATION
    DAYS = "$ 1"
    FROMTIME = "$ 2"
    TOTIME = "$ 3"
    DESTDIR = "$ REPORTDIR / $ 4"
    Starttime = `date +% s-d" $ FROMTIME "`
    EndTime = `date +% s-d" $ TOTIME "`
    echo "Generating report to $ DESTDIR from" \
    "` date +% Y% m% d-d "$ FROMTIME" `" "to" \
    "` date +% Y% m% d-d "$ TOTIME" `"

    [-D $ DESTDIR] & & rm-r $ DESTDIR
    mkdir-p $ DESTDIR
    # Unzip files before use ...
    # Find $ LOGDIR $ FINDOPTS-name "access.log-*. gz"-mtime - $ DAYS-exec gunzip () \;
    cataccesslogs | SQUINT $ $ $ DESTDIR EXCLUDEOPTIONS STARTTIME $ $ $ ENDTIME USERLIST
    doupdateindex
    }

    # Rotate the logs in the directory
    rotatereports function ()
    {
    mkdir-p $ REPORTDIR
    TYPE = "$ 1" # daily / weekly
    rm-r $ REPORTDIR / $ (TYPE) 6
    mv 2> / dev / null-f $ REPORTDIR / $ (TYPE) $ 5 REPORTDIR / $ (TYPE) 6
    mv 2> / dev / null-f $ REPORTDIR / $ (TYPE) $ 4 REPORTDIR / $ (TYPE) 5
    mv 2> / dev / null-f $ REPORTDIR / $ (TYPE) $ 3 REPORTDIR / $ (TYPE) 4
    mv 2> / dev / null-f $ REPORTDIR / $ (TYPE) $ 2 REPORTDIR / $ (TYPE) 3
    mv 2> / dev / null-f $ REPORTDIR / $ (TYPE) REPORTDIR $ 1 / $ (TYPE) 2
    mv 2> / dev / null-f $ REPORTDIR / $ (TYPE) $ 0 REPORTDIR / $ (TYPE) 1
    }

    setuphtaccess function ()
    {
    if [-w $ HTTPDCONF] then
    grep-q "Added by squint" $ HTTPDCONF | | echo "
    # - Begin squint --
    # Added by squint - allow. Htaccess files in $ BASEDIR
    <Directory $BASEDIR>
    AllowOverride AuthConfig Limit
    </ Directory>
    # - Squint end --
    ">> $ HTTPDCONF
    else
    echo 1> & 2 "$ HTTPDCONF not modified ... it's not there"
    fi

    Dirname = `cd $ REPORTDIR; pwd-P`
    AuthUserFile = "$ dirname / .htpasswd"
    touch "$ AuthUserFile"
    echo "AuthUserFile $ AuthUserFile
    AuthGroupFile / dev / null
    AuthName \ "Squint files for` basename $ DIRNAME `\"
    AuthType Basic

    GET <Limit POST>
    require valid-user
    </ Limit>
    ">" $ REPORTDIR / .htaccess "
    echo 1> & 2 ". htaccess files in $ dirname"
    }

    # Update the list of groups
    updategrouplist function ()
    {

    {
    htmlHead "Squint reports - report list"
    echo "<a href=all/index.html> Reports for all users </ a> <br>"
    if [-d "$ listdir"] then
    for LISTFILE in `ls" $ listdir "`; do
    [ "$ LISTFILE" = "all"] & & continue
    HREF = "$ LISTFILE / index.html"
    DESC = $ LISTFILE
    [-F $ LISTFILE / DESC.TXT] & & DESC = "` cat $ LISTFILE / DESC.TXT `"
    echo "$ DESC <a href=$HREF> </ a> <br>"
    done
    fi
    htmlfooter
    }> $ BASEDIR / index.html

    }


    doreporting function ()
    {
    MONTH = "` date '+% Y% m01' `"
    case "$ 1" in
    htaccess)
    setuphtaccess;
    ;;
    doupdateindex)
    doupdateindex
    ;;
    regen)
    for report in daily weekly0 weekly1 weekly2 weekly3 weekly4 weekly5 weekly6 monthly0 monthly1 monthly2 monthly3 monthly4 monthly5 monthly6; do
    $ doreporting report
    done
    ;;
    grep)
    if [ "$ 3"] then
    DAYS = 365 # 1 year
    cataccesslogs | egrep "$ 2" | $ 3 $ SQUINT
    else
    echo "Usage: $ 0 grep '\ <192 \ .168 \ .12 \ .13 \>"
    fi
    # Do it once only ...
    exit 0
    ;;

    daily)
    # Weekend-so-far report
    7 DoReport "last monday" "now" daily
    ;;

    weekly0) 15 DoReport "last monday 1 week ago" "last monday week ago 0" weekly0;;
    weekly1) 21 DoReport "last monday 2 weeks ago" "last monday 1 week ago" weekly1;;
    weekly2) 28 DoReport "last monday 3 weeks ago" "last monday 2 weeks ago" weekly2;;
    weekly3) 35 DoReport "last monday 4 weeks ago" "last monday 3 weeks ago" weekly3;;
    weekly4) 42 DoReport "last monday 5 weeks ago" "last monday 4 weeks ago" weekly4;;
    weekly5) 49 DoReport "last monday 6 weeks ago" "last monday 5 weeks ago" weekly5;;
    weekly6) 56 DoReport "last monday 7 weeks ago" "last monday 6 weeks ago" weekly6;;

    weekly) # called on the first day of the week
    rotatereports weekly
    DoReport 8 "1 week ago 00:00" "00:00" weekly0
    ;;

    monthly0) DoReport 62 "$ MONTH 1 month ago" "$ MONTH 0 month ago" monthly0;;
    monthly1) DoReport 93 "$ MONTH 2 months ago" "$ MONTH 1 month ago" monthly1;;
    monthly2) DoReport 114 "$ MONTH 3 month ago" "$ MONTH 2 months ago" monthly2;;
    monthly3) DoReport 144 "$ MONTH 4 months ago" "$ MONTH 3 month ago" monthly3;;
    monthly4) DoReport 175 "$ MONTH 5 months ago" "$ MONTH 4 months ago" monthly4;;
    monthly5) DoReport 205 "$ MONTH 6 months ago" "$ MONTH 5 months ago" monthly5;;
    monthly6) DoReport 236 "$ MONTH 7 months ago" "$ MONTH 6 months ago" monthly6;;

    monthly) # called on the first day of the month
    rotatereports monthly
    DoReport 32 "$ MONTH 1 month ago" "$ MONTH 0 month ago" monthly0
    ;;
    init)
    doupdateindex
    ;;
    all)
    doreporting daily
    doreporting weekly
    doreporting monthly
    ;;
    htpasswd)
    echo-ne "User name for $ REPORTDIR / .htpasswd"
    read USER
    [$ USER] & & $ REPORTDIR htpasswd / .htpasswd $ USER
    ;;
    *)
    echo "$ rev squint.cron.sh SHORTREVISION (usually) run from cron"
    echo ""
    echo "Usage: $ 0 command"
    echo ""
    echo "Commands:"
    echo "Update daily the daily report"
    echo "Create the weekly weekly report and archive previous"
    echo "Create the monthly report and monthly archive previous"
    echo "htaccess Access control: make $ REPORTDIR / .htaccess and"
    echo "modify / mangle $ HTTPDCONF"
    echo "Update $ REPORTDIR htpasswd / .htpasswd"
    echo "regen Recreate all reports (may take hours)"
    echo "weekly [0-6] Recreate specific weekly report"
    echo "monthly [0-6] Recreate specific monthly report"
    echo ""
    echo "Find-an offender command"
    echo "grep '\ <192 \ .168 \ .12 \ .13 \>' report-directory"
    echo ""
    echo "Input is read from LOGDIR = $ LOGDIR"
    echo "Output is written to BASEDIR = $ BASEDIR"
    exit 1 # Avoid repeated usage reports
    ;;
    esac
    }

    # If there is a file called excludelist in the reports directory,
    # Then it is used for exclusions
    Excludefile = $ BASEDIR / excludelist
    if [-f $ excludefile] then
    EXCLUDEOPTIONS = "- exclude $ excludefile"
    else
    EXCLUDEOPTIONS = ""
    fi

    # If there is a dir called list / reports in the directory, then it is used ...
    Listdir = $ BASEDIR / lists
    if [-d "$ listdir"] then
    for LISTFILE in `ls" $ listdir "`; do
    [-F "$ listdir / $ LISTFILE"] | | continue
    [$ LISTFILE excludelist =] & & continue
    USERLIST = "$ listdir / $ LISTFILE"
    REPORTDIR = "$ BASEDIR / $ LISTFILE"
    doreporting "$ @"
    done
    fi
    if [! -e "$ listdir / all"] then
    # List for all $ BASEDIR / all /
    USERLIST = ""
    REPORTDIR = "$ BASEDIR / all"
    doreporting "$ @"
    fi
    updategrouplist

    exit 0

  4. #4
    Join Date
    May 2008
    Posts
    2,945

    Re: Installation and operation of Squint

    How can one determine a "connection time" from a log that lists only the "hits"? (files / objects accessed)

    While it is easy to say what time this machine has gained for the first time that day (beginning of a session), IMHO it is impossible to translate that into time added session that would set the connection time.

    For if the session starts at a known time, it stops at what time?

    I do not see the test. Or maybe it's a test manual adjustable:

    For example, we may set (unilaterally) a "session" is terminated when a user has gained nothing for 10 minutes. But then why not 10 minutes and 15 ...

    So I do not see the criterion "time of session / connection.

    Me, I like to LightSquid the button allocation of time in front of the @ ip (or name): if in doubt, we accessed the volumes per site per hour ...

    And anyway, the transmitted volume gives a good idea of time spent watching internet ...

Similar Threads

  1. Replies: 3
    Last Post: 25-11-2010, 05:03 AM
  2. Replies: 3
    Last Post: 10-09-2009, 06:35 PM
  3. Installation and operation of WAMP
    By Gyan Guru in forum Guides & Tutorials
    Replies: 1
    Last Post: 27-11-2008, 12:32 PM
  4. Vista Installation freezes at Completing Installation stage.
    By Manik in forum Vista Setup and Install
    Replies: 2
    Last Post: 01-01-2008, 01:07 PM
  5. msi installer error code 11708 (installation operation failed)
    By Javier Eduardo Bello Marcos in forum Windows Server Help
    Replies: 0
    Last Post: 17-02-2005, 11:39 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,718,242.09745 seconds with 17 queries