Pulldata problems
list Francesco Duranti
Hi, I don't know if this is a bug report or just a work as intended with whom I've some problems.. I'm start using msgcache and pulldata, I've all of my hosts in the bb-hosts file with 0.0.0.0 ip address so that I can define the ip in the /etc/hosts and use it for every application that need it. I've 2 hosts with pulldata defined as: 0.0.0.0 itromwb13 # pulldata and when hobbitfetch try to get the data it will try to use 0.0.0.0:1984 instead of resolving and using the hostname. It's possible to have the pulldata=ip:port accept also hostname or better than this if the ip address is 0.0.0.0 use the hostname defined in the bb-hosts instead of the ip address? Thanks
list Francesco Duranti
Another little problem... If I define the pulldata=IP:Port without an IP it will use 0.0.0.0 as the IP address to get data from also if i defined the host with the IP Address: 10.1.1.1 machine #pulldata=:1985 Hobbitfetch will try to contact 0.0.0.0:1985 instead of 10.1.1.1:1985
▸
-----Original Message----- From: Francesco Duranti [mailto:user-7104dcecbfef@xymon.invalid] Sent: Monday, August 14, 2006 5:46 PM To: user-ae9b8668bcde@xymon.invalid Subject: [hobbit] Pulldata problems Hi, I don't know if this is a bug report or just a work as intended with whom I've some problems.. I'm start using msgcache and pulldata, I've all of my hosts in the bb-hosts file with 0.0.0.0 ip address so that I can define the ip in the /etc/hosts and use it for every application that need it. I've 2 hosts with pulldata defined as: 0.0.0.0 itromwb13 # pulldata and when hobbitfetch try to get the data it will try to use 0.0.0.0:1984 instead of resolving and using the hostname. It's possible to have the pulldata=ip:port accept also hostname or better than this if the ip address is 0.0.0.0 use the hostname defined in the bb-hosts instead of the ip address? Thanks
list Henrik Størner
▸
On Mon, Aug 14, 2006 at 05:46:10PM +0200, Francesco Duranti wrote:
I'm start using msgcache and pulldata, I've all of my hosts in the bb-hosts file with 0.0.0.0 ip address so that I can define the ip in the /etc/hosts and use it for every application that need it. I've 2 hosts with pulldata defined as: 0.0.0.0 itromwb13 # pulldata and when hobbitfetch try to get the data it will try to use 0.0.0.0:1984 instead of resolving and using the hostname.
It works as designed, but it might not be the best way to do it. The
attached patch will make hobbitfetch determine the IP-address from the
hostname, if the IP in bb-hosts is 0.0.0.0.
It also takes care of your other requests for "pulldata=:2084" style
syntax.
Regards,
Henrik
-------------- next part --------------
--- hobbitd/hobbitfetch.c 2006/07/22 11:23:56 1.13
+++ hobbitd/hobbitfetch.c 2006/08/14 20:10:05
@@ -30,6 +30,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
+#include <arpa/nameser.h>
#include <netdb.h>
#include <ctype.h>
#include <signal.h>
@@ -619,14 +620,36 @@
ip = strdup(bbh_item(hostwalk, BBH_IP));
}
else {
+ /* There is an explicit IP setting in the pulldata tag */
char *p;
ip++; /* Skip the '=' */
ip = strdup(ip);
p = strchr(ip, ':');
if (p) { *p = '\0'; port = atoi(p+1); }
• + if (*ip == '\0') {
+ /* No IP given, just a port number */
+ xfree(ip);
+ ip = strdup(bbh_item(hostwalk, BBH_IP));
+ }
+ }
• + if (strcmp(ip, "0.0.0.0") == 0) {
+ struct hostent *hent;
• + xfree(ip); ip = NULL;
+ hent = gethostbyname(clientwalk->hostname);
+ if (hent) {
+ struct in_addr addr;
• + memcpy(&addr, *(hent->h_addr_list), sizeof(addr));
+ ip = strdup(inet_ntoa(addr));
+ }
}
+ if (!ip) continue;
• /*
* Build the "pullclient" request, which includes the latest
* clientdata config we got from the server. Keep the clientdata