Imported Upstream version 0.64
Willi Mann
11 years ago
12 | 12 | and writing to a string that had been c_str() in another - pretty |
13 | 13 | big coding mistakes if you ask me. Naughty boy etc. |
14 | 14 | |
15 | So the sorting should be fine now (provided I haven't coded other | |
16 | errors) so please use the STL sort (for faster results too) and let | |
17 | me know if it breaks for you: set "bRepMySort" to "no" and as I | |
18 | previously explained: | |
15 | For stability reasons my routines are still used, however this | |
16 | is not the fastest solution. You can get about a 20% speed boost | |
17 | if you set "bRepMySort" to "no", as I previously explained: | |
19 | 18 | |
20 | 19 | > There are two variables in squidview.conf which direct |
21 | 20 | > sorting operations. "bRepMySort" can be set to "yes" to use |
0 | 0 | >> Squidview history: |
1 | ||
2 | v0.64: 17 February 2004: | |
3 | - reverted back to stable, slower sort as a bug still lurks | |
4 | - minor documentation fixes | |
1 | 5 | |
2 | 6 | v0.63: 17 December 2003: |
3 | 7 | - fixes to allow compiling in some environments |
0 | squidview 0.6 (c) 2001 - 2003 Graeme Sheppard - GPL software | |
0 | squidview 0.6 (c) 2001 - 2004 Graeme Sheppard - GPL software | |
1 | 1 | www.rillion.net/squidview |
2 | 2 | |
3 | 3 | --Overview |
28 | 28 | /usr/local/squid/var/logs/access.log |
29 | 29 | If it isn't just symlink it appropriately from the following |
30 | 30 | default. This directory and links are made in the user's home |
31 | space when first run by the user. | |
31 | space when squidview is first run by the user. | |
32 | 32 | |
33 | 33 | graeme@localhost:~/.squidview$ ls -l |
34 | HOWTO -> /usr/local/share/doc/squidview/HOWTO | |
34 | HOWTO -> /usr/local/share/squidview/HOWTO | |
35 | 35 | log1 -> /usr/local/squid/var/logs/access.log |
36 | 36 | log2 -> log1 |
37 | 37 | log3 -> log1 |
39 | 39 | words |
40 | 40 | |
41 | 41 | In this case squidview expects the primary log to be "log1", |
42 | and the symlink redirects it to where the file actually is. | |
43 | The same thing applies to the readme. | |
42 | and the symlink redirects it to where the file actually is. Three | |
43 | log locations are supported which gives you a bit of room for | |
44 | accomodating rotating logs. | |
44 | 45 | |
45 | 46 | This tar.gz archive comes with an example access.log named |
46 | example.log. Symlink it to view it with squidview. | |
47 | example.log. Symlink it to view it with squidview, or copy it to | |
48 | your ~/.squidview directory. The same applies to the HOWTO. | |
47 | 49 | |
48 | 50 | "users" and "words" are reporting files - these can be symlinks |
49 | 51 | to /etc if you would rather have these files there. "aliases" is |
0 | squidview 0.60 (c) 2001 - 2003 Graeme Sheppard - GPL software | |
0 | squidview 0.60 (c) 2001 - 2004 Graeme Sheppard - GPL software | |
1 | 1 | www.rillion.net/squidview |
2 | 2 | |
3 | 3 | --Overview |
4 | 4 | |
5 | Squidview is a program meant to display the squid proxy server log | |
5 | Squidview is a program that displays the squid proxy server log | |
6 | 6 | file in a nice fashion, providing the log file is in squid's |
7 | 7 | native reporting fashion. It has features such as search, report |
8 | 8 | generation, monitor mode and supports three log files. |
12 | 12 | this program is not a proactive resource controller. What it can |
13 | 13 | do is tell you who and which sites are consuming the most bandwidth. |
14 | 14 | |
15 | First time users should read INSTALL and HOWTO. | |
16 | ||
15 | 17 | You will need the ncurses library. |
693 | 693 | |
694 | 694 | PACKAGE=squidview |
695 | 695 | |
696 | VERSION=0.63 | |
696 | VERSION=0.64 | |
697 | 697 | |
698 | 698 | if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then |
699 | 699 | { echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; } |
0 | 0 | AC_INIT(squidview.cpp) |
1 | 1 | AM_CONFIG_HEADER(config.h) |
2 | AM_INIT_AUTOMAKE(squidview,0.63) | |
2 | AM_INIT_AUTOMAKE(squidview,0.64) | |
3 | 3 | AC_PROG_CXX |
4 | 4 | AC_PROG_INSTALL |
5 | 5 |
16 | 16 | |
17 | 17 | A program to nicely browse your squid log |
18 | 18 | |
19 | (c) 2001, 2002, 2003 Graeme Sheppard | |
19 | (c) 2001 - 2004 Graeme Sheppard | |
20 | 20 | |
21 | 21 | This program is not how it would be if I had to rewrite it from scratch. |
22 | 22 | It started off very simple (quick and nasty) and needed to be fast because |
212 | 212 | if (snprintf (szTemp, sizeof (szTemp), "%d", iNumber) < 0) |
213 | 213 | return "0"; |
214 | 214 | sReturn = szTemp; |
215 | ||
215 | 216 | return sReturn; |
216 | 217 | } |
217 | 218 | |
227 | 228 | return "0"; |
228 | 229 | |
229 | 230 | sReturn = szTemp; |
231 | ||
230 | 232 | iIndex = sReturn.length(); |
231 | 233 | if (iIndex == 0) |
232 | 234 | return sReturn; |
1491 | 1493 | } |
1492 | 1494 | |
1493 | 1495 | |
1494 | string PosToTime (tFilePos iCurrent) | |
1496 | // get the request's time out of it | |
1497 | string RequestToTime (const char* szRequest) | |
1495 | 1498 | { |
1496 | 1499 | string sTime; |
1497 | 1500 | time_t iTime; |
1499 | 1502 | if (iLogFileSize == 0) |
1500 | 1503 | return ""; |
1501 | 1504 | |
1502 | GetLine (iCurrent); | |
1503 | if (NullText (pcReqBuff)) | |
1505 | if (NullText (szRequest)) | |
1504 | 1506 | return ""; |
1505 | 1507 | |
1506 | iTime = GetTimeNumber (pcReqBuff); | |
1508 | iTime = GetTimeNumber (szRequest); | |
1507 | 1509 | CalcTime (iTime, sTime); |
1508 | 1510 | RemoveSeconds (sTime); |
1509 | 1511 | return sTime; |
1512 | } | |
1513 | ||
1514 | ||
1515 | // get the time from an arbitary point in log file | |
1516 | string FilePosToTime (tFilePos iCurrent) | |
1517 | { | |
1518 | if (iLogFileSize == 0) | |
1519 | return ""; | |
1520 | ||
1521 | GetLine (iCurrent); | |
1522 | return RequestToTime (pcReqBuff); | |
1510 | 1523 | } |
1511 | 1524 | |
1512 | 1525 | |
1523 | 1536 | if (iRepStart == 0) |
1524 | 1537 | sTemp1 = "begining of log"; |
1525 | 1538 | else |
1526 | sTemp1 = PosToTime (iRepStart); | |
1539 | sTemp1 = FilePosToTime (iRepStart); | |
1527 | 1540 | |
1528 | 1541 | if (iRepEnd == 0) |
1529 | 1542 | sTemp2 = "end of log"; |
1530 | 1543 | else |
1531 | sTemp2 = PosToTime (iRepEnd); | |
1544 | sTemp2 = FilePosToTime (iRepEnd); | |
1532 | 1545 | |
1533 | 1546 | switch (iRepWordHits) |
1534 | 1547 | { |
1972 | 1985 | EraseStatusLine(); |
1973 | 1986 | refresh(); |
1974 | 1987 | printf ("%s\r", sText.c_str()); |
1975 | ShowHighLightMessage (sStatusLine); | |
1988 | ShowHighLightMessage (sStatusLine); /// don't like this bit | |
1976 | 1989 | } |
1977 | 1990 | |
1978 | 1991 | if (fwrite (sText.c_str(), 1, sText.length(), fOutput) != sText.length()) |
2129 | 2142 | if (sRepTitle != "") |
2130 | 2143 | WriteReportLine (sRepTitle + "\n\n"); |
2131 | 2144 | |
2132 | sTemp = PosToTime (iCurrent); | |
2145 | sTemp = FilePosToTime (iCurrent); | |
2133 | 2146 | if (iRepEnd == 0) |
2134 | sTemp2 = PosToTime (iLastPage); | |
2147 | sTemp2 = FilePosToTime (iLastPage); | |
2135 | 2148 | else |
2136 | sTemp2 = PosToTime (iRepEnd); | |
2149 | sTemp2 = FilePosToTime (iRepEnd); | |
2137 | 2150 | |
2138 | 2151 | if (sTemp2 == sTemp) |
2139 | 2152 | WriteReportLine ("For " + sTemp + "\n\n"); |
4510 | 4523 | CalcPercentage (iLinePos, iLastLinePos, sTemp); |
4511 | 4524 | NoLeadingSpaces (sTemp); |
4512 | 4525 | con << "All Users' Tally Mode\n\nCurrent position is " |
4513 | << PosToTime (iRepStart) | |
4526 | << FilePosToTime (iRepStart) | |
4514 | 4527 | << " (" << sTemp << ")\n\nPress enter to begin from here.\n\n" |
4515 | 4528 | << "Note this might take a while."; |
4516 | 4529 | iKey = getch(); |
5247 | 5260 | void Help() |
5248 | 5261 | { |
5249 | 5262 | MyCls(); |
5250 | con << PACKAGE << " " << VERSION << ": (c) " << "2001-2003" | |
5263 | con << PACKAGE << " " << VERSION << ": (c) " << "2001-2004" | |
5251 | 5264 | << " Graeme Sheppard - GPL software\n" |
5252 | 5265 | << "www.rillion.net/squidview\n\n" << |
5253 | 5266 | "Keystrokes:-\n\n" |
16 | 16 | |
17 | 17 | A program to nicely browse your squid log |
18 | 18 | |
19 | (c) 2001, 2002, 2003 Graeme Sheppard | |
19 | (c) 2001 - 2004 Graeme Sheppard | |
20 | 20 | |
21 | 21 | */ |
22 | 22 | |
155 | 155 | bool bLookupIP = true; |
156 | 156 | bool bAliases = false; |
157 | 157 | int iRepFast = 10000; |
158 | bool bRepMySort = false; | |
158 | bool bRepMySort = true; | |
159 | 159 | |
160 | 160 | struct sRecordPointer |
161 | 161 | { |