From 0a253c107392b7aa33f83766e61bac49be093234 Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Mon, 26 Sep 2011 11:49:38 +0000 Subject: [PATCH] PowerDNS application type. Thanks to Dennis de Houx. git-svn-id: http://www.observium.org/svn/observer/trunk@2572 61d68cd4-352d-0410-923a-c4978735b2b8 --- .../graphs/application/powerdns_fail.inc.php | 36 ++++++++ .../application/powerdns_latency.inc.php | 27 ++++++ .../application/powerdns_packetcache.inc.php | 36 ++++++++ .../application/powerdns_queries.inc.php | 37 +++++++++ .../application/powerdns_queries_udp.inc.php | 37 +++++++++ .../application/powerdns_querycache.inc.php | 36 ++++++++ .../application/powerdns_recursing.inc.php | 36 ++++++++ html/pages/device/apps/powerdns.inc.php | 30 +++++++ .../polling/applications/powerdns.inc.php | 55 ++++++++++++ scripts/powerdns.php | 83 +++++++++++++++++++ 10 files changed, 413 insertions(+) create mode 100644 html/includes/graphs/application/powerdns_fail.inc.php create mode 100644 html/includes/graphs/application/powerdns_latency.inc.php create mode 100644 html/includes/graphs/application/powerdns_packetcache.inc.php create mode 100644 html/includes/graphs/application/powerdns_queries.inc.php create mode 100644 html/includes/graphs/application/powerdns_queries_udp.inc.php create mode 100644 html/includes/graphs/application/powerdns_querycache.inc.php create mode 100644 html/includes/graphs/application/powerdns_recursing.inc.php create mode 100644 html/pages/device/apps/powerdns.inc.php create mode 100644 includes/polling/applications/powerdns.inc.php create mode 100755 scripts/powerdns.php diff --git a/html/includes/graphs/application/powerdns_fail.inc.php b/html/includes/graphs/application/powerdns_fail.inc.php new file mode 100644 index 0000000000..b6cb754380 --- /dev/null +++ b/html/includes/graphs/application/powerdns_fail.inc.php @@ -0,0 +1,36 @@ + array('descr' => 'Corrupt', 'colour' => 'FF8800FF'), + 'servfailPackets' => array('descr' => 'Failed', 'colour' => 'FF0000FF'), + 'q_timedout' => array('descr' => 'Timedout', 'colour' => 'FFFF00FF'), +); + + +$i = 0; +if (is_file($rrd_filename)) +{ + foreach ($array as $ds => $vars) + { + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = $vars['descr']; + $rrd_list[$i]['ds'] = $ds; + $rrd_list[$i]['colour'] = $vars['colour']; + $i++; + } +} else { echo("file missing: $file"); } + +$colours = "red"; +$nototal = 0; +$unit_text = "Packets/sec"; + +include("includes/graphs/generic_multi_simplex_seperated.inc.php"); + + +?> diff --git a/html/includes/graphs/application/powerdns_latency.inc.php b/html/includes/graphs/application/powerdns_latency.inc.php new file mode 100644 index 0000000000..68cf52218c --- /dev/null +++ b/html/includes/graphs/application/powerdns_latency.inc.php @@ -0,0 +1,27 @@ + diff --git a/html/includes/graphs/application/powerdns_packetcache.inc.php b/html/includes/graphs/application/powerdns_packetcache.inc.php new file mode 100644 index 0000000000..c7ba418d93 --- /dev/null +++ b/html/includes/graphs/application/powerdns_packetcache.inc.php @@ -0,0 +1,36 @@ + array('descr' => 'Hits', 'colour' => '008800FF'), + 'pc_miss' => array('descr' => 'Misses', 'colour' => '880000FF'), + 'pc_size' => array('descr' => 'Size', 'colour' => '006699FF'), +); + + +$i = 0; +if (is_file($rrd_filename)) +{ + foreach ($array as $ds => $vars) + { + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = $vars['descr']; + $rrd_list[$i]['ds'] = $ds; + $rrd_list[$i]['colour'] = $vars['colour']; + $i++; + } +} else { echo("file missing: $file"); } + +$colours = "blue"; +$nototal = 0; +$unit_text = "Packets/sec"; + +include("includes/graphs/generic_multi_simplex_seperated.inc.php"); + + +?> diff --git a/html/includes/graphs/application/powerdns_queries.inc.php b/html/includes/graphs/application/powerdns_queries.inc.php new file mode 100644 index 0000000000..ee1933f444 --- /dev/null +++ b/html/includes/graphs/application/powerdns_queries.inc.php @@ -0,0 +1,37 @@ + array('descr' => 'TCP Answers', 'colour' => '008800FF'), + 'q_tcpQueries' => array('descr' => 'TCP Queries', 'colour' => '00FF00FF'), + 'q_udpAnswers' => array('descr' => 'UDP Answers', 'colour' => '336699FF'), + 'q_udpQueries' => array('descr' => 'UDP Queries', 'colour' => '6699CCFF'), +); + + +$i = 0; +if (is_file($rrd_filename)) +{ + foreach ($array as $ds => $vars) + { + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = $vars['descr']; + $rrd_list[$i]['ds'] = $ds; + $rrd_list[$i]['colour'] = $vars['colour']; + $i++; + } +} else { echo("file missing: $file"); } + +$colours = "mixed"; +$nototal = 0; +$unit_text = "Packets/sec"; + +include("includes/graphs/generic_multi_simplex_seperated.inc.php"); + + +?> diff --git a/html/includes/graphs/application/powerdns_queries_udp.inc.php b/html/includes/graphs/application/powerdns_queries_udp.inc.php new file mode 100644 index 0000000000..065f4a4115 --- /dev/null +++ b/html/includes/graphs/application/powerdns_queries_udp.inc.php @@ -0,0 +1,37 @@ + array('descr' => 'UDP4 Answers\t', 'colour' => '00008888'), + 'q_udp4Queries' => array('descr' => 'UDP4 Queries ', 'colour' => '000088FF'), + 'q_udp6Answers' => array('descr' => 'UDP6 Answers ', 'colour' => '88000088'), + 'q_udp6Queries' => array('descr' => 'UDP6 Queries ', 'colour' => '880000FF'), +); + + +$i = 0; +if (is_file($rrd_filename)) +{ + foreach ($array as $ds => $vars) + { + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = $vars['descr']; + $rrd_list[$i]['ds'] = $ds; + $rrd_list[$i]['colour'] = $vars['colour']; + $i++; + } +} else { echo("file missing: $file"); } + +$colours = "mixed"; +$nototal = 0; +$unit_text = "Packets/sec"; + +include("includes/graphs/generic_multi_simplex_seperated.inc.php"); + + +?> diff --git a/html/includes/graphs/application/powerdns_querycache.inc.php b/html/includes/graphs/application/powerdns_querycache.inc.php new file mode 100644 index 0000000000..1f3986ead0 --- /dev/null +++ b/html/includes/graphs/application/powerdns_querycache.inc.php @@ -0,0 +1,36 @@ + array('descr' => 'Misses', 'colour' => '750F7DFF'), + 'qc_hit' => array('descr' => 'Hits', 'colour' => '00FF00FF'), +); + + +$i = 0; +if (is_file($rrd_filename)) +{ + foreach ($array as $ds => $vars) + { + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = $vars['descr']; + $rrd_list[$i]['ds'] = $ds; + $rrd_list[$i]['colour'] = $vars['colour']; + $i++; + } +} else { echo("file missing: $file"); } + +$colours = "mixed"; +$nototal = 0; +$unit_text = "Packets/sec"; + +//include("includes/graphs/generic_multi_simplex_seperated.inc.php"); +include("includes/graphs/generic_multi_line.inc.php"); + + +?> diff --git a/html/includes/graphs/application/powerdns_recursing.inc.php b/html/includes/graphs/application/powerdns_recursing.inc.php new file mode 100644 index 0000000000..780687e3ec --- /dev/null +++ b/html/includes/graphs/application/powerdns_recursing.inc.php @@ -0,0 +1,36 @@ + array('descr' => 'Questions', 'colour' => '6699CCFF'), + 'rec_answers' => array('descr' => 'Answers', 'colour' => '336699FF'), +); + + +$i = 0; +if (is_file($rrd_filename)) +{ + foreach ($array as $ds => $vars) + { + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = $vars['descr']; + $rrd_list[$i]['ds'] = $ds; + $rrd_list[$i]['colour'] = $vars['colour']; + $i++; + } +} else { echo("file missing: $file"); } + +$colours = "mixed"; +$nototal = 0; +$unit_text = "Packets/sec"; + +//include("includes/graphs/generic_multi_simplex_seperated.inc.php"); +include("includes/graphs/generic_multi_line.inc.php"); + + +?> diff --git a/html/pages/device/apps/powerdns.inc.php b/html/pages/device/apps/powerdns.inc.php new file mode 100644 index 0000000000..ae857f3846 --- /dev/null +++ b/html/pages/device/apps/powerdns.inc.php @@ -0,0 +1,30 @@ + 'Latency', + 'powerdns_fail' => 'Corrupt - Failed - Timedout', + 'powerdns_packetcache' => 'Packet Cache', + 'powerdns_querycache' => 'Query Cache', + 'powerdns_recursing' => 'Recursing Queries and Answers', + 'powerdns_queries' => 'Total UDP/TCP Queries and Answers', + 'powerdns_queries_udp' => 'Detail UDP IPv4/IPv6 Queries and Answers'); + +foreach ($graphs as $key => $text) { + $graph_type = $key; + $graph_array['height'] = "100"; + $graph_array['width'] = "215"; + $graph_array['to'] = $now; + $graph_array['id'] = $app['app_id']; + $graph_array['type'] = "application_".$key; + + echo('

'.$text.'

'); + + echo(""); + + include("includes/print-quadgraphs.inc.php"); + + echo(""); +} + +?> \ No newline at end of file diff --git a/includes/polling/applications/powerdns.inc.php b/includes/polling/applications/powerdns.inc.php new file mode 100644 index 0000000000..7822e3eee4 --- /dev/null +++ b/includes/polling/applications/powerdns.inc.php @@ -0,0 +1,55 @@ + diff --git a/scripts/powerdns.php b/scripts/powerdns.php new file mode 100755 index 0000000000..a71ae79981 --- /dev/null +++ b/scripts/powerdns.php @@ -0,0 +1,83 @@ +#!/usr/bin/env php + +## +######################################################################################## + + +#### START SETTINGS #### + + $pdnscontrol = "/usr/bin/pdns_control"; + +#### END SETTINGS #### + + +## +## DO NOT EDIT BENETH THIS LINE +## +######################################################################################## + + $cmd = shell_exec($pdnscontrol." show \*"); + $vars = array(); + $vars = explode(',', $cmd); + + function doSNMP($vars) { + foreach ($vars as $item=>$value) { + $value = trim($value); + if (!empty($value)) { + echo $value."\n"; + } + } + } + + function doSNMPv2($vars) { + $pdns = array(); + foreach ($vars as $item=>$value) { + if (!empty($value)) { + $temp = explode('=', $value); + if (isset($temp[1])) { + $pdns[$temp[0]] = $temp[1]; + } + } + } + $var['corrupt-packets'] = (isset($pdns['corrupt-packets']) ? $pdns['corrupt-packets'] : "U"); + $var['deferred-cache-inserts'] = (isset($pdns['deferred-cache-inserts']) ? $pdns['deferred-cache-inserts'] : "U"); + $var['deferred-cache-lookup'] = (isset($pdns['deferred-cache-lookup']) ? $pdns['deferred-cache-lookup'] : "U"); + $var['latency'] = (isset($pdns['latency']) ? $pdns['latency'] : "U"); + $var['packetcache-hit'] = (isset($pdns['packetcache-hit']) ? $pdns['packetcache-hit'] : "U"); + $var['packetcache-miss'] = (isset($pdns['packetcache-miss']) ? $pdns['packetcache-miss'] : "U"); + $var['packetcache-size'] = (isset($pdns['packetcache-size']) ? $pdns['packetcache-size'] : "U"); + $var['qsize-q'] = (isset($pdns['qsize-q']) ? $pdns['qsize-q'] : "U"); + $var['query-cache-hit'] = (isset($pdns['query-cache-hit']) ? $pdns['query-cache-hit'] : "U"); + $var['query-cache-miss'] = (isset($pdns['query-cache-miss']) ? $pdns['query-cache-miss'] : "U"); + $var['recursing-answers'] = (isset($pdns['recursing-answers']) ? $pdns['recursing-answers'] : "U"); + $var['recursing-questions'] = (isset($pdns['recursing-questions']) ? $pdns['recursing-questions'] : "U"); + $var['servfail-packets'] = (isset($pdns['servfail-packets']) ? $pdns['servfail-packets'] : "U"); + $var['tcp-answers'] = (isset($pdns['tcp-answers']) ? $pdns['tcp-answers'] : "U"); + $var['tcp-queries'] = (isset($pdns['tcp-queries']) ? $pdns['tcp-queries'] : "U"); + $var['timedout-packets'] = (isset($pdns['timedout-packets']) ? $pdns['timedout-packets'] : "U"); + $var['udp-answers'] = (isset($pdns['udp-answers']) ? $pdns['udp-answers'] : "U"); + $var['udp-queries'] = (isset($pdns['udp-queries']) ? $pdns['udp-queries'] : "U"); + $var['udp4-answers'] = (isset($pdns['udp4-answers']) ? $pdns['udp4-answers'] : "U"); + $var['udp4-queries'] = (isset($pdns['udp4-queries']) ? $pdns['udp4-queries'] : "U"); + $var['udp6-answers'] = (isset($pdns['udp6-answers']) ? $pdns['udp6-answers'] : "U"); + $var['udp6-queries'] = (isset($pdns['udp6-queries']) ? $pdns['udp6-queries'] : "U"); + foreach ($var as $item=>$count) { + echo $count."\n"; + } + } + + doSNMPv2($vars); + +?>