[collectd] [PATCH] IPVS plugin not handling firewall marks
Mark Brooks
mark at loadbalancer.org
Wed May 30 14:50:51 CEST 2012
Hi all,
This was detected in 5.1.0, when using the ipvs plugin to collect
stats from ipvs with firewall marks. (I am quite new to using collectd
so if Ive missed something please shout)
The observed normal folder naming convention is -
ipvs-<virtual IP>_{UDP,TCP}<port>
which is fine until you use a firewall mark as you get
ipvs-0.0.0.0_TCP0/
Which is usable unless you have more than one firewall mark pointing
to the same real servers, as everything ends up in the same directory.
The patch detects if the Virtual IP is a firewall mark and uses that
to form the folder name instead. So if your using a firewall mark you
would get
ipvs-<firewall_mark>_FWM0
Mark
-----------------------------------------------------------------------------------------------------------------
diff -pur collectd-5.1.0/src/ipvs.c collectd-5.1.0-mine/src/ipvs.c
--- collectd-5.1.0/src/ipvs.c 2012-04-02 09:04:58.000000000 +0100
+++ collectd-5.1.0-mine/src/ipvs.c 2012-05-30 13:05:58.239637001 +0100
@@ -188,14 +188,20 @@ static int get_pi (struct ip_vs_service_
if ((NULL == se) || (NULL == pi))
return 0;
-
- addr.s_addr = se->addr;
-
+
+ if (se->fwmark) {
+ len = ssnprintf (pi, size, "%u_FWM%u", se->fwmark,
+ ntohs (se->port));
+ }
+ else {
+ addr.s_addr = se->addr;
+
+ len = ssnprintf (pi, size, "%s_%s%u", inet_ntoa (addr),
+ (se->protocol == IPPROTO_TCP) ? "TCP" : "UDP",
+ ntohs (se->port));
+ }
/* inet_ntoa() returns a pointer to a statically allocated buffer
* I hope non-glibc systems behave the same */
- len = ssnprintf (pi, size, "%s_%s%u", inet_ntoa (addr),
- (se->protocol == IPPROTO_TCP) ? "TCP" : "UDP",
- ntohs (se->port));
if ((0 > len) || (size <= len)) {
log_err ("plugin instance truncated: %s", pi);
More information about the collectd
mailing list