{"id":72,"date":"2021-07-09T14:12:33","date_gmt":"2021-07-09T14:12:33","guid":{"rendered":"http:\/\/www.iam8up.com\/?p=72"},"modified":"2021-07-13T14:08:39","modified_gmt":"2021-07-13T14:08:39","slug":"unbound-stats-graphed-with-xymon","status":"publish","type":"post","link":"https:\/\/www.iam8up.com\/?p=72","title":{"rendered":"Unbound stats graphed with Xymon"},"content":{"rendered":"<p>Refer to this overall guide for a master overview and below is an example hopefully others can find useful.\u00a0 This is for the Unbound stats we wanted to monitor initially and it may change.<\/p>\n<p>Script to collect data<\/p>\n<p>On the Xymon client:<\/p>\n<blockquote><p>touch ~xymon\/ext\/unboundstats.sh &amp;&amp; chown xymon:xymon unboundstats.sh &amp;&amp; chmod 744 unboundstats.sh<\/p><\/blockquote>\n<p>unboundstatsh.sh:<\/p>\n<blockquote><p>#!\/bin\/sh<\/p>\n<p>\/usr\/sbin\/unbound-control stats | \\<br \/>\ngrep -E &#8220;^total.num.queries|^total.num.queries_ip_ratelimited|^total.num.cachehits|^total.num.cachemiss|^total.recursion.time.avg|num.query.tcp|^unwanted.queries|^unwanted.replies&#8221; | \\<br \/>\nawk -F= -v OFS=: &#8216;{gsub(\/\\.\/, &#8220;&#8221;, $1); print}&#8217; &gt; \/tmp\/unbound.stats<\/p>\n<p>#sed would remove decimal in the recursion time value<br \/>\n#sed s,=,:, | sed s,\\\\.,,g &gt; \/tmp\/unbound.stats<\/p>\n<p>$XYMON $XYMSRV &#8220;status $MACHINE.unboundstats green `date`<\/p>\n<p>`cat \/tmp\/unbound.stats`<br \/>\n&#8221;<\/p>\n<p>exit 0<\/p><\/blockquote>\n<p>You need to restart the Xymon server!\u00a0 Generally this is <strong>systemctl restart xymon <\/strong>or<strong> \/etc\/init.d\/xymonlaunch.cfg restart<\/strong><\/p>\n<p>I&#8217;m not sure if this is the right way of going about the permissions issue, but the Xymon user needs to be able to read the SSL key\/pem&#8230;<\/p>\n<blockquote><p>chgrp xymon\u00a0\/etc\/unbound\/unbound_control.pem\u00a0\/etc\/unbound\/unbound_control.key\u00a0\/etc\/unbound\/unbound_server.pem\u00a0\/etc\/unbound\/unbound_server.key<\/p><\/blockquote>\n<p>Now make the Xymon client run the above script in ~xymon\/etc\/clientlaunch.cfg:<\/p>\n<blockquote><p>#this collects unbound stats<br \/>\n[unboundstats]<br \/>\nENVFILE $XYMONCLIENTHOME\/etc\/xymonclient.cfg<br \/>\nCMD $XYMONCLIENTHOME\/ext\/unboundstats.sh<br \/>\nINTERVAL 5m<\/p><\/blockquote>\n<p>On the Xymon server you will want to turn this test submission data into RRD.\u00a0 In ~xymon\/server\/etc\/xymonserver.cfg:<\/p>\n<blockquote><p>TEST2RRD=&#8221;cpu=la,defaultdefaultdefault,<strong>unboundstats=ncv<\/strong>&#8221;<\/p>\n<p><strong>SPLITNCV_unboundstats=&#8221;totalnumqueries:GAUGE,totalnumqueries_ip_ratelimited:GAUGE,totalnumcachehits:GAUGE,totalnumcachemiss:GAUGE,totalrecursiontimeavg:GAUGE,numquerytcp:GAUGE,numquerytcpout:GAUGE,unwantedqueries:GAUGE,unwantedreplies:GAUGE&#8221;<\/strong><\/p>\n<p>GRAPHS=&#8221;defaultdefaultdefault&#8221;<\/p>\n<p><strong>GRAPHS_unboundstats=&#8221;unboundstats,unboundstats1&#8243; #note this requires xymon 4.3.20 https:\/\/lists.xymon.com\/archive\/2017-April\/044560.html<\/strong><\/p><\/blockquote>\n<p>After a few minutes you should see RRD files<\/p>\n<blockquote><p># ls \/var\/lib\/xymon\/rrd\/HOST.FOOBAR.COM\/unboundstats,*<br \/>\n\/var\/lib\/xymon\/rrd\/HOST.FOOBAR.COM\/unboundstats,numquerytcpout.rrd<br \/>\n&#8230;<\/p><\/blockquote>\n<p>Add the graph definition (this translates from the RRD files to pretty graphs and once the file is edited\/saved you can refresh the test page on Xymon\/unboundstats for live viewing) in\u00a0~xymon\/server\/etc\/graphs.cfg:<\/p>\n<blockquote><p>[unboundstats]<br \/>\nTITLE Unbound Stats<br \/>\nYAXIS Num<br \/>\nDEF:numqueries=unboundstats,totalnumqueries.rrd:lambda:AVERAGE<br \/>\nDEF:numqueriesiprate=unboundstats,totalnumqueries_ip_ratelimited.rrd:lambda:AVERAGE<br \/>\nDEF:numcachehits=unboundstats,totalnumcachehits.rrd:lambda:AVERAGE<br \/>\nDEF:totalnumcachemiss=unboundstats,totalnumcachemiss.rrd:lambda:AVERAGE<\/p>\n<p>LINE2:numqueries#00CCCC:Total Queries<br \/>\nLINE2:numqueriesiprate#00FF00:Queries IP Rate<br \/>\nLINE2:numcachehits#FF0000:Total Cache Hits<br \/>\nLINE2:totalnumcachemiss#0000FF:Total Cache Miss<\/p>\n<p>COMMENT:\\n<br \/>\nGPRINT:numqueries:LAST:Total Queries \\: %5.1lf%s (cur)<br \/>\nGPRINT:numqueries:MAX: \\: %5.1lf%s (max)<br \/>\nGPRINT:numqueries:MIN: \\: %5.1lf%s (min)<br \/>\nGPRINT:numqueries:AVERAGE: \\: %5.1lf%s (avg)\\n<\/p>\n<p>GPRINT:numqueriesiprate:LAST:IP Rate Queries \\: %5.1lf%s (cur)<br \/>\nGPRINT:numqueriesiprate:MAX: \\: %5.1lf%s (max)<br \/>\nGPRINT:numqueriesiprate:MIN: \\: %5.1lf%s (min)<br \/>\nGPRINT:numqueriesiprate:AVERAGE: \\: %5.1lf%s (avg)\\n<\/p>\n<p>GPRINT:numcachehits:LAST:Cache Hits\\: %5.1lf%s (cur)<br \/>\nGPRINT:numcachehits:MAX: \\: %5.1lf%s (max)<br \/>\nGPRINT:numcachehits:MIN: \\: %5.1lf%s (min)<br \/>\nGPRINT:numcachehits:AVERAGE: \\: %5.1lf%s (avg)\\n<\/p>\n<p>GPRINT:totalnumcachemiss:LAST:Cache Miss\\: %5.1lf%s (cur)<br \/>\nGPRINT:totalnumcachemiss:MAX: \\: %5.1lf%s (max)<br \/>\nGPRINT:totalnumcachemiss:MIN: \\: %5.1lf%s (min)<br \/>\nGPRINT:totalnumcachemiss:AVERAGE: \\: %5.1lf%s (avg)\\n<\/p>\n<p>[unboundstats1]<br \/>\nTITLE Unbound Stats<br \/>\nYAXIS Num<br \/>\nDEF:totalrecursiontimeavg=unboundstats,totalrecursiontimeavg.rrd:lambda:AVERAGE<br \/>\nDEF:numquerytcp=unboundstats,numquerytcp.rrd:lambda:AVERAGE<br \/>\nDEF:numquerytcpout=unboundstats,numquerytcpout.rrd:lambda:AVERAGE<br \/>\nDEF:unwantedqueries=unboundstats,unwantedqueries.rrd:lambda:AVERAGE<br \/>\nDEF:unwantedreplies=unboundstats,unwantedreplies.rrd:lambda:AVERAGE<\/p>\n<p>LINE2:totalrecursiontimeavg#AAA1AA:Average Recusion Time<br \/>\nLINE2:numquerytcp#C6913B:Queries w TCP<br \/>\nLINE2:numquerytcpout#8BBFFF:Queries out w TCP<br \/>\nLINE2:unwantedqueries#FF69B4:Unwanted Queries<br \/>\nLINE2:unwantedreplies#FFFF00:Unwanted Replies<\/p>\n<p>COMMENT:\\n<br \/>\nGPRINT:totalrecursiontimeavg:LAST:Recursion Time Avg\\: %5.1lf%s (cur)<br \/>\nGPRINT:totalrecursiontimeavg:MAX: \\: %5.1lf%s (max)<br \/>\nGPRINT:totalrecursiontimeavg:MIN: \\: %5.1lf%s (min)<br \/>\nGPRINT:totalrecursiontimeavg:AVERAGE: \\: %5.1lf%s (avg)\\n<\/p>\n<p>GPRINT:numquerytcp:LAST:TCP Queries\\: %5.1lf%s (cur)<br \/>\nGPRINT:numquerytcp:MAX: \\: %5.1lf%s (max)<br \/>\nGPRINT:numquerytcp:MIN: \\: %5.1lf%s (min)<br \/>\nGPRINT:numquerytcp:AVERAGE: \\: %5.1lf%s (avg)\\n<\/p>\n<p>GPRINT:numquerytcpout:LAST:TCP Queries Out\\: %5.1lf%s (cur)<br \/>\nGPRINT:numquerytcpout:MAX: \\: %5.1lf%s (max)<br \/>\nGPRINT:numquerytcpout:MIN: \\: %5.1lf%s (min)<br \/>\nGPRINT:numquerytcpout:AVERAGE: \\: %5.1lf%s (avg)\\n<\/p>\n<p>GPRINT:unwantedqueries:LAST:Unwanted Queries\\: %5.1lf%s (cur)<br \/>\nGPRINT:unwantedqueries:MAX: \\: %5.1lf%s (max)<br \/>\nGPRINT:unwantedqueries:MIN: \\: %5.1lf%s (min)<br \/>\nGPRINT:unwantedqueries:AVERAGE: \\: %5.1lf%s (avg)\\n<\/p>\n<p>GPRINT:unwantedreplies:LAST:Unwanted Replies\\: %5.1lf%s (cur)<br \/>\nGPRINT:unwantedreplies:MAX: \\: %5.1lf%s (max)<br \/>\nGPRINT:unwantedreplies:MIN: \\: %5.1lf%s (min)<br \/>\nGPRINT:unwantedreplies:AVERAGE: \\: %5.1lf%s (avg)\\n<\/p>\n<p>&nbsp;<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Refer to this overall guide for a master overview and below is an example hopefully others can find useful.\u00a0 This is for the Unbound stats we wanted to monitor initially and it may change. Script to collect data On the Xymon client: touch ~xymon\/ext\/unboundstats.sh &amp;&amp; chown xymon:xymon unboundstats.sh &amp;&amp; chmod 744 unboundstats.sh unboundstatsh.sh: #!\/bin\/sh \/usr\/sbin\/unbound-control &hellip; <a href=\"https:\/\/www.iam8up.com\/?p=72\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Unbound stats graphed with Xymon&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-72","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.iam8up.com\/index.php?rest_route=\/wp\/v2\/posts\/72","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.iam8up.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.iam8up.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.iam8up.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.iam8up.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=72"}],"version-history":[{"count":8,"href":"https:\/\/www.iam8up.com\/index.php?rest_route=\/wp\/v2\/posts\/72\/revisions"}],"predecessor-version":[{"id":80,"href":"https:\/\/www.iam8up.com\/index.php?rest_route=\/wp\/v2\/posts\/72\/revisions\/80"}],"wp:attachment":[{"href":"https:\/\/www.iam8up.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=72"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.iam8up.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=72"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.iam8up.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=72"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}