Skip to content

Instantly share code, notes, and snippets.

@phonedph1
Created November 14, 2019 21:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phonedph1/6576f3ad80203c2d9b113208da081481 to your computer and use it in GitHub Desktop.
Save phonedph1/6576f3ad80203c2d9b113208da081481 to your computer and use it in GitHub Desktop.
diff --git a/pdns/dnsdist-web.cc b/pdns/dnsdist-web.cc
index 07613f131..25021b745 100644
--- a/pdns/dnsdist-web.cc
+++ b/pdns/dnsdist-web.cc
@@ -531,6 +531,16 @@ static void connectionThread(int sock, ComboAddress remote)
output << statesbase << "tcpavgconnduration" << label << " " << state->tcpAvgConnectionDuration << "\n";
}
+ const string rulesbase = "dnsdist_rules";
+ auto localRules = g_rulactions.getLocal();
+ int num = 0;
+ for(const auto& a : *localRules) {
+ const std::string rule_info = boost::str(boost::format("{id=\"%1%\",creationOrder=\"%2%\",uuid=\"%3%\",rule=\"%4%\",action=\"%5%\"}")
+ % num % (double)a.d_creationOrder % boost::uuids::to_string(a.d_id) % a.d_rule->toString() % a.d_action->toString());
+ output << rulesbase << rule_info << " " << a.d_rule->d_matches << "\n";
+ num++;
+ }
+
const string frontsbase = "dnsdist_frontend_";
output << "# HELP " << frontsbase << "queries " << "Amount of queries received by this frontend" << "\n";
output << "# TYPE " << frontsbase << "queries " << "counter" << "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment