From 9ea5e8e8d26c2e26853782d0ee3ec82ae292906a Mon Sep 17 00:00:00 2001 From: Gregory Soutade Date: Wed, 19 Nov 2014 08:01:12 +0100 Subject: [PATCH 1/5] Initial commit --- .gitignore | 3 + LICENCE | 674 ++++++++++++++++++++ TODO | 5 + awstats_data.py | 12 + conf.py | 34 ++ default_conf.py | 61 ++ display.py | 387 ++++++++++++ docs/index.md | 552 +++++++++++++++++ docs/main.md | 92 +++ docs/modules.md | 460 ++++++++++++++ iplugin.py | 124 ++++ iwla.pot | 279 +++++++++ iwla.py | 810 ++++++++++++++++++++----- iwla_convert.pl | 34 -- iwla_get.sh | 20 + locales/fr_FR/LC_MESSAGES/iwla.mo | Bin 0 -> 2934 bytes locales/fr_FR/LC_MESSAGES/iwla.pot | 283 +++++++++ plugins/__init__.py | 2 + plugins/display/__init__.py | 1 + plugins/display/all_visits.py | 99 +++ plugins/display/istats_diff.py | 98 +++ plugins/display/referers.py | 225 +++++++ plugins/display/referers_diff.py | 61 ++ plugins/display/top_downloads.py | 106 ++++ plugins/display/top_hits.py | 106 ++++ plugins/display/top_pages.py | 105 ++++ plugins/display/top_visitors.py | 97 +++ plugins/post_analysis/__init__.py | 1 + plugins/post_analysis/referers.py | 173 ++++++ plugins/post_analysis/reverse_dns.py | 78 +++ plugins/post_analysis/top_downloads.py | 94 +++ plugins/post_analysis/top_hits.py | 78 +++ plugins/post_analysis/top_pages.py | 87 +++ plugins/pre_analysis/__init__.py | 1 + plugins/pre_analysis/page_to_hit.py | 103 ++++ plugins/pre_analysis/robots.py | 113 ++++ resources/css/iwla.css | 87 +++ resources/icon/vh.png | Bin 0 -> 239 bytes resources/icon/vk.png | Bin 0 -> 236 bytes resources/icon/vp.png | Bin 0 -> 248 bytes resources/icon/vu.png | Bin 0 -> 239 bytes resources/icon/vv.png | Bin 0 -> 239 bytes robots.py | 2 - tools/extract_doc.py | 30 + tools/extract_docs.sh | 16 + tools/gettext.sh | 3 + tools/iwla_convert.pl | 79 +++ 47 files changed, 5504 insertions(+), 171 deletions(-) create mode 100644 .gitignore create mode 100644 LICENCE create mode 100644 TODO create mode 100644 awstats_data.py create mode 100644 conf.py create mode 100644 default_conf.py create mode 100644 display.py create mode 100644 docs/index.md create mode 100644 docs/main.md create mode 100644 docs/modules.md create mode 100644 iplugin.py create mode 100644 iwla.pot delete mode 100755 iwla_convert.pl create mode 100755 iwla_get.sh create mode 100644 locales/fr_FR/LC_MESSAGES/iwla.mo create mode 100644 locales/fr_FR/LC_MESSAGES/iwla.pot create mode 100644 plugins/__init__.py create mode 100644 plugins/display/__init__.py create mode 100644 plugins/display/all_visits.py create mode 100644 plugins/display/istats_diff.py create mode 100644 plugins/display/referers.py create mode 100644 plugins/display/referers_diff.py create mode 100644 plugins/display/top_downloads.py create mode 100644 plugins/display/top_hits.py create mode 100644 plugins/display/top_pages.py create mode 100644 plugins/display/top_visitors.py create mode 100644 plugins/post_analysis/__init__.py create mode 100644 plugins/post_analysis/referers.py create mode 100644 plugins/post_analysis/reverse_dns.py create mode 100644 plugins/post_analysis/top_downloads.py create mode 100644 plugins/post_analysis/top_hits.py create mode 100644 plugins/post_analysis/top_pages.py create mode 100644 plugins/pre_analysis/__init__.py create mode 100644 plugins/pre_analysis/page_to_hit.py create mode 100644 plugins/pre_analysis/robots.py create mode 100644 resources/css/iwla.css create mode 100644 resources/icon/vh.png create mode 100644 resources/icon/vk.png create mode 100644 resources/icon/vp.png create mode 100644 resources/icon/vu.png create mode 100644 resources/icon/vv.png delete mode 100644 robots.py create mode 100755 tools/extract_doc.py create mode 100755 tools/extract_docs.sh create mode 100755 tools/gettext.sh create mode 100755 tools/iwla_convert.pl diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e03b74e --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*~ +*.pyc +*.gz \ No newline at end of file diff --git a/LICENCE b/LICENCE new file mode 100644 index 0000000..94a9ed0 --- /dev/null +++ b/LICENCE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/TODO b/TODO new file mode 100644 index 0000000..4999056 --- /dev/null +++ b/TODO @@ -0,0 +1,5 @@ +doc enhancement +Limit hits/pages/downloads by rate +Automatic tests +Free memory as soon as possible +Remove some IP from statistics diff --git a/awstats_data.py b/awstats_data.py new file mode 100644 index 0000000..8789384 --- /dev/null +++ b/awstats_data.py @@ -0,0 +1,12 @@ +robots = ['appie', 'architext', 'jeeves', 'bjaaland', 'contentmatch', 'ferret', 'googlebot', 'google\-sitemaps', 'gulliver', 'virus[_+ ]detector', 'harvest', 'htdig', 'linkwalker', 'lilina', 'lycos[_+ ]', 'moget', 'muscatferret', 'myweb', 'nomad', 'scooter', 'slurp', '^voyager\/', 'weblayers', 'antibot', 'bruinbot', 'digout4u', 'echo!', 'fast\-webcrawler', 'ia_archiver\-web\.archive\.org', 'ia_archiver', 'jennybot', 'mercator', 'netcraft', 'msnbot\-media', 'msnbot', 'petersnews', 'relevantnoise\.com', 'unlost_web_crawler', 'voila', 'webbase', 'webcollage', 'cfetch', 'zyborg', 'wisenutbot', '[^a]fish', 'abcdatos', 'acme\.spider', 'ahoythehomepagefinder', 'alkaline', 'anthill', 'arachnophilia', 'arale', 'araneo', 'aretha', 'ariadne', 'powermarks', 'arks', 'aspider', 'atn\.txt', 'atomz', 'auresys', 'backrub', 'bbot', 'bigbrother', 'blackwidow', 'blindekuh', 'bloodhound', 'borg\-bot', 'brightnet', 'bspider', 'cactvschemistryspider', 'calif[^r]', 'cassandra', 'cgireader', 'checkbot', 'christcrawler', 'churl', 'cienciaficcion', 'collective', 'combine', 'conceptbot', 'coolbot', 'core', 'cosmos', 'cruiser', 'cusco', 'cyberspyder', 'desertrealm', 'deweb', 'dienstspider', 'digger', 'diibot', 'direct_hit', 'dnabot', 'download_express', 'dragonbot', 'dwcp', 'e\-collector', 'ebiness', 'elfinbot', 'emacs', 'emcspider', 'esther', 'evliyacelebi', 'fastcrawler', 'feedcrawl', 'fdse', 'felix', 'fetchrover', 'fido', 'finnish', 'fireball', 'fouineur', 'francoroute', 'freecrawl', 'funnelweb', 'gama', 'gazz', 'gcreep', 'getbot', 'geturl', 'golem', 'gougou', 'grapnel', 'griffon', 'gromit', 'gulperbot', 'hambot', 'havindex', 'hometown', 'htmlgobble', 'hyperdecontextualizer', 'iajabot', 'iaskspider', 'hl_ftien_spider', 'sogou', 'iconoclast', 'ilse', 'imagelock', 'incywincy', 'informant', 'infoseek', 'infoseeksidewinder', 'infospider', 'inspectorwww', 'intelliagent', 'irobot', 'iron33', 'israelisearch', 'javabee', 'jbot', 'jcrawler', 'jobo', 'jobot', 'joebot', 'jubii', 'jumpstation', 'kapsi', 'katipo', 'kilroy', 'ko[_+ ]yappo[_+ ]robot', 'kummhttp', 'labelgrabber\.txt', 'larbin', 'legs', 'linkidator', 'linkscan', 'lockon', 'logo_gif', 'macworm', 'magpie', 'marvin', 'mattie', 'mediafox', 'merzscope', 'meshexplorer', 'mindcrawler', 'mnogosearch', 'momspider', 'monster', 'motor', 'muncher', 'mwdsearch', 'ndspider', 'nederland\.zoek', 'netcarta', 'netmechanic', 'netscoop', 'newscan\-online', 'nhse', 'northstar', 'nzexplorer', 'objectssearch', 'occam', 'octopus', 'openfind', 'orb_search', 'packrat', 'pageboy', 'parasite', 'patric', 'pegasus', 'perignator', 'perlcrawler', 'phantom', 'phpdig', 'piltdownman', 'pimptrain', 'pioneer', 'pitkow', 'pjspider', 'plumtreewebaccessor', 'poppi', 'portalb', 'psbot', 'python', 'raven', 'rbse', 'resumerobot', 'rhcs', 'road_runner', 'robbie', 'robi', 'robocrawl', 'robofox', 'robozilla', 'roverbot', 'rules', 'safetynetrobot', 'search\-info', 'search_au', 'searchprocess', 'senrigan', 'sgscout', 'shaggy', 'shaihulud', 'sift', 'simbot', 'site\-valet', 'sitetech', 'skymob', 'slcrawler', 'smartspider', 'snooper', 'solbot', 'speedy', 'spider[_+ ]monkey', 'spiderbot', 'spiderline', 'spiderman', 'spiderview', 'spry', 'sqworm', 'ssearcher', 'suke', 'sunrise', 'suntek', 'sven', 'tach_bw', 'tagyu_agent', 'tailrank', 'tarantula', 'tarspider', 'techbot', 'templeton', 'titan', 'titin', 'tkwww', 'tlspider', 'ucsd', 'udmsearch', 'universalfeedparser', 'urlck', 'valkyrie', 'verticrawl', 'victoria', 'visionsearch', 'voidbot', 'vwbot', 'w3index', 'w3m2', 'wallpaper', 'wanderer', 'wapspIRLider', 'webbandit', 'webcatcher', 'webcopy', 'webfetcher', 'webfoot', 'webinator', 'weblinker', 'webmirror', 'webmoose', 'webquest', 'webreader', 'webreaper', 'websnarf', 'webspider', 'webvac', 'webwalk', 'webwalker', 'webwatch', 'whatuseek', 'whowhere', 'wired\-digital', 'wmir', 'wolp', 'wombat', 'wordpress', 'worm', 'woozweb', 'wwwc', 'wz101', 'xget', '1\-more_scanner', 'accoona\-ai\-agent', 'activebookmark', 'adamm_bot', 'almaden', 'aipbot', 'aleadsoftbot', 'alpha_search_agent', 'allrati', 'aport', 'archive\.org_bot', 'argus', 'arianna\.libero\.it', 'aspseek', 'asterias', 'awbot', 'baiduspider', 'becomebot', 'bender', 'betabot', 'biglotron', 'bittorrent_bot', 'biz360[_+ ]spider', 'blogbridge[_+ ]service', 'bloglines', 'blogpulse', 'blogsearch', 'blogshares', 'blogslive', 'blogssay', 'bncf\.firenze\.sbn\.it\/raccolta\.txt', 'bobby', 'boitho\.com\-dc', 'bookmark\-manager', 'boris', 'bumblebee', 'candlelight[_+ ]favorites[_+ ]inspector', 'cbn00glebot', 'cerberian_drtrs', 'cfnetwork', 'cipinetbot', 'checkweb_link_validator', 'commons\-httpclient', 'computer_and_automation_research_institute_crawler', 'converamultimediacrawler', 'converacrawler', 'cscrawler', 'cse_html_validator_lite_online', 'cuasarbot', 'cursor', 'custo', 'datafountains\/dmoz_downloader', 'daviesbot', 'daypopbot', 'deepindex', 'dipsie\.bot', 'dnsgroup', 'domainchecker', 'domainsdb\.net', 'dulance', 'dumbot', 'dumm\.de\-bot', 'earthcom\.info', 'easydl', 'edgeio\-retriever', 'ets_v', 'exactseek', 'extreme[_+ ]picture[_+ ]finder', 'eventax', 'everbeecrawler', 'everest\-vulcan', 'ezresult', 'enteprise', 'facebook', 'fast_enterprise_crawler.*crawleradmin\.t\-info@telekom\.de', 'fast_enterprise_crawler.*t\-info_bi_cluster_crawleradmin\.t\-info@telekom\.de', 'matrix_s\.p\.a\._\-_fast_enterprise_crawler', 'fast_enterprise_crawler', 'fast\-search\-engine', 'favicon', 'favorg', 'favorites_sweeper', 'feedburner', 'feedfetcher\-google', 'feedflow', 'feedster', 'feedsky', 'feedvalidator', 'filmkamerabot', 'findlinks', 'findexa_crawler', 'fooky\.com\/ScorpionBot', 'g2crawler', 'gaisbot', 'geniebot', 'gigabot', 'girafabot', 'global_fetch', 'gnodspider', 'goforit\.com', 'goforitbot', 'gonzo', 'grub', 'gpu_p2p_crawler', 'henrythemiragorobot', 'heritrix', 'holmes', 'hoowwwer', 'hpprint', 'htmlparser', 'html[_+ ]link[_+ ]validator', 'httrack', 'hundesuche\.com\-bot', 'ichiro', 'iltrovatore\-setaccio', 'infobot', 'infociousbot', 'infomine', 'insurancobot', 'internet[_+ ]ninja', 'internetarchive', 'internetseer', 'internetsupervision', 'irlbot', 'isearch2006', 'iupui_research_bot', 'jrtwine[_+ ]software[_+ ]check[_+ ]favorites[_+ ]utility', 'justview', 'kalambot', 'kamano\.de_newsfeedverzeichnis', 'kazoombot', 'kevin', 'keyoshid', 'kinjabot', 'kinja\-imagebot', 'knowitall', 'knowledge\.com', 'kouaa_krawler', 'krugle', 'ksibot', 'kurzor', 'lanshanbot', 'letscrawl\.com', 'libcrawl', 'linkbot', 'link_valet_online', 'metager\-linkchecker', 'linkchecker', 'livejournal\.com', 'lmspider', 'lwp\-request', 'lwp\-trivial', 'magpierss', 'mail\.ru', 'mapoftheinternet\.com', 'mediapartners\-google', 'megite', 'metaspinner', 'microsoft[_+ ]url[_+ ]control', 'mini\-reptile', 'minirank', 'missigua_locator', 'misterbot', 'miva', 'mizzu_labs', 'mj12bot', 'mojeekbot', 'msiecrawler', 'ms_search_4\.0_robot', 'msrabot', 'msrbot', 'mt::telegraph::agent', 'nagios', 'nasa_search', 'mydoyouhike', 'netluchs', 'netsprint', 'newsgatoronline', 'nicebot', 'nimblecrawler', 'noxtrumbot', 'npbot', 'nutchcvs', 'nutchosu\-vlib', 'nutch', 'ocelli', 'octora_beta_bot', 'omniexplorer[_+ ]bot', 'onet\.pl[_+ ]sa', 'onfolio', 'opentaggerbot', 'openwebspider', 'oracle_ultra_search', 'orbiter', 'yodaobot', 'qihoobot', 'passwordmaker\.org', 'pear_http_request_class', 'peerbot', 'perman', 'php[_+ ]version[_+ ]tracker', 'pictureofinternet', 'ping\.blo\.gs', 'plinki', 'pluckfeedcrawler', 'pogodak', 'pompos', 'popdexter', 'port_huron_labs', 'postfavorites', 'projectwf\-java\-test\-crawler', 'proodlebot', 'pyquery', 'rambler', 'redalert', 'rojo', 'rssimagesbot', 'ruffle', 'rufusbot', 'sandcrawler', 'sbider', 'schizozilla', 'scumbot', 'searchguild[_+ ]dmoz[_+ ]experiment', 'seekbot', 'sensis_web_crawler', 'seznambot', 'shim\-crawler', 'shoutcast', 'slysearch', 'snap\.com_beta_crawler', 'sohu\-search', 'sohu', 'snappy', 'sphere_scout', 'spip', 'sproose_crawler', 'steeler', 'steroid__download', 'suchfin\-bot', 'superbot', 'surveybot', 'susie', 'syndic8', 'syndicapi', 'synoobot', 'tcl_http_client_package', 'technoratibot', 'teragramcrawlersurf', 'test_crawler', 'testbot', 't\-h\-u\-n\-d\-e\-r\-s\-t\-o\-n\-e', 'topicblogs', 'turnitinbot', 'turtlescanner', 'turtle', 'tutorgigbot', 'twiceler', 'ubicrawler', 'ultraseek', 'unchaos_bot_hybrid_web_search_engine', 'unido\-bot', 'updated', 'ustc\-semantic\-group', 'vagabondo\-wap', 'vagabondo', 'vermut', 'versus_crawler_from_eda\.baykan@epfl\.ch', 'vespa_crawler', 'vortex', 'vse\/', 'w3c\-checklink', 'w3c[_+ ]css[_+ ]validator[_+ ]jfouffa', 'w3c_validator', 'watchmouse', 'wavefire', 'webclipping\.com', 'webcompass', 'webcrawl\.net', 'web_downloader', 'webdup', 'webfilter', 'webindexer', 'webminer', 'website[_+ ]monitoring[_+ ]bot', 'webvulncrawl', 'wells_search', 'wonderer', 'wume_crawler', 'wwweasel', 'xenu\'s_link_sleuth', 'xenu_link_sleuth', 'xirq', 'y!j', 'yacy', 'yahoo\-blogs', 'yahoo\-verticalcrawler', 'yahoofeedseeker', 'yahooseeker\-testing', 'yahooseeker', 'yahoo\-mmcrawler', 'yahoo!_mindset', 'yandex', 'flexum', 'yanga', 'yooglifetchagent', 'z\-add_link_checker', 'zealbot', 'zhuaxia', 'zspider', 'zeus', 'ng\/1\.', 'ng\/2\.', 'exabot', 'wget', 'libwww', 'java\/[0-9]'] + +search_engines = ['google\.[\w.]+/products', 'base\.google\.', 'froogle\.google\.', 'groups\.google\.', 'images\.google\.', 'google\.', 'googlee\.', 'googlecom\.com', 'goggle\.co\.hu', '216\.239\.(35|37|39|51)\.100', '216\.239\.(35|37|39|51)\.101', '216\.239\.5[0-9]\.104', '64\.233\.1[0-9]{2}\.104', '66\.102\.[1-9]\.104', '66\.249\.93\.104', '72\.14\.2[0-9]{2}\.104', 'msn\.', 'live\.com', 'bing\.', 'voila\.', 'mindset\.research\.yahoo', 'yahoo\.', '(66\.218\.71\.225|216\.109\.117\.135|216\.109\.125\.130|66\.218\.69\.11)', 'search\.aol\.co', 'tiscali\.', 'lycos\.', 'alexa\.com', 'alltheweb\.com', 'altavista\.', 'a9\.com', 'dmoz\.org', 'netscape\.', 'search\.terra\.', 'www\.search\.com', 'search\.sli\.sympatico\.ca', 'excite\.'] + +search_engines_2 = ['4\-counter\.com', 'att\.net', 'bungeebonesdotcom', 'northernlight\.', 'hotbot\.', 'kvasir\.', 'webcrawler\.', 'metacrawler\.', 'go2net\.com', '(^|\.)go\.com', 'euroseek\.', 'looksmart\.', 'spray\.', 'nbci\.com\/search', 'de\.ask.\com', 'es\.ask.\com', 'fr\.ask.\com', 'it\.ask.\com', 'nl\.ask.\com', 'uk\.ask.\com', '(^|\.)ask\.com', 'atomz\.', 'overture\.com', 'teoma\.', 'findarticles\.com', 'infospace\.com', 'mamma\.', 'dejanews\.', 'dogpile\.com', 'wisenut\.com', 'ixquick\.com', 'search\.earthlink\.net', 'i-une\.com', 'blingo\.com', 'centraldatabase\.org', 'clusty\.com', 'mysearch\.', 'vivisimo\.com', 'kartoo\.com', 'icerocket\.com', 'sphere\.com', 'ledix\.net', 'start\.shaw\.ca', 'searchalot\.com', 'copernic\.com', 'avantfind\.com', 'steadysearch\.com', 'steady-search\.com', 'chello\.at', 'chello\.be', 'chello\.cz', 'chello\.fr', 'chello\.hu', 'chello\.nl', 'chello\.no', 'chello\.pl', 'chello\.se', 'chello\.sk', 'chello', 'mirago\.be', 'mirago\.ch', 'mirago\.de', 'mirago\.dk', 'es\.mirago\.com', 'mirago\.fr', 'mirago\.it', 'mirago\.nl', 'no\.mirago\.com', 'mirago\.se', 'mirago\.co\.uk', 'mirago', 'answerbus\.com', 'icq\.com\/search', 'nusearch\.com', 'goodsearch\.com', 'scroogle\.org', 'questionanswering\.com', 'mywebsearch\.com', 'as\.starware\.com', 'del\.icio\.us', 'digg\.com', 'stumbleupon\.com', 'swik\.net', 'segnalo\.alice\.it', 'ineffabile\.it', 'anzwers\.com\.au', 'engine\.exe', 'miner\.bol\.com\.br', '\.baidu\.com', '\.vnet\.cn', '\.soso\.com', '\.sogou\.com', '\.3721\.com', 'iask\.com', '\.accoona\.com', '\.163\.com', '\.zhongsou\.com', 'atlas\.cz', 'seznam\.cz', 'quick\.cz', 'centrum\.cz', 'jyxo\.(cz|com)', 'najdi\.to', 'redbox\.cz', 'opasia\.dk', 'danielsen\.com', 'sol\.dk', 'jubii\.dk', 'find\.dk', 'edderkoppen\.dk', 'netstjernen\.dk', 'orbis\.dk', 'tyfon\.dk', '1klik\.dk', 'ofir\.dk', 'ilse\.', 'vindex\.', '(^|\.)ask\.co\.uk', 'bbc\.co\.uk/cgi-bin/search', 'ifind\.freeserve', 'looksmart\.co\.uk', 'splut\.', 'spotjockey\.', 'ukdirectory\.', 'ukindex\.co\.uk', 'ukplus\.', 'searchy\.co\.uk', 'haku\.www\.fi', 'recherche\.aol\.fr', 'ctrouve\.', 'francite\.', '\.lbb\.org', 'rechercher\.libertysurf\.fr', 'search[\w\-]+\.free\.fr', 'recherche\.club-internet\.fr', 'toile\.com', 'biglotron\.com', 'mozbot\.fr', 'sucheaol\.aol\.de', 'fireball\.de', 'infoseek\.de', 'suche\d?\.web\.de', '[a-z]serv\.rrzn\.uni-hannover\.de', 'suchen\.abacho\.de', '(brisbane|suche)\.t-online\.de', 'allesklar\.de', 'meinestadt\.de', '212\.227\.33\.241', '(161\.58\.227\.204|161\.58\.247\.101|212\.40\.165\.90|213\.133\.108\.202|217\.160\.108\.151|217\.160\.111\.99|217\.160\.131\.108|217\.160\.142\.227|217\.160\.176\.42)', 'wwweasel\.de', 'netluchs\.de', 'schoenerbrausen\.de', 'heureka\.hu', 'vizsla\.origo\.hu', 'lapkereso\.hu', 'goliat\.hu', 'index\.hu', 'wahoo\.hu', 'webmania\.hu', 'search\.internetto\.hu', 'tango\.hu', 'keresolap\.hu', 'polymeta\.hu', 'sify\.com', 'virgilio\.it', 'arianna\.libero\.it', 'supereva\.com', 'kataweb\.it', 'search\.alice\.it\.master', 'search\.alice\.it', 'gotuneed\.com', 'godado', 'jumpy\.it', 'shinyseek\.it', 'teecno\.it', 'ask\.jp', 'sagool\.jp', 'sok\.start\.no', 'eniro\.no', 'szukaj\.wp\.pl', 'szukaj\.onet\.pl', 'dodaj\.pl', 'gazeta\.pl', 'gery\.pl', 'hoga\.pl', 'netsprint\.pl', 'interia\.pl', 'katalog\.onet\.pl', 'o2\.pl', 'polska\.pl', 'szukacz\.pl', 'wow\.pl', 'ya(ndex)?\.ru', 'aport\.ru', 'rambler\.ru', 'turtle\.ru', 'metabot\.ru', 'evreka\.passagen\.se', 'eniro\.se', 'zoznam\.sk', 'sapo\.pt', 'search\.ch', 'search\.bluewin\.ch', 'pogodak\.'] + +not_search_engines_keys = {'yahoo\.' : '(?:picks|mail)\.yahoo\.|yahoo\.[^/]+/picks', 'altavista\.' : 'babelfish\.altavista\.', 'tiscali\.' : 'mail\.tiscali\.', 'yandex\.' : 'direct\.yandex\.', 'google\.' : 'translate\.google\.', 'msn\.' : 'hotmail\.msn\.'} + +search_engines_hashid = {'search\.sli\.sympatico\.ca' : 'sympatico', 'mywebsearch\.com' : 'mywebsearch', 'netsprint\.pl\/hoga\-search' : 'hogapl', 'findarticles\.com' : 'findarticles', 'wow\.pl' : 'wowpl', 'allesklar\.de' : 'allesklar', 'atomz\.' : 'atomz', 'bing\.' : 'bing', 'find\.dk' : 'finddk', 'google\.' : 'google', '(66\.218\.71\.225|216\.109\.117\.135|216\.109\.125\.130|66\.218\.69\.11)' : 'yahoo', 'pogodak\.' : 'pogodak', 'ask\.jp' : 'askjp', '\.baidu\.com' : 'baidu', 'tango\.hu' : 'tango_hu', 'gotuneed\.com' : 'gotuneed', 'quick\.cz' : 'quick', 'mirago' : 'mirago', 'szukaj\.wp\.pl' : 'wp', 'mirago\.de' : 'miragode', 'mirago\.dk' : 'miragodk', 'katalog\.onet\.pl' : 'katalogonetpl', 'googlee\.' : 'google', 'orbis\.dk' : 'orbis', 'turtle\.ru' : 'turtle', 'zoznam\.sk' : 'zoznam', 'start\.shaw\.ca' : 'shawca', 'chello\.at' : 'chelloat', 'centraldatabase\.org' : 'centraldatabase', 'centrum\.cz' : 'centrum', 'kataweb\.it' : 'kataweb', '\.lbb\.org' : 'lbb', 'blingo\.com' : 'blingo', 'vivisimo\.com' : 'vivisimo', 'stumbleupon\.com' : 'stumbleupon', 'es\.ask.\com' : 'askes', 'interia\.pl' : 'interiapl', '[a-z]serv\.rrzn\.uni-hannover\.de' : 'meta', 'search\.alice\.it' : 'aliceit', 'shinyseek\.it' : 'shinyseek\.it', 'i-une\.com' : 'iune', 'dejanews\.' : 'dejanews', 'opasia\.dk' : 'opasia', 'chello\.cz' : 'chellocz', 'ya(ndex)?\.ru' : 'yandex', 'kartoo\.com' : 'kartoo', 'arianna\.libero\.it' : 'arianna', 'ofir\.dk' : 'ofir', 'search\.earthlink\.net' : 'earthlink', 'biglotron\.com' : 'biglotron', 'lapkereso\.hu' : 'lapkereso', '216\.239\.(35|37|39|51)\.101' : 'google_cache', 'miner\.bol\.com\.br' : 'miner', 'dodaj\.pl' : 'dodajpl', 'mirago\.be' : 'miragobe', 'googlecom\.com' : 'google', 'steadysearch\.com' : 'steadysearch', 'redbox\.cz' : 'redbox', 'haku\.www\.fi' : 'haku', 'sapo\.pt' : 'sapo', 'sphere\.com' : 'sphere', 'danielsen\.com' : 'danielsen', 'alexa\.com' : 'alexa', 'mamma\.' : 'mamma', 'swik\.net' : 'swik', 'polska\.pl' : 'polskapl', 'groups\.google\.' : 'google_groups', 'metabot\.ru' : 'metabot', 'rechercher\.libertysurf\.fr' : 'libertysurf', 'szukaj\.onet\.pl' : 'onetpl', 'aport\.ru' : 'aport', 'de\.ask.\com' : 'askde', 'splut\.' : 'splut', 'live\.com' : 'live', '216\.239\.5[0-9]\.104' : 'google_cache', 'mysearch\.' : 'mysearch', 'ukplus\.' : 'ukplus', 'najdi\.to' : 'najdi', 'overture\.com' : 'overture', 'iask\.com' : 'iask', 'nl\.ask.\com' : 'asknl', 'nbci\.com\/search' : 'nbci', 'search\.aol\.co' : 'aol', 'eniro\.se' : 'enirose', '64\.233\.1[0-9]{2}\.104' : 'google_cache', 'mirago\.ch' : 'miragoch', 'altavista\.' : 'altavista', 'chello\.hu' : 'chellohu', 'mozbot\.fr' : 'mozbot', 'northernlight\.' : 'northernlight', 'mirago\.co\.uk' : 'miragocouk', 'search[\w\-]+\.free\.fr' : 'free', 'mindset\.research\.yahoo' : 'yahoo_mindset', 'copernic\.com' : 'copernic', 'heureka\.hu' : 'heureka', 'steady-search\.com' : 'steadysearch', 'teecno\.it' : 'teecnoit', 'voila\.' : 'voila', 'netstjernen\.dk' : 'netstjernen', 'keresolap\.hu' : 'keresolap_hu', 'yahoo\.' : 'yahoo', 'icerocket\.com' : 'icerocket', 'alltheweb\.com' : 'alltheweb', 'www\.search\.com' : 'search.com', 'digg\.com' : 'digg', 'tiscali\.' : 'tiscali', 'spotjockey\.' : 'spotjockey', 'a9\.com' : 'a9', '(brisbane|suche)\.t-online\.de' : 't-online', 'ifind\.freeserve' : 'freeserve', 'att\.net' : 'att', 'mirago\.it' : 'miragoit', 'index\.hu' : 'indexhu', '\.sogou\.com' : 'sogou', 'no\.mirago\.com' : 'miragono', 'ineffabile\.it' : 'ineffabile', 'netluchs\.de' : 'netluchs', 'toile\.com' : 'toile', 'search\..*\.\w+' : 'search', 'del\.icio\.us' : 'delicious', 'vizsla\.origo\.hu' : 'origo', 'netscape\.' : 'netscape', 'dogpile\.com' : 'dogpile', 'anzwers\.com\.au' : 'anzwers', '\.zhongsou\.com' : 'zhongsou', 'ctrouve\.' : 'ctrouve', 'gazeta\.pl' : 'gazetapl', 'recherche\.club-internet\.fr' : 'clubinternet', 'sok\.start\.no' : 'start', 'scroogle\.org' : 'scroogle', 'schoenerbrausen\.de' : 'schoenerbrausen', 'looksmart\.co\.uk' : 'looksmartuk', 'wwweasel\.de' : 'wwweasel', 'godado' : 'godado', '216\.239\.(35|37|39|51)\.100' : 'google_cache', 'jubii\.dk' : 'jubii', '212\.227\.33\.241' : 'metaspinner', 'mirago\.fr' : 'miragofr', 'sol\.dk' : 'sol', 'bbc\.co\.uk/cgi-bin/search' : 'bbc', 'jumpy\.it' : 'jumpy\.it', 'francite\.' : 'francite', 'infoseek\.de' : 'infoseek', 'es\.mirago\.com' : 'miragoes', 'jyxo\.(cz|com)' : 'jyxo', 'hotbot\.' : 'hotbot', 'engine\.exe' : 'engine', '(^|\.)ask\.com' : 'ask', 'goliat\.hu' : 'goliat', 'wisenut\.com' : 'wisenut', 'mirago\.nl' : 'miragonl', 'base\.google\.' : 'google_base', 'search\.bluewin\.ch' : 'bluewin', 'lycos\.' : 'lycos', 'meinestadt\.de' : 'meinestadt', '4\-counter\.com' : 'google4counter', 'search\.alice\.it\.master' : 'aliceitmaster', 'teoma\.' : 'teoma', '(^|\.)ask\.co\.uk' : 'askuk', 'tyfon\.dk' : 'tyfon', 'froogle\.google\.' : 'google_froogle', 'ukdirectory\.' : 'ukdirectory', 'ledix\.net' : 'ledix', 'edderkoppen\.dk' : 'edderkoppen', 'recherche\.aol\.fr' : 'aolfr', 'google\.[\w.]+/products' : 'google_products', 'webmania\.hu' : 'webmania', 'searchy\.co\.uk' : 'searchy', 'fr\.ask.\com' : 'askfr', 'spray\.' : 'spray', '72\.14\.2[0-9]{2}\.104' : 'google_cache', 'eniro\.no' : 'eniro', 'goodsearch\.com' : 'goodsearch', 'kvasir\.' : 'kvasir', '\.accoona\.com' : 'accoona', '\.soso\.com' : 'soso', 'as\.starware\.com' : 'comettoolbar', 'virgilio\.it' : 'virgilio', 'o2\.pl' : 'o2pl', 'chello\.nl' : 'chellonl', 'chello\.be' : 'chellobe', 'icq\.com\/search' : 'icq', 'msn\.' : 'msn', 'fireball\.de' : 'fireball', 'sucheaol\.aol\.de' : 'aolde', 'uk\.ask.\com' : 'askuk', 'euroseek\.' : 'euroseek', 'gery\.pl' : 'gerypl', 'chello\.fr' : 'chellofr', 'netsprint\.pl' : 'netsprintpl', 'avantfind\.com' : 'avantfind', 'supereva\.com' : 'supereva', 'polymeta\.hu' : 'polymeta_hu', 'infospace\.com' : 'infospace', 'sify\.com' : 'sify', 'go2net\.com' : 'go2net', 'wahoo\.hu' : 'wahoo', 'suche\d?\.web\.de' : 'webde', '(161\.58\.227\.204|161\.58\.247\.101|212\.40\.165\.90|213\.133\.108\.202|217\.160\.108\.151|217\.160\.111\.99|217\.160\.131\.108|217\.160\.142\.227|217\.160\.176\.42)' : 'metacrawler_de', '\.3721\.com' : '3721', 'ilse\.' : 'ilse', 'metacrawler\.' : 'metacrawler', 'sagool\.jp' : 'sagool', 'atlas\.cz' : 'atlas', 'vindex\.' : 'vindex', 'ixquick\.com' : 'ixquick', '66\.102\.[1-9]\.104' : 'google_cache', 'rambler\.ru' : 'rambler', 'answerbus\.com' : 'answerbus', 'evreka\.passagen\.se' : 'passagen', 'chello\.se' : 'chellose', 'clusty\.com' : 'clusty', 'search\.ch' : 'searchch', 'chello\.no' : 'chellono', 'searchalot\.com' : 'searchalot', 'questionanswering\.com' : 'questionanswering', 'seznam\.cz' : 'seznam', 'ukindex\.co\.uk' : 'ukindex', 'dmoz\.org' : 'dmoz', 'excite\.' : 'excite', 'chello\.pl' : 'chellopl', 'looksmart\.' : 'looksmart', '1klik\.dk' : '1klik', '\.vnet\.cn' : 'vnet', 'chello\.sk' : 'chellosk', '(^|\.)go\.com' : 'go', 'nusearch\.com' : 'nusearch', 'it\.ask.\com' : 'askit', 'bungeebonesdotcom' : 'bungeebonesdotcom', 'search\.terra\.' : 'terra', 'webcrawler\.' : 'webcrawler', 'suchen\.abacho\.de' : 'abacho', 'szukacz\.pl' : 'szukaczpl', '66\.249\.93\.104' : 'google_cache', 'search\.internetto\.hu' : 'internetto', 'goggle\.co\.hu' : 'google', 'mirago\.se' : 'miragose', 'images\.google\.' : 'google_image', 'segnalo\.alice\.it' : 'segnalo', '\.163\.com' : 'netease', 'chello' : 'chellocom'} + +search_engines_knwown_url = {'dmoz' : 'search=', 'google' : '(p|q|as_p|as_q)=', 'searchalot' : 'q=', 'teoma' : 'q=', 'looksmartuk' : 'key=', 'polymeta_hu' : '', 'google_groups' : 'group\/', 'iune' : '(keywords|q)=', 'chellosk' : 'q1=', 'eniro' : 'q=', 'msn' : 'q=', 'webcrawler' : 'searchText=', 'mirago' : '(txtsearch|qry)=', 'enirose' : 'q=', 'miragobe' : '(txtsearch|qry)=', 'netease' : 'q=', 'netluchs' : 'query=', 'google_products' : '(p|q|as_p|as_q)=', 'jyxo' : '(s|q)=', 'origo' : '(q|search)=', 'ilse' : 'search_for=', 'chellocom' : 'q1=', 'goodsearch' : 'Keywords=', 'ledix' : 'q=', 'mozbot' : 'q=', 'chellocz' : 'q1=', 'webde' : 'su=', 'biglotron' : 'question=', 'metacrawler_de' : 'qry=', 'finddk' : 'words=', 'start' : 'q=', 'sagool' : 'q=', 'miragoch' : '(txtsearch|qry)=', 'google_base' : '(p|q|as_p|as_q)=', 'aliceit' : 'qs=', 'shinyseek\.it' : 'KEY=', 'onetpl' : 'qt=', 'clusty' : 'query=', 'chellonl' : 'q1=', 'miragode' : '(txtsearch|qry)=', 'miragose' : '(txtsearch|qry)=', 'o2pl' : 'qt=', 'goliat' : 'KERESES=', 'kvasir' : 'q=', 'askfr' : '(ask|q)=', 'infoseek' : 'qt=', 'yahoo_mindset' : 'p=', 'comettoolbar' : 'qry=', 'alltheweb' : 'q(|uery)=', 'miner' : 'q=', 'aol' : 'query=', 'rambler' : 'words=', 'scroogle' : 'Gw=', 'chellose' : 'q1=', 'ineffabile' : '', 'miragoit' : '(txtsearch|qry)=', 'yandex' : 'text=', 'segnalo' : '', 'dodajpl' : 'keyword=', 'avantfind' : 'keywords=', 'nusearch' : 'nusearch_terms=', 'bbc' : 'q=', 'supereva' : 'q=', 'atomz' : 'sp-q=', 'searchy' : 'search_term=', 'dogpile' : 'q(|kw)=', 'chellohu' : 'q1=', 'vnet' : 'kw=', '1klik' : 'query=', 't-online' : 'q=', 'hogapl' : 'qt=', 'stumbleupon' : '', 'soso' : 'q=', 'zhongsou' : '(word|w)=', 'a9' : 'a9\.com\/', 'centraldatabase' : 'query=', 'mamma' : 'query=', 'icerocket' : 'q=', 'ask' : '(ask|q)=', 'chellobe' : 'q1=', 'altavista' : 'q=', 'vindex' : 'in=', 'miragodk' : '(txtsearch|qry)=', 'chelloat' : 'q1=', 'digg' : 's=', 'metacrawler' : 'general=', 'nbci' : 'keyword=', 'chellono' : 'q1=', 'icq' : 'q=', 'arianna' : 'query=', 'miragocouk' : '(txtsearch|qry)=', '3721' : '(p|name)=', 'pogodak' : 'q=', 'ukdirectory' : 'k=', 'overture' : 'keywords=', 'heureka' : 'heureka=', 'teecnoit' : 'q=', 'miragoes' : '(txtsearch|qry)=', 'haku' : 'w=', 'go' : 'qt=', 'fireball' : 'q=', 'wisenut' : 'query=', 'sify' : 'keyword=', 'ixquick' : 'query=', 'anzwers' : 'search=', 'quick' : 'query=', 'jubii' : 'soegeord=', 'questionanswering' : '', 'asknl' : '(ask|q)=', 'askde' : '(ask|q)=', 'att' : 'qry=', 'terra' : 'query=', 'bing' : 'q=', 'wowpl' : 'q=', 'freeserve' : 'q=', 'atlas' : '(searchtext|q)=', 'askuk' : '(ask|q)=', 'godado' : 'Keywords=', 'northernlight' : 'qr=', 'answerbus' : '', 'search.com' : 'q=', 'google_image' : '(p|q|as_p|as_q)=', 'jumpy\.it' : 'searchWord=', 'gazetapl' : 'slowo=', 'yahoo' : 'p=', 'hotbot' : 'mt=', 'metabot' : 'st=', 'copernic' : 'web\/', 'kartoo' : '', 'metaspinner' : 'qry=', 'toile' : 'q=', 'aolde' : 'q=', 'blingo' : 'q=', 'askit' : '(ask|q)=', 'netscape' : 'search=', 'splut' : 'pattern=', 'looksmart' : 'key=', 'sphere' : 'q=', 'sol' : 'q=', 'miragono' : '(txtsearch|qry)=', 'kataweb' : 'q=', 'ofir' : 'querytext=', 'aliceitmaster' : 'qs=', 'miragofr' : '(txtsearch|qry)=', 'spray' : 'string=', 'seznam' : '(w|q)=', 'interiapl' : 'q=', 'euroseek' : 'query=', 'schoenerbrausen' : 'q=', 'centrum' : 'q=', 'netsprintpl' : 'q=', 'go2net' : 'general=', 'katalogonetpl' : 'qt=', 'ukindex' : 'stext=', 'shawca' : 'q=', 'szukaczpl' : 'q=', 'accoona' : 'qt=', 'live' : 'q=', 'google4counter' : '(p|q|as_p|as_q)=', 'iask' : '(w|k)=', 'earthlink' : 'q=', 'tiscali' : 'key=', 'askes' : '(ask|q)=', 'gotuneed' : '', 'clubinternet' : 'q=', 'redbox' : 'srch=', 'delicious' : 'all=', 'chellofr' : 'q1=', 'lycos' : 'query=', 'sympatico' : 'query=', 'vivisimo' : 'query=', 'bluewin' : 'qry=', 'mysearch' : 'searchfor=', 'google_cache' : '(p|q|as_p|as_q)=cache:[0-9A-Za-z]{12}:', 'ukplus' : 'search=', 'gerypl' : 'q=', 'keresolap_hu' : 'q=', 'abacho' : 'q=', 'engine' : 'p1=', 'opasia' : 'q=', 'wp' : 'szukaj=', 'steadysearch' : 'w=', 'chellopl' : 'q1=', 'voila' : '(kw|rdata)=', 'aport' : 'r=', 'internetto' : 'searchstr=', 'passagen' : 'q=', 'wwweasel' : 'q=', 'najdi' : 'dotaz=', 'alexa' : 'q=', 'baidu' : '(wd|word)=', 'spotjockey' : 'Search_Keyword=', 'virgilio' : 'qs=', 'orbis' : 'search_field=', 'tango_hu' : 'q=', 'askjp' : '(ask|q)=', 'bungeebonesdotcom' : 'query=', 'francite' : 'name=', 'searchch' : 'q=', 'google_froogle' : '(p|q|as_p|as_q)=', 'excite' : 'search=', 'infospace' : 'qkw=', 'polskapl' : 'qt=', 'swik' : 'swik\.net/', 'edderkoppen' : 'query=', 'mywebsearch' : 'searchfor=', 'danielsen' : 'q=', 'wahoo' : 'q=', 'sogou' : 'query=', 'miragonl' : '(txtsearch|qry)=', 'findarticles' : 'key='} + diff --git a/conf.py b/conf.py new file mode 100644 index 0000000..e26b953 --- /dev/null +++ b/conf.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- + +# Web server log +analyzed_filename = 'access.log' + +# Domain name to analyze +domain_name = 'soutade.fr' + +# Display visitor IP in addition to resolved names +display_visitor_ip = True + +# Hooks used +pre_analysis_hooks = ['page_to_hit', 'robots'] +post_analysis_hooks = ['referers', 'top_pages', 'top_downloads', 'top_hits']#, 'reverse_dns'] +display_hooks = ['top_visitors', 'all_visits', 'referers', 'top_pages', 'top_downloads', 'top_hits'] + +# Reverse DNS timeout +reverse_dns_timeout = 0.2 + +# Count this addresses as hit +page_to_hit_conf = [r'^.+/logo[/]?$'] +## Count this addresses as page +hit_to_page_conf = [r'^.+/category/.+$', r'^.+/tag/.+$', r'^.+/archive/.+$', r'^.+/ljdc[/]?$'] + +# Because it's too long to build HTML when there is too much entries +max_hits_displayed = 100 +max_downloads_displayed = 100 + +# Compress these files after generation +compress_output_files = ['html', 'css', 'js'] + +# Display result in French +locale = 'fr' + diff --git a/default_conf.py b/default_conf.py new file mode 100644 index 0000000..dcc8190 --- /dev/null +++ b/default_conf.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- + +import os + +# Default configuration + +# Default database directory +DB_ROOT = './output_db' +# Default HTML output directory +DISPLAY_ROOT = './output' + +# Hooks directories (don't edit) +HOOKS_ROOT = 'plugins' +PRE_HOOK_DIRECTORY = HOOKS_ROOT + '.pre_analysis' +POST_HOOK_DIRECTORY = HOOKS_ROOT + '.post_analysis' +DISPLAY_HOOK_DIRECTORY = HOOKS_ROOT + '.display' +# Meta Database filename +META_PATH = os.path.join(DB_ROOT, 'meta.db') +# Database filename per month +DB_FILENAME = 'iwla.db' + +# Web server log format (nginx style). Default is apache log format +log_format = '$server_name:$server_port $remote_addr - $remote_user [$time_local] ' +\ + '"$request" $status $body_bytes_sent ' +\ + '"$http_referer" "$http_user_agent"' + +# Time format used in log format +time_format = '%d/%b/%Y:%H:%M:%S %z' + +# Hooks that are loaded at runtime (only set names without path and extensions) +pre_analysis_hooks = [] +post_analysis_hooks = [] +display_hooks = [] + +# Extensions that are considered as a HTML page (or result) in opposite to hits +pages_extensions = ['/', 'htm', 'html', 'xhtml', 'py', 'pl', 'rb', 'php'] +# HTTP codes that are cosidered OK +viewed_http_codes = [200, 304] + +# If False, doesn't cout visitors that doesn't GET a page but resources only (images, rss...) +count_hit_only_visitors = True + +# Multimedia extensions (not accounted as downloaded files) +multimedia_files = ['png', 'jpg', 'jpeg', 'gif', 'ico', + 'css', 'js'] + +# Default resources path (will be symlinked in DISPLAY_OUTPUT) +resources_path = ['resources'] +# Icon path +icon_path = '%s/%s' % (os.path.basename(resources_path[0]), 'icon') +# CSS path (you can add yours) +css_path = ['%s/%s/%s' % (os.path.basename(resources_path[0]), 'css', 'iwla.css')] + +# Files extensions to compress in gzip during display build +compress_output_files = [] + +# Path to locales files +locales_path = './locales' + +# Default locale (english) +locale = 'en_EN' diff --git a/display.py b/display.py new file mode 100644 index 0000000..cb98693 --- /dev/null +++ b/display.py @@ -0,0 +1,387 @@ +# -*- coding: utf-8 -*- +# +# Copyright Grégory Soutadé 2015 + +# This file is part of iwla + +# iwla is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# iwla is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with iwla. If not, see . +# + +import os +import codecs +import time +import logging + +# +# Create output HTML files +# + +# Just for detection +def _(name): pass +_('January'), _('February'), _('March'), _('April'), _('May'), _('June'), _('July') +_('August'), _('September'), _('October'), _('November'), _('December') +del _ + +class DisplayHTMLRaw(object): + + def __init__(self, iwla, html=u''): + self.iwla = iwla + self.html = html + + def setRawHTML(self, html): + self.html = html + + def _buildHTML(self): + pass + + def _build(self, f, html): + if html: f.write(html) + + def build(self, f): + self._buildHTML() + self._build(f, self.html) + +class DisplayHTMLBlock(DisplayHTMLRaw): + + def __init__(self, iwla, title=''): + super(DisplayHTMLBlock, self).__init__(iwla, html='') + self.title = title + self.cssclass = u'iwla_block' + self.title_cssclass = u'iwla_block_title' + self.value_cssclass = u'iwla_block_value' + + def getTitle(self): + return self.title + + def setTitle(self, value): + self.title = unicode(value) + + def setCSSClass(self, cssclass): + self.cssclass = unicode(cssclass) + + def setTitleCSSClass(self, cssclass): + self.title_cssclass = unicode(cssclass) + + def setValueCSSClass(self, cssclass): + self.value_cssclass = unicode(cssclass) + + def _buildHTML(self): + html = u'
' % (self.cssclass) + if self.title: + html += u'
%s
' % (self.title_cssclass, self.title) + html += u'
%s
' % (self.value_cssclass, self.html) + html += u'
' + + self.html = html + +class DisplayHTMLBlockTable(DisplayHTMLBlock): + + def __init__(self, iwla, title, cols): + super(DisplayHTMLBlockTable, self).__init__(iwla=iwla, title=title) + self.cols = listToStr(cols) + self.rows = [] + self.cols_cssclasses = [u''] * len(cols) + self.rows_cssclasses = [] + self.table_css = u'iwla_table' + + def appendRow(self, row): + self.rows.append(listToStr(row)) + self.rows_cssclasses.append([u''] * len(row)) + + def getNbRows(self): + return len(self.rows) + + def getNbCols(self): + return len(self.cols) + + def getCellValue(self, row, col): + if row < 0 or col < 0 or\ + row >= len(self.rows) or col >= len(self.cols): + raise ValueError('Invalid indices %d,%d' % (row, col)) + + return self.rows[row][col] + + def setCellValue(self, row, col, value): + if row < 0 or col < 0 or\ + row >= len(self.rows) or col >= len(self.cols): + raise ValueError('Invalid indices %d,%d' % (row, col)) + + self.rows[row][col] = unicode(value) + + def setCellCSSClass(self, row, col, value): + if row < 0 or col < 0 or\ + row >= len(self.rows) or col >= len(self.cols): + raise ValueError('Invalid indices %d,%d' % (row, col)) + + self.rows_cssclasses[row][col] = unicode(value) + + def getCellCSSClass(self, row, col): + if row < 0 or col < 0 or\ + row >= len(self.rows) or col >= len(self.cols): + raise ValueError('Invalid indices %d,%d' % (row, col)) + + return self.rows_cssclasses[row][col] + + def getColCSSClass(self, col): + if col < 0 or col >= len(self.cols): + raise ValueError('Invalid indice %d' % (col)) + + return self.cols_cssclasses[col] + + def setRowCSSClass(self, row, value): + if row < 0 or row >= len(self.rows): + raise ValueError('Invalid indice %d' % (row)) + + self.rows_cssclasses[row] = [unicode(value)] * len(self.rows_cssclasses[row]) + + def setColCSSClass(self, col, value): + if col < 0 or col >= len(self.cols): + raise ValueError('Invalid indice %d' % (col)) + + self.cols_cssclasses[col] = unicode(value) + + def setColsCSSClass(self, values): + if len(values) != len(self.cols): + raise ValueError('Invalid values size') + + self.cols_cssclasses = listToStr(values) + + def _buildHTML(self): + style = u'' + if self.table_css: style = u' class="%s"' % (self.table_css) + html = u'' % (style) + if self.cols: + html += u'' + for i in range (0, len(self.cols)): + title = self.cols[i] + style = self.getColCSSClass(i) + if style: style = u' class="%s"' % (style) + html += u'%s' % (style, title) + html += u'' + for i in range(0, len(self.rows)): + row = self.rows[i] + html += u'' + for j in range(0, len(row)): + v = row[j] + style = self.getCellCSSClass(i, j) + if style: style = u' class="%s"' % (style) + html += u'%s' % (style, v) + html += u'' + html += u'' + + self.html += html + + super(DisplayHTMLBlockTable, self)._buildHTML() + +class DisplayHTMLBlockTableWithGraph(DisplayHTMLBlockTable): + + def __init__(self, iwla, title, cols, short_titles=None, nb_valid_rows=0, graph_cols=None): + super(DisplayHTMLBlockTableWithGraph, self).__init__(iwla=iwla, title=title, cols=cols) + self.short_titles = short_titles or [] + self.short_titles = listToStr(self.short_titles) + self.nb_valid_rows = nb_valid_rows + self.icon_path = self.iwla.getConfValue('icon_path', '/') + self.raw_rows = [] + self.maxes = [0] * len(cols) + self.table_graph_css = u'iwla_graph_table' + self.td_img_css = u'iwla_td_img' + self.graph_cols = graph_cols or [] + + def appendRow(self, row): + self.raw_rows.append(row) + super(DisplayHTMLBlockTableWithGraph, self).appendRow(row) + + def appendShortTitle(self, short_title): + self.short_titles.append(unicode(short_title)) + + def setShortTitle(self, short_titles): + self.short_titles = listToStr(short_titles) + + def setNbValidRows(self, nb_valid_rows): + self.nb_valid_rows = nb_valid_rows + + def _computeMax(self): + for i in range(0, self.nb_valid_rows): + row = self.raw_rows[i] + for j in range(1, len(row)): + if row[j] > self.maxes[j]: + self.maxes[j] = row[j] + + def _getIconFromStyle(self, style): + if style.startswith(u'iwla_page'): icon = u'vp.png' + elif style.startswith(u'iwla_hit'): icon = u'vh.png' + elif style.startswith(u'iwla_bandwidth'): icon = u'vk.png' + elif style.startswith(u'iwla_visitor'): icon = u'vu.png' + elif style.startswith(u'iwla_visit'): icon = u'vv.png' + else: return '' + + return u'/%s/%s' % (self.icon_path, icon) + + def _buildHTML(self): + self._computeMax() + + style = u'' + if self.table_graph_css: style = u' class="%s"' % (self.table_graph_css) + html = u'' % (style) + html += u'' + for i in range(0, self.nb_valid_rows): + row = self.rows[i] + css = u'' + if self.td_img_css: css=u' class="%s"' % (self.td_img_css) + html += u'' % (css) + for j in self.graph_cols: + style = self.getColCSSClass(j) + icon = self._getIconFromStyle(style) + if not icon: continue + if style: style = u' class="%s"' % (style) + alt = u'%s: %s' % (row[j], self.cols[j]) + if self.maxes[j]: + height = int((self.raw_rows[i][j] * 100) / self.maxes[j]) or 1 + else: + height = 1 + html += u'' % (style, icon, height, alt, alt) + html += u'' + html += u'' + html += u'' + for i in range(0, len(self.short_titles)): + style = self.getCellCSSClass(i, 0) + if style: style = u' class="%s"' % (style) + html += u'%s' % (style, self.short_titles[i]) + html += u'' + html += u'' + + self.html += html + + super(DisplayHTMLBlockTableWithGraph, self)._buildHTML() + +class DisplayHTMLPage(object): + + def __init__(self, iwla, title, filename, css_path): + self.iwla = iwla + self.title = unicode(title) + self.filename = filename + self.blocks = [] + self.css_path = listToStr(css_path) + self.logger = logging.getLogger(self.__class__.__name__) + + def getFilename(self): + return self.filename; + + def getBlock(self, title): + for b in self.blocks: + if title == b.getTitle(): + return b + return None + + def appendBlock(self, block): + self.blocks.append(block) + + def build(self, root): + filename = os.path.join(root, self.filename) + + base = os.path.dirname(filename) + if not os.path.exists(base): + os.makedirs(base) + + self.logger.debug('Write %s' % (filename)) + + f = codecs.open(filename, 'w', 'utf-8') + f.write(u'') + f.write(u'') + f.write(u'') + f.write(u'') + for css in self.css_path: + f.write(u'' % (css)) + if self.title: + f.write(u'%s' % (self.title)) + f.write(u'') + for block in self.blocks: + block.build(f) + f.write(u'
Generated by IWLA %s
' % + ("http://indefero.soutade.fr/p/iwla", self.iwla.getVersion())) + f.write(u'') + f.close() + +class DisplayHTMLBuild(object): + + def __init__(self, iwla): + self.pages = [] + self.iwla = iwla + + def createPage(self, *args): + return DisplayHTMLPage(self.iwla, *args) + + def createBlock(self, _class, *args): + return _class(self.iwla, *args) + + def getPage(self, filename): + for page in self.pages: + if page.getFilename() == filename: + return page + return None + + def addPage(self, page): + self.pages.append(page) + + def build(self, root): + display_root = self.iwla.getConfValue('DISPLAY_ROOT', '') + if not os.path.exists(display_root): + os.makedirs(display_root) + for res_path in self.iwla.getResourcesPath(): + target = os.path.abspath(res_path) + link_name = os.path.join(display_root, res_path) + if not os.path.exists(link_name): + os.symlink(target, link_name) + + for page in self.pages: + page.build(root) + +# +# Global functions +# + +def bytesToStr(bytes): + suffixes = [u'', u' kB', u' MB', u' GB', u' TB'] + + for i in range(0, len(suffixes)): + if bytes < 1024: break + bytes /= 1024.0 + + if i: + return u'%.02f%s' % (bytes, suffixes[i]) + else: + return u'%d%s' % (bytes, suffixes[i]) + +def _toStr(v): + if type(v) != unicode: return unicode(v) + else: return v + +def listToStr(l): return map(lambda(v) : _toStr(v), l) + +def generateHTMLLink(url, name=None, max_length=100, prefix=u'http'): + url = unicode(url) + if not name: name = unicode(url) + if not url.startswith(prefix): url = u'%s://%s' % (prefix, url) + return u'%s' % (url, name[:max_length]) + +def createCurTitle(iwla, title): + title = iwla._(title) + month_name = time.strftime(u'%B', iwla.getCurTime()) + year = time.strftime(u'%Y', iwla.getCurTime()) + title += u' - %s %s' % (iwla._(month_name), year) + domain_name = iwla.getConfValue('domain_name', '') + if domain_name: + title += u' - %s' % (domain_name) + return title + diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..1a3b36c --- /dev/null +++ b/docs/index.md @@ -0,0 +1,552 @@ +iwla +==== + +Introduction +------------ + +iwla (Intelligent Web Log Analyzer) is basically a clone of [awstats](http://www.awstats.org). The main problem with awstats is that it's a very monolothic project with everything in one big PERL file. In opposite, iwla has be though to be very modular : a small core analysis and a lot of filters. It can be viewed as UNIX pipes. Philosophy of iwla is : add, update, delete ! That's the job of each filters : modify statistics until final result. It's written in Python. + +Nevertheless, iwla is only focused on HTTP logs. It uses data (robots definitions, search engines definitions) and design from awstats. Moreover, it's not dynamic, but only generates static HTML page (with gzip compression option). + +Usage +----- + + ./iwla [-c|--clean-output] [-i|--stdin] [-f FILE|--file FILE] [-d LOGLEVEL|--log-level LOGLEVEL] + + -c : Clean output (database and HTML) before starting + -i : Read data from stdin instead of conf.analyzed_filename + -f : Read data from FILE instead of conf.analyzed_filename + -d : Loglevel in ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'] + +Basic usage +----------- + +In addition to command line, iwla read parameters in default_conf.py. User can override default values using _conf.py_ file. Each module requires its own parameters. + +Main values to edit are : + + * **analyzed_filename** : web server log + * **domaine_name** : domain name to filter + * **pre_analysis_hooks** : List of pre analysis hooks + * **post_analysis_hooks** : List of post analysis hooks + * **display_hooks** : List of display hooks + * **locale** : Displayed locale (_en_ or _fr_) + +Then, you can then iwla. Output HTML files are created in _output_ directory by default. To quickly see it go in output and type + + python -m SimpleHTTPServer 8000 + +Open your favorite web browser at _http://localhost:8000_. Enjoy ! + +**Warning** : The order is hooks list is important : Some plugins may requires others plugins, and the order of display_hooks is the order of displayed blocks in final result. + + +Interesting default configuration values +---------------------------------------- + + * **DB_ROOT** : Default database directory (default ./output_db) + * **DISPLAY_ROOT** : Default HTML output directory (default ./output) + * **log_format** : Web server log format (nginx style). Default is apache log format + * **time_format** : Time format used in log format + * **pages_extensions** : Extensions that are considered as a HTML page (or result) in opposit to hits + * **viewed_http_codes** : HTTP codes that are cosidered OK (200, 304) + * **count_hit_only_visitors** : If False, doesn't cout visitors that doesn't GET a page but resources only (images, rss...) + * **multimedia_files** : Multimedia extensions (not accounted as downloaded files) + * **css_path** : CSS path (you can add yours) + * **compress_output_files** : Files extensions to compress in gzip during display build + +Plugins +------- + +As previously described, plugins acts like UNIX pipes : statistics are constantly updated by each plugin to produce final result. We have three type of plugins : + + * **Pre analysis plugins** : Called before generating days statistics. They are in charge to filter robots, crawlers, bad pages... + * **Post analysis plugins** : Called after basic statistics computation. They are in charge to enlight them with their own algorithms + * **Display plugins** : They are in charge to produce HTML files from statistics. + +To use plugins, just insert their name in _pre_analysis_hooks_, _post_analysis_hooks_ and _display_hooks_ lists in conf.py. + +Statistics are stored in dictionaries : + + * **month_stats** : Statistics of current analysed month + * **valid_visitor** : A subset of month_stats without robots + * **days_stats** : Statistics of current analysed day + * **visits** : All visitors with all of its requests + * **meta** : Final result of month statistics (by year) + +Create a Plugins +---------------- + +To create a new plugin, it's necessary to create a derived class of IPlugin (_iplugin.py) in the right directory (_plugins/xxx/yourPlugin.py_). + +Plugins can defines required configuration values (self.conf_requires) that must be set in conf.py (or can be optional). They can also defines required plugins (self.requires). + +The two functions to overload are _load(self)_ that must returns True or False if all is good (or not). It's called after _init_. The second is _hook(self)_ that is the body of plugins. + +For display plugins, a lot of code has been wrote in _display.py_ that simplify the creation on HTML blocks, tables and bar graphs. + +Plugins +======= + +Optional configuration values ends with *. + +iwla +---- + + Main class IWLA + Parse Log, compute them, call plugins and produce output + For now, only HTTP log are valid + + Plugin requirements : + None + + Conf values needed : + analyzed_filename + domain_name + locales_path + compress_output_files* + + Output files : + DB_ROOT/meta.db + DB_ROOT/year/month/iwla.db + OUTPUT_ROOT/index.html + OUTPUT_ROOT/year/month/index.html + + Statistics creation : + + meta : + last_time + start_analysis_time + stats => + year => + month => + viewed_bandwidth + not_viewed_bandwidth + viewed_pages + viewed_hits + nb_visits + nb_visitors + + month_stats : + viewed_bandwidth + not_viewed_bandwidth + viewed_pages + viewed_hits + nb_visits + + days_stats : + day => + viewed_bandwidth + not_viewed_bandwidth + viewed_pages + viewed_hits + nb_visits + nb_visitors + + visits : + remote_addr => + remote_addr + remote_ip + viewed_pages + viewed_hits + not_viewed_pages + not_viewed_hits + bandwidth + last_access + requests => + [fields_from_format_log] + extract_request => + extract_uri + extract_parameters* + extract_referer* => + extract_uri + extract_parameters* + robot + hit_only + is_page + + valid_visitors: + month_stats without robot and hit only visitors (if not conf.count_hit_only_visitors) + + Statistics update : + None + + Statistics deletion : + None + + +plugins.display.top_downloads +----------------------------- + + Display hook + + Create TOP downloads page + + Plugin requirements : + post_analysis/top_downloads + + Conf values needed : + max_downloads_displayed* + create_all_downloads_page* + + Output files : + OUTPUT_ROOT/year/month/top_downloads.html + OUTPUT_ROOT/year/month/index.html + + Statistics creation : + None + + Statistics update : + None + + Statistics deletion : + None + + +plugins.display.all_visits +-------------------------- + + Display hook + + Create All visits page + + Plugin requirements : + None + + Conf values needed : + display_visitor_ip* + + Output files : + OUTPUT_ROOT/year/month/all_visits.html + OUTPUT_ROOT/year/month/index.html + + Statistics creation : + None + + Statistics update : + None + + Statistics deletion : + None + + +plugins.display.top_hits +------------------------ + + Display hook + + Create TOP hits page + + Plugin requirements : + post_analysis/top_hits + + Conf values needed : + max_hits_displayed* + create_all_hits_page* + + Output files : + OUTPUT_ROOT/year/month/top_hits.html + OUTPUT_ROOT/year/month/index.html + + Statistics creation : + None + + Statistics update : + None + + Statistics deletion : + None + + +plugins.display.referers +------------------------ + + Display hook + + Create Referers page + + Plugin requirements : + post_analysis/referers + + Conf values needed : + max_referers_displayed* + create_all_referers_page* + max_key_phrases_displayed* + create_all_key_phrases_page* + + Output files : + OUTPUT_ROOT/year/month/referers.html + OUTPUT_ROOT/year/month/key_phrases.html + OUTPUT_ROOT/year/month/index.html + + Statistics creation : + None + + Statistics update : + None + + Statistics deletion : + None + + +plugins.display.top_visitors +---------------------------- + + Display hook + + Create TOP visitors block + + Plugin requirements : + None + + Conf values needed : + display_visitor_ip* + + Output files : + OUTPUT_ROOT/year/month/index.html + + Statistics creation : + None + + Statistics update : + None + + Statistics deletion : + None + + +plugins.display.top_pages +------------------------- + + Display hook + + Create TOP pages page + + Plugin requirements : + post_analysis/top_pages + + Conf values needed : + max_pages_displayed* + create_all_pages_page* + + Output files : + OUTPUT_ROOT/year/month/top_pages.html + OUTPUT_ROOT/year/month/index.html + + Statistics creation : + None + + Statistics update : + None + + Statistics deletion : + None + + +plugins.post_analysis.top_downloads +----------------------------------- + + Post analysis hook + + Count TOP downloads + + Plugin requirements : + None + + Conf values needed : + None + + Output files : + None + + Statistics creation : + None + + Statistics update : + month_stats: + top_downloads => + uri + + Statistics deletion : + None + + +plugins.post_analysis.top_hits +------------------------------ + + Post analysis hook + + Count TOP hits + + Plugin requirements : + None + + Conf values needed : + None + + Output files : + None + + Statistics creation : + None + + Statistics update : + month_stats: + top_hits => + uri + + Statistics deletion : + None + + +plugins.post_analysis.referers +------------------------------ + + Post analysis hook + + Extract referers and key phrases from requests + + Plugin requirements : + None + + Conf values needed : + domain_name + + Output files : + None + + Statistics creation : + None + + Statistics update : + month_stats : + referers => + pages + hits + robots_referers => + pages + hits + search_engine_referers => + pages + hits + key_phrases => + phrase + + Statistics deletion : + None + + +plugins.post_analysis.reverse_dns +--------------------------------- + + Post analysis hook + + Replace IP by reverse DNS names + + Plugin requirements : + None + + Conf values needed : + reverse_dns_timeout* + + Output files : + None + + Statistics creation : + None + + Statistics update : + valid_visitors: + remote_addr + dns_name_replaced + dns_analyzed + + Statistics deletion : + None + + +plugins.post_analysis.top_pages +------------------------------- + + Post analysis hook + + Count TOP pages + + Plugin requirements : + None + + Conf values needed : + None + + Output files : + None + + Statistics creation : + None + + Statistics update : + month_stats: + top_pages => + uri + + Statistics deletion : + None + + +plugins.pre_analysis.page_to_hit +-------------------------------- + + Pre analysis hook + Change page into hit and hit into page into statistics + + Plugin requirements : + None + + Conf values needed : + page_to_hit_conf* + hit_to_page_conf* + + Output files : + None + + Statistics creation : + None + + Statistics update : + visits : + remote_addr => + is_page + + Statistics deletion : + None + + +plugins.pre_analysis.robots +--------------------------- + + Pre analysis hook + + Filter robots + + Plugin requirements : + None + + Conf values needed : + page_to_hit_conf* + hit_to_page_conf* + + Output files : + None + + Statistics creation : + None + + Statistics update : + visits : + remote_addr => + robot + + Statistics deletion : + None + + diff --git a/docs/main.md b/docs/main.md new file mode 100644 index 0000000..0b5b16e --- /dev/null +++ b/docs/main.md @@ -0,0 +1,92 @@ +iwla +==== + +Introduction +------------ + +iwla (Intelligent Web Log Analyzer) is basically a clone of [awstats](http://www.awstats.org). The main problem with awstats is that it's a very monolothic project with everything in one big PERL file. In opposite, iwla has be though to be very modular : a small core analysis and a lot of filters. It can be viewed as UNIX pipes. Philosophy of iwla is : add, update, delete ! That's the job of each filters : modify statistics until final result. It's written in Python. + +Nevertheless, iwla is only focused on HTTP logs. It uses data (robots definitions, search engines definitions) and design from awstats. Moreover, it's not dynamic, but only generates static HTML page (with gzip compression option). + +Usage +----- + + ./iwla [-c|--clean-output] [-i|--stdin] [-f FILE|--file FILE] [-d LOGLEVEL|--log-level LOGLEVEL] + + -c : Clean output (database and HTML) before starting + -i : Read data from stdin instead of conf.analyzed_filename + -f : Read data from FILE instead of conf.analyzed_filename + -d : Loglevel in ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'] + +Basic usage +----------- + +In addition to command line, iwla read parameters in default_conf.py. User can override default values using _conf.py_ file. Each module requires its own parameters. + +Main values to edit are : + + * **analyzed_filename** : web server log + * **domaine_name** : domain name to filter + * **pre_analysis_hooks** : List of pre analysis hooks + * **post_analysis_hooks** : List of post analysis hooks + * **display_hooks** : List of display hooks + * **locale** : Displayed locale (_en_ or _fr_) + +Then, you can then iwla. Output HTML files are created in _output_ directory by default. To quickly see it go in output and type + + python -m SimpleHTTPServer 8000 + +Open your favorite web browser at _http://localhost:8000_. Enjoy ! + +**Warning** : The order is hooks list is important : Some plugins may requires others plugins, and the order of display_hooks is the order of displayed blocks in final result. + + +Interesting default configuration values +---------------------------------------- + + * **DB_ROOT** : Default database directory (default ./output_db) + * **DISPLAY_ROOT** : Default HTML output directory (default ./output) + * **log_format** : Web server log format (nginx style). Default is apache log format + * **time_format** : Time format used in log format + * **pages_extensions** : Extensions that are considered as a HTML page (or result) in opposit to hits + * **viewed_http_codes** : HTTP codes that are cosidered OK (200, 304) + * **count_hit_only_visitors** : If False, doesn't cout visitors that doesn't GET a page but resources only (images, rss...) + * **multimedia_files** : Multimedia extensions (not accounted as downloaded files) + * **css_path** : CSS path (you can add yours) + * **compress_output_files** : Files extensions to compress in gzip during display build + +Plugins +------- + +As previously described, plugins acts like UNIX pipes : statistics are constantly updated by each plugin to produce final result. We have three type of plugins : + + * **Pre analysis plugins** : Called before generating days statistics. They are in charge to filter robots, crawlers, bad pages... + * **Post analysis plugins** : Called after basic statistics computation. They are in charge to enlight them with their own algorithms + * **Display plugins** : They are in charge to produce HTML files from statistics. + +To use plugins, just insert their name in _pre_analysis_hooks_, _post_analysis_hooks_ and _display_hooks_ lists in conf.py. + +Statistics are stored in dictionaries : + + * **month_stats** : Statistics of current analysed month + * **valid_visitor** : A subset of month_stats without robots + * **days_stats** : Statistics of current analysed day + * **visits** : All visitors with all of its requests + * **meta** : Final result of month statistics (by year) + +Create a Plugins +---------------- + +To create a new plugin, it's necessary to create a derived class of IPlugin (_iplugin.py) in the right directory (_plugins/xxx/yourPlugin.py_). + +Plugins can defines required configuration values (self.conf_requires) that must be set in conf.py (or can be optional). They can also defines required plugins (self.requires). + +The two functions to overload are _load(self)_ that must returns True or False if all is good (or not). It's called after _init_. The second is _hook(self)_ that is the body of plugins. + +For display plugins, a lot of code has been wrote in _display.py_ that simplify the creation on HTML blocks, tables and bar graphs. + +Plugins +======= + +Optional configuration values ends with *. + diff --git a/docs/modules.md b/docs/modules.md new file mode 100644 index 0000000..41167c3 --- /dev/null +++ b/docs/modules.md @@ -0,0 +1,460 @@ +iwla +---- + + Main class IWLA + Parse Log, compute them, call plugins and produce output + For now, only HTTP log are valid + + Plugin requirements : + None + + Conf values needed : + analyzed_filename + domain_name + locales_path + compress_output_files* + + Output files : + DB_ROOT/meta.db + DB_ROOT/year/month/iwla.db + OUTPUT_ROOT/index.html + OUTPUT_ROOT/year/month/index.html + + Statistics creation : + + meta : + last_time + start_analysis_time + stats => + year => + month => + viewed_bandwidth + not_viewed_bandwidth + viewed_pages + viewed_hits + nb_visits + nb_visitors + + month_stats : + viewed_bandwidth + not_viewed_bandwidth + viewed_pages + viewed_hits + nb_visits + + days_stats : + day => + viewed_bandwidth + not_viewed_bandwidth + viewed_pages + viewed_hits + nb_visits + nb_visitors + + visits : + remote_addr => + remote_addr + remote_ip + viewed_pages + viewed_hits + not_viewed_pages + not_viewed_hits + bandwidth + last_access + requests => + [fields_from_format_log] + extract_request => + extract_uri + extract_parameters* + extract_referer* => + extract_uri + extract_parameters* + robot + hit_only + is_page + + valid_visitors: + month_stats without robot and hit only visitors (if not conf.count_hit_only_visitors) + + Statistics update : + None + + Statistics deletion : + None + + +plugins.display.top_downloads +----------------------------- + + Display hook + + Create TOP downloads page + + Plugin requirements : + post_analysis/top_downloads + + Conf values needed : + max_downloads_displayed* + create_all_downloads_page* + + Output files : + OUTPUT_ROOT/year/month/top_downloads.html + OUTPUT_ROOT/year/month/index.html + + Statistics creation : + None + + Statistics update : + None + + Statistics deletion : + None + + +plugins.display.all_visits +-------------------------- + + Display hook + + Create All visits page + + Plugin requirements : + None + + Conf values needed : + display_visitor_ip* + + Output files : + OUTPUT_ROOT/year/month/all_visits.html + OUTPUT_ROOT/year/month/index.html + + Statistics creation : + None + + Statistics update : + None + + Statistics deletion : + None + + +plugins.display.top_hits +------------------------ + + Display hook + + Create TOP hits page + + Plugin requirements : + post_analysis/top_hits + + Conf values needed : + max_hits_displayed* + create_all_hits_page* + + Output files : + OUTPUT_ROOT/year/month/top_hits.html + OUTPUT_ROOT/year/month/index.html + + Statistics creation : + None + + Statistics update : + None + + Statistics deletion : + None + + +plugins.display.referers +------------------------ + + Display hook + + Create Referers page + + Plugin requirements : + post_analysis/referers + + Conf values needed : + max_referers_displayed* + create_all_referers_page* + max_key_phrases_displayed* + create_all_key_phrases_page* + + Output files : + OUTPUT_ROOT/year/month/referers.html + OUTPUT_ROOT/year/month/key_phrases.html + OUTPUT_ROOT/year/month/index.html + + Statistics creation : + None + + Statistics update : + None + + Statistics deletion : + None + + +plugins.display.top_visitors +---------------------------- + + Display hook + + Create TOP visitors block + + Plugin requirements : + None + + Conf values needed : + display_visitor_ip* + + Output files : + OUTPUT_ROOT/year/month/index.html + + Statistics creation : + None + + Statistics update : + None + + Statistics deletion : + None + + +plugins.display.top_pages +------------------------- + + Display hook + + Create TOP pages page + + Plugin requirements : + post_analysis/top_pages + + Conf values needed : + max_pages_displayed* + create_all_pages_page* + + Output files : + OUTPUT_ROOT/year/month/top_pages.html + OUTPUT_ROOT/year/month/index.html + + Statistics creation : + None + + Statistics update : + None + + Statistics deletion : + None + + +plugins.post_analysis.top_downloads +----------------------------------- + + Post analysis hook + + Count TOP downloads + + Plugin requirements : + None + + Conf values needed : + None + + Output files : + None + + Statistics creation : + None + + Statistics update : + month_stats: + top_downloads => + uri + + Statistics deletion : + None + + +plugins.post_analysis.top_hits +------------------------------ + + Post analysis hook + + Count TOP hits + + Plugin requirements : + None + + Conf values needed : + None + + Output files : + None + + Statistics creation : + None + + Statistics update : + month_stats: + top_hits => + uri + + Statistics deletion : + None + + +plugins.post_analysis.referers +------------------------------ + + Post analysis hook + + Extract referers and key phrases from requests + + Plugin requirements : + None + + Conf values needed : + domain_name + + Output files : + None + + Statistics creation : + None + + Statistics update : + month_stats : + referers => + pages + hits + robots_referers => + pages + hits + search_engine_referers => + pages + hits + key_phrases => + phrase + + Statistics deletion : + None + + +plugins.post_analysis.reverse_dns +--------------------------------- + + Post analysis hook + + Replace IP by reverse DNS names + + Plugin requirements : + None + + Conf values needed : + reverse_dns_timeout* + + Output files : + None + + Statistics creation : + None + + Statistics update : + valid_visitors: + remote_addr + dns_name_replaced + dns_analyzed + + Statistics deletion : + None + + +plugins.post_analysis.top_pages +------------------------------- + + Post analysis hook + + Count TOP pages + + Plugin requirements : + None + + Conf values needed : + None + + Output files : + None + + Statistics creation : + None + + Statistics update : + month_stats: + top_pages => + uri + + Statistics deletion : + None + + +plugins.pre_analysis.page_to_hit +-------------------------------- + + Pre analysis hook + Change page into hit and hit into page into statistics + + Plugin requirements : + None + + Conf values needed : + page_to_hit_conf* + hit_to_page_conf* + + Output files : + None + + Statistics creation : + None + + Statistics update : + visits : + remote_addr => + is_page + + Statistics deletion : + None + + +plugins.pre_analysis.robots +--------------------------- + + Pre analysis hook + + Filter robots + + Plugin requirements : + None + + Conf values needed : + page_to_hit_conf* + hit_to_page_conf* + + Output files : + None + + Statistics creation : + None + + Statistics update : + visits : + remote_addr => + robot + + Statistics deletion : + None + + diff --git a/iplugin.py b/iplugin.py new file mode 100644 index 0000000..2664190 --- /dev/null +++ b/iplugin.py @@ -0,0 +1,124 @@ +# -*- coding: utf-8 -*- +# +# Copyright Grégory Soutadé 2015 + +# This file is part of iwla + +# iwla is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# iwla is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with iwla. If not, see . +# + +import importlib +import inspect +import logging + +# +# IWLA Plugin interface +# + +class IPlugin(object): + + def __init__(self, iwla): + self.iwla = iwla + self.requires = [] + self.conf_requires = [] + self.API_VERSION = 1 + self.ANALYSIS_CLASS = 'HTTP' + + def isValid(self, analysis_class, api_version): + if analysis_class != self.ANALYSIS_CLASS: return False + + # For now there is only version 1 + if self.API_VERSION != api_version: + return False + + return True + + def getRequirements(self): + return self.requires + + def getConfRequirements(self): + return self.conf_requires + + def load(self): + return True + + def hook(self): + pass + +def validConfRequirements(conf_requirements, iwla, plugin_path): + for r in conf_requirements: + if iwla.getConfValue(r, None) is None: + print '\'%s\' conf value required for %s' % (r, plugin_path) + return False + + return True + +def preloadPlugins(plugins, iwla): + cache_plugins = {} + + logger = logging.getLogger(__name__) + + logger.info("==> Preload plugins") + + for (root, plugins_filenames) in plugins: + for plugin_filename in plugins_filenames: + plugin_path = root + '.' + plugin_filename + try: + mod = importlib.import_module(plugin_path) + classes = [c for _,c in inspect.getmembers(mod)\ + if inspect.isclass(c) and \ + issubclass(c, IPlugin) and \ + c.__name__ != 'IPlugin' + ] + + if not classes: + logger.warning('No plugin defined in %s' % (plugin_path)) + continue + + plugin = classes[0](iwla) + plugin_name = plugin.__class__.__name__ + + if not plugin.isValid(iwla.ANALYSIS_CLASS, iwla.API_VERSION): + #print 'Plugin not valid %s' % (plugin_filename) + continue + + #print 'Load plugin %s' % (plugin_name) + + conf_requirements = plugin.getConfRequirements() + if not validConfRequirements(conf_requirements, iwla, plugin_path): + continue + + requirements = plugin.getRequirements() + + requirement_validated = False + for r in requirements: + for (_,p) in cache_plugins.items(): + if p.__class__.__name__ == r: + requirement_validated = True + break + if not requirement_validated: + logger.error('Missing requirements \'%s\' for plugin %s' % (r, plugin_path)) + break + if requirements and not requirement_validated: continue + + if not plugin.load(): + logger.error('Plugin %s load failed' % (plugin_path)) + continue + + logger.info('\tRegister %s' % (plugin_path)) + cache_plugins[plugin_path] = plugin + except Exception as e: + logger.exception('Error loading %s => %s' % (plugin_path, e)) + + return cache_plugins diff --git a/iwla.pot b/iwla.pot new file mode 100644 index 0000000..d8b1510 --- /dev/null +++ b/iwla.pot @@ -0,0 +1,279 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR ORGANIZATION +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"POT-Creation-Date: 2014-12-19 17:46+CET\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: ENCODING\n" +"Generated-By: pygettext.py 1.5\n" + + +#: display.py:32 +msgid "April" +msgstr "" + +#: display.py:32 +msgid "February" +msgstr "" + +#: display.py:32 +msgid "January" +msgstr "" + +#: display.py:32 +msgid "July" +msgstr "" + +#: display.py:32 +msgid "March" +msgstr "" + +#: display.py:32 iwla.py:428 +msgid "June" +msgstr "" + +#: display.py:32 iwla.py:428 +msgid "May" +msgstr "" + +#: display.py:33 +msgid "August" +msgstr "" + +#: display.py:33 +msgid "December" +msgstr "" + +#: display.py:33 +msgid "November" +msgstr "" + +#: display.py:33 +msgid "October" +msgstr "" + +#: display.py:33 +msgid "September" +msgstr "" + +#: iwla.py:371 +msgid "Statistics" +msgstr "" + +#: iwla.py:377 +msgid "By day" +msgstr "" + +#: iwla.py:377 +msgid "Day" +msgstr "" + +#: iwla.py:377 iwla.py:430 +msgid "Not viewed Bandwidth" +msgstr "" + +#: iwla.py:377 iwla.py:430 +msgid "Visits" +msgstr "" + +#: iwla.py:377 iwla.py:430 plugins/display/all_visits.py:70 +#: plugins/display/referers.py:95 plugins/display/referers.py:153 +#: plugins/display/top_downloads.py:97 plugins/display/top_visitors.py:72 +msgid "Hits" +msgstr "" + +#: iwla.py:377 iwla.py:430 plugins/display/all_visits.py:70 +#: plugins/display/referers.py:95 plugins/display/referers.py:153 +#: plugins/display/top_visitors.py:72 +msgid "Pages" +msgstr "" + +#: iwla.py:377 iwla.py:430 plugins/display/all_visits.py:70 +#: plugins/display/top_visitors.py:72 +msgid "Bandwidth" +msgstr "" + +#: iwla.py:414 +msgid "Average" +msgstr "" + +#: iwla.py:419 iwla.py:457 +msgid "Total" +msgstr "" + +#: iwla.py:428 +msgid "Apr" +msgstr "" + +#: iwla.py:428 +msgid "Aug" +msgstr "" + +#: iwla.py:428 +msgid "Dec" +msgstr "" + +#: iwla.py:428 +msgid "Feb" +msgstr "" + +#: iwla.py:428 +msgid "Jan" +msgstr "" + +#: iwla.py:428 +msgid "Jul" +msgstr "" + +#: iwla.py:428 +msgid "Mar" +msgstr "" + +#: iwla.py:428 +msgid "Nov" +msgstr "" + +#: iwla.py:428 +msgid "Oct" +msgstr "" + +#: iwla.py:428 +msgid "Sep" +msgstr "" + +#: iwla.py:429 +msgid "Summary" +msgstr "" + +#: iwla.py:430 +msgid "Month" +msgstr "" + +#: iwla.py:430 +msgid "Visitors" +msgstr "" + +#: iwla.py:430 iwla.py:440 +msgid "Details" +msgstr "" + +#: iwla.py:465 +msgid "Statistics for" +msgstr "" + +#: iwla.py:472 +msgid "Last update" +msgstr "" + +#: plugins/display/all_visits.py:70 plugins/display/top_visitors.py:72 +msgid "Host" +msgstr "" + +#: plugins/display/all_visits.py:70 plugins/display/top_visitors.py:72 +msgid "Last seen" +msgstr "" + +#: plugins/display/all_visits.py:92 +msgid "All visits" +msgstr "" + +#: plugins/display/all_visits.py:93 plugins/display/top_visitors.py:72 +msgid "Top visitors" +msgstr "" + +#: plugins/display/referers.py:95 +msgid "Connexion from" +msgstr "" + +#: plugins/display/referers.py:95 plugins/display/referers.py:153 +msgid "Origin" +msgstr "" + +#: plugins/display/referers.py:99 plugins/display/referers.py:156 +msgid "Search Engine" +msgstr "" + +#: plugins/display/referers.py:110 plugins/display/referers.py:125 +#: plugins/display/referers.py:140 plugins/display/referers.py:163 +#: plugins/display/referers.py:174 plugins/display/referers.py:185 +#: plugins/display/referers.py:222 plugins/display/top_downloads.py:83 +#: plugins/display/top_downloads.py:103 plugins/display/top_hits.py:82 +#: plugins/display/top_hits.py:103 plugins/display/top_pages.py:82 +#: plugins/display/top_pages.py:102 plugins/display/top_visitors.py:92 +msgid "Others" +msgstr "" + +#: plugins/display/referers.py:114 plugins/display/referers.py:167 +msgid "External URL" +msgstr "" + +#: plugins/display/referers.py:129 plugins/display/referers.py:178 +msgid "External URL (robot)" +msgstr "" + +#: plugins/display/referers.py:147 +msgid "Top Referers" +msgstr "" + +#: plugins/display/referers.py:149 +msgid "All Referers" +msgstr "" + +#: plugins/display/referers.py:200 plugins/display/referers.py:210 +msgid "Top key phrases" +msgstr "" + +#: plugins/display/referers.py:200 plugins/display/referers.py:216 +msgid "Key phrase" +msgstr "" + +#: plugins/display/referers.py:200 plugins/display/referers.py:216 +msgid "Search" +msgstr "" + +#: plugins/display/referers.py:212 +msgid "All key phrases" +msgstr "" + +#: plugins/display/top_downloads.py:71 +msgid "Hit" +msgstr "" + +#: plugins/display/top_downloads.py:71 plugins/display/top_downloads.py:91 +msgid "All Downloads" +msgstr "" + +#: plugins/display/top_downloads.py:71 plugins/display/top_downloads.py:97 +#: plugins/display/top_hits.py:71 plugins/display/top_hits.py:97 +#: plugins/display/top_pages.py:71 plugins/display/top_pages.py:96 +msgid "URI" +msgstr "" + +#: plugins/display/top_downloads.py:89 +msgid "Top Downloads" +msgstr "" + +#: plugins/display/top_hits.py:71 plugins/display/top_hits.py:91 +msgid "All Hits" +msgstr "" + +#: plugins/display/top_hits.py:71 plugins/display/top_hits.py:97 +#: plugins/display/top_pages.py:71 plugins/display/top_pages.py:96 +msgid "Entrance" +msgstr "" + +#: plugins/display/top_pages.py:71 plugins/display/top_pages.py:90 +msgid "All Pages" +msgstr "" + +#: plugins/display/top_pages.py:88 +msgid "Top Pages" +msgstr "" + diff --git a/iwla.py b/iwla.py index 39fcafd..0c0f331 100755 --- a/iwla.py +++ b/iwla.py @@ -1,178 +1,718 @@ #!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# Copyright Grégory Soutadé 2015 + +# This file is part of iwla + +# iwla is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# iwla is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with iwla. If not, see . +# import os +import shutil +import sys import re import time -import glob -import imp -from robots import awstats_robots; +import pickle +import gzip +import importlib +import argparse +import logging +import gettext +from calendar import monthrange +from datetime import date -print '==> Start' +import default_conf as conf +import conf as _ +conf.__dict__.update(_.__dict__) +del _ -current_visit = {} +from iplugin import * +from display import * -log_format = '$server_name:$server_port $remote_addr - $remote_user [$time_local] ' +\ - '"$request" $status $body_bytes_sent ' +\ - '"$http_referer" "$http_user_agent"'; +""" +Main class IWLA +Parse Log, compute them, call plugins and produce output +For now, only HTTP log are valid -log_format_extracted = re.sub(r'([^\$\w])', r'\\\g<1>', log_format); -log_format_extracted = re.sub(r'\$(\w+)', '(?P<\g<1>>.+)', log_format_extracted) -http_request_extracted = re.compile(r'(?P\S+) (?P\S+) (?P\S+)') -#09/Nov/2014:06:35:16 +0100 -time_format = '%d/%b/%Y:%H:%M:%S +0100' -#print "Log format : " + log_format_extracted +Plugin requirements : + None -log_re = re.compile(log_format_extracted) -uri_re = re.compile(r'(?P[^\?]*)\?(?P.*)') -pages_extensions = ['/', 'html', 'xhtml', 'py', 'pl', 'rb', 'php'] -viewed_http_codes = [200] +Conf values needed : + analyzed_filename + domain_name + locales_path + compress_output_files* -cur_time = None +Output files : + DB_ROOT/meta.db + DB_ROOT/year/month/iwla.db + OUTPUT_ROOT/index.html + OUTPUT_ROOT/year/month/index.html -print '==> Generating robot dictionary' +Statistics creation : -awstats_robots = map(lambda (x) : re.compile(x, re.IGNORECASE), awstats_robots) +meta : + last_time + start_analysis_time + stats => + year => + month => + viewed_bandwidth + not_viewed_bandwidth + viewed_pages + viewed_hits + nb_visits + nb_visitors -def isPage(request): - for e in pages_extensions: - if request.endswith(e): - return True +month_stats : + viewed_bandwidth + not_viewed_bandwidth + viewed_pages + viewed_hits + nb_visits - return False +days_stats : + day => + viewed_bandwidth + not_viewed_bandwidth + viewed_pages + viewed_hits + nb_visits + nb_visitors -def appendHit(hit): - super_hit = current_visit[hit['remote_addr']] - super_hit['pages'].append(hit) - super_hit['bandwith'] += int(hit['body_bytes_sent']) - - request = hit['extract_request'] +visits : + remote_addr => + remote_addr + remote_ip + viewed_pages + viewed_hits + not_viewed_pages + not_viewed_hits + bandwidth + last_access + requests => + [fields_from_format_log] + extract_request => + extract_uri + extract_parameters* + extract_referer* => + extract_uri + extract_parameters* + robot + hit_only + is_page - if 'extract_uri' in request.keys(): - uri = request['extract_uri'] - else: - uri = request['http_uri'] +valid_visitors: + month_stats without robot and hit only visitors (if not conf.count_hit_only_visitors) - hit['is_page'] = isPage(uri) +Statistics update : + None - # Don't count redirect status - if int(hit['status']) == 302: return +Statistics deletion : + None +""" - if super_hit['robot'] or\ - not int(hit['status']) in viewed_http_codes: - page_key = 'not_viewed_pages' - hit_key = 'not_viewed_hits' - else: - page_key = 'viewed_pages' - hit_key = 'viewed_hits' - - if hit['is_page']: - super_hit[page_key] += 1 - else: - super_hit[hit_key] += 1 - -def createGeneric(hit): - super_hit = current_visit[hit['remote_addr']] = {} - super_hit['viewed_pages'] = 0; - super_hit['viewed_hits'] = 0; - super_hit['not_viewed_pages'] = 0; - super_hit['not_viewed_hits'] = 0; - super_hit['bandwith'] = 0; - super_hit['pages'] = []; - - return super_hit -def createUser(hit, robot): - super_hit = createGeneric(hit) - super_hit['robot'] = robot; - appendHit(hit) +class IWLA(object): -def isRobot(hit): - for r in awstats_robots: - if r.match(hit['http_user_agent']): - return True - return False + ANALYSIS_CLASS = 'HTTP' + API_VERSION = 1 + IWLA_VERSION = '0.1' -def decode_http_request(hit): - if not 'request' in hit.keys(): return False + def __init__(self, logLevel): + self.meta_infos = {} + self.analyse_started = False + self.current_analysis = {} + self.cache_plugins = {} + self.display = DisplayHTMLBuild(self) + self.valid_visitors = None + + self.log_format_extracted = re.sub(r'([^\$\w])', r'\\\g<1>', conf.log_format) + self.log_format_extracted = re.sub(r'\$(\w+)', '(?P<\g<1>>.+)', self.log_format_extracted) + self.http_request_extracted = re.compile(r'(?P\S+) (?P\S+) (?P\S+)') + self.log_re = re.compile(self.log_format_extracted) + self.uri_re = re.compile(r'(?P[^\?#]+)(\?(?P[^#]+))?(#.*)?') + self.domain_name_re = re.compile(r'.*%s' % conf.domain_name) + self.plugins = [(conf.PRE_HOOK_DIRECTORY , conf.pre_analysis_hooks), + (conf.POST_HOOK_DIRECTORY , conf.post_analysis_hooks), + (conf.DISPLAY_HOOK_DIRECTORY , conf.display_hooks)] + + logging.basicConfig(format='%(name)s %(message)s', level=logLevel) + self.logger = logging.getLogger(self.__class__.__name__) + self.logger.info('==> Start') + try: + t = gettext.translation('iwla', localedir=conf.locales_path, languages=[conf.locale], codeset='utf8') + self.logger.info('\tUsing locale %s' % (conf.locale)) + except IOError: + t = gettext.NullTranslations() + self.logger.info('\tUsing default locale en_EN') + self._ = t.ugettext + + def getVersion(self): + return IWLA.IWLA_VERSION + + def getConfValue(self, key, default=None): + if not key in dir(conf): + return default + else: + return conf.__dict__[key] + + def _clearVisits(self): + self.current_analysis = { + 'days_stats' : {}, + 'month_stats' : {}, + 'visits' : {} + } + self.valid_visitors = None + return self.current_analysis + + def getDaysStats(self): + return self.current_analysis['days_stats'] + + def getMonthStats(self): + return self.current_analysis['month_stats'] + + def getCurrentVisists(self): + return self.current_analysis['visits'] + + def getValidVisitors(self): + return self.valid_visitors + + def getDisplay(self): + return self.display + + def getCurTime(self): + return self.meta_infos['last_time'] + + def getStartAnalysisTime(self): + return self.meta_infos['start_analysis_time'] + + def isValidForCurrentAnalysis(self, request): + cur_time = self.meta_infos['start_analysis_time'] + # Analyse not started + if not cur_time: return False + return (time.mktime(cur_time) < time.mktime(request['time_decoded'])) + + def hasBeenViewed(self, request): + return int(request['status']) in conf.viewed_http_codes + + def getCurDisplayPath(self, filename): + cur_time = self.meta_infos['last_time'] + return os.path.join(str(cur_time.tm_year), '%02d' % (cur_time.tm_mon), filename) + + def getResourcesPath(self): + return conf.resources_path + + def getCSSPath(self): + return conf.css_path + + def _clearMeta(self): + self.meta_infos = { + 'last_time' : None, + 'start_analysis_time' : None + } + return self.meta_infos + + def _clearDisplay(self): + self.display = DisplayHTMLBuild(self) + return self.display + + def getDBFilename(self, time): + return os.path.join(conf.DB_ROOT, str(time.tm_year), '%02d' % (time.tm_mon), conf.DB_FILENAME) + + def _serialize(self, obj, filename): + base = os.path.dirname(filename) + if not os.path.exists(base): + os.makedirs(base) + + # TODO : remove return + #return + + with open(filename + '.tmp', 'wb+') as f, gzip.open(filename, 'w') as fzip: + pickle.dump(obj, f) + f.seek(0) + fzip.write(f.read()) + os.remove(filename + '.tmp') + + def _deserialize(self, filename): + if not os.path.exists(filename): + return None + + with gzip.open(filename, 'r') as f: + return pickle.load(f) + return None + + def _callPlugins(self, target_root, *args): + self.logger.info('==> Call plugins (%s)' % (target_root)) + for (root, plugins) in self.plugins: + if root != target_root: continue + for p in plugins: + mod = self.cache_plugins.get(root + '.' + p, None) + if mod: + self.logger.info('\t%s' % (p)) + mod.hook(*args) + + def isPage(self, request): + for e in conf.pages_extensions: + if request.endswith(e): + return True - groups = http_request_extracted.match(hit['request']) - - if groups: - hit['extract_request'] = groups.groupdict() - uri_groups = uri_re.match(hit['extract_request']['http_uri']); - if uri_groups: - hit['extract_request']['extract_uri'] = uri_groups.group('extract_uri') - hit['extract_request']['extract_parameters'] = uri_groups.group('extract_parameters') - else: - print "Bad request extraction " + hit['request'] return False - referer_groups = uri_re.match(hit['http_referer']); - if referer_groups: - hit['extract_referer']['extract_uri'] = referer_groups.group('extract_uri') - hit['extract_referer']['extract_parameters'] = referer_groups.group('extract_parameters') - return True + def _appendHit(self, hit): + remote_addr = hit['remote_addr'] + + if not remote_addr: return -def decode_time(hit): - t = hit['time_local'] + if not remote_addr in self.current_analysis['visits'].keys(): + self._createVisitor(hit) + + super_hit = self.current_analysis['visits'][remote_addr] + super_hit['requests'].append(hit) + super_hit['bandwidth'] += int(hit['body_bytes_sent']) + super_hit['last_access'] = self.meta_infos['last_time'] - hit['time_decoded'] = time.strptime(t, time_format) + request = hit['extract_request'] + uri = request.get('extract_uri', request['http_uri']) -def newHit(hit): - global cur_time + hit['is_page'] = self.isPage(uri) - if not decode_http_request(hit): return + if super_hit['robot'] or\ + not self.hasBeenViewed(hit): + page_key = 'not_viewed_pages' + hit_key = 'not_viewed_hits' + else: + page_key = 'viewed_pages' + hit_key = 'viewed_hits' - for k in hit.keys(): - if hit[k] == '-': hit[k] = '' + if hit['is_page']: + super_hit[page_key] += 1 + else: + super_hit[hit_key] += 1 - decode_time(hit) + def _createVisitor(self, hit): + super_hit = self.current_analysis['visits'][hit['remote_addr']] = {} + super_hit['remote_addr'] = hit['remote_addr'] + super_hit['remote_ip'] = hit['remote_addr'] + super_hit['viewed_pages'] = 0 + super_hit['viewed_hits'] = 0 + super_hit['not_viewed_pages'] = 0 + super_hit['not_viewed_hits'] = 0 + super_hit['bandwidth'] = 0 + super_hit['last_access'] = self.meta_infos['last_time'] + super_hit['requests'] = [] + super_hit['robot'] = False + super_hit['hit_only'] = 0 - t = hit['time_decoded'] + def _decodeHTTPRequest(self, hit): + if not 'request' in hit.keys(): return False - current_visit['last_time'] = t + groups = self.http_request_extracted.match(hit['request']) - if cur_time == None: - cur_time = t - else: - if cur_time.tm_mday != t.tm_mday: + if groups: + hit['extract_request'] = groups.groupdict() + uri_groups = self.uri_re.match(hit['extract_request']['http_uri']) + if uri_groups: + d = uri_groups.groupdict() + hit['extract_request']['extract_uri'] = d['extract_uri'] + if 'extract_parameters' in d.keys(): + hit['extract_request']['extract_parameters'] = d['extract_parameters'] + else: + self.logger.warning("Bad request extraction %s" % (hit['request'])) return False - remote_addr = hit['remote_addr'] - if remote_addr in current_visit.keys(): - appendHit(hit) - else: - createUser(hit, isRobot(hit)) + if hit['http_referer']: + referer_groups = self.uri_re.match(hit['http_referer']) + if referer_groups: + hit['extract_referer'] = referer_groups.groupdict() + return True - return True + def _decodeTime(self, hit): + try: + hit['time_decoded'] = time.strptime(hit['time_local'], conf.time_format) + except ValueError, e: + if sys.version_info < (3, 2): + # Try without UTC value at the end (%z not recognized) + gmt_offset_str = hit['time_local'][-5:] + gmt_offset_hours = int(gmt_offset_str[1:3])*60*60 + gmt_offset_minutes = int(gmt_offset_str[3:5])*60 + gmt_offset = gmt_offset_hours + gmt_offset_minutes + hit['time_decoded'] = time.strptime(hit['time_local'][:-6], conf.time_format[:-3]) + if gmt_offset_str[0] == '+': + hit['time_decoded'] = time.localtime(time.mktime(hit['time_decoded'])+gmt_offset) + else: + hit['time_decoded'] = time.localtime(time.mktime(hit['time_decoded'])-gmt_offset) + else: + raise e + return hit['time_decoded'] -print '==> Analysing log' -f = open("access.log") -for l in f: - # print "line " + l; + def getDisplayIndex(self): + cur_time = self.meta_infos['last_time'] + filename = self.getCurDisplayPath('index.html') + + return self.display.getPage(filename) + + def _generateDisplayDaysStats(self): + cur_time = self.meta_infos['last_time'] + title = createCurTitle(self, self._('Statistics')) + filename = self.getCurDisplayPath('index.html') + self.logger.info('==> Generate display (%s)' % (filename)) + page = self.display.createPage(title, filename, conf.css_path) + + _, nb_month_days = monthrange(cur_time.tm_year, cur_time.tm_mon) + days = self.display.createBlock(DisplayHTMLBlockTableWithGraph, self._('By day'), [self._('Day'), self._('Visits'), self._('Pages'), self._('Hits'), self._('Bandwidth'), self._('Not viewed Bandwidth')], None, nb_month_days, range(1,6)) + days.setColsCSSClass(['', 'iwla_visit', 'iwla_page', 'iwla_hit', 'iwla_bandwidth', 'iwla_bandwidth']) + nb_visits = 0 + nb_days = 0 + for i in range(1, nb_month_days+1): + day = '%d
%s' % (i, time.strftime('%b', cur_time)) + full_day = '%02d %s %d' % (i, time.strftime('%b', cur_time), cur_time.tm_year) + if i in self.current_analysis['days_stats'].keys(): + stats = self.current_analysis['days_stats'][i] + row = [full_day, stats['nb_visits'], stats['viewed_pages'], stats['viewed_hits'], + stats['viewed_bandwidth'], stats['not_viewed_bandwidth']] + nb_visits += stats['nb_visits'] + nb_days += 1 + else: + row = [full_day, 0, 0, 0, 0, 0] + days.appendRow(row) + days.setCellValue(i-1, 4, bytesToStr(row[4])) + days.setCellValue(i-1, 5, bytesToStr(row[5])) + days.appendShortTitle(day) + adate = date(cur_time.tm_year, cur_time.tm_mon, i) + week_day = adate.weekday() + if week_day == 5 or week_day == 6: + days.setRowCSSClass(i-1, 'iwla_weekend') + if adate == date.today(): + css = days.getCellCSSClass(i-1, 0) + if css: css = '%s %s' % (css, 'iwla_curday') + else: css = 'iwla_curday' + days.setCellCSSClass(i-1, 0, css) + + stats = self.current_analysis['month_stats'] + + row = [0, nb_visits, stats['viewed_pages'], stats['viewed_hits'], stats['viewed_bandwidth'], stats['not_viewed_bandwidth']] + if nb_days: + average_row = map(lambda(v): int(v/nb_days), row) + else: + average_row = map(lambda(v): 0, row) + + average_row[0] = self._('Average') + average_row[4] = bytesToStr(average_row[4]) + average_row[5] = bytesToStr(average_row[5]) + days.appendRow(average_row) + + row[0] = self._('Total') + row[4] = bytesToStr(row[4]) + row[5] = bytesToStr(row[5]) + days.appendRow(row) + page.appendBlock(days) + self.display.addPage(page) + + def _generateDisplayMonthStats(self, page, year, month_stats): + cur_time = time.localtime() + months_name = ['', self._('Jan'), self._('Feb'), self._('Mar'), self._('Apr'), self._('May'), self._('June'), self._('Jul'), self._('Aug'), self._('Sep'), self._('Oct'), self._('Nov'), self._('Dec')] + title = '%s %d' % (self._('Summary'), year) + cols = [self._('Month'), self._('Visitors'), self._('Visits'), self._('Pages'), self._('Hits'), self._('Bandwidth'), self._('Not viewed Bandwidth'), self._('Details')] + graph_cols=range(1,7) + months = self.display.createBlock(DisplayHTMLBlockTableWithGraph, title, cols, None, 12, graph_cols) + months.setColsCSSClass(['', 'iwla_visitor', 'iwla_visit', 'iwla_page', 'iwla_hit', 'iwla_bandwidth', 'iwla_bandwidth', '']) + total = [0] * len(cols) + for i in range(1, 13): + month = '%s
%d' % (months_name[i], year) + full_month = '%s %d' % (months_name[i], year) + if i in month_stats.keys(): + stats = month_stats[i] + link = '%s' % (year, i, self._('Details')) + row = [full_month, stats['nb_visitors'], stats['nb_visits'], stats['viewed_pages'], stats['viewed_hits'], + stats['viewed_bandwidth'], stats['not_viewed_bandwidth'], link] + for j in graph_cols: + total[j] += row[j] + else: + row = [full_month, 0, 0, 0, 0, 0, 0, ''] + months.appendRow(row) + months.setCellValue(i-1, 5, bytesToStr(row[5])) + months.setCellValue(i-1, 6, bytesToStr(row[6])) + months.appendShortTitle(month) + if year == cur_time.tm_year and i == cur_time.tm_mon: + css = months.getCellCSSClass(i-1, 0) + if css: css = '%s %s' % (css, 'iwla_curday') + else: css = 'iwla_curday' + months.setCellCSSClass(i-1, 0, css) + + total[0] = self._('Total') + total[5] = bytesToStr(total[5]) + total[6] = bytesToStr(total[6]) + total[7] = u'' + months.appendRow(total) + page.appendBlock(months) + + def _generateDisplayWholeMonthStats(self): + title = '%s %s' % (self._('Statistics for'), conf.domain_name) + filename = 'index.html' + + self.logger.info('==> Generate main page (%s)' % (filename)) + + page = self.display.createPage(title, filename, conf.css_path) + + last_update = '%s %s
' % (self._('Last update'), time.strftime('%02d %b %Y %H:%M', time.localtime())) + page.appendBlock(self.display.createBlock(DisplayHTMLRaw, last_update)) + + for year in sorted(self.meta_infos['stats'].keys(), reverse=True): + self._generateDisplayMonthStats(page, year, self.meta_infos['stats'][year]) + + self.display.addPage(page) + + def _compressFile(self, build_time, root, filename): + path = os.path.join(root, filename) + gz_path = path + '.gz' + + self.logger.debug('Compress %s => %s' % (path, gz_path)) + + if not os.path.exists(gz_path) or\ + os.stat(path).st_mtime > build_time: + with open(path, 'rb') as f_in, gzip.open(gz_path, 'wb') as f_out: + f_out.write(f_in.read()) + + def _compressFiles(self, build_time, root): + if not conf.compress_output_files: return + for rootdir, subdirs, files in os.walk(root, followlinks=True): + for f in files: + for ext in conf.compress_output_files: + if f.endswith(ext): + self._compressFile(build_time, rootdir, f) + break + + def _generateDisplay(self): + self._generateDisplayDaysStats() + self._callPlugins(conf.DISPLAY_HOOK_DIRECTORY) + self._generateDisplayWholeMonthStats() + build_time = time.localtime() + self.display.build(conf.DISPLAY_ROOT) + self._compressFiles(build_time, conf.DISPLAY_ROOT) + + def _createEmptyStats(self): + stats = {} + stats['viewed_bandwidth'] = 0 + stats['not_viewed_bandwidth'] = 0 + stats['viewed_pages'] = 0 + stats['viewed_hits'] = 0 + stats['nb_visits'] = 0 + + return stats + + def _generateMonthStats(self): + self._clearDisplay() + + visits = self.current_analysis['visits'] + + stats = self._createEmptyStats() + for (day, stat) in self.current_analysis['days_stats'].items(): + for k in stats.keys(): + stats[k] += stat[k] + + duplicated_stats = {k:v for (k,v) in stats.items()} + + cur_time = self.meta_infos['last_time'] + self.logger.info("== Stats for %d/%02d ==" % (cur_time.tm_year, cur_time.tm_mon)) + self.logger.info(stats) + + if not 'month_stats' in self.current_analysis.keys(): + self.current_analysis['month_stats'] = stats + else: + for (k,v) in stats.items(): + self.current_analysis['month_stats'][k] = v + + self.valid_visitors = {} + for (k,v) in visits.items(): + if v['robot']: continue + if not (conf.count_hit_only_visitors or\ + v['viewed_pages']): + continue + self.valid_visitors[k] = v + + duplicated_stats['nb_visitors'] = stats['nb_visitors'] = len(self.valid_visitors.keys()) + + self._callPlugins(conf.POST_HOOK_DIRECTORY) + + path = self.getDBFilename(cur_time) + if os.path.exists(path): + os.remove(path) + + self.logger.info("==> Serialize to %s" % (path)) + self._serialize(self.current_analysis, path) + + # Save month stats + year = cur_time.tm_year + month = cur_time.tm_mon + if not 'stats' in self.meta_infos.keys(): + self.meta_infos['stats'] = {} + if not year in self.meta_infos['stats'].keys(): + self.meta_infos['stats'][year] = {} + self.meta_infos['stats'][year][month] = duplicated_stats + + self._generateDisplay() + + def _generateDayStats(self): + visits = self.current_analysis['visits'] + cur_time = self.meta_infos['last_time'] + + self._callPlugins(conf.PRE_HOOK_DIRECTORY) + + stats = self._createEmptyStats() + + for (k, super_hit) in visits.items(): + if super_hit['last_access'].tm_mday != cur_time.tm_mday: + continue + viewed_page = False + for hit in super_hit['requests'][::-1]: + if hit['time_decoded'].tm_mday != cur_time.tm_mday: + break + if super_hit['robot'] or\ + not self.hasBeenViewed(hit): + stats['not_viewed_bandwidth'] += int(hit['body_bytes_sent']) + continue + stats['viewed_bandwidth'] += int(hit['body_bytes_sent']) + if hit['is_page']: + stats['viewed_pages'] += 1 + viewed_pages = True + else: + stats['viewed_hits'] += 1 + if (conf.count_hit_only_visitors or\ + viewed_pages) and\ + not super_hit['robot']: + stats['nb_visits'] += 1 + + self.logger.info("== Stats for %d/%02d/%02d ==" % (cur_time.tm_year, cur_time.tm_mon, cur_time.tm_mday)) + self.logger.info(stats) + + self.current_analysis['days_stats'][cur_time.tm_mday] = stats + + def _newHit(self, hit): + if not self.domain_name_re.match(hit['server_name']): + return False + + t = self._decodeTime(hit) + + cur_time = self.meta_infos['last_time'] + + if cur_time == None: + self.current_analysis = self._deserialize(self.getDBFilename(t)) or self._clearVisits() + self.analyse_started = True + else: + if time.mktime(t) <= time.mktime(cur_time): + return False + self.analyse_started = True + if cur_time.tm_mon != t.tm_mon: + self._generateMonthStats() + self.current_analysis = self._deserialize(self.getDBFilename(t)) or self._clearVisits() + elif cur_time.tm_mday != t.tm_mday: + self._generateDayStats() + + self.meta_infos['last_time'] = t + + if not self.meta_infos['start_analysis_time']: + self.meta_infos['start_analysis_time'] = t + + if not self._decodeHTTPRequest(hit): return False + + for k in hit.keys(): + if hit[k] == '-' or hit[k] == '*': + hit[k] = '' + + self._appendHit(hit) + + return True + + def start(self, _file): + self.logger.info('==> Load previous database') + + self.meta_infos = self._deserialize(conf.META_PATH) or self._clearMeta() + if self.meta_infos['last_time']: + self.logger.info('Last time') + self.logger.info(self.meta_infos['last_time']) + self.current_analysis = self._deserialize(self.getDBFilename(self.meta_infos['last_time'])) or self._clearVisits() + else: + self._clearVisits() + + self.meta_infos['start_analysis_time'] = None + + self.cache_plugins = preloadPlugins(self.plugins, self) + + self.logger.info('==> Analysing log') + + for l in _file: + # print "line " + l + + groups = self.log_re.match(l) + + if groups: + self._newHit(groups.groupdict()) + else: + self.logger.warning("No match for %s" % (l)) + #break + + if self.analyse_started: + self._generateDayStats() + self._generateMonthStats() + del self.meta_infos['start_analysis_time'] + self._serialize(self.meta_infos, conf.META_PATH) + else: + self.logger.info('==> Analyse not started : nothing new') + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='Intelligent Web Log Analyzer') + + parser.add_argument('-c', '--clean-output', dest='clean_output', action='store_true', + default=False, + help='Clean output before starting') + + parser.add_argument('-i', '--stdin', dest='stdin', action='store_true', + default=False, + help='Read data from stdin instead of conf.analyzed_filename') + + parser.add_argument('-f', '--file', dest='file', + help='Analyse this log file') + + parser.add_argument('-d', '--log-level', dest='loglevel', + default='INFO', type=str, + help='Loglevel in %s, default : %s' % (['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'], 'INFO')) + + args = parser.parse_args() + + if args.clean_output: + if os.path.exists(conf.DB_ROOT): shutil.rmtree(conf.DB_ROOT) + if os.path.exists(conf.DISPLAY_ROOT): shutil.rmtree(conf.DISPLAY_ROOT) + + loglevel = getattr(logging, args.loglevel.upper(), None) + if not isinstance(loglevel, int): + raise ValueError('Invalid log level: %s' % (args.loglevel)) - groups = log_re.match(l) + iwla = IWLA(loglevel) - if groups: - if not newHit(groups.groupdict()): - break + required_conf = ['analyzed_filename', 'domain_name'] + if not validConfRequirements(required_conf, iwla, 'Main Conf'): + sys.exit(0) + + if args.stdin: + iwla.start(sys.stdin) else: - print "No match " + l -f.close(); - -print '==> Call plugins' -plugins = glob.glob('./hooks_pre/*.py') -plugins.sort() -for p in plugins: - print '\t%s' % (p) - mod = imp.load_source('hook', p) - mod.hook(current_visit) - -for ip in current_visit.keys(): - hit = current_visit[ip] - if hit['robot']: continue - print "%s =>" % (ip) - for k in hit.keys(): - if k != 'pages': - print "\t%s : %s" % (k, current_visit[ip][k]) + filename = args.file or conf.analyzed_filename + if not os.path.exists(filename): + print 'No such file \'%s\'' % (filename) + sys.exit(-1) + with open(filename) as f: + iwla.start(f) diff --git a/iwla_convert.pl b/iwla_convert.pl deleted file mode 100755 index a47140a..0000000 --- a/iwla_convert.pl +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/perl - -my $awstats_lib_root = '/usr/share/awstats/lib/'; -my @awstats_libs = ('browsers.pm', 'browsers_phone.pm', 'mime.pm', 'referer_spam.pm', 'search_engines.pm', 'operating_systems.pm', 'robots.pm', 'worms.pm'); - -foreach $lib (@awstats_libs) {require $awstats_lib_root . $lib;} - -open($FIC,">", "robots.py") or die $!; - -print $FIC "awstats_robots = ["; -$first = 0; -foreach $r (@RobotsSearchIDOrder_list1) -{ - $r =~ s/\'/\\\'/g; - if ($first != 0) - { - print $FIC ", "; - } - else - { - $first = 1; - } - print $FIC "'.*$r.*'"; -} -foreach $r (@RobotsSearchIDOrder_list2) -{ - $r =~ s/\'/\\\'/g; - print $FIC ", '.*$r.*'"; -} -print $FIC "]\n\n"; - -close($FIC); - - diff --git a/iwla_get.sh b/iwla_get.sh new file mode 100755 index 0000000..eef3164 --- /dev/null +++ b/iwla_get.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +rm -f mega_log +for i in `seq 53 -1 2` ; do + [ ! -f "cybelle/soutade.fr_access.log.$i.gz" ] && continue + zcat "cybelle/soutade.fr_access.log.$i.gz" >> mega_log + echo "cybelle/soutade.fr_access.log.$i.gz" +done + +#cat "cybelle/soutade.fr_access.log.2" >> mega_log +echo "cybelle/soutade.fr_access.log.1" +cat "cybelle/soutade.fr_access.log.1" >> mega_log +# cat "cybelle/soutade.fr_access.log" >> mega_log +cat mega_log | ./iwla.py -i -c +# cat "cybelle/soutade.fr_access.log.1" | ./iwla.py -i +# cat "cybelle/soutade.fr_access.log" | ./iwla.py -i + +# TODO : reverse analysis +# -f option +# other when pages truncated diff --git a/locales/fr_FR/LC_MESSAGES/iwla.mo b/locales/fr_FR/LC_MESSAGES/iwla.mo new file mode 100644 index 0000000000000000000000000000000000000000..360249b9be26cf63291f68baccb3bc9bf31d6867 GIT binary patch literal 2934 zcmZ{kO^g&p6vqn%#SxKD6%{EJ5X4?)_-2+5cXxIL++~;9fhaN2-kI9jhMw-Gx_Wje z#t;uA9yAdX4n_@LNZf<*LOei1Ool|G2M-)HhL~_sPF_s(Ac_9}-L*S|(MrGm)vKz0 z^O067U1?VelfD1HS<8 z1+Rd3#5Jp52k(Ra4R}BJJxDu0*zsH7Qs}oqe*dTCUm*AW8{~J3VTAfJko&IzSAiQr ze%EW~4_f^Y$WVqYkJ<4PAnl#B`h=aIv^)(mo(QC$Z-Nhk=Rodr9)wHcg4I8=`bCib zT(aX=K>B;l>R*H0_d5`exMBGdNPD-e{wv6H{|)4RcR>2VkLgzqUDVT>k>d zbw!ZpQv#WvV^()T?h}BtYe4!p17ZvDHrQBz{DO}|{{xe>yBtQBf$PAPU>sbhM`0vJhy2%c11|NfLh3v6oJTErp`5DLtDqW3rz_uOI1Hn;=1CTs~xp)G? zvwR-HwjNS|?1u2nSs&{lY3uWSSqi5EKXhxcpmxYJS!c|xtE^X6lS(U{DW_FSMpN32 z?PSx7(=Q?|`XcT5qA#galGup8rqZw?`rV*5?bXbb=x@oI+Y$p|5U3e14CJH^8={1v zlB!ZvV?t?kjO+Qa7z~VdgQ^mPGe+sa_2u#M@Lh`Bq{E5OY!*Xmf}#^ww*-Qq#Ntp0 zH;%XgC7n5v_yW?xD^TL)`C!Db8ygub6=c06s<}pq5m!^HQ+T(;NEjf7qoI*aPfe?u z>;!f+Y+|CBxj$Mp0unNmQSH^eK#ZCxo?v#U<0>_oK@J93pv1U}C?+#8Zd~KV#;eAn z)0LB<7UM~y!5AxH)Rj7FnQ`{!Ge)I5W7N}(g>a@48rK)c%ZJ4YCXqvF2X5-{l&Tu% zaLqXZw~?r#^rn3`H#S;v2DE~2Vc?W-LPfbPU)bRkwmF5pvaq|jWBZnY!3x$nWyOvD ze_6he&*ymRP6auReHRWC<#?DFx7MDO`{J~xUaU886?&>+;{a9%^#m8nsVKK$J(?RU z;wrs9RL+eY9vSR7UFgZ@aM_FsuuUt1yGG5Jt~L9eV%xjI&6|MAL@v!}C;?%>8d zgF!W{c|pA>_e^*u_mT>5osFtF{jH*mT6JY;tS4&8LeI|JD~?^jFvdbv^9;s!^%U}$ z%5(?O>8cvYwk^tRU*sW)rLSUX+OvLpmR{9W11>W~c4~^Z8JfW|E{)Ra>>3EudxoOy z8nbmOtFYQVp56e~Zxcn^Op7*bUq!v9?~$;jP@ZYkDr^+TE)Eb^SIblIzpHp_DoVUq z9N}mQj;Al&U#-~dlyG|%o1tozneHokE5=Pl+RIW$y zeTC9aP+Mc^?@#FbTDSyfTs5ZE#*(Xytbo*(O~Z5Ws<=rajE?^a~QlPtGq o, YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: iwla\n" +"POT-Creation-Date: 2014-12-19 17:43+CET\n" +"PO-Revision-Date: 2014-12-19 17:43+0100\n" +"Last-Translator: Soutadé \n" +"Language-Team: iwla\n" +"Language: fr_FR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: pygettext.py 1.5\n" +"X-Generator: Poedit 1.6.10\n" +"X-Poedit-SourceCharset: UTF-8\n" + +#: display.py:32 +msgid "April" +msgstr "Avril" + +#: display.py:32 +msgid "February" +msgstr "Février" + +#: display.py:32 +msgid "January" +msgstr "Janvier" + +#: display.py:32 +msgid "July" +msgstr "Juillet" + +#: display.py:32 +msgid "March" +msgstr "Mars" + +#: display.py:32 iwla.py:428 +msgid "June" +msgstr "Juin" + +#: display.py:32 iwla.py:428 +msgid "May" +msgstr "Mai" + +#: display.py:33 +msgid "August" +msgstr "Août" + +#: display.py:33 +msgid "December" +msgstr "Décembre" + +#: display.py:33 +msgid "November" +msgstr "Novembre" + +#: display.py:33 +msgid "October" +msgstr "Octobre" + +#: display.py:33 +msgid "September" +msgstr "Septembre" + +#: iwla.py:371 +msgid "Statistics" +msgstr "Statistiques" + +#: iwla.py:377 +msgid "By day" +msgstr "Par jour" + +#: iwla.py:377 +msgid "Day" +msgstr "Jour" + +#: iwla.py:377 iwla.py:430 +msgid "Not viewed Bandwidth" +msgstr "Traffic non vu" + +#: iwla.py:377 iwla.py:430 +msgid "Visits" +msgstr "Visites" + +#: iwla.py:377 iwla.py:430 plugins/display/all_visits.py:70 +#: plugins/display/referers.py:95 plugins/display/referers.py:153 +#: plugins/display/top_downloads.py:97 plugins/display/top_visitors.py:72 +msgid "Hits" +msgstr "Hits" + +#: iwla.py:377 iwla.py:430 plugins/display/all_visits.py:70 +#: plugins/display/referers.py:95 plugins/display/referers.py:153 +#: plugins/display/top_visitors.py:72 +msgid "Pages" +msgstr "Pages" + +#: iwla.py:377 iwla.py:430 plugins/display/all_visits.py:70 +#: plugins/display/top_visitors.py:72 +msgid "Bandwidth" +msgstr "Bande passante" + +#: iwla.py:414 +msgid "Average" +msgstr "Moyenne" + +#: iwla.py:419 iwla.py:457 +msgid "Total" +msgstr "Total" + +#: iwla.py:428 +msgid "Apr" +msgstr "Avr" + +#: iwla.py:428 +msgid "Aug" +msgstr "Août" + +#: iwla.py:428 +msgid "Dec" +msgstr "Déc" + +#: iwla.py:428 +msgid "Feb" +msgstr "Fév" + +#: iwla.py:428 +msgid "Jan" +msgstr "Jan" + +#: iwla.py:428 +msgid "Jul" +msgstr "Jui" + +#: iwla.py:428 +msgid "Mar" +msgstr "Mars" + +#: iwla.py:428 +msgid "Nov" +msgstr "Nov" + +#: iwla.py:428 +msgid "Oct" +msgstr "Oct" + +#: iwla.py:428 +msgid "Sep" +msgstr "Sep" + +#: iwla.py:429 +msgid "Summary" +msgstr "Résumé" + +#: iwla.py:430 +msgid "Month" +msgstr "Mois" + +#: iwla.py:430 +msgid "Visitors" +msgstr "Visiteurs" + +#: iwla.py:430 iwla.py:440 +msgid "Details" +msgstr "Détails" + +#: iwla.py:465 +msgid "Statistics for" +msgstr "Statistiques pour" + +#: iwla.py:472 +msgid "Last update" +msgstr "Dernière mise à jour" + +#: plugins/display/all_visits.py:70 plugins/display/top_visitors.py:72 +msgid "Host" +msgstr "Hôte" + +#: plugins/display/all_visits.py:70 plugins/display/top_visitors.py:72 +msgid "Last seen" +msgstr "Dernière visite" + +#: plugins/display/all_visits.py:92 +msgid "All visits" +msgstr "Toutes les visites" + +#: plugins/display/all_visits.py:93 plugins/display/top_visitors.py:72 +msgid "Top visitors" +msgstr "Top visiteurs" + +#: plugins/display/referers.py:95 +msgid "Connexion from" +msgstr "Connexion depuis" + +#: plugins/display/referers.py:95 plugins/display/referers.py:153 +msgid "Origin" +msgstr "Origine" + +#: plugins/display/referers.py:99 plugins/display/referers.py:156 +msgid "Search Engine" +msgstr "Moteur de recherche" + +#: plugins/display/referers.py:110 plugins/display/referers.py:125 +#: plugins/display/referers.py:140 plugins/display/referers.py:163 +#: plugins/display/referers.py:174 plugins/display/referers.py:185 +#: plugins/display/referers.py:222 plugins/display/top_downloads.py:83 +#: plugins/display/top_downloads.py:103 plugins/display/top_hits.py:82 +#: plugins/display/top_hits.py:103 plugins/display/top_pages.py:82 +#: plugins/display/top_pages.py:102 plugins/display/top_visitors.py:92 +msgid "Others" +msgstr "Autres" + +#: plugins/display/referers.py:114 plugins/display/referers.py:167 +msgid "External URL" +msgstr "URL externe" + +#: plugins/display/referers.py:129 plugins/display/referers.py:178 +msgid "External URL (robot)" +msgstr "URL externe (robot)" + +#: plugins/display/referers.py:147 +msgid "Top Referers" +msgstr "Top Origines" + +#: plugins/display/referers.py:149 +msgid "All Referers" +msgstr "Toutes les origines" + +#: plugins/display/referers.py:200 plugins/display/referers.py:210 +msgid "Top key phrases" +msgstr "Top phrases clé" + +#: plugins/display/referers.py:200 plugins/display/referers.py:216 +msgid "Key phrase" +msgstr "Phrase clé" + +#: plugins/display/referers.py:200 plugins/display/referers.py:216 +msgid "Search" +msgstr "Recherche" + +#: plugins/display/referers.py:212 +msgid "All key phrases" +msgstr "Toutes les phrases clé" + +#: plugins/display/top_downloads.py:71 +msgid "Hit" +msgstr "Hit" + +#: plugins/display/top_downloads.py:71 plugins/display/top_downloads.py:91 +msgid "All Downloads" +msgstr "Tous les téléchargements" + +#: plugins/display/top_downloads.py:71 plugins/display/top_downloads.py:97 +#: plugins/display/top_hits.py:71 plugins/display/top_hits.py:97 +#: plugins/display/top_pages.py:71 plugins/display/top_pages.py:96 +msgid "URI" +msgstr "URI" + +#: plugins/display/top_downloads.py:89 +msgid "Top Downloads" +msgstr "Top Téléchargements" + +#: plugins/display/top_hits.py:71 plugins/display/top_hits.py:91 +msgid "All Hits" +msgstr "Tous les hits" + +#: plugins/display/top_hits.py:71 plugins/display/top_hits.py:97 +#: plugins/display/top_pages.py:71 plugins/display/top_pages.py:96 +msgid "Entrance" +msgstr "Entrées" + +#: plugins/display/top_pages.py:71 plugins/display/top_pages.py:90 +msgid "All Pages" +msgstr "Toutes les pages" + +#: plugins/display/top_pages.py:88 +msgid "Top Pages" +msgstr "Top Pages" + +#~ msgid "Key Phrases" +#~ msgstr "Phrases clé" diff --git a/plugins/__init__.py b/plugins/__init__.py new file mode 100644 index 0000000..bd0daba --- /dev/null +++ b/plugins/__init__.py @@ -0,0 +1,2 @@ + +__all__ = ['pre_analysis', 'post_analysis', 'display'] diff --git a/plugins/display/__init__.py b/plugins/display/__init__.py new file mode 100644 index 0000000..792d600 --- /dev/null +++ b/plugins/display/__init__.py @@ -0,0 +1 @@ +# diff --git a/plugins/display/all_visits.py b/plugins/display/all_visits.py new file mode 100644 index 0000000..4dbc92c --- /dev/null +++ b/plugins/display/all_visits.py @@ -0,0 +1,99 @@ +# -*- coding: utf-8 -*- +# +# Copyright Grégory Soutadé 2015 + +# This file is part of iwla + +# iwla is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# iwla is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with iwla. If not, see . +# + +import time + +from iwla import IWLA +from iplugin import IPlugin +from display import * + +""" +Display hook + +Create All visits page + +Plugin requirements : + None + +Conf values needed : + display_visitor_ip* + +Output files : + OUTPUT_ROOT/year/month/all_visits.html + OUTPUT_ROOT/year/month/index.html + +Statistics creation : + None + +Statistics update : + None + +Statistics deletion : + None +""" + +class IWLADisplayAllVisits(IPlugin): + def __init__(self, iwla): + super(IWLADisplayAllVisits, self).__init__(iwla) + self.API_VERSION = 1 + + def hook(self): + display = self.iwla.getDisplay() + hits = self.iwla.getValidVisitors() + display_visitor_ip = self.iwla.getConfValue('display_visitor_ip', False) + + last_access = sorted(hits.values(), key=lambda t: t['last_access'], reverse=True) + + title = createCurTitle(self.iwla, u'All visits') + + filename = 'all_visits.html' + path = self.iwla.getCurDisplayPath(filename) + + page = display.createPage(title, path, self.iwla.getConfValue('css_path', [])) + table = display.createBlock(DisplayHTMLBlockTable, self.iwla._(u'Last seen'), [self.iwla._(u'Host'), self.iwla._(u'Pages'), self.iwla._(u'Hits'), self.iwla._(u'Bandwidth'), self.iwla._(u'Last seen')]) + table.setColsCSSClass(['', 'iwla_page', 'iwla_hit', 'iwla_bandwidth', '']) + + for super_hit in last_access: + address = super_hit['remote_addr'] + if display_visitor_ip and\ + super_hit.get('dns_name_replaced', False): + address = '%s [%s]' % (address, super_hit['remote_ip']) + + row = [ + address, + super_hit['viewed_pages'], + super_hit['viewed_hits'], + bytesToStr(super_hit['bandwidth']), + time.asctime(super_hit['last_access']) + ] + table.appendRow(row) + page.appendBlock(table) + + display.addPage(page) + + index = self.iwla.getDisplayIndex() + link = '%s' % (filename, self.iwla._(u'All visits')) + block = index.getBlock(self.iwla._(u'Top visitors')) + if block: + block.setTitle('%s - %s' % (block.getTitle(), link)) + else: + block = display.createBlock(DisplayHTMLRawBlock) + block.setRawHTML(link) + index.appendBlock(block) diff --git a/plugins/display/istats_diff.py b/plugins/display/istats_diff.py new file mode 100644 index 0000000..897d2c4 --- /dev/null +++ b/plugins/display/istats_diff.py @@ -0,0 +1,98 @@ +# -*- coding: utf-8 -*- +# +# Copyright Grégory Soutadé 2015 + +# This file is part of iwla + +# iwla is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# iwla is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with iwla. If not, see . +# + +from iwla import IWLA +from iplugin import IPlugin +from display import * +import logging + +""" +Display hook itnerface + +Enlight new and updated statistics + +Plugin requirements : + None + +Conf values needed : + None + +Output files : + None + +Statistics creation : + None + +Statistics update : + None + +Statistics deletion : + None +""" + +class IWLADisplayStatsDiff(IPlugin): + def __init__(self, iwla): + super(IWLADisplayStatsDiff, self).__init__(iwla) + self.API_VERSION = 1 + self.month_stats_key = None + # Set >= if month_stats[self.month_stats_key] is a list or a tuple + self.stats_index = -1 + self.filename = None + self.block_name = None + self.logger = logging.getLogger(__name__) + + def load(self): + if not self.month_stats_key or not self.filename or\ + not self.block_name: + self.logger('Bad parametrization') + return False + month_stats = self.iwla.getMonthStats() + self.cur_stats = {k:v for (k,v) in month_stats.get(self.month_stats_key, {}).items()} + return True + + def hook(self): + display = self.iwla.getDisplay() + month_stats = self.iwla.getMonthStats() + + path = self.iwla.getCurDisplayPath(self.filename) + page = display.getPage(path) + if not page: return + title = self.iwla._(self.block_name) + block = page.getBlock(title) + if not block: + self.logger.error('Block %s not found' % (title)) + return + + stats_diff = {} + for (k, v) in month_stats[self.month_stats_key].items(): + new_value = self.cur_stats.get(k, 0) + if new_value: + if self.stats_index != -1: + if new_value[self.stats_index] != v[self.stats_index]: + stats_diff[k] = 'iwla_update' + else: + if new_value != v: + stats_diff[k] = 'iwla_update' + else: + stats_diff[k] = 'iwla_new' + + for (idx, row) in enumerate(block.rows): + if row[0] in stats_diff.keys(): + block.setCellCSSClass(idx, 0, stats_diff[row[0]]) diff --git a/plugins/display/referers.py b/plugins/display/referers.py new file mode 100644 index 0000000..bdd04a5 --- /dev/null +++ b/plugins/display/referers.py @@ -0,0 +1,225 @@ +# -*- coding: utf-8 -*- +# +# Copyright Grégory Soutadé 2015 + +# This file is part of iwla + +# iwla is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# iwla is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with iwla. If not, see . +# + +from iwla import IWLA +from iplugin import IPlugin +from display import * + +""" +Display hook + +Create Referers page + +Plugin requirements : + post_analysis/referers + +Conf values needed : + max_referers_displayed* + create_all_referers_page* + max_key_phrases_displayed* + create_all_key_phrases_page* + +Output files : + OUTPUT_ROOT/year/month/referers.html + OUTPUT_ROOT/year/month/key_phrases.html + OUTPUT_ROOT/year/month/index.html + +Statistics creation : + None + +Statistics update : + None + +Statistics deletion : + None +""" + +class IWLADisplayReferers(IPlugin): + def __init__(self, iwla): + super(IWLADisplayReferers, self).__init__(iwla) + self.API_VERSION = 1 + self.requires = ['IWLAPostAnalysisReferers'] + self.max_referers = self.iwla.getConfValue('max_referers_displayed', 0) + self.create_all_referers = self.iwla.getConfValue('create_all_referers_page', True) + self.max_key_phrases = self.iwla.getConfValue('max_key_phrases_displayed', 0) + self.create_all_key_phrases = self.iwla.getConfValue('create_all_key_phrases_page', True) + + def hook(self): + display = self.iwla.getDisplay() + month_stats = self.iwla.getMonthStats() + referers = month_stats.get('referers', {}) + robots_referers = month_stats.get('robots_referers', {}) + search_engine_referers = month_stats.get('search_engine_referers', {}) + key_phrases = month_stats.get('key_phrases', {}) + + top_referers = [(k, referers[k]['pages']) for k in referers.keys()] + top_referers = sorted(top_referers, key=lambda t: t[1], reverse=True) + + top_robots_referers = [(k, robots_referers[k]['pages']) for k in robots_referers.keys()] + top_robots_referers = sorted(top_robots_referers, key=lambda t: t[1], reverse=True) + + top_search_engine_referers = [(k, search_engine_referers[k]['pages']) for k in search_engine_referers.keys()] + top_search_engine_referers = sorted(top_search_engine_referers, key=lambda t: t[1], reverse=True) + + top_key_phrases = key_phrases.items() + top_key_phrases = sorted(top_key_phrases, key=lambda t: t[1], reverse=True) + + cur_time = self.iwla.getCurTime() + index = self.iwla.getDisplayIndex() + + # All referers in a file + if self.create_all_referers: + title = createCurTitle(self.iwla, u'Connexion from') + + filename = 'referers.html' + path = self.iwla.getCurDisplayPath(filename) + + page = display.createPage(title, path, self.iwla.getConfValue('css_path', [])) + table = display.createBlock(DisplayHTMLBlockTable, self.iwla._(u'Connexion from'), [self.iwla._(u'Origin'), self.iwla._(u'Pages'), self.iwla._(u'Hits')]) + table.setColsCSSClass(['', 'iwla_page', 'iwla_hit']) + + total_search = [0]*3 + table.appendRow(['%s' % (self.iwla._(u'Search Engine')), '', '']) + new_list = self.max_referers and top_search_engine_referers[:self.max_referers] or top_search_engine_referers + for r,_ in new_list: + row = [r, search_engine_referers[r]['pages'], search_engine_referers[r]['hits']] + total_search[1] += search_engine_referers[r]['pages'] + total_search[2] += search_engine_referers[r]['hits'] + table.appendRow(row) + if self.max_referers: + others = 0 + for (uri, entrance) in top_referers[self.max_referers:]: + others += entrance + table.appendRow([self.iwla._(u'Others'), others]) + table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others') + + total_external = [0]*3 + table.appendRow(['%s' % (self.iwla._(u'External URL')), '', '']) + new_list = self.max_referers and top_referers[:self.max_referers] or top_referers + for r,_ in new_list: + row = [generateHTMLLink(r), referers[r]['pages'], referers[r]['hits']] + total_external[1] += referers[r]['pages'] + total_external[2] += referers[r]['hits'] + table.appendRow(row) + if self.max_referers: + others = 0 + for (uri, entrance) in top_referers[self.max_referers:]: + others += entrance + table.appendRow([self.iwla._(u'Others'), others]) + table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others') + + total_robot = [0]*3 + table.appendRow(['%s' % (self.iwla._(u'External URL (robot)')), '', '']) + new_list = self.max_referers and top_robots_referers[:self.max_referers] or top_robots_referers + for r,_ in new_list: + row = [generateHTMLLink(r), robots_referers[r]['pages'], robots_referers[r]['hits']] + total_robot[1] += robots_referers[r]['pages'] + total_robot[2] += robots_referers[r]['hits'] + table.appendRow(row) + if self.max_referers: + others = 0 + for (uri, entrance) in top_referers[self.max_referers:]: + others += entrance + table.appendRow([self.iwla._(u'Others'), others]) + table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others') + + page.appendBlock(table) + + display.addPage(page) + + title = self.iwla._(u'Top Referers') + if self.create_all_referers: + link = '%s' % (filename, self.iwla._(u'All Referers')) + title = '%s - %s' % (title, link) + + # Top referers in index + table = display.createBlock(DisplayHTMLBlockTable, title, [self.iwla._(u'Origin'), self.iwla._(u'Pages'), self.iwla._(u'Hits')]) + table.setColsCSSClass(['', 'iwla_page', 'iwla_hit']) + + table.appendRow(['%s' % (self.iwla._(u'Search Engine')), '', '']) + for r,_ in top_search_engine_referers[:10]: + row = [r, search_engine_referers[r]['pages'], search_engine_referers[r]['hits']] + total_search[1] -= search_engine_referers[r]['pages'] + total_search[2] -= search_engine_referers[r]['hits'] + table.appendRow(row) + if total_search[1] or total_search[2]: + total_search[0] = self.iwla._(u'Others') + table.appendRow(total_search) + table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others') + + table.appendRow(['%s' % (self.iwla._(u'External URL')), '', '']) + for r,_ in top_referers[:10]: + row = [generateHTMLLink(r), referers[r]['pages'], referers[r]['hits']] + total_external[1] -= referers[r]['pages'] + total_external[2] -= referers[r]['hits'] + table.appendRow(row) + if total_external[1] or total_external[2]: + total_external[0] = self.iwla._(u'Others') + table.appendRow(total_external) + table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others') + + table.appendRow(['%s' % (self.iwla._(u'External URL (robot)')), '', '']) + for r,_ in top_robots_referers[:10]: + row = [generateHTMLLink(r), robots_referers[r]['pages'], robots_referers[r]['hits']] + total_robot[1] -= robots_referers[r]['pages'] + total_robot[2] -= robots_referers[r]['hits'] + table.appendRow(row) + if total_robot[1] or total_robot[2]: + total_robot[0] = self.iwla._(u'Others') + table.appendRow(total_robot) + table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others') + + index.appendBlock(table) + + # All key phrases in a file + if self.create_all_key_phrases: + title = createCurTitle(self.iwla, u'Key Phrases') + + filename = 'key_phrases.html' + path = self.iwla.getCurDisplayPath(filename) + + total_search = [0]*2 + page = display.createPage(title, path, self.iwla.getConfValue('css_path', [])) + table = display.createBlock(DisplayHTMLBlockTable, self.iwla._(u'Top key phrases'), [self.iwla._(u'Key phrase'), self.iwla._(u'Search')]) + table.setColsCSSClass(['', 'iwla_search']) + new_list = self.max_key_phrases and top_key_phrases[:self.max_key_phrases] or top_key_phrases + for phrase in new_list: + table.appendRow([phrase[0], phrase[1]]) + total_search[1] += phrase[1] + page.appendBlock(table) + + display.addPage(page) + + title = self.iwla._(u'Top key phrases') + if self.create_all_key_phrases: + link = '%s' % (filename, self.iwla._(u'All key phrases')) + title = '%s - %s' % (title, link) + + # Top key phrases in index + table = display.createBlock(DisplayHTMLBlockTable, title, [self.iwla._(u'Key phrase'), self.iwla._(u'Search')]) + table.setColsCSSClass(['', 'iwla_search']) + for phrase in top_key_phrases[:10]: + table.appendRow([phrase[0], phrase[1]]) + total_search[1] -= phrase[1] + if total_search[1]: + total_search[0] = self.iwla._(u'Others') + table.appendRow(total_search) + table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others') + index.appendBlock(table) diff --git a/plugins/display/referers_diff.py b/plugins/display/referers_diff.py new file mode 100644 index 0000000..8e63ecb --- /dev/null +++ b/plugins/display/referers_diff.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +# +# Copyright Grégory Soutadé 2015 + +# This file is part of iwla + +# iwla is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# iwla is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with iwla. If not, see . +# + +from iwla import IWLA +from istats_diff import IWLADisplayStatsDiff +from display import * + +""" +Display hook + +Enlight new and updated key phrases in in all_key_phrases.html + +Plugin requirements : + display/referers + +Conf values needed : + None + +Output files : + None + +Statistics creation : + None + +Statistics update : + None + +Statistics deletion : + None +""" + +class IWLADisplayReferersDiff(IWLADisplayStatsDiff): + def __init__(self, iwla): + super(IWLADisplayReferersDiff, self).__init__(iwla) + self.API_VERSION = 1 + self.requires = ['IWLADisplayReferers'] + self.month_stats_key = 'key_phrases' + self.filename = 'key_phrases.html' + self.block_name = u'Key phrases' + + def load(self): + if not self.iwla.getConfValue('create_all_key_phrases_page', True): + return False + return super(IWLADisplayReferersDiff, self).load() diff --git a/plugins/display/top_downloads.py b/plugins/display/top_downloads.py new file mode 100644 index 0000000..f5d4a60 --- /dev/null +++ b/plugins/display/top_downloads.py @@ -0,0 +1,106 @@ +# -*- coding: utf-8 -*- +# +# Copyright Grégory Soutadé 2015 + +# This file is part of iwla + +# iwla is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# iwla is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with iwla. If not, see . +# + +from iwla import IWLA +from iplugin import IPlugin +from display import * + +""" +Display hook + +Create TOP downloads page + +Plugin requirements : + post_analysis/top_downloads + +Conf values needed : + max_downloads_displayed* + create_all_downloads_page* + +Output files : + OUTPUT_ROOT/year/month/top_downloads.html + OUTPUT_ROOT/year/month/index.html + +Statistics creation : + None + +Statistics update : + None + +Statistics deletion : + None +""" + +class IWLADisplayTopDownloads(IPlugin): + def __init__(self, iwla): + super(IWLADisplayTopDownloads, self).__init__(iwla) + self.API_VERSION = 1 + self.requires = ['IWLAPostAnalysisTopDownloads'] + self.max_downloads = self.iwla.getConfValue('max_downloads_displayed', 0) + self.create_all_downloads = self.iwla.getConfValue('create_all_downloads_page', True) + + def hook(self): + display = self.iwla.getDisplay() + top_downloads = self.iwla.getMonthStats()['top_downloads'] + top_downloads = sorted(top_downloads.items(), key=lambda t: t[1], reverse=True) + + # All in a file + if self.create_all_downloads: + filename = 'top_downloads.html' + path = self.iwla.getCurDisplayPath(filename) + title = createCurTitle(self.iwla, u'All Downloads') + + page = display.createPage(title, path, self.iwla.getConfValue('css_path', [])) + table = display.createBlock(DisplayHTMLBlockTable, self.iwla._(u'All Downloads'), [self.iwla._(u'URI'), self.iwla._(u'Hit')]) + table.setColsCSSClass(['', 'iwla_hit']) + + total_entrance = [0]*2 + new_list = self.max_downloads and top_downloads[:self.max_downloads] or top_downloads + for (uri, entrance) in new_list: + table.appendRow([generateHTMLLink(uri), entrance]) + total_entrance[1] += entrance + if self.max_downloads: + others = 0 + for (uri, entrance) in top_downloads[self.max_downloads:]: + others += entrance + table.appendRow([self.iwla._(u'Others'), others]) + table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others') + page.appendBlock(table) + + display.addPage(page) + + title = self.iwla._(u'Top Downloads') + if self.create_all_downloads: + link = '%s' % (filename, self.iwla._(u'All Downloads')) + title = '%s - %s' % (title, link) + + # Top in index + index = self.iwla.getDisplayIndex() + + table = display.createBlock(DisplayHTMLBlockTable, title, [self.iwla._(u'URI'), self.iwla._(u'Hits')]) + table.setColsCSSClass(['', 'iwla_hit']) + for (uri, entrance) in top_downloads[:10]: + table.appendRow([generateHTMLLink(uri), entrance]) + total_entrance[1] -= entrance + if total_entrance[1]: + total_entrance[0] = self.iwla._(u'Others') + table.appendRow(total_entrance) + table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others') + index.appendBlock(table) diff --git a/plugins/display/top_hits.py b/plugins/display/top_hits.py new file mode 100644 index 0000000..412b3fe --- /dev/null +++ b/plugins/display/top_hits.py @@ -0,0 +1,106 @@ +# -*- coding: utf-8 -*- +# +# Copyright Grégory Soutadé 2015 + +# This file is part of iwla + +# iwla is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# iwla is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with iwla. If not, see . +# + +from iwla import IWLA +from iplugin import IPlugin +from display import * + +""" +Display hook + +Create TOP hits page + +Plugin requirements : + post_analysis/top_hits + +Conf values needed : + max_hits_displayed* + create_all_hits_page* + +Output files : + OUTPUT_ROOT/year/month/top_hits.html + OUTPUT_ROOT/year/month/index.html + +Statistics creation : + None + +Statistics update : + None + +Statistics deletion : + None +""" + +class IWLADisplayTopHits(IPlugin): + def __init__(self, iwla): + super(IWLADisplayTopHits, self).__init__(iwla) + self.API_VERSION = 1 + self.requires = ['IWLAPostAnalysisTopHits'] + self.max_hits = self.iwla.getConfValue('max_hits_displayed', 0) + self.create_all_hits = self.iwla.getConfValue('create_all_hits_page', True) + + def hook(self): + display = self.iwla.getDisplay() + top_hits = self.iwla.getMonthStats()['top_hits'] + top_hits = sorted(top_hits.items(), key=lambda t: t[1], reverse=True) + + # All in a file + if self.create_all_hits: + title = createCurTitle(self.iwla, u'All Hits') + filename = 'top_hits.html' + path = self.iwla.getCurDisplayPath(filename) + + page = display.createPage(title, path, self.iwla.getConfValue('css_path', [])) + table = display.createBlock(DisplayHTMLBlockTable, self.iwla._(u'All Hits'), [self.iwla._(u'URI'), self.iwla._(u'Entrance')]) + table.setColsCSSClass(['', 'iwla_hit']) + total_hits = [0]*2 + new_list = self.max_hits and top_hits[:self.max_hits] or top_hits + for (uri, entrance) in new_list: + table.appendRow([generateHTMLLink(uri), entrance]) + total_hits[1] += entrance + if self.max_hits: + others = 0 + for (uri, entrance) in top_hits[self.max_hits:]: + others += entrance + table.appendRow([self.iwla._(u'Others'), others]) + table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others') + + page.appendBlock(table) + + display.addPage(page) + + title = 'Top Hits' + if self.create_all_hits: + link = '%s' % (filename, self.iwla._(u'All Hits')) + title = '%s - %s' % (title, link) + + # Top in index + index = self.iwla.getDisplayIndex() + + table = display.createBlock(DisplayHTMLBlockTable, title, [self.iwla._(u'URI'), self.iwla._(u'Entrance')]) + table.setColsCSSClass(['', 'iwla_hit']) + for (uri, entrance) in top_hits[:10]: + table.appendRow([generateHTMLLink(uri), entrance]) + total_hits[1] -= entrance + if total_hits[1]: + total_hits[0] = self.iwla._(u'Others') + table.appendRow(total_hits) + table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others') + index.appendBlock(table) diff --git a/plugins/display/top_pages.py b/plugins/display/top_pages.py new file mode 100644 index 0000000..b44bf81 --- /dev/null +++ b/plugins/display/top_pages.py @@ -0,0 +1,105 @@ +# -*- coding: utf-8 -*- +# +# Copyright Grégory Soutadé 2015 + +# This file is part of iwla + +# iwla is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# iwla is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with iwla. If not, see . +# + +from iwla import IWLA +from iplugin import IPlugin +from display import * + +""" +Display hook + +Create TOP pages page + +Plugin requirements : + post_analysis/top_pages + +Conf values needed : + max_pages_displayed* + create_all_pages_page* + +Output files : + OUTPUT_ROOT/year/month/top_pages.html + OUTPUT_ROOT/year/month/index.html + +Statistics creation : + None + +Statistics update : + None + +Statistics deletion : + None +""" + +class IWLADisplayTopPages(IPlugin): + def __init__(self, iwla): + super(IWLADisplayTopPages, self).__init__(iwla) + self.API_VERSION = 1 + self.requires = ['IWLAPostAnalysisTopPages'] + self.max_pages = self.iwla.getConfValue('max_pages_displayed', 0) + self.create_all_pages = self.iwla.getConfValue('create_all_pages_page', True) + + def hook(self): + display = self.iwla.getDisplay() + top_pages = self.iwla.getMonthStats()['top_pages'] + top_pages = sorted(top_pages.items(), key=lambda t: t[1], reverse=True) + + # All in a page + if self.create_all_pages: + title = createCurTitle(self.iwla, u'All Pages') + filename = 'top_pages.html' + path = self.iwla.getCurDisplayPath(filename) + + page = display.createPage(title, path, self.iwla.getConfValue('css_path', [])) + table = display.createBlock(DisplayHTMLBlockTable, self.iwla._(u'All Pages'), [self.iwla._(u'URI'), self.iwla._(u'Entrance')]) + table.setColsCSSClass(['', 'iwla_hit']) + total_hits = [0]*2 + new_list = self.max_pages and top_pages[:self.max_pages] or top_pages + for (uri, entrance) in new_list: + table.appendRow([generateHTMLLink(uri), entrance]) + total_hits[1] += entrance + if self.max_pages: + others = 0 + for (uri, entrance) in top_pages[self.max_pages:]: + others += entrance + table.appendRow([self.iwla._(u'Others'), others]) + table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others') + page.appendBlock(table) + + display.addPage(page) + + title = self.iwla._(u'Top Pages') + if self.create_all_pages: + link = '%s' % (filename, self.iwla._(u'All Pages')) + title = '%s - %s' % (title, link) + + # Top in index + index = self.iwla.getDisplayIndex() + + table = display.createBlock(DisplayHTMLBlockTable, title, [self.iwla._(u'URI'), self.iwla._(u'Entrance')]) + table.setColsCSSClass(['', 'iwla_hit']) + for (uri, entrance) in top_pages[:10]: + table.appendRow([generateHTMLLink(uri), entrance]) + total_hits[1] -= entrance + if total_hits[1]: + total_hits[0] = self.iwla._(u'Others') + table.appendRow(total_hits) + table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others') + index.appendBlock(table) diff --git a/plugins/display/top_visitors.py b/plugins/display/top_visitors.py new file mode 100644 index 0000000..b7d3b66 --- /dev/null +++ b/plugins/display/top_visitors.py @@ -0,0 +1,97 @@ +# -*- coding: utf-8 -*- +# +# Copyright Grégory Soutadé 2015 + +# This file is part of iwla + +# iwla is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# iwla is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with iwla. If not, see . +# + +import time + +from iwla import IWLA +from iplugin import IPlugin +from display import * + +""" +Display hook + +Create TOP visitors block + +Plugin requirements : + None + +Conf values needed : + display_visitor_ip* + +Output files : + OUTPUT_ROOT/year/month/index.html + +Statistics creation : + None + +Statistics update : + None + +Statistics deletion : + None +""" + +class IWLADisplayTopVisitors(IPlugin): + def __init__(self, iwla): + super(IWLADisplayTopVisitors, self).__init__(iwla) + self.API_VERSION = 1 + + def hook(self): + hits = self.iwla.getValidVisitors() + display = self.iwla.getDisplay() + display_visitor_ip = self.iwla.getConfValue('display_visitor_ip', False) + + total = [0]*5 + for super_hit in hits.values(): + total[1] += super_hit['viewed_pages'] + total[2] += super_hit['viewed_hits'] + total[3] += super_hit['bandwidth'] + + top_bandwidth = [(k,v['bandwidth']) for (k,v) in hits.items()] + top_bandwidth = sorted(top_bandwidth, key=lambda t: t[1], reverse=True) + top_visitors = [hits[h[0]] for h in top_bandwidth[:10]] + + index = self.iwla.getDisplayIndex() + table = display.createBlock(DisplayHTMLBlockTable, self.iwla._(u'Top visitors'), [self.iwla._(u'Host'), self.iwla._(u'Pages'), self.iwla._(u'Hits'), self.iwla._(u'Bandwidth'), self.iwla._(u'Last seen')]) + table.setColsCSSClass(['', 'iwla_page', 'iwla_hit', 'iwla_bandwidth', '']) + for super_hit in top_visitors: + address = super_hit['remote_addr'] + if display_visitor_ip and\ + super_hit.get('dns_name_replaced', False): + address = '%s [%s]' % (address, super_hit['remote_ip']) + + row = [ + address, + super_hit['viewed_pages'], + super_hit['viewed_hits'], + bytesToStr(super_hit['bandwidth']), + time.asctime(super_hit['last_access']) + ] + total[1] -= super_hit['viewed_pages'] + total[2] -= super_hit['viewed_hits'] + total[3] -= super_hit['bandwidth'] + table.appendRow(row) + if total[1] or total[2] or total[3]: + total[0] = self.iwla._(u'Others') + total[3] = bytesToStr(total[3]) + total[4] = '' + table.appendRow(total) + table.setCellCSSClass(table.getNbRows()-1, 0, 'iwla_others') + index.appendBlock(table) diff --git a/plugins/post_analysis/__init__.py b/plugins/post_analysis/__init__.py new file mode 100644 index 0000000..792d600 --- /dev/null +++ b/plugins/post_analysis/__init__.py @@ -0,0 +1 @@ +# diff --git a/plugins/post_analysis/referers.py b/plugins/post_analysis/referers.py new file mode 100644 index 0000000..64ec66f --- /dev/null +++ b/plugins/post_analysis/referers.py @@ -0,0 +1,173 @@ +# -*- coding: utf-8 -*- +# +# Copyright Grégory Soutadé 2015 + +# This file is part of iwla + +# iwla is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# iwla is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with iwla. If not, see . +# + +import re +import urllib + +from iwla import IWLA +from iplugin import IPlugin + +import awstats_data + +""" +Post analysis hook + +Extract referers and key phrases from requests + +Plugin requirements : + None + +Conf values needed : + domain_name + +Output files : + None + +Statistics creation : + None + +Statistics update : +month_stats : + referers => + pages + hits + robots_referers => + pages + hits + search_engine_referers => + pages + hits + key_phrases => + phrase + +Statistics deletion : + None +""" + +class IWLAPostAnalysisReferers(IPlugin): + def __init__(self, iwla): + super(IWLAPostAnalysisReferers, self).__init__(iwla) + self.API_VERSION = 1 + self.conf_requires = ['domain_name'] + + def _getSearchEngine(self, hashid): + for (k, e) in self.search_engines.items(): + for (h,h_re) in e['hashid']: + if hashid == h: + return k + return None + + def load(self): + domain_name = self.iwla.getConfValue('domain_name', '') + + if not domain_name: + print 'domain_name must not be empty !' + return False + + self.own_domain_re = re.compile(r'.*%s.*' % (domain_name)) + self.search_engines = {} + + for (hashid, name) in awstats_data.search_engines_hashid.items(): + hashid_re = re.compile(r'.*%s.*' % (hashid)) + if not name in self.search_engines.keys(): + self.search_engines[name] = { + 'hashid' : [(hashid, hashid_re)] + } + else: + self.search_engines[name]['hashid'].append((hashid, hashid_re)) + #print 'Hashid %s => %s' % (name, hashid) + + for (name, known_url) in awstats_data.search_engines_knwown_url.items(): + self.search_engines[name]['known_url'] = re.compile(known_url + '(?P.+)') + + for (engine, not_engine) in awstats_data.not_search_engines_keys.items(): + not_engine_re = re.compile(r'.*%s.*' % (not_engine)) + key = self._getSearchEngine(engine) + if key: + self.search_engines[key]['not_search_engine'] = not_engine_re + + return True + + def _extractKeyPhrase(self, key_phrase_re, parameters, key_phrases): + if not parameters or not key_phrase_re: return + + for p in parameters.split('&'): + groups = key_phrase_re.match(p) + if groups: + key_phrase = groups.groupdict()['key_phrase'] + key_phrase = urllib.unquote_plus(key_phrase).decode('utf8') + if not key_phrase in key_phrases.keys(): + key_phrases[key_phrase] = 1 + else: + key_phrases[key_phrase] += 1 + break + + def hook(self): + stats = self.iwla.getCurrentVisists() + month_stats = self.iwla.getMonthStats() + + referers = month_stats.get('referers', {}) + robots_referers = month_stats.get('robots_referers', {}) + search_engine_referers = month_stats.get('search_engine_referers', {}) + key_phrases = month_stats.get('key_phrases', {}) + + for (k, super_hit) in stats.items(): + for r in super_hit['requests'][::-1]: + if not self.iwla.isValidForCurrentAnalysis(r): break + if not r['http_referer']: continue + + uri = r['extract_referer']['extract_uri'] + if self.own_domain_re.match(uri): continue + + is_search_engine = False + for (name, engine) in self.search_engines.items(): + for (hashid, hashid_re) in engine['hashid']: + if not hashid_re.match(uri): continue + + not_engine = engine.get('not_search_engine', None) + # Try not engine + if not_engine and not_engine.match(uri): break + is_search_engine = True + uri = name + + parameters = r['extract_referer'].get('extract_parameters', None) + key_phrase_re = engine.get('known_url', None) + + self._extractKeyPhrase(key_phrase_re, parameters, key_phrases) + break + + if is_search_engine: + dictionary = search_engine_referers + elif super_hit['robot']: + dictionary = robots_referers + # print '%s => %s' % (uri, super_hit['remote_ip']) + else: + dictionary = referers + if r['is_page']: + key = 'pages' + else: + key = 'hits' + if not uri in dictionary: dictionary[uri] = {'pages':0, 'hits':0} + dictionary[uri][key] += 1 + + month_stats['referers'] = referers + month_stats['robots_referers'] = robots_referers + month_stats['search_engine_referers'] = search_engine_referers + month_stats['key_phrases'] = key_phrases diff --git a/plugins/post_analysis/reverse_dns.py b/plugins/post_analysis/reverse_dns.py new file mode 100644 index 0000000..c63965f --- /dev/null +++ b/plugins/post_analysis/reverse_dns.py @@ -0,0 +1,78 @@ +# -*- coding: utf-8 -*- +# +# Copyright Grégory Soutadé 2015 + +# This file is part of iwla + +# iwla is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# iwla is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with iwla. If not, see . +# + +import socket + +from iwla import IWLA +from iplugin import IPlugin + +""" +Post analysis hook + +Replace IP by reverse DNS names + +Plugin requirements : + None + +Conf values needed : + reverse_dns_timeout* + +Output files : + None + +Statistics creation : + None + +Statistics update : +valid_visitors: + remote_addr + dns_name_replaced + dns_analyzed + +Statistics deletion : + None +""" + +class IWLAPostAnalysisReverseDNS(IPlugin): + DEFAULT_DNS_TIMEOUT = 0.5 + + def __init__(self, iwla): + super(IWLAPostAnalysisReverseDNS, self).__init__(iwla) + self.API_VERSION = 1 + + def load(self): + timeout = self.iwla.getConfValue('reverse_dns_timeout', + IWLAPostAnalysisReverseDNS.DEFAULT_DNS_TIMEOUT) + socket.setdefaulttimeout(timeout) + return True + + def hook(self): + hits = self.iwla.getValidVisitors() + for (k, hit) in hits.items(): + if hit.get('dns_analysed', False): continue + try: + name, _, _ = socket.gethostbyaddr(k) + hit['remote_addr'] = name.lower() + hit['dns_name_replaced'] = True + except: + pass + finally: + hit['dns_analysed'] = True + diff --git a/plugins/post_analysis/top_downloads.py b/plugins/post_analysis/top_downloads.py new file mode 100644 index 0000000..7b28c33 --- /dev/null +++ b/plugins/post_analysis/top_downloads.py @@ -0,0 +1,94 @@ +# -*- coding: utf-8 -*- +# +# Copyright Grégory Soutadé 2015 + +# This file is part of iwla + +# iwla is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# iwla is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with iwla. If not, see . +# + +import re + +from iwla import IWLA +from iplugin import IPlugin + +""" +Post analysis hook + +Count TOP downloads + +Plugin requirements : + None + +Conf values needed : + None + +Output files : + None + +Statistics creation : + None + +Statistics update : +month_stats: + top_downloads => + uri + +Statistics deletion : + None +""" + +class IWLAPostAnalysisTopDownloads(IPlugin): + def __init__(self, iwla): + super(IWLAPostAnalysisTopDownloads, self).__init__(iwla) + self.API_VERSION = 1 + self.conf_requires = ['multimedia_files', 'viewed_http_codes'] + + def hook(self): + stats = self.iwla.getCurrentVisists() + month_stats = self.iwla.getMonthStats() + + multimedia_files = self.iwla.getConfValue('multimedia_files') + viewed_http_codes = self.iwla.getConfValue('viewed_http_codes') + + top_downloads = month_stats.get('top_downloads', {}) + + for (k, super_hit) in stats.items(): + if super_hit['robot']: continue + for r in super_hit['requests'][::-1]: + if not self.iwla.isValidForCurrentAnalysis(r): + break + if not self.iwla.hasBeenViewed(r) or\ + r['is_page']: + continue + + uri = r['extract_request']['extract_uri'].lower() + + isMultimedia = False + for ext in multimedia_files: + if uri.endswith(ext): + isMultimedia = True + break + + if isMultimedia: continue + + uri = "%s%s" % (r.get('server_name', ''), + r['extract_request']['extract_uri']) + + if not uri in top_downloads.keys(): + top_downloads[uri] = 1 + else: + top_downloads[uri] += 1 + + month_stats['top_downloads'] = top_downloads diff --git a/plugins/post_analysis/top_hits.py b/plugins/post_analysis/top_hits.py new file mode 100644 index 0000000..64446c7 --- /dev/null +++ b/plugins/post_analysis/top_hits.py @@ -0,0 +1,78 @@ +# -*- coding: utf-8 -*- +# +# Copyright Grégory Soutadé 2015 + +# This file is part of iwla + +# iwla is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# iwla is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with iwla. If not, see . +# + +from iwla import IWLA +from iplugin import IPlugin + +""" +Post analysis hook + +Count TOP hits + +Plugin requirements : + None + +Conf values needed : + None + +Output files : + None + +Statistics creation : + None + +Statistics update : +month_stats: + top_hits => + uri + +Statistics deletion : + None +""" + +class IWLAPostAnalysisTopHits(IPlugin): + def __init__(self, iwla): + super(IWLAPostAnalysisTopHits, self).__init__(iwla) + self.API_VERSION = 1 + + def hook(self): + stats = self.iwla.getCurrentVisists() + month_stats = self.iwla.getMonthStats() + + top_hits = month_stats.get('top_hits', {}) + + for (k, super_hit) in stats.items(): + if super_hit['robot']: continue + for r in super_hit['requests'][::-1]: + if not self.iwla.isValidForCurrentAnalysis(r): + break + if not self.iwla.hasBeenViewed(r) or\ + r['is_page']: + continue + + uri = r['extract_request']['extract_uri'].lower() + uri = "%s%s" % (r.get('server_name', ''), uri) + + if not uri in top_hits.keys(): + top_hits[uri] = 1 + else: + top_hits[uri] += 1 + + month_stats['top_hits'] = top_hits diff --git a/plugins/post_analysis/top_pages.py b/plugins/post_analysis/top_pages.py new file mode 100644 index 0000000..a5d086c --- /dev/null +++ b/plugins/post_analysis/top_pages.py @@ -0,0 +1,87 @@ +# -*- coding: utf-8 -*- +# +# Copyright Grégory Soutadé 2015 + +# This file is part of iwla + +# iwla is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# iwla is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with iwla. If not, see . +# + +import re + +from iwla import IWLA +from iplugin import IPlugin + +""" +Post analysis hook + +Count TOP pages + +Plugin requirements : + None + +Conf values needed : + None + +Output files : + None + +Statistics creation : + None + +Statistics update : +month_stats: + top_pages => + uri + +Statistics deletion : + None +""" + +class IWLAPostAnalysisTopPages(IPlugin): + def __init__(self, iwla): + super(IWLAPostAnalysisTopPages, self).__init__(iwla) + self.API_VERSION = 1 + + def load(self): + self.index_re = re.compile(r'/index.*') + return True + + def hook(self): + stats = self.iwla.getCurrentVisists() + month_stats = self.iwla.getMonthStats() + + top_pages = month_stats.get('top_pages', {}) + + for (k, super_hit) in stats.items(): + if super_hit['robot']: continue + for r in super_hit['requests'][::-1]: + if not self.iwla.isValidForCurrentAnalysis(r): + break + if not self.iwla.hasBeenViewed(r) or\ + not r['is_page']: + continue + + uri = r['extract_request']['extract_uri'] + if self.index_re.match(uri): + uri = '/' + + uri = "%s%s" % (r.get('server_name', ''), uri) + + if not uri in top_pages.keys(): + top_pages[uri] = 1 + else: + top_pages[uri] += 1 + + month_stats['top_pages'] = top_pages diff --git a/plugins/pre_analysis/__init__.py b/plugins/pre_analysis/__init__.py new file mode 100644 index 0000000..792d600 --- /dev/null +++ b/plugins/pre_analysis/__init__.py @@ -0,0 +1 @@ +# diff --git a/plugins/pre_analysis/page_to_hit.py b/plugins/pre_analysis/page_to_hit.py new file mode 100644 index 0000000..a3919c4 --- /dev/null +++ b/plugins/pre_analysis/page_to_hit.py @@ -0,0 +1,103 @@ +# -*- coding: utf-8 -*- +# +# Copyright Grégory Soutadé 2015 + +# This file is part of iwla + +# iwla is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# iwla is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with iwla. If not, see . +# + +import re + +from iwla import IWLA +from iplugin import IPlugin + +""" +Pre analysis hook +Change page into hit and hit into page into statistics + +Plugin requirements : + None + +Conf values needed : + page_to_hit_conf* + hit_to_page_conf* + +Output files : + None + +Statistics creation : + None + +Statistics update : +visits : + remote_addr => + is_page + +Statistics deletion : + None +""" + +class IWLAPreAnalysisPageToHit(IPlugin): + + def __init__(self, iwla): + super(IWLAPreAnalysisPageToHit, self).__init__(iwla) + self.API_VERSION = 1 + + def load(self): + # Page to hit + self.ph_regexps = self.iwla.getConfValue('page_to_hit_conf', []) + if not self.ph_regexps: return False + self.ph_regexps = map(lambda(r): re.compile(r), self.ph_regexps) + + # Hit to page + self.hp_regexps = self.iwla.getConfValue('hit_to_page_conf', []) + if not self.hp_regexps: return False + self.hp_regexps = map(lambda(r): re.compile(r), self.hp_regexps) + + return True + + def hook(self): + hits = self.iwla.getCurrentVisists() + + for (k, super_hit) in hits.items(): + if super_hit['robot']: continue + + for request in super_hit['requests'][::-1]: + if not self.iwla.isValidForCurrentAnalysis(request): + break + + if not self.iwla.hasBeenViewed(request): + continue + + uri = request['extract_request']['extract_uri'] + + if request['is_page']: + # Page to hit + for regexp in self.ph_regexps: + if regexp.match(uri): + #print '%s is a hit' % (uri ) + request['is_page'] = False + super_hit['viewed_pages'] -= 1 + super_hit['viewed_hits'] += 1 + break + else: + # Hit to page + for regexp in self.hp_regexps: + if regexp.match(uri): + #print '%s is a page' % (uri ) + request['is_page'] = True + super_hit['viewed_pages'] += 1 + super_hit['viewed_hits'] -= 1 + break diff --git a/plugins/pre_analysis/robots.py b/plugins/pre_analysis/robots.py new file mode 100644 index 0000000..662ce57 --- /dev/null +++ b/plugins/pre_analysis/robots.py @@ -0,0 +1,113 @@ +# -*- coding: utf-8 -*- +# +# Copyright Grégory Soutadé 2015 + +# This file is part of iwla + +# iwla is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# iwla is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with iwla. If not, see . +# + +import re + +from iwla import IWLA +from iplugin import IPlugin + +import awstats_data + +""" +Pre analysis hook + +Filter robots + +Plugin requirements : + None + +Conf values needed : + page_to_hit_conf* + hit_to_page_conf* + +Output files : + None + +Statistics creation : + None + +Statistics update : +visits : + remote_addr => + robot + +Statistics deletion : + None +""" + +class IWLAPreAnalysisRobots(IPlugin): + def __init__(self, iwla): + super(IWLAPreAnalysisRobots, self).__init__(iwla) + self.API_VERSION = 1 + + def load(self): + self.awstats_robots = map(lambda (x) : re.compile(('.*%s.*') % (x), re.IGNORECASE), awstats_data.robots) + + return True + +# Basic rule to detect robots + def hook(self): + hits = self.iwla.getCurrentVisists() + for (k, super_hit) in hits.items(): + if super_hit['robot']: continue + + isRobot = False + referers = 0 + + first_page = super_hit['requests'][0] + if not self.iwla.isValidForCurrentAnalysis(first_page): continue + + for r in self.awstats_robots: + if r.match(first_page['http_user_agent']): + isRobot = True + break + + if isRobot: + super_hit['robot'] = 1 + continue + +# 1) no pages view --> robot + # if not super_hit['viewed_pages']: + # super_hit['robot'] = 1 + # continue + +# 2) pages without hit --> robot + if not super_hit['viewed_hits']: + super_hit['robot'] = 1 + continue + + for hit in super_hit['requests']: +# 3) /robots.txt read + if hit['extract_request']['http_uri'] == '/robots.txt': + isRobot = True + break + +# 4) Any referer for hits + if not hit['is_page'] and hit['http_referer']: + referers += 1 + + if isRobot: + super_hit['robot'] = 1 + continue + + if not super_hit['viewed_pages'] and \ + (super_hit['viewed_hits'] and not referers): + super_hit['robot'] = 1 + continue diff --git a/resources/css/iwla.css b/resources/css/iwla.css new file mode 100644 index 0000000..71b652b --- /dev/null +++ b/resources/css/iwla.css @@ -0,0 +1,87 @@ + +body +{ + font: 11px verdana, arial, helvetica, sans-serif; + background-color: #FFFFFF; +} + +.iwla_block +{ + display:block; + margin: 2em; +} + +.iwla_block_title { + font: 13px verdana, arial, helvetica, sans-serif; + font-weight: bold; + background-color: #CCCCDD; + text-align: center; + color: #000000; + width: 60%; +} + +a +{ + font: 11px verdana, arial, helvetica, sans-serif; + font-weight: normal; + text-decoration: none; +} + +.iwla_block_value +{ + border-width : 0.2em; + border-color : #CCCCDD; + border-style : solid; +} + +/* .iwla_block_value table tr th */ +th +{ + padding : 0.5em; + background : #ECECEC; + font-weight: normal; + white-space: nowrap; +} + +td +{ + text-align:center; + vertical-align:middle; +} + +.iwla_td_img +{ + vertical-align:bottom; +} + +td:first-child +{ + text-align:left; + /* width : 100%; */ +} + +.iwla_visitor { background : #FFAA66; } +.iwla_visit { background : #F4F090; } +.iwla_page { background : #4477DD; } +.iwla_hit { background : #66DDEE; } +.iwla_bandwidth { background : #2EA495; } +.iwla_search { background : #F4F090; } +.iwla_weekend { background : #ECECEC; } +.iwla_curday { font-weight: bold; } +.iwla_others { color: #668; } +.iwla_graph_table +{ + margin-left:auto; + margin-right:auto; +} + +table.iwla_graph_table + table.iwla_table +{ + margin-left:auto; + margin-right:auto; +} + +table.iwla_graph_table td +{ + text-align:center; +} diff --git a/resources/icon/vh.png b/resources/icon/vh.png new file mode 100644 index 0000000000000000000000000000000000000000..13e52f9ef9a675349c93b1eeeef2ea1388a3bdc6 GIT binary patch literal 239 zcmeAS@N?(olHy`uVBq!ia0vp@K+MR(3?#p^TbckV{Sw!R66d1S#FEVXJcW?V+*F3F z)KWbKLoTn9*sC$qb+%OS+@4BLl<6e(pbstU$hcfKP}k$FXyY=dL+De_#Fo z|D5mtTb{o!zV|%&+P$D-=M1;*WmvkFVagPNwQD^ta>oF*2za_UhE&{2P6#RUeIHW` Yw7Z?@X!#7GUZ5OmdKI;Vst0F_-zU;qFB literal 0 HcmV?d00001 diff --git a/resources/icon/vk.png b/resources/icon/vk.png new file mode 100644 index 0000000000000000000000000000000000000000..ac1bc63b7f1b1566abc0986fc6a8d5f0c70aff44 GIT binary patch literal 236 zcmeAS@N?(olHy`uVBq!ia0vp@K+MR(3?#p^TbckV{Sw!R66d1S#FEVXJcW?V+*F3F z)KWbKLoi7I;J!Gca&{0AWU_H6}BFf-LEdzK#qG8~eHcB(eheDgizrt_%%<3>{$%3kp@Y z&aq#;NN>qh;i}1Cxn#wzK_`}!@!=$ Vv?lgUttn8B!PC{xWt~$(695VHJjDP2 literal 0 HcmV?d00001 diff --git a/resources/icon/vp.png b/resources/icon/vp.png new file mode 100644 index 0000000000000000000000000000000000000000..8ebf70216123ac0fd386005e511f20f42be2d5ca GIT binary patch literal 248 zcmeAS@N?(olHy`uVBq!ia0vp@K+MR(3?#p^TbckV{Sw!R66d1S#FEVXJcW?V+*F3F z)KWbKLo*8o|0J>k`33<#A+8)==M=V@SoV21sUuG2GF=Z-H zdhh`##981GS*8o|0J>k`RV~aA+DEChTJ%o^5SmQ z=V$Xizg_q8@#4pKXWYBqclm7diG6wdw)(G|<-c!TPZ!6Kid)GEA!WYr cV`^m>*!!5ylr{#t0p%DxUHx3vIVCg!0ItzYF#rGn literal 0 HcmV?d00001 diff --git a/robots.py b/robots.py deleted file mode 100644 index 8373f65..0000000 --- a/robots.py +++ /dev/null @@ -1,2 +0,0 @@ -awstats_robots = ['.*appie.*', '.*architext.*', '.*jeeves.*', '.*bjaaland.*', '.*contentmatch.*', '.*ferret.*', '.*googlebot.*', '.*google\-sitemaps.*', '.*gulliver.*', '.*virus[_+ ]detector.*', '.*harvest.*', '.*htdig.*', '.*linkwalker.*', '.*lilina.*', '.*lycos[_+ ].*', '.*moget.*', '.*muscatferret.*', '.*myweb.*', '.*nomad.*', '.*scooter.*', '.*slurp.*', '.*^voyager\/.*', '.*weblayers.*', '.*antibot.*', '.*bruinbot.*', '.*digout4u.*', '.*echo!.*', '.*fast\-webcrawler.*', '.*ia_archiver\-web\.archive\.org.*', '.*ia_archiver.*', '.*jennybot.*', '.*mercator.*', '.*netcraft.*', '.*msnbot\-media.*', '.*msnbot.*', '.*petersnews.*', '.*relevantnoise\.com.*', '.*unlost_web_crawler.*', '.*voila.*', '.*webbase.*', '.*webcollage.*', '.*cfetch.*', '.*zyborg.*', '.*wisenutbot.*', '.*[^a]fish.*', '.*abcdatos.*', '.*acme\.spider.*', '.*ahoythehomepagefinder.*', '.*alkaline.*', '.*anthill.*', '.*arachnophilia.*', '.*arale.*', '.*araneo.*', '.*aretha.*', '.*ariadne.*', '.*powermarks.*', '.*arks.*', '.*aspider.*', '.*atn\.txt.*', '.*atomz.*', '.*auresys.*', '.*backrub.*', '.*bbot.*', '.*bigbrother.*', '.*blackwidow.*', '.*blindekuh.*', '.*bloodhound.*', '.*borg\-bot.*', '.*brightnet.*', '.*bspider.*', '.*cactvschemistryspider.*', '.*calif[^r].*', '.*cassandra.*', '.*cgireader.*', '.*checkbot.*', '.*christcrawler.*', '.*churl.*', '.*cienciaficcion.*', '.*collective.*', '.*combine.*', '.*conceptbot.*', '.*coolbot.*', '.*core.*', '.*cosmos.*', '.*cruiser.*', '.*cusco.*', '.*cyberspyder.*', '.*desertrealm.*', '.*deweb.*', '.*dienstspider.*', '.*digger.*', '.*diibot.*', '.*direct_hit.*', '.*dnabot.*', '.*download_express.*', '.*dragonbot.*', '.*dwcp.*', '.*e\-collector.*', '.*ebiness.*', '.*elfinbot.*', '.*emacs.*', '.*emcspider.*', '.*esther.*', '.*evliyacelebi.*', '.*fastcrawler.*', '.*feedcrawl.*', '.*fdse.*', '.*felix.*', '.*fetchrover.*', '.*fido.*', '.*finnish.*', '.*fireball.*', '.*fouineur.*', '.*francoroute.*', '.*freecrawl.*', '.*funnelweb.*', '.*gama.*', '.*gazz.*', '.*gcreep.*', '.*getbot.*', '.*geturl.*', '.*golem.*', '.*gougou.*', '.*grapnel.*', '.*griffon.*', '.*gromit.*', '.*gulperbot.*', '.*hambot.*', '.*havindex.*', '.*hometown.*', '.*htmlgobble.*', '.*hyperdecontextualizer.*', '.*iajabot.*', '.*iaskspider.*', '.*hl_ftien_spider.*', '.*sogou.*', '.*iconoclast.*', '.*ilse.*', '.*imagelock.*', '.*incywincy.*', '.*informant.*', '.*infoseek.*', '.*infoseeksidewinder.*', '.*infospider.*', '.*inspectorwww.*', '.*intelliagent.*', '.*irobot.*', '.*iron33.*', '.*israelisearch.*', '.*javabee.*', '.*jbot.*', '.*jcrawler.*', '.*jobo.*', '.*jobot.*', '.*joebot.*', '.*jubii.*', '.*jumpstation.*', '.*kapsi.*', '.*katipo.*', '.*kilroy.*', '.*ko[_+ ]yappo[_+ ]robot.*', '.*kummhttp.*', '.*labelgrabber\.txt.*', '.*larbin.*', '.*legs.*', '.*linkidator.*', '.*linkscan.*', '.*lockon.*', '.*logo_gif.*', '.*macworm.*', '.*magpie.*', '.*marvin.*', '.*mattie.*', '.*mediafox.*', '.*merzscope.*', '.*meshexplorer.*', '.*mindcrawler.*', '.*mnogosearch.*', '.*momspider.*', '.*monster.*', '.*motor.*', '.*muncher.*', '.*mwdsearch.*', '.*ndspider.*', '.*nederland\.zoek.*', '.*netcarta.*', '.*netmechanic.*', '.*netscoop.*', '.*newscan\-online.*', '.*nhse.*', '.*northstar.*', '.*nzexplorer.*', '.*objectssearch.*', '.*occam.*', '.*octopus.*', '.*openfind.*', '.*orb_search.*', '.*packrat.*', '.*pageboy.*', '.*parasite.*', '.*patric.*', '.*pegasus.*', '.*perignator.*', '.*perlcrawler.*', '.*phantom.*', '.*phpdig.*', '.*piltdownman.*', '.*pimptrain.*', '.*pioneer.*', '.*pitkow.*', '.*pjspider.*', '.*plumtreewebaccessor.*', '.*poppi.*', '.*portalb.*', '.*psbot.*', '.*python.*', '.*raven.*', '.*rbse.*', '.*resumerobot.*', '.*rhcs.*', '.*road_runner.*', '.*robbie.*', '.*robi.*', '.*robocrawl.*', '.*robofox.*', '.*robozilla.*', '.*roverbot.*', '.*rules.*', '.*safetynetrobot.*', '.*search\-info.*', '.*search_au.*', '.*searchprocess.*', '.*senrigan.*', '.*sgscout.*', '.*shaggy.*', '.*shaihulud.*', '.*sift.*', '.*simbot.*', '.*site\-valet.*', '.*sitetech.*', '.*skymob.*', '.*slcrawler.*', '.*smartspider.*', '.*snooper.*', '.*solbot.*', '.*speedy.*', '.*spider[_+ ]monkey.*', '.*spiderbot.*', '.*spiderline.*', '.*spiderman.*', '.*spiderview.*', '.*spry.*', '.*sqworm.*', '.*ssearcher.*', '.*suke.*', '.*sunrise.*', '.*suntek.*', '.*sven.*', '.*tach_bw.*', '.*tagyu_agent.*', '.*tailrank.*', '.*tarantula.*', '.*tarspider.*', '.*techbot.*', '.*templeton.*', '.*titan.*', '.*titin.*', '.*tkwww.*', '.*tlspider.*', '.*ucsd.*', '.*udmsearch.*', '.*universalfeedparser.*', '.*urlck.*', '.*valkyrie.*', '.*verticrawl.*', '.*victoria.*', '.*visionsearch.*', '.*voidbot.*', '.*vwbot.*', '.*w3index.*', '.*w3m2.*', '.*wallpaper.*', '.*wanderer.*', '.*wapspIRLider.*', '.*webbandit.*', '.*webcatcher.*', '.*webcopy.*', '.*webfetcher.*', '.*webfoot.*', '.*webinator.*', '.*weblinker.*', '.*webmirror.*', '.*webmoose.*', '.*webquest.*', '.*webreader.*', '.*webreaper.*', '.*websnarf.*', '.*webspider.*', '.*webvac.*', '.*webwalk.*', '.*webwalker.*', '.*webwatch.*', '.*whatuseek.*', '.*whowhere.*', '.*wired\-digital.*', '.*wmir.*', '.*wolp.*', '.*wombat.*', '.*wordpress.*', '.*worm.*', '.*woozweb.*', '.*wwwc.*', '.*wz101.*', '.*xget.*', '.*1\-more_scanner.*', '.*accoona\-ai\-agent.*', '.*activebookmark.*', '.*adamm_bot.*', '.*almaden.*', '.*aipbot.*', '.*aleadsoftbot.*', '.*alpha_search_agent.*', '.*allrati.*', '.*aport.*', '.*archive\.org_bot.*', '.*argus.*', '.*arianna\.libero\.it.*', '.*aspseek.*', '.*asterias.*', '.*awbot.*', '.*baiduspider.*', '.*becomebot.*', '.*bender.*', '.*betabot.*', '.*biglotron.*', '.*bittorrent_bot.*', '.*biz360[_+ ]spider.*', '.*blogbridge[_+ ]service.*', '.*bloglines.*', '.*blogpulse.*', '.*blogsearch.*', '.*blogshares.*', '.*blogslive.*', '.*blogssay.*', '.*bncf\.firenze\.sbn\.it\/raccolta\.txt.*', '.*bobby.*', '.*boitho\.com\-dc.*', '.*bookmark\-manager.*', '.*boris.*', '.*bumblebee.*', '.*candlelight[_+ ]favorites[_+ ]inspector.*', '.*cbn00glebot.*', '.*cerberian_drtrs.*', '.*cfnetwork.*', '.*cipinetbot.*', '.*checkweb_link_validator.*', '.*commons\-httpclient.*', '.*computer_and_automation_research_institute_crawler.*', '.*converamultimediacrawler.*', '.*converacrawler.*', '.*cscrawler.*', '.*cse_html_validator_lite_online.*', '.*cuasarbot.*', '.*cursor.*', '.*custo.*', '.*datafountains\/dmoz_downloader.*', '.*daviesbot.*', '.*daypopbot.*', '.*deepindex.*', '.*dipsie\.bot.*', '.*dnsgroup.*', '.*domainchecker.*', '.*domainsdb\.net.*', '.*dulance.*', '.*dumbot.*', '.*dumm\.de\-bot.*', '.*earthcom\.info.*', '.*easydl.*', '.*edgeio\-retriever.*', '.*ets_v.*', '.*exactseek.*', '.*extreme[_+ ]picture[_+ ]finder.*', '.*eventax.*', '.*everbeecrawler.*', '.*everest\-vulcan.*', '.*ezresult.*', '.*enteprise.*', '.*facebook.*', '.*fast_enterprise_crawler.*crawleradmin\.t\-info@telekom\.de.*', '.*fast_enterprise_crawler.*t\-info_bi_cluster_crawleradmin\.t\-info@telekom\.de.*', '.*matrix_s\.p\.a\._\-_fast_enterprise_crawler.*', '.*fast_enterprise_crawler.*', '.*fast\-search\-engine.*', '.*favicon.*', '.*favorg.*', '.*favorites_sweeper.*', '.*feedburner.*', '.*feedfetcher\-google.*', '.*feedflow.*', '.*feedster.*', '.*feedsky.*', '.*feedvalidator.*', '.*filmkamerabot.*', '.*findlinks.*', '.*findexa_crawler.*', '.*fooky\.com\/ScorpionBot.*', '.*g2crawler.*', '.*gaisbot.*', '.*geniebot.*', '.*gigabot.*', '.*girafabot.*', '.*global_fetch.*', '.*gnodspider.*', '.*goforit\.com.*', '.*goforitbot.*', '.*gonzo.*', '.*grub.*', '.*gpu_p2p_crawler.*', '.*henrythemiragorobot.*', '.*heritrix.*', '.*holmes.*', '.*hoowwwer.*', '.*hpprint.*', '.*htmlparser.*', '.*html[_+ ]link[_+ ]validator.*', '.*httrack.*', '.*hundesuche\.com\-bot.*', '.*ichiro.*', '.*iltrovatore\-setaccio.*', '.*infobot.*', '.*infociousbot.*', '.*infomine.*', '.*insurancobot.*', '.*internet[_+ ]ninja.*', '.*internetarchive.*', '.*internetseer.*', '.*internetsupervision.*', '.*irlbot.*', '.*isearch2006.*', '.*iupui_research_bot.*', '.*jrtwine[_+ ]software[_+ ]check[_+ ]favorites[_+ ]utility.*', '.*justview.*', '.*kalambot.*', '.*kamano\.de_newsfeedverzeichnis.*', '.*kazoombot.*', '.*kevin.*', '.*keyoshid.*', '.*kinjabot.*', '.*kinja\-imagebot.*', '.*knowitall.*', '.*knowledge\.com.*', '.*kouaa_krawler.*', '.*krugle.*', '.*ksibot.*', '.*kurzor.*', '.*lanshanbot.*', '.*letscrawl\.com.*', '.*libcrawl.*', '.*linkbot.*', '.*link_valet_online.*', '.*metager\-linkchecker.*', '.*linkchecker.*', '.*livejournal\.com.*', '.*lmspider.*', '.*lwp\-request.*', '.*lwp\-trivial.*', '.*magpierss.*', '.*mail\.ru.*', '.*mapoftheinternet\.com.*', '.*mediapartners\-google.*', '.*megite.*', '.*metaspinner.*', '.*microsoft[_+ ]url[_+ ]control.*', '.*mini\-reptile.*', '.*minirank.*', '.*missigua_locator.*', '.*misterbot.*', '.*miva.*', '.*mizzu_labs.*', '.*mj12bot.*', '.*mojeekbot.*', '.*msiecrawler.*', '.*ms_search_4\.0_robot.*', '.*msrabot.*', '.*msrbot.*', '.*mt::telegraph::agent.*', '.*nagios.*', '.*nasa_search.*', '.*mydoyouhike.*', '.*netluchs.*', '.*netsprint.*', '.*newsgatoronline.*', '.*nicebot.*', '.*nimblecrawler.*', '.*noxtrumbot.*', '.*npbot.*', '.*nutchcvs.*', '.*nutchosu\-vlib.*', '.*nutch.*', '.*ocelli.*', '.*octora_beta_bot.*', '.*omniexplorer[_+ ]bot.*', '.*onet\.pl[_+ ]sa.*', '.*onfolio.*', '.*opentaggerbot.*', '.*openwebspider.*', '.*oracle_ultra_search.*', '.*orbiter.*', '.*yodaobot.*', '.*qihoobot.*', '.*passwordmaker\.org.*', '.*pear_http_request_class.*', '.*peerbot.*', '.*perman.*', '.*php[_+ ]version[_+ ]tracker.*', '.*pictureofinternet.*', '.*ping\.blo\.gs.*', '.*plinki.*', '.*pluckfeedcrawler.*', '.*pogodak.*', '.*pompos.*', '.*popdexter.*', '.*port_huron_labs.*', '.*postfavorites.*', '.*projectwf\-java\-test\-crawler.*', '.*proodlebot.*', '.*pyquery.*', '.*rambler.*', '.*redalert.*', '.*rojo.*', '.*rssimagesbot.*', '.*ruffle.*', '.*rufusbot.*', '.*sandcrawler.*', '.*sbider.*', '.*schizozilla.*', '.*scumbot.*', '.*searchguild[_+ ]dmoz[_+ ]experiment.*', '.*seekbot.*', '.*sensis_web_crawler.*', '.*seznambot.*', '.*shim\-crawler.*', '.*shoutcast.*', '.*slysearch.*', '.*snap\.com_beta_crawler.*', '.*sohu\-search.*', '.*sohu.*', '.*snappy.*', '.*sphere_scout.*', '.*spip.*', '.*sproose_crawler.*', '.*steeler.*', '.*steroid__download.*', '.*suchfin\-bot.*', '.*superbot.*', '.*surveybot.*', '.*susie.*', '.*syndic8.*', '.*syndicapi.*', '.*synoobot.*', '.*tcl_http_client_package.*', '.*technoratibot.*', '.*teragramcrawlersurf.*', '.*test_crawler.*', '.*testbot.*', '.*t\-h\-u\-n\-d\-e\-r\-s\-t\-o\-n\-e.*', '.*topicblogs.*', '.*turnitinbot.*', '.*turtlescanner.*', '.*turtle.*', '.*tutorgigbot.*', '.*twiceler.*', '.*ubicrawler.*', '.*ultraseek.*', '.*unchaos_bot_hybrid_web_search_engine.*', '.*unido\-bot.*', '.*updated.*', '.*ustc\-semantic\-group.*', '.*vagabondo\-wap.*', '.*vagabondo.*', '.*vermut.*', '.*versus_crawler_from_eda\.baykan@epfl\.ch.*', '.*vespa_crawler.*', '.*vortex.*', '.*vse\/.*', '.*w3c\-checklink.*', '.*w3c[_+ ]css[_+ ]validator[_+ ]jfouffa.*', '.*w3c_validator.*', '.*watchmouse.*', '.*wavefire.*', '.*webclipping\.com.*', '.*webcompass.*', '.*webcrawl\.net.*', '.*web_downloader.*', '.*webdup.*', '.*webfilter.*', '.*webindexer.*', '.*webminer.*', '.*website[_+ ]monitoring[_+ ]bot.*', '.*webvulncrawl.*', '.*wells_search.*', '.*wonderer.*', '.*wume_crawler.*', '.*wwweasel.*', '.*xenu\'s_link_sleuth.*', '.*xenu_link_sleuth.*', '.*xirq.*', '.*y!j.*', '.*yacy.*', '.*yahoo\-blogs.*', '.*yahoo\-verticalcrawler.*', '.*yahoofeedseeker.*', '.*yahooseeker\-testing.*', '.*yahooseeker.*', '.*yahoo\-mmcrawler.*', '.*yahoo!_mindset.*', '.*yandex.*', '.*flexum.*', '.*yanga.*', '.*yooglifetchagent.*', '.*z\-add_link_checker.*', '.*zealbot.*', '.*zhuaxia.*', '.*zspider.*', '.*zeus.*', '.*ng\/1\..*', '.*ng\/2\..*', '.*exabot.*', '.*wget.*', '.*libwww.*', '.*java\/[0-9].*'] - diff --git a/tools/extract_doc.py b/tools/extract_doc.py new file mode 100755 index 0000000..eee534b --- /dev/null +++ b/tools/extract_doc.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python + +import sys + +filename = sys.argv[1] + +if filename.endswith('__init__.py'): + sys.exit(0) + +package_name = filename.replace('/', '.').replace('.py', '') +sys.stdout.write('%s' % (package_name)) +sys.stdout.write('\n') +# sys.stdout.write('\n\n') +sys.stdout.write('-' * len(package_name)) +sys.stdout.write('\n\n') + +sys.stderr.write('\tExtract doc from %s\n' % (filename)) + +with open(filename) as infile: + copy = False + for line in infile: + if line.strip() in ['"""', "'''"]: + if not copy: + copy = True + else: + break + elif copy: + sys.stdout.write(' %s' % (line)) + +sys.stdout.write('\n\n') diff --git a/tools/extract_docs.sh b/tools/extract_docs.sh new file mode 100755 index 0000000..e556330 --- /dev/null +++ b/tools/extract_docs.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +MODULES_TARGET="docs/modules.md" +MAIN_MD="docs/main.md" +TARGET_MD="docs/index.md" + +rm -f "${MODULES_TARGET}" + +echo "Generate doc from iwla.py" +python tools/extract_doc.py iwla.py > "${MODULES_TARGET}" + +echo "Generate plugins documentation" +find plugins -name '*.py' -exec python tools/extract_doc.py \{\} \; >> "${MODULES_TARGET}" + +echo "Generate ${TARGET_MD}" +cat "${MAIN_MD}" "${MODULES_TARGET}" > "${TARGET_MD}" diff --git a/tools/gettext.sh b/tools/gettext.sh new file mode 100755 index 0000000..81bafab --- /dev/null +++ b/tools/gettext.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +pygettext -a -d iwla -o iwla.pot -k gettext *.py plugins/pre_analysis/*.py plugins/post_analysis/*.py plugins/display/*.py diff --git a/tools/iwla_convert.pl b/tools/iwla_convert.pl new file mode 100755 index 0000000..b5c9587 --- /dev/null +++ b/tools/iwla_convert.pl @@ -0,0 +1,79 @@ +#!/usr/bin/perl + +my $awstats_lib_root = './'; +my @awstats_libs = ('search_engines.pm', 'robots.pm'); + +# my $awstats_lib_root = '/usr/share/awstats/lib/'; +# my @awstats_libs = ('browsers.pm', 'browsers_phone.pm', 'mime.pm', 'referer_spam.pm', 'search_engines.pm', 'operating_systems.pm', 'robots.pm', 'worms.pm'); + +foreach $lib (@awstats_libs) {require $awstats_lib_root . $lib;} + +sub dumpList { + my @list = @{$_[0]}; + my $FIC = $_[1]; + my $first = $_[2]; + + foreach $r (@list) + { + $r =~ s/\'/\\\'/g; + if ($first == 0) + { + print $FIC ", "; + } + else + { + $first = 0; + } + print $FIC "'$r'"; + } +} + +sub dumpHash { + my %hash = %{$_[0]}; + my $FIC = $_[1]; + my $first = $_[2]; + + while( my ($k,$v) = each(%hash) ) { + $k =~ s/\'/\\\'/g; + $v =~ s/\'/\\\'/g; + if ($first == 0) + { + print $FIC ", "; + } + else + { + $first = 0; + } + print $FIC "'$k' : '$v'"; + } +} + +# Robots +open($FIC,">", "awstats_data.py") or die $!; + +print $FIC "robots = ["; +dumpList(\@RobotsSearchIDOrder_list1, $FIC, 1); +dumpList(\@RobotsSearchIDOrder_list2, $FIC, 0); +print $FIC "]\n\n"; + +print $FIC "search_engines = ["; +dumpList(\@SearchEnginesSearchIDOrder_list1, $FIC, 1); +print $FIC "]\n\n"; + +print $FIC "search_engines_2 = ["; +dumpList(\@SearchEnginesSearchIDOrder_list2, $FIC, 1); +print $FIC "]\n\n"; + +print $FIC "not_search_engines_keys = {"; +dumpHash(\%NotSearchEnginesKeys, $FIC, 1); +print $FIC "}\n\n"; + +print $FIC "search_engines_hashid = {"; +dumpHash(\%SearchEnginesHashID, $FIC, 1); +print $FIC "}\n\n"; + +print $FIC "search_engines_knwown_url = {"; +dumpHash(\%SearchEnginesKnownUrl, $FIC, 1); +print $FIC "}\n\n"; + +close($FIC); From 9a1ad3dc25312040e957e842df19425e073343e1 Mon Sep 17 00:00:00 2001 From: Gregory Soutade Date: Tue, 23 Dec 2014 09:18:30 +0100 Subject: [PATCH 2/5] Update doc --- docs/index.md | 352 ++++++++++++++++++++++++------------------------ docs/main.md | 14 +- docs/modules.md | 338 +++++++++++++++++++++++----------------------- 3 files changed, 352 insertions(+), 352 deletions(-) diff --git a/docs/index.md b/docs/index.md index 1a3b36c..9fa98a3 100644 --- a/docs/index.md +++ b/docs/index.md @@ -4,7 +4,7 @@ iwla Introduction ------------ -iwla (Intelligent Web Log Analyzer) is basically a clone of [awstats](http://www.awstats.org). The main problem with awstats is that it's a very monolothic project with everything in one big PERL file. In opposite, iwla has be though to be very modular : a small core analysis and a lot of filters. It can be viewed as UNIX pipes. Philosophy of iwla is : add, update, delete ! That's the job of each filters : modify statistics until final result. It's written in Python. +iwla (Intelligent Web Log Analyzer) is basically a clone of [awstats](http://www.awstats.org). The main problem with awstats is that it's a very monolothic project with everything in one big PERL file. In opposite, iwla has been though to be very modular : a small core analysis and a lot of filters. It can be viewed as UNIX pipes. Philosophy of iwla is : add, update, delete ! That's the job of each filter : modify statistics until final result. It's written in Python. Nevertheless, iwla is only focused on HTTP logs. It uses data (robots definitions, search engines definitions) and design from awstats. Moreover, it's not dynamic, but only generates static HTML page (with gzip compression option). @@ -32,25 +32,25 @@ Main values to edit are : * **display_hooks** : List of display hooks * **locale** : Displayed locale (_en_ or _fr_) -Then, you can then iwla. Output HTML files are created in _output_ directory by default. To quickly see it go in output and type +Then, you can launch iwla. Output HTML files are created in _output_ directory by default. To quickly see it, go into _output_ and type python -m SimpleHTTPServer 8000 Open your favorite web browser at _http://localhost:8000_. Enjoy ! -**Warning** : The order is hooks list is important : Some plugins may requires others plugins, and the order of display_hooks is the order of displayed blocks in final result. +**Warning** : The order in hooks list is important : Some plugins may requires others plugins, and the order of display_hooks is the order of displayed blocks in final result. Interesting default configuration values ---------------------------------------- * **DB_ROOT** : Default database directory (default ./output_db) - * **DISPLAY_ROOT** : Default HTML output directory (default ./output) + * **DISPLAY_ROOT** : Default HTML output directory (default _./output_) * **log_format** : Web server log format (nginx style). Default is apache log format * **time_format** : Time format used in log format * **pages_extensions** : Extensions that are considered as a HTML page (or result) in opposit to hits * **viewed_http_codes** : HTTP codes that are cosidered OK (200, 304) - * **count_hit_only_visitors** : If False, doesn't cout visitors that doesn't GET a page but resources only (images, rss...) + * **count_hit_only_visitors** : If False, don't count visitors that doesn't GET a page but resources only (images, rss...) * **multimedia_files** : Multimedia extensions (not accounted as downloaded files) * **css_path** : CSS path (you can add yours) * **compress_output_files** : Files extensions to compress in gzip during display build @@ -64,7 +64,7 @@ As previously described, plugins acts like UNIX pipes : statistics are constantl * **Post analysis plugins** : Called after basic statistics computation. They are in charge to enlight them with their own algorithms * **Display plugins** : They are in charge to produce HTML files from statistics. -To use plugins, just insert their name in _pre_analysis_hooks_, _post_analysis_hooks_ and _display_hooks_ lists in conf.py. +To use plugins, just insert their file name (without _.py_ extension) in _pre_analysis_hooks_, _post_analysis_hooks_ and _display_hooks_ lists in conf.py. Statistics are stored in dictionaries : @@ -77,7 +77,7 @@ Statistics are stored in dictionaries : Create a Plugins ---------------- -To create a new plugin, it's necessary to create a derived class of IPlugin (_iplugin.py) in the right directory (_plugins/xxx/yourPlugin.py_). +To create a new plugin, it's necessary to subclass IPlugin (_iplugin.py) in the right directory (_plugins/xxx/yourPlugin.py_). Plugins can defines required configuration values (self.conf_requires) that must be set in conf.py (or can be optional). They can also defines required plugins (self.requires). @@ -175,34 +175,6 @@ iwla None -plugins.display.top_downloads ------------------------------ - - Display hook - - Create TOP downloads page - - Plugin requirements : - post_analysis/top_downloads - - Conf values needed : - max_downloads_displayed* - create_all_downloads_page* - - Output files : - OUTPUT_ROOT/year/month/top_downloads.html - OUTPUT_ROOT/year/month/index.html - - Statistics creation : - None - - Statistics update : - None - - Statistics deletion : - None - - plugins.display.all_visits -------------------------- @@ -230,34 +202,6 @@ plugins.display.all_visits None -plugins.display.top_hits ------------------------- - - Display hook - - Create TOP hits page - - Plugin requirements : - post_analysis/top_hits - - Conf values needed : - max_hits_displayed* - create_all_hits_page* - - Output files : - OUTPUT_ROOT/year/month/top_hits.html - OUTPUT_ROOT/year/month/index.html - - Statistics creation : - None - - Statistics update : - None - - Statistics deletion : - None - - plugins.display.referers ------------------------ @@ -343,151 +287,57 @@ plugins.display.top_pages None -plugins.post_analysis.top_downloads ------------------------------------ +plugins.display.top_hits +------------------------ - Post analysis hook + Display hook - Count TOP downloads + Create TOP hits page Plugin requirements : - None + post_analysis/top_hits Conf values needed : - None + max_hits_displayed* + create_all_hits_page* Output files : - None + OUTPUT_ROOT/year/month/top_hits.html + OUTPUT_ROOT/year/month/index.html Statistics creation : None Statistics update : - month_stats: - top_downloads => - uri + None Statistics deletion : None -plugins.post_analysis.top_hits ------------------------------- +plugins.display.top_downloads +----------------------------- - Post analysis hook + Display hook - Count TOP hits + Create TOP downloads page Plugin requirements : - None + post_analysis/top_downloads Conf values needed : - None + max_downloads_displayed* + create_all_downloads_page* Output files : - None + OUTPUT_ROOT/year/month/top_downloads.html + OUTPUT_ROOT/year/month/index.html Statistics creation : None Statistics update : - month_stats: - top_hits => - uri - - Statistics deletion : None - - -plugins.post_analysis.referers ------------------------------- - - Post analysis hook - - Extract referers and key phrases from requests - - Plugin requirements : - None - - Conf values needed : - domain_name - - Output files : - None - - Statistics creation : - None - - Statistics update : - month_stats : - referers => - pages - hits - robots_referers => - pages - hits - search_engine_referers => - pages - hits - key_phrases => - phrase - - Statistics deletion : - None - - -plugins.post_analysis.reverse_dns ---------------------------------- - - Post analysis hook - - Replace IP by reverse DNS names - - Plugin requirements : - None - - Conf values needed : - reverse_dns_timeout* - - Output files : - None - - Statistics creation : - None - - Statistics update : - valid_visitors: - remote_addr - dns_name_replaced - dns_analyzed - - Statistics deletion : - None - - -plugins.post_analysis.top_pages -------------------------------- - - Post analysis hook - - Count TOP pages - - Plugin requirements : - None - - Conf values needed : - None - - Output files : - None - - Statistics creation : - None - - Statistics update : - month_stats: - top_pages => - uri Statistics deletion : None @@ -550,3 +400,153 @@ plugins.pre_analysis.robots None +plugins.post_analysis.referers +------------------------------ + + Post analysis hook + + Extract referers and key phrases from requests + + Plugin requirements : + None + + Conf values needed : + domain_name + + Output files : + None + + Statistics creation : + None + + Statistics update : + month_stats : + referers => + pages + hits + robots_referers => + pages + hits + search_engine_referers => + pages + hits + key_phrases => + phrase + + Statistics deletion : + None + + +plugins.post_analysis.top_pages +------------------------------- + + Post analysis hook + + Count TOP pages + + Plugin requirements : + None + + Conf values needed : + None + + Output files : + None + + Statistics creation : + None + + Statistics update : + month_stats: + top_pages => + uri + + Statistics deletion : + None + + +plugins.post_analysis.reverse_dns +--------------------------------- + + Post analysis hook + + Replace IP by reverse DNS names + + Plugin requirements : + None + + Conf values needed : + reverse_dns_timeout* + + Output files : + None + + Statistics creation : + None + + Statistics update : + valid_visitors: + remote_addr + dns_name_replaced + dns_analyzed + + Statistics deletion : + None + + +plugins.post_analysis.top_hits +------------------------------ + + Post analysis hook + + Count TOP hits + + Plugin requirements : + None + + Conf values needed : + None + + Output files : + None + + Statistics creation : + None + + Statistics update : + month_stats: + top_hits => + uri + + Statistics deletion : + None + + +plugins.post_analysis.top_downloads +----------------------------------- + + Post analysis hook + + Count TOP downloads + + Plugin requirements : + None + + Conf values needed : + None + + Output files : + None + + Statistics creation : + None + + Statistics update : + month_stats: + top_downloads => + uri + + Statistics deletion : + None + + diff --git a/docs/main.md b/docs/main.md index 0b5b16e..7df8333 100644 --- a/docs/main.md +++ b/docs/main.md @@ -4,7 +4,7 @@ iwla Introduction ------------ -iwla (Intelligent Web Log Analyzer) is basically a clone of [awstats](http://www.awstats.org). The main problem with awstats is that it's a very monolothic project with everything in one big PERL file. In opposite, iwla has be though to be very modular : a small core analysis and a lot of filters. It can be viewed as UNIX pipes. Philosophy of iwla is : add, update, delete ! That's the job of each filters : modify statistics until final result. It's written in Python. +iwla (Intelligent Web Log Analyzer) is basically a clone of [awstats](http://www.awstats.org). The main problem with awstats is that it's a very monolothic project with everything in one big PERL file. In opposite, iwla has been though to be very modular : a small core analysis and a lot of filters. It can be viewed as UNIX pipes. Philosophy of iwla is : add, update, delete ! That's the job of each filter : modify statistics until final result. It's written in Python. Nevertheless, iwla is only focused on HTTP logs. It uses data (robots definitions, search engines definitions) and design from awstats. Moreover, it's not dynamic, but only generates static HTML page (with gzip compression option). @@ -32,25 +32,25 @@ Main values to edit are : * **display_hooks** : List of display hooks * **locale** : Displayed locale (_en_ or _fr_) -Then, you can then iwla. Output HTML files are created in _output_ directory by default. To quickly see it go in output and type +Then, you can launch iwla. Output HTML files are created in _output_ directory by default. To quickly see it, go into _output_ and type python -m SimpleHTTPServer 8000 Open your favorite web browser at _http://localhost:8000_. Enjoy ! -**Warning** : The order is hooks list is important : Some plugins may requires others plugins, and the order of display_hooks is the order of displayed blocks in final result. +**Warning** : The order in hooks list is important : Some plugins may requires others plugins, and the order of display_hooks is the order of displayed blocks in final result. Interesting default configuration values ---------------------------------------- * **DB_ROOT** : Default database directory (default ./output_db) - * **DISPLAY_ROOT** : Default HTML output directory (default ./output) + * **DISPLAY_ROOT** : Default HTML output directory (default _./output_) * **log_format** : Web server log format (nginx style). Default is apache log format * **time_format** : Time format used in log format * **pages_extensions** : Extensions that are considered as a HTML page (or result) in opposit to hits * **viewed_http_codes** : HTTP codes that are cosidered OK (200, 304) - * **count_hit_only_visitors** : If False, doesn't cout visitors that doesn't GET a page but resources only (images, rss...) + * **count_hit_only_visitors** : If False, don't count visitors that doesn't GET a page but resources only (images, rss...) * **multimedia_files** : Multimedia extensions (not accounted as downloaded files) * **css_path** : CSS path (you can add yours) * **compress_output_files** : Files extensions to compress in gzip during display build @@ -64,7 +64,7 @@ As previously described, plugins acts like UNIX pipes : statistics are constantl * **Post analysis plugins** : Called after basic statistics computation. They are in charge to enlight them with their own algorithms * **Display plugins** : They are in charge to produce HTML files from statistics. -To use plugins, just insert their name in _pre_analysis_hooks_, _post_analysis_hooks_ and _display_hooks_ lists in conf.py. +To use plugins, just insert their file name (without _.py_ extension) in _pre_analysis_hooks_, _post_analysis_hooks_ and _display_hooks_ lists in conf.py. Statistics are stored in dictionaries : @@ -77,7 +77,7 @@ Statistics are stored in dictionaries : Create a Plugins ---------------- -To create a new plugin, it's necessary to create a derived class of IPlugin (_iplugin.py) in the right directory (_plugins/xxx/yourPlugin.py_). +To create a new plugin, it's necessary to subclass IPlugin (_iplugin.py) in the right directory (_plugins/xxx/yourPlugin.py_). Plugins can defines required configuration values (self.conf_requires) that must be set in conf.py (or can be optional). They can also defines required plugins (self.requires). diff --git a/docs/modules.md b/docs/modules.md index 41167c3..5067afb 100644 --- a/docs/modules.md +++ b/docs/modules.md @@ -83,34 +83,6 @@ iwla None -plugins.display.top_downloads ------------------------------ - - Display hook - - Create TOP downloads page - - Plugin requirements : - post_analysis/top_downloads - - Conf values needed : - max_downloads_displayed* - create_all_downloads_page* - - Output files : - OUTPUT_ROOT/year/month/top_downloads.html - OUTPUT_ROOT/year/month/index.html - - Statistics creation : - None - - Statistics update : - None - - Statistics deletion : - None - - plugins.display.all_visits -------------------------- @@ -138,34 +110,6 @@ plugins.display.all_visits None -plugins.display.top_hits ------------------------- - - Display hook - - Create TOP hits page - - Plugin requirements : - post_analysis/top_hits - - Conf values needed : - max_hits_displayed* - create_all_hits_page* - - Output files : - OUTPUT_ROOT/year/month/top_hits.html - OUTPUT_ROOT/year/month/index.html - - Statistics creation : - None - - Statistics update : - None - - Statistics deletion : - None - - plugins.display.referers ------------------------ @@ -251,151 +195,57 @@ plugins.display.top_pages None -plugins.post_analysis.top_downloads ------------------------------------ +plugins.display.top_hits +------------------------ - Post analysis hook + Display hook - Count TOP downloads + Create TOP hits page Plugin requirements : - None + post_analysis/top_hits Conf values needed : - None + max_hits_displayed* + create_all_hits_page* Output files : - None + OUTPUT_ROOT/year/month/top_hits.html + OUTPUT_ROOT/year/month/index.html Statistics creation : None Statistics update : - month_stats: - top_downloads => - uri + None Statistics deletion : None -plugins.post_analysis.top_hits ------------------------------- +plugins.display.top_downloads +----------------------------- - Post analysis hook + Display hook - Count TOP hits + Create TOP downloads page Plugin requirements : - None + post_analysis/top_downloads Conf values needed : - None + max_downloads_displayed* + create_all_downloads_page* Output files : - None + OUTPUT_ROOT/year/month/top_downloads.html + OUTPUT_ROOT/year/month/index.html Statistics creation : None Statistics update : - month_stats: - top_hits => - uri - - Statistics deletion : None - - -plugins.post_analysis.referers ------------------------------- - - Post analysis hook - - Extract referers and key phrases from requests - - Plugin requirements : - None - - Conf values needed : - domain_name - - Output files : - None - - Statistics creation : - None - - Statistics update : - month_stats : - referers => - pages - hits - robots_referers => - pages - hits - search_engine_referers => - pages - hits - key_phrases => - phrase - - Statistics deletion : - None - - -plugins.post_analysis.reverse_dns ---------------------------------- - - Post analysis hook - - Replace IP by reverse DNS names - - Plugin requirements : - None - - Conf values needed : - reverse_dns_timeout* - - Output files : - None - - Statistics creation : - None - - Statistics update : - valid_visitors: - remote_addr - dns_name_replaced - dns_analyzed - - Statistics deletion : - None - - -plugins.post_analysis.top_pages -------------------------------- - - Post analysis hook - - Count TOP pages - - Plugin requirements : - None - - Conf values needed : - None - - Output files : - None - - Statistics creation : - None - - Statistics update : - month_stats: - top_pages => - uri Statistics deletion : None @@ -458,3 +308,153 @@ plugins.pre_analysis.robots None +plugins.post_analysis.referers +------------------------------ + + Post analysis hook + + Extract referers and key phrases from requests + + Plugin requirements : + None + + Conf values needed : + domain_name + + Output files : + None + + Statistics creation : + None + + Statistics update : + month_stats : + referers => + pages + hits + robots_referers => + pages + hits + search_engine_referers => + pages + hits + key_phrases => + phrase + + Statistics deletion : + None + + +plugins.post_analysis.top_pages +------------------------------- + + Post analysis hook + + Count TOP pages + + Plugin requirements : + None + + Conf values needed : + None + + Output files : + None + + Statistics creation : + None + + Statistics update : + month_stats: + top_pages => + uri + + Statistics deletion : + None + + +plugins.post_analysis.reverse_dns +--------------------------------- + + Post analysis hook + + Replace IP by reverse DNS names + + Plugin requirements : + None + + Conf values needed : + reverse_dns_timeout* + + Output files : + None + + Statistics creation : + None + + Statistics update : + valid_visitors: + remote_addr + dns_name_replaced + dns_analyzed + + Statistics deletion : + None + + +plugins.post_analysis.top_hits +------------------------------ + + Post analysis hook + + Count TOP hits + + Plugin requirements : + None + + Conf values needed : + None + + Output files : + None + + Statistics creation : + None + + Statistics update : + month_stats: + top_hits => + uri + + Statistics deletion : + None + + +plugins.post_analysis.top_downloads +----------------------------------- + + Post analysis hook + + Count TOP downloads + + Plugin requirements : + None + + Conf values needed : + None + + Output files : + None + + Statistics creation : + None + + Statistics update : + month_stats: + top_downloads => + uri + + Statistics deletion : + None + + From 2de395c3dd917549f3b9197f67a7d7cde2f27a6f Mon Sep 17 00:00:00 2001 From: Gregory Soutade Date: Mon, 13 Jul 2015 13:30:52 +0200 Subject: [PATCH 3/5] Fix version --- iwla.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iwla.py b/iwla.py index 7e23d3d..57e38f3 100755 --- a/iwla.py +++ b/iwla.py @@ -131,7 +131,7 @@ class IWLA(object): ANALYSIS_CLASS = 'HTTP' API_VERSION = 1 - IWLA_VERSION = '0.2-dev' + IWLA_VERSION = '0.2' def __init__(self, logLevel): self.meta_infos = {} From fdda7a527e467e7e1824789e6379e07b249caea8 Mon Sep 17 00:00:00 2001 From: Gregory Soutade Date: Mon, 2 May 2016 07:54:53 +0200 Subject: [PATCH 4/5] Bug fix : for robots, we have to use not_viewed_pages (feeds plugin) --- plugins/post_analysis/feeds.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/post_analysis/feeds.py b/plugins/post_analysis/feeds.py index 570649f..e90e9e2 100644 --- a/plugins/post_analysis/feeds.py +++ b/plugins/post_analysis/feeds.py @@ -103,7 +103,7 @@ class IWLAPostAnalysisFeeds(IPlugin): isFeedParser = self.FEED_PARSER # Robot that views pages -> bot if hit['robot']: - if hit['viewed_pages']: + if hit['not_viewed_pages']: isFeedParser = self.NOT_A_FEED_PARSER break if self.merge_one_hit_only_feeds_parsers: From 6505246ba41d28908065287eb9581939cf1a8817 Mon Sep 17 00:00:00 2001 From: Gregory Soutade Date: Mon, 2 May 2016 07:56:40 +0200 Subject: [PATCH 5/5] Update ChangeLog --- ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index bd5fd43..20e0327 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +v0.4 (02/05/2016) +** User ** +** Dev ** +** Bugs ** + for robots, we have to use not_viewed_pages (feeds plugin) + v0.3 (12/04/2016) ** User ** Add referers_diff display plugin