This script is intended to be used in conjunction with net-snmp and cacti.
The princips of operation: script asks unbound-control for satistics, after that it makes reformation of original statistics according to cacti neads (variable:value), and dumps statistics in temporary directory where net-snmp can find it. Now you cacti server can remotely poll it via SNMP.
Cacti templates (Data input methods) is manualy configured for SNMP v2c. All other settings (SNMP community name and unbound server hostname) will be imported from settings configured insight of Device for with you gonna to create graph. Settings for correct SNMP OID value should be provided in the time of graph creation, (read comments in cacti_unbound for information about default OID pathes).
My system is FreeBSD 7.1 - if you a Linux user please recheck for proper path to snmpget in "Data input method" templates, and also check for proper path to unbound-control in unbound_cacti script.

To start using this unbound_cacti script you should:

1) Setup and configure cacti.
I assume that all cacti settings is in default state. Only one cacti part should be customized - you should adjust font size of legend.
Go to: [Console] -> [Settings] -> [Visual] -> [Legend Font Size] and change size from 12 to 8.

2) Setup and configure both unbound and unbound-control.

3) Read comments insight of unbound_cacti script and setup temporary directory according to settings in $datadir variable.

4) Setup cron to run unbound_cacti.

5) Install and configure net-snmp.
Use snmpconf to make you new snmpd.conf if you don't have one. I assume use of SNMP version v2c and some custom, you own community name. Cacti templates is already configured for it.

6) Import in cacti provided xml template from "Host template" directory.
You are present with one big "ready to go" template named "cacti_host_template_unbound_dns.xml" - it is *all in one* pack (host template and all dependencys in one file). Just Import this big template and you are ready for next step.

You are also present with separate tepmlates for each type of graph. They all have been exported with dependencys. If you are gonna to import some of them, then first of all import *_data_template_* files, and after that import *_graph_template_* files.

6.1) In some rare situations cacti imports "Data Input Methods" templates with error. Please recheck each Input Method template for proper "Input String".
The example of correct Input String for all templates is: /usr/local/bin/snmpget -v2c -Ovqa -c <snmp_community> <host> <oid>

7) Create new Device using [Devices] -> [Add]. Type correct hostname, select [Host Template] -> [Unbound DNS], select using of SNMP Version 2 and type you community name. Create new graphs using [New Graphs]. In the first time of graph creation you will be asked for SNMP OID value to monitor.
Now go to section [Graph Trees] - [Default Tree] and add new Tree Item (Tree Item Type - Host)


Sorry for my English if any... ;)

====================================================================

        net-snmp  cacti.
   :    unbound-control ,        cacti (:)         -     net-snmp.         cacti.
  cacti,   ,     (Data input method)   SNMP  v2c.    (SNMP community name  -  unbound)       Device.     SNMP OID                .           SNMP OID -    net-snmp          unbound_cacti ( extend  snmpd.conf)  OID   .
  FreeBSD 7.1, ,    Linux    snmpget      "Data input method",      unbound-control   unbound_cacti.

   , :

1)    cacti.
      -.              .    [Console] -> [Settings] -> [Visual] -> [Legend Font Size] -     12  8.

2)      unbound   unbound-control.

3,4)    unbound_cacti ,       $datadir      ,    ,       cron.    ,      snmpd.conf      .

5)     net-snmp.
   net-snmp   snmpconf -      snmpd.conf,    .      cacti  SNMP v2c -   read only SNMP community       .

6)   cacti xml    "Host template".
  .  "cacti_host_template_unbound_dns.xml"          .            .

         .          .    -   ,    *_data_template_* ,    *_graph_template_*.

6.1)     cacti     "Data Input Methods"  .      "Input String".
       : /usr/local/bin/snmpget -v2c -Ovqa -c <snmp_community> <host> <oid>

7)   cacti            :  [Devices] - > [Add].      -,  [Host Template] -> [Unbound DNS],   SNMP Version 2    SNMP community.
         [New Graphs].        SNMP OID  .
   [Graph Trees] - [Default Tree]         Tree Item (Tree Item Type - Host).
