summaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--admin/acme.sh/LICENSE674
-rw-r--r--admin/acme.sh/README13
-rw-r--r--admin/acme.sh/haproxy.sh403
-rw-r--r--admin/dyncookie/dyncookie.c56
-rw-r--r--admin/halog/README4
-rw-r--r--admin/halog/fgets2.c267
-rw-r--r--admin/halog/halog.c1915
-rw-r--r--admin/iprange/Makefile13
-rw-r--r--admin/iprange/ip6range.c397
-rw-r--r--admin/iprange/iprange.c202
-rw-r--r--admin/netsnmp-perl/README111
-rw-r--r--admin/netsnmp-perl/cacti_data_query_haproxy_backends.xml750
-rw-r--r--admin/netsnmp-perl/cacti_data_query_haproxy_frontends.xml750
-rw-r--r--admin/netsnmp-perl/haproxy.pl249
-rw-r--r--admin/netsnmp-perl/haproxy_backend.xml83
-rw-r--r--admin/netsnmp-perl/haproxy_frontend.xml83
-rw-r--r--admin/netsnmp-perl/haproxy_socket.xml90
-rw-r--r--admin/release-estimator/README.md68
-rwxr-xr-xadmin/release-estimator/release-estimator.py429
-rw-r--r--admin/selinux/README18
-rw-r--r--admin/selinux/haproxy.fc6
-rw-r--r--admin/selinux/haproxy.if2
-rw-r--r--admin/selinux/haproxy.te66
-rw-r--r--admin/syntax-highlight/haproxy.vim164
-rw-r--r--admin/systemd/Makefile8
-rw-r--r--admin/systemd/haproxy.service.in37
-rw-r--r--admin/wireshark-dissectors/peers/Makefile17
-rw-r--r--admin/wireshark-dissectors/peers/README78
-rw-r--r--admin/wireshark-dissectors/peers/packet-happp.c1679
-rw-r--r--admin/wireshark-dissectors/peers/wireshark.happp.dissector.patch24
30 files changed, 8656 insertions, 0 deletions
diff --git a/admin/acme.sh/LICENSE b/admin/acme.sh/LICENSE
new file mode 100644
index 0000000..f288702
--- /dev/null
+++ b/admin/acme.sh/LICENSE
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
+ 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.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ 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 <https://www.gnu.org/licenses/>.
+
+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:
+
+ <program> Copyright (C) <year> <name of author>
+ 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
+<https://www.gnu.org/licenses/>.
+
+ 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
+<https://www.gnu.org/licenses/why-not-lgpl.html>.
diff --git a/admin/acme.sh/README b/admin/acme.sh/README
new file mode 100644
index 0000000..7f8cef4
--- /dev/null
+++ b/admin/acme.sh/README
@@ -0,0 +1,13 @@
+This directory contains a fork of the acme.sh deploy script for haproxy which
+allow acme.sh to run as non-root and don't require to reload haproxy.
+
+The content of this directory is licensed under GPLv3 as explained in the
+LICENSE file.
+
+This was originally written for this pull request
+https://github.com/acmesh-official/acme.sh/pull/4581.
+
+The documentation is available on the haproxy wiki:
+https://github.com/haproxy/wiki/wiki/Letsencrypt-integration-with-HAProxy-and-acme.sh
+
+The haproxy.sh script must replace the one provided by acme.sh.
diff --git a/admin/acme.sh/haproxy.sh b/admin/acme.sh/haproxy.sh
new file mode 100644
index 0000000..4b6ca0e
--- /dev/null
+++ b/admin/acme.sh/haproxy.sh
@@ -0,0 +1,403 @@
+#!/usr/bin/env sh
+
+# Script for acme.sh to deploy certificates to haproxy
+#
+# The following variables can be exported:
+#
+# export DEPLOY_HAPROXY_PEM_NAME="${domain}.pem"
+#
+# Defines the name of the PEM file.
+# Defaults to "<domain>.pem"
+#
+# export DEPLOY_HAPROXY_PEM_PATH="/etc/haproxy"
+#
+# Defines location of PEM file for HAProxy.
+# Defaults to /etc/haproxy
+#
+# export DEPLOY_HAPROXY_RELOAD="systemctl reload haproxy"
+#
+# OPTIONAL: Reload command used post deploy
+# This defaults to be a no-op (ie "true").
+# It is strongly recommended to set this something that makes sense
+# for your distro.
+#
+# export DEPLOY_HAPROXY_ISSUER="no"
+#
+# OPTIONAL: Places CA file as "${DEPLOY_HAPROXY_PEM}.issuer"
+# Note: Required for OCSP stapling to work
+#
+# export DEPLOY_HAPROXY_BUNDLE="no"
+#
+# OPTIONAL: Deploy this certificate as part of a multi-cert bundle
+# This adds a suffix to the certificate based on the certificate type
+# eg RSA certificates will have .rsa as a suffix to the file name
+# HAProxy will load all certificates and provide one or the other
+# depending on client capabilities
+# Note: This functionality requires HAProxy was compiled against
+# a version of OpenSSL that supports this.
+#
+# export DEPLOY_HAPROXY_HOT_UPDATE="yes"
+# export DEPLOY_HAPROXY_STATS_SOCKET="UNIX:/run/haproxy/admin.sock"
+#
+# OPTIONAL: Deploy the certificate over the HAProxy stats socket without
+# needing to reload HAProxy. Default is "no".
+#
+# Require the socat binary. DEPLOY_HAPROXY_STATS_SOCKET variable uses the socat
+# address format.
+#
+# export DEPLOY_HAPROXY_MASTER_CLI="UNIX:/run/haproxy-master.sock"
+#
+# OPTIONAL: To use the master CLI with DEPLOY_HAPROXY_HOT_UPDATE="yes" instead
+# of a stats socket, use this variable.
+
+######## Public functions #####################
+
+#domain keyfile certfile cafile fullchain
+haproxy_deploy() {
+ _cdomain="$1"
+ _ckey="$2"
+ _ccert="$3"
+ _cca="$4"
+ _cfullchain="$5"
+ _cmdpfx=""
+
+ # Some defaults
+ DEPLOY_HAPROXY_PEM_PATH_DEFAULT="/etc/haproxy"
+ DEPLOY_HAPROXY_PEM_NAME_DEFAULT="${_cdomain}.pem"
+ DEPLOY_HAPROXY_BUNDLE_DEFAULT="no"
+ DEPLOY_HAPROXY_ISSUER_DEFAULT="no"
+ DEPLOY_HAPROXY_RELOAD_DEFAULT="true"
+ DEPLOY_HAPROXY_HOT_UPDATE_DEFAULT="no"
+ DEPLOY_HAPROXY_STATS_SOCKET_DEFAULT="UNIX:/run/haproxy/admin.sock"
+
+ _debug _cdomain "${_cdomain}"
+ _debug _ckey "${_ckey}"
+ _debug _ccert "${_ccert}"
+ _debug _cca "${_cca}"
+ _debug _cfullchain "${_cfullchain}"
+
+ # PEM_PATH is optional. If not provided then assume "${DEPLOY_HAPROXY_PEM_PATH_DEFAULT}"
+ _getdeployconf DEPLOY_HAPROXY_PEM_PATH
+ _debug2 DEPLOY_HAPROXY_PEM_PATH "${DEPLOY_HAPROXY_PEM_PATH}"
+ if [ -n "${DEPLOY_HAPROXY_PEM_PATH}" ]; then
+ Le_Deploy_haproxy_pem_path="${DEPLOY_HAPROXY_PEM_PATH}"
+ _savedomainconf Le_Deploy_haproxy_pem_path "${Le_Deploy_haproxy_pem_path}"
+ elif [ -z "${Le_Deploy_haproxy_pem_path}" ]; then
+ Le_Deploy_haproxy_pem_path="${DEPLOY_HAPROXY_PEM_PATH_DEFAULT}"
+ fi
+
+ # Ensure PEM_PATH exists
+ if [ -d "${Le_Deploy_haproxy_pem_path}" ]; then
+ _debug "PEM_PATH ${Le_Deploy_haproxy_pem_path} exists"
+ else
+ _err "PEM_PATH ${Le_Deploy_haproxy_pem_path} does not exist"
+ return 1
+ fi
+
+ # PEM_NAME is optional. If not provided then assume "${DEPLOY_HAPROXY_PEM_NAME_DEFAULT}"
+ _getdeployconf DEPLOY_HAPROXY_PEM_NAME
+ _debug2 DEPLOY_HAPROXY_PEM_NAME "${DEPLOY_HAPROXY_PEM_NAME}"
+ if [ -n "${DEPLOY_HAPROXY_PEM_NAME}" ]; then
+ Le_Deploy_haproxy_pem_name="${DEPLOY_HAPROXY_PEM_NAME}"
+ _savedomainconf Le_Deploy_haproxy_pem_name "${Le_Deploy_haproxy_pem_name}"
+ elif [ -z "${Le_Deploy_haproxy_pem_name}" ]; then
+ Le_Deploy_haproxy_pem_name="${DEPLOY_HAPROXY_PEM_NAME_DEFAULT}"
+ # We better not have '*' as the first character
+ if [ "${Le_Deploy_haproxy_pem_name%%"${Le_Deploy_haproxy_pem_name#?}"}" = '*' ]; then
+ # removes the first characters and add a _ instead
+ Le_Deploy_haproxy_pem_name="_${Le_Deploy_haproxy_pem_name#?}"
+ fi
+ fi
+
+ # BUNDLE is optional. If not provided then assume "${DEPLOY_HAPROXY_BUNDLE_DEFAULT}"
+ _getdeployconf DEPLOY_HAPROXY_BUNDLE
+ _debug2 DEPLOY_HAPROXY_BUNDLE "${DEPLOY_HAPROXY_BUNDLE}"
+ if [ -n "${DEPLOY_HAPROXY_BUNDLE}" ]; then
+ Le_Deploy_haproxy_bundle="${DEPLOY_HAPROXY_BUNDLE}"
+ _savedomainconf Le_Deploy_haproxy_bundle "${Le_Deploy_haproxy_bundle}"
+ elif [ -z "${Le_Deploy_haproxy_bundle}" ]; then
+ Le_Deploy_haproxy_bundle="${DEPLOY_HAPROXY_BUNDLE_DEFAULT}"
+ fi
+
+ # ISSUER is optional. If not provided then assume "${DEPLOY_HAPROXY_ISSUER_DEFAULT}"
+ _getdeployconf DEPLOY_HAPROXY_ISSUER
+ _debug2 DEPLOY_HAPROXY_ISSUER "${DEPLOY_HAPROXY_ISSUER}"
+ if [ -n "${DEPLOY_HAPROXY_ISSUER}" ]; then
+ Le_Deploy_haproxy_issuer="${DEPLOY_HAPROXY_ISSUER}"
+ _savedomainconf Le_Deploy_haproxy_issuer "${Le_Deploy_haproxy_issuer}"
+ elif [ -z "${Le_Deploy_haproxy_issuer}" ]; then
+ Le_Deploy_haproxy_issuer="${DEPLOY_HAPROXY_ISSUER_DEFAULT}"
+ fi
+
+ # RELOAD is optional. If not provided then assume "${DEPLOY_HAPROXY_RELOAD_DEFAULT}"
+ _getdeployconf DEPLOY_HAPROXY_RELOAD
+ _debug2 DEPLOY_HAPROXY_RELOAD "${DEPLOY_HAPROXY_RELOAD}"
+ if [ -n "${DEPLOY_HAPROXY_RELOAD}" ]; then
+ Le_Deploy_haproxy_reload="${DEPLOY_HAPROXY_RELOAD}"
+ _savedomainconf Le_Deploy_haproxy_reload "${Le_Deploy_haproxy_reload}"
+ elif [ -z "${Le_Deploy_haproxy_reload}" ]; then
+ Le_Deploy_haproxy_reload="${DEPLOY_HAPROXY_RELOAD_DEFAULT}"
+ fi
+
+ # HOT_UPDATE is optional. If not provided then assume "${DEPLOY_HAPROXY_HOT_UPDATE_DEFAULT}"
+ _getdeployconf DEPLOY_HAPROXY_HOT_UPDATE
+ _debug2 DEPLOY_HAPROXY_HOT_UPDATE "${DEPLOY_HAPROXY_HOT_UPDATE}"
+ if [ -n "${DEPLOY_HAPROXY_HOT_UPDATE}" ]; then
+ Le_Deploy_haproxy_hot_update="${DEPLOY_HAPROXY_HOT_UPDATE}"
+ _savedomainconf Le_Deploy_haproxy_hot_update "${Le_Deploy_haproxy_hot_update}"
+ elif [ -z "${Le_Deploy_haproxy_hot_update}" ]; then
+ Le_Deploy_haproxy_hot_update="${DEPLOY_HAPROXY_HOT_UPDATE_DEFAULT}"
+ fi
+
+ # STATS_SOCKET is optional. If not provided then assume "${DEPLOY_HAPROXY_STATS_SOCKET_DEFAULT}"
+ _getdeployconf DEPLOY_HAPROXY_STATS_SOCKET
+ _debug2 DEPLOY_HAPROXY_STATS_SOCKET "${DEPLOY_HAPROXY_STATS_SOCKET}"
+ if [ -n "${DEPLOY_HAPROXY_STATS_SOCKET}" ]; then
+ Le_Deploy_haproxy_stats_socket="${DEPLOY_HAPROXY_STATS_SOCKET}"
+ _savedomainconf Le_Deploy_haproxy_stats_socket "${Le_Deploy_haproxy_stats_socket}"
+ elif [ -z "${Le_Deploy_haproxy_stats_socket}" ]; then
+ Le_Deploy_haproxy_stats_socket="${DEPLOY_HAPROXY_STATS_SOCKET_DEFAULT}"
+ fi
+
+ # MASTER_CLI is optional. No defaults are used. When the master CLI is used,
+ # all commands are sent with a prefix.
+ _getdeployconf DEPLOY_HAPROXY_MASTER_CLI
+ _debug2 DEPLOY_HAPROXY_MASTER_CLI "${DEPLOY_HAPROXY_MASTER_CLI}"
+ if [ -n "${DEPLOY_HAPROXY_MASTER_CLI}" ]; then
+ Le_Deploy_haproxy_stats_socket="${DEPLOY_HAPROXY_MASTER_CLI}"
+ _savedomainconf Le_Deploy_haproxy_stats_socket "${Le_Deploy_haproxy_stats_socket}"
+ _cmdpfx="@1 " # command prefix used for master CLI only.
+ fi
+
+ # Set the suffix depending if we are creating a bundle or not
+ if [ "${Le_Deploy_haproxy_bundle}" = "yes" ]; then
+ _info "Bundle creation requested"
+ # Initialise $Le_Keylength if its not already set
+ if [ -z "${Le_Keylength}" ]; then
+ Le_Keylength=""
+ fi
+ if _isEccKey "${Le_Keylength}"; then
+ _info "ECC key type detected"
+ _suffix=".ecdsa"
+ else
+ _info "RSA key type detected"
+ _suffix=".rsa"
+ fi
+ else
+ _suffix=""
+ fi
+ _debug _suffix "${_suffix}"
+
+ # Set variables for later
+ _pem="${Le_Deploy_haproxy_pem_path}/${Le_Deploy_haproxy_pem_name}${_suffix}"
+ _issuer="${_pem}.issuer"
+ _ocsp="${_pem}.ocsp"
+ _reload="${Le_Deploy_haproxy_reload}"
+ _statssock="${Le_Deploy_haproxy_stats_socket}"
+
+ _info "Deploying PEM file"
+ # Create a temporary PEM file
+ _temppem="$(_mktemp)"
+ _debug _temppem "${_temppem}"
+ cat "${_ccert}" "${_cca}" "${_ckey}" | grep . >"${_temppem}"
+ _ret="$?"
+
+ # Check that we could create the temporary file
+ if [ "${_ret}" != "0" ]; then
+ _err "Error code ${_ret} returned during PEM file creation"
+ [ -f "${_temppem}" ] && rm -f "${_temppem}"
+ return ${_ret}
+ fi
+
+ # Move PEM file into place
+ _info "Moving new certificate into place"
+ _debug _pem "${_pem}"
+ cat "${_temppem}" >"${_pem}"
+ _ret=$?
+
+ # Clean up temp file
+ [ -f "${_temppem}" ] && rm -f "${_temppem}"
+
+ # Deal with any failure of moving PEM file into place
+ if [ "${_ret}" != "0" ]; then
+ _err "Error code ${_ret} returned while moving new certificate into place"
+ return ${_ret}
+ fi
+
+ # Update .issuer file if requested
+ if [ "${Le_Deploy_haproxy_issuer}" = "yes" ]; then
+ _info "Updating .issuer file"
+ _debug _issuer "${_issuer}"
+ cat "${_cca}" >"${_issuer}"
+ _ret="$?"
+
+ if [ "${_ret}" != "0" ]; then
+ _err "Error code ${_ret} returned while copying issuer/CA certificate into place"
+ return ${_ret}
+ fi
+ else
+ [ -f "${_issuer}" ] && _err "Issuer file update not requested but .issuer file exists"
+ fi
+
+ # Update .ocsp file if certificate was requested with --ocsp/--ocsp-must-staple option
+ if [ -z "${Le_OCSP_Staple}" ]; then
+ Le_OCSP_Staple="0"
+ fi
+ if [ "${Le_OCSP_Staple}" = "1" ]; then
+ _info "Updating OCSP stapling info"
+ _debug _ocsp "${_ocsp}"
+ _info "Extracting OCSP URL"
+ _ocsp_url=$(${ACME_OPENSSL_BIN:-openssl} x509 -noout -ocsp_uri -in "${_pem}")
+ _debug _ocsp_url "${_ocsp_url}"
+
+ # Only process OCSP if URL was present
+ if [ "${_ocsp_url}" != "" ]; then
+ # Extract the hostname from the OCSP URL
+ _info "Extracting OCSP URL"
+ _ocsp_host=$(echo "${_ocsp_url}" | cut -d/ -f3)
+ _debug _ocsp_host "${_ocsp_host}"
+
+ # Only process the certificate if we have a .issuer file
+ if [ -r "${_issuer}" ]; then
+ # Check if issuer cert is also a root CA cert
+ _subjectdn=$(${ACME_OPENSSL_BIN:-openssl} x509 -in "${_issuer}" -subject -noout | cut -d'/' -f2,3,4,5,6,7,8,9,10)
+ _debug _subjectdn "${_subjectdn}"
+ _issuerdn=$(${ACME_OPENSSL_BIN:-openssl} x509 -in "${_issuer}" -issuer -noout | cut -d'/' -f2,3,4,5,6,7,8,9,10)
+ _debug _issuerdn "${_issuerdn}"
+ _info "Requesting OCSP response"
+ # If the issuer is a CA cert then our command line has "-CAfile" added
+ if [ "${_subjectdn}" = "${_issuerdn}" ]; then
+ _cafile_argument="-CAfile \"${_issuer}\""
+ else
+ _cafile_argument=""
+ fi
+ _debug _cafile_argument "${_cafile_argument}"
+ # if OpenSSL/LibreSSL is v1.1 or above, the format for the -header option has changed
+ _openssl_version=$(${ACME_OPENSSL_BIN:-openssl} version | cut -d' ' -f2)
+ _debug _openssl_version "${_openssl_version}"
+ _openssl_major=$(echo "${_openssl_version}" | cut -d '.' -f1)
+ _openssl_minor=$(echo "${_openssl_version}" | cut -d '.' -f2)
+ if [ "${_openssl_major}" -eq "1" ] && [ "${_openssl_minor}" -ge "1" ] || [ "${_openssl_major}" -ge "2" ]; then
+ _header_sep="="
+ else
+ _header_sep=" "
+ fi
+ # Request the OCSP response from the issuer and store it
+ _openssl_ocsp_cmd="${ACME_OPENSSL_BIN:-openssl} ocsp \
+ -issuer \"${_issuer}\" \
+ -cert \"${_pem}\" \
+ -url \"${_ocsp_url}\" \
+ -header Host${_header_sep}\"${_ocsp_host}\" \
+ -respout \"${_ocsp}\" \
+ -verify_other \"${_issuer}\" \
+ ${_cafile_argument} \
+ | grep -q \"${_pem}: good\""
+ _debug _openssl_ocsp_cmd "${_openssl_ocsp_cmd}"
+ eval "${_openssl_ocsp_cmd}"
+ _ret=$?
+ else
+ # Non fatal: No issuer file was present so no OCSP stapling file created
+ _err "OCSP stapling in use but no .issuer file was present"
+ fi
+ else
+ # Non fatal: No OCSP url was found int the certificate
+ _err "OCSP update requested but no OCSP URL was found in certificate"
+ fi
+
+ # Non fatal: Check return code of openssl command
+ if [ "${_ret}" != "0" ]; then
+ _err "Updating OCSP stapling failed with return code ${_ret}"
+ fi
+ else
+ # An OCSP file was already present but certificate did not have OCSP extension
+ if [ -f "${_ocsp}" ]; then
+ _err "OCSP was not requested but .ocsp file exists."
+ # Could remove the file at this step, although HAProxy just ignores it in this case
+ # rm -f "${_ocsp}" || _err "Problem removing stale .ocsp file"
+ fi
+ fi
+
+ if [ "${Le_Deploy_haproxy_hot_update}" = "yes" ]; then
+ # set the socket name for messages
+ if [ -n "${_cmdpfx}" ]; then
+ _socketname="master CLI"
+ else
+ _socketname="stats socket"
+ fi
+
+ # Update certificate over HAProxy stats socket or master CLI.
+ if _exists socat; then
+ # look for the certificate on the stats socket, to chose between updating or creating one
+ _socat_cert_cmd="echo '${_cmdpfx}show ssl cert' | socat '${_statssock}' - | grep -q '^${_pem}$'"
+ _debug _socat_cert_cmd "${_socat_cert_cmd}"
+ eval "${_socat_cert_cmd}"
+ _ret=$?
+ if [ "${_ret}" != "0" ]; then
+ _newcert="1"
+ _info "Creating new certificate '${_pem}' over HAProxy ${_socketname}."
+ # certificate wasn't found, it's a new one. We should check if the crt-list exists and creates/inserts the certificate.
+ _socat_crtlist_show_cmd="echo '${_cmdpfx}show ssl crt-list' | socat '${_statssock}' - | grep -q '^${Le_Deploy_haproxy_pem_path}$'"
+ _debug _socat_crtlist_show_cmd "${_socat_crtlist_show_cmd}"
+ eval "${_socat_crtlist_show_cmd}"
+ _ret=$?
+ if [ "${_ret}" != "0" ]; then
+ _err "Couldn't find '${Le_Deploy_haproxy_pem_path}' in haproxy 'show ssl crt-list'"
+ return "${_ret}"
+ fi
+ # create a new certificate
+ _socat_new_cmd="echo '${_cmdpfx}new ssl cert ${_pem}' | socat '${_statssock}' - | grep -q 'New empty'"
+ _debug _socat_new_cmd "${_socat_new_cmd}"
+ eval "${_socat_new_cmd}"
+ _ret=$?
+ if [ "${_ret}" != "0" ]; then
+ _err "Couldn't create '${_pem}' in haproxy"
+ return "${_ret}"
+ fi
+ else
+ _info "Update existing certificate '${_pem}' over HAProxy ${_socketname}."
+ fi
+ _socat_cert_set_cmd="echo -e '${_cmdpfx}set ssl cert ${_pem} <<\n$(cat "${_pem}")\n' | socat '${_statssock}' - | grep -q 'Transaction created'"
+ _debug _socat_cert_set_cmd "${_socat_cert_set_cmd}"
+ eval "${_socat_cert_set_cmd}"
+ _ret=$?
+ if [ "${_ret}" != "0" ]; then
+ _err "Can't update '${_pem}' in haproxy"
+ return "${_ret}"
+ fi
+ _socat_cert_commit_cmd="echo '${_cmdpfx}commit ssl cert ${_pem}' | socat '${_statssock}' - | grep -q '^Success!$'"
+ _debug _socat_cert_commit_cmd "${_socat_cert_commit_cmd}"
+ eval "${_socat_cert_commit_cmd}"
+ _ret=$?
+ if [ "${_ret}" != "0" ]; then
+ _err "Can't commit '${_pem}' in haproxy"
+ return ${_ret}
+ fi
+ if [ "${_newcert}" = "1" ]; then
+ # if this is a new certificate, it needs to be inserted into the crt-list`
+ _socat_cert_add_cmd="echo '${_cmdpfx}add ssl crt-list ${Le_Deploy_haproxy_pem_path} ${_pem}' | socat '${_statssock}' - | grep -q 'Success!'"
+ _debug _socat_cert_add_cmd "${_socat_cert_add_cmd}"
+ eval "${_socat_cert_add_cmd}"
+ _ret=$?
+ if [ "${_ret}" != "0" ]; then
+ _err "Can't update '${_pem}' in haproxy"
+ return "${_ret}"
+ fi
+ fi
+ else
+ _err "'socat' is not available, couldn't update over ${_socketname}"
+ fi
+ else
+ # Reload HAProxy
+ _debug _reload "${_reload}"
+ eval "${_reload}"
+ _ret=$?
+ if [ "${_ret}" != "0" ]; then
+ _err "Error code ${_ret} during reload"
+ return ${_ret}
+ else
+ _info "Reload successful"
+ fi
+ fi
+
+ return 0
+}
diff --git a/admin/dyncookie/dyncookie.c b/admin/dyncookie/dyncookie.c
new file mode 100644
index 0000000..ddb71a7
--- /dev/null
+++ b/admin/dyncookie/dyncookie.c
@@ -0,0 +1,56 @@
+/*
+ * Dynamic server cookie calculator
+ *
+ * Copyright 2021 Willy Tarreau <w@1wt.eu>
+ *
+ * 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
+ * 2 of the License, or (at your option) any later version.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <arpa/inet.h>
+
+#include <haproxy/xxhash.h>
+
+__attribute__((noreturn)) void die(int code, const char *format, ...)
+{
+ va_list args;
+
+ va_start(args, format);
+ vfprintf(stderr, format, args);
+ va_end(args);
+ exit(code);
+}
+
+int main(int argc, char **argv)
+{
+ size_t key_len;
+ int addr_len;
+ char *buf;
+ int port;
+
+ if (argc < 4)
+ die(1, "Usage: %s <key> <ip> <port>\n", argv[0]);
+
+ key_len = strlen(argv[1]);
+ buf = realloc(strdup(argv[1]), key_len + 16 + 4);
+ if (!buf)
+ die(2, "Not enough memory\n");
+
+ if (inet_pton(AF_INET, argv[2], buf + key_len) > 0)
+ addr_len = 4;
+ else if (inet_pton(AF_INET6, argv[2], buf + key_len) > 0)
+ addr_len = 16;
+ else
+ die(3, "Cannot parse address <%s> as IPv4/IPv6\n", argv[2]);
+
+ port = htonl(atoi(argv[3]));
+ memcpy(buf + key_len + addr_len, &port, 4);
+ printf("%016llx\n", (long long)XXH64(buf, key_len + addr_len + 4, 0));
+ return 0;
+}
diff --git a/admin/halog/README b/admin/halog/README
new file mode 100644
index 0000000..ff1bb12
--- /dev/null
+++ b/admin/halog/README
@@ -0,0 +1,4 @@
+This needs to be built from the top makefile, for example :
+
+ make admin/halog/halog
+
diff --git a/admin/halog/fgets2.c b/admin/halog/fgets2.c
new file mode 100644
index 0000000..7fbe16b
--- /dev/null
+++ b/admin/halog/fgets2.c
@@ -0,0 +1,267 @@
+/*
+ * fast fgets() replacement for log parsing
+ *
+ * Copyright 2000-2012 Willy Tarreau <w@1wt.eu>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, version 2.1
+ * exclusively.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * This function manages its own buffer and returns a pointer to that buffer
+ * in order to avoid expensive memory copies. It also checks for line breaks
+ * 32 or 64 bits at a time. It could be improved a lot using mmap() but we
+ * would not be allowed to replace trailing \n with zeroes and we would be
+ * limited to small log files on 32-bit machines.
+ *
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#ifndef FGETS2_BUFSIZE
+#define FGETS2_BUFSIZE (256*1024)
+#endif
+
+/* memchr() is faster in glibc with SSE since commit 093ecf92998de2 */
+#if defined(__x86_64__) && defined(__GLIBC__) && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 15))
+#define USE_MEMCHR
+#endif
+
+/* return non-zero if the integer contains at least one zero byte */
+static inline __attribute__((unused)) unsigned int has_zero32(unsigned int x)
+{
+ unsigned int y;
+
+ /* Principle: we want to perform 4 tests on one 32-bit int at once. For
+ * this, we have to simulate an SIMD instruction which we don't have by
+ * default. The principle is that a zero byte is the only one which
+ * will cause a 1 to appear on the upper bit of a byte/word/etc... when
+ * we subtract 1. So we can detect a zero byte if a one appears at any
+ * of the bits 7, 15, 23 or 31 where it was not. It takes only one
+ * instruction to test for the presence of any of these bits, but it is
+ * still complex to check for their initial absence. Thus, we'll
+ * proceed differently : we first save and clear only those bits, then
+ * we check in the final result if one of them is present and was not.
+ * The order of operations below is important to save registers and
+ * tests. The result is used as a boolean, so the last test must apply
+ * on the constant so that it can efficiently be inlined.
+ */
+#if defined(__i386__)
+ /* gcc on x86 loves copying registers over and over even on code that
+ * simple, so let's do it by hand to prevent it from doing so :-(
+ */
+ asm("lea -0x01010101(%0),%1\n"
+ "not %0\n"
+ "and %1,%0\n"
+ : "=a" (x), "=r"(y)
+ : "0" (x)
+ );
+ return x & 0x80808080;
+#else
+ y = x - 0x01010101; /* generate a carry */
+ x = ~x & y; /* clear the bits that were already set */
+ return x & 0x80808080;
+#endif
+}
+
+/* return non-zero if the argument contains at least one zero byte. See principle above. */
+static inline __attribute__((unused)) unsigned long long has_zero64(unsigned long long x)
+{
+ unsigned long long y;
+
+ y = x - 0x0101010101010101ULL; /* generate a carry */
+ y &= ~x; /* clear the bits that were already set */
+ return y & 0x8080808080808080ULL;
+}
+
+static inline __attribute__((unused)) unsigned long has_zero(unsigned long x)
+{
+ return (sizeof(x) == 8) ? has_zero64(x) : has_zero32(x);
+}
+
+/* find a '\n' between <next> and <end>. Warning: may read slightly past <end>.
+ * If no '\n' is found, <end> is returned.
+ */
+static char *find_lf(char *next, char *end)
+{
+#if defined USE_MEMCHR
+ /* some recent libc use platform-specific optimizations to provide more
+ * efficient byte search than below (eg: glibc 2.11 on x86_64).
+ */
+ next = memchr(next, '\n', end - next);
+ if (!next)
+ next = end;
+#else
+ if (sizeof(long) == 4) { /* 32-bit system */
+ /* this is a speed-up, we read 32 bits at once and check for an
+ * LF character there. We stop if found then continue one at a
+ * time.
+ */
+ while (next < end && (((unsigned long)next) & 3) && *next != '\n')
+ next++;
+
+ /* Now next is multiple of 4 or equal to end. We know we can safely
+ * read up to 32 bytes past end if needed because they're allocated.
+ */
+ while (next < end) {
+ if (has_zero32(*(unsigned int *)next ^ 0x0A0A0A0A))
+ break;
+ next += 4;
+ if (has_zero32(*(unsigned int *)next ^ 0x0A0A0A0A))
+ break;
+ next += 4;
+ if (has_zero32(*(unsigned int *)next ^ 0x0A0A0A0A))
+ break;
+ next += 4;
+ if (has_zero32(*(unsigned int *)next ^ 0x0A0A0A0A))
+ break;
+ next += 4;
+ if (has_zero32(*(unsigned int *)next ^ 0x0A0A0A0A))
+ break;
+ next += 4;
+ if (has_zero32(*(unsigned int *)next ^ 0x0A0A0A0A))
+ break;
+ next += 4;
+ if (has_zero32(*(unsigned int *)next ^ 0x0A0A0A0A))
+ break;
+ next += 4;
+ if (has_zero32(*(unsigned int *)next ^ 0x0A0A0A0A))
+ break;
+ next += 4;
+ }
+ }
+ else { /* 64-bit system */
+ /* this is a speed-up, we read 64 bits at once and check for an
+ * LF character there. We stop if found then continue one at a
+ * time.
+ */
+ if (next <= end) {
+ /* max 3 bytes tested here */
+ while ((((unsigned long)next) & 3) && *next != '\n')
+ next++;
+
+ /* maybe we have can skip 4 more bytes */
+ if ((((unsigned long)next) & 4) && !has_zero32(*(unsigned int *)next ^ 0x0A0A0A0AU))
+ next += 4;
+ }
+
+ /* now next is multiple of 8 or equal to end */
+ while (next <= (end-68)) {
+ if (has_zero64(*(unsigned long long *)next ^ 0x0A0A0A0A0A0A0A0AULL))
+ break;
+ next += 8;
+ if (has_zero64(*(unsigned long long *)next ^ 0x0A0A0A0A0A0A0A0AULL))
+ break;
+ next += 8;
+ if (has_zero64(*(unsigned long long *)next ^ 0x0A0A0A0A0A0A0A0AULL))
+ break;
+ next += 8;
+ if (has_zero64(*(unsigned long long *)next ^ 0x0A0A0A0A0A0A0A0AULL))
+ break;
+ next += 8;
+ if (has_zero64(*(unsigned long long *)next ^ 0x0A0A0A0A0A0A0A0AULL))
+ break;
+ next += 8;
+ if (has_zero64(*(unsigned long long *)next ^ 0x0A0A0A0A0A0A0A0AULL))
+ break;
+ next += 8;
+ if (has_zero64(*(unsigned long long *)next ^ 0x0A0A0A0A0A0A0A0AULL))
+ break;
+ next += 8;
+ if (has_zero64(*(unsigned long long *)next ^ 0x0A0A0A0A0A0A0A0AULL))
+ break;
+ next += 8;
+ }
+
+ /* maybe we can skip 4 more bytes */
+ if (!has_zero32(*(unsigned int *)next ^ 0x0A0A0A0AU))
+ next += 4;
+ }
+
+ /* We finish if needed : if <next> is below <end>, it means we
+ * found an LF in one of the 4 following bytes.
+ */
+ while (next < end) {
+ if (*next == '\n')
+ break;
+ next++;
+ }
+#endif
+ return next;
+}
+
+const char *fgets2(FILE *stream)
+{
+ static char buffer[FGETS2_BUFSIZE + 68]; /* Note: +32 is enough on 32-bit systems */
+ static char *end = buffer;
+ static char *line = buffer;
+ char *next;
+ int ret;
+
+ next = line;
+
+ while (1) {
+ next = find_lf(next, end);
+ if (next < end) {
+ const char *start = line;
+ *next = '\0';
+ line = next + 1;
+ return start;
+ }
+
+ /* we found an incomplete line. First, let's move the
+ * remaining part of the buffer to the beginning, then
+ * try to complete the buffer with a new read. We can't
+ * rely on <next> anymore because it went past <end>.
+ */
+ if (line > buffer) {
+ if (end != line)
+ memmove(buffer, line, end - line);
+ end = buffer + (end - line);
+ next = end;
+ line = buffer;
+ } else {
+ if (end == buffer + FGETS2_BUFSIZE)
+ return NULL;
+ }
+
+ ret = read(fileno(stream), end, buffer + FGETS2_BUFSIZE - end);
+
+ if (ret <= 0) {
+ if (end == line)
+ return NULL;
+
+ *end = '\0';
+ end = line; /* ensure we stop next time */
+ return line;
+ }
+
+ end += ret;
+ *end = '\n'; /* make parser stop ASAP */
+ /* search for '\n' again */
+ }
+}
+
+#ifdef BENCHMARK
+int main() {
+ const char *p;
+ unsigned int lines = 0;
+
+ while ((p=fgets2(stdin)))
+ lines++;
+ printf("lines=%u\n", lines);
+ return 0;
+}
+#endif
diff --git a/admin/halog/halog.c b/admin/halog/halog.c
new file mode 100644
index 0000000..884a606
--- /dev/null
+++ b/admin/halog/halog.c
@@ -0,0 +1,1915 @@
+/*
+ * haproxy log statistics reporter
+ *
+ * Copyright 2000-2012 Willy Tarreau <w@1wt.eu>
+ *
+ * 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
+ * 2 of the License, or (at your option) any later version.
+ *
+ */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <syslog.h>
+#include <string.h>
+#include <unistd.h>
+#include <ctype.h>
+#include <time.h>
+
+#include <haproxy/compiler.h>
+
+#include <import/eb32tree.h>
+#include <import/eb64tree.h>
+#include <import/ebistree.h>
+#include <import/ebsttree.h>
+
+#define SOURCE_FIELD 5
+#define ACCEPT_FIELD 6
+#define SERVER_FIELD 8
+#define TIME_FIELD 9
+#define STATUS_FIELD 10
+#define BYTES_SENT_FIELD 11
+#define TERM_CODES_FIELD 14
+#define CONN_FIELD 15
+#define QUEUE_LEN_FIELD 16
+#define METH_FIELD 17
+#define URL_FIELD 18
+#define MAXLINE 16384
+#define QBITS 4
+
+#define SEP(c) ((unsigned char)(c) <= ' ')
+#define SKIP_CHAR(p,c) do { while (1) { int __c = (unsigned char)*p++; if (__c == c) break; if (__c <= ' ') { p--; break; } } } while (0)
+
+/* [0] = err/date, [1] = req, [2] = conn, [3] = resp, [4] = data */
+static struct eb_root timers[5] = {
+ EB_ROOT_UNIQUE, EB_ROOT_UNIQUE, EB_ROOT_UNIQUE,
+ EB_ROOT_UNIQUE, EB_ROOT_UNIQUE,
+};
+
+struct timer {
+ struct eb32_node node;
+ unsigned int count;
+};
+
+struct srv_st {
+ unsigned int st_cnt[6]; /* 0xx to 5xx */
+ unsigned int nb_ct, nb_rt, nb_ok;
+ unsigned long long cum_ct, cum_rt;
+ struct ebmb_node node;
+ /* don't put anything else here, the server name will be there */
+};
+
+struct url_stat {
+ union {
+ struct ebpt_node url;
+ struct eb64_node val;
+ } node;
+ char *url;
+ unsigned long long total_time; /* sum(all reqs' times) */
+ unsigned long long total_time_ok; /* sum(all OK reqs' times) */
+ unsigned long long total_bytes_sent; /* sum(all bytes sent) */
+ unsigned int nb_err, nb_req;
+};
+
+#define FILT_COUNT_ONLY 0x01
+#define FILT_INVERT 0x02
+#define FILT_QUIET 0x04
+#define FILT_ERRORS_ONLY 0x08
+#define FILT_ACC_DELAY 0x10
+#define FILT_ACC_COUNT 0x20
+#define FILT_GRAPH_TIMERS 0x40
+#define FILT_PERCENTILE 0x80
+#define FILT_TIME_RESP 0x100
+
+#define FILT_INVERT_ERRORS 0x200
+#define FILT_INVERT_TIME_RESP 0x400
+
+#define FILT_COUNT_STATUS 0x800
+#define FILT_COUNT_SRV_STATUS 0x1000
+#define FILT_COUNT_TERM_CODES 0x2000
+
+#define FILT_COUNT_URL_ONLY 0x004000
+#define FILT_COUNT_URL_COUNT 0x008000
+#define FILT_COUNT_URL_ERR 0x010000
+#define FILT_COUNT_URL_TTOT 0x020000
+#define FILT_COUNT_URL_TAVG 0x040000
+#define FILT_COUNT_URL_TTOTO 0x080000
+#define FILT_COUNT_URL_TAVGO 0x100000
+
+#define FILT_HTTP_ONLY 0x200000
+#define FILT_TERM_CODE_NAME 0x400000
+#define FILT_INVERT_TERM_CODE_NAME 0x800000
+
+#define FILT_HTTP_STATUS 0x1000000
+#define FILT_INVERT_HTTP_STATUS 0x2000000
+#define FILT_QUEUE_ONLY 0x4000000
+#define FILT_QUEUE_SRV_ONLY 0x8000000
+
+#define FILT_COUNT_URL_BAVG 0x10000000
+#define FILT_COUNT_URL_BTOT 0x20000000
+
+#define FILT_COUNT_URL_ANY (FILT_COUNT_URL_ONLY|FILT_COUNT_URL_COUNT|FILT_COUNT_URL_ERR| \
+ FILT_COUNT_URL_TTOT|FILT_COUNT_URL_TAVG|FILT_COUNT_URL_TTOTO|FILT_COUNT_URL_TAVGO| \
+ FILT_COUNT_URL_BAVG|FILT_COUNT_URL_BTOT)
+
+#define FILT_COUNT_COOK_CODES 0x40000000
+#define FILT_COUNT_IP_COUNT 0x80000000
+
+#define FILT2_TIMESTAMP 0x01
+#define FILT2_PRESERVE_QUERY 0x02
+#define FILT2_EXTRACT_CAPTURE 0x04
+
+unsigned int filter = 0;
+unsigned int filter2 = 0;
+unsigned int filter_invert = 0;
+const char *line;
+int linenum = 0;
+int parse_err = 0;
+int lines_out = 0;
+int lines_max = -1;
+
+const char *fgets2(FILE *stream);
+
+void filter_count_url(const char *accept_field, const char *time_field, struct timer **tptr);
+void filter_count_ip(const char *source_field, const char *accept_field, const char *time_field, struct timer **tptr);
+void filter_count_srv_status(const char *accept_field, const char *time_field, struct timer **tptr);
+void filter_count_cook_codes(const char *accept_field, const char *time_field, struct timer **tptr);
+void filter_count_term_codes(const char *accept_field, const char *time_field, struct timer **tptr);
+void filter_count_status(const char *accept_field, const char *time_field, struct timer **tptr);
+void filter_graphs(const char *accept_field, const char *time_field, struct timer **tptr);
+void filter_output_line(const char *accept_field, const char *time_field, struct timer **tptr);
+void filter_extract_capture(const char *accept_field, const char *time_field, unsigned int, unsigned int);
+void filter_accept_holes(const char *accept_field, const char *time_field, struct timer **tptr);
+
+void usage(FILE *output, const char *msg)
+{
+ fprintf(output,
+ "%s"
+ "Usage:\n"
+ " halog [-h|--help] for long help\n"
+ " halog [input_filters]* [modifiers]* [output_format] < log\n"
+ " inp = [-e|-E] [-H] [-Q|-QS] [-rt|-RT <time>] [-ad <delay>] [-ac <count>]\n"
+ " [-hs|-HS [min][:[max]]] [-tcn|-TCN <termcode>] [-time [min][:[max]]]\n"
+ " mod = [-q] [-v] [-m <lines>] [-s <skipflds>] [-query]\n"
+ " out = {-c|-u|-uc|-ue|-ua|-ut|-uao|-uto|-uba|-ubt|-hdr <block>:<field>|\n"
+ " -cc|-gt|-pct|-st|-tc|-srv|-ic}\n"
+ "\n",
+ msg ? msg : ""
+ );
+}
+
+void die(const char *msg)
+{
+ usage(stderr, msg);
+ exit(1);
+}
+
+void help()
+{
+ usage(stdout, NULL);
+ printf(
+ "Input filters - several filters may be combined\n"
+ " -H only match lines containing HTTP logs (ignore TCP)\n"
+ " -E only match lines without any error (no 5xx status)\n"
+ " -e only match lines with errors (status 5xx or negative)\n"
+ " -rt|-RT <time> only match response times larger|smaller than <time>\n"
+ " -Q|-QS only match queued requests (any queue|server queue)\n"
+ " -tcn|-TCN <code> only match requests with/without termination code <code>\n"
+ " -hs|-HS <[min][:][max]> only match requests with HTTP status codes within/not\n"
+ " within min..max. Any of them may be omitted. Exact\n"
+ " code is checked for if no ':' is specified.\n"
+ " -time <[min][:max]> only match requests recorded between timestamps.\n"
+ " Any of them may be omitted.\n"
+ "Modifiers\n"
+ " -v invert the input filtering condition\n"
+ " -q don't report errors/warnings\n"
+ " -m <lines> limit output to the first <lines> lines\n"
+ " -s <skip_n_fields> skip n fields from the beginning of a line (default %d)\n"
+ " you can also use -n to start from earlier then field %d\n"
+ " -query preserve the query string for per-URL (-u*) statistics\n"
+ "\n"
+ "Output format - only one may be used at a time\n"
+ " -c only report the number of lines that would have been printed\n"
+ " -pct output connect and response times percentiles\n"
+ " -st output number of requests per HTTP status code\n"
+ " -cc output number of requests per cookie code (2 chars)\n"
+ " -tc output number of requests per termination code (2 chars)\n"
+ " -srv output statistics per server (time, requests, errors)\n"
+ " -ic output statistics per ip count (time, requests, errors)\n"
+ " -u* output statistics per URL (time, requests, errors)\n"
+ " Additional characters indicate the output sorting key :\n"
+ " -u : by URL, -uc : request count, -ue : error count\n"
+ " -ua : average response time, -ut : average total time\n"
+ " -uao, -uto: average times computed on valid ('OK') requests\n"
+ " -uba, -ubt: average bytes returned, total bytes returned\n"
+ " -hdr output captured header at the given <block>:<field>\n"
+ " -ac <count> -ad <delay>:\n"
+ " Report periods corresponding to a grouped accept of <count> requests at\n"
+ " the same millisecond after a delay of at least <ad> milliseconds with no\n"
+ " incoming accept (used to spot network outages). Output format contains:\n"
+ " <accept_date> <date_ms> <delta_ms from previous one> <nb_entries>\n",
+ (int)SOURCE_FIELD, (int)SOURCE_FIELD
+ );
+ exit(0);
+}
+
+
+/* return pointer to first char not part of current field starting at <p>. */
+
+#if defined(__i386__)
+/* this one is always faster on 32-bits */
+static inline const char *field_stop(const char *p)
+{
+ asm(
+ /* Look for spaces */
+ "4: \n\t"
+ "inc %0 \n\t"
+ "cmpb $0x20, -1(%0) \n\t"
+ "ja 4b \n\t"
+ "jz 3f \n\t"
+
+ /* we only get there for control chars 0..31. Leave if we find '\0' */
+ "cmpb $0x0, -1(%0) \n\t"
+ "jnz 4b \n\t"
+
+ /* return %0-1 = position of the last char we checked */
+ "3: \n\t"
+ "dec %0 \n\t"
+ : "=r" (p)
+ : "0" (p)
+ );
+ return p;
+}
+#else
+const char *field_stop(const char *p)
+{
+ unsigned char c;
+
+ while (1) {
+ c = *(p++);
+ if (c > ' ')
+ continue;
+ if (c == ' ' || c == 0)
+ break;
+ }
+ return p - 1;
+}
+#endif
+
+/* return non-zero if the argument contains at least one zero byte. See principle above. */
+static inline __attribute__((unused)) unsigned long long has_zero64(unsigned long long x)
+{
+ unsigned long long y;
+
+ y = x - 0x0101010101010101ULL; /* generate a carry */
+ y &= ~x; /* clear the bits that were already set */
+ return y & 0x8080808080808080ULL;
+}
+
+/* return field <field> (starting from 1) in string <p>. Only consider
+ * contiguous spaces (or tabs) as one delimiter. May return pointer to
+ * last char if field is not found. Equivalent to awk '{print $field}'.
+ */
+const char *field_start(const char *p, int field)
+{
+#ifndef PREFER_ASM
+ unsigned char c;
+ while (1) {
+ /* skip spaces */
+ while (1) {
+ c = *(p++);
+ if (!c) /* end of line */
+ return p-1;
+ if (c == ' ')
+ continue;
+ /* other char => new field */
+ break;
+ }
+
+ /* start of field */
+ field--;
+ if (!field)
+ return p-1;
+
+ /* skip this field */
+ while (1) {
+#if defined(HA_UNALIGNED_LE64)
+ unsigned long long l = *(unsigned long long *)p;
+ if (!has_zero64(l)) {
+ l ^= 0x2020202020202020;
+ l = has_zero64(l);
+ if (!l) {
+ p += 8;
+ continue;
+ }
+ /* there is at least one space, find it and
+ * skip it now. The lowest byte in <l> with
+ * a 0x80 is the right one, but checking for
+ * it remains slower than testing each byte,
+ * probably due to the numerous short fields.
+ */
+ while (*(p++) != ' ')
+ ;
+ break;
+ }
+#endif
+ c = *(p++);
+ if (c == '\0')
+ return p - 1;
+ if (c == ' ')
+ break;
+ }
+ }
+#else
+ /* This version works optimally on i386 and x86_64 but the code above
+ * shows similar performance. However, depending on the version of GCC
+ * used, inlining rules change and it may have difficulties to make
+ * efficient use of this code at other locations and could result in
+ * worse performance (eg: gcc 4.4). You may want to experience.
+ */
+ asm(
+ /* skip spaces */
+ "1: \n\t"
+ "inc %0 \n\t"
+ "cmpb $0x20, -1(%0) \n\t"
+ "ja 2f \n\t"
+ "jz 1b \n\t"
+
+ /* we only get there for control chars 0..31. Leave if we find '\0' */
+ "cmpb $0x0, -1(%0) \n\t"
+ "jz 3f \n\t"
+
+ /* start of field at [%0-1]. Check if we need to skip more fields */
+ "2: \n\t"
+ "dec %1 \n\t"
+ "jz 3f \n\t"
+
+ /* Look for spaces */
+ "4: \n\t"
+ "inc %0 \n\t"
+ "cmpb $0x20, -1(%0) \n\t"
+ "jz 1b \n\t"
+ "ja 4b \n\t"
+
+ /* we only get there for control chars 0..31. Leave if we find '\0' */
+ "cmpb $0x0, -1(%0) \n\t"
+ "jnz 4b \n\t"
+
+ /* return %0-1 = position of the last char we checked */
+ "3: \n\t"
+ "dec %0 \n\t"
+ : "=r" (p)
+ : "r" (field), "0" (p)
+ );
+ return p;
+#endif
+}
+
+/* keep only the <bits> higher bits of <i> */
+static inline unsigned int quantify_u32(unsigned int i, int bits)
+{
+ int high;
+
+ if (!bits)
+ return 0;
+
+ if (i)
+ high = fls_auto(i); // 1 to 32
+ else
+ high = 0;
+
+ if (high <= bits)
+ return i;
+
+ return i & ~((1 << (high - bits)) - 1);
+}
+
+/* keep only the <bits> higher bits of the absolute value of <i>, as well as
+ * its sign. */
+static inline int quantify(int i, int bits)
+{
+ if (i >= 0)
+ return quantify_u32(i, bits);
+ else
+ return -quantify_u32(-i, bits);
+}
+
+/* Insert timer value <v> into tree <r>. A pre-allocated node must be passed
+ * in <alloc>. It may be NULL, in which case the function will allocate it
+ * itself. It will be reset to NULL once consumed. The caller is responsible
+ * for freeing the node once not used anymore. The node where the value was
+ * inserted is returned.
+ */
+struct timer *insert_timer(struct eb_root *r, struct timer **alloc, int v)
+{
+ struct timer *t = *alloc;
+ struct eb32_node *n;
+
+ if (!t) {
+ t = calloc(1, sizeof(*t));
+ if (unlikely(!t)) {
+ fprintf(stderr, "%s: not enough memory\n", __FUNCTION__);
+ exit(1);
+ }
+ }
+ t->node.key = quantify(v, QBITS); // keep only the higher QBITS bits
+
+ n = eb32i_insert(r, &t->node);
+ if (n == &t->node)
+ t = NULL; /* node inserted, will malloc next time */
+
+ *alloc = t;
+ return container_of(n, struct timer, node);
+}
+
+/* Insert value value <v> into tree <r>. A pre-allocated node must be passed
+ * in <alloc>. It may be NULL, in which case the function will allocate it
+ * itself. It will be reset to NULL once consumed. The caller is responsible
+ * for freeing the node once not used anymore. The node where the value was
+ * inserted is returned.
+ */
+struct timer *insert_value(struct eb_root *r, struct timer **alloc, int v)
+{
+ struct timer *t = *alloc;
+ struct eb32_node *n;
+
+ if (!t) {
+ t = calloc(1, sizeof(*t));
+ if (unlikely(!t)) {
+ fprintf(stderr, "%s: not enough memory\n", __FUNCTION__);
+ exit(1);
+ }
+ }
+ t->node.key = v;
+
+ n = eb32i_insert(r, &t->node);
+ if (n == &t->node)
+ t = NULL; /* node inserted, will malloc next time */
+
+ *alloc = t;
+ return container_of(n, struct timer, node);
+}
+
+int str2ic(const char *s)
+{
+ int i = 0;
+ int j, k;
+
+ if (*s != '-') {
+ /* positive number */
+ while (1) {
+ j = (*s++) - '0';
+ k = i * 10;
+ if ((unsigned)j > 9)
+ break;
+ i = k + j;
+ }
+ } else {
+ /* negative number */
+ s++;
+ while (1) {
+ j = (*s++) - '0';
+ k = i * 10;
+ if ((unsigned)j > 9)
+ break;
+ i = k - j;
+ }
+ }
+
+ return i;
+}
+
+
+/* Convert "[04/Dec/2008:09:49:40.555]" to an integer equivalent to the time of
+ * the day in milliseconds. It returns -1 for all unparsable values. The parser
+ * looks ugly but gcc emits far better code that way.
+ */
+int convert_date(const char *field)
+{
+ unsigned int h, m, s, ms;
+ unsigned char c;
+ const char *e;
+
+ h = m = s = ms = 0;
+ e = field;
+
+ /* skip the date */
+ while (1) {
+ c = *(e++);
+ if (c == ':')
+ break;
+ if (!c)
+ goto out_err;
+ }
+
+ /* hour + ':' */
+ while (1) {
+ c = *(e++) - '0';
+ if (c > 9)
+ break;
+ h = h * 10 + c;
+ }
+ if (c == (unsigned char)(0 - '0'))
+ goto out_err;
+
+ /* minute + ':' */
+ while (1) {
+ c = *(e++) - '0';
+ if (c > 9)
+ break;
+ m = m * 10 + c;
+ }
+ if (c == (unsigned char)(0 - '0'))
+ goto out_err;
+
+ /* second + '.' or ']' */
+ while (1) {
+ c = *(e++) - '0';
+ if (c > 9)
+ break;
+ s = s * 10 + c;
+ }
+ if (c == (unsigned char)(0 - '0'))
+ goto out_err;
+
+ /* if there's a '.', we have milliseconds */
+ if (c == (unsigned char)('.' - '0')) {
+ /* millisecond second + ']' */
+ while (1) {
+ c = *(e++) - '0';
+ if (c > 9)
+ break;
+ ms = ms * 10 + c;
+ }
+ if (c == (unsigned char)(0 - '0'))
+ goto out_err;
+ }
+ return (((h * 60) + m) * 60 + s) * 1000 + ms;
+ out_err:
+ return -1;
+}
+
+/* Convert "[04/Dec/2008:09:49:40.555]" to an unix timestamp.
+ * It returns -1 for all unparsable values. The parser
+ * looks ugly but gcc emits far better code that way.
+ */
+int convert_date_to_timestamp(const char *field)
+{
+ unsigned int d, mo, y, h, m, s;
+ unsigned char c;
+ const char *e;
+ time_t rawtime;
+ static struct tm * timeinfo;
+ static int last_res;
+
+ d = mo = y = h = m = s = 0;
+ e = field;
+
+ e++; // remove '['
+
+ /* day + '/' */
+ while (1) {
+ c = *(e++) - '0';
+ if (c > 9)
+ break;
+ d = d * 10 + c;
+ if (c == (unsigned char)(0 - '0'))
+ goto out_err;
+ }
+
+ /* month + '/' */
+ c = *(e++);
+ if (c =='F') {
+ mo = 2;
+ e = e+3;
+ } else if (c =='S') {
+ mo = 9;
+ e = e+3;
+ } else if (c =='O') {
+ mo = 10;
+ e = e+3;
+ } else if (c =='N') {
+ mo = 11;
+ e = e+3;
+ } else if (c == 'D') {
+ mo = 12;
+ e = e+3;
+ } else if (c == 'A') {
+ c = *(e++);
+ if (c == 'p') {
+ mo = 4;
+ e = e+2;
+ } else if (c == 'u') {
+ mo = 8;
+ e = e+2;
+ } else
+ goto out_err;
+ } else if (c == 'J') {
+ c = *(e++);
+ if (c == 'a') {
+ mo = 1;
+ e = e+2;
+ } else if (c == 'u') {
+ c = *(e++);
+ if (c == 'n') {
+ mo = 6;
+ e = e+1;
+ } else if (c == 'l') {
+ mo = 7;
+ e++;
+ }
+ } else
+ goto out_err;
+ } else if (c == 'M') {
+ e++;
+ c = *(e++);
+ if (c == 'r') {
+ mo = 3;
+ e = e+1;
+ } else if (c == 'y') {
+ mo = 5;
+ e = e+1;
+ } else
+ goto out_err;
+ } else
+ goto out_err;
+
+ /* year + ':' */
+ while (1) {
+ c = *(e++) - '0';
+ if (c > 9)
+ break;
+ y = y * 10 + c;
+ if (c == (unsigned char)(0 - '0'))
+ goto out_err;
+ }
+
+ /* hour + ':' */
+ while (1) {
+ c = *(e++) - '0';
+ if (c > 9)
+ break;
+ h = h * 10 + c;
+ }
+ if (c == (unsigned char)(0 - '0'))
+ goto out_err;
+
+ /* minute + ':' */
+ while (1) {
+ c = *(e++) - '0';
+ if (c > 9)
+ break;
+ m = m * 10 + c;
+ }
+ if (c == (unsigned char)(0 - '0'))
+ goto out_err;
+
+ /* second + '.' or ']' */
+ while (1) {
+ c = *(e++) - '0';
+ if (c > 9)
+ break;
+ s = s * 10 + c;
+ }
+
+ if (likely(timeinfo)) {
+ if ((unsigned)timeinfo->tm_min == m &&
+ (unsigned)timeinfo->tm_hour == h &&
+ (unsigned)timeinfo->tm_mday == d &&
+ (unsigned)timeinfo->tm_mon == mo - 1 &&
+ (unsigned)timeinfo->tm_year == y - 1900)
+ return last_res + s;
+ }
+ else {
+ time(&rawtime);
+ timeinfo = localtime(&rawtime);
+ }
+
+ timeinfo->tm_sec = 0;
+ timeinfo->tm_min = m;
+ timeinfo->tm_hour = h;
+ timeinfo->tm_mday = d;
+ timeinfo->tm_mon = mo - 1;
+ timeinfo->tm_year = y - 1900;
+ last_res = mktime(timeinfo);
+
+ return last_res + s;
+ out_err:
+ return -1;
+}
+
+void truncated_line(int linenum, const char *line)
+{
+ if (!(filter & FILT_QUIET))
+ fprintf(stderr, "Truncated line %d: %s\n", linenum, line);
+}
+
+int main(int argc, char **argv)
+{
+ const char *b, *p, *time_field, *accept_field, *source_field;
+ const char *filter_term_code_name = NULL;
+ const char *output_file = NULL;
+ int f, last;
+ struct timer *t = NULL;
+ struct eb32_node *n;
+ struct url_stat *ustat = NULL;
+ int val, test;
+ unsigned int uval;
+ unsigned int filter_acc_delay = 0, filter_acc_count = 0;
+ int filter_time_resp = 0;
+ int filt_http_status_low = 0, filt_http_status_high = 0;
+ unsigned int filt2_timestamp_low = 0, filt2_timestamp_high = 0;
+ unsigned int filt2_capture_block = 0, filt2_capture_field = 0;
+ int skip_fields = 1;
+
+ void (*line_filter)(const char *accept_field, const char *time_field, struct timer **tptr) = NULL;
+
+ argc--; argv++;
+ while (argc > 0) {
+ if (*argv[0] != '-')
+ break;
+
+ if (strcmp(argv[0], "-ad") == 0) {
+ if (argc < 2) die("missing option for -ad\n");
+ argc--; argv++;
+ filter |= FILT_ACC_DELAY;
+ filter_acc_delay = atol(*argv);
+ }
+ else if (strcmp(argv[0], "-ac") == 0) {
+ if (argc < 2) die("missing option for -ac\n");
+ argc--; argv++;
+ filter |= FILT_ACC_COUNT;
+ filter_acc_count = atol(*argv);
+ }
+ else if (strcmp(argv[0], "-rt") == 0) {
+ if (argc < 2) die("missing option for -rt\n");
+ argc--; argv++;
+ filter |= FILT_TIME_RESP;
+ filter_time_resp = atol(*argv);
+ }
+ else if (strcmp(argv[0], "-RT") == 0) {
+ if (argc < 2) die("missing option for -RT\n");
+ argc--; argv++;
+ filter |= FILT_TIME_RESP | FILT_INVERT_TIME_RESP;
+ filter_time_resp = atol(*argv);
+ }
+ else if (strcmp(argv[0], "-s") == 0) {
+ if (argc < 2) die("missing option for -s\n");
+ argc--; argv++;
+ skip_fields = atol(*argv);
+ }
+ else if (strcmp(argv[0], "-m") == 0) {
+ if (argc < 2) die("missing option for -m\n");
+ argc--; argv++;
+ lines_max = atol(*argv);
+ }
+ else if (strcmp(argv[0], "-e") == 0)
+ filter |= FILT_ERRORS_ONLY;
+ else if (strcmp(argv[0], "-E") == 0)
+ filter |= FILT_ERRORS_ONLY | FILT_INVERT_ERRORS;
+ else if (strcmp(argv[0], "-H") == 0)
+ filter |= FILT_HTTP_ONLY;
+ else if (strcmp(argv[0], "-Q") == 0)
+ filter |= FILT_QUEUE_ONLY;
+ else if (strcmp(argv[0], "-QS") == 0)
+ filter |= FILT_QUEUE_SRV_ONLY;
+ else if (strcmp(argv[0], "-c") == 0)
+ filter |= FILT_COUNT_ONLY;
+ else if (strcmp(argv[0], "-q") == 0)
+ filter |= FILT_QUIET;
+ else if (strcmp(argv[0], "-v") == 0)
+ filter_invert = !filter_invert;
+ else if (strcmp(argv[0], "-gt") == 0)
+ filter |= FILT_GRAPH_TIMERS;
+ else if (strcmp(argv[0], "-pct") == 0)
+ filter |= FILT_PERCENTILE;
+ else if (strcmp(argv[0], "-st") == 0)
+ filter |= FILT_COUNT_STATUS;
+ else if (strcmp(argv[0], "-srv") == 0)
+ filter |= FILT_COUNT_SRV_STATUS;
+ else if (strcmp(argv[0], "-cc") == 0)
+ filter |= FILT_COUNT_COOK_CODES;
+ else if (strcmp(argv[0], "-tc") == 0)
+ filter |= FILT_COUNT_TERM_CODES;
+ else if (strcmp(argv[0], "-tcn") == 0) {
+ if (argc < 2) die("missing option for -tcn\n");
+ argc--; argv++;
+ filter |= FILT_TERM_CODE_NAME;
+ filter_term_code_name = *argv;
+ }
+ else if (strcmp(argv[0], "-TCN") == 0) {
+ if (argc < 2) die("missing option for -TCN\n");
+ argc--; argv++;
+ filter |= FILT_TERM_CODE_NAME | FILT_INVERT_TERM_CODE_NAME;
+ filter_term_code_name = *argv;
+ }
+ else if (strcmp(argv[0], "-hs") == 0 || strcmp(argv[0], "-HS") == 0) {
+ char *sep, *str;
+
+ if (argc < 2) die("missing option for -hs/-HS ([min]:[max])\n");
+ filter |= FILT_HTTP_STATUS;
+ if (argv[0][1] == 'H')
+ filter |= FILT_INVERT_HTTP_STATUS;
+
+ argc--; argv++;
+ str = *argv;
+ sep = strchr(str, ':'); /* [min]:[max] */
+ if (!sep)
+ sep = str; /* make max point to min */
+ else
+ *sep++ = 0;
+ filt_http_status_low = *str ? atol(str) : 0;
+ filt_http_status_high = *sep ? atol(sep) : 65535;
+ }
+ else if (strcmp(argv[0], "-time") == 0) {
+ char *sep, *str;
+
+ if (argc < 2) die("missing option for -time ([min]:[max])\n");
+ filter2 |= FILT2_TIMESTAMP;
+
+ argc--; argv++;
+ str = *argv;
+ sep = strchr(str, ':'); /* [min]:[max] */
+ filt2_timestamp_low = *str ? atol(str) : 0;
+ if (!sep)
+ filt2_timestamp_high = 0xFFFFFFFF;
+ else
+ filt2_timestamp_high = atol(++sep);
+ }
+ else if (strcmp(argv[0], "-u") == 0)
+ filter |= FILT_COUNT_URL_ONLY;
+ else if (strcmp(argv[0], "-uc") == 0)
+ filter |= FILT_COUNT_URL_COUNT;
+ else if (strcmp(argv[0], "-ue") == 0)
+ filter |= FILT_COUNT_URL_ERR;
+ else if (strcmp(argv[0], "-ua") == 0)
+ filter |= FILT_COUNT_URL_TAVG;
+ else if (strcmp(argv[0], "-ut") == 0)
+ filter |= FILT_COUNT_URL_TTOT;
+ else if (strcmp(argv[0], "-uao") == 0)
+ filter |= FILT_COUNT_URL_TAVGO;
+ else if (strcmp(argv[0], "-uto") == 0)
+ filter |= FILT_COUNT_URL_TTOTO;
+ else if (strcmp(argv[0], "-uba") == 0)
+ filter |= FILT_COUNT_URL_BAVG;
+ else if (strcmp(argv[0], "-ubt") == 0)
+ filter |= FILT_COUNT_URL_BTOT;
+ else if (strcmp(argv[0], "-query") == 0)
+ filter2 |= FILT2_PRESERVE_QUERY;
+ else if (strcmp(argv[0], "-ic") == 0)
+ filter |= FILT_COUNT_IP_COUNT;
+ else if (strcmp(argv[0], "-hdr") == 0) {
+ char *sep, *str;
+
+ if (argc < 2) die("missing option for -hdr (<block>:<field>)\n");
+ filter2 |= FILT2_EXTRACT_CAPTURE;
+
+ argc--; argv++;
+ str = *argv;
+ sep = strchr(str, ':');
+ if (!sep)
+ die("missing colon in -hdr (<block>:<field>)\n");
+ else
+ *sep++ = 0;
+
+ filt2_capture_block = *str ? atol(str) : 1;
+ filt2_capture_field = *sep ? atol(sep) : 1;
+
+ if (filt2_capture_block < 1 || filt2_capture_field < 1)
+ die("block and field must be at least 1 for -hdr (<block>:<field>)\n");
+ }
+ else if (strcmp(argv[0], "-o") == 0) {
+ if (output_file)
+ die("Fatal: output file name already specified.\n");
+ if (argc < 2)
+ die("Fatal: missing output file name.\n");
+ output_file = argv[1];
+ }
+ else if (strcmp(argv[0], "-h") == 0 || strcmp(argv[0], "--help") == 0)
+ help();
+ argc--;
+ argv++;
+ }
+
+ if (!filter && !filter2)
+ die("No action specified.\n");
+
+ if (filter & FILT_ACC_COUNT && !filter_acc_count)
+ filter_acc_count=1;
+
+ if (filter & FILT_ACC_DELAY && !filter_acc_delay)
+ filter_acc_delay = 1;
+
+
+ /* by default, all lines are printed */
+ line_filter = filter_output_line;
+ if (filter & (FILT_ACC_COUNT|FILT_ACC_DELAY))
+ line_filter = filter_accept_holes;
+ else if (filter & (FILT_GRAPH_TIMERS|FILT_PERCENTILE))
+ line_filter = filter_graphs;
+ else if (filter & FILT_COUNT_STATUS)
+ line_filter = filter_count_status;
+ else if (filter & FILT_COUNT_COOK_CODES)
+ line_filter = filter_count_cook_codes;
+ else if (filter & FILT_COUNT_TERM_CODES)
+ line_filter = filter_count_term_codes;
+ else if (filter & FILT_COUNT_SRV_STATUS)
+ line_filter = filter_count_srv_status;
+ else if (filter & FILT_COUNT_URL_ANY)
+ line_filter = filter_count_url;
+ else if (filter & FILT_COUNT_ONLY)
+ line_filter = NULL;
+
+#if defined(POSIX_FADV_SEQUENTIAL)
+ /* around 20% performance improvement is observed on Linux with this
+ * on cold-cache. Surprisingly, WILLNEED is less performant. Don't
+ * use NOREUSE as it flushes the cache and prevents easy data
+ * manipulation on logs!
+ */
+ posix_fadvise(0, 0, 0, POSIX_FADV_SEQUENTIAL);
+#endif
+
+ if (!line_filter && /* FILT_COUNT_ONLY ( see above), and no input filter (see below) */
+ !(filter & (FILT_HTTP_ONLY|FILT_TIME_RESP|FILT_ERRORS_ONLY|FILT_HTTP_STATUS|FILT_QUEUE_ONLY|FILT_QUEUE_SRV_ONLY|FILT_TERM_CODE_NAME)) &&
+ !(filter2 & (FILT2_TIMESTAMP))) {
+ /* read the whole file at once first, ignore it if inverted output */
+ if (!filter_invert)
+ while ((lines_max < 0 || lines_out < lines_max) && fgets2(stdin) != NULL)
+ lines_out++;
+
+ goto skip_filters;
+ }
+
+ while ((line = fgets2(stdin)) != NULL) {
+ linenum++;
+ time_field = NULL; accept_field = NULL;
+ source_field = NULL;
+
+ test = 1;
+
+ /* for any line we process, we first ensure that there is a field
+ * looking like the accept date field (beginning with a '[').
+ */
+ if (filter & FILT_COUNT_IP_COUNT) {
+ /* we need the IP first */
+ source_field = field_start(line, SOURCE_FIELD + skip_fields);
+ accept_field = field_start(source_field, ACCEPT_FIELD - SOURCE_FIELD + 1);
+ }
+ else
+ accept_field = field_start(line, ACCEPT_FIELD + skip_fields);
+
+ if (unlikely(*accept_field != '[')) {
+ parse_err++;
+ continue;
+ }
+
+ /* the day of month field is begin 01 and 31 */
+ if (accept_field[1] < '0' || accept_field[1] > '3') {
+ parse_err++;
+ continue;
+ }
+
+ if (filter2 & FILT2_TIMESTAMP) {
+ uval = convert_date_to_timestamp(accept_field);
+ test &= (uval>=filt2_timestamp_low && uval<=filt2_timestamp_high) ;
+ }
+
+ if (filter & FILT_HTTP_ONLY) {
+ /* only report lines with at least 4 timers */
+ if (!time_field) {
+ time_field = field_start(accept_field, TIME_FIELD - ACCEPT_FIELD + 1);
+ if (unlikely(!*time_field)) {
+ truncated_line(linenum, line);
+ continue;
+ }
+ }
+
+ field_stop(time_field + 1);
+ /* we have field TIME_FIELD in [time_field]..[e-1] */
+ p = time_field;
+ f = 0;
+ while (!SEP(*p)) {
+ if (++f == 4)
+ break;
+ SKIP_CHAR(p, '/');
+ }
+ test &= (f >= 4);
+ }
+
+ if (filter & FILT_TIME_RESP) {
+ int tps;
+
+ /* only report lines with response times larger than filter_time_resp */
+ if (!time_field) {
+ time_field = field_start(accept_field, TIME_FIELD - ACCEPT_FIELD + 1);
+ if (unlikely(!*time_field)) {
+ truncated_line(linenum, line);
+ continue;
+ }
+ }
+
+ field_stop(time_field + 1);
+ /* we have field TIME_FIELD in [time_field]..[e-1], let's check only the response time */
+
+ p = time_field;
+ f = 0;
+ while (!SEP(*p)) {
+ tps = str2ic(p);
+ if (tps < 0) {
+ tps = -1;
+ }
+ if (++f == 4)
+ break;
+ SKIP_CHAR(p, '/');
+ }
+
+ if (unlikely(f < 4)) {
+ parse_err++;
+ continue;
+ }
+
+ test &= (tps >= filter_time_resp) ^ !!(filter & FILT_INVERT_TIME_RESP);
+ }
+
+ if (filter & (FILT_ERRORS_ONLY | FILT_HTTP_STATUS)) {
+ /* Check both error codes (-1, 5xx) and status code ranges */
+ if (time_field)
+ b = field_start(time_field, STATUS_FIELD - TIME_FIELD + 1);
+ else
+ b = field_start(accept_field, STATUS_FIELD - ACCEPT_FIELD + 1);
+
+ if (unlikely(!*b)) {
+ truncated_line(linenum, line);
+ continue;
+ }
+
+ val = str2ic(b);
+ if (filter & FILT_ERRORS_ONLY)
+ test &= (val < 0 || (val >= 500 && val <= 599)) ^ !!(filter & FILT_INVERT_ERRORS);
+
+ if (filter & FILT_HTTP_STATUS)
+ test &= (val >= filt_http_status_low && val <= filt_http_status_high) ^ !!(filter & FILT_INVERT_HTTP_STATUS);
+ }
+
+ if (filter & (FILT_QUEUE_ONLY|FILT_QUEUE_SRV_ONLY)) {
+ /* Check if the server's queue is non-nul */
+ if (time_field)
+ b = field_start(time_field, QUEUE_LEN_FIELD - TIME_FIELD + 1);
+ else
+ b = field_start(accept_field, QUEUE_LEN_FIELD - ACCEPT_FIELD + 1);
+
+ if (unlikely(!*b)) {
+ truncated_line(linenum, line);
+ continue;
+ }
+
+ if (*b == '0') {
+ if (filter & FILT_QUEUE_SRV_ONLY) {
+ test = 0;
+ }
+ else {
+ do {
+ b++;
+ if (*b == '/') {
+ b++;
+ break;
+ }
+ } while (*b);
+ test &= ((unsigned char)(*b - '1') < 9);
+ }
+ }
+ }
+
+ if (filter & FILT_TERM_CODE_NAME) {
+ /* only report corresponding termination code name */
+ if (time_field)
+ b = field_start(time_field, TERM_CODES_FIELD - TIME_FIELD + 1);
+ else
+ b = field_start(accept_field, TERM_CODES_FIELD - ACCEPT_FIELD + 1);
+
+ if (unlikely(!*b)) {
+ truncated_line(linenum, line);
+ continue;
+ }
+
+ test &= (b[0] == filter_term_code_name[0] && b[1] == filter_term_code_name[1]) ^ !!(filter & FILT_INVERT_TERM_CODE_NAME);
+ }
+
+
+ test ^= filter_invert;
+ if (!test)
+ continue;
+
+ /************** here we process inputs *******************/
+
+ if (line_filter) {
+ if (filter & FILT_COUNT_IP_COUNT)
+ filter_count_ip(source_field, accept_field, time_field, &t);
+ else if (filter2 & FILT2_EXTRACT_CAPTURE)
+ filter_extract_capture(accept_field, time_field, filt2_capture_block, filt2_capture_field);
+ else
+ line_filter(accept_field, time_field, &t);
+ }
+ else
+ lines_out++; /* FILT_COUNT_ONLY was used, so we're just counting lines */
+ if (lines_max >= 0 && lines_out >= lines_max)
+ break;
+ }
+
+ skip_filters:
+ /*****************************************************
+ * Here we've finished reading all input. Depending on the
+ * filters, we may still have some analysis to run on the
+ * collected data and to output data in a new format.
+ *************************************************** */
+
+ if (t)
+ free(t);
+
+ if (filter & FILT_COUNT_ONLY) {
+ printf("%d\n", lines_out);
+ exit(0);
+ }
+
+ if (filter & (FILT_ACC_COUNT|FILT_ACC_DELAY)) {
+ /* sort and count all timers. Output will look like this :
+ * <accept_date> <delta_ms from previous one> <nb entries>
+ */
+ n = eb32_first(&timers[0]);
+
+ if (n)
+ last = n->key;
+ while (n) {
+ unsigned int d, h, m, s, ms;
+
+ t = container_of(n, struct timer, node);
+ h = n->key;
+ d = h - last;
+ last = h;
+
+ if (d >= filter_acc_delay && t->count >= filter_acc_count) {
+ ms = h % 1000; h = h / 1000;
+ s = h % 60; h = h / 60;
+ m = h % 60; h = h / 60;
+ printf("%02u:%02u:%02u.%03u %d %u %u\n", h, m, s, ms, last, d, t->count);
+ lines_out++;
+ if (lines_max >= 0 && lines_out >= lines_max)
+ break;
+ }
+ n = eb32_next(n);
+ }
+ }
+ else if (filter & FILT_GRAPH_TIMERS) {
+ /* sort all timers */
+ for (f = 0; f < 5; f++) {
+ struct eb32_node *n;
+
+ n = eb32_first(&timers[f]);
+ while (n) {
+ int i;
+ double d;
+ int val;
+
+ t = container_of(n, struct timer, node);
+ last = n->key;
+ val = t->count;
+
+ i = (last < 0) ? -last : last;
+ i = fls_auto(i) - QBITS;
+
+ if (i > 0)
+ d = val / (double)(1 << i);
+ else
+ d = val;
+
+ if (d > 0.0)
+ printf("%d %d %f\n", f, last, d+1.0);
+
+ n = eb32_next(n);
+ }
+ }
+ }
+ else if (filter & FILT_PERCENTILE) {
+ /* report timers by percentile :
+ * <percent> <total> <max_req_time> <max_conn_time> <max_resp_time> <max_data_time>
+ * We don't count errs.
+ */
+ struct eb32_node *n[5];
+ unsigned long cum[5];
+ double step;
+
+ if (!lines_out)
+ goto empty;
+
+ for (f = 1; f < 5; f++) {
+ n[f] = eb32_first(&timers[f]);
+ cum[f] = container_of(n[f], struct timer, node)->count;
+ }
+
+ for (step = 1; step <= 1000;) {
+ unsigned int thres = lines_out * (step / 1000.0);
+
+ printf("%3.1f %u ", step/10.0, thres);
+ for (f = 1; f < 5; f++) {
+ struct eb32_node *next;
+ while (cum[f] < thres) {
+ /* need to find other keys */
+ next = eb32_next(n[f]);
+ if (!next)
+ break;
+ n[f] = next;
+ cum[f] += container_of(next, struct timer, node)->count;
+ }
+
+ /* value still within $step % of total */
+ printf("%d ", n[f]->key);
+ }
+ putchar('\n');
+ if (step >= 100 && step < 900)
+ step += 50; // jump 5% by 5% between those steps.
+ else if (step >= 20 && step < 980)
+ step += 10;
+ else
+ step += 1;
+ }
+ }
+ else if (filter & FILT_COUNT_STATUS) {
+ /* output all statuses in the form of <status> <occurrences> */
+ n = eb32_first(&timers[0]);
+ while (n) {
+ t = container_of(n, struct timer, node);
+ printf("%d %u\n", n->key, t->count);
+ lines_out++;
+ if (lines_max >= 0 && lines_out >= lines_max)
+ break;
+ n = eb32_next(n);
+ }
+ }
+ else if (filter & FILT_COUNT_SRV_STATUS) {
+ struct ebmb_node *srv_node;
+ struct srv_st *srv;
+
+ printf("#srv_name 1xx 2xx 3xx 4xx 5xx other tot_req req_ok pct_ok avg_ct avg_rt\n");
+
+ srv_node = ebmb_first(&timers[0]);
+ while (srv_node) {
+ int tot_rq;
+
+ srv = container_of(srv_node, struct srv_st, node);
+
+ tot_rq = 0;
+ for (f = 0; f <= 5; f++)
+ tot_rq += srv->st_cnt[f];
+
+ printf("%s %u %u %u %u %u %u %d %u %.1f %d %d\n",
+ srv_node->key, srv->st_cnt[1], srv->st_cnt[2],
+ srv->st_cnt[3], srv->st_cnt[4], srv->st_cnt[5], srv->st_cnt[0],
+ tot_rq,
+ srv->nb_ok, (double)srv->nb_ok * 100.0 / (tot_rq?tot_rq:1),
+ (int)(srv->cum_ct / (srv->nb_ct?srv->nb_ct:1)), (int)(srv->cum_rt / (srv->nb_rt?srv->nb_rt:1)));
+ srv_node = ebmb_next(srv_node);
+ lines_out++;
+ if (lines_max >= 0 && lines_out >= lines_max)
+ break;
+ }
+ }
+ else if (filter & (FILT_COUNT_TERM_CODES|FILT_COUNT_COOK_CODES)) {
+ /* output all statuses in the form of <code> <occurrences> */
+ n = eb32_first(&timers[0]);
+ while (n) {
+ t = container_of(n, struct timer, node);
+ printf("%c%c %u\n", (n->key >> 8), (n->key) & 255, t->count);
+ lines_out++;
+ if (lines_max >= 0 && lines_out >= lines_max)
+ break;
+ n = eb32_next(n);
+ }
+ }
+ else if (filter & (FILT_COUNT_URL_ANY|FILT_COUNT_IP_COUNT)) {
+ struct eb_node *node, *next;
+
+ if (!(filter & FILT_COUNT_URL_ONLY)) {
+ /* we have to sort on another criterion. We'll use timers[1] for the
+ * destination tree.
+ */
+
+ timers[1] = EB_ROOT; /* reconfigure to accept duplicates */
+ for (node = eb_first(&timers[0]); node; node = next) {
+ next = eb_next(node);
+ eb_delete(node);
+
+ ustat = container_of(node, struct url_stat, node.url.node);
+
+ if (filter & (FILT_COUNT_URL_COUNT|FILT_COUNT_IP_COUNT))
+ ustat->node.val.key = ustat->nb_req;
+ else if (filter & FILT_COUNT_URL_ERR)
+ ustat->node.val.key = ustat->nb_err;
+ else if (filter & FILT_COUNT_URL_TTOT)
+ ustat->node.val.key = ustat->total_time;
+ else if (filter & FILT_COUNT_URL_TAVG)
+ ustat->node.val.key = ustat->nb_req ? ustat->total_time / ustat->nb_req : 0;
+ else if (filter & FILT_COUNT_URL_TTOTO)
+ ustat->node.val.key = ustat->total_time_ok;
+ else if (filter & FILT_COUNT_URL_TAVGO)
+ ustat->node.val.key = (ustat->nb_req - ustat->nb_err) ? ustat->total_time_ok / (ustat->nb_req - ustat->nb_err) : 0;
+ else if (filter & FILT_COUNT_URL_BAVG)
+ ustat->node.val.key = ustat->nb_req ? ustat->total_bytes_sent / ustat->nb_req : 0;
+ else if (filter & FILT_COUNT_URL_BTOT)
+ ustat->node.val.key = ustat->total_bytes_sent;
+ else
+ ustat->node.val.key = 0;
+
+ eb64_insert(&timers[1], &ustat->node.val);
+ }
+ /* switch trees */
+ timers[0] = timers[1];
+ }
+
+ if (FILT_COUNT_IP_COUNT)
+ printf("#req err ttot tavg oktot okavg bavg btot src\n");
+ else
+ printf("#req err ttot tavg oktot okavg bavg btot url\n");
+
+ /* scan the tree in its reverse sorting order */
+ node = eb_last(&timers[0]);
+ while (node) {
+ ustat = container_of(node, struct url_stat, node.url.node);
+ printf("%u %u %llu %llu %llu %llu %llu %llu %s\n",
+ ustat->nb_req,
+ ustat->nb_err,
+ ustat->total_time,
+ ustat->nb_req ? ustat->total_time / ustat->nb_req : 0,
+ ustat->total_time_ok,
+ (ustat->nb_req - ustat->nb_err) ? ustat->total_time_ok / (ustat->nb_req - ustat->nb_err) : 0,
+ ustat->nb_req ? ustat->total_bytes_sent / ustat->nb_req : 0,
+ ustat->total_bytes_sent,
+ ustat->url);
+
+ node = eb_prev(node);
+ lines_out++;
+ if (lines_max >= 0 && lines_out >= lines_max)
+ break;
+ }
+ }
+
+ empty:
+ if (!(filter & FILT_QUIET))
+ fprintf(stderr, "%d lines in, %d lines out, %d parsing errors\n",
+ linenum, lines_out, parse_err);
+ exit(0);
+}
+
+void filter_output_line(const char *accept_field, const char *time_field, struct timer **tptr)
+{
+ puts(line);
+ lines_out++;
+}
+
+void filter_extract_capture(const char *accept_field, const char *time_field, unsigned int block, unsigned int field)
+{
+ const char *e, *f;
+
+ if (time_field)
+ e = field_start(time_field, METH_FIELD - TIME_FIELD + 1);
+ else
+ e = field_start(accept_field, METH_FIELD - ACCEPT_FIELD + 1);
+
+ while (block-- > 0) {
+ /* Scan until the start of a capture block ('{') until the URL ('"'). */
+ while ((*e != '"' && *e != '{') && *e) {
+ /* Note: some syslog servers escape quotes ! */
+ if (*e == '\\' && e[1] == '"')
+ break;
+
+ e = field_start(e, 2);
+ }
+
+ if (unlikely(!*e)) {
+ truncated_line(linenum, line);
+ return;
+ }
+
+ /* We reached the URL, no more captures will follow. */
+ if (*e != '{') {
+ puts("");
+ lines_out++;
+ return;
+ }
+
+ /* e points the the opening brace of the capture block. */
+
+ e++;
+ }
+
+ /* We are in the first field of the selected capture block. */
+
+ while (--field > 0) {
+ while ((*e != '|' && *e != '}') && *e)
+ e++;
+
+ if (unlikely(!*e)) {
+ truncated_line(linenum, line);
+ return;
+ }
+
+ if (*e != '|') {
+ puts("");
+ lines_out++;
+ return;
+ }
+
+ /* e points to the pipe. */
+
+ e++;
+ }
+
+ f = e;
+
+ while ((*f != '|' && *f != '}') && *f)
+ f++;
+
+ if (unlikely(!*f)) {
+ truncated_line(linenum, line);
+ return;
+ }
+
+ fwrite(e, f - e, 1, stdout);
+ putchar('\n');
+ lines_out++;
+}
+
+void filter_accept_holes(const char *accept_field, const char *time_field, struct timer **tptr)
+{
+ struct timer *t2;
+ int val;
+
+ val = convert_date(accept_field);
+ if (unlikely(val < 0)) {
+ truncated_line(linenum, line);
+ return;
+ }
+
+ t2 = insert_value(&timers[0], tptr, val);
+ t2->count++;
+ return;
+}
+
+void filter_count_status(const char *accept_field, const char *time_field, struct timer **tptr)
+{
+ struct timer *t2;
+ const char *b;
+ int val;
+
+ if (time_field)
+ b = field_start(time_field, STATUS_FIELD - TIME_FIELD + 1);
+ else
+ b = field_start(accept_field, STATUS_FIELD - ACCEPT_FIELD + 1);
+
+ if (unlikely(!*b)) {
+ truncated_line(linenum, line);
+ return;
+ }
+
+ val = str2ic(b);
+
+ t2 = insert_value(&timers[0], tptr, val);
+ t2->count++;
+}
+
+void filter_count_cook_codes(const char *accept_field, const char *time_field, struct timer **tptr)
+{
+ struct timer *t2;
+ const char *b;
+ int val;
+
+ if (time_field)
+ b = field_start(time_field, TERM_CODES_FIELD - TIME_FIELD + 1);
+ else
+ b = field_start(accept_field, TERM_CODES_FIELD - ACCEPT_FIELD + 1);
+
+ if (unlikely(!*b)) {
+ truncated_line(linenum, line);
+ return;
+ }
+
+ val = 256 * b[2] + b[3];
+
+ t2 = insert_value(&timers[0], tptr, val);
+ t2->count++;
+}
+
+void filter_count_term_codes(const char *accept_field, const char *time_field, struct timer **tptr)
+{
+ struct timer *t2;
+ const char *b;
+ int val;
+
+ if (time_field)
+ b = field_start(time_field, TERM_CODES_FIELD - TIME_FIELD + 1);
+ else
+ b = field_start(accept_field, TERM_CODES_FIELD - ACCEPT_FIELD + 1);
+
+ if (unlikely(!*b)) {
+ truncated_line(linenum, line);
+ return;
+ }
+
+ val = 256 * b[0] + b[1];
+
+ t2 = insert_value(&timers[0], tptr, val);
+ t2->count++;
+}
+
+void filter_count_srv_status(const char *accept_field, const char *time_field, struct timer **tptr)
+{
+ const char *b, *e, *p;
+ int f, err, array[5];
+ struct ebmb_node *srv_node;
+ struct srv_st *srv;
+ int val;
+
+ /* the server field is before the status field, so let's
+ * parse them in the proper order.
+ */
+ b = field_start(accept_field, SERVER_FIELD - ACCEPT_FIELD + 1);
+ if (unlikely(!*b)) {
+ truncated_line(linenum, line);
+ return;
+ }
+
+ e = field_stop(b + 1); /* we have the server name in [b]..[e-1] */
+
+ /* the chance that a server name already exists is extremely high,
+ * so let's perform a normal lookup first.
+ */
+ srv_node = ebst_lookup_len(&timers[0], b, e - b);
+ srv = container_of(srv_node, struct srv_st, node);
+
+ if (!srv_node) {
+ /* server not yet in the tree, let's create it */
+ srv = (void *)calloc(1, sizeof(struct srv_st) + e - b + 1);
+ srv_node = &srv->node;
+ memcpy(&srv_node->key, b, e - b);
+ srv_node->key[e - b] = '\0';
+ ebst_insert(&timers[0], srv_node);
+ }
+
+ /* let's collect the connect and response times */
+ if (!time_field) {
+ time_field = field_start(e, TIME_FIELD - SERVER_FIELD);
+ if (unlikely(!*time_field)) {
+ truncated_line(linenum, line);
+ return;
+ }
+ }
+
+ e = field_stop(time_field + 1);
+ /* we have field TIME_FIELD in [time_field]..[e-1] */
+
+ p = time_field;
+ err = 0;
+ f = 0;
+ while (!SEP(*p)) {
+ array[f] = str2ic(p);
+ if (array[f] < 0) {
+ array[f] = -1;
+ err = 1;
+ }
+ if (++f == 5)
+ break;
+ SKIP_CHAR(p, '/');
+ }
+
+ if (unlikely(f < 5)){
+ parse_err++;
+ return;
+ }
+
+ /* OK we have our timers in array[2,3] */
+ if (!err)
+ srv->nb_ok++;
+
+ if (array[2] >= 0) {
+ srv->cum_ct += array[2];
+ srv->nb_ct++;
+ }
+
+ if (array[3] >= 0) {
+ srv->cum_rt += array[3];
+ srv->nb_rt++;
+ }
+
+ /* we're interested in the 5 HTTP status classes (1xx ... 5xx), and
+ * the invalid ones which will be reported as 0.
+ */
+ b = field_start(e, STATUS_FIELD - TIME_FIELD);
+ if (unlikely(!*b)) {
+ truncated_line(linenum, line);
+ return;
+ }
+
+ val = 0;
+ if (*b >= '1' && *b <= '5')
+ val = *b - '0';
+
+ srv->st_cnt[val]++;
+}
+
+void filter_count_url(const char *accept_field, const char *time_field, struct timer **tptr)
+{
+ struct url_stat *ustat = NULL;
+ struct ebpt_node *ebpt_old;
+ const char *b, *e;
+ int f, err, array[5];
+ int val;
+
+ /* let's collect the response time */
+ if (!time_field) {
+ time_field = field_start(accept_field, TIME_FIELD - ACCEPT_FIELD + 1); // avg 115 ns per line
+ if (unlikely(!*time_field)) {
+ truncated_line(linenum, line);
+ return;
+ }
+ }
+
+ /* we have the field TIME_FIELD starting at <time_field>. We'll
+ * parse the 5 timers to detect errors, it takes avg 55 ns per line.
+ */
+ e = time_field; err = 0; f = 0;
+ while (!SEP(*e)) {
+ array[f] = str2ic(e);
+ if (array[f] < 0) {
+ array[f] = -1;
+ err = 1;
+ }
+ if (++f == 5)
+ break;
+ SKIP_CHAR(e, '/');
+ }
+ if (f < 5) {
+ parse_err++;
+ return;
+ }
+
+ /* OK we have our timers in array[3], and err is >0 if at
+ * least one -1 was seen. <e> points to the first char of
+ * the last timer. Let's prepare a new node with that.
+ */
+ if (unlikely(!ustat))
+ ustat = calloc(1, sizeof(*ustat));
+
+ ustat->nb_err = err;
+ ustat->nb_req = 1;
+
+ /* use array[4] = total time in case of error */
+ ustat->total_time = (array[3] >= 0) ? array[3] : array[4];
+ ustat->total_time_ok = (array[3] >= 0) ? array[3] : 0;
+
+ e = field_start(e, BYTES_SENT_FIELD - TIME_FIELD + 1);
+ val = str2ic(e);
+ ustat->total_bytes_sent = val;
+
+ /* the line may be truncated because of a bad request or anything like this,
+ * without a method. Also, if it does not begin with an quote, let's skip to
+ * the next field because it's a capture. Let's fall back to the "method" itself
+ * if there's nothing else.
+ */
+ e = field_start(e, METH_FIELD - BYTES_SENT_FIELD + 1);
+ while (*e != '"' && *e) {
+ /* Note: some syslog servers escape quotes ! */
+ if (*e == '\\' && e[1] == '"')
+ break;
+ e = field_start(e, 2);
+ }
+
+ if (unlikely(!*e)) {
+ truncated_line(linenum, line);
+ free(ustat);
+ return;
+ }
+
+ b = field_start(e, URL_FIELD - METH_FIELD + 1); // avg 40 ns per line
+ if (!*b)
+ b = e;
+
+ /* stop at end of field or first ';' or '?', takes avg 64 ns per line */
+ e = b;
+ do {
+ if (*e == ' '||
+ (!(filter2 & FILT2_PRESERVE_QUERY) && (*e == '?' || *e == ';'))) {
+ *(char *)e = 0;
+ break;
+ }
+ e++;
+ } while (*e);
+
+ /* now instead of copying the URL for a simple lookup, we'll link
+ * to it from the node we're trying to insert. If it returns a
+ * different value, it was already there. Otherwise we just have
+ * to dynamically realloc an entry using strdup().
+ */
+ ustat->node.url.key = (char *)b;
+ ebpt_old = ebis_insert(&timers[0], &ustat->node.url);
+
+ if (ebpt_old != &ustat->node.url) {
+ struct url_stat *ustat_old;
+ /* node was already there, let's update previous one */
+ ustat_old = container_of(ebpt_old, struct url_stat, node.url);
+ ustat_old->nb_req ++;
+ ustat_old->nb_err += ustat->nb_err;
+ ustat_old->total_time += ustat->total_time;
+ ustat_old->total_time_ok += ustat->total_time_ok;
+ ustat_old->total_bytes_sent += ustat->total_bytes_sent;
+ } else {
+ ustat->url = ustat->node.url.key = strdup(ustat->node.url.key);
+ ustat = NULL; /* node was used */
+ }
+}
+
+void filter_count_ip(const char *source_field, const char *accept_field, const char *time_field, struct timer **tptr)
+{
+ struct url_stat *ustat = NULL;
+ struct ebpt_node *ebpt_old;
+ const char *b, *e;
+ int f, err, array[5];
+ int val;
+
+ /* let's collect the response time */
+ if (!time_field) {
+ time_field = field_start(accept_field, TIME_FIELD - ACCEPT_FIELD + 1); // avg 115 ns per line
+ if (unlikely(!*time_field)) {
+ truncated_line(linenum, line);
+ return;
+ }
+ }
+
+ /* we have the field TIME_FIELD starting at <time_field>. We'll
+ * parse the 5 timers to detect errors, it takes avg 55 ns per line.
+ */
+ e = time_field; err = 0; f = 0;
+ while (!SEP(*e)) {
+ if (f == 0 || f == 4) {
+ array[f] = str2ic(e);
+ if (array[f] < 0) {
+ array[f] = -1;
+ err = 1;
+ }
+ }
+ if (++f == 5)
+ break;
+ SKIP_CHAR(e, '/');
+ }
+ if (f < 5) {
+ parse_err++;
+ return;
+ }
+
+ /* OK we have our timers in array[0], and err is >0 if at
+ * least one -1 was seen. <e> points to the first char of
+ * the last timer. Let's prepare a new node with that.
+ */
+ if (unlikely(!ustat))
+ ustat = calloc(1, sizeof(*ustat));
+
+ ustat->nb_err = err;
+ ustat->nb_req = 1;
+
+ /* use array[4] = total time in case of error */
+ ustat->total_time = (array[0] >= 0) ? array[0] : array[4];
+ ustat->total_time_ok = (array[0] >= 0) ? array[0] : 0;
+
+ e = field_start(e, BYTES_SENT_FIELD - TIME_FIELD + 1);
+ val = str2ic(e);
+ ustat->total_bytes_sent = val;
+
+ /* the source might be IPv4 or IPv6, so we always strip the port by
+ * removing the last colon.
+ */
+ b = source_field;
+ e = field_stop(b + 1);
+ while (e > b && e[-1] != ':')
+ e--;
+ *(char *)(e - 1) = '\0';
+
+ /* now instead of copying the src for a simple lookup, we'll link
+ * to it from the node we're trying to insert. If it returns a
+ * different value, it was already there. Otherwise we just have
+ * to dynamically realloc an entry using strdup(). We're using the
+ * <url> field of the node to store the source address.
+ */
+ ustat->node.url.key = (char *)b;
+ ebpt_old = ebis_insert(&timers[0], &ustat->node.url);
+
+ if (ebpt_old != &ustat->node.url) {
+ struct url_stat *ustat_old;
+ /* node was already there, let's update previous one */
+ ustat_old = container_of(ebpt_old, struct url_stat, node.url);
+ ustat_old->nb_req ++;
+ ustat_old->nb_err += ustat->nb_err;
+ ustat_old->total_time += ustat->total_time;
+ ustat_old->total_time_ok += ustat->total_time_ok;
+ ustat_old->total_bytes_sent += ustat->total_bytes_sent;
+ } else {
+ ustat->url = ustat->node.url.key = strdup(ustat->node.url.key);
+ ustat = NULL; /* node was used */
+ }
+}
+
+void filter_graphs(const char *accept_field, const char *time_field, struct timer **tptr)
+{
+ struct timer *t2;
+ const char *p;
+ int f, err, array[5];
+
+ if (!time_field) {
+ time_field = field_start(accept_field, TIME_FIELD - ACCEPT_FIELD + 1);
+ if (unlikely(!*time_field)) {
+ truncated_line(linenum, line);
+ return;
+ }
+ }
+
+ field_stop(time_field + 1);
+ /* we have field TIME_FIELD in [time_field]..[e-1] */
+
+ p = time_field;
+ err = 0;
+ f = 0;
+ while (!SEP(*p)) {
+ array[f] = str2ic(p);
+ if (array[f] < 0) {
+ array[f] = -1;
+ err = 1;
+ }
+ if (++f == 5)
+ break;
+ SKIP_CHAR(p, '/');
+ }
+
+ if (unlikely(f < 5)) {
+ parse_err++;
+ return;
+ }
+
+ /* if we find at least one negative time, we count one error
+ * with a time equal to the total session time. This will
+ * emphasize quantum timing effects associated to known
+ * timeouts. Note that on some buggy machines, it is possible
+ * that the total time is negative, hence the reason to reset
+ * it.
+ */
+
+ if (filter & FILT_GRAPH_TIMERS) {
+ if (err) {
+ if (array[4] < 0)
+ array[4] = -1;
+ t2 = insert_timer(&timers[0], tptr, array[4]); // total time
+ t2->count++;
+ } else {
+ int v;
+
+ t2 = insert_timer(&timers[1], tptr, array[0]); t2->count++; // req
+ t2 = insert_timer(&timers[2], tptr, array[2]); t2->count++; // conn
+ t2 = insert_timer(&timers[3], tptr, array[3]); t2->count++; // resp
+
+ v = array[4] - array[0] - array[1] - array[2] - array[3]; // data time
+ if (v < 0 && !(filter & FILT_QUIET))
+ fprintf(stderr, "ERR: %s (%d %d %d %d %d => %d)\n",
+ line, array[0], array[1], array[2], array[3], array[4], v);
+ t2 = insert_timer(&timers[4], tptr, v); t2->count++;
+ lines_out++;
+ }
+ } else { /* percentile */
+ if (err) {
+ if (array[4] < 0)
+ array[4] = -1;
+ t2 = insert_value(&timers[0], tptr, array[4]); // total time
+ t2->count++;
+ } else {
+ int v;
+
+ t2 = insert_value(&timers[1], tptr, array[0]); t2->count++; // req
+ t2 = insert_value(&timers[2], tptr, array[2]); t2->count++; // conn
+ t2 = insert_value(&timers[3], tptr, array[3]); t2->count++; // resp
+
+ v = array[4] - array[0] - array[1] - array[2] - array[3]; // data time
+ if (v < 0 && !(filter & FILT_QUIET))
+ fprintf(stderr, "ERR: %s (%d %d %d %d %d => %d)\n",
+ line, array[0], array[1], array[2], array[3], array[4], v);
+ t2 = insert_value(&timers[4], tptr, v); t2->count++;
+ lines_out++;
+ }
+ }
+}
+
+
+/*
+ * Local variables:
+ * c-indent-level: 8
+ * c-basic-offset: 8
+ * End:
+ */
diff --git a/admin/iprange/Makefile b/admin/iprange/Makefile
new file mode 100644
index 0000000..13598d8
--- /dev/null
+++ b/admin/iprange/Makefile
@@ -0,0 +1,13 @@
+CC = cc
+OPTIMIZE = -O3
+LDFLAGS = -s
+
+OBJS = iprange ip6range
+
+all: $(OBJS)
+
+%: %.c
+ $(CC) $(LDFLAGS) $(OPTIMIZE) -o $@ $^
+
+clean:
+ rm -f $(OBJS) *.o *.a *~
diff --git a/admin/iprange/ip6range.c b/admin/iprange/ip6range.c
new file mode 100644
index 0000000..2ffd490
--- /dev/null
+++ b/admin/iprange/ip6range.c
@@ -0,0 +1,397 @@
+/*
+ * network range to IP+mask converter
+ *
+ * Copyright 2011-2012 Willy Tarreau <w@1wt.eu>
+ *
+ * This program reads lines starting by two IP addresses and outputs them with
+ * the two IP addresses replaced by a netmask covering the range between these
+ * IPs (inclusive). When multiple ranges are needed, as many lines are emitted.
+ * The IP addresses may be delimited by spaces, tabs or commas. Quotes are
+ * stripped, and lines beginning with a sharp character ('#') are ignored. The
+ * IP addresses may be either in the dotted format or represented as a 32-bit
+ * integer value in network byte order.
+ *
+ * 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
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define MAXLINE 1024
+
+static inline void in6_bswap(struct in6_addr *a)
+{
+ a->s6_addr32[0] = ntohl(a->s6_addr32[0]);
+ a->s6_addr32[1] = ntohl(a->s6_addr32[1]);
+ a->s6_addr32[2] = ntohl(a->s6_addr32[2]);
+ a->s6_addr32[3] = ntohl(a->s6_addr32[3]);
+}
+
+/* returns a string version of an IPv6 address in host order */
+static const char *get_ipv6_addr(struct in6_addr *addr)
+{
+ struct in6_addr a;
+ static char out[INET6_ADDRSTRLEN + 1];
+
+ memcpy(&a, addr, sizeof(struct in6_addr));
+ in6_bswap(&a);
+ return inet_ntop(AF_INET6, &a, out, INET6_ADDRSTRLEN + 1);
+}
+
+static const char *get_addr(struct in6_addr *addr)
+{
+ static char out[50];
+ snprintf(out, 50, "%08x:%08x:%08x:%08x",
+ addr->s6_addr32[0],
+ addr->s6_addr32[1],
+ addr->s6_addr32[2],
+ addr->s6_addr32[3]);
+ return out;
+}
+
+/* a <= b */
+static inline int a_le_b(struct in6_addr *a, struct in6_addr *b)
+{
+ if (a->s6_addr32[0] < b->s6_addr32[0]) return 1;
+ if (a->s6_addr32[0] > b->s6_addr32[0]) return 0;
+ if (a->s6_addr32[1] < b->s6_addr32[1]) return 1;
+ if (a->s6_addr32[1] > b->s6_addr32[1]) return 0;
+ if (a->s6_addr32[2] < b->s6_addr32[2]) return 1;
+ if (a->s6_addr32[2] > b->s6_addr32[2]) return 0;
+ if (a->s6_addr32[3] < b->s6_addr32[3]) return 1;
+ if (a->s6_addr32[3] > b->s6_addr32[3]) return 0;
+ return 1;
+}
+
+/* a == b */
+static inline int a_eq_b(struct in6_addr *a, struct in6_addr *b)
+{
+ if (a->s6_addr32[0] != b->s6_addr32[0]) return 0;
+ if (a->s6_addr32[1] != b->s6_addr32[1]) return 0;
+ if (a->s6_addr32[2] != b->s6_addr32[2]) return 0;
+ if (a->s6_addr32[3] != b->s6_addr32[3]) return 0;
+ return 1;
+}
+
+/* a > b */
+static inline int a_gt_b(struct in6_addr *a, struct in6_addr *b)
+{
+ if (a->s6_addr32[0] > b->s6_addr32[0]) return 1;
+ if (a->s6_addr32[0] < b->s6_addr32[0]) return 0;
+ if (a->s6_addr32[1] > b->s6_addr32[1]) return 1;
+ if (a->s6_addr32[1] < b->s6_addr32[1]) return 0;
+ if (a->s6_addr32[2] > b->s6_addr32[2]) return 1;
+ if (a->s6_addr32[2] < b->s6_addr32[2]) return 0;
+ if (a->s6_addr32[3] > b->s6_addr32[3]) return 1;
+ if (a->s6_addr32[3] < b->s6_addr32[3]) return 0;
+ return 0;
+}
+
+/* ( 1 << m ) - 1 -> r */
+static inline struct in6_addr *hmask(unsigned int b, struct in6_addr *r)
+{
+
+ if (b < 32) {
+ r->s6_addr32[3] = (1 << b) - 1;
+ r->s6_addr32[2] = 0;
+ r->s6_addr32[1] = 0;
+ r->s6_addr32[0] = 0;
+ }
+ else if (b < 64) {
+ r->s6_addr32[3] = 0xffffffff;
+ r->s6_addr32[2] = (1 << (b - 32)) - 1;
+ r->s6_addr32[1] = 0;
+ r->s6_addr32[0] = 0;
+ }
+ else if (b < 96) {
+ r->s6_addr32[3] = 0xffffffff;
+ r->s6_addr32[2] = 0xffffffff;
+ r->s6_addr32[1] = (1 << (b - 64)) - 1;
+ r->s6_addr32[0] = 0;
+ }
+ else if (b < 128) {
+ r->s6_addr32[3] = 0xffffffff;
+ r->s6_addr32[2] = 0xffffffff;
+ r->s6_addr32[1] = 0xffffffff;
+ r->s6_addr32[0] = (1 << (b - 96)) - 1;
+ }
+ else {
+ r->s6_addr32[3] = 0xffffffff;
+ r->s6_addr32[2] = 0xffffffff;
+ r->s6_addr32[1] = 0xffffffff;
+ r->s6_addr32[0] = 0xffffffff;
+ }
+ return r;
+}
+
+/* 1 << b -> r */
+static inline struct in6_addr *one_ls_b(unsigned int b, struct in6_addr *r)
+{
+ if (b < 32) {
+ r->s6_addr32[3] = 1 << b;
+ r->s6_addr32[2] = 0;
+ r->s6_addr32[1] = 0;
+ r->s6_addr32[0] = 0;
+ }
+ else if (b < 64) {
+ r->s6_addr32[3] = 0;
+ r->s6_addr32[2] = 1 << (b - 32);
+ r->s6_addr32[1] = 0;
+ r->s6_addr32[0] = 0;
+ }
+ else if (b < 96) {
+ r->s6_addr32[3] = 0;
+ r->s6_addr32[2] = 0;
+ r->s6_addr32[1] = 1 << (b - 64);
+ r->s6_addr32[0] = 0;
+ }
+ else if (b < 128) {
+ r->s6_addr32[3] = 0;
+ r->s6_addr32[2] = 0;
+ r->s6_addr32[1] = 0;
+ r->s6_addr32[0] = 1 << (b - 96);
+ }
+ else {
+ r->s6_addr32[3] = 0;
+ r->s6_addr32[2] = 0;
+ r->s6_addr32[1] = 0;
+ r->s6_addr32[0] = 0;
+ }
+ return r;
+}
+
+/* a + b -> r */
+static inline struct in6_addr *a_plus_b(struct in6_addr *a, struct in6_addr *b, struct in6_addr *r)
+{
+ unsigned long long int c = 0;
+ int i;
+
+ for (i=3; i>=0; i--) {
+ c = (unsigned long long int)a->s6_addr32[i] +
+ (unsigned long long int)b->s6_addr32[i] + c;
+ r->s6_addr32[i] = c;
+ c >>= 32;
+ }
+
+ return r;
+}
+
+/* a - b -> r */
+static inline struct in6_addr *a_minus_b(struct in6_addr *a, struct in6_addr *b, struct in6_addr *r)
+{
+ signed long long int c = 0;
+ signed long long int d;
+ int i;
+
+ /* Check sign. Return 0xff..ff (-1) if the result is less than 0. */
+ if (a_gt_b(b, a)) {
+ r->s6_addr32[3] = 0xffffffff;
+ r->s6_addr32[2] = 0xffffffff;
+ r->s6_addr32[1] = 0xffffffff;
+ r->s6_addr32[0] = 0xffffffff;
+ return r;
+ }
+
+ for (i=3; i>=0; i--) {
+ d = (unsigned long long int)b->s6_addr32[i] + c;
+ c = (unsigned long long int)a->s6_addr32[i];
+ if (c < d)
+ c += 0x100000000ULL;
+ c -= d;
+ r->s6_addr32[i] = c;
+ c >>= 32;
+ }
+
+ return r;
+}
+
+/* a & b -> r */
+static inline struct in6_addr *a_and_b(struct in6_addr *a, struct in6_addr *b, struct in6_addr *r)
+{
+ r->s6_addr32[0] = a->s6_addr32[0] & b->s6_addr32[0];
+ r->s6_addr32[1] = a->s6_addr32[1] & b->s6_addr32[1];
+ r->s6_addr32[2] = a->s6_addr32[2] & b->s6_addr32[2];
+ r->s6_addr32[3] = a->s6_addr32[3] & b->s6_addr32[3];
+ return r;
+}
+
+/* a != 0 */
+int is_set(struct in6_addr *a)
+{
+ return a->s6_addr32[0] ||
+ a->s6_addr32[1] ||
+ a->s6_addr32[2] ||
+ a->s6_addr32[3];
+}
+
+/* 1 */
+static struct in6_addr one = { .s6_addr32 = {0, 0, 0, 1} };
+
+/* print all networks present between address <low> and address <high> in
+ * cidr format, followed by <eol>.
+ */
+static void convert_range(struct in6_addr *low, struct in6_addr *high, const char *eol, const char *pfx)
+{
+ int bit;
+ struct in6_addr r0;
+ struct in6_addr r1;
+
+ if (a_eq_b(low, high)) {
+ /* single value */
+ printf("%s%s%s%s\n", pfx?pfx:"", pfx?" ":"", get_ipv6_addr(low), eol);
+ return;
+ }
+ else if (a_gt_b(low, high)) {
+ struct in6_addr *swap = low;
+ low = high;
+ high = swap;
+ }
+
+ if (a_eq_b(low, a_plus_b(high, &one, &r0))) {
+ /* full range */
+ printf("%s%s::/0%s\n", pfx?pfx:"", pfx?" ":"", eol);
+ return;
+ }
+ //printf("low=%08x high=%08x\n", low, high);
+
+ bit = 0;
+ while (bit < 128 && a_le_b(a_plus_b(low, hmask(bit, &r0), &r0), high)) {
+
+ /* enlarge mask */
+ if (is_set(a_and_b(low, one_ls_b(bit, &r0), &r0))) {
+ /* can't aggregate anymore, dump and retry from the same bit */
+ printf("%s%s%s/%d%s\n", pfx?pfx:"", pfx?" ":"", get_ipv6_addr(low), 128-bit, eol);
+ a_plus_b(low, one_ls_b(bit, &r0), low);
+ }
+ else {
+ /* try to enlarge the mask as much as possible first */
+ bit++;
+ //printf(" ++bit=%d\n", bit);
+ }
+ }
+ //printf("stopped 1 at low=%08x, bit=%d\n", low, bit);
+
+ bit = 127;
+ while (bit >= 0 && is_set(a_plus_b(a_minus_b(high, low, &r0), &one, &r0))) {
+
+ /* shrink mask */
+ if (is_set(a_and_b(a_plus_b(a_minus_b(high, low, &r0), &one, &r0), one_ls_b(bit, &r1), &r1))) {
+ /* large bit accepted, dump and go on from the same bit */
+ //printf("max: %08x/%d\n", low, 32-bit);
+ printf("%s%s%s/%d%s\n", pfx?pfx:"", pfx?" ":"", get_ipv6_addr(low), 128-bit, eol);
+ a_plus_b(low, one_ls_b(bit, &r0), low);
+ }
+ else {
+ bit--;
+ //printf(" --bit=%d, low=%08x\n", bit, low);
+ }
+ }
+ //printf("stopped at low=%08x\n", low);
+}
+
+static void usage(const char *argv0)
+{
+ fprintf(stderr,
+ "Usage: %s [<addr> ...] < iplist.csv\n"
+ "\n"
+ "This program reads lines starting by two IP addresses and outputs them with\n"
+ "the two IP addresses replaced by a netmask covering the range between these\n"
+ "IPs (inclusive). When multiple ranges are needed, as many lines are emitted.\n"
+ "The IP addresses may be delimited by spaces, tabs or commas. Quotes are\n"
+ "stripped, and lines beginning with a sharp character ('#') are ignored. The\n"
+ "IP addresses may be either in the dotted format or represented as a 32-bit\n"
+ "integer value in network byte order.\n"
+ "\n"
+ "For each optional <addr> specified, only the network it belongs to is returned,\n"
+ "prefixed with the <addr> value.\n"
+ "\n", argv0);
+}
+
+int main(int argc, char **argv)
+{
+ char line[MAXLINE];
+ int l, lnum;
+ char *lb, *le, *hb, *he, *err;
+ struct in6_addr sa, da, ta;
+
+ if (argc > 1 && *argv[1] == '-') {
+ usage(argv[0]);
+ exit(1);
+ }
+
+ lnum = 0;
+ while (fgets(line, sizeof(line), stdin) != NULL) {
+ l = strlen(line);
+ if (l && line[l - 1] == '\n')
+ line[--l] = '\0';
+
+ lnum++;
+ /* look for the first field which must be the low address of a range,
+ * in dotted IPv4 format or as an integer. spaces and commas are
+ * considered as delimiters, quotes are removed.
+ */
+ for (lb = line; *lb == ' ' || *lb == '\t' || *lb == ',' || *lb == '"'; lb++);
+ if (!*lb || *lb == '#')
+ continue;
+ for (le = lb + 1; *le != ' ' && *le != '\t' && *le != ',' && *le != '"' && *le; le++);
+ if (!*le)
+ continue;
+ /* we have the low address between lb(included) and le(excluded) */
+ *(le++) = 0;
+
+ for (hb = le; *hb == ' ' || *hb == '\t' || *hb == ',' || *hb == '"'; hb++);
+ if (!*hb || *hb == '#')
+ continue;
+ for (he = hb + 1; *he != ' ' && *he != '\t' && *he != ',' && *he != '"' && *he; he++);
+ if (!*he)
+ continue;
+ /* we have the high address between hb(included) and he(excluded) */
+ *(he++) = 0;
+
+ /* we want to remove a possible ending quote and a possible comma,
+ * not more.
+ */
+ while (*he == '"')
+ *(he++) = ' ';
+ while (*he == ',' || *he == ' ' || *he == '\t')
+ *(he++) = ' ';
+
+ /* if the trailing string is not empty, prefix it with a space */
+ if (*(he-1) == ' ')
+ he--;
+
+ if (inet_pton(AF_INET6, lb, &sa) <= 0) {
+ fprintf(stderr, "Failed to parse source address <%s> at line %d, skipping line\n", lb, lnum);
+ continue;
+ }
+
+ if (inet_pton(AF_INET6, hb, &da) <= 0) {
+ fprintf(stderr, "Failed to parse destination address <%s> at line %d, skipping line\n", hb, lnum);
+ continue;
+ }
+
+ in6_bswap(&sa);
+ in6_bswap(&da);
+
+ if (argc > 1) {
+ for (l = 1; l < argc; l++) {
+ if (inet_pton(AF_INET6, argv[l], &da) <= 0)
+ continue;
+ in6_bswap(&ta);
+ if ((a_le_b(&sa, &ta) && a_le_b(&ta, &da)) || (a_le_b(&da, &ta) && a_le_b(&ta, &sa)))
+ convert_range(&sa, &da, he, argv[l]);
+ }
+ }
+ else {
+ convert_range(&sa, &da, he, NULL);
+ }
+ }
+ return 0;
+}
diff --git a/admin/iprange/iprange.c b/admin/iprange/iprange.c
new file mode 100644
index 0000000..abae007
--- /dev/null
+++ b/admin/iprange/iprange.c
@@ -0,0 +1,202 @@
+/*
+ * network range to IP+mask converter
+ *
+ * Copyright 2011-2012 Willy Tarreau <w@1wt.eu>
+ *
+ * This program reads lines starting by two IP addresses and outputs them with
+ * the two IP addresses replaced by a netmask covering the range between these
+ * IPs (inclusive). When multiple ranges are needed, as many lines are emitted.
+ * The IP addresses may be delimited by spaces, tabs or commas. Quotes are
+ * stripped, and lines beginning with a sharp character ('#') are ignored. The
+ * IP addresses may be either in the dotted format or represented as a 32-bit
+ * integer value in network byte order.
+ *
+ * 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
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define MAXLINE 1024
+
+/* returns a string version of an IPv4 address in host order */
+static const char *get_ipv4_addr(unsigned int addr)
+{
+ struct in_addr a;
+
+ a.s_addr = ntohl(addr);
+ return inet_ntoa(a);
+}
+
+/* print all networks present between address <low> and address <high> in
+ * cidr format, followed by <eol>.
+ */
+static void convert_range(unsigned int low, unsigned int high, const char *eol, const char *pfx)
+{
+ int bit;
+
+ if (low == high) {
+ /* single value */
+ printf("%s%s%s%s\n", pfx?pfx:"", pfx?" ":"", get_ipv4_addr(low), eol);
+ return;
+ }
+ else if (low > high) {
+ int swap = low;
+ low = high;
+ high = swap;
+ }
+
+ if (low == high + 1) {
+ /* full range */
+ printf("%s%s0.0.0.0/0%s\n", pfx?pfx:"", pfx?" ":"", eol);
+ return;
+ }
+ //printf("low=%08x high=%08x\n", low, high);
+
+ bit = 0;
+ while (bit < 32 && low + (1 << bit) - 1 <= high) {
+ /* enlarge mask */
+ if (low & (1 << bit)) {
+ /* can't aggregate anymore, dump and retry from the same bit */
+ printf("%s%s%s/%d%s\n", pfx?pfx:"", pfx?" ":"", get_ipv4_addr(low), 32-bit, eol);
+ low += (1 << bit);
+ }
+ else {
+ /* try to enlarge the mask as much as possible first */
+ bit++;
+ //printf(" ++bit=%d\n", bit);
+ }
+ }
+ //printf("stopped 1 at low=%08x, bit=%d\n", low, bit);
+
+ bit = 31;
+ while (bit >= 0 && high - low + 1 != 0) {
+ /* shrink mask */
+ if ((high - low + 1) & (1 << bit)) {
+ /* large bit accepted, dump and go on from the same bit */
+ //printf("max: %08x/%d\n", low, 32-bit);
+ printf("%s%s%s/%d%s\n", pfx?pfx:"", pfx?" ":"", get_ipv4_addr(low), 32-bit, eol);
+ low += (1 << bit);
+ }
+ else {
+ bit--;
+ //printf(" --bit=%d, low=%08x\n", bit, low);
+ }
+ }
+ //printf("stopped at low=%08x\n", low);
+}
+
+static void usage(const char *argv0)
+{
+ fprintf(stderr,
+ "Usage: %s [<addr> ...] < iplist.csv\n"
+ "\n"
+ "This program reads lines starting by two IP addresses and outputs them with\n"
+ "the two IP addresses replaced by a netmask covering the range between these\n"
+ "IPs (inclusive). When multiple ranges are needed, as many lines are emitted.\n"
+ "The IP addresses may be delimited by spaces, tabs or commas. Quotes are\n"
+ "stripped, and lines beginning with a sharp character ('#') are ignored. The\n"
+ "IP addresses may be either in the dotted format or represented as a 32-bit\n"
+ "integer value in network byte order.\n"
+ "\n"
+ "For each optional <addr> specified, only the network it belongs to is returned,\n"
+ "prefixed with the <addr> value.\n"
+ "\n", argv0);
+}
+
+int main(int argc, char **argv)
+{
+ char line[MAXLINE];
+ int l, lnum;
+ char *lb, *le, *hb, *he, *err;
+ struct in_addr src_addr, dst_addr;
+ unsigned int sa, da, ta;
+
+ if (argc > 1 && *argv[1] == '-') {
+ usage(argv[0]);
+ exit(1);
+ }
+
+ lnum = 0;
+ while (fgets(line, sizeof(line), stdin) != NULL) {
+ l = strlen(line);
+ if (l && line[l - 1] == '\n')
+ line[--l] = '\0';
+
+ lnum++;
+ /* look for the first field which must be the low address of a range,
+ * in dotted IPv4 format or as an integer. spaces and commas are
+ * considered as delimiters, quotes are removed.
+ */
+ for (lb = line; *lb == ' ' || *lb == '\t' || *lb == ',' || *lb == '"'; lb++);
+ if (!*lb || *lb == '#')
+ continue;
+ for (le = lb + 1; *le != ' ' && *le != '\t' && *le != ',' && *le != '"' && *le; le++);
+ if (!*le)
+ continue;
+ /* we have the low address between lb(included) and le(excluded) */
+ *(le++) = 0;
+
+ for (hb = le; *hb == ' ' || *hb == '\t' || *hb == ',' || *hb == '"'; hb++);
+ if (!*hb || *hb == '#')
+ continue;
+ for (he = hb + 1; *he != ' ' && *he != '\t' && *he != ',' && *he != '"' && *he; he++);
+ if (!*he)
+ continue;
+ /* we have the high address between hb(included) and he(excluded) */
+ *(he++) = 0;
+
+ /* we want to remove a possible ending quote and a possible comma,
+ * not more.
+ */
+ while (*he == '"')
+ *(he++) = ' ';
+ while (*he == ',' || *he == ' ' || *he == '\t')
+ *(he++) = ' ';
+
+ /* if the trailing string is not empty, prefix it with a space */
+ if (*(he-1) == ' ')
+ he--;
+
+ if (inet_pton(AF_INET, lb, &src_addr) <= 0) {
+ /* parsing failed, retry with a plain numeric IP */
+ src_addr.s_addr = ntohl(strtoul(lb, &err, 10));
+ if (err && *err) {
+ fprintf(stderr, "Failed to parse source address <%s> at line %d, skipping line\n", lb, lnum);
+ continue;
+ }
+ }
+
+ if (inet_pton(AF_INET, hb, &dst_addr) <= 0) {
+ /* parsing failed, retry with a plain numeric IP */
+ dst_addr.s_addr = ntohl(strtoul(hb, &err, 10));
+ if (err && *err) {
+ fprintf(stderr, "Failed to parse destination address <%s> at line %d, skipping line\n", hb, lnum);
+ continue;
+ }
+ }
+
+ sa = htonl(src_addr.s_addr);
+ da = htonl(dst_addr.s_addr);
+ if (argc > 1) {
+ for (l = 1; l < argc; l++) {
+ if (inet_pton(AF_INET, argv[l], &dst_addr) <= 0)
+ continue;
+ ta = htonl(dst_addr.s_addr);
+ if ((sa <= ta && ta <= da) || (da <= ta && ta <= sa))
+ convert_range(sa, da, he, argv[l]);
+ }
+ }
+ else {
+ convert_range(sa, da, he, NULL);
+ }
+ }
+ exit(0);
+}
diff --git a/admin/netsnmp-perl/README b/admin/netsnmp-perl/README
new file mode 100644
index 0000000..f44eb5b
--- /dev/null
+++ b/admin/netsnmp-perl/README
@@ -0,0 +1,111 @@
+SNMP support for HAProxy
+Copyright 2007-2008 Krzysztof Piotr Oledzki <ole@ans.pl>
+
+Root OID: 1.3.6.1.4.1.29385.106
+
+Files:
+ - README: this file
+ - haproxy.pl: Net-SNMP embedded perl module
+ - haproxy_backend.xml: Cacti snmp-query definition for backends
+ - haproxy_frontend.xml: Cacti snmp-query definition for frontends
+
+Install:
+ cp haproxy.pl /etc/snmp/
+ grep -q "disablePerl false" /etc/snmp/snmpd.conf || echo "disablePerl false" >> /etc/snmp/snmpd.conf
+ echo "perl do '/etc/snmp/haproxy.pl';" >> /etc/snmp/snmpd.conf
+
+Supported commands:
+ - GET (snmpget, snmpbulkget): quite fast.
+ - GETNEXT (snmpwalk, snmpbulkwalk): not so fast as requires to transfer
+ and parse a lot of data during each step. Always use "get" instead of "walk"
+ if that's possible.
+
+Supported OIDs:
+ - 1.3.6.1.4.1.29385.106.1: get a variable from stats
+ Usage: 1.3.6.1.4.1.29385.106.1.$type.$field.$iid.$sid
+
+ - type is one of:
+ 0) frontend
+ 1) backend
+ 2) server
+
+ - field is one of:
+ 0..32) CSV format variable
+ 10001) index
+ 10002) unique name
+
+ - iid is a proxy id
+
+ - sid is a service id (sid): 0 for frontends and backends, >= 1 for servers
+
+ - 1.3.6.1.4.1.29385.106.2: get a variable from info
+ Usage: 1.3.6.1.4.1.29385.106.2.$req.$varnr
+
+ - req is one of:
+ 0) get variable name
+ 1) gat variable value
+
+Examples:
+
+- Get a list of frontends (type: 0) with status (field: 17):
+$ snmpbulkwalk -c public -v2c 192.168.0.1 1.3.6.1.4.1.29385.106.1.0.17
+SNMPv2-SMI::enterprises.29385.106.1.0.17.1.0 = STRING: "OPEN"
+SNMPv2-SMI::enterprises.29385.106.1.0.17.47.0 = STRING: "OPEN"
+
+- Get a list of backends (type: 1) with index (field: 10001):
+$ snmpbulkwalk -c public -v2c 192.168.0.1 1.3.6.1.4.1.29385.106.1.1.10001
+SNMPv2-SMI::enterprises.29385.106.1.1.10001.1.0 = STRING: "1.0"
+SNMPv2-SMI::enterprises.29385.106.1.1.10001.1100.0 = STRING: "1100.0"
+SNMPv2-SMI::enterprises.29385.106.1.1.10001.1101.0 = STRING: "1101.0"
+SNMPv2-SMI::enterprises.29385.106.1.1.10001.1200.0 = STRING: "1200.0"
+SNMPv2-SMI::enterprises.29385.106.1.1.10001.1201.0 = STRING: "1201.0"
+SNMPv2-SMI::enterprises.29385.106.1.1.10001.1300.0 = STRING: "1300.0"
+SNMPv2-SMI::enterprises.29385.106.1.1.10001.1400.0 = STRING: "1400.0"
+SNMPv2-SMI::enterprises.29385.106.1.1.10001.1401.0 = STRING: "1401.0"
+SNMPv2-SMI::enterprises.29385.106.1.1.10001.1500.0 = STRING: "1500.0"
+(...)
+
+- Get a list of servers (type: 2) with unique name (field: 10002):
+$ snmpbulkwalk -c public -v2c 192.168.0.1 1.3.6.1.4.1.29385.106.1.2.10002
+SNMPv2-SMI::enterprises.29385.106.1.2.10002.1100.1001 = STRING: "backend1/s2"
+SNMPv2-SMI::enterprises.29385.106.1.2.10002.1100.1002 = STRING: "backend1/s5"
+SNMPv2-SMI::enterprises.29385.106.1.2.10002.1100.1003 = STRING: "backend1/s6"
+SNMPv2-SMI::enterprises.29385.106.1.2.10002.1100.1012 = STRING: "backend1/s7"
+SNMPv2-SMI::enterprises.29385.106.1.2.10002.1101.1001 = STRING: "backend2/s9"
+SNMPv2-SMI::enterprises.29385.106.1.2.10002.1101.1002 = STRING: "backend2/s10"
+SNMPv2-SMI::enterprises.29385.106.1.2.10002.1101.1003 = STRING: "backend2/s11"
+SNMPv2-SMI::enterprises.29385.106.1.2.10002.1101.1012 = STRING: "backend2/s12"
+SNMPv2-SMI::enterprises.29385.106.1.2.10002.1200.1001 = STRING: "backend3/s8"
+(...)
+
+- Get a list of servers (type: 2) with weight (field: 18) in proxy 4300:
+$ snmpbulkwalk -c public -v2c 192.168.0.1 1.3.6.1.4.1.29385.106.1.2.18.4300
+SNMPv2-SMI::enterprises.29385.106.1.2.18.4300.1001 = STRING: "40"
+SNMPv2-SMI::enterprises.29385.106.1.2.18.4300.1002 = STRING: "25"
+SNMPv2-SMI::enterprises.29385.106.1.2.18.4300.1003 = STRING: "40"
+SNMPv2-SMI::enterprises.29385.106.1.2.18.4300.1012 = STRING: "80"
+
+- Get total sessions count (field: 7) in frontend (type: 1), sid.iid: 47.0 (proxy #47):
+snmpget -c public -v2c 192.168.0.1 enterprises.29385.106.1.0.7.47.0
+SNMPv2-SMI::enterprises.29385.106.1.0.7.47.0 = STRING: "1014019"
+
+- Get a list of available variables (req: 0):
+$ snmpbulkwalk -c public -v2c 192.168.0.1 1.3.6.1.4.1.29385.106.2.0
+SNMPv2-SMI::enterprises.29385.106.2.0.0 = STRING: "Name"
+SNMPv2-SMI::enterprises.29385.106.2.0.1 = STRING: "Version"
+SNMPv2-SMI::enterprises.29385.106.2.0.2 = STRING: "Release_date"
+SNMPv2-SMI::enterprises.29385.106.2.0.3 = STRING: "Nbproc"
+SNMPv2-SMI::enterprises.29385.106.2.0.4 = STRING: "Process_num"
+SNMPv2-SMI::enterprises.29385.106.2.0.5 = STRING: "Pid"
+SNMPv2-SMI::enterprises.29385.106.2.0.6 = STRING: "Uptime"
+SNMPv2-SMI::enterprises.29385.106.2.0.7 = STRING: "Uptime_sec"
+SNMPv2-SMI::enterprises.29385.106.2.0.8 = STRING: "Memmax_MB"
+SNMPv2-SMI::enterprises.29385.106.2.0.9 = STRING: "Ulimit-n"
+SNMPv2-SMI::enterprises.29385.106.2.0.10 = STRING: "Maxsock"
+SNMPv2-SMI::enterprises.29385.106.2.0.11 = STRING: "Maxconn"
+SNMPv2-SMI::enterprises.29385.106.2.0.12 = STRING: "CurrConns"
+
+- Get a variable (req: 1), varnr: 7 (Uptime_sec):
+$ snmpget -c public -v2c 192.168.0.1 1.3.6.1.4.1.29385.106.2.1.7
+SNMPv2-SMI::enterprises.29385.106.2.1.7 = STRING: "18761"
+
diff --git a/admin/netsnmp-perl/cacti_data_query_haproxy_backends.xml b/admin/netsnmp-perl/cacti_data_query_haproxy_backends.xml
new file mode 100644
index 0000000..9c4ea38
--- /dev/null
+++ b/admin/netsnmp-perl/cacti_data_query_haproxy_backends.xml
@@ -0,0 +1,750 @@
+<cacti>
+ <hash_040013d1dd43e3e5cee941860ea277826c4fe2>
+ <name>HaProxy Backends</name>
+ <description></description>
+ <xml_path>&lt;path_cacti&gt;/resource/snmp_queries/haproxy_backend.xml</xml_path>
+ <data_input_id>hash_030013bf566c869ac6443b0c75d1c32b5a350e</data_input_id>
+ <graphs>
+ <hash_1100134d2954fa52f51ed186916f2cf624a8b9>
+ <name>HAProxy Backend Sessions</name>
+ <graph_template_id>hash_000013cdbf9accfcd57d9e0a7c97896313ddee</graph_template_id>
+ <rrd>
+ <item_000>
+ <snmp_field_name>beSTot</snmp_field_name>
+ <data_template_id>hash_010013fa4d4fff334b60e9064e89082173fe34</data_template_id>
+ <data_template_rrd_id>hash_080013230e04055a4228154123e74c6586d435</data_template_rrd_id>
+ </item_000>
+ <item_001>
+ <snmp_field_name>beEResp</snmp_field_name>
+ <data_template_id>hash_010013fa4d4fff334b60e9064e89082173fe34</data_template_id>
+ <data_template_rrd_id>hash_080013088549c8d7e8cdc80f19bae4d78dc296</data_template_rrd_id>
+ </item_001>
+ </rrd>
+ <sv_graph>
+ <hash_12001368ff8a0bfc447cb94d02e0d17cc3e252>
+ <field_name>ResponseErrors</field_name>
+ <sequence>1</sequence>
+ <text>ResponseErrors</text>
+ </hash_12001368ff8a0bfc447cb94d02e0d17cc3e252>
+ <hash_120013c2e81996ac5a70f67fa4a07e95eea035>
+ <field_name>TotalSessions</field_name>
+ <sequence>1</sequence>
+ <text>TotalSessions</text>
+ </hash_120013c2e81996ac5a70f67fa4a07e95eea035>
+ </sv_graph>
+ <sv_data_source>
+ <hash_130013169b7ea71d2aa3a8abaece19de7feeff>
+ <field_name>ResponseErrors</field_name>
+ <data_template_id>hash_010013fa4d4fff334b60e9064e89082173fe34</data_template_id>
+ <sequence>1</sequence>
+ <text>ResponseErrors</text>
+ </hash_130013169b7ea71d2aa3a8abaece19de7feeff>
+ <hash_130013a61ea1bb051f2162ba635c815324678d>
+ <field_name>TotalSessions</field_name>
+ <data_template_id>hash_010013fa4d4fff334b60e9064e89082173fe34</data_template_id>
+ <sequence>1</sequence>
+ <text>TotalSessions</text>
+ </hash_130013a61ea1bb051f2162ba635c815324678d>
+ </sv_data_source>
+ </hash_1100134d2954fa52f51ed186916f2cf624a8b9>
+ <hash_110013abc35ade0aae030d90f817dfd91486f4>
+ <name>HAProxy Backend Traffic</name>
+ <graph_template_id>hash_000013b6d238ff2532fcc19ab498043c7c65c2</graph_template_id>
+ <rrd>
+ <item_000>
+ <snmp_field_name>beBOut</snmp_field_name>
+ <data_template_id>hash_010013a63ddba34026d2c07d73c0ef2ae64b54</data_template_id>
+ <data_template_rrd_id>hash_0800136c0e4debeb9b084231d858faabd82f8f</data_template_rrd_id>
+ </item_000>
+ <item_001>
+ <snmp_field_name>beBIn</snmp_field_name>
+ <data_template_id>hash_010013a63ddba34026d2c07d73c0ef2ae64b54</data_template_id>
+ <data_template_rrd_id>hash_0800132f5283f17a7cde63137189d4d3ea7e4e</data_template_rrd_id>
+ </item_001>
+ </rrd>
+ <sv_graph>
+ <hash_1200133ba4a6c8aacf161f3e2411afd7053b8d>
+ <field_name>BytesIn</field_name>
+ <sequence>1</sequence>
+ <text>BytesIn</text>
+ </hash_1200133ba4a6c8aacf161f3e2411afd7053b8d>
+ <hash_1200130f8f674b52f6ea2e09608b505abfb3a1>
+ <field_name>BytesOut</field_name>
+ <sequence>1</sequence>
+ <text>BytesOut</text>
+ </hash_1200130f8f674b52f6ea2e09608b505abfb3a1>
+ </sv_graph>
+ <sv_data_source>
+ <hash_130013d9fb3064081d77e553c5ce732f15c909>
+ <field_name>BytesIn</field_name>
+ <data_template_id>hash_010013fa4d4fff334b60e9064e89082173fe34</data_template_id>
+ <sequence>1</sequence>
+ <text>BytesIn</text>
+ </hash_130013d9fb3064081d77e553c5ce732f15c909>
+ <hash_1300134fc96e4392a7a86d05fda31c2d5d334c>
+ <field_name>BytesOut</field_name>
+ <data_template_id>hash_010013fa4d4fff334b60e9064e89082173fe34</data_template_id>
+ <sequence>1</sequence>
+ <text>BytesOut</text>
+ </hash_1300134fc96e4392a7a86d05fda31c2d5d334c>
+ <hash_130013a7aad3557880ac197539a1d658f5d5da>
+ <field_name>BytesIn</field_name>
+ <data_template_id>hash_010013a63ddba34026d2c07d73c0ef2ae64b54</data_template_id>
+ <sequence>1</sequence>
+ <text>BytesIn</text>
+ </hash_130013a7aad3557880ac197539a1d658f5d5da>
+ <hash_130013acb469b673f6adbaa21ad5c634c3683f>
+ <field_name>BytesOut</field_name>
+ <data_template_id>hash_010013a63ddba34026d2c07d73c0ef2ae64b54</data_template_id>
+ <sequence>1</sequence>
+ <text>BytesOut</text>
+ </hash_130013acb469b673f6adbaa21ad5c634c3683f>
+ </sv_data_source>
+ </hash_110013abc35ade0aae030d90f817dfd91486f4>
+ </graphs>
+ </hash_040013d1dd43e3e5cee941860ea277826c4fe2>
+ <hash_030013bf566c869ac6443b0c75d1c32b5a350e>
+ <name>Get SNMP Data (Indexed)</name>
+ <type_id>3</type_id>
+ <input_string></input_string>
+ <fields>
+ <hash_070013617cdc8a230615e59f06f361ef6e7728>
+ <name>SNMP IP Address</name>
+ <update_rra></update_rra>
+ <regexp_match></regexp_match>
+ <allow_nulls></allow_nulls>
+ <type_code>hostname</type_code>
+ <input_output>in</input_output>
+ <data_name>management_ip</data_name>
+ </hash_070013617cdc8a230615e59f06f361ef6e7728>
+ <hash_070013acb449d1451e8a2a655c2c99d31142c7>
+ <name>SNMP Community</name>
+ <update_rra></update_rra>
+ <regexp_match></regexp_match>
+ <allow_nulls></allow_nulls>
+ <type_code>snmp_community</type_code>
+ <input_output>in</input_output>
+ <data_name>snmp_community</data_name>
+ </hash_070013acb449d1451e8a2a655c2c99d31142c7>
+ <hash_070013f4facc5e2ca7ebee621f09bc6d9fc792>
+ <name>SNMP Username (v3)</name>
+ <update_rra></update_rra>
+ <regexp_match></regexp_match>
+ <allow_nulls>on</allow_nulls>
+ <type_code>snmp_username</type_code>
+ <input_output>in</input_output>
+ <data_name>snmp_username</data_name>
+ </hash_070013f4facc5e2ca7ebee621f09bc6d9fc792>
+ <hash_0700131cc1493a6781af2c478fa4de971531cf>
+ <name>SNMP Password (v3)</name>
+ <update_rra></update_rra>
+ <regexp_match></regexp_match>
+ <allow_nulls>on</allow_nulls>
+ <type_code>snmp_password</type_code>
+ <input_output>in</input_output>
+ <data_name>snmp_password</data_name>
+ </hash_0700131cc1493a6781af2c478fa4de971531cf>
+ <hash_070013b5c23f246559df38662c255f4aa21d6b>
+ <name>SNMP Version (1, 2, or 3)</name>
+ <update_rra></update_rra>
+ <regexp_match></regexp_match>
+ <allow_nulls></allow_nulls>
+ <type_code>snmp_version</type_code>
+ <input_output>in</input_output>
+ <data_name>snmp_version</data_name>
+ </hash_070013b5c23f246559df38662c255f4aa21d6b>
+ <hash_0700136027a919c7c7731fbe095b6f53ab127b>
+ <name>Index Type</name>
+ <update_rra></update_rra>
+ <regexp_match></regexp_match>
+ <allow_nulls></allow_nulls>
+ <type_code>index_type</type_code>
+ <input_output>in</input_output>
+ <data_name>index_type</data_name>
+ </hash_0700136027a919c7c7731fbe095b6f53ab127b>
+ <hash_070013cbbe5c1ddfb264a6e5d509ce1c78c95f>
+ <name>Index Value</name>
+ <update_rra></update_rra>
+ <regexp_match></regexp_match>
+ <allow_nulls></allow_nulls>
+ <type_code>index_value</type_code>
+ <input_output>in</input_output>
+ <data_name>index_value</data_name>
+ </hash_070013cbbe5c1ddfb264a6e5d509ce1c78c95f>
+ <hash_070013e6deda7be0f391399c5130e7c4a48b28>
+ <name>Output Type ID</name>
+ <update_rra></update_rra>
+ <regexp_match></regexp_match>
+ <allow_nulls></allow_nulls>
+ <type_code>output_type</type_code>
+ <input_output>in</input_output>
+ <data_name>output_type</data_name>
+ </hash_070013e6deda7be0f391399c5130e7c4a48b28>
+ <hash_070013c1f36ee60c3dc98945556d57f26e475b>
+ <name>SNMP Port</name>
+ <update_rra></update_rra>
+ <regexp_match></regexp_match>
+ <allow_nulls></allow_nulls>
+ <type_code>snmp_port</type_code>
+ <input_output>in</input_output>
+ <data_name>snmp_port</data_name>
+ </hash_070013c1f36ee60c3dc98945556d57f26e475b>
+ </fields>
+ </hash_030013bf566c869ac6443b0c75d1c32b5a350e>
+ <hash_000013cdbf9accfcd57d9e0a7c97896313ddee>
+ <name>HAProxy Backend Sessions</name>
+ <graph>
+ <t_title></t_title>
+ <title>|host_description| - HaProxy - |query_bePxName| Backend Sessions</title>
+ <t_image_format_id></t_image_format_id>
+ <image_format_id>1</image_format_id>
+ <t_height></t_height>
+ <height>120</height>
+ <t_width></t_width>
+ <width>500</width>
+ <t_auto_scale></t_auto_scale>
+ <auto_scale>on</auto_scale>
+ <t_auto_scale_opts></t_auto_scale_opts>
+ <auto_scale_opts>2</auto_scale_opts>
+ <t_auto_scale_log></t_auto_scale_log>
+ <auto_scale_log></auto_scale_log>
+ <t_auto_scale_rigid></t_auto_scale_rigid>
+ <auto_scale_rigid></auto_scale_rigid>
+ <t_auto_padding></t_auto_padding>
+ <auto_padding>on</auto_padding>
+ <t_export></t_export>
+ <export>on</export>
+ <t_upper_limit></t_upper_limit>
+ <upper_limit>10000</upper_limit>
+ <t_lower_limit></t_lower_limit>
+ <lower_limit>0</lower_limit>
+ <t_base_value></t_base_value>
+ <base_value>1000</base_value>
+ <t_unit_value></t_unit_value>
+ <unit_value></unit_value>
+ <t_unit_exponent_value></t_unit_exponent_value>
+ <unit_exponent_value></unit_exponent_value>
+ <t_vertical_label></t_vertical_label>
+ <vertical_label></vertical_label>
+ </graph>
+ <items>
+ <hash_1000131ecaf3728447913a30dfa80cdd9cdff4>
+ <task_item_id>hash_080013230e04055a4228154123e74c6586d435</task_item_id>
+ <color_id>0000FF</color_id>
+ <graph_type_id>5</graph_type_id>
+ <consolidation_function_id>1</consolidation_function_id>
+ <cdef_id>0</cdef_id>
+ <value></value>
+ <gprint_id>hash_060013e9c43831e54eca8069317a2ce8c6f751</gprint_id>
+ <text_format>Total Sessions:</text_format>
+ <hard_return></hard_return>
+ <sequence>5</sequence>
+ </hash_1000131ecaf3728447913a30dfa80cdd9cdff4>
+ <hash_1000132171a00b34d33f99ef24bcc235fbb6a3>
+ <task_item_id>hash_080013230e04055a4228154123e74c6586d435</task_item_id>
+ <color_id>0</color_id>
+ <graph_type_id>9</graph_type_id>
+ <consolidation_function_id>4</consolidation_function_id>
+ <cdef_id>0</cdef_id>
+ <value></value>
+ <gprint_id>hash_060013e9c43831e54eca8069317a2ce8c6f751</gprint_id>
+ <text_format>Current:</text_format>
+ <hard_return></hard_return>
+ <sequence>6</sequence>
+ </hash_1000132171a00b34d33f99ef24bcc235fbb6a3>
+ <hash_1000132129590e72a46480422f85e063d8cf4d>
+ <task_item_id>hash_080013230e04055a4228154123e74c6586d435</task_item_id>
+ <color_id>0</color_id>
+ <graph_type_id>9</graph_type_id>
+ <consolidation_function_id>1</consolidation_function_id>
+ <cdef_id>0</cdef_id>
+ <value></value>
+ <gprint_id>hash_060013e9c43831e54eca8069317a2ce8c6f751</gprint_id>
+ <text_format>Average:</text_format>
+ <hard_return></hard_return>
+ <sequence>7</sequence>
+ </hash_1000132129590e72a46480422f85e063d8cf4d>
+ <hash_1000138d11fec869f88ccf2fa3227bcffadfc3>
+ <task_item_id>hash_080013230e04055a4228154123e74c6586d435</task_item_id>
+ <color_id>0</color_id>
+ <graph_type_id>9</graph_type_id>
+ <consolidation_function_id>3</consolidation_function_id>
+ <cdef_id>0</cdef_id>
+ <value></value>
+ <gprint_id>hash_060013e9c43831e54eca8069317a2ce8c6f751</gprint_id>
+ <text_format>Maximum:</text_format>
+ <hard_return>on</hard_return>
+ <sequence>8</sequence>
+ </hash_1000138d11fec869f88ccf2fa3227bcffadfc3>
+ <hash_100013783d295131617ad996e4699533a134ea>
+ <task_item_id>hash_080013088549c8d7e8cdc80f19bae4d78dc296</task_item_id>
+ <color_id>EA8F00</color_id>
+ <graph_type_id>5</graph_type_id>
+ <consolidation_function_id>1</consolidation_function_id>
+ <cdef_id>0</cdef_id>
+ <value></value>
+ <gprint_id>hash_060013e9c43831e54eca8069317a2ce8c6f751</gprint_id>
+ <text_format>Response Errors:</text_format>
+ <hard_return></hard_return>
+ <sequence>9</sequence>
+ </hash_100013783d295131617ad996e4699533a134ea>
+ <hash_1000139bc04e5072b25ca992ee0b0eec981b95>
+ <task_item_id>hash_080013088549c8d7e8cdc80f19bae4d78dc296</task_item_id>
+ <color_id>0</color_id>
+ <graph_type_id>9</graph_type_id>
+ <consolidation_function_id>4</consolidation_function_id>
+ <cdef_id>0</cdef_id>
+ <value></value>
+ <gprint_id>hash_060013e9c43831e54eca8069317a2ce8c6f751</gprint_id>
+ <text_format>Current:</text_format>
+ <hard_return></hard_return>
+ <sequence>10</sequence>
+ </hash_1000139bc04e5072b25ca992ee0b0eec981b95>
+ <hash_1000136333a9334fa0dc0d2f75c031dee1dcc5>
+ <task_item_id>hash_080013088549c8d7e8cdc80f19bae4d78dc296</task_item_id>
+ <color_id>0</color_id>
+ <graph_type_id>9</graph_type_id>
+ <consolidation_function_id>1</consolidation_function_id>
+ <cdef_id>0</cdef_id>
+ <value></value>
+ <gprint_id>hash_060013e9c43831e54eca8069317a2ce8c6f751</gprint_id>
+ <text_format>Average:</text_format>
+ <hard_return></hard_return>
+ <sequence>11</sequence>
+ </hash_1000136333a9334fa0dc0d2f75c031dee1dcc5>
+ <hash_10001386e0e18d79915cd21ff123fb830e150e>
+ <task_item_id>hash_080013088549c8d7e8cdc80f19bae4d78dc296</task_item_id>
+ <color_id>0</color_id>
+ <graph_type_id>9</graph_type_id>
+ <consolidation_function_id>3</consolidation_function_id>
+ <cdef_id>0</cdef_id>
+ <value></value>
+ <gprint_id>hash_060013e9c43831e54eca8069317a2ce8c6f751</gprint_id>
+ <text_format>Maximum:</text_format>
+ <hard_return>on</hard_return>
+ <sequence>12</sequence>
+ </hash_10001386e0e18d79915cd21ff123fb830e150e>
+ <hash_100013206b0b016daf267ff0a1daa7733ecf25>
+ <task_item_id>0</task_item_id>
+ <color_id>0</color_id>
+ <graph_type_id>1</graph_type_id>
+ <consolidation_function_id>1</consolidation_function_id>
+ <cdef_id>0</cdef_id>
+ <value></value>
+ <gprint_id>hash_060013e9c43831e54eca8069317a2ce8c6f751</gprint_id>
+ <text_format>Graph Last Updated: |date_time|</text_format>
+ <hard_return>on</hard_return>
+ <sequence>13</sequence>
+ </hash_100013206b0b016daf267ff0a1daa7733ecf25>
+ </items>
+ <inputs>
+ <hash_090013871102d568ae1a0d7d79aa4b0d3a6411>
+ <name>Data Source [TotalSessions]</name>
+ <description></description>
+ <column_name>task_item_id</column_name>
+ <items>hash_0000131ecaf3728447913a30dfa80cdd9cdff4|hash_0000132171a00b34d33f99ef24bcc235fbb6a3|hash_0000132129590e72a46480422f85e063d8cf4d|hash_0000138d11fec869f88ccf2fa3227bcffadfc3</items>
+ </hash_090013871102d568ae1a0d7d79aa4b0d3a6411>
+ <hash_090013320fd0edeb30465be51274fa3ecbe168>
+ <name>Data Source [ResponseErrors]</name>
+ <description></description>
+ <column_name>task_item_id</column_name>
+ <items>hash_000013783d295131617ad996e4699533a134ea|hash_0000139bc04e5072b25ca992ee0b0eec981b95|hash_0000136333a9334fa0dc0d2f75c031dee1dcc5|hash_00001386e0e18d79915cd21ff123fb830e150e</items>
+ </hash_090013320fd0edeb30465be51274fa3ecbe168>
+ </inputs>
+ </hash_000013cdbf9accfcd57d9e0a7c97896313ddee>
+ <hash_000013b6d238ff2532fcc19ab498043c7c65c2>
+ <name>HAProxy Backend Traffic</name>
+ <graph>
+ <t_title></t_title>
+ <title>|host_description| - HaProxy |query_bePxName| Backend Traffic</title>
+ <t_image_format_id></t_image_format_id>
+ <image_format_id>1</image_format_id>
+ <t_height></t_height>
+ <height>120</height>
+ <t_width></t_width>
+ <width>500</width>
+ <t_auto_scale></t_auto_scale>
+ <auto_scale>on</auto_scale>
+ <t_auto_scale_opts></t_auto_scale_opts>
+ <auto_scale_opts>2</auto_scale_opts>
+ <t_auto_scale_log></t_auto_scale_log>
+ <auto_scale_log></auto_scale_log>
+ <t_auto_scale_rigid></t_auto_scale_rigid>
+ <auto_scale_rigid></auto_scale_rigid>
+ <t_auto_padding></t_auto_padding>
+ <auto_padding>on</auto_padding>
+ <t_export></t_export>
+ <export>on</export>
+ <t_upper_limit></t_upper_limit>
+ <upper_limit>10000000000</upper_limit>
+ <t_lower_limit></t_lower_limit>
+ <lower_limit>0</lower_limit>
+ <t_base_value></t_base_value>
+ <base_value>1024</base_value>
+ <t_unit_value></t_unit_value>
+ <unit_value></unit_value>
+ <t_unit_exponent_value></t_unit_exponent_value>
+ <unit_exponent_value></unit_exponent_value>
+ <t_vertical_label></t_vertical_label>
+ <vertical_label>bytes</vertical_label>
+ </graph>
+ <items>
+ <hash_100013184e60d8dac2421c2787887fe07f6d25>
+ <task_item_id>hash_0800132f5283f17a7cde63137189d4d3ea7e4e</task_item_id>
+ <color_id>6EA100</color_id>
+ <graph_type_id>5</graph_type_id>
+ <consolidation_function_id>1</consolidation_function_id>
+ <cdef_id>0</cdef_id>
+ <value></value>
+ <gprint_id>hash_060013e9c43831e54eca8069317a2ce8c6f751</gprint_id>
+ <text_format>Ingress Traffic:</text_format>
+ <hard_return></hard_return>
+ <sequence>2</sequence>
+ </hash_100013184e60d8dac2421c2787887fe07f6d25>
+ <hash_100013f3889b4094b935798483e489b5f5e16e>
+ <task_item_id>hash_0800132f5283f17a7cde63137189d4d3ea7e4e</task_item_id>
+ <color_id>0</color_id>
+ <graph_type_id>9</graph_type_id>
+ <consolidation_function_id>4</consolidation_function_id>
+ <cdef_id>0</cdef_id>
+ <value></value>
+ <gprint_id>hash_060013e9c43831e54eca8069317a2ce8c6f751</gprint_id>
+ <text_format>Current:</text_format>
+ <hard_return></hard_return>
+ <sequence>3</sequence>
+ </hash_100013f3889b4094b935798483e489b5f5e16e>
+ <hash_1000134bbdf263db6461f5d76717c12564c42c>
+ <task_item_id>hash_0800132f5283f17a7cde63137189d4d3ea7e4e</task_item_id>
+ <color_id>0</color_id>
+ <graph_type_id>9</graph_type_id>
+ <consolidation_function_id>1</consolidation_function_id>
+ <cdef_id>0</cdef_id>
+ <value></value>
+ <gprint_id>hash_060013e9c43831e54eca8069317a2ce8c6f751</gprint_id>
+ <text_format>Average:</text_format>
+ <hard_return></hard_return>
+ <sequence>4</sequence>
+ </hash_1000134bbdf263db6461f5d76717c12564c42c>
+ <hash_1000131b708578244e36caba0f4dea67230c80>
+ <task_item_id>hash_0800132f5283f17a7cde63137189d4d3ea7e4e</task_item_id>
+ <color_id>0</color_id>
+ <graph_type_id>9</graph_type_id>
+ <consolidation_function_id>3</consolidation_function_id>
+ <cdef_id>0</cdef_id>
+ <value></value>
+ <gprint_id>hash_060013e9c43831e54eca8069317a2ce8c6f751</gprint_id>
+ <text_format>Maximum:</text_format>
+ <hard_return>on</hard_return>
+ <sequence>5</sequence>
+ </hash_1000131b708578244e36caba0f4dea67230c80>
+ <hash_1000133e2f02edb1a55bcdd20e925a3849fd37>
+ <task_item_id>hash_0800136c0e4debeb9b084231d858faabd82f8f</task_item_id>
+ <color_id>FF0000</color_id>
+ <graph_type_id>5</graph_type_id>
+ <consolidation_function_id>1</consolidation_function_id>
+ <cdef_id>0</cdef_id>
+ <value></value>
+ <gprint_id>hash_060013e9c43831e54eca8069317a2ce8c6f751</gprint_id>
+ <text_format>Egress Traffic:</text_format>
+ <hard_return></hard_return>
+ <sequence>6</sequence>
+ </hash_1000133e2f02edb1a55bcdd20e925a3849fd37>
+ <hash_1000134517c9799c71e03dcd2278681858d70f>
+ <task_item_id>hash_0800136c0e4debeb9b084231d858faabd82f8f</task_item_id>
+ <color_id>0</color_id>
+ <graph_type_id>9</graph_type_id>
+ <consolidation_function_id>4</consolidation_function_id>
+ <cdef_id>0</cdef_id>
+ <value></value>
+ <gprint_id>hash_060013e9c43831e54eca8069317a2ce8c6f751</gprint_id>
+ <text_format>Current:</text_format>
+ <hard_return></hard_return>
+ <sequence>7</sequence>
+ </hash_1000134517c9799c71e03dcd2278681858d70f>
+ <hash_1000132edf24a4592c9537d2341ec20c588fc2>
+ <task_item_id>hash_0800136c0e4debeb9b084231d858faabd82f8f</task_item_id>
+ <color_id>0</color_id>
+ <graph_type_id>9</graph_type_id>
+ <consolidation_function_id>1</consolidation_function_id>
+ <cdef_id>0</cdef_id>
+ <value></value>
+ <gprint_id>hash_060013e9c43831e54eca8069317a2ce8c6f751</gprint_id>
+ <text_format>Average:</text_format>
+ <hard_return></hard_return>
+ <sequence>8</sequence>
+ </hash_1000132edf24a4592c9537d2341ec20c588fc2>
+ <hash_100013150e680935bfccc75f1f88c7c60030f7>
+ <task_item_id>hash_0800136c0e4debeb9b084231d858faabd82f8f</task_item_id>
+ <color_id>0</color_id>
+ <graph_type_id>9</graph_type_id>
+ <consolidation_function_id>3</consolidation_function_id>
+ <cdef_id>0</cdef_id>
+ <value></value>
+ <gprint_id>hash_060013e9c43831e54eca8069317a2ce8c6f751</gprint_id>
+ <text_format>Maximum:</text_format>
+ <hard_return>on</hard_return>
+ <sequence>9</sequence>
+ </hash_100013150e680935bfccc75f1f88c7c60030f7>
+ <hash_1000135dcb7625a1a21d8d94fdf2f97d302a42>
+ <task_item_id>0</task_item_id>
+ <color_id>0</color_id>
+ <graph_type_id>1</graph_type_id>
+ <consolidation_function_id>1</consolidation_function_id>
+ <cdef_id>0</cdef_id>
+ <value></value>
+ <gprint_id>hash_060013e9c43831e54eca8069317a2ce8c6f751</gprint_id>
+ <text_format>Graph Last Updated: |date_time|</text_format>
+ <hard_return>on</hard_return>
+ <sequence>10</sequence>
+ </hash_1000135dcb7625a1a21d8d94fdf2f97d302a42>
+ </items>
+ <inputs>
+ <hash_090013952f2971b58b10f88a55d63a0388a429>
+ <name>Data Source [BytesIn]</name>
+ <description></description>
+ <column_name>task_item_id</column_name>
+ <items>hash_000013184e60d8dac2421c2787887fe07f6d25|hash_000013f3889b4094b935798483e489b5f5e16e|hash_0000134bbdf263db6461f5d76717c12564c42c|hash_0000131b708578244e36caba0f4dea67230c80</items>
+ </hash_090013952f2971b58b10f88a55d63a0388a429>
+ <hash_09001393a65aa111654d6801846a6cb523580b>
+ <name>Data Source [BytesOut]</name>
+ <description></description>
+ <column_name>task_item_id</column_name>
+ <items>hash_0000133e2f02edb1a55bcdd20e925a3849fd37|hash_0000134517c9799c71e03dcd2278681858d70f|hash_0000132edf24a4592c9537d2341ec20c588fc2|hash_000013150e680935bfccc75f1f88c7c60030f7</items>
+ </hash_09001393a65aa111654d6801846a6cb523580b>
+ </inputs>
+ </hash_000013b6d238ff2532fcc19ab498043c7c65c2>
+ <hash_010013fa4d4fff334b60e9064e89082173fe34>
+ <name>HAProxy Backend Session Stats</name>
+ <ds>
+ <t_name></t_name>
+ <name>|host_description| - HAProxy - |query_bePxName| Backend Session Stats</name>
+ <data_input_id>hash_030013bf566c869ac6443b0c75d1c32b5a350e</data_input_id>
+ <t_rra_id></t_rra_id>
+ <t_rrd_step></t_rrd_step>
+ <rrd_step>300</rrd_step>
+ <t_active></t_active>
+ <active>on</active>
+ <rra_items>hash_150013c21df5178e5c955013591239eb0afd46|hash_1500130d9c0af8b8acdc7807943937b3208e29|hash_1500136fc2d038fb42950138b0ce3e9874cc60|hash_150013e36f3adb9f152adfa5dc50fd2b23337e|hash_15001352829408ab566127eede2c74d201c678|hash_150013e73fb797d3ab2a9b97c3ec29e9690910</rra_items>
+ </ds>
+ <items>
+ <hash_080013230e04055a4228154123e74c6586d435>
+ <t_data_source_name></t_data_source_name>
+ <data_source_name>TotalSessions</data_source_name>
+ <t_rrd_minimum></t_rrd_minimum>
+ <rrd_minimum>0</rrd_minimum>
+ <t_rrd_maximum></t_rrd_maximum>
+ <rrd_maximum>10000</rrd_maximum>
+ <t_data_source_type_id></t_data_source_type_id>
+ <data_source_type_id>2</data_source_type_id>
+ <t_rrd_heartbeat></t_rrd_heartbeat>
+ <rrd_heartbeat>600</rrd_heartbeat>
+ <t_data_input_field_id></t_data_input_field_id>
+ <data_input_field_id>0</data_input_field_id>
+ </hash_080013230e04055a4228154123e74c6586d435>
+ <hash_080013088549c8d7e8cdc80f19bae4d78dc296>
+ <t_data_source_name></t_data_source_name>
+ <data_source_name>ResponseErrors</data_source_name>
+ <t_rrd_minimum></t_rrd_minimum>
+ <rrd_minimum>0</rrd_minimum>
+ <t_rrd_maximum></t_rrd_maximum>
+ <rrd_maximum>10000</rrd_maximum>
+ <t_data_source_type_id></t_data_source_type_id>
+ <data_source_type_id>2</data_source_type_id>
+ <t_rrd_heartbeat></t_rrd_heartbeat>
+ <rrd_heartbeat>600</rrd_heartbeat>
+ <t_data_input_field_id></t_data_input_field_id>
+ <data_input_field_id>0</data_input_field_id>
+ </hash_080013088549c8d7e8cdc80f19bae4d78dc296>
+ </items>
+ <data>
+ <item_000>
+ <data_input_field_id>hash_070013c1f36ee60c3dc98945556d57f26e475b</data_input_field_id>
+ <t_value></t_value>
+ <value></value>
+ </item_000>
+ <item_001>
+ <data_input_field_id>hash_070013e6deda7be0f391399c5130e7c4a48b28</data_input_field_id>
+ <t_value></t_value>
+ <value></value>
+ </item_001>
+ <item_002>
+ <data_input_field_id>hash_070013cbbe5c1ddfb264a6e5d509ce1c78c95f</data_input_field_id>
+ <t_value></t_value>
+ <value></value>
+ </item_002>
+ <item_003>
+ <data_input_field_id>hash_0700136027a919c7c7731fbe095b6f53ab127b</data_input_field_id>
+ <t_value></t_value>
+ <value></value>
+ </item_003>
+ <item_004>
+ <data_input_field_id>hash_070013b5c23f246559df38662c255f4aa21d6b</data_input_field_id>
+ <t_value></t_value>
+ <value></value>
+ </item_004>
+ <item_005>
+ <data_input_field_id>hash_0700131cc1493a6781af2c478fa4de971531cf</data_input_field_id>
+ <t_value></t_value>
+ <value></value>
+ </item_005>
+ <item_006>
+ <data_input_field_id>hash_070013f4facc5e2ca7ebee621f09bc6d9fc792</data_input_field_id>
+ <t_value></t_value>
+ <value></value>
+ </item_006>
+ <item_007>
+ <data_input_field_id>hash_070013acb449d1451e8a2a655c2c99d31142c7</data_input_field_id>
+ <t_value></t_value>
+ <value></value>
+ </item_007>
+ <item_008>
+ <data_input_field_id>hash_070013617cdc8a230615e59f06f361ef6e7728</data_input_field_id>
+ <t_value></t_value>
+ <value></value>
+ </item_008>
+ </data>
+ </hash_010013fa4d4fff334b60e9064e89082173fe34>
+ <hash_010013a63ddba34026d2c07d73c0ef2ae64b54>
+ <name>HAProxy Backend Traffic Stats</name>
+ <ds>
+ <t_name></t_name>
+ <name>|host_description| - HAProxy - |query_bePxName| Backend Traffic Stats</name>
+ <data_input_id>hash_030013bf566c869ac6443b0c75d1c32b5a350e</data_input_id>
+ <t_rra_id></t_rra_id>
+ <t_rrd_step></t_rrd_step>
+ <rrd_step>300</rrd_step>
+ <t_active></t_active>
+ <active>on</active>
+ <rra_items>hash_150013c21df5178e5c955013591239eb0afd46|hash_1500130d9c0af8b8acdc7807943937b3208e29|hash_1500136fc2d038fb42950138b0ce3e9874cc60|hash_150013e36f3adb9f152adfa5dc50fd2b23337e|hash_150013a4aa6f4de84eaa00008f88d3f5bd8520|hash_150013e73fb797d3ab2a9b97c3ec29e9690910</rra_items>
+ </ds>
+ <items>
+ <hash_0800136c0e4debeb9b084231d858faabd82f8f>
+ <t_data_source_name></t_data_source_name>
+ <data_source_name>BytesOut</data_source_name>
+ <t_rrd_minimum></t_rrd_minimum>
+ <rrd_minimum>0</rrd_minimum>
+ <t_rrd_maximum></t_rrd_maximum>
+ <rrd_maximum>10000000000</rrd_maximum>
+ <t_data_source_type_id></t_data_source_type_id>
+ <data_source_type_id>2</data_source_type_id>
+ <t_rrd_heartbeat></t_rrd_heartbeat>
+ <rrd_heartbeat>600</rrd_heartbeat>
+ <t_data_input_field_id></t_data_input_field_id>
+ <data_input_field_id>0</data_input_field_id>
+ </hash_0800136c0e4debeb9b084231d858faabd82f8f>
+ <hash_0800132f5283f17a7cde63137189d4d3ea7e4e>
+ <t_data_source_name></t_data_source_name>
+ <data_source_name>BytesIn</data_source_name>
+ <t_rrd_minimum></t_rrd_minimum>
+ <rrd_minimum>0</rrd_minimum>
+ <t_rrd_maximum></t_rrd_maximum>
+ <rrd_maximum>10000000000</rrd_maximum>
+ <t_data_source_type_id></t_data_source_type_id>
+ <data_source_type_id>2</data_source_type_id>
+ <t_rrd_heartbeat></t_rrd_heartbeat>
+ <rrd_heartbeat>600</rrd_heartbeat>
+ <t_data_input_field_id></t_data_input_field_id>
+ <data_input_field_id>0</data_input_field_id>
+ </hash_0800132f5283f17a7cde63137189d4d3ea7e4e>
+ </items>
+ <data>
+ <item_000>
+ <data_input_field_id>hash_070013c1f36ee60c3dc98945556d57f26e475b</data_input_field_id>
+ <t_value></t_value>
+ <value></value>
+ </item_000>
+ <item_001>
+ <data_input_field_id>hash_070013e6deda7be0f391399c5130e7c4a48b28</data_input_field_id>
+ <t_value></t_value>
+ <value></value>
+ </item_001>
+ <item_002>
+ <data_input_field_id>hash_070013cbbe5c1ddfb264a6e5d509ce1c78c95f</data_input_field_id>
+ <t_value></t_value>
+ <value></value>
+ </item_002>
+ <item_003>
+ <data_input_field_id>hash_0700136027a919c7c7731fbe095b6f53ab127b</data_input_field_id>
+ <t_value></t_value>
+ <value></value>
+ </item_003>
+ <item_004>
+ <data_input_field_id>hash_070013b5c23f246559df38662c255f4aa21d6b</data_input_field_id>
+ <t_value></t_value>
+ <value></value>
+ </item_004>
+ <item_005>
+ <data_input_field_id>hash_0700131cc1493a6781af2c478fa4de971531cf</data_input_field_id>
+ <t_value></t_value>
+ <value></value>
+ </item_005>
+ <item_006>
+ <data_input_field_id>hash_070013f4facc5e2ca7ebee621f09bc6d9fc792</data_input_field_id>
+ <t_value></t_value>
+ <value></value>
+ </item_006>
+ <item_007>
+ <data_input_field_id>hash_070013acb449d1451e8a2a655c2c99d31142c7</data_input_field_id>
+ <t_value></t_value>
+ <value></value>
+ </item_007>
+ <item_008>
+ <data_input_field_id>hash_070013617cdc8a230615e59f06f361ef6e7728</data_input_field_id>
+ <t_value></t_value>
+ <value></value>
+ </item_008>
+ </data>
+ </hash_010013a63ddba34026d2c07d73c0ef2ae64b54>
+ <hash_150013c21df5178e5c955013591239eb0afd46>
+ <name>Daily (5 Minute Average)</name>
+ <x_files_factor>0.5</x_files_factor>
+ <steps>1</steps>
+ <rows>600</rows>
+ <timespan>86400</timespan>
+ <cf_items>1|2|3|4</cf_items>
+ </hash_150013c21df5178e5c955013591239eb0afd46>
+ <hash_1500130d9c0af8b8acdc7807943937b3208e29>
+ <name>Weekly (30 Minute Average)</name>
+ <x_files_factor>0.5</x_files_factor>
+ <steps>6</steps>
+ <rows>700</rows>
+ <timespan>604800</timespan>
+ <cf_items>1|2|3|4</cf_items>
+ </hash_1500130d9c0af8b8acdc7807943937b3208e29>
+ <hash_1500136fc2d038fb42950138b0ce3e9874cc60>
+ <name>Monthly (2 Hour Average)</name>
+ <x_files_factor>0.5</x_files_factor>
+ <steps>24</steps>
+ <rows>775</rows>
+ <timespan>2678400</timespan>
+ <cf_items>1|2|3|4</cf_items>
+ </hash_1500136fc2d038fb42950138b0ce3e9874cc60>
+ <hash_150013e36f3adb9f152adfa5dc50fd2b23337e>
+ <name>Yearly (1 Day Average)</name>
+ <x_files_factor>0.5</x_files_factor>
+ <steps>288</steps>
+ <rows>797</rows>
+ <timespan>33053184</timespan>
+ <cf_items>1|2|3|4</cf_items>
+ </hash_150013e36f3adb9f152adfa5dc50fd2b23337e>
+ <hash_1500130028a19ed71b758898eaa55ab1c59694>
+ <name>Three days (5 minutes average)</name>
+ <x_files_factor>0.5</x_files_factor>
+ <steps>6</steps>
+ <rows>700</rows>
+ <timespan>302400</timespan>
+ <cf_items>1|2|3|4</cf_items>
+ </hash_1500130028a19ed71b758898eaa55ab1c59694>
+ <hash_150013e73fb797d3ab2a9b97c3ec29e9690910>
+ <name>Hourly (1 Minute Average)</name>
+ <x_files_factor>0.5</x_files_factor>
+ <steps>1</steps>
+ <rows>500</rows>
+ <timespan>14400</timespan>
+ <cf_items>1|3</cf_items>
+ </hash_150013e73fb797d3ab2a9b97c3ec29e9690910>
+ <hash_060013e9c43831e54eca8069317a2ce8c6f751>
+ <name>Normal</name>
+ <gprint_text>%8.2lf %s</gprint_text>
+ </hash_060013e9c43831e54eca8069317a2ce8c6f751>
+</cacti>
diff --git a/admin/netsnmp-perl/cacti_data_query_haproxy_frontends.xml b/admin/netsnmp-perl/cacti_data_query_haproxy_frontends.xml
new file mode 100644
index 0000000..1429b07
--- /dev/null
+++ b/admin/netsnmp-perl/cacti_data_query_haproxy_frontends.xml
@@ -0,0 +1,750 @@
+<cacti>
+ <hash_0400138cb70c1064bd60742726af23828c4b05>
+ <name>HAProxy Frontends</name>
+ <description></description>
+ <xml_path>&lt;path_cacti&gt;/resource/snmp_queries/haproxy_frontend.xml</xml_path>
+ <data_input_id>hash_030013bf566c869ac6443b0c75d1c32b5a350e</data_input_id>
+ <graphs>
+ <hash_110013c1c2bca3af0ae4e2ce0de096aa79dba5>
+ <name>HAProxy Frontend Sessions</name>
+ <graph_template_id>hash_00001328b6727aa54dde6bb3f5dde939ae03aa</graph_template_id>
+ <rrd>
+ <item_000>
+ <snmp_field_name>feSTot</snmp_field_name>
+ <data_template_id>hash_0100139f985697a7530256b4e35c95ef03db20</data_template_id>
+ <data_template_rrd_id>hash_080013f9c76e05d0a87b2d32f9a5b014e17aab</data_template_rrd_id>
+ </item_000>
+ <item_001>
+ <snmp_field_name>feEReq</snmp_field_name>
+ <data_template_id>hash_0100139f985697a7530256b4e35c95ef03db20</data_template_id>
+ <data_template_rrd_id>hash_080013c137bec94d7220e65a5b3dfa4049c242</data_template_rrd_id>
+ </item_001>
+ </rrd>
+ <sv_graph>
+ <hash_1200130f0e4ffcd11f807d23794ab805d7901a>
+ <field_name>TotalSessions</field_name>
+ <sequence>1</sequence>
+ <text>TotalSessions</text>
+ </hash_1200130f0e4ffcd11f807d23794ab805d7901a>
+ <hash_1200134fc506db9ce45c0e5cb38a429ad8e077>
+ <field_name>RequestErrors</field_name>
+ <sequence>1</sequence>
+ <text>RequestErrors</text>
+ </hash_1200134fc506db9ce45c0e5cb38a429ad8e077>
+ </sv_graph>
+ <sv_data_source>
+ <hash_1300138a5efc51c95b400c3139b352ce110969>
+ <field_name>RequestErrors</field_name>
+ <data_template_id>hash_0100139f985697a7530256b4e35c95ef03db20</data_template_id>
+ <sequence>1</sequence>
+ <text>RequestErrors</text>
+ </hash_1300138a5efc51c95b400c3139b352ce110969>
+ <hash_130013e374903ab025bc2728f2f9abeb412ac3>
+ <field_name>TotalSessions</field_name>
+ <data_template_id>hash_0100139f985697a7530256b4e35c95ef03db20</data_template_id>
+ <sequence>1</sequence>
+ <text>TotalSessions</text>
+ </hash_130013e374903ab025bc2728f2f9abeb412ac3>
+ </sv_data_source>
+ </hash_110013c1c2bca3af0ae4e2ce0de096aa79dba5>
+ <hash_1100130838495d5d82f25f4a675ee7c56543a5>
+ <name>HAProxy Frontend Traffic</name>
+ <graph_template_id>hash_000013d0fe9e9efc2746de488fdede0419b051</graph_template_id>
+ <rrd>
+ <item_000>
+ <snmp_field_name>feBOut</snmp_field_name>
+ <data_template_id>hash_010013a88327df77ea19e333ddd96096c34751</data_template_id>
+ <data_template_rrd_id>hash_0800137db81cd58fbbbd203af0f55c15c2081a</data_template_rrd_id>
+ </item_000>
+ <item_001>
+ <snmp_field_name>feBIn</snmp_field_name>
+ <data_template_id>hash_010013a88327df77ea19e333ddd96096c34751</data_template_id>
+ <data_template_rrd_id>hash_08001305772980bb6de1f12223d7ec53e323c4</data_template_rrd_id>
+ </item_001>
+ </rrd>
+ <sv_graph>
+ <hash_120013934d1311136bccb4d9ca5a67e240afeb>
+ <field_name>BytesIn</field_name>
+ <sequence>1</sequence>
+ <text>BytesIn</text>
+ </hash_120013934d1311136bccb4d9ca5a67e240afeb>
+ <hash_12001399a6e6fb09b025bc60a214cb00e6d1f0>
+ <field_name>BytesOut</field_name>
+ <sequence>1</sequence>
+ <text>BytesOut</text>
+ </hash_12001399a6e6fb09b025bc60a214cb00e6d1f0>
+ </sv_graph>
+ <sv_data_source>
+ <hash_1300135f35cdaeda1a1169be21e52a85af339e>
+ <field_name>BytesOut</field_name>
+ <data_template_id>hash_0100139f985697a7530256b4e35c95ef03db20</data_template_id>
+ <sequence>1</sequence>
+ <text>BytesOut</text>
+ </hash_1300135f35cdaeda1a1169be21e52a85af339e>
+ <hash_1300136ee916a0c0ce8dad133b9dfcf32e2581>
+ <field_name>BytesIn</field_name>
+ <data_template_id>hash_0100139f985697a7530256b4e35c95ef03db20</data_template_id>
+ <sequence>1</sequence>
+ <text>BytesIn</text>
+ </hash_1300136ee916a0c0ce8dad133b9dfcf32e2581>
+ <hash_13001382c5a3b953f8d1583b168d15beed6e9c>
+ <field_name>BytesOut</field_name>
+ <data_template_id>hash_010013a88327df77ea19e333ddd96096c34751</data_template_id>
+ <sequence>1</sequence>
+ <text>BytesOut</text>
+ </hash_13001382c5a3b953f8d1583b168d15beed6e9c>
+ <hash_1300132c486fa1a5e875179031ea9f5328614b>
+ <field_name>BytesIn</field_name>
+ <data_template_id>hash_010013a88327df77ea19e333ddd96096c34751</data_template_id>
+ <sequence>1</sequence>
+ <text>BytesIn</text>
+ </hash_1300132c486fa1a5e875179031ea9f5328614b>
+ </sv_data_source>
+ </hash_1100130838495d5d82f25f4a675ee7c56543a5>
+ </graphs>
+ </hash_0400138cb70c1064bd60742726af23828c4b05>
+ <hash_030013bf566c869ac6443b0c75d1c32b5a350e>
+ <name>Get SNMP Data (Indexed)</name>
+ <type_id>3</type_id>
+ <input_string></input_string>
+ <fields>
+ <hash_070013617cdc8a230615e59f06f361ef6e7728>
+ <name>SNMP IP Address</name>
+ <update_rra></update_rra>
+ <regexp_match></regexp_match>
+ <allow_nulls></allow_nulls>
+ <type_code>hostname</type_code>
+ <input_output>in</input_output>
+ <data_name>management_ip</data_name>
+ </hash_070013617cdc8a230615e59f06f361ef6e7728>
+ <hash_070013acb449d1451e8a2a655c2c99d31142c7>
+ <name>SNMP Community</name>
+ <update_rra></update_rra>
+ <regexp_match></regexp_match>
+ <allow_nulls></allow_nulls>
+ <type_code>snmp_community</type_code>
+ <input_output>in</input_output>
+ <data_name>snmp_community</data_name>
+ </hash_070013acb449d1451e8a2a655c2c99d31142c7>
+ <hash_070013f4facc5e2ca7ebee621f09bc6d9fc792>
+ <name>SNMP Username (v3)</name>
+ <update_rra></update_rra>
+ <regexp_match></regexp_match>
+ <allow_nulls>on</allow_nulls>
+ <type_code>snmp_username</type_code>
+ <input_output>in</input_output>
+ <data_name>snmp_username</data_name>
+ </hash_070013f4facc5e2ca7ebee621f09bc6d9fc792>
+ <hash_0700131cc1493a6781af2c478fa4de971531cf>
+ <name>SNMP Password (v3)</name>
+ <update_rra></update_rra>
+ <regexp_match></regexp_match>
+ <allow_nulls>on</allow_nulls>
+ <type_code>snmp_password</type_code>
+ <input_output>in</input_output>
+ <data_name>snmp_password</data_name>
+ </hash_0700131cc1493a6781af2c478fa4de971531cf>
+ <hash_070013b5c23f246559df38662c255f4aa21d6b>
+ <name>SNMP Version (1, 2, or 3)</name>
+ <update_rra></update_rra>
+ <regexp_match></regexp_match>
+ <allow_nulls></allow_nulls>
+ <type_code>snmp_version</type_code>
+ <input_output>in</input_output>
+ <data_name>snmp_version</data_name>
+ </hash_070013b5c23f246559df38662c255f4aa21d6b>
+ <hash_0700136027a919c7c7731fbe095b6f53ab127b>
+ <name>Index Type</name>
+ <update_rra></update_rra>
+ <regexp_match></regexp_match>
+ <allow_nulls></allow_nulls>
+ <type_code>index_type</type_code>
+ <input_output>in</input_output>
+ <data_name>index_type</data_name>
+ </hash_0700136027a919c7c7731fbe095b6f53ab127b>
+ <hash_070013cbbe5c1ddfb264a6e5d509ce1c78c95f>
+ <name>Index Value</name>
+ <update_rra></update_rra>
+ <regexp_match></regexp_match>
+ <allow_nulls></allow_nulls>
+ <type_code>index_value</type_code>
+ <input_output>in</input_output>
+ <data_name>index_value</data_name>
+ </hash_070013cbbe5c1ddfb264a6e5d509ce1c78c95f>
+ <hash_070013e6deda7be0f391399c5130e7c4a48b28>
+ <name>Output Type ID</name>
+ <update_rra></update_rra>
+ <regexp_match></regexp_match>
+ <allow_nulls></allow_nulls>
+ <type_code>output_type</type_code>
+ <input_output>in</input_output>
+ <data_name>output_type</data_name>
+ </hash_070013e6deda7be0f391399c5130e7c4a48b28>
+ <hash_070013c1f36ee60c3dc98945556d57f26e475b>
+ <name>SNMP Port</name>
+ <update_rra></update_rra>
+ <regexp_match></regexp_match>
+ <allow_nulls></allow_nulls>
+ <type_code>snmp_port</type_code>
+ <input_output>in</input_output>
+ <data_name>snmp_port</data_name>
+ </hash_070013c1f36ee60c3dc98945556d57f26e475b>
+ </fields>
+ </hash_030013bf566c869ac6443b0c75d1c32b5a350e>
+ <hash_00001328b6727aa54dde6bb3f5dde939ae03aa>
+ <name>HAProxy Frontend Sessions</name>
+ <graph>
+ <t_title></t_title>
+ <title>|host_description| - HaProxy - |query_fePxName| Frontend Sessions</title>
+ <t_image_format_id></t_image_format_id>
+ <image_format_id>1</image_format_id>
+ <t_height></t_height>
+ <height>120</height>
+ <t_width></t_width>
+ <width>500</width>
+ <t_auto_scale></t_auto_scale>
+ <auto_scale>on</auto_scale>
+ <t_auto_scale_opts></t_auto_scale_opts>
+ <auto_scale_opts>2</auto_scale_opts>
+ <t_auto_scale_log></t_auto_scale_log>
+ <auto_scale_log></auto_scale_log>
+ <t_auto_scale_rigid></t_auto_scale_rigid>
+ <auto_scale_rigid></auto_scale_rigid>
+ <t_auto_padding></t_auto_padding>
+ <auto_padding>on</auto_padding>
+ <t_export></t_export>
+ <export>on</export>
+ <t_upper_limit></t_upper_limit>
+ <upper_limit>10000</upper_limit>
+ <t_lower_limit></t_lower_limit>
+ <lower_limit>0</lower_limit>
+ <t_base_value></t_base_value>
+ <base_value>1000</base_value>
+ <t_unit_value></t_unit_value>
+ <unit_value></unit_value>
+ <t_unit_exponent_value></t_unit_exponent_value>
+ <unit_exponent_value></unit_exponent_value>
+ <t_vertical_label></t_vertical_label>
+ <vertical_label></vertical_label>
+ </graph>
+ <items>
+ <hash_100013b1ecfd75df9c17c0ba11acc5e9b7d8f8>
+ <task_item_id>hash_080013f9c76e05d0a87b2d32f9a5b014e17aab</task_item_id>
+ <color_id>0000FF</color_id>
+ <graph_type_id>5</graph_type_id>
+ <consolidation_function_id>1</consolidation_function_id>
+ <cdef_id>0</cdef_id>
+ <value></value>
+ <gprint_id>hash_060013e9c43831e54eca8069317a2ce8c6f751</gprint_id>
+ <text_format>Total Sessions:</text_format>
+ <hard_return></hard_return>
+ <sequence>5</sequence>
+ </hash_100013b1ecfd75df9c17c0ba11acc5e9b7d8f8>
+ <hash_100013fa878148199aee5bb2a10b7693318347>
+ <task_item_id>hash_080013f9c76e05d0a87b2d32f9a5b014e17aab</task_item_id>
+ <color_id>0</color_id>
+ <graph_type_id>9</graph_type_id>
+ <consolidation_function_id>4</consolidation_function_id>
+ <cdef_id>0</cdef_id>
+ <value></value>
+ <gprint_id>hash_060013e9c43831e54eca8069317a2ce8c6f751</gprint_id>
+ <text_format>Current:</text_format>
+ <hard_return></hard_return>
+ <sequence>6</sequence>
+ </hash_100013fa878148199aee5bb2a10b7693318347>
+ <hash_1000137d834c383afa4863974edc19a337e260>
+ <task_item_id>hash_080013f9c76e05d0a87b2d32f9a5b014e17aab</task_item_id>
+ <color_id>0</color_id>
+ <graph_type_id>9</graph_type_id>
+ <consolidation_function_id>1</consolidation_function_id>
+ <cdef_id>0</cdef_id>
+ <value></value>
+ <gprint_id>hash_060013e9c43831e54eca8069317a2ce8c6f751</gprint_id>
+ <text_format>Average:</text_format>
+ <hard_return></hard_return>
+ <sequence>7</sequence>
+ </hash_1000137d834c383afa4863974edc19a337e260>
+ <hash_1000138b0422b293230883462cfbfe32144d47>
+ <task_item_id>hash_080013f9c76e05d0a87b2d32f9a5b014e17aab</task_item_id>
+ <color_id>0</color_id>
+ <graph_type_id>9</graph_type_id>
+ <consolidation_function_id>3</consolidation_function_id>
+ <cdef_id>0</cdef_id>
+ <value></value>
+ <gprint_id>hash_060013e9c43831e54eca8069317a2ce8c6f751</gprint_id>
+ <text_format>Maximum:</text_format>
+ <hard_return>on</hard_return>
+ <sequence>8</sequence>
+ </hash_1000138b0422b293230883462cfbfe32144d47>
+ <hash_1000131c87ed4e76c026cd131418d792822944>
+ <task_item_id>hash_080013c137bec94d7220e65a5b3dfa4049c242</task_item_id>
+ <color_id>EA8F00</color_id>
+ <graph_type_id>5</graph_type_id>
+ <consolidation_function_id>1</consolidation_function_id>
+ <cdef_id>0</cdef_id>
+ <value></value>
+ <gprint_id>hash_060013e9c43831e54eca8069317a2ce8c6f751</gprint_id>
+ <text_format>Request Errors:</text_format>
+ <hard_return></hard_return>
+ <sequence>9</sequence>
+ </hash_1000131c87ed4e76c026cd131418d792822944>
+ <hash_100013a9993114514cb1abea4b929f984222ea>
+ <task_item_id>hash_080013c137bec94d7220e65a5b3dfa4049c242</task_item_id>
+ <color_id>0</color_id>
+ <graph_type_id>9</graph_type_id>
+ <consolidation_function_id>4</consolidation_function_id>
+ <cdef_id>0</cdef_id>
+ <value></value>
+ <gprint_id>hash_060013e9c43831e54eca8069317a2ce8c6f751</gprint_id>
+ <text_format>Current:</text_format>
+ <hard_return></hard_return>
+ <sequence>10</sequence>
+ </hash_100013a9993114514cb1abea4b929f984222ea>
+ <hash_1000131bc67adbaa8b77cd6c73d9622c7eebc1>
+ <task_item_id>hash_080013c137bec94d7220e65a5b3dfa4049c242</task_item_id>
+ <color_id>0</color_id>
+ <graph_type_id>9</graph_type_id>
+ <consolidation_function_id>1</consolidation_function_id>
+ <cdef_id>0</cdef_id>
+ <value></value>
+ <gprint_id>hash_060013e9c43831e54eca8069317a2ce8c6f751</gprint_id>
+ <text_format>Average:</text_format>
+ <hard_return></hard_return>
+ <sequence>12</sequence>
+ </hash_1000131bc67adbaa8b77cd6c73d9622c7eebc1>
+ <hash_1000138840d17711368b90a61132ba83e9edb8>
+ <task_item_id>hash_080013c137bec94d7220e65a5b3dfa4049c242</task_item_id>
+ <color_id>0</color_id>
+ <graph_type_id>9</graph_type_id>
+ <consolidation_function_id>3</consolidation_function_id>
+ <cdef_id>0</cdef_id>
+ <value></value>
+ <gprint_id>hash_060013e9c43831e54eca8069317a2ce8c6f751</gprint_id>
+ <text_format>Maximum:</text_format>
+ <hard_return>on</hard_return>
+ <sequence>13</sequence>
+ </hash_1000138840d17711368b90a61132ba83e9edb8>
+ <hash_100013e8ddbe92933ba99b2d2ebc8f76a06e2e>
+ <task_item_id>0</task_item_id>
+ <color_id>0</color_id>
+ <graph_type_id>1</graph_type_id>
+ <consolidation_function_id>1</consolidation_function_id>
+ <cdef_id>0</cdef_id>
+ <value></value>
+ <gprint_id>hash_060013e9c43831e54eca8069317a2ce8c6f751</gprint_id>
+ <text_format>Graph Last Updated: |date_time|</text_format>
+ <hard_return>on</hard_return>
+ <sequence>14</sequence>
+ </hash_100013e8ddbe92933ba99b2d2ebc8f76a06e2e>
+ </items>
+ <inputs>
+ <hash_0900134bedc49c15c9557fc95cdbc8850a5cb1>
+ <name>Data Source [TotalSessions]</name>
+ <description></description>
+ <column_name>task_item_id</column_name>
+ <items>hash_000013b1ecfd75df9c17c0ba11acc5e9b7d8f8|hash_000013fa878148199aee5bb2a10b7693318347|hash_0000138b0422b293230883462cfbfe32144d47|hash_0000137d834c383afa4863974edc19a337e260</items>
+ </hash_0900134bedc49c15c9557fc95cdbc8850a5cb1>
+ <hash_090013f3f3dfd39bb035006de08df94415e828>
+ <name>Data Source [RequestErrors]</name>
+ <description></description>
+ <column_name>task_item_id</column_name>
+ <items>hash_0000131c87ed4e76c026cd131418d792822944|hash_000013a9993114514cb1abea4b929f984222ea|hash_0000131bc67adbaa8b77cd6c73d9622c7eebc1|hash_0000138840d17711368b90a61132ba83e9edb8</items>
+ </hash_090013f3f3dfd39bb035006de08df94415e828>
+ </inputs>
+ </hash_00001328b6727aa54dde6bb3f5dde939ae03aa>
+ <hash_000013d0fe9e9efc2746de488fdede0419b051>
+ <name>HAProxy Frontend Traffic</name>
+ <graph>
+ <t_title></t_title>
+ <title>|host_description| - HaProxy |query_fePxName| Frontend Traffic</title>
+ <t_image_format_id></t_image_format_id>
+ <image_format_id>1</image_format_id>
+ <t_height></t_height>
+ <height>120</height>
+ <t_width></t_width>
+ <width>500</width>
+ <t_auto_scale></t_auto_scale>
+ <auto_scale>on</auto_scale>
+ <t_auto_scale_opts></t_auto_scale_opts>
+ <auto_scale_opts>2</auto_scale_opts>
+ <t_auto_scale_log></t_auto_scale_log>
+ <auto_scale_log></auto_scale_log>
+ <t_auto_scale_rigid></t_auto_scale_rigid>
+ <auto_scale_rigid></auto_scale_rigid>
+ <t_auto_padding></t_auto_padding>
+ <auto_padding>on</auto_padding>
+ <t_export></t_export>
+ <export>on</export>
+ <t_upper_limit></t_upper_limit>
+ <upper_limit>10000000000</upper_limit>
+ <t_lower_limit></t_lower_limit>
+ <lower_limit>0</lower_limit>
+ <t_base_value></t_base_value>
+ <base_value>1024</base_value>
+ <t_unit_value></t_unit_value>
+ <unit_value></unit_value>
+ <t_unit_exponent_value></t_unit_exponent_value>
+ <unit_exponent_value></unit_exponent_value>
+ <t_vertical_label></t_vertical_label>
+ <vertical_label>bytes</vertical_label>
+ </graph>
+ <items>
+ <hash_100013d5c13ff711cbd645e9f88697b2c5e61b>
+ <task_item_id>hash_08001305772980bb6de1f12223d7ec53e323c4</task_item_id>
+ <color_id>6EA100</color_id>
+ <graph_type_id>5</graph_type_id>
+ <consolidation_function_id>1</consolidation_function_id>
+ <cdef_id>0</cdef_id>
+ <value></value>
+ <gprint_id>hash_060013e9c43831e54eca8069317a2ce8c6f751</gprint_id>
+ <text_format>Ingress Traffic:</text_format>
+ <hard_return></hard_return>
+ <sequence>2</sequence>
+ </hash_100013d5c13ff711cbd645e9f88697b2c5e61b>
+ <hash_10001353cff0cd64c4d70574ef9da42f62c86a>
+ <task_item_id>hash_08001305772980bb6de1f12223d7ec53e323c4</task_item_id>
+ <color_id>0</color_id>
+ <graph_type_id>9</graph_type_id>
+ <consolidation_function_id>4</consolidation_function_id>
+ <cdef_id>0</cdef_id>
+ <value></value>
+ <gprint_id>hash_060013e9c43831e54eca8069317a2ce8c6f751</gprint_id>
+ <text_format>Current:</text_format>
+ <hard_return></hard_return>
+ <sequence>3</sequence>
+ </hash_10001353cff0cd64c4d70574ef9da42f62c86a>
+ <hash_1000136788d44f6207ce323ad40ccc8f15d462>
+ <task_item_id>hash_08001305772980bb6de1f12223d7ec53e323c4</task_item_id>
+ <color_id>0</color_id>
+ <graph_type_id>9</graph_type_id>
+ <consolidation_function_id>1</consolidation_function_id>
+ <cdef_id>0</cdef_id>
+ <value></value>
+ <gprint_id>hash_060013e9c43831e54eca8069317a2ce8c6f751</gprint_id>
+ <text_format>Average:</text_format>
+ <hard_return></hard_return>
+ <sequence>4</sequence>
+ </hash_1000136788d44f6207ce323ad40ccc8f15d462>
+ <hash_100013d4cb02a8fb7fa37ef1e37d8b78333ea3>
+ <task_item_id>hash_08001305772980bb6de1f12223d7ec53e323c4</task_item_id>
+ <color_id>0</color_id>
+ <graph_type_id>9</graph_type_id>
+ <consolidation_function_id>3</consolidation_function_id>
+ <cdef_id>0</cdef_id>
+ <value></value>
+ <gprint_id>hash_060013e9c43831e54eca8069317a2ce8c6f751</gprint_id>
+ <text_format>Maximum:</text_format>
+ <hard_return>on</hard_return>
+ <sequence>5</sequence>
+ </hash_100013d4cb02a8fb7fa37ef1e37d8b78333ea3>
+ <hash_1000137d82a7f3c82c698fe4e9cecc03d680b1>
+ <task_item_id>hash_0800137db81cd58fbbbd203af0f55c15c2081a</task_item_id>
+ <color_id>FF0000</color_id>
+ <graph_type_id>5</graph_type_id>
+ <consolidation_function_id>1</consolidation_function_id>
+ <cdef_id>0</cdef_id>
+ <value></value>
+ <gprint_id>hash_060013e9c43831e54eca8069317a2ce8c6f751</gprint_id>
+ <text_format>Egress Traffic:</text_format>
+ <hard_return></hard_return>
+ <sequence>6</sequence>
+ </hash_1000137d82a7f3c82c698fe4e9cecc03d680b1>
+ <hash_100013d2d059378b521327426b451324bbb608>
+ <task_item_id>hash_0800137db81cd58fbbbd203af0f55c15c2081a</task_item_id>
+ <color_id>0</color_id>
+ <graph_type_id>9</graph_type_id>
+ <consolidation_function_id>4</consolidation_function_id>
+ <cdef_id>0</cdef_id>
+ <value></value>
+ <gprint_id>hash_060013e9c43831e54eca8069317a2ce8c6f751</gprint_id>
+ <text_format>Current:</text_format>
+ <hard_return></hard_return>
+ <sequence>7</sequence>
+ </hash_100013d2d059378b521327426b451324bbb608>
+ <hash_1000132eef0fae129ef21ad2d73e5e80814a23>
+ <task_item_id>hash_0800137db81cd58fbbbd203af0f55c15c2081a</task_item_id>
+ <color_id>0</color_id>
+ <graph_type_id>9</graph_type_id>
+ <consolidation_function_id>1</consolidation_function_id>
+ <cdef_id>0</cdef_id>
+ <value></value>
+ <gprint_id>hash_060013e9c43831e54eca8069317a2ce8c6f751</gprint_id>
+ <text_format>Average:</text_format>
+ <hard_return></hard_return>
+ <sequence>8</sequence>
+ </hash_1000132eef0fae129ef21ad2d73e5e80814a23>
+ <hash_1000138365462951b1f4e6b1a76f20b91be65d>
+ <task_item_id>hash_0800137db81cd58fbbbd203af0f55c15c2081a</task_item_id>
+ <color_id>0</color_id>
+ <graph_type_id>9</graph_type_id>
+ <consolidation_function_id>3</consolidation_function_id>
+ <cdef_id>0</cdef_id>
+ <value></value>
+ <gprint_id>hash_060013e9c43831e54eca8069317a2ce8c6f751</gprint_id>
+ <text_format>Maximum:</text_format>
+ <hard_return>on</hard_return>
+ <sequence>9</sequence>
+ </hash_1000138365462951b1f4e6b1a76f20b91be65d>
+ <hash_100013eefc9c0f83c57d6d6f8d75fbd45965a3>
+ <task_item_id>0</task_item_id>
+ <color_id>0</color_id>
+ <graph_type_id>1</graph_type_id>
+ <consolidation_function_id>1</consolidation_function_id>
+ <cdef_id>0</cdef_id>
+ <value></value>
+ <gprint_id>hash_060013e9c43831e54eca8069317a2ce8c6f751</gprint_id>
+ <text_format>Graph Last Updated: |date_time|</text_format>
+ <hard_return>on</hard_return>
+ <sequence>10</sequence>
+ </hash_100013eefc9c0f83c57d6d6f8d75fbd45965a3>
+ </items>
+ <inputs>
+ <hash_090013384e7b730bb32653e3fbce5ce509977d>
+ <name>Data Source [BytesOut]</name>
+ <description></description>
+ <column_name>task_item_id</column_name>
+ <items>hash_000013d2d059378b521327426b451324bbb608|hash_0000137d82a7f3c82c698fe4e9cecc03d680b1|hash_0000132eef0fae129ef21ad2d73e5e80814a23|hash_0000138365462951b1f4e6b1a76f20b91be65d</items>
+ </hash_090013384e7b730bb32653e3fbce5ce509977d>
+ <hash_090013e5ff60e3069b2d28d905f6affa63250e>
+ <name>Data Source [BytesIn]</name>
+ <description></description>
+ <column_name>task_item_id</column_name>
+ <items>hash_00001353cff0cd64c4d70574ef9da42f62c86a|hash_000013d5c13ff711cbd645e9f88697b2c5e61b|hash_0000136788d44f6207ce323ad40ccc8f15d462|hash_000013d4cb02a8fb7fa37ef1e37d8b78333ea3</items>
+ </hash_090013e5ff60e3069b2d28d905f6affa63250e>
+ </inputs>
+ </hash_000013d0fe9e9efc2746de488fdede0419b051>
+ <hash_0100139f985697a7530256b4e35c95ef03db20>
+ <name>HAProxy Frontend Session Stats</name>
+ <ds>
+ <t_name></t_name>
+ <name>|host_description| - HAProxy - |query_fePxName| Frontend Session Stats</name>
+ <data_input_id>hash_030013bf566c869ac6443b0c75d1c32b5a350e</data_input_id>
+ <t_rra_id></t_rra_id>
+ <t_rrd_step></t_rrd_step>
+ <rrd_step>300</rrd_step>
+ <t_active></t_active>
+ <active>on</active>
+ <rra_items>hash_150013c21df5178e5c955013591239eb0afd46|hash_1500130d9c0af8b8acdc7807943937b3208e29|hash_1500136fc2d038fb42950138b0ce3e9874cc60|hash_150013e36f3adb9f152adfa5dc50fd2b23337e|hash_1500139b529013942d5a6891d05a84d17175e0|hash_150013e73fb797d3ab2a9b97c3ec29e9690910</rra_items>
+ </ds>
+ <items>
+ <hash_080013c137bec94d7220e65a5b3dfa4049c242>
+ <t_data_source_name></t_data_source_name>
+ <data_source_name>RequestErrors</data_source_name>
+ <t_rrd_minimum></t_rrd_minimum>
+ <rrd_minimum>0</rrd_minimum>
+ <t_rrd_maximum></t_rrd_maximum>
+ <rrd_maximum>10000</rrd_maximum>
+ <t_data_source_type_id></t_data_source_type_id>
+ <data_source_type_id>2</data_source_type_id>
+ <t_rrd_heartbeat></t_rrd_heartbeat>
+ <rrd_heartbeat>600</rrd_heartbeat>
+ <t_data_input_field_id></t_data_input_field_id>
+ <data_input_field_id>0</data_input_field_id>
+ </hash_080013c137bec94d7220e65a5b3dfa4049c242>
+ <hash_080013f9c76e05d0a87b2d32f9a5b014e17aab>
+ <t_data_source_name></t_data_source_name>
+ <data_source_name>TotalSessions</data_source_name>
+ <t_rrd_minimum></t_rrd_minimum>
+ <rrd_minimum>0</rrd_minimum>
+ <t_rrd_maximum></t_rrd_maximum>
+ <rrd_maximum>10000</rrd_maximum>
+ <t_data_source_type_id></t_data_source_type_id>
+ <data_source_type_id>2</data_source_type_id>
+ <t_rrd_heartbeat></t_rrd_heartbeat>
+ <rrd_heartbeat>600</rrd_heartbeat>
+ <t_data_input_field_id></t_data_input_field_id>
+ <data_input_field_id>0</data_input_field_id>
+ </hash_080013f9c76e05d0a87b2d32f9a5b014e17aab>
+ </items>
+ <data>
+ <item_000>
+ <data_input_field_id>hash_070013c1f36ee60c3dc98945556d57f26e475b</data_input_field_id>
+ <t_value></t_value>
+ <value></value>
+ </item_000>
+ <item_001>
+ <data_input_field_id>hash_070013e6deda7be0f391399c5130e7c4a48b28</data_input_field_id>
+ <t_value></t_value>
+ <value></value>
+ </item_001>
+ <item_002>
+ <data_input_field_id>hash_070013cbbe5c1ddfb264a6e5d509ce1c78c95f</data_input_field_id>
+ <t_value></t_value>
+ <value></value>
+ </item_002>
+ <item_003>
+ <data_input_field_id>hash_0700136027a919c7c7731fbe095b6f53ab127b</data_input_field_id>
+ <t_value></t_value>
+ <value></value>
+ </item_003>
+ <item_004>
+ <data_input_field_id>hash_070013b5c23f246559df38662c255f4aa21d6b</data_input_field_id>
+ <t_value></t_value>
+ <value></value>
+ </item_004>
+ <item_005>
+ <data_input_field_id>hash_0700131cc1493a6781af2c478fa4de971531cf</data_input_field_id>
+ <t_value></t_value>
+ <value></value>
+ </item_005>
+ <item_006>
+ <data_input_field_id>hash_070013f4facc5e2ca7ebee621f09bc6d9fc792</data_input_field_id>
+ <t_value></t_value>
+ <value></value>
+ </item_006>
+ <item_007>
+ <data_input_field_id>hash_070013acb449d1451e8a2a655c2c99d31142c7</data_input_field_id>
+ <t_value></t_value>
+ <value></value>
+ </item_007>
+ <item_008>
+ <data_input_field_id>hash_070013617cdc8a230615e59f06f361ef6e7728</data_input_field_id>
+ <t_value></t_value>
+ <value></value>
+ </item_008>
+ </data>
+ </hash_0100139f985697a7530256b4e35c95ef03db20>
+ <hash_010013a88327df77ea19e333ddd96096c34751>
+ <name>HAProxy Frontend Traffic Stats</name>
+ <ds>
+ <t_name></t_name>
+ <name>|host_description| - HAProxy - |query_fePxName| Frontend Traffic Stats</name>
+ <data_input_id>hash_030013bf566c869ac6443b0c75d1c32b5a350e</data_input_id>
+ <t_rra_id></t_rra_id>
+ <t_rrd_step></t_rrd_step>
+ <rrd_step>300</rrd_step>
+ <t_active></t_active>
+ <active>on</active>
+ <rra_items>hash_150013c21df5178e5c955013591239eb0afd46|hash_1500130d9c0af8b8acdc7807943937b3208e29|hash_1500136fc2d038fb42950138b0ce3e9874cc60|hash_150013e36f3adb9f152adfa5dc50fd2b23337e|hash_15001369b0abdb84cea4d93762fd5a5d0c2777|hash_150013e73fb797d3ab2a9b97c3ec29e9690910</rra_items>
+ </ds>
+ <items>
+ <hash_0800137db81cd58fbbbd203af0f55c15c2081a>
+ <t_data_source_name></t_data_source_name>
+ <data_source_name>BytesOut</data_source_name>
+ <t_rrd_minimum></t_rrd_minimum>
+ <rrd_minimum>0</rrd_minimum>
+ <t_rrd_maximum></t_rrd_maximum>
+ <rrd_maximum>10000000000</rrd_maximum>
+ <t_data_source_type_id></t_data_source_type_id>
+ <data_source_type_id>2</data_source_type_id>
+ <t_rrd_heartbeat></t_rrd_heartbeat>
+ <rrd_heartbeat>600</rrd_heartbeat>
+ <t_data_input_field_id></t_data_input_field_id>
+ <data_input_field_id>0</data_input_field_id>
+ </hash_0800137db81cd58fbbbd203af0f55c15c2081a>
+ <hash_08001305772980bb6de1f12223d7ec53e323c4>
+ <t_data_source_name></t_data_source_name>
+ <data_source_name>BytesIn</data_source_name>
+ <t_rrd_minimum></t_rrd_minimum>
+ <rrd_minimum>0</rrd_minimum>
+ <t_rrd_maximum></t_rrd_maximum>
+ <rrd_maximum>10000000000</rrd_maximum>
+ <t_data_source_type_id></t_data_source_type_id>
+ <data_source_type_id>2</data_source_type_id>
+ <t_rrd_heartbeat></t_rrd_heartbeat>
+ <rrd_heartbeat>600</rrd_heartbeat>
+ <t_data_input_field_id></t_data_input_field_id>
+ <data_input_field_id>0</data_input_field_id>
+ </hash_08001305772980bb6de1f12223d7ec53e323c4>
+ </items>
+ <data>
+ <item_000>
+ <data_input_field_id>hash_070013c1f36ee60c3dc98945556d57f26e475b</data_input_field_id>
+ <t_value></t_value>
+ <value></value>
+ </item_000>
+ <item_001>
+ <data_input_field_id>hash_070013e6deda7be0f391399c5130e7c4a48b28</data_input_field_id>
+ <t_value></t_value>
+ <value></value>
+ </item_001>
+ <item_002>
+ <data_input_field_id>hash_070013cbbe5c1ddfb264a6e5d509ce1c78c95f</data_input_field_id>
+ <t_value></t_value>
+ <value></value>
+ </item_002>
+ <item_003>
+ <data_input_field_id>hash_0700136027a919c7c7731fbe095b6f53ab127b</data_input_field_id>
+ <t_value></t_value>
+ <value></value>
+ </item_003>
+ <item_004>
+ <data_input_field_id>hash_070013b5c23f246559df38662c255f4aa21d6b</data_input_field_id>
+ <t_value></t_value>
+ <value></value>
+ </item_004>
+ <item_005>
+ <data_input_field_id>hash_0700131cc1493a6781af2c478fa4de971531cf</data_input_field_id>
+ <t_value></t_value>
+ <value></value>
+ </item_005>
+ <item_006>
+ <data_input_field_id>hash_070013f4facc5e2ca7ebee621f09bc6d9fc792</data_input_field_id>
+ <t_value></t_value>
+ <value></value>
+ </item_006>
+ <item_007>
+ <data_input_field_id>hash_070013acb449d1451e8a2a655c2c99d31142c7</data_input_field_id>
+ <t_value></t_value>
+ <value></value>
+ </item_007>
+ <item_008>
+ <data_input_field_id>hash_070013617cdc8a230615e59f06f361ef6e7728</data_input_field_id>
+ <t_value></t_value>
+ <value></value>
+ </item_008>
+ </data>
+ </hash_010013a88327df77ea19e333ddd96096c34751>
+ <hash_150013c21df5178e5c955013591239eb0afd46>
+ <name>Daily (5 Minute Average)</name>
+ <x_files_factor>0.5</x_files_factor>
+ <steps>1</steps>
+ <rows>600</rows>
+ <timespan>86400</timespan>
+ <cf_items>1|2|3|4</cf_items>
+ </hash_150013c21df5178e5c955013591239eb0afd46>
+ <hash_1500130d9c0af8b8acdc7807943937b3208e29>
+ <name>Weekly (30 Minute Average)</name>
+ <x_files_factor>0.5</x_files_factor>
+ <steps>6</steps>
+ <rows>700</rows>
+ <timespan>604800</timespan>
+ <cf_items>1|2|3|4</cf_items>
+ </hash_1500130d9c0af8b8acdc7807943937b3208e29>
+ <hash_1500136fc2d038fb42950138b0ce3e9874cc60>
+ <name>Monthly (2 Hour Average)</name>
+ <x_files_factor>0.5</x_files_factor>
+ <steps>24</steps>
+ <rows>775</rows>
+ <timespan>2678400</timespan>
+ <cf_items>1|2|3|4</cf_items>
+ </hash_1500136fc2d038fb42950138b0ce3e9874cc60>
+ <hash_150013e36f3adb9f152adfa5dc50fd2b23337e>
+ <name>Yearly (1 Day Average)</name>
+ <x_files_factor>0.5</x_files_factor>
+ <steps>288</steps>
+ <rows>797</rows>
+ <timespan>33053184</timespan>
+ <cf_items>1|2|3|4</cf_items>
+ </hash_150013e36f3adb9f152adfa5dc50fd2b23337e>
+ <hash_1500136399acb234c65ef56054d5a82b23bc20>
+ <name>Three days (5 minutes average)</name>
+ <x_files_factor>0.5</x_files_factor>
+ <steps>6</steps>
+ <rows>700</rows>
+ <timespan>302400</timespan>
+ <cf_items>1|2|3|4</cf_items>
+ </hash_1500136399acb234c65ef56054d5a82b23bc20>
+ <hash_150013e73fb797d3ab2a9b97c3ec29e9690910>
+ <name>Hourly (1 Minute Average)</name>
+ <x_files_factor>0.5</x_files_factor>
+ <steps>1</steps>
+ <rows>500</rows>
+ <timespan>14400</timespan>
+ <cf_items>1|3</cf_items>
+ </hash_150013e73fb797d3ab2a9b97c3ec29e9690910>
+ <hash_060013e9c43831e54eca8069317a2ce8c6f751>
+ <name>Normal</name>
+ <gprint_text>%8.2lf %s</gprint_text>
+ </hash_060013e9c43831e54eca8069317a2ce8c6f751>
+</cacti>
diff --git a/admin/netsnmp-perl/haproxy.pl b/admin/netsnmp-perl/haproxy.pl
new file mode 100644
index 0000000..64684ad
--- /dev/null
+++ b/admin/netsnmp-perl/haproxy.pl
@@ -0,0 +1,249 @@
+#
+# Net-SNMP perl plugin for HAProxy
+# Version 0.30
+#
+# Copyright 2007-2010 Krzysztof Piotr Oledzki <ole@ans.pl>
+#
+# 1. get a variable from "show stat":
+# 1.3.6.1.4.1.29385.106.1.$type.$field.$iid.$sid
+# type: 0->frontend, 1->backend, 2->server, 3->socket
+#
+# 2. get a variable from "show info":
+# 1.3.6.1.4.1.29385.106.2.$req.$varnr
+#
+# TODO:
+# - implement read timeout
+#
+
+use NetSNMP::agent (':all');
+use NetSNMP::ASN qw(:all);
+use IO::Socket::UNIX;
+
+use strict;
+
+my $agent = new NetSNMP::agent('Name' => 'HAProxy');
+my $sa = "/var/run/haproxy.stat";
+
+use constant OID_HAPROXY => '1.3.6.1.4.1.29385.106';
+use constant OID_HAPROXY_STATS => OID_HAPROXY . '.1';
+use constant OID_HAPROXY_INFO => OID_HAPROXY . '.2';
+
+my $oid_stat = new NetSNMP::OID(OID_HAPROXY_STATS);
+my $oid_info = new NetSNMP::OID(OID_HAPROXY_INFO);
+
+use constant STATS_PXNAME => 0;
+use constant STATS_SVNAME => 1;
+use constant STATS_IID => 27;
+use constant STATS_SID => 28;
+use constant STATS_TYPE => 32;
+
+use constant FIELD_INDEX => 10001;
+use constant FIELD_NAME => 10002;
+
+my %info_vars = (
+ 0 => 'Name',
+ 1 => 'Version',
+ 2 => 'Release_date',
+ 3 => 'Nbproc',
+ 4 => 'Process_num',
+ 5 => 'Pid',
+ 6 => 'Uptime',
+ 7 => 'Uptime_sec',
+ 8 => 'Memmax_MB',
+ 9 => 'Ulimit-n',
+ 10 => 'Maxsock',
+ 11 => 'Maxconn',
+ 12 => 'Maxpipes',
+ 13 => 'CurrConns',
+ 14 => 'PipesUsed',
+ 15 => 'PipesFree',
+ 16 => 'Tasks',
+ 17 => 'Run_queue',
+ 18 => 'node',
+ 19 => 'description',
+);
+
+sub find_next_stat_id {
+ my($type, $field, $proxyid, $sid) = @_;
+
+ my $obj = 1 << $type;
+
+ my $np = -1;
+ my $nl = -1;
+
+ my $sock = new IO::Socket::UNIX (Peer => $sa, Type => SOCK_STREAM, Timeout => 1);
+ next if !$sock;
+
+ print $sock "show stat -1 $obj -1\n";
+
+ while(<$sock>) {
+ chomp;
+ my @d = split(',');
+
+ last if !$d[$field] && $field != FIELD_INDEX && $field != FIELD_NAME && /^#/;
+ next if /^#/;
+
+ next if $d[STATS_TYPE] != $type;
+
+ next if ($d[STATS_IID] < $proxyid) || ($d[STATS_IID] == $proxyid && $d[STATS_SID] <= $sid);
+
+ if ($np == -1 || $d[STATS_IID] < $np || ($d[STATS_IID] == $np && $d[STATS_SID] < $nl)) {
+ $np = $d[STATS_IID];
+ $nl = $d[STATS_SID];
+ next;
+ }
+ }
+
+ close($sock);
+
+ return 0 if ($np == -1);
+
+ return "$type.$field.$np.$nl"
+}
+
+sub haproxy_stat {
+ my($handler, $registration_info, $request_info, $requests) = @_;
+
+ for(my $request = $requests; $request; $request = $request->next()) {
+ my $oid = $request->getOID();
+
+ $oid =~ s/$oid_stat//;
+ $oid =~ s/^\.//;
+
+ my $mode = $request_info->getMode();
+
+ my($type, $field, $proxyid, $sid, $or) = split('\.', $oid, 5);
+
+ next if $type > 3 || defined($or);
+
+ if ($mode == MODE_GETNEXT) {
+
+ $type = 0 if !$type;
+ $field = 0 if !$field;
+ $proxyid = 0 if !$proxyid;
+ $sid = 0 if !$sid;
+
+ my $nextid = find_next_stat_id($type, $field, $proxyid, $sid);
+ $nextid = find_next_stat_id($type, $field+1, 0, 0) if !$nextid;
+ $nextid = find_next_stat_id($type+1, 0, 0, 0) if !$nextid;
+
+ if ($nextid) {
+ ($type, $field, $proxyid, $sid) = split('\.', $nextid);
+ $request->setOID(sprintf("%s.%s", OID_HAPROXY_STATS, $nextid));
+ $mode = MODE_GET;
+ }
+ }
+
+ if ($mode == MODE_GET) {
+ next if !defined($proxyid) || !defined($type) || !defined($sid) || !defined($field);
+
+ my $obj = 1 << $type;
+
+ my $sock = new IO::Socket::UNIX (Peer => $sa, Type => SOCK_STREAM, Timeout => 1);
+ next if !$sock;
+
+ print $sock "show stat $proxyid $obj $sid\n";
+
+ while(<$sock>) {
+ chomp;
+ my @data = split(',');
+
+ last if !defined($data[$field]) && $field != FIELD_INDEX && $field != FIELD_NAME;
+
+ if ($proxyid) {
+ next if $data[STATS_IID] ne $proxyid;
+ next if $data[STATS_SID] ne $sid;
+ next if $data[STATS_TYPE] ne $type;
+ }
+
+ if ($field == FIELD_INDEX) {
+ $request->setValue(ASN_OCTET_STR,
+ sprintf("%s.%s", $data[STATS_IID],
+ $data[STATS_SID]));
+ } elsif ($field == FIELD_NAME) {
+ $request->setValue(ASN_OCTET_STR,
+ sprintf("%s/%s", $data[STATS_PXNAME],
+ $data[STATS_SVNAME]));
+ } else {
+ $request->setValue(ASN_OCTET_STR, $data[$field]);
+ }
+
+ close($sock);
+ last;
+ }
+
+ close($sock);
+ next;
+ }
+
+ }
+}
+
+sub haproxy_info {
+ my($handler, $registration_info, $request_info, $requests) = @_;
+
+ for(my $request = $requests; $request; $request = $request->next()) {
+ my $oid = $request->getOID();
+
+ $oid =~ s/$oid_info//;
+ $oid =~ s/^\.//;
+
+ my $mode = $request_info->getMode();
+
+ my($req, $nr, $or) = split('\.', $oid, 3);
+
+ next if $req >= 2 || defined($or);
+
+ if ($mode == MODE_GETNEXT) {
+ $req = 0 if !defined($req);
+ $nr = -1 if !defined($nr);
+
+ if (!defined($info_vars{$nr+1})) {
+ $req++;
+ $nr = -1;
+ }
+
+ next if $req >= 2;
+
+ $request->setOID(sprintf("%s.%s.%s", OID_HAPROXY_INFO, $req, ++$nr));
+ $mode = MODE_GET;
+
+ }
+
+ if ($mode == MODE_GET) {
+
+ next if !defined($req) || !defined($nr);
+
+ if ($req == 0) {
+ next if !defined($info_vars{$nr});
+ $request->setValue(ASN_OCTET_STR, $info_vars{$nr});
+ next;
+ }
+
+ if ($req == 1) {
+ next if !defined($info_vars{$nr});
+
+ my $sock = new IO::Socket::UNIX (Peer => $sa, Type => SOCK_STREAM, Timeout => 1);
+ next if !$sock;
+
+ print $sock "show info\n";
+
+ while(<$sock>) {
+ chomp;
+ my ($key, $val) = /(.*):\s*(.*)/;
+
+ next if $info_vars{$nr} ne $key;
+
+ $request->setValue(ASN_OCTET_STR, $val);
+ last;
+ }
+
+ close($sock);
+ }
+ }
+ }
+}
+
+$agent->register('HAProxy stat', OID_HAPROXY_STATS, \&haproxy_stat);
+$agent->register('HAProxy info', OID_HAPROXY_INFO, \&haproxy_info);
+
diff --git a/admin/netsnmp-perl/haproxy_backend.xml b/admin/netsnmp-perl/haproxy_backend.xml
new file mode 100644
index 0000000..26ce63f
--- /dev/null
+++ b/admin/netsnmp-perl/haproxy_backend.xml
@@ -0,0 +1,83 @@
+<interface>
+ <name>HAProxy - backend</name>
+ <oid_index>.1.3.6.1.4.1.29385.106.1.1.10001</oid_index>
+ <fields>
+ <beIID>
+ <name>Proxy ID</name>
+ <method>get</method>
+ <source>value</source>
+ <direction>input</direction>
+ <oid>.1.3.6.1.4.1.29385.106.1.1.27</oid>
+ </beIID>
+ <beSID>
+ <name>Service ID</name>
+ <method>get</method>
+ <source>value</source>
+ <direction>input</direction>
+ <oid>.1.3.6.1.4.1.29385.106.1.1.28</oid>
+ </beSID>
+ <bePxName>
+ <name>Proxy Name</name>
+ <method>get</method>
+ <source>value</source>
+ <direction>input</direction>
+ <oid>.1.3.6.1.4.1.29385.106.1.1.0</oid>
+ </bePxName>
+ <beSvName>
+ <name>Service Name</name>
+ <method>get</method>
+ <source>value</source>
+ <direction>input</direction>
+ <oid>.1.3.6.1.4.1.29385.106.1.1.1</oid>
+ </beSvName>
+ <beSTot>
+ <name>Total Sessions</name>
+ <method>get</method>
+ <source>value</source>
+ <direction>output</direction>
+ <oid>.1.3.6.1.4.1.29385.106.1.1.7</oid>
+ </beSTot>
+ <beBIn>
+ <name>Bytes In</name>
+ <method>get</method>
+ <source>value</source>
+ <direction>output</direction>
+ <oid>.1.3.6.1.4.1.29385.106.1.1.8</oid>
+ </beBIn>
+ <beBOut>
+ <name>Bytes Out</name>
+ <method>get</method>
+ <source>value</source>
+ <direction>output</direction>
+ <oid>.1.3.6.1.4.1.29385.106.1.1.9</oid>
+ </beBOut>
+ <beEConn>
+ <name>Connection Errors</name>
+ <method>get</method>
+ <source>value</source>
+ <direction>output</direction>
+ <oid>.1.3.6.1.4.1.29385.106.1.1.13</oid>
+ </beEConn>
+ <beEResp>
+ <name>Response Errors</name>
+ <method>get</method>
+ <source>value</source>
+ <direction>output</direction>
+ <oid>.1.3.6.1.4.1.29385.106.1.1.14</oid>
+ </beEResp>
+ <beLBTot>
+ <name>LB Total</name>
+ <method>get</method>
+ <source>value</source>
+ <direction>output</direction>
+ <oid>.1.3.6.1.4.1.29385.106.1.1.30</oid>
+ </beLBTot>
+ <beDReq>
+ <name>Denied Requests</name>
+ <method>get</method>
+ <source>value</source>
+ <direction>output</direction>
+ <oid>.1.3.6.1.4.1.29385.106.1.1.10</oid>
+ </beDReq>
+ </fields>
+</interface>
diff --git a/admin/netsnmp-perl/haproxy_frontend.xml b/admin/netsnmp-perl/haproxy_frontend.xml
new file mode 100644
index 0000000..ade2a77
--- /dev/null
+++ b/admin/netsnmp-perl/haproxy_frontend.xml
@@ -0,0 +1,83 @@
+<interface>
+ <name>HAProxy - frontend</name>
+ <oid_index>.1.3.6.1.4.1.29385.106.1.0.10001</oid_index>
+ <fields>
+ <feIID>
+ <name>Proxy ID</name>
+ <method>get</method>
+ <source>value</source>
+ <direction>input</direction>
+ <oid>.1.3.6.1.4.1.29385.106.1.0.27</oid>
+ </feIID>
+ <feSID>
+ <name>Service ID</name>
+ <method>get</method>
+ <source>value</source>
+ <direction>input</direction>
+ <oid>.1.3.6.1.4.1.29385.106.1.0.28</oid>
+ </feSID>
+ <fePxName>
+ <name>Proxy Name</name>
+ <method>get</method>
+ <source>value</source>
+ <direction>input</direction>
+ <oid>.1.3.6.1.4.1.29385.106.1.0.0</oid>
+ </fePxName>
+ <feSvName>
+ <name>Service Name</name>
+ <method>get</method>
+ <source>value</source>
+ <direction>input</direction>
+ <oid>.1.3.6.1.4.1.29385.106.1.0.1</oid>
+ </feSvName>
+ <feSCur>
+ <name>Current Sessions</name>
+ <method>get</method>
+ <source>value</source>
+ <direction>output</direction>
+ <oid>.1.3.6.1.4.1.29385.106.1.0.4</oid>
+ </feSCur>
+ <feSMax>
+ <name>Maximum Sessions</name>
+ <method>get</method>
+ <source>value</source>
+ <direction>output</direction>
+ <oid>.1.3.6.1.4.1.29385.106.1.0.5</oid>
+ </feSMax>
+ <feSTot>
+ <name>Total Sessions</name>
+ <method>get</method>
+ <source>value</source>
+ <direction>output</direction>
+ <oid>.1.3.6.1.4.1.29385.106.1.0.7</oid>
+ </feSTot>
+ <feEReq>
+ <name>Request Errors</name>
+ <method>get</method>
+ <source>value</source>
+ <direction>output</direction>
+ <oid>.1.3.6.1.4.1.29385.106.1.0.12</oid>
+ </feEReq>
+ <feBIn>
+ <name>Bytes In</name>
+ <method>get</method>
+ <source>value</source>
+ <direction>output</direction>
+ <oid>.1.3.6.1.4.1.29385.106.1.0.8</oid>
+ </feBIn>
+ <feBOut>
+ <name>Bytes Out</name>
+ <method>get</method>
+ <source>value</source>
+ <direction>output</direction>
+ <oid>.1.3.6.1.4.1.29385.106.1.0.9</oid>
+ </feBOut>
+ <feDReq>
+ <name>Denied Requests</name>
+ <method>get</method>
+ <source>value</source>
+ <direction>output</direction>
+ <oid>.1.3.6.1.4.1.29385.106.1.0.10</oid>
+ </feDReq>
+ </fields>
+</interface>
diff --git a/admin/netsnmp-perl/haproxy_socket.xml b/admin/netsnmp-perl/haproxy_socket.xml
new file mode 100644
index 0000000..63ae110
--- /dev/null
+++ b/admin/netsnmp-perl/haproxy_socket.xml
@@ -0,0 +1,90 @@
+<interface>
+ <name>HAProxy - socket</name>
+ <oid_index>.1.3.6.1.4.1.29385.106.1.3.10001</oid_index>
+ <fields>
+ <feseID>
+ <name>Unique Index</name>
+ <method>get</method>
+ <source>value</source>
+ <direction>input</direction>
+ <oid>.1.3.6.1.4.1.29385.106.1.3.10001</oid>
+ </feseID>
+ <feIID>
+ <name>Proxy ID</name>
+ <method>get</method>
+ <source>value</source>
+ <direction>input</direction>
+ <oid>.1.3.6.1.4.1.29385.106.1.3.27</oid>
+ </feIID>
+ <feSID>
+ <name>Service ID</name>
+ <method>get</method>
+ <source>value</source>
+ <direction>input</direction>
+ <oid>.1.3.6.1.4.1.29385.106.1.3.28</oid>
+ </feSID>
+ <fePxName>
+ <name>Proxy Name</name>
+ <method>get</method>
+ <source>value</source>
+ <direction>input</direction>
+ <oid>.1.3.6.1.4.1.29385.106.1.3.0</oid>
+ </fePxName>
+ <feSvName>
+ <name>Service Name</name>
+ <method>get</method>
+ <source>value</source>
+ <direction>input</direction>
+ <oid>.1.3.6.1.4.1.29385.106.1.3.1</oid>
+ </feSvName>
+ <feSCur>
+ <name>Current Sessions</name>
+ <method>get</method>
+ <source>value</source>
+ <direction>output</direction>
+ <oid>.1.3.6.1.4.1.29385.106.1.3.4</oid>
+ </feSCur>
+ <feSMax>
+ <name>Maximum Sessions</name>
+ <method>get</method>
+ <source>value</source>
+ <direction>output</direction>
+ <oid>.1.3.6.1.4.1.29385.106.1.3.5</oid>
+ </feSMax>
+ <feSTot>
+ <name>Total Sessions</name>
+ <method>get</method>
+ <source>value</source>
+ <direction>output</direction>
+ <oid>.1.3.6.1.4.1.29385.106.1.3.7</oid>
+ </feSTot>
+ <feEReq>
+ <name>Request Errors</name>
+ <method>get</method>
+ <source>value</source>
+ <direction>output</direction>
+ <oid>.1.3.6.1.4.1.29385.106.1.3.12</oid>
+ </feEReq>
+ <feBIn>
+ <name>Bytes In</name>
+ <method>get</method>
+ <source>value</source>
+ <direction>output</direction>
+ <oid>.1.3.6.1.4.1.29385.106.1.3.8</oid>
+ </feBIn>
+ <feBOut>
+ <name>Bytes Out</name>
+ <method>get</method>
+ <source>value</source>
+ <direction>output</direction>
+ <oid>.1.3.6.1.4.1.29385.106.1.3.9</oid>
+ </feBOut>
+ <feDReq>
+ <name>Denied Requests</name>
+ <method>get</method>
+ <source>value</source>
+ <direction>output</direction>
+ <oid>.1.3.6.1.4.1.29385.106.1.3.10</oid>
+ </feDReq>
+ </fields>
+</interface>
diff --git a/admin/release-estimator/README.md b/admin/release-estimator/README.md
new file mode 100644
index 0000000..a51f731
--- /dev/null
+++ b/admin/release-estimator/README.md
@@ -0,0 +1,68 @@
+# Release Estimator
+This tool monitors the HAProxy stable branches and calculates a proposed
+release date for the next minor release based on the bug fixes that are in
+the queue.
+
+
+## Requirements
+ - Python 3.x
+ - [lxml](https://lxml.de/installation.html)
+
+
+## Usage
+ release-estimator.py [-h] [--print] [--to-email TO_EMAIL]
+ [--from-email FROM_EMAIL] [--send-mail]
+
+ optional arguments:
+ -h, --help show this help message and exit
+ --print Print email only
+ --to-email TO_EMAIL Send email to <email>
+ --from-email FROM_EMAIL
+ Send email from <email>
+ --send-mail Send email
+
+
+## Examples
+
+
+### Print only:
+ ./release-estimator.py --print
+
+
+### Send email:
+ ./release-estimator.py --send-mail --from-email from@domain.local --to-email to@domain.local
+
+
+## How it works
+For each version we check the age and apply the following logic:
+ - Skip the release if it's:
+ - older than MAX_VERSION_AGE
+ - older than MAX_VERSION_AGE_NONLTS days and an odd numbered release
+ (1.9,2.1,2.3)
+
+ - For all other valid releases we will then collect the number of bug fixes
+ in queue for each of the defined severity levels:
+ - BUG
+ - BUILD
+ - MINOR
+ - MEDIUM
+ - MAJOR
+ - CRITICAL
+
+ We'll then begin calculating the proposed release date based on the last
+ release date plus the first commit date of the first bug fix for the defined
+ severity level.
+
+ By default the proposed release dates use the following padding:
+ (Can be modified in THRESHOLDS)
+ - BUG/BUILD/MINOR - 28 days
+ - MEDIUM - 30 days
+ - MAJOR - 14 days
+ - CRITICAL - 2 days
+
+ After we have a proposed release date we will assign a release urgency
+ to it. As we get closer to the proposed release date the urgency level changes.
+ By default the urgency levels and their times are:
+ - WARNING - proposed date is 7 days or less
+ - NOTICE - proposed date is 21 days or less
+ - INFO - proposed date is longer than the above
diff --git a/admin/release-estimator/release-estimator.py b/admin/release-estimator/release-estimator.py
new file mode 100755
index 0000000..bf005df
--- /dev/null
+++ b/admin/release-estimator/release-estimator.py
@@ -0,0 +1,429 @@
+#!/usr/bin/python3
+#
+# Release estimator for HAProxy
+#
+# A tool that monitors the HAProxy stable branches and calculates a proposed
+# release date for the next minor release based on the bug fixes that are in
+# the queue.
+#
+# Copyright 2020 HAProxy Technologies, Daniel Corbett <dcorbett@haproxy.com>
+#
+# 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.
+#
+#
+
+from lxml import html
+import requests
+import traceback
+import smtplib
+import math
+import copy
+import time
+import sys
+import argparse
+from datetime import datetime
+from datetime import timedelta
+from email.mime.text import MIMEText
+
+# Do not report on versions older than
+# MAX_VERSION_AGE.
+MAX_VERSION_AGE = 1095 # days
+
+# Do not report on non-lts releases (odd releases) that
+# are older than MAX_VERSION_AGE_NONLTS
+MAX_VERSION_AGE_NONLTS = 547 # days
+
+# For each severity/issue type, set thresholds
+# count - indicates how many bugs for this issue type should be in the queue
+# time - indicates how many days should be added to the release date
+THRESHOLDS = {
+ 'BUG' :{ 'count' : 1, 'time' : 28},
+ 'BUILD' :{ 'count' : 1, 'time' : 28},
+ 'MINOR' : { 'count' : 1, 'time' : 28},
+ 'MEDIUM' : { 'count' : 1, 'time' : 30},
+ 'MAJOR' : { 'count' : 1, 'time' : 14 },
+ 'CRITICAL' : { 'count' : 1, 'time' : 2 }
+}
+
+# Increase the urgency of a release as estimated time (in days) gets closer.
+RELEASE_URGENCY = { 'WARNING' : 7, 'NOTICE' : 21, 'INFO' : '' }
+
+def search_set(s, f):
+ for t in s:
+ if f in t:
+ return True
+
+def check_for_email(s, parser):
+ if "@" not in s:
+ parser.print_help()
+ sys.exit()
+
+def main():
+ global MAX_VERSION_AGE
+ global MAX_VERSION_AGE_NONLTS
+ global THRESHOLDS
+ global RELEASE_URGENCY
+
+ SEND_MAIL=False
+ VERSIONS = []
+ issues = {}
+ BUGQUEUE = {}
+ BUGS = { "bugs" :[] }
+ email_message = """Hi,
+
+This is a friendly bot that watches fixes pending for the next haproxy-stable release! One such e-mail is sent periodically once patches are waiting in the last maintenance branch, and an ideal release date is computed based on the severity of these fixes and their merge date. Responses to this mail must be sent to the mailing list.
+
+"""
+
+ parser = argparse.ArgumentParser(description='HAProxy Stable Release Estimator')
+ parser.add_argument('--print', action="store_true",
+ help='Print email only')
+ parser.add_argument('--to-email', nargs=1, required=False,
+ help='Send email to <email>')
+ parser.add_argument('--from-email', nargs=1, required=False,
+ help='Send email from <email>')
+ parser.add_argument('--send-mail', action="store_true",
+ help='Send email')
+ args = parser.parse_args()
+
+ if not args.print and not args.send_mail and not args.to_email and not args.from_email:
+ parser.print_help()
+ sys.exit()
+
+ if args.send_mail and (not args.to_email or not args.from_email):
+ parser.print_help()
+ sys.exit()
+
+ if args.to_email:
+ check_for_email(args.to_email[0], parser)
+ TO_EMAIL = args.to_email[0]
+
+ if args.from_email:
+ check_for_email(args.from_email[0], parser)
+ FROM_EMAIL = args.from_email[0]
+
+ if args.send_mail:
+ SEND_MAIL = True
+
+ if SEND_MAIL:
+ try:
+ TO_EMAIL
+ FROM_EMAIL
+ except:
+ parser.print_help()
+ sys.exit()
+
+ #
+ # Let's get the list of the current stable versions
+ #
+
+ page = requests.get('http://www.haproxy.org/bugs/')
+ tree = html.fromstring(page.content)
+
+ for x in (tree.xpath('//th')):
+ if x.xpath('./a/text()'):
+ VERSIONS.append(x.xpath('./a/text()')[0])
+
+
+ #
+ # For each version let's check it's age. We'll apply the following logic:
+ # - Skip the release if it's:
+ # * older than MAX_VERSION_AGE days
+ # * older than MAX_VERSION_AGE_NONLTS days and an odd numbered release (1.9,2.1,2.3)
+ #
+ # For all other valid releases we will then collect the number of bug fixes
+ # in queue for each of the defined severity levels:
+ # - BUG
+ # - BUILD
+ # - MINOR
+ # - MEDIUM
+ # - MAJOR
+ # - CRITICAL
+ #
+ # We'll then begin calculating the proposed release date based on the last
+ # release date plus the first commit date of the first bug fix for the defined
+ # severity level.
+ #
+ # By default the proposed release dates use the following padding:
+ # (Can be modified in THRESHOLDS)
+ # - BUG/BUILD/MINOR - 28 days
+ # - MEDIUM - 30 days
+ # - MAJOR - 14 days
+ # - CRITICAL - 2 days
+ #
+ # After we have a proposed release date we will assign a release urgency
+ # to it. As we get closer to the proposed release date the urgency level changes.
+ # By default the urgency levels and their times are:
+ # - WARNING - proposed date is 7 days or less
+ # - NOTICE - proposed date is 21 days or less
+ # - INFO - proposed date is longer than the above
+ #
+
+ for version in VERSIONS:
+ BUGQUEUE[version] = { "total" : 0, "last": "" }
+ VERSION_THRESHOLDS = copy.deepcopy(THRESHOLDS)
+ print("Collecting information on %s" % (version))
+ page = requests.get('http://www.haproxy.org/bugs/bugs-%s.html' % (version))
+ tree = html.fromstring(page.content)
+
+ issues[version] = {}
+ issues_count = {}
+ release_soon = False
+ num_to_word = {
+ 1 : 'one',
+ 2 : 'two',
+ 3 : 'three',
+ 4 : 'four',
+ 5 : 'five',
+ 6 : 'six',
+ 7 : 'seven',
+ 8 : 'eight',
+ 9 : 'nine',
+ 10 : 'ten',
+ 11 : 'eleven',
+ 12 : 'twelve',
+ 13 : 'thirteen',
+ }
+
+ # parse out the CHANGELOG link
+ CHANGELOG = tree.xpath('//a[contains(@href,"CHANGELOG")]/@href')[0]
+
+ last_version = tree.xpath('//td[contains(text(), "last")]/../td/a/text()')[0]
+ first_version = "%s.0" % (version)
+
+ # Get CHANGELOG for release
+ changelog_page = requests.get(CHANGELOG)
+ try:
+ for l in changelog_page.content.decode('utf-8').split('\n'):
+ # the below is a bit of a hack to parse out valid years in the CHANGELOG
+ if (last_version in l) and ('201' in l or '202' in l or '200' in l) and '/' in l:
+ # set the date in which this version was last released
+ last_release_date = l.split(' ')[0]
+ last_release_datetime = datetime.strptime(last_release_date.strip(), '%Y/%m/%d')
+ BUGQUEUE[version]['last'] = last_release_date
+ break
+ for l in changelog_page.content.decode('utf-8').split('\n'):
+ # the below is a bit of a hack to parse out valid years in the CHANGELOG
+ if (first_version in l) and ('201' in l or '202' in l or '200' in l) and '/' in l:
+ # set the date in which this version was first released
+ first_release_date = l.split(' ')[0]
+ first_release_datetime = datetime.strptime(first_release_date.strip(), '%Y/%m/%d')
+ BUGQUEUE[version]['first'] = first_release_datetime
+ break
+ except:
+ print(traceback.format_exc())
+ last_release_date = False
+
+ # get unix timestamp for today and timestamp of first release date
+ today_ts = datetime.today().timestamp()
+ first_version_ts = BUGQUEUE[version]['first'].timestamp()
+
+ # calculate the age of this version in days and years
+ version_age = math.ceil((today_ts-first_version_ts)/86400)
+ version_age_years = math.ceil(version_age/365)
+
+ # We do not want to monitor versions that are older
+ # than MAX_VERSION_AGE or MAX_VERSION_AGE_NONLTS
+ if version_age >= MAX_VERSION_AGE:
+ print("\t - Version: %s is older than %d days, skipping" % (version, MAX_VERSION_AGE))
+ continue
+
+ if version_age > MAX_VERSION_AGE_NONLTS:
+ if int(version.split('.')[1]) % 2 > 0:
+ print("\t - Version: %s is not LTS and is older than %d days, skipping" % (version, MAX_VERSION_AGE_NONLTS))
+ continue
+
+ # If the release is older than 1 year let's increase the time until
+ # a release is due. <base time threshold> * <version age years>
+ if version_age_years > 1:
+ for k in VERSION_THRESHOLDS.keys():
+ VERSION_THRESHOLDS[k]['time'] *= int(version_age_years)
+
+ # Let's capture the bug table which contains each bug & their severity
+ bug_table = tree.xpath('//th[contains(text(), "Severity")]/ancestor::table[last()]')[0]
+
+ # Loop through bug table and parse out the title of each bug
+ # found within the links and their merge date.
+ # Example is: 2020-10-19 BUG/MINOR: disable dynamic OCSP load with BoringSSL
+ for x in bug_table.xpath('.//a[contains(@href,"commitdiff")]'):
+ # Capture the bug label
+ # Example: BUG/MINOR: disable dynamic OCSP load with BoringSSL
+ issue_tmp = x.xpath('./text()')[0]
+ # Capture the date
+ # Example: 2020-10-19
+ date_tmp = x.xpath('../preceding-sibling::td/text()')[0]
+
+ # Split the bug into a severity
+ if "/" in issue_tmp:
+ bug_type = issue_tmp.split(':')[0].split('/')[1].strip()
+ else:
+ bug_type = issue_tmp.split(':')[0].strip()
+ bug_text = ":".join(issue_tmp.split(':')[1:]).strip()
+ if bug_type not in issues[version].keys():
+ issues[version][bug_type] = set()
+ issues[version][bug_type].add("%s|%s" % (date_tmp, bug_text))
+
+ # Loop through the issue_types (severities) (MINOR, MEDIUM, MAJOR, etc.)
+ # We'll check if the severity has already been accounted for
+ # If not, we'll set the timestamp to the timestamp of the current issue
+ # If so, we'll check if the current bugs timestamp is less than the
+ # previous one. This will help us to determine when we first saw this
+ # severity type as calculations are based on the first time seeing a
+ # severity type. We'll then set the number of issues for each severity.
+ for issue_type in issues[version]:
+ issues_count[issue_type] = {}
+ for k in issues[version][issue_type]:
+ if 'timestamp' not in issues_count[issue_type].keys():
+ issues_count[issue_type]['timestamp'] = int(time.mktime(datetime.strptime(k.split('|')[0], "%Y-%m-%d").timetuple()))
+ else:
+ if issues_count[issue_type]['timestamp'] > int(time.mktime(datetime.strptime(k.split('|')[0], "%Y-%m-%d").timetuple())):
+ issues_count[issue_type]['timestamp'] = int(time.mktime(datetime.strptime(k.split('|')[0], "%Y-%m-%d").timetuple()))
+ issues_count[issue_type]['count'] = len(issues[version][issue_type])
+
+ release_date = None
+ total_count = 0
+
+ # Let's check the count for each severity type and see if they
+ # are greater than our thresholds count. This can be used to
+ # hold off on calculating release estimates until a certain number of
+ # MINOR bugs have accumulated.
+ for issue_type in issues_count.keys():
+ if issues_count[issue_type]['count'] >= VERSION_THRESHOLDS[issue_type]['count']:
+ # If the total number of issues is greater than the threshold
+ # for a severity we'll attempt to set a release date.
+ # We'll use the timestamp from the first time an issue was
+ # seen and add on the number of days specified within the
+ # THRESHOLDS for that issue type. We'll also increment
+ # the total number of issues that have been fixed in this
+ # version across all severities/issue types.
+ total_count += issues_count[issue_type]['count']
+ issue_timestamp_delta = datetime.fromtimestamp(int(issues_count[issue_type]['timestamp'])) + timedelta(days=int(VERSION_THRESHOLDS[issue_type]['time']))
+ if not release_date: release_date = issue_timestamp_delta
+ elif release_date > issue_timestamp_delta: release_date = issue_timestamp_delta
+
+ if release_date: release_soon = True
+ if release_soon:
+ time_until_release = release_date - datetime.now()
+
+ # If a release date has been sent, let's calculate how long
+ # in words until that release. i.e. "less than 2 weeks"
+ if release_soon:
+ for k in sorted(RELEASE_URGENCY.keys()):
+ if not RELEASE_URGENCY[k]:
+ release_urgency_msg = k
+ elif time_until_release.days <= RELEASE_URGENCY[k]:
+ release_urgency_msg = k
+ rounded_week_time = math.ceil(time_until_release.days/7.0)
+ if abs(rounded_week_time) > 1:
+ week_word = 'weeks'
+ else:
+ week_word = 'week'
+ try:
+ # We now have all of the required information for building
+ # the email message.
+ # TODO: Fix alignment
+ email_message = """%s
+ Last release %s was issued on %s. There are currently %d patches in the queue cut down this way:
+""" % (email_message, last_version, last_release_datetime.strftime("%Y-%m-%d"), total_count)
+ for issue_type in sorted(issues_count.keys()):
+ email_message = "%s - %d %s, first one merged on %s\n" % (email_message, issues_count[issue_type]['count'],issue_type,datetime.fromtimestamp(int(issues_count[issue_type]['timestamp'])).strftime("%Y-%m-%d"))
+ email_message = "%s\nThus the computed ideal release date for %s would be %s, " % (email_message, ".".join(last_version.split(".")[:-1])+"."+str(int(last_version.split(".")[-1])+1), release_date.strftime("%Y-%m-%d"))
+ if rounded_week_time < 0:
+ email_message = "%swhich was %s %s ago.\n" % (email_message, num_to_word[abs(rounded_week_time)], week_word)
+ elif rounded_week_time == 0:
+ email_message = "%swhich was within the last week.\n" % (email_message)
+ else:
+ email_message = "%swhich is in %s %s or less.\n" % (email_message, num_to_word[rounded_week_time], week_word)
+ except Exception as err:
+ print(traceback.format_exc())
+ sys.exit()
+ # Total number of bugs fixed in this version
+ # since last release.
+ BUGQUEUE[version]['total'] = total_count
+
+ email_subject = "stable-bot: Bugfixes waiting for a release "
+
+ # Add each version & their number of bugs to the subject
+ for k in sorted(BUGQUEUE.keys(), reverse=True):
+ if BUGQUEUE[k]['total'] > 0:
+ email_subject = "%s %s (%d)," % ( email_subject, k, BUGQUEUE[k]['total'])
+
+ email_subject = email_subject.rstrip(",")
+ email_message = "%s\nThe current list of patches in the queue is:\n" % (email_message)
+ uniq_issues = set()
+
+ # Parse out unique issues across all versions so that we can
+ # print them once with the list of affected versions.
+ for k in BUGQUEUE.keys():
+ for issue_type in sorted(issues[k].keys()):
+ for issue in issues[k][issue_type]:
+ uniq_issues.add("%s|%s" % (issue_type,issue.split('|')[1]))
+
+ # Loop through the unique issues and determine which versions
+ # are affected.
+ for i in uniq_issues:
+ affected_versions = []
+ for k in BUGQUEUE.keys():
+ try:
+ if search_set(issues[k][i.split('|')[0]], i.split('|')[1]):
+ affected_versions.append(k)
+ except Exception as e:
+ pass
+ if affected_versions:
+ affected_versions.sort()
+ try:
+ BUGS["bugs"].append({ "affected_versions" : affected_versions, "bug":i.split('|')[1], "severity":i.split('|')[0] })
+ except:
+ BUGS["bugs"] = [ { "affected_versions" : affected_versions, "bug":i.split('|')[1], "severity":i.split('|')[0] } ]
+
+ BUGS["bugs"] = sorted(BUGS["bugs"], key = lambda i: i['severity'])
+
+ # Add each issue with affected versions to email message
+ # Example:
+ # - 1.8, 2.0, 2.1, 2.2 - MINOR : stats: fix validity of the json schema
+ for bug in BUGS["bugs"]:
+ email_message = "%s - %s %s %s : %s\n" % (email_message, ", ".join(bug["affected_versions"]).ljust(14), "-".rjust(12), bug["severity"].ljust(7), bug["bug"])
+
+ email_message="%s\n-- \nThe haproxy stable-bot is freely provided by HAProxy Technologies to help improve the quality of each HAProxy release. If you have any issue with these emails or if you want to suggest some improvements, please post them on the list so that the solutions suiting the most users can be found.\n" % (email_message)
+
+ # If a message with actual issues exists let's either print it or send out
+ # an email.
+ if "first one merged on" in email_message:
+ if args.print:
+ print(email_subject)
+ print(email_message)
+ if SEND_MAIL:
+ print('Send email to:%s from:%s' % (TO_EMAIL, FROM_EMAIL), end="")
+ msg = MIMEText(email_message)
+ msg['to'] = TO_EMAIL
+ msg['from'] = FROM_EMAIL
+ msg['subject'] = email_subject
+ msg.add_header('reply-to', TO_EMAIL)
+ try:
+ server = smtplib.SMTP('127.0.0.1', timeout=10)
+ server.sendmail(msg['from'], [msg['to']], msg.as_string())
+ print(" - Email sent")
+ except (ConnectionRefusedError, smtplib.SMTPConnectError):
+ print("- Error: SMTP Connection Error")
+ sys.exit()
+ except smtplib.SMTPServerDisconnected:
+ print('- Error: SMTP Server Disconnect (possible timeout)')
+ sys.exit()
+ except (smtplib.SMTPRecipientsRefused, smtplib.SMTPSenderRefused):
+ print('- Error: Recipients or Sender Refused')
+ sys.exit()
+ except (smtplib.SMTPHeloError, smtplib.SMTPAuthenticationError):
+ print('- Error: SMTP rejected HELO or requires Authentication')
+ sys.exit()
+ except:
+ print(traceback.format_exc())
+ sys.exit()
+
+
+if __name__ == "__main__":
+ main()
+
+sys.exit()
diff --git a/admin/selinux/README b/admin/selinux/README
new file mode 100644
index 0000000..7ad924d
--- /dev/null
+++ b/admin/selinux/README
@@ -0,0 +1,18 @@
+This directory includes an selinux policy for haproxy. It assumes
+the following file locations:
+
+ /usr/sbin/haproxy -- binary
+ /etc/haproxy/haproxy\.cfg -- configuration
+ /var/run/haproxy\.pid -- pid-file
+ /var/run/haproxy\.sock(.*) -- stats socket
+ /var/empty/haproxy -- chroot dir
+
+To build and load it on RHEL5 you'll need the "selinux-policy-devel" package,
+and from within this directory run:
+
+ make -f /usr/share/selinux/devel/Makefile
+ sudo semodule -i haproxy.pp
+ restorecon /usr/sbin/haproxy /etc/haproxy/haproxy.cfg /var/run/haproxy.pid /var/run/haproxy.sock*
+
+
+Feedback to Jan-Frode Myklebust <janfrode@tanso.no> is much appreciated,
diff --git a/admin/selinux/haproxy.fc b/admin/selinux/haproxy.fc
new file mode 100644
index 0000000..63a0828
--- /dev/null
+++ b/admin/selinux/haproxy.fc
@@ -0,0 +1,6 @@
+# haproxy labeling policy
+# file: haproxy.fc
+/usr/sbin/haproxy -- gen_context(system_u:object_r:haproxy_exec_t, s0)
+/etc/haproxy/haproxy\.cfg -- gen_context(system_u:object_r:haproxy_conf_t, s0)
+/var/run/haproxy\.pid -- gen_context(system_u:object_r:haproxy_var_run_t, s0)
+/var/run/haproxy\.sock(.*) -- gen_context(system_u:object_r:haproxy_var_run_t, s0)
diff --git a/admin/selinux/haproxy.if b/admin/selinux/haproxy.if
new file mode 100644
index 0000000..236ad38
--- /dev/null
+++ b/admin/selinux/haproxy.if
@@ -0,0 +1,2 @@
+## <summary>selinux policy module for haproxy</summary>
+
diff --git a/admin/selinux/haproxy.te b/admin/selinux/haproxy.te
new file mode 100644
index 0000000..bc124fb
--- /dev/null
+++ b/admin/selinux/haproxy.te
@@ -0,0 +1,66 @@
+policy_module(haproxy,1.0.0)
+
+########################################
+#
+# Declarations
+#
+
+type haproxy_t;
+type haproxy_exec_t;
+type haproxy_port_t;
+init_daemon_domain(haproxy_t, haproxy_exec_t)
+
+type haproxy_var_run_t;
+files_pid_file(haproxy_var_run_t)
+
+type haproxy_conf_t;
+files_config_file(haproxy_conf_t)
+
+########################################
+#
+# Local policy
+#
+
+# Configuration files - read
+allow haproxy_t haproxy_conf_t : dir list_dir_perms;
+allow haproxy_t haproxy_conf_t : file read_file_perms;
+allow haproxy_t haproxy_conf_t : lnk_file read_file_perms;
+
+# PID and socket file - create, read, and write
+files_pid_filetrans(haproxy_t, haproxy_var_run_t, { file sock_file })
+allow haproxy_t haproxy_var_run_t:file manage_file_perms;
+allow haproxy_t haproxy_var_run_t:sock_file { create rename link setattr unlink };
+
+allow haproxy_t self : tcp_socket create_stream_socket_perms;
+allow haproxy_t self: udp_socket create_socket_perms;
+allow haproxy_t self: capability { setgid setuid sys_chroot sys_resource kill };
+allow haproxy_t self: process { setrlimit signal };
+
+
+logging_send_syslog_msg(haproxy_t)
+
+corenet_tcp_bind_all_ports(haproxy_t)
+corenet_tcp_connect_all_ports(haproxy_t)
+corenet_tcp_bind_all_nodes(haproxy_t)
+corenet_tcp_sendrecv_all_ports(haproxy_t)
+corenet_tcp_recvfrom_unlabeled(haproxy_t)
+
+# use shared libraries
+libs_use_ld_so(haproxy_t)
+libs_use_shared_libs(haproxy_t)
+
+# Read /etc/localtime:
+miscfiles_read_localization(haproxy_t)
+# Read /etc/passwd and more.
+files_read_etc_files(haproxy_t)
+
+# RHEL5 specific:
+require {
+ type unlabeled_t;
+ type haproxy_t;
+ class packet send;
+ class packet recv;
+}
+
+allow haproxy_t unlabeled_t:packet { send recv };
+
diff --git a/admin/syntax-highlight/haproxy.vim b/admin/syntax-highlight/haproxy.vim
new file mode 100644
index 0000000..f559df0
--- /dev/null
+++ b/admin/syntax-highlight/haproxy.vim
@@ -0,0 +1,164 @@
+" Vim syntax file
+" Language: HAProxy
+" Maintainer: Bruno Michel <brmichel@free.fr>
+" Last Change: Mar 30, 2007
+" Version: 0.3
+" URL: http://haproxy.1wt.eu/
+" URL: http://vim.sourceforge.net/scripts/script.php?script_id=1845
+
+" It is suggested to add the following line to $HOME/.vimrc :
+" au BufRead,BufNewFile haproxy* set ft=haproxy
+
+" For version 5.x: Clear all syntax items
+" For version 6.x: Quit when a syntax file was already loaded
+if version < 600
+ syntax clear
+elseif exists("b:current_syntax")
+ finish
+endif
+
+if version >= 600
+ setlocal iskeyword=_,-,a-z,A-Z,48-57
+else
+ set iskeyword=_,-,a-z,A-Z,48-57
+endif
+
+
+" Escaped chars
+syn match hapEscape +\\\(\\\| \|n\|r\|t\|#\|x\x\x\)+
+
+" Comments
+syn match hapComment /#.*$/ contains=hapTodo
+syn keyword hapTodo contained TODO FIXME XXX
+syn case ignore
+
+" Sections
+syn match hapSection /^\s*\(global\|defaults\)/
+syn match hapSection /^\s*\(listen\|frontend\|backend\|ruleset\)/ skipwhite nextgroup=hapSectLabel
+syn match hapSectLabel /\S\+/ skipwhite nextgroup=hapIp1 contained
+syn match hapIp1 /\(\d\{1,3}\.\d\{1,3}\.\d\{1,3}\.\d\{1,3}\)\?:\d\{1,5}/ nextgroup=hapIp2 contained
+syn match hapIp2 /,\(\d\{1,3}\.\d\{1,3}\.\d\{1,3}\.\d\{1,3}\)\?:\d\{1,5}/hs=s+1 nextgroup=hapIp2 contained
+
+" Parameters
+syn keyword hapParam chroot cliexp
+syn keyword hapParam daemon debug disabled
+syn keyword hapParam enabled
+syn keyword hapParam fullconn
+syn keyword hapParam gid group
+syn keyword hapParam maxconn monitor-uri
+syn keyword hapParam noepoll nopoll
+syn keyword hapParam pidfile
+syn keyword hapParam quiet
+syn keyword hapParam redispatch retries
+syn keyword hapParam reqallow reqdel reqdeny reqpass reqtarpit skipwhite nextgroup=hapRegexp
+syn keyword hapParam reqiallow reqidel reqideny reqipass reqitarpit skipwhite nextgroup=hapRegexp
+syn keyword hapParam rspdel rspdeny skipwhite nextgroup=hapRegexp
+syn keyword hapParam rspidel rspideny skipwhite nextgroup=hapRegexp
+syn keyword hapParam reqsetbe reqisetbe skipwhite nextgroup=hapRegexp2
+syn keyword hapParam reqadd reqiadd rspadd rspiadd
+syn keyword hapParam server source srvexp
+syn keyword hapParam uid ulimit-n user
+syn keyword hapParam reqrep reqirep rsprep rspirep skipwhite nextgroup=hapRegexp
+syn keyword hapParam errorloc errorloc302 errorloc303 skipwhite nextgroup=hapStatus
+syn keyword hapParam default_backend skipwhite nextgroup=hapSectLabel
+syn keyword hapParam appsession skipwhite nextgroup=hapAppSess
+syn keyword hapParam bind skipwhite nextgroup=hapIp1
+syn keyword hapParam balance skipwhite nextgroup=hapBalance
+syn keyword hapParam cookie skipwhite nextgroup=hapCookieNam
+syn keyword hapParam capture skipwhite nextgroup=hapCapture
+syn keyword hapParam dispatch skipwhite nextgroup=hapIpPort
+syn keyword hapParam source skipwhite nextgroup=hapIpPort
+syn keyword hapParam mode skipwhite nextgroup=hapMode
+syn keyword hapParam monitor-net skipwhite nextgroup=hapIPv4Mask
+syn keyword hapParam option skipwhite nextgroup=hapOption
+syn keyword hapParam stats skipwhite nextgroup=hapStats
+syn keyword hapParam server skipwhite nextgroup=hapServerN
+syn keyword hapParam source skipwhite nextgroup=hapServerEOL
+syn keyword hapParam log skipwhite nextgroup=hapGLog,hapLogIp
+
+" Options and additional parameters
+syn keyword hapAppSess contained len timeout
+syn keyword hapBalance contained roundrobin source
+syn keyword hapLen contained len
+syn keyword hapGLog contained global
+syn keyword hapMode contained http tcp health
+syn keyword hapOption contained abortonclose allbackups checkcache clitcpka dontlognull forwardfor
+syn keyword hapOption contained httpchk httpclose httplog keepalive logasap persist srvtcpka ssl-hello-chk
+syn keyword hapOption contained tcplog tcpka tcpsplice
+syn keyword hapOption contained except skipwhite nextgroup=hapIPv4Mask
+syn keyword hapStats contained uri realm auth scope enable
+syn keyword hapLogFac contained kern user mail daemon auth syslog lpr news nextgroup=hapLogLvl skipwhite
+syn keyword hapLogFac contained uucp cron auth2 ftp ntp audit alert cron2 nextgroup=hapLogLvl skipwhite
+syn keyword hapLogFac contained local0 local1 local2 local3 local4 local5 local6 local7 nextgroup=hapLogLvl skipwhite
+syn keyword hapLogLvl contained emerg alert crit err warning notice info debug
+syn keyword hapCookieKey contained rewrite insert nocache postonly indirect prefix nextgroup=hapCookieKey skipwhite
+syn keyword hapCapture contained cookie nextgroup=hapNameLen skipwhite
+syn keyword hapCapture contained request response nextgroup=hapHeader skipwhite
+syn keyword hapHeader contained header nextgroup=hapNameLen skipwhite
+syn keyword hapSrvKey contained backup cookie check inter rise fall port source minconn maxconn weight usesrc
+syn match hapStatus contained /\d\{3}/
+syn match hapIPv4Mask contained /\d\{1,3}\.\d\{1,3}\.\d\{1,3}\.\d\{1,3}\(\/\d\{1,2}\)\?/
+syn match hapLogIp contained /\d\{1,3}\.\d\{1,3}\.\d\{1,3}\.\d\{1,3}/ nextgroup=hapLogFac skipwhite
+syn match hapIpPort contained /\d\{1,3}\.\d\{1,3}\.\d\{1,3}\.\d\{1,3}:\d\{1,5}/
+syn match hapServerAd contained /\d\{1,3}\.\d\{1,3}\.\d\{1,3}\.\d\{1,3}\(:[+-]\?\d\{1,5}\)\?/ nextgroup=hapSrvEOL skipwhite
+syn match hapNameLen contained /\S\+/ nextgroup=hapLen skipwhite
+syn match hapCookieNam contained /\S\+/ nextgroup=hapCookieKey skipwhite
+syn match hapServerN contained /\S\+/ nextgroup=hapServerAd skipwhite
+syn region hapSrvEOL contained start=/\S/ end=/$/ contains=hapSrvKey
+syn region hapRegexp contained start=/\S/ end=/\(\s\|$\)/ skip=/\\ / nextgroup=hapRegRepl skipwhite
+syn region hapRegRepl contained start=/\S/ end=/$/ contains=hapComment,hapEscape,hapBackRef
+syn region hapRegexp2 contained start=/\S/ end=/\(\s\|$\)/ skip=/\\ / nextgroup=hapSectLabel skipwhite
+syn match hapBackref contained /\\\d/
+
+
+" Transparent is a Vim keyword, so we need a regexp to match it
+syn match hapParam +transparent+
+syn match hapOption +transparent+ contained
+
+
+" Define the default highlighting.
+" For version 5.7 and earlier: only when not done already
+" For version 5.8 and later: only when an item doesn't have highlighting yet
+if version < 508
+ command -nargs=+ HiLink hi link <args>
+else
+ command -nargs=+ HiLink hi def link <args>
+endif
+
+HiLink hapEscape SpecialChar
+HiLink hapBackRef Special
+HiLink hapComment Comment
+HiLink hapTodo Todo
+HiLink hapSection Constant
+HiLink hapSectLabel Identifier
+HiLink hapParam Keyword
+
+HiLink hapRegexp String
+HiLink hapRegexp2 hapRegexp
+HiLink hapIp1 Number
+HiLink hapIp2 hapIp1
+HiLink hapLogIp hapIp1
+HiLink hapIpPort hapIp1
+HiLink hapIPv4Mask hapIp1
+HiLink hapServerAd hapIp1
+HiLink hapStatus Number
+
+HiLink hapOption Operator
+HiLink hapAppSess hapOption
+HiLink hapBalance hapOption
+HiLink hapCapture hapOption
+HiLink hapCookieKey hapOption
+HiLink hapHeader hapOption
+HiLink hapGLog hapOption
+HiLink hapLogFac hapOption
+HiLink hapLogLvl hapOption
+HiLink hapMode hapOption
+HiLink hapStats hapOption
+HiLink hapLen hapOption
+HiLink hapSrvKey hapOption
+
+
+delcommand HiLink
+
+let b:current_syntax = "haproxy"
+" vim: ts=8
diff --git a/admin/systemd/Makefile b/admin/systemd/Makefile
new file mode 100644
index 0000000..e542c23
--- /dev/null
+++ b/admin/systemd/Makefile
@@ -0,0 +1,8 @@
+PREFIX = /usr/local
+SBINDIR = $(PREFIX)/sbin
+
+haproxy.service: haproxy.service.in
+ sed -e 's:@SBINDIR@:'$(strip $(SBINDIR))':' $< > $@
+
+clean:
+ rm -f haproxy.service
diff --git a/admin/systemd/haproxy.service.in b/admin/systemd/haproxy.service.in
new file mode 100644
index 0000000..22a53d8
--- /dev/null
+++ b/admin/systemd/haproxy.service.in
@@ -0,0 +1,37 @@
+[Unit]
+Description=HAProxy Load Balancer
+After=network-online.target
+Wants=network-online.target
+
+[Service]
+EnvironmentFile=-/etc/default/haproxy
+EnvironmentFile=-/etc/sysconfig/haproxy
+Environment="CONFIG=/etc/haproxy/haproxy.cfg" "PIDFILE=/run/haproxy.pid" "EXTRAOPTS=-S /run/haproxy-master.sock"
+ExecStart=@SBINDIR@/haproxy -Ws -f $CONFIG -p $PIDFILE $EXTRAOPTS
+ExecReload=@SBINDIR@/haproxy -Ws -f $CONFIG -c $EXTRAOPTS
+ExecReload=/bin/kill -USR2 $MAINPID
+KillMode=mixed
+Restart=always
+SuccessExitStatus=143
+Type=notify
+
+# The following lines leverage SystemD's sandboxing options to provide
+# defense in depth protection at the expense of restricting some flexibility
+# in your setup (e.g. placement of your configuration files) or possibly
+# reduced performance. See systemd.service(5) and systemd.exec(5) for further
+# information.
+
+# NoNewPrivileges=true
+# ProtectHome=true
+# If you want to use 'ProtectSystem=strict' you should whitelist the PIDFILE,
+# any state files and any other files written using 'ReadWritePaths' or
+# 'RuntimeDirectory'.
+# ProtectSystem=true
+# ProtectKernelTunables=true
+# ProtectKernelModules=true
+# ProtectControlGroups=true
+# If your SystemD version supports them, you can add: @reboot, @swap, @sync
+# SystemCallFilter=~@cpu-emulation @keyring @module @obsolete @raw-io
+
+[Install]
+WantedBy=multi-user.target
diff --git a/admin/wireshark-dissectors/peers/Makefile b/admin/wireshark-dissectors/peers/Makefile
new file mode 100644
index 0000000..95149e7
--- /dev/null
+++ b/admin/wireshark-dissectors/peers/Makefile
@@ -0,0 +1,17 @@
+CFLAGS = `pkg-config --cflags wireshark` -g -fPIC $(OPTS)
+LDFLAGS = `pkg-config --libs wireshark`
+
+NAME = packet-happp.so
+OBJS = packet-happp.o
+
+plugins=$(HOME)/.wireshark/plugins/
+
+$(NAME): $(OBJS)
+ $(CC) -shared $(LDFLAGS) $(OBJS) -o $@
+
+install: $(NAME)
+ install -d $(DESTDIR)$(plugins)
+ install -m 0755 $(NAME) $(DESTDIR)$(plugins)
+
+clean:
+ rm $(NAME) $(OBJS)
diff --git a/admin/wireshark-dissectors/peers/README b/admin/wireshark-dissectors/peers/README
new file mode 100644
index 0000000..95a3603
--- /dev/null
+++ b/admin/wireshark-dissectors/peers/README
@@ -0,0 +1,78 @@
+------------------------------------------------------------------------
+How to build wireshark with HAProxy Peers Protocol dissection support.
+------------------------------------------------------------------------
+
+Please note that at this time, HAProxy Peers Protocol dissection is not supported
+on Windows systems (could not be tested).
+
+1) File list
+-------------
+ - packet-happp.c: source code for HAProxy Peers Protocol (HAPPP) dissection
+ support.
+ - wireshark.happp.dissector.patch: a patch file for wireshark sources to enable HAPPP
+ dissection support. Note that this patch file modifies only two files:
+ (epan/dissectors/CMakeLists.txt and epan/dissectors/Makefile.am) to add
+ packet-happp.c file DISSECTOR_SRC variable which list all wireshark
+ - README: this file.
+
+2a) To build wireshark with HAPPP dissection support
+---------------------------------------------------
+ - Download wireshark sources:
+ $ git clone https://code.wireshark.org/review/wireshark
+ - copy packet-happp.c file to epan/dissectors/ directory.
+ - apply wireshark.happp.dissector.patch file to wireshark source directory.
+ - build wireshark (see https://www.wireshark.org/docs/wsdg_html_chunked/):
+ $ ./autogen.sh
+ $ ./configure
+ $ make
+
+2b) Alternative: build the HAPPP dissector as a wireshark plugin
+-----------------------------------------------------------------
+If you don't want to build completely wireshark, you can build the dissector as
+a plugin.
+
+You will need the development package of your distribution, which is
+"libwireshark-dev" for debian based distribution and "wireshark-dev" for
+redhat-based ones.
+
+$ make
+
+It is possible that depending on your distribution the compilation may fail
+with such an error:
+
+ packet-happp.c:40:10: fatal error: ws_version.h: No such file or directory
+ #include <ws_version.h>
+
+In this case try to build this plugins with this OPTS variable:
+
+$ OPTS=-DWITHOUT_WS_VERSION make
+
+To install it in your home directory:
+
+$ make install
+
+The plugin will be installed in ~/.wireshark/plugins/ by default, but you can
+change this path by setting the "plugins" variable. If it didn't work, check
+the paths in "Help > About Wireshark > Folders > Personal Plugins" which should
+give you the right path to use.
+
+In some distribution it will be in ~/.local/lib/wireshark/ so you will need to
+install it this way:
+
+$ make install plugins=~/.local/lib/wireshark/plugins/3.2/epan/
+
+If you want to install it in the system directory you can do it this way, the
+right path is also in the Folder window. Change the plugins variable this way:
+
+$ sudo make install plugins=/usr/lib64/wireshark/plugins/3.2/epan/
+
+Be careful to use the right version number in the path.
+
+3) Check if you have the dissector in wireshark
+-----------------------------------------------
+To verify if the protocol was well loaded by your wireshark, open the Supported
+Protocols window in "View > Internals > Supported Protocols" and look for
+"HAPPP".
+
+In the case of a plugin, you should see your plugin loaded in "Help > About
+Wireshark > Plugins".
diff --git a/admin/wireshark-dissectors/peers/packet-happp.c b/admin/wireshark-dissectors/peers/packet-happp.c
new file mode 100644
index 0000000..581262f
--- /dev/null
+++ b/admin/wireshark-dissectors/peers/packet-happp.c
@@ -0,0 +1,1679 @@
+/* packet-happp.c
+ * Routines for HAProxy Peers Protocol (HAPPP) dissection
+ * Copyright 2016, Frédéric Lécaille <flecaille@haproxy.com>
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * 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 2 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <stdio.h>
+#include <inttypes.h>
+#include <inttypes.h>
+#include <arpa/inet.h>
+
+#include <config.h>
+
+#include <epan/to_str.h>
+#include <epan/packet.h>
+#include <epan/prefs.h>
+#include <epan/conversation.h>
+#include <epan/strutil.h>
+#include <epan/dissectors/packet-tcp.h>
+#include <epan/tvbuff.h>
+
+#ifndef WITHOUT_WS_VERSION
+#include <ws_version.h>
+#endif
+
+#ifndef WIRESHARK_VERSION_MAJOR
+#define WIRESHARK_VERSION_MAJOR VERSION_MAJOR
+#endif
+#ifndef WIRESHARK_VERSION_MINOR
+#define WIRESHARK_VERSION_MINOR VERSION_MINOR
+#endif
+#ifndef WIRESHARK_VERSION_MICRO
+#define WIRESHARK_VERSION_MICRO VERSION_MICRO
+#endif
+
+#define HAPP_STR(str) #str
+#define HAPP_XSTR(str) HAPP_STR(str)
+
+WS_DLL_PUBLIC_DEF const gchar plugin_version[] = "0.0.1";
+WS_DLL_PUBLIC_DEF const gchar plugin_release[] = HAPP_XSTR(WIRESHARK_VERSION_MAJOR.WIRESHARK_VERSION_MINOR);
+WS_DLL_PUBLIC_DEF const int plugin_want_major = WIRESHARK_VERSION_MAJOR;
+WS_DLL_PUBLIC_DEF const int plugin_want_minor = WIRESHARK_VERSION_MINOR;
+WS_DLL_PUBLIC void plugin_register(void);
+
+
+#define HAPPP_PROTOCOL "HAProxyS"
+#define HAPPP_MSG_MIN_LEN 2
+
+/* Status messages are the shortest ones (3 digits followed by a LF character) */
+#define STATUS_HANDSHAKE_SUCCEEDED "200"
+#define STATUS_TRY_AGAIN_LATER "300"
+#define STATUS_PROTOCOL_ERROR "501"
+#define STATUS_BAD_VERSION "502"
+#define STATUS_LOCAL_PEER_NAME_MISMATCH "503"
+#define STATUS_REMOTE_PEER_NAME_MISMATCH "504"
+
+#include <stdio.h>
+#include <ctype.h>
+#include <stdarg.h>
+
+
+#ifdef DEBUG
+static unsigned char dbg_buf[16 << 10];
+
+__attribute__((format (printf, 3, 4)))
+void hexdump(const unsigned char *buf, size_t buflen, const char *title_fmt, ...)
+{
+ size_t i;
+ va_list ap;
+ const unsigned char *p;
+ char str_buf[2 + 1 + 16 + 1 + 1];
+
+ va_start(ap, title_fmt);
+ vfprintf(stderr, title_fmt, ap);
+ va_end(ap);
+
+ p = buf;
+ str_buf[0] = str_buf[1] = ' ';
+ str_buf[2] = '|';
+
+ for (i = 0; i < buflen; i++) {
+ if (!(i & 0xf))
+ fprintf(stderr, "%08X: ", i);
+ fprintf(stderr, " %02x", *p);
+ if (isalnum(*p))
+ str_buf[(i & 0xf) + 3] = *p;
+ else
+ str_buf[(i & 0xf) + 3] = '.';
+ if ((i & 0xf) == 0xf || i == buflen -1) {
+ size_t k;
+
+ for (k = 0; k < (0x10 - (i & 0xf) - 1); k++)
+ fprintf(stderr, " ");
+ str_buf[(i & 0xf) + 4] = '|';
+ str_buf[(i & 0xf) + 5 ] = '\0';
+ fprintf(stderr, "%s\n", str_buf);
+ }
+ p++;
+ }
+}
+
+void hexdump_tvb(tvbuff_t *tvb, const gint offset, size_t len)
+{
+ len = len > sizeof dbg_buf ? sizeof dbg_buf : len;
+ if (tvb_memcpy(tvb, dbg_buf, offset, len)) {
+ hexdump(dbg_buf, len, "tvb buff (%zu bytes):\n", len);
+ } else
+ fprintf(stderr, "tvb buff COPY FAILED\n");
+}
+#endif
+
+/* HAPPP message classes */
+enum {
+ PEER_MSG_CLASS_CONTROL = 0,
+ PEER_MSG_CLASS_ERROR,
+ PEER_MSG_CLASS_STICKTABLE = 0x0a,
+ PEER_MSG_CLASS_RESERVED = 0xff,
+};
+
+enum {
+ CONTROL_CLASS_INDEX,
+ ERROR_CLASS_INDEX,
+ STICK_TABLE_CLASS_INDEX,
+ RESERVED_CLASS_INDEX,
+};
+
+/* Control messages */
+enum {
+ PEER_MSG_CTRL_RESYNCREQ = 0,
+ PEER_MSG_CTRL_RESYNCFINISHED,
+ PEER_MSG_CTRL_RESYNCPARTIAL,
+ PEER_MSG_CTRL_RESYNCCONFIRM,
+ PEER_MSG_CTRL_HEARTBEAT,
+};
+
+/* Error messages */
+enum {
+ PEER_MSG_ERR_PROTOCOL = 0,
+ PEER_MSG_ERR_SIZELIMIT,
+};
+
+/* Stick table messages */
+enum {
+ PEER_MSG_STKT_UPDATE = 0x80,
+ PEER_MSG_STKT_INCUPDATE,
+ PEER_MSG_STKT_DEFINE,
+ PEER_MSG_STKT_SWITCH,
+ PEER_MSG_STKT_ACK,
+ PEER_MSG_STKT_UPDATE_TIMED,
+ PEER_MSG_STKT_INCUPDATE_TIMED,
+};
+
+/* This is the different key types of the stick tables.
+ * Same definitions as in HAProxy sources.
+ */
+enum {
+ SMP_T_ANY, /* any type */
+ SMP_T_BOOL, /* boolean */
+ SMP_T_SINT, /* signed 64bits integer type */
+ SMP_T_ADDR, /* ipv4 or ipv6, only used for input type compatibility */
+ SMP_T_IPV4, /* ipv4 type */
+ SMP_T_IPV6, /* ipv6 type */
+ SMP_T_STR, /* char string type */
+ SMP_T_BIN, /* buffer type */
+ SMP_T_METH, /* contain method */
+ SMP_TYPES /* number of types, must always be last */
+};
+
+/* The types of data we can store in a stick table.
+ * Same definitions as in HAProxy sources.
+ */
+enum {
+ STKT_DT_SERVER_ID, /* the server ID to use with this stream if > 0 */
+ STKT_DT_GPT0, /* General Purpose Flag 0. */
+ STKT_DT_GPC0, /* General Purpose Counter 0 (unsigned 32-bit integer) */
+ STKT_DT_GPC0_RATE, /* General Purpose Counter 0's event rate */
+ STKT_DT_CONN_CNT, /* cumulated number of connections */
+ STKT_DT_CONN_RATE, /* incoming connection rate */
+ STKT_DT_CONN_CUR, /* concurrent number of connections */
+ STKT_DT_SESS_CNT, /* cumulated number of sessions (accepted connections) */
+ STKT_DT_SESS_RATE, /* accepted sessions rate */
+ STKT_DT_HTTP_REQ_CNT, /* cumulated number of incoming HTTP requests */
+ STKT_DT_HTTP_REQ_RATE, /* incoming HTTP request rate */
+ STKT_DT_HTTP_ERR_CNT, /* cumulated number of HTTP requests errors (4xx) */
+ STKT_DT_HTTP_ERR_RATE, /* HTTP request error rate */
+ STKT_DT_BYTES_IN_CNT, /* cumulated bytes count from client to servers */
+ STKT_DT_BYTES_IN_RATE, /* bytes rate from client to servers */
+ STKT_DT_BYTES_OUT_CNT, /* cumulated bytes count from servers to client */
+ STKT_DT_BYTES_OUT_RATE, /* bytes rate from servers to client */
+ STKT_STATIC_DATA_TYPES, /* number of types above */
+};
+
+/* The types of data in stick stored in stick tables.
+ * Same definitions as in HAProxy sources.
+ */
+enum {
+ STD_T_SINT = 0, /* signed int */
+ STD_T_UINT, /* unsigned int */
+ STD_T_ULL, /* unsigned long long */
+ STD_T_FRQP, /* freq_ctr structure made of three unsigned int */
+};
+
+/* Prototypes */
+void proto_reg_handoff_happp(void);
+void proto_register_happp(void);
+
+/* Initialize the protocol and registered fields */
+static int proto_happp = -1;
+static int hf_happp_fake = -1;
+static int hf_happp_version = -1;
+static int hf_happp_remotepeerid = -1;
+static int hf_happp_localpeerid = -1;
+static int hf_happp_processpid = -1;
+static int hf_happp_relativepid = -1;
+static int hf_happp_status = -1;
+static int hf_happp_msg = -1;
+static int hf_happp_msg_class = -1;
+static int hf_happp_msg_type = -1;
+static int hf_happp_msg_len = -1;
+static int hf_happp_stkt_def_id = -1;
+static int hf_happp_stkt_def_name_len = -1;
+static int hf_happp_stkt_def_name_value = -1;
+static int hf_happp_stkt_def_key_type = -1;
+static int hf_happp_stkt_def_key_len = -1;
+static int hf_happp_stkt_def_data_types = -1;
+static int hf_happp_stkt_updt_update_id = -1;
+static int hf_happp_stkt_updt_expire = -1;
+static int hf_happp_stkt_updt_key_len = -1;
+static int hf_happp_stkt_updt_key_ipv4_value = -1;
+static int hf_happp_stkt_updt_key_str_value = -1;
+static int hf_happp_stkt_updt_key_int_value = -1;
+static int hf_happp_stkt_updt_key_bytes_value = -1;
+static int hf_happp_stkt_updt_data_server_id = -1;
+static int hf_happp_stkt_updt_data_gpt0 = -1;
+static int hf_happp_stkt_updt_data_gpc0 = -1;
+static int hf_happp_stkt_updt_data_gpc0_rate_curr_tick = -1;
+static int hf_happp_stkt_updt_data_gpc0_rate_curr_ctr = -1;
+static int hf_happp_stkt_updt_data_gpc0_rate_prev_ctr = -1;
+static int hf_happp_stkt_updt_data_conn_cnt = -1;
+static int hf_happp_stkt_updt_data_conn_rate_curr_tick = -1;
+static int hf_happp_stkt_updt_data_conn_rate_curr_ctr = -1;
+static int hf_happp_stkt_updt_data_conn_rate_prev_ctr = -1;
+static int hf_happp_stkt_updt_data_conn_cur = -1;
+static int hf_happp_stkt_updt_data_sess_cnt = -1;
+static int hf_happp_stkt_updt_data_sess_rate_curr_tick = -1;
+static int hf_happp_stkt_updt_data_sess_rate_curr_ctr = -1;
+static int hf_happp_stkt_updt_data_sess_rate_prev_ctr = -1;
+static int hf_happp_stkt_updt_data_http_req_cnt = -1;
+static int hf_happp_stkt_updt_data_http_req_rate_curr_tick = -1;
+static int hf_happp_stkt_updt_data_http_req_rate_curr_ctr = -1;
+static int hf_happp_stkt_updt_data_http_req_rate_prev_ctr= -1;
+static int hf_happp_stkt_updt_data_http_err_cnt = -1;
+static int hf_happp_stkt_updt_data_http_err_rate_curr_tick = -1;
+static int hf_happp_stkt_updt_data_http_err_rate_curr_ctr = -1;
+static int hf_happp_stkt_updt_data_http_err_rate_prev_ctr = -1;
+static int hf_happp_stkt_updt_data_bytes_in_cnt = -1;
+static int hf_happp_stkt_updt_data_bytes_in_rate_curr_tick = -1;
+static int hf_happp_stkt_updt_data_bytes_in_rate_curr_ctr = -1;
+static int hf_happp_stkt_updt_data_bytes_in_rate_prev_ctr = -1;
+static int hf_happp_stkt_updt_data_bytes_out_cnt = -1;
+static int hf_happp_stkt_updt_data_bytes_out_rate_curr_tick = -1;
+static int hf_happp_stkt_updt_data_bytes_out_rate_curr_ctr = -1;
+static int hf_happp_stkt_updt_data_bytes_out_rate_prev_ctr = -1;
+static int hf_happp_stkt_updt_ack_table_id = -1;
+static int hf_happp_stkt_updt_ack_update_id = -1;
+
+struct happp_cv_data_t {
+ /* Same thing for the type of the the stick table keys */
+ uint64_t stkt_key_type;
+
+ /* Same thing for the length of the stick table keys.
+ * Note that this is true only for key types different of SMT_T_STR (strings)
+ * and SMT_T_SINT (signed ints).
+ */
+ uint64_t stkt_key_len;
+
+ /* Same thing for the types of the stick table data */
+ uint64_t stkt_data_types;
+ void *data;
+};
+
+struct hf_stkt_data_type {
+ const char *name;
+ unsigned int type;
+ int *hf_ids[3];
+ size_t hf_ids_len;
+};
+
+struct hf_stkt_data_type hf_stkt_data_types[] = {
+ [STKT_DT_SERVER_ID] = {
+ .name = "server_id",
+ .type = STD_T_SINT,
+ .hf_ids = {
+ &hf_happp_stkt_updt_data_server_id,
+ },
+ .hf_ids_len = 1,
+ },
+ [STKT_DT_GPT0] = {
+ .name = "gpt0",
+ .type = STD_T_UINT,
+ .hf_ids = {
+ &hf_happp_stkt_updt_data_gpt0,
+ },
+ .hf_ids_len = 1,
+ },
+ [STKT_DT_GPC0] = {
+ .name = "gpc0",
+ .type = STD_T_UINT,
+ .hf_ids = {
+ &hf_happp_stkt_updt_data_gpc0,
+ },
+ .hf_ids_len = 1,
+ },
+ [STKT_DT_GPC0_RATE] = {
+ .name = "gpc0_rate",
+ .type = STD_T_FRQP,
+ .hf_ids = {
+ &hf_happp_stkt_updt_data_gpc0_rate_curr_tick,
+ &hf_happp_stkt_updt_data_gpc0_rate_curr_ctr,
+ &hf_happp_stkt_updt_data_gpc0_rate_prev_ctr,
+ },
+ .hf_ids_len = 3,
+ },
+ [STKT_DT_CONN_CNT] = {
+ .name = "conn_cnt",
+ .type = STD_T_UINT,
+ .hf_ids = {
+ &hf_happp_stkt_updt_data_conn_cnt,
+ },
+ .hf_ids_len = 1,
+ },
+ [STKT_DT_CONN_RATE] = {
+ .name = "conn_rate",
+ .type = STD_T_FRQP,
+ .hf_ids = {
+ &hf_happp_stkt_updt_data_conn_rate_curr_tick,
+ &hf_happp_stkt_updt_data_conn_rate_curr_ctr,
+ &hf_happp_stkt_updt_data_conn_rate_prev_ctr,
+ },
+ .hf_ids_len = 3,
+ },
+ [STKT_DT_CONN_CUR] = {
+ .name = "conn_cur",
+ .type = STD_T_UINT,
+ .hf_ids = {
+ &hf_happp_stkt_updt_data_conn_cur,
+ },
+ .hf_ids_len = 1,
+ },
+ [STKT_DT_SESS_CNT] = {
+ .name = "sess_cnt",
+ .type = STD_T_UINT,
+ .hf_ids = {
+ &hf_happp_stkt_updt_data_sess_cnt,
+ },
+ .hf_ids_len = 1,
+ },
+ [STKT_DT_SESS_RATE] = {
+ .name = "sess_rate",
+ .type = STD_T_FRQP,
+ .hf_ids = {
+ &hf_happp_stkt_updt_data_sess_rate_curr_tick,
+ &hf_happp_stkt_updt_data_sess_rate_curr_ctr,
+ &hf_happp_stkt_updt_data_sess_rate_prev_ctr,
+ },
+ .hf_ids_len = 3,
+ },
+ [STKT_DT_HTTP_REQ_CNT] = {
+ .name = "http_req_cnt",
+ .type = STD_T_UINT,
+ .hf_ids = {
+ &hf_happp_stkt_updt_data_http_req_cnt,
+ },
+ .hf_ids_len = 1,
+ },
+ [STKT_DT_HTTP_REQ_RATE] = {
+ .name = "http_req_rate",
+ .type = STD_T_FRQP,
+ .hf_ids = {
+ &hf_happp_stkt_updt_data_http_req_rate_curr_tick,
+ &hf_happp_stkt_updt_data_http_req_rate_curr_ctr,
+ &hf_happp_stkt_updt_data_http_req_rate_prev_ctr,
+ },
+ .hf_ids_len = 3,
+ },
+ [STKT_DT_HTTP_ERR_CNT] = {
+ .name = "http_err_cnt",
+ .type = STD_T_UINT,
+ .hf_ids = {
+ &hf_happp_stkt_updt_data_http_err_cnt,
+ },
+ .hf_ids_len = 1,
+ },
+ [STKT_DT_HTTP_ERR_RATE] = {
+ .name = "http_err_rate",
+ .type = STD_T_FRQP,
+ .hf_ids = {
+ &hf_happp_stkt_updt_data_http_err_rate_curr_tick,
+ &hf_happp_stkt_updt_data_http_err_rate_curr_ctr,
+ &hf_happp_stkt_updt_data_http_err_rate_prev_ctr,
+ },
+ .hf_ids_len = 3,
+ },
+ [STKT_DT_BYTES_IN_CNT] = {
+ .name = "bytes_in_cnt",
+ .type = STD_T_ULL,
+ .hf_ids = {
+ &hf_happp_stkt_updt_data_bytes_in_cnt,
+ },
+ .hf_ids_len = 1,
+ },
+ [STKT_DT_BYTES_IN_RATE] = {
+ .name = "bytes_in_rate",
+ .type = STD_T_FRQP,
+ .hf_ids = {
+ &hf_happp_stkt_updt_data_bytes_in_rate_curr_tick,
+ &hf_happp_stkt_updt_data_bytes_in_rate_curr_ctr,
+ &hf_happp_stkt_updt_data_bytes_in_rate_prev_ctr,
+ },
+ .hf_ids_len = 3,
+ },
+ [STKT_DT_BYTES_OUT_CNT] = {
+ .name = "bytes_out_cnt",
+ .type = STD_T_ULL,
+ .hf_ids = {
+ &hf_happp_stkt_updt_data_bytes_out_cnt,
+ },
+ .hf_ids_len = 1,
+ },
+ [STKT_DT_BYTES_OUT_RATE] = {
+ .name = "bytes_out_rate",
+ .type = STD_T_FRQP,
+ .hf_ids = {
+ &hf_happp_stkt_updt_data_bytes_out_rate_curr_tick,
+ &hf_happp_stkt_updt_data_bytes_out_rate_curr_ctr,
+ &hf_happp_stkt_updt_data_bytes_out_rate_prev_ctr,
+ },
+ .hf_ids_len = 3,
+ },
+};
+
+
+/* Initialize the subtree pointers */
+static gint ett_happp = -1;
+static gint ett_happp_msg = -1;
+
+static dissector_handle_t happp_tcp_handle;
+
+static const char *control_msg_type_str_from_byte(guint8 c);
+static const char *error_msg_type_str_from_byte(guint8 c);
+static const char *stkt_msg_type_str_from_byte(guint8 c);
+
+struct class_def_t {
+ const char *class_str;
+ const char *col_info_str;
+ const char *(*msg_type_str_func)(guint8 c);
+ unsigned int count;
+};
+
+static struct class_def_t class_def_tab[] = {
+ [CONTROL_CLASS_INDEX] = {
+ .class_str = "Control Class Message",
+ .col_info_str = "Ctl",
+ .msg_type_str_func = control_msg_type_str_from_byte,
+ },
+ [ERROR_CLASS_INDEX] = {
+ .class_str = "Error Class Message",
+ .col_info_str = "Err",
+ .msg_type_str_func = error_msg_type_str_from_byte,
+ },
+ [STICK_TABLE_CLASS_INDEX] = {
+ .class_str = "Stick Table Class Message",
+ .col_info_str = "Stkt",
+ .msg_type_str_func = stkt_msg_type_str_from_byte,
+ },
+ [RESERVED_CLASS_INDEX] = {
+ .class_str = "Reserved Class Message",
+ .col_info_str = "Res",
+ }
+};
+
+static int control_class_index_from_byte(guint8 c)
+{
+ switch (c) {
+ case PEER_MSG_CLASS_CONTROL:
+ return CONTROL_CLASS_INDEX;
+ case PEER_MSG_CLASS_ERROR:
+ return ERROR_CLASS_INDEX;
+ case PEER_MSG_CLASS_STICKTABLE:
+ return STICK_TABLE_CLASS_INDEX;
+ case PEER_MSG_CLASS_RESERVED:
+ return RESERVED_CLASS_INDEX;
+ default:
+ return -1;
+ };
+}
+
+static const char *class_str_from_byte(guint8 c)
+{
+ int class_idx;
+
+ class_idx = control_class_index_from_byte(c);
+ if (class_idx == -1)
+ return "N/A";
+
+ return class_def_tab[class_idx].class_str;
+}
+
+static const char *control_msg_type_str_from_byte(guint8 c)
+{
+ switch (c) {
+ case PEER_MSG_CTRL_RESYNCREQ:
+ return "resync. request";
+ case PEER_MSG_CTRL_RESYNCFINISHED:
+ return "resync. finished";
+ case PEER_MSG_CTRL_RESYNCPARTIAL:
+ return "resync. partial";
+ case PEER_MSG_CTRL_RESYNCCONFIRM:
+ return "resync. confirm";
+ case PEER_MSG_CTRL_HEARTBEAT:
+ return "heartbeat";
+ default:
+ return "Unknown";
+ }
+}
+
+static const char *stkt_msg_type_str_from_byte(guint8 c)
+{
+ switch (c) {
+ case PEER_MSG_STKT_UPDATE:
+ return "update";
+ case PEER_MSG_STKT_INCUPDATE:
+ return "inc. update";
+ case PEER_MSG_STKT_DEFINE:
+ return "definition";
+ case PEER_MSG_STKT_SWITCH:
+ return "switch";
+ case PEER_MSG_STKT_ACK:
+ return "ack";
+ case PEER_MSG_STKT_UPDATE_TIMED:
+ return "update (with expiration)";
+ case PEER_MSG_STKT_INCUPDATE_TIMED:
+ return "inc. update (with expiration)";
+ default:
+ return "Unknown";
+ }
+}
+
+static const char *error_msg_type_str_from_byte(guint8 c)
+{
+ switch (c) {
+ case PEER_MSG_ERR_PROTOCOL:
+ return "protocol error";
+ case PEER_MSG_ERR_SIZELIMIT:
+ return "limit size error";
+ default:
+ return "Unknown";
+ }
+}
+
+#define MAX_ENC_LEN 10
+static uint64_t intdecode(unsigned char **str, size_t len) {
+ int i = 0;
+ uint64_t ret;
+
+ if (len < 1 || len > MAX_ENC_LEN) {
+ *str = NULL;
+ return 0;
+ }
+
+ ret = *(*str)++;
+ len--;
+ if ((ret & 0xf0) != 0xf0 || !len)
+ return ret;
+
+ do {
+ /* As shifting value may be greater than 8 (size of **str in bits),
+ * uint64_t cast is required.
+ */
+ ret += (uint64_t)**str << (4 + 7 * i++);
+ } while (len-- && (*(*str)++ & 0x80) == 0x80);
+
+ return ret;
+}
+
+static int dissect_happp_handshake_pdu(tvbuff_t *tvb, packet_info *pinfo,
+ proto_tree *happp_tree)
+{
+ int line_len, token_len;
+ gint offset = 0, next_offset;
+ const guchar *line, *line_end, *next_token;
+ size_t protocol_strlen;
+
+ line_len = tvb_find_line_end(tvb, offset, -1, &next_offset, TRUE);
+ /* XXX TO DO */
+ if (line_len == -1)
+ return -1;
+
+ protocol_strlen = strlen(HAPPP_PROTOCOL);
+
+ line = tvb_get_ptr(tvb, offset, line_len);
+ line_end = line + (next_offset - offset);
+ /* The line must contain at least HAPPP_PROTOCOL string followed by a space,
+ * then version string (at least one character) and a '\n' character.
+ */
+ if (line_len >= (int)protocol_strlen + 3 &&
+ !tvb_strncaseeql(tvb, 0, HAPPP_PROTOCOL, protocol_strlen)) {
+ /* This is an Hello message */
+ col_set_str(pinfo->cinfo, COL_INFO, "Hello message");
+
+ token_len = get_token_len(line + protocol_strlen + 1, line_end, &next_token);
+ proto_tree_add_item(happp_tree, hf_happp_version, tvb,
+ offset + protocol_strlen + 1, token_len,
+ ENC_ASCII | ENC_NA);
+
+ offset = next_offset;
+ line_len = tvb_find_line_end(tvb, offset, -1, &next_offset, TRUE);
+ /* XXX TO DO */
+ if (line_len == -1)
+ return -1;
+
+ line = tvb_get_ptr(tvb, offset, line_len);
+ line_end = line + (next_offset - offset);
+ /* Get next token: remotepeerid */
+ token_len = get_token_len(line, line_end, &next_token);
+ if (!token_len)
+ return -1;
+
+ proto_tree_add_item(happp_tree, hf_happp_remotepeerid, tvb, offset,
+ token_len, ENC_ASCII | ENC_NA);
+
+ /* Retrieve next line */
+ offset = next_offset;
+ line_len = tvb_find_line_end(tvb, offset, -1, &next_offset, TRUE);
+ /* XXX TO DO */
+ if (line_len == -1)
+ return -1;
+
+ line = tvb_get_ptr(tvb, offset, line_len);
+ line_end = line + (next_offset - offset);
+ /* Get next token: localpeerid */
+ token_len = get_token_len(line, line_end, &next_token);
+ if (!token_len)
+ return -1;
+
+ proto_tree_add_item(happp_tree, hf_happp_localpeerid, tvb, offset,
+ token_len, ENC_ASCII | ENC_NA);
+ offset += next_token - line;
+ line = next_token;
+
+ /* Get next token: processpid */
+ token_len = get_token_len(line, line_end, &next_token);
+ if (!token_len)
+ return -1;
+
+ proto_tree_add_item(happp_tree, hf_happp_processpid, tvb, offset,
+ token_len, ENC_ASCII | ENC_NA);
+ offset += next_token - line;
+ line = next_token;
+
+ /* Get next token: relativepid */
+ token_len = get_token_len(line, line_end, &next_token);
+ if (!token_len)
+ return -1;
+
+ proto_tree_add_item(happp_tree, hf_happp_relativepid, tvb, offset,
+ token_len, ENC_ASCII | ENC_NA);
+ offset += next_token - line;
+ line = next_token;
+
+ }
+ else if (line_len == 3) {
+ col_set_str(pinfo->cinfo, COL_INFO, "Status message");
+ token_len = get_token_len(line, line_end, &next_token);
+ if (!token_len)
+ return -1;
+
+ proto_tree_add_item(happp_tree, hf_happp_status, tvb, offset,
+ token_len, ENC_ASCII | ENC_NA);
+ }
+
+ return tvb_captured_length(tvb);
+}
+
+/* Reset to zero all statistics counters of class_def_array */
+static void init_class_def_tab(struct class_def_t *class_def_array, size_t size)
+{
+ size_t i;
+
+ for (i = 0; i < size; i++)
+ class_def_array[i].count = 0;
+}
+
+/* Add statistics counting information about HAPPP message classes to
+ * info column (numbers of messages found in an HAPPP PDU by class).
+ */
+static inline void col_info_append_class(packet_info *pinfo, int class_index,
+ int *first_class)
+{
+ if (!class_def_tab[class_index].count)
+ return;
+
+ col_append_fstr(pinfo->cinfo, COL_INFO, "%s%s=%u",
+ *first_class ? "" : " ",
+ class_def_tab[class_index].col_info_str,
+ class_def_tab[class_index].count);
+ class_def_tab[class_index].count = 0;
+ *first_class = 0;
+}
+
+
+static int intdecode_from_tvbuff(tvbuff_t *tvb, uint64_t *dec_val,
+ guint *offset, guint total)
+{
+ unsigned char *p, enc_buf[MAX_ENC_LEN];
+ size_t max_enc_buf_len, left;
+
+ left = total - *offset;
+ max_enc_buf_len = left < sizeof enc_buf ? left : sizeof enc_buf;
+ if (!tvb_memcpy(tvb, enc_buf, *offset, max_enc_buf_len))
+ return -1;
+
+ p = enc_buf;
+ *dec_val = intdecode(&p, max_enc_buf_len);
+ if (!p)
+ return -1;
+
+ *offset += p - enc_buf;
+
+ return 0;
+}
+
+static int add_enc_field_to_happp_tree(int field_id, proto_tree *tree, tvbuff_t *tvb,
+ guint *offset, guint total, uint64_t *val)
+{
+ uint64_t dec_val;
+ size_t dec_val_len;
+ guint saved_offset;
+
+ saved_offset = *offset;
+ if (intdecode_from_tvbuff(tvb, &dec_val, offset, total) < 0)
+ return -1;
+
+ dec_val_len = *offset - saved_offset;
+ proto_tree_add_uint64_format_value(tree, field_id, tvb, saved_offset,
+ dec_val_len, dec_val, "%" PRIu64, dec_val);
+
+ if (val)
+ *val = dec_val;
+
+ return 0;
+}
+
+static int add_int_field_to_happp_tree(int field_id,
+ tvbuff_t *tvb, proto_tree *tree,
+ guint *offset, guint total _U_)
+{
+ uint32_t val;
+
+ if (!tvb_memcpy(tvb, &val, *offset, sizeof val))
+ return -1;
+
+ val = ntohl(val);
+ proto_tree_add_int_format_value(tree, field_id, tvb, *offset,
+ sizeof val, val, "%" PRId32, val);
+ *offset += sizeof val;
+
+ return 0;
+}
+
+static void dissect_happp_stkt_define_msg(tvbuff_t *tvb, packet_info *pinfo _U_,
+ proto_tree *tree, guint offset, guint total)
+{
+ uint64_t dec_val;
+ uint64_t stkt_key_type;
+ uint64_t stkt_key_len;
+ uint64_t stkt_data_types;
+ struct happp_cv_data_t *happp_cv_data;
+ conversation_t *cv;
+
+ if (add_enc_field_to_happp_tree(hf_happp_stkt_def_id, tree,
+ tvb, &offset, total, NULL) < 0 ||
+ add_enc_field_to_happp_tree(hf_happp_stkt_def_name_len, tree,
+ tvb, &offset, total, &dec_val) < 0)
+ return;
+
+ /* Add the stick table name to HAPPP proto tree */
+ proto_tree_add_item(tree, hf_happp_stkt_def_name_value, tvb, offset, dec_val,
+ ENC_ASCII | ENC_NA);
+ offset += dec_val;
+
+ if (add_enc_field_to_happp_tree(hf_happp_stkt_def_key_type, tree,
+ tvb, &offset, total, &stkt_key_type) < 0 ||
+ add_enc_field_to_happp_tree(hf_happp_stkt_def_key_len, tree,
+ tvb, &offset, total, &stkt_key_len) < 0 ||
+ add_enc_field_to_happp_tree(hf_happp_stkt_def_data_types, tree,
+ tvb, &offset, total, &stkt_data_types) < 0)
+ return;
+
+ cv = find_conversation(pinfo->num, &pinfo->src, &pinfo->dst,
+ pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
+ if (!cv)
+ return;
+
+ /*
+ * According to the documentation, it is not our responsibility
+ * to free this allocated memory.
+ */
+ happp_cv_data = (struct happp_cv_data_t *)wmem_alloc(wmem_file_scope(),
+ sizeof *happp_cv_data);
+ if (!happp_cv_data)
+ return;
+
+ happp_cv_data->stkt_key_type = stkt_key_type;
+ happp_cv_data->stkt_key_len = stkt_key_len;
+ happp_cv_data->stkt_data_types = stkt_data_types;
+
+ conversation_add_proto_data(cv, proto_happp, happp_cv_data);
+}
+
+static void dissect_happp_stkt_update_msg(tvbuff_t *tvb, packet_info *pinfo _U_,
+ proto_tree *tree, guint offset, guint total,
+ unsigned char msg_type_byte)
+{
+ unsigned int data_type;
+ uint64_t *stkt_key_type;
+ uint64_t *stkt_key_len;
+ struct happp_cv_data_t *happp_cv_data;
+ int has_update_id, has_exp;
+ conversation_t *cv;
+
+ cv = find_conversation(pinfo->num, &pinfo->src, &pinfo->dst,
+ pinfo->ptype, pinfo->srcport, pinfo->destport, 0);
+ if (!cv)
+ return;
+
+ happp_cv_data = (struct happp_cv_data_t *)conversation_get_proto_data(cv, proto_happp);
+ if (!happp_cv_data)
+ return;
+
+ has_update_id = msg_type_byte == PEER_MSG_STKT_UPDATE ||
+ msg_type_byte == PEER_MSG_STKT_UPDATE_TIMED;
+ has_exp = msg_type_byte == PEER_MSG_STKT_UPDATE_TIMED ||
+ msg_type_byte == PEER_MSG_STKT_INCUPDATE_TIMED;
+ /* Add the stick table update ID to HAPPP tree */
+ if (has_update_id &&
+ add_int_field_to_happp_tree(hf_happp_stkt_updt_update_id, tvb, tree,
+ &offset, total) < 0)
+ return;
+
+ if (has_exp &&
+ add_int_field_to_happp_tree(hf_happp_stkt_updt_expire, tvb, tree,
+ &offset, total) < 0)
+ return;
+
+
+ stkt_key_type = &happp_cv_data->stkt_key_type;
+ stkt_key_len = &happp_cv_data->stkt_key_len;
+
+ switch(*stkt_key_type) {
+ case SMP_T_STR:
+ if (add_enc_field_to_happp_tree(hf_happp_stkt_updt_key_len, tree, tvb,
+ &offset, total, stkt_key_len) < 0)
+ return;
+
+ proto_tree_add_item(tree, hf_happp_stkt_updt_key_str_value, tvb,
+ offset, *stkt_key_len, ENC_ASCII | ENC_NA);
+ offset += *stkt_key_len;
+ break;
+ case SMP_T_SINT:
+ if (add_int_field_to_happp_tree(hf_happp_stkt_updt_key_int_value, tvb, tree,
+ &offset, total) < 0)
+ return;
+
+ break;
+ case SMP_T_IPV4:
+ proto_tree_add_ipv4(tree, hf_happp_stkt_updt_key_ipv4_value,
+ tvb, offset, 4, tvb_get_ipv4(tvb, offset));
+ offset += 4;
+ break;
+ default:
+ proto_tree_add_item(tree, hf_happp_stkt_updt_key_bytes_value,
+ tvb, offset, *stkt_key_len, ENC_NA);
+ offset += *stkt_key_len;
+ break;
+ }
+
+ /* Data dissection */
+ for (data_type = 0;
+ data_type < sizeof hf_stkt_data_types / sizeof *hf_stkt_data_types;
+ data_type++) {
+ struct hf_stkt_data_type *hf_stkt_dtype;
+ size_t i;
+
+ if (!(happp_cv_data->stkt_data_types & (1 << data_type)))
+ continue;
+
+ hf_stkt_dtype = &hf_stkt_data_types[data_type];
+
+ for (i = 0; i < hf_stkt_dtype->hf_ids_len; i++)
+ if (add_enc_field_to_happp_tree(*hf_stkt_dtype->hf_ids[i], tree, tvb,
+ &offset, total, NULL) < 0)
+ return;
+ }
+}
+
+static void dissect_happp_stkt_ack_msg(tvbuff_t *tvb, packet_info *pinfo _U_,
+ proto_tree *tree, guint offset, guint total)
+{
+ if (add_enc_field_to_happp_tree(hf_happp_stkt_updt_ack_table_id, tree, tvb,
+ &offset, total, NULL) < 0)
+ return;
+
+ if (add_int_field_to_happp_tree(hf_happp_stkt_updt_ack_update_id, tvb, tree,
+ &offset, total) < 0)
+ return;
+}
+
+static void dissect_happp_stk_msg(tvbuff_t *tvb, packet_info *pinfo _U_,
+ proto_tree *tree, guint8 msg_type_byte,
+ guint offset, guint total)
+{
+ switch (msg_type_byte) {
+ case PEER_MSG_STKT_DEFINE:
+ dissect_happp_stkt_define_msg(tvb, pinfo, tree, offset, total);
+ break;
+ case PEER_MSG_STKT_UPDATE:
+ case PEER_MSG_STKT_INCUPDATE:
+ case PEER_MSG_STKT_UPDATE_TIMED:
+ case PEER_MSG_STKT_INCUPDATE_TIMED:
+ dissect_happp_stkt_update_msg(tvb, pinfo, tree, offset, total, msg_type_byte);
+ break;
+ case PEER_MSG_STKT_ACK:
+ dissect_happp_stkt_ack_msg(tvb, pinfo, tree, offset, total);
+ break;
+ };
+
+}
+
+static void
+dissect_happp_msg(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
+ guint8 msg_class_byte, guint8 msg_type_byte,
+ guint *offset, guint total)
+{
+ unsigned char *p, enc_buf[MAX_ENC_LEN];
+ uint64_t dec_msg_len;
+ size_t max_enc_buf_len, left, dec_val_len;
+
+ left = total - *offset;
+ max_enc_buf_len = left < sizeof enc_buf ? left : sizeof enc_buf;
+ if (!tvb_memcpy(tvb, enc_buf, *offset, max_enc_buf_len))
+ return;
+
+ p = enc_buf;
+ dec_msg_len = intdecode(&p, max_enc_buf_len);
+ if (!p)
+ return;
+
+ dec_val_len = p - enc_buf;
+ proto_tree_add_uint64_format_value(tree, hf_happp_msg_len,
+ tvb, *offset, dec_val_len, dec_msg_len,
+ "%" PRIu64, dec_msg_len);
+ *offset += dec_val_len;
+
+ switch (msg_class_byte) {
+ case PEER_MSG_CLASS_STICKTABLE:
+ dissect_happp_stk_msg(tvb, pinfo, tree, msg_type_byte, *offset, total);
+ break;
+ }
+
+ *offset += dec_msg_len;
+}
+
+/* Code to actually dissect the packets */
+static int
+dissect_happp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
+{
+ /* Set up structures needed to add the protocol subtree and manage it */
+ proto_item *item;
+ proto_tree *happp_tree;
+ /* Other misc. local variables. */
+ guint total, offset;
+ int first_message, first_class, curr_class, prev_class;
+ guint8 first_byte;
+ size_t sizeof_class_def_tab;
+
+ offset = 0;
+ first_message = first_class = 1;
+ total = tvb_reported_length(tvb);
+
+ /* create display subtree for the protocol */
+ item = proto_tree_add_item(tree, proto_happp, tvb, offset, -1, ENC_NA);
+ happp_tree = proto_item_add_subtree(item, ett_happp);
+
+ /* Set the protocol column value */
+ col_set_str(pinfo->cinfo, COL_PROTOCOL, "happp");
+
+ first_byte = (gchar)tvb_get_guint8(tvb, offset);
+ if (first_byte != PEER_MSG_CLASS_CONTROL &&
+ first_byte != PEER_MSG_CLASS_ERROR &&
+ first_byte != PEER_MSG_CLASS_STICKTABLE &&
+ first_byte != PEER_MSG_CLASS_RESERVED)
+ return dissect_happp_handshake_pdu(tvb, pinfo, happp_tree);
+
+ /* Reset class_def_tab message class counters */
+ sizeof_class_def_tab = sizeof class_def_tab / sizeof *class_def_tab;
+ init_class_def_tab(class_def_tab, sizeof_class_def_tab);
+
+ prev_class = curr_class = -1;
+ col_set_str(pinfo->cinfo, COL_INFO, "[");
+ while (offset < total) {
+ guint8 msg_class_byte, msg_type_byte;
+ const char *(*msg_type_str_func)(guint8 c);
+ struct class_def_t *class_def;
+
+ if (first_message) {
+ msg_class_byte = first_byte;
+ }
+ else {
+ msg_class_byte = tvb_get_guint8(tvb, offset);
+ }
+ curr_class = control_class_index_from_byte(msg_class_byte);
+ if (curr_class == -1)
+ return -1;
+
+ if (first_message) {
+ prev_class = curr_class;
+ first_message = 0;
+ }
+
+ class_def = &class_def_tab[curr_class];
+ class_def->count++;
+ msg_type_str_func = class_def->msg_type_str_func;
+
+ /* Insert a line separator */
+ proto_tree_add_item(happp_tree, hf_happp_fake, tvb,
+ offset, 0,
+ ENC_ASCII | ENC_NA);
+ proto_tree_add_uint_format_value(happp_tree, hf_happp_msg_class,
+ tvb, offset++, 1, msg_class_byte,
+ "%u (%s)", msg_class_byte,
+ class_str_from_byte(msg_class_byte));
+ msg_type_byte = tvb_get_guint8(tvb, offset);
+
+ /* First byte: message class */
+ switch (msg_class_byte) {
+ case PEER_MSG_CLASS_CONTROL:
+ case PEER_MSG_CLASS_ERROR:
+ case PEER_MSG_CLASS_STICKTABLE:
+ /* Second byte: message type in the class */
+ proto_tree_add_uint_format_value(happp_tree, hf_happp_msg_type,
+ tvb, offset++, 1, msg_type_byte,
+ "%u (%s)", msg_type_byte,
+ msg_type_str_func(msg_type_byte));
+ break;
+ case PEER_MSG_CLASS_RESERVED:
+ col_append_str(pinfo->cinfo, COL_INFO, "NON IMPLEMENTED");
+ break;
+ }
+ if (msg_class_byte >= PEER_MSG_CLASS_STICKTABLE)
+ dissect_happp_msg(tvb, pinfo, happp_tree,
+ msg_class_byte, msg_type_byte, &offset, total);
+
+ /* Sequentially add counting information to info column about
+ * number of messages found by class in an HAPPP PDU.
+ * For instance if an HAPPP PDU contains this sequence of messages:
+ * 1 Control message - 2 Stick Table messages - 3 Control messages
+ * column information displays: [Ctl=1 Stkt=2 Ctl=3].
+ */
+ if (curr_class != prev_class) {
+ col_info_append_class(pinfo, prev_class, &first_class);
+ col_info_append_class(pinfo, curr_class, &first_class);
+ prev_class = curr_class;
+ }
+ else if (offset >= total) {
+ /* Last message */
+ col_info_append_class(pinfo, curr_class, &first_class);
+ }
+ }
+ col_append_str(pinfo->cinfo, COL_INFO, "]");
+
+ return tvb_captured_length(tvb);
+}
+
+static guint
+get_happp_msg_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, void *data _U_)
+{
+ guint ret, len, left;
+ gint next_offset, line_len;
+ guint8 first_byte;
+ uint64_t dec_len;
+ int saved_offset;
+
+ /* 0 means there is not enough data to get length. */
+ ret = 0;
+
+ len = tvb_reported_length(tvb);
+ left = len - offset;
+ if (left < HAPPP_MSG_MIN_LEN)
+ goto out;
+
+ saved_offset = offset;
+ first_byte = (gchar)tvb_get_guint8(tvb, offset);
+ if (first_byte == PEER_MSG_CLASS_CONTROL ||
+ first_byte == PEER_MSG_CLASS_ERROR ||
+ first_byte == PEER_MSG_CLASS_RESERVED) {
+ ret = HAPPP_MSG_MIN_LEN;
+ } else if (first_byte == PEER_MSG_CLASS_STICKTABLE) {
+ int soff;
+
+ left -= HAPPP_MSG_MIN_LEN;
+ offset += HAPPP_MSG_MIN_LEN;
+ soff = offset;
+ if (intdecode_from_tvbuff(tvb, &dec_len, &offset, len) < 0)
+ goto out;
+
+ left -= offset - soff;
+ if (left < dec_len)
+ goto out;
+
+ ret = dec_len + offset - saved_offset;
+ } else {
+ /* hello message: add line lengths to compute this message length. */
+ for (;;) {
+ line_len = tvb_find_line_end(tvb, offset, -1, &next_offset, TRUE);
+ if (line_len == -1)
+ break;
+
+ ret += line_len + 1;
+ offset += line_len + 1;
+ }
+ }
+
+ out:
+ return ret;
+ }
+
+static int
+dissect_happp_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
+{
+ tcp_dissect_pdus(tvb, pinfo, tree, TRUE,
+ HAPPP_MSG_MIN_LEN, get_happp_msg_len, dissect_happp_pdu, data);
+
+ return tvb_captured_length(tvb);
+}
+
+/* Register the protocol with Wireshark.
+ *
+ * This format is require because a script is used to build the C function that
+ * calls all the protocol registration.
+ */
+void
+proto_register_happp(void)
+{
+ /* Setup list of header fields See Section 1.5 of README.dissector for
+ * details. */
+ static hf_register_info hf[] = {
+ {
+ /* This one is used as separator between HAPPP messages */
+ &hf_happp_fake,
+ {
+ ":-----------------------------------------------", "happp.fake",
+ FT_STRING, STR_ASCII, NULL, 0, "FAKE", HFILL
+ }
+ },
+ {
+ &hf_happp_version,
+ {
+ "version", "happp.version",
+ FT_STRING, STR_ASCII, NULL, 0, "version", HFILL
+ }
+ },
+ {
+ &hf_happp_remotepeerid,
+ {
+ "remotepeerid", "happp.remotepeerid",
+ FT_STRING, STR_ASCII, NULL, 0, "remote peer id", HFILL
+ }
+ },
+ {
+ &hf_happp_localpeerid,
+ {
+ "localpeerid", "happp.localpeerid",
+ FT_STRING, STR_ASCII, NULL, 0, "local peer id", HFILL
+ }
+ },
+ {
+ &hf_happp_processpid,
+ {
+ "processpid", "happp.processpid",
+ FT_STRING, STR_ASCII, NULL, 0, "process pid", HFILL
+ }
+ },
+ {
+ &hf_happp_relativepid,
+ {
+ "relativepid", "happp.relativepid",
+ FT_STRING, STR_ASCII, NULL, 0, "relative pid", HFILL
+ }
+ },
+ {
+ &hf_happp_status,
+ {
+ "status", "happp.status",
+ FT_STRING, STR_ASCII, NULL, 0, "status message", HFILL
+ }
+ },
+ {
+ &hf_happp_msg,
+ {
+ "message", "happp.msg",
+ FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_msg_class,
+ {
+ "message class", "happp.msg.class",
+ FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_msg_type,
+ {
+ "message type", "happp.msg.type",
+ FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_msg_len,
+ {
+ "message length", "happp.msg.len",
+ FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_def_id,
+ {
+ " ID", "happp.msg.stkt.def.id",
+ FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_def_name_len,
+ {
+ " name length", "happp.msg.stkt.def.name.length",
+ FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_def_name_value,
+ {
+ " name", "happp.msg.stkt.def.name.value",
+ FT_STRING, STR_ASCII, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_def_key_type,
+ {
+ " key type", "happp.msg.stkt.def.key.type",
+ FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_def_key_len,
+ {
+ " key length", "happp.msg.stkt.def.key.len",
+ FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_def_data_types,
+ {
+ " data types", "happp.msg.stkt.def.data_types",
+ FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_updt_update_id,
+ {
+ " update ID", "happp.msg.stkt.updt.update_id",
+ FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_updt_expire,
+ {
+ " expiration", "happp.msg.stkt.updt.expiration",
+ FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_updt_key_len,
+ {
+ " key length", "happp.msg.stkt.updt.key.len",
+ FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_updt_key_str_value,
+ {
+ " key value", "happp.msg.stkt.updt.key.str.value",
+ FT_STRING, STR_ASCII, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_updt_key_int_value,
+ {
+ " key value", "happp.msg.stkt.updt.key.int.value",
+ FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_updt_key_ipv4_value,
+ {
+ " key IPv4 value", "happp.msg.stkt.updt.key.ipv4.value",
+ FT_IPv4, BASE_NONE, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_updt_key_bytes_value,
+ {
+ " key value", "happp.msg.stkt.updt.key.bytes.value",
+ FT_BYTES, 0, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_updt_data_server_id,
+ {
+ " server_id", "happp.msg.stkt.updt.data.server_id",
+ FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_updt_data_gpt0,
+ {
+ " gpt0", "happp.msg.stkt.updt.data.gpt0",
+ FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_updt_data_gpc0,
+ {
+ " gpc0", "happp.msg.stkt.updt.data.gpc0",
+ FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_updt_data_gpc0_rate_curr_tick,
+ {
+ " gpc0 curr. tick",
+ "happp.msg.stkt.updt.data.gpc0_rate.curr_tick",
+ FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_updt_data_gpc0_rate_curr_ctr,
+ {
+ " gpc0 curr. ctr.",
+ "happp.msg.stkt.updt.data.gpc0_rate.curr_ctr",
+ FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_updt_data_gpc0_rate_prev_ctr,
+ {
+ " gpc0 prev. ctr.",
+ "happp.msg.stkt.updt.data.gpc0_rate.prev_ctr",
+ FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_updt_data_conn_cnt,
+ {
+ " conn_cnt",
+ "happp.msg.stkt.updt.data.conn_cnt",
+ FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_updt_data_conn_rate_curr_tick,
+ {
+ " conn_rate curr. tick",
+ "happp.msg.stkt.updt.data.conn_rate.curr_tick",
+ FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_updt_data_conn_rate_curr_ctr,
+ {
+ " conn_rate curr. ctr.",
+ "happp.msg.stkt.updt.data.conn_rate.curr_ctr",
+ FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_updt_data_conn_rate_prev_ctr,
+ {
+ " conn_rate prev. ctr.",
+ "happp.msg.stkt.updt.data.conn_rate.prev_ctr",
+ FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_updt_data_conn_cur,
+ {
+ " conn_curr curr. tick",
+ "happp.msg.stkt.updt.data.conn_cur",
+ FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_updt_data_sess_cnt,
+ {
+ " sess_cnt", "happp.msg.stkt.updt.data.sess_cnt",
+ FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_updt_data_sess_rate_curr_tick,
+ {
+ " sess_rate curr. tick",
+ "happp.msg.stkt.updt.data.sess_rate.curr_tick",
+ FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_updt_data_sess_rate_curr_ctr,
+ {
+ " sess_rate curr. ctr.",
+ "happp.msg.stkt.updt.data.sess_rate.curr_ctr",
+ FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_updt_data_sess_rate_prev_ctr,
+ {
+ " sess_rate prev. ctr.",
+ "happp.msg.stkt.updt.data.sess_rate.prev_ctr",
+ FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_updt_data_http_req_cnt,
+ {
+ " http_req_cnt",
+ "happp.msg.stkt.updt.data.http_req_cnt",
+ FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_updt_data_http_req_rate_curr_tick,
+ {
+ " http_req_rate curr. tick",
+ "happp.msg.stkt.updt.data.http_req_rate.curr_tick",
+ FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_updt_data_http_req_rate_curr_ctr,
+ {
+ " http_req_rate curr. ctr.",
+ "happp.msg.stkt.updt.data.http_req_rate.curr_ctr",
+ FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_updt_data_http_req_rate_prev_ctr,
+ {
+ " http_req_rate prev. ctr.",
+ "happp.msg.stkt.updt.data.http_req_rate.prev_ctr",
+ FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_updt_data_http_err_cnt,
+ {
+ " http_err_cnt",
+ "happp.msg.stkt.updt.data.http_err_cnt",
+ FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_updt_data_http_err_rate_curr_tick,
+ {
+ " http_err_rate curr. tick",
+ "happp.msg.stkt.updt.data.http_err_rate.curr_tick",
+ FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_updt_data_http_err_rate_curr_ctr,
+ {
+ " http_err_rate curr. ctr.",
+ "happp.msg.stkt.updt.data.http_err_rate.curr_ctr",
+ FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_updt_data_http_err_rate_prev_ctr,
+ {
+ " http_err_rate prev. ctr.",
+ "happp.msg.stkt.updt.data.http_err_rate.prev_ctr",
+ FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_updt_data_bytes_in_cnt,
+ {
+ " bytes_in_cnt",
+ "happp.msg.stkt.updt.data.bytes_in_cnt",
+ FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_updt_data_bytes_in_rate_curr_tick,
+ {
+ " bytes_in_rate curr. tick",
+ "happp.msg.stkt.updt.data.bytes_in_rate.curr_tick",
+ FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_updt_data_bytes_in_rate_curr_ctr,
+ {
+ " bytes_in_rate curr. ctr.",
+ "happp.msg.stkt.updt.data.bytes_in_rate.curr_ctr",
+ FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_updt_data_bytes_in_rate_prev_ctr,
+ {
+ " bytes_in_rate prev. ctr.",
+ "happp.msg.stkt.updt.data.bytes_in_rate.prev_ctr",
+ FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_updt_data_bytes_out_cnt,
+ {
+ " bytes_out_cnt",
+ "happp.msg.stkt.updt.data.bytes_out_cnt",
+ FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_updt_data_bytes_out_rate_curr_tick,
+ {
+ " bytes_out_rate curr. tick",
+ "happp.msg.stkt.updt.data.bytes_out_rate.curr_tick",
+ FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_updt_data_bytes_out_rate_curr_ctr,
+ {
+ " bytes_out_rate curr. ctr.",
+ "happp.msg.stkt.updt.data.bytes_out_rate.curr_ctr",
+ FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_updt_data_bytes_out_rate_prev_ctr,
+ {
+ " bytes_out_rate prev. ctr.",
+ "happp.msg.stkt.updt.data.bytes_out_rate.prev_ctr",
+ FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_updt_ack_table_id,
+ {
+ " remote table Id",
+ "happp.msg.stkt.updt.ack.table_id",
+ FT_UINT64, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ {
+ &hf_happp_stkt_updt_ack_update_id,
+ {
+ " update Id", "happp.msg.stkt.updt.ack.update_id",
+ FT_INT32, BASE_DEC, NULL, 0, NULL, HFILL
+ }
+ },
+ };
+
+ /* Setup protocol subtree array */
+ static gint *ett[] = {
+ &ett_happp,
+ &ett_happp_msg
+ };
+
+ /* Register the protocol name and description */
+ proto_happp = proto_register_protocol("HAProxy Peers Protocol", "HAPPP", "happp");
+
+ /* Required function calls to register the header fields and subtrees */
+ proto_register_field_array(proto_happp, hf, array_length(hf));
+ proto_register_subtree_array(ett, array_length(ett));
+}
+
+static gboolean
+dissect_happp_heur_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
+{
+ size_t proto_strlen;
+ conversation_t *conversation;
+
+ proto_strlen = strlen(HAPPP_PROTOCOL);
+
+ if (tvb_captured_length(tvb) < 2)
+ return FALSE;
+
+ if (tvb_get_guint8(tvb, 0) == PEER_MSG_CLASS_STICKTABLE &&
+ tvb_get_guint8(tvb, 1) >= PEER_MSG_STKT_UPDATE &&
+ tvb_get_guint8(tvb, 1) <= PEER_MSG_STKT_ACK)
+ goto found;
+
+ if (tvb_captured_length(tvb) < proto_strlen + 1)
+ return FALSE;
+
+ /* Check that we received a line beginning with HAPPP_PROTOCOL
+ * followed by a space character.
+ */
+ if (tvb_strneql(tvb, 0, HAPPP_PROTOCOL, proto_strlen) ||
+ tvb_get_guint8(tvb, proto_strlen) != ' ')
+ return FALSE;
+
+ found:
+ conversation = find_or_create_conversation(pinfo);
+ if (!conversation)
+ return FALSE;
+
+ conversation_set_dissector(conversation, happp_tcp_handle);
+ dissect_happp_tcp(tvb, pinfo, tree, data);
+
+ return TRUE;
+}
+
+/* Simpler form of proto_reg_handoff_happp which can be used if there are
+ * no prefs-dependent registration function calls. */
+void
+proto_reg_handoff_happp(void)
+{
+ /* Use create_dissector_handle() to indicate that dissect_happp_tcp()
+ * returns the number of bytes it dissected (or 0 if it thinks the packet
+ * does not belong to HAProxy Peers Protocol).
+ */
+ happp_tcp_handle = create_dissector_handle(dissect_happp_tcp, proto_happp);
+ heur_dissector_add("tcp", dissect_happp_heur_tcp, "HAPPP over TCP", "happp_tcp",
+ proto_happp, HEURISTIC_ENABLE);
+}
+
+
+void
+plugin_register(void)
+{
+ static proto_plugin plug;
+
+ plug.register_protoinfo = proto_register_happp;
+ plug.register_handoff = proto_reg_handoff_happp;
+ proto_register_plugin(&plug);
+}
diff --git a/admin/wireshark-dissectors/peers/wireshark.happp.dissector.patch b/admin/wireshark-dissectors/peers/wireshark.happp.dissector.patch
new file mode 100644
index 0000000..c06134d
--- /dev/null
+++ b/admin/wireshark-dissectors/peers/wireshark.happp.dissector.patch
@@ -0,0 +1,24 @@
+diff --git a/epan/dissectors/CMakeLists.txt b/epan/dissectors/CMakeLists.txt
+index 38e2149..5f8cd49 100644
+--- a/epan/dissectors/CMakeLists.txt
++++ b/epan/dissectors/CMakeLists.txt
+@@ -665,6 +665,7 @@ set(DISSECTOR_SRC
+ packet-h263.c
+ packet-h263p.c
+ packet-h264.c
++ packet-happp.c
+ packet-hartip.c
+ packet-hazelcast.c
+ packet-hci_h1.c
+diff --git a/epan/dissectors/Makefile.am b/epan/dissectors/Makefile.am
+index 70edc66..bc46235 100644
+--- a/epan/dissectors/Makefile.am
++++ b/epan/dissectors/Makefile.am
+@@ -694,6 +694,7 @@ DISSECTOR_SRC = \
+ packet-h263.c \
+ packet-h263p.c \
+ packet-h264.c \
++ packet-happp.c \
+ packet-hartip.c \
+ packet-hazelcast.c \
+ packet-hci_h1.c \