6 #include "rec_channel.hh"
9 #include "arguments.hh"
13 void doCarbonDump(void*)
17 vector
<string
> carbonServers
;
20 Lock
l(&g_carbon_config_lock
);
21 stringtok(carbonServers
, arg()["carbon-server"], ", ");
22 hostname
=arg()["carbon-ourname"];
25 if(carbonServers
.empty())
28 if(hostname
.empty()) {
30 memset(tmp
, 0, sizeof(tmp
));
31 gethostname(tmp
, sizeof(tmp
));
32 char *p
= strchr(tmp
, '.');
36 boost::replace_all(hostname
, ".", "_");
40 for(const auto& carbonServer
: carbonServers
) {
41 RecursorControlParser rcp
; // inits if needed
42 ComboAddress
remote(carbonServer
, 2003);
43 Socket
s(remote
.sin4
.sin_family
, SOCK_STREAM
);
46 s
.connect(remote
); // we do the connect so the first attempt happens while we gather stats
49 typedef map
<string
,string
> all_t
;
50 all_t all
=getAllStatsMap();
55 for(const all_t::value_type
& val
: all
) {
56 str
<<"pdns."<<hostname
<<".recursor."<<val
.first
<<' '<<val
.second
<<' '<<now
<<"\r\n";
61 int ret
=asendtcp(msg
, &s
); // this will actually do the right thing waiting on the connect
63 L
<<Logger::Warning
<<"Error writing carbon data to "<<remote
.toStringWithPort()<<": "<<strerror(errno
)<<endl
;
65 L
<<Logger::Warning
<<"Timeout connecting/writing carbon data to "<<remote
.toStringWithPort()<<endl
;
68 catch(PDNSException
& e
)
70 L
<<Logger::Error
<<"Error in carbon thread: "<<e
.reason
<<endl
;
72 catch(std::exception
& e
)
74 L
<<Logger::Error
<<"Error in carbon thread: "<<e
.what()<<endl
;