[collectd] [PATCH] ipvs plugin: Get IP_VS_SO_GET_INFO in cipvs_read() instead of cipvs_init().
Sebastian Harl
sh at tokkee.org
Wed Oct 10 20:37:58 CEST 2007
IP_VS_SO_GET_INFO also provides the number of services which might change
after initializing the plugin.
Signed-off-by: Sebastian Harl <sh at tokkee.org>
---
src/ipvs.c | 19 +++++++++----------
1 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/src/ipvs.c b/src/ipvs.c
index c670b09..3c8c8a4 100644
--- a/src/ipvs.c
+++ b/src/ipvs.c
@@ -162,20 +162,10 @@ static struct ip_vs_get_dests *ipvs_get_dests (struct ip_vs_service_entry *se)
static int cipvs_init (void)
{
- socklen_t len;
-
- len = sizeof (ipvs_info);
-
if (-1 == (sockfd = socket (AF_INET, SOCK_RAW, IPPROTO_RAW))) {
log_err ("cipvs_init: socket() failed: %s", ipvs_strerror (errno));
return -1;
}
-
- if (0 != getsockopt (sockfd, IPPROTO_IP, IP_VS_SO_GET_INFO,
- (void *)&ipvs_info, &len)) {
- log_err ("cipvs_init: getsockopt() failed: %s", ipvs_strerror (errno));
- return -1;
- }
return 0;
} /* cipvs_init */
@@ -318,8 +308,17 @@ static int cipvs_read (void)
{
struct ip_vs_get_services *services = NULL;
+ socklen_t len;
int i = 0;
+ len = sizeof (ipvs_info);
+
+ if (0 != getsockopt (sockfd, IPPROTO_IP, IP_VS_SO_GET_INFO,
+ (void *)&ipvs_info, &len)) {
+ log_err ("cipvs_read: getsockopt() failed: %s", ipvs_strerror (errno));
+ return -1;
+ }
+
if (NULL == (services = ipvs_get_services ()))
return -1;
--
1.5.3.3.131.g34c6d-dirty
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20071010/21301897/attachment.pgp
More information about the collectd
mailing list