Ubuntu 10.10 的 BIND9 版本為 9.7.1,所以便再來一篇囉!

參考:Cacti 論壇使用SSH使用SNMP

在 DNS Server 上進行下列的動作:

1.編輯 /etc/bind/named.conf.options,加入下列兩行:

options {
        directory "/var/cache/bind";
        zone-statistics yes;
        statistics-file "/var/cache/bind/named.stats";

        managed-keys-directory "/etc/bind";

2.重新啟動 bind9,可以執行 rndc stats 來確定是否有 named.stats 檔案:

$ sudo /etc/init.d/bind9 restart
 * Stopping domain name service... bind9                    [ OK ]
 * Starting domain name service... bind9                     [ OK ]
$ rndc stats
$ ls /var/cache/bind/

named.stats

3.安裝 snmpd 並修改設定檔。(以下兩個步驟非必要)

$ sudo apt-get install snmpd
$ sudo vi /etc/snmp/snmpd.conf

#agentAddress  udp:127.0.0.1:161

view   systemonly  included   .1.3.6.1.2.1.1
view   systemonly  included   .1.3.6.1.2.1.2.2.1
view   systemonly  included   .1.3.6.1.2.1.25.1
view   systemonly  included   .1.3.6.1.2.1.25.3.3.1
view   systemonly  included   .1.3.6.1.4.1.2021.4
view   systemonly  included   .1.3.6.1.4.1.2021.10.1.3
view   systemonly  included   .1.3.6.1.4.1.2021.11

4.重新啟動 snmpd,並檢視是否可被外部存取。

$ sudo /etc/init.d/snmpd start
$ netstat -nalu

Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
udp        0      0 192.168.0.10:53        0.0.0.0:*
udp        0      0 127.0.0.1:53            0.0.0.0:*
udp        0      0 0.0.0.0:161             0.0.0.0:*
udp        0      0 0.0.0.0:51011           0.0.0.0:*
udp6       0      0 :::53                   :::*

接下來便是在 Cacti Server 上進行:

1.先將 ssh-dns-bind95-stats.pl 複製到 Cacti Server 上的 /var/www/html/scrips/AF 底下。CactiEZ 預設的網頁路徑為 /var/www/html,AF 目錄要新建

# mkdir /var/www/html/scripts/AF
# cp ssh-dns-bind95-stats.pl /var/www/html/scripts/AF
# chown apache.apache /var/www/html/scripts/AF -R
# chmod +x /var/www/html/scripts/AF/ssh-dns-bind95-stats.pl

2.編輯 ssh-dns-bind95-stats.pl,要填入及修改一些資訊:

#!/usr/bin/perl


# Local SSH config
my $hostname = "" ;
my $user = "" ;

my $ssh_bin = "/usr/bin/ssh" ;
my $ssh_opt = "" ;

# Remote BIND config
my $named_stats = "/var/cache/bind/named.stats" ;
my $named_ndc = "/usr/sbin/rndc" ;


3.確認 Cacti Server 與 DNS Server 之間的 SSH 是不用密碼的。執行一下 ssh-dns-bind95-stats.pl,看是否可正常運作。

# /var/www/html/scripts/AF/ssh-dns-bind95-stats.pl -h dns -u root
A:987 AAAA:511 ANY:1 AXFR:0 CNAME:0 IXFR:0 MX:161 NS:7 PTR:232 SOA:0 SRV:0 TXT:22 success:2006 nonauthoritative:706 errors:35 nxdomain:43 recursion:184 dropped:0

登入 Cacti 管理介面,進行下列的動作:

1.匯入樣版:
 到 {console}→[Inport Templates],點選右上角的「瀏覽...」,將「cacti_host_template_af-dns-bind_9_5.xml」選入,再按下「Save」來進行匯入的動作。
Cacti透過Data Input Method抓取Ubun

 它會列出加了些什麼東西在哪些地方。
Cacti透過Data Input Method抓取Ubun

2.在要監控的 DNS Server 立關聯圖形樣版:
 到 {console}→[Devices] 點選「dns」(本例的 DNS Server),在【Associated Graph Templates】的「Add Graph Template」中挑選「AF-1-ssh-dns-bind9.5-stats-Queries by Minutes by Types」及「AF-3-ssh-dns-bind9.5-stats-Queries & Answers」,按下「Add」來完成選取。
Cacti透過Data Input Method抓取Ubun
Cacti透過Data Input Method抓取Ubun

 點選右上角的「Create Graphs for this Host
Cacti透過Data Input Method抓取Ubun

 在 Graph Templates 將「Create: AF-1-ssh-dns-bind9.5-stats-Queries by Minutes by Types」及「Create: AF-3-ssh-dns-bind9.5-stats-Queries & Answers」都勾選,按下「Create」來產生。
Cacti透過Data Input Method抓取Ubun

 將兩個 user 的欄位值改成「root」,按下「Create」來儲存設定。
Cacti透過Data Input Method抓取Ubun

 看到反灰就代表已經建好了。
Cacti透過Data Input Method抓取Ubun

 回到上一層,也可以看到這兩個的「Status」值為「Is Being Graped(Edit)」。
Cacti透過Data Input Method抓取Ubun

3.過一陣子再去 {graphs} 看,就可以出現如下的圖了。
Cacti透過Data Input Method抓取Ubun

20110323

arrow
arrow
    創作者介紹
    創作者 游蜂 的頭像
    游蜂

    暉獲無度的步烙閣

    游蜂 發表在 痞客邦 留言(0) 人氣()