[MAJOR] proto_uxst rework -> SNMP support
Currently there is a ~16KB limit for a data size passed via unix socket.
It is caused by a trivial bug ttat is going to fixed soon, however
in most cases there is no need to dump a full stats.
This patch makes possible to select a scope of dumped data by extending
current "show stat" to "show stat [<iid> <type> <sid>]":
- iid is a proxy id, -1 to dump all proxies
- type selects type of dumpable objects: 1 for frontend, 2 for backend, 4 for
server, -1 for all types. Values can be ORed, for example:
1+2=3 -> frontend+backend.
1+2+4=7 -> frontend+backend+server.
- sid is a service id, -1 to dump everything from the selected proxy.
To do this I implemented a new session flag (SN_STAT_BOUND), added three
variables in data_ctx.stats (iid, type, sid), modified dumpstats.c and
completely revorked the process_uxst_stats: now it waits for a "\n"
terminated string, splits args and uses them. BTW: It should be quite easy
to add new commands, for example to enable/disable servers, the only problem
I can see is a not very lucky config name (*stats* socket). :|
During the work I also fixed two bug:
- s->flags were not initialized for proto_uxst
- missing comma if throttling not enabled (caused by a stupid change in
"Implement persistent id for proxies and servers")
Other changes:
- No more magic type valuse, use STATS_TYPE_FE/STATS_TYPE_BE/STATS_TYPE_SV
- Don't memset full s->data_ctx (it was clearing s->data_ctx.stats.{iid/type/sid},
instead initialize stats.sv & stats.sv_st (stats.px and stats.px_st were already
initialized)
With all that changes it was extremely easy to write a short perl plugin
for a perl-enabled net-snmp (also included in this patch).
29385 is my PEN (Private Enterprise Number) and I'm willing to donate
the SNMPv2-SMI::enterprises.29385.106.* OIDs for HAProxy if there
is nothing assigned already.
diff --git a/contrib/netsnmp-perl/haproxy_frontend.xml b/contrib/netsnmp-perl/haproxy_frontend.xml
new file mode 100644
index 0000000..09789c8
--- /dev/null
+++ b/contrib/netsnmp-perl/haproxy_frontend.xml
@@ -0,0 +1,62 @@
+<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>
+ <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>
+ </fields>
+</interface>