From: bert hubert Date: Wed, 2 Apr 2014 21:56:34 +0000 (+0200) Subject: add support for carbon-ourname to override our hostname for carbon reporting if needed X-Git-Tag: rec-3.6.0-rc1~94 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cc08b5a9b134a2378159b1f1fffaf8cb0c483177;p=thirdparty%2Fpdns.git add support for carbon-ourname to override our hostname for carbon reporting if needed --- diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index fb8f4d4c1c..7a35121e4e 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -2099,6 +2099,7 @@ int main(int argc, char **argv) ::arg().set("experimental-webserver-port", "Port of webserver to listen on") = "8082"; ::arg().set("experimental-webserver-password", "Password required for accessing the webserver") = ""; ::arg().set("experimental-api-config-dir", "Directory where REST API stores config and zones") = ""; + ::arg().set("carbon-ourname", "If set, overrides our reported hostname for carbon stats")=""; ::arg().set("carbon-server", "If set, send metrics in carbon (graphite) format to this server")=""; ::arg().set("carbon-interval", "Number of seconds between carbon (graphite) updates")="30"; ::arg().set("quiet","Suppress logging of questions and answers")=""; diff --git a/pdns/rec-carbon.cc b/pdns/rec-carbon.cc index f96ef3970d..48056b0c3f 100644 --- a/pdns/rec-carbon.cc +++ b/pdns/rec-carbon.cc @@ -24,8 +24,15 @@ try ostringstream str; time_t now=time(0); + string hostname=arg()["carbon-ourname"]; + if(hostname.empty()) { + char tmp[80]; + memset(tmp, 0, sizeof(tmp)); + gethostname(tmp, sizeof(tmp)); + hostname=tmp; + } BOOST_FOREACH(const all_t::value_type& val, all) { - str<<"pdns.recursor.localhost."<