YAMAHA NVR500をCentOS7にインストールしたMRTGで負荷監視する設定


YAMAHA NVR500をCentOS7にインストールしたMRTGで負荷監視する設定YAMAHA NVR500をCentOS7にインストールしたMRTGで負荷監視する設定

設定メモ

■参考
CentOS7で作るネットワークサーバ構築ガイドを参考

■環境例
ルータのIPを192.168.1.1とする
MRTGを入れるサーバのIPを192.168.1.166とする

[root@localhost ~]# cat /etc/redhat-release 
CentOS Linux release 7.1.1503 (Core) 

■CentOS7のサーバにMRTGをインストール

[root@localhost ~]# yum install mrtg

■コンフィグ設定

[root@localhost ~]# cfgmaker --out=/etc/mrtg/mrtg.cfg --global "workdir: /var/www/mrtg" --global "Language:eucjp" public@192.168.1.1
Use of uninitialized value $t in substitution (s///) at /bin/cfgmaker line 1375.
Use of uninitialized value $t in substitution (s///) at /bin/cfgmaker line 1376.
Use of uninitialized value $t in substitution (s///) at /bin/cfgmaker line 1377.
Use of uninitialized value $fs in pattern match (m//) at /bin/cfgmaker line 1382.
Use of uninitialized value $t in hash element at /bin/cfgmaker line 1383.
Use of uninitialized value $t in substitution (s///) at /bin/cfgmaker line 1375.
Use of uninitialized value $t in substitution (s///) at /bin/cfgmaker line 1376.
Use of uninitialized value $t in substitution (s///) at /bin/cfgmaker line 1377.
Use of uninitialized value $fs in pattern match (m//) at /bin/cfgmaker line 1382.
Use of uninitialized value $t in hash element at /bin/cfgmaker line 1383.
--base: Get Device Info on public@192.168.1.1:
SNMP Error:
no response received
SNMPv1_Session (remote host: "192.168.1.1" [192.168.1.1].161)
                  community: "public"
                 request ID: 132523945
                PDU bufsize: 8000 bytes
                    timeout: 2s
                    retries: 5
                    backoff: 1)
 at /usr/bin/../lib64/mrtg2/SNMP_util.pm line 651.
SNMPWALK Problem for 1.3.6.1.2.1.1 on public@192.168.1.1::::::v4only
 at /bin/cfgmaker line 951.
WARNING: Skipping public@192.168.1.1: as no info could be retrieved

Use of uninitialized value $comment_sysdescr in substitution (s///) at /bin/cfgmaker line 379.
Use of uninitialized value $sysname in concatenation (.) or string at /bin/cfgmaker line 412.
Use of uninitialized value $comment_sysdescr in concatenation (.) or string at /bin/cfgmaker line 412.
Use of uninitialized value $syscontact in concatenation (.) or string at /bin/cfgmaker line 412.
Use of uninitialized value $syslocation in concatenation (.) or string at /bin/cfgmaker line 412.
--base: Writing /etc/mrtg/mrtg.cfg

■エラーが出たのでルータ側でSNMPをざっくり有効化

NVR500の管理画面から実行したコマンド
snmp host any
snmp community read-only public
※これはざっくり設定なのでちゃんと制限したりしたほうが良いと思われます。

■もう一度コンフィグの設定

[root@localhost ~]# cfgmaker --out=/etc/mrtg/mrtg.cfg --global "workdir: /var/www/mrtg" --global "Language:eucjp" public@192.168.1.1
Use of uninitialized value $t in substitution (s///) at /bin/cfgmaker line 1375.
Use of uninitialized value $t in substitution (s///) at /bin/cfgmaker line 1376.
Use of uninitialized value $t in substitution (s///) at /bin/cfgmaker line 1377.
Use of uninitialized value $fs in pattern match (m//) at /bin/cfgmaker line 1382.
Use of uninitialized value $t in hash element at /bin/cfgmaker line 1383.
Use of uninitialized value $t in substitution (s///) at /bin/cfgmaker line 1375.
Use of uninitialized value $t in substitution (s///) at /bin/cfgmaker line 1376.
Use of uninitialized value $t in substitution (s///) at /bin/cfgmaker line 1377.
Use of uninitialized value $fs in pattern match (m//) at /bin/cfgmaker line 1382.
Use of uninitialized value $t in hash element at /bin/cfgmaker line 1383.
--base: Get Device Info on public@192.168.1.1:
--base: Vendor Id: Unknown Vendor - 1.3.6.1.4.1.1182.1.40
--base: Populating confcache
--base: Get Interface Info
--base: Walking ifIndex
--snpd:   public@192.168.1.1: -> 1 -> ifIndex = 1
--snpd:   public@192.168.1.1: -> 2 -> ifIndex = 2
--snpd:   public@192.168.1.1: -> 3 -> ifIndex = 3
--snpd:   public@192.168.1.1: -> 4 -> ifIndex = 4
--snpd:   public@192.168.1.1: -> 52 -> ifIndex = 52
--snpd:   public@192.168.1.1: -> 53 -> ifIndex = 53
--snpd:   public@192.168.1.1: -> 54 -> ifIndex = 54
--snpd:   public@192.168.1.1: -> 55 -> ifIndex = 55
--snpd:   public@192.168.1.1: -> 56 -> ifIndex = 56
--snpd:   public@192.168.1.1: -> 57 -> ifIndex = 57
--snpd:   public@192.168.1.1: -> 58 -> ifIndex = 58
--snpd:   public@192.168.1.1: -> 59 -> ifIndex = 59
--snpd:   public@192.168.1.1: -> 60 -> ifIndex = 60
--snpd:   public@192.168.1.1: -> 61 -> ifIndex = 61
--base: Walking ifType
--snpd:   public@192.168.1.1: -> 1 -> ifType = 6
--snpd:   public@192.168.1.1: -> 2 -> ifType = 6
--snpd:   public@192.168.1.1: -> 3 -> ifType = 1
--snpd:   public@192.168.1.1: -> 4 -> ifType = 20
--snpd:   public@192.168.1.1: -> 52 -> ifType = 24
--snpd:   public@192.168.1.1: -> 53 -> ifType = 24
--snpd:   public@192.168.1.1: -> 54 -> ifType = 24
--snpd:   public@192.168.1.1: -> 55 -> ifType = 24
--snpd:   public@192.168.1.1: -> 56 -> ifType = 24
--snpd:   public@192.168.1.1: -> 57 -> ifType = 24
--snpd:   public@192.168.1.1: -> 58 -> ifType = 24
--snpd:   public@192.168.1.1: -> 59 -> ifType = 24
--snpd:   public@192.168.1.1: -> 60 -> ifType = 24
--snpd:   public@192.168.1.1: -> 61 -> ifType = 24
--base: Walking ifAdminStatus
--snpd:   public@192.168.1.1: -> 1 -> ifAdminStatus = 1
--snpd:   public@192.168.1.1: -> 2 -> ifAdminStatus = 1
--snpd:   public@192.168.1.1: -> 3 -> ifAdminStatus = 1
--snpd:   public@192.168.1.1: -> 4 -> ifAdminStatus = 1
--snpd:   public@192.168.1.1: -> 52 -> ifAdminStatus = 1
--snpd:   public@192.168.1.1: -> 53 -> ifAdminStatus = 1
--snpd:   public@192.168.1.1: -> 54 -> ifAdminStatus = 1
--snpd:   public@192.168.1.1: -> 55 -> ifAdminStatus = 1
--snpd:   public@192.168.1.1: -> 56 -> ifAdminStatus = 1
--snpd:   public@192.168.1.1: -> 57 -> ifAdminStatus = 1
--snpd:   public@192.168.1.1: -> 58 -> ifAdminStatus = 1
--snpd:   public@192.168.1.1: -> 59 -> ifAdminStatus = 1
--snpd:   public@192.168.1.1: -> 60 -> ifAdminStatus = 1
--snpd:   public@192.168.1.1: -> 61 -> ifAdminStatus = 1
--base: Walking ifOperStatus
--snpd:   public@192.168.1.1: -> 1 -> ifOperStatus = 1
--snpd:   public@192.168.1.1: -> 2 -> ifOperStatus = 1
--snpd:   public@192.168.1.1: -> 3 -> ifOperStatus = 2
--snpd:   public@192.168.1.1: -> 4 -> ifOperStatus = 2
--snpd:   public@192.168.1.1: -> 52 -> ifOperStatus = 1
--snpd:   public@192.168.1.1: -> 53 -> ifOperStatus = 1
--snpd:   public@192.168.1.1: -> 54 -> ifOperStatus = 1
--snpd:   public@192.168.1.1: -> 55 -> ifOperStatus = 1
--snpd:   public@192.168.1.1: -> 56 -> ifOperStatus = 1
--snpd:   public@192.168.1.1: -> 57 -> ifOperStatus = 1
--snpd:   public@192.168.1.1: -> 58 -> ifOperStatus = 1
--snpd:   public@192.168.1.1: -> 59 -> ifOperStatus = 1
--snpd:   public@192.168.1.1: -> 60 -> ifOperStatus = 1
--snpd:   public@192.168.1.1: -> 61 -> ifOperStatus = 1
--base: Walking ifMtu
--snpd:   public@192.168.1.1: -> 1 -> ifMtu = 1500
--snpd:   public@192.168.1.1: -> 2 -> ifMtu = 1500
--snpd:   public@192.168.1.1: -> 3 -> ifMtu = 1500
--snpd:   public@192.168.1.1: -> 4 -> ifMtu = 1500
--snpd:   public@192.168.1.1: -> 52 -> ifMtu = 65535
--snpd:   public@192.168.1.1: -> 53 -> ifMtu = 65535
--snpd:   public@192.168.1.1: -> 54 -> ifMtu = 65535
--snpd:   public@192.168.1.1: -> 55 -> ifMtu = 65535
--snpd:   public@192.168.1.1: -> 56 -> ifMtu = 65535
--snpd:   public@192.168.1.1: -> 57 -> ifMtu = 65535
--snpd:   public@192.168.1.1: -> 58 -> ifMtu = 65535
--snpd:   public@192.168.1.1: -> 59 -> ifMtu = 65535
--snpd:   public@192.168.1.1: -> 60 -> ifMtu = 65535
--snpd:   public@192.168.1.1: -> 61 -> ifMtu = 65535
--base: Walking ifSpeed
--snpd:   public@192.168.1.1: -> 1 -> ifSpeed = 1000000000
--snpd:   public@192.168.1.1: -> 2 -> ifSpeed = 100000000
--snpd:   public@192.168.1.1: -> 3 -> ifSpeed = 64000
--snpd:   public@192.168.1.1: -> 4 -> ifSpeed = 128000
--snpd:   public@192.168.1.1: -> 52 -> ifSpeed = 100000000
--snpd:   public@192.168.1.1: -> 53 -> ifSpeed = 100000000
--snpd:   public@192.168.1.1: -> 54 -> ifSpeed = 100000000
--snpd:   public@192.168.1.1: -> 55 -> ifSpeed = 100000000
--snpd:   public@192.168.1.1: -> 56 -> ifSpeed = 100000000
--snpd:   public@192.168.1.1: -> 57 -> ifSpeed = 100000000
--snpd:   public@192.168.1.1: -> 58 -> ifSpeed = 100000000
--snpd:   public@192.168.1.1: -> 59 -> ifSpeed = 100000000
--snpd:   public@192.168.1.1: -> 60 -> ifSpeed = 100000000
--snpd:   public@192.168.1.1: -> 61 -> ifSpeed = 100000000
--base: Writing /etc/mrtg/mrtg.cfg

■mrtgコマンドの実行

[root@localhost ~]# LANG=ja_JP.eucJP mrtg /etc/mrtg/mrtg.cfg
2015-06-15 11:05:29, Rateup WARNING: /usr/bin/rateup could not read the primary log file for 192.168.1.1_1
2015-06-15 11:05:29, Rateup WARNING: /usr/bin/rateup The backup log file for 192.168.1.1_1 was invalid as well
2015-06-15 11:05:29, Rateup WARNING: /usr/bin/rateup Can't rename 192.168.1.1_1.log to 192.168.1.1_1.old updating log file
2015-06-15 11:05:29, Rateup WARNING: /usr/bin/rateup could not read the primary log file for 192.168.1.1_2
2015-06-15 11:05:29, Rateup WARNING: /usr/bin/rateup The backup log file for 192.168.1.1_2 was invalid as well
2015-06-15 11:05:29, Rateup WARNING: /usr/bin/rateup Can't rename 192.168.1.1_2.log to 192.168.1.1_2.old updating log file
[root@localhost ~]# LANG=ja_JP.eucJP mrtg /etc/mrtg/mrtg.cfg
[root@localhost ~]# LANG=ja_JP.eucJP mrtg /etc/mrtg/mrtg.cfg

■mrtg.confの設定を変更しローカルエリアから見えるようにする。
※あとEUC-JPで正しく表示できるようにoffにしておく

[root@localhost conf.d]# pwd
/etc/httpd/conf.d
[root@localhost conf.d]# vim mrtg.conf 
<Location /mrtg>
    Require local
    Require ip 192.168.1.0/24
    AddDefaultCharset off
    # Require host example.org
</Location>

■グラフの右端が最新になるようにする。また単位をビットにする

[root@localhost mrtg]# vim /etc/mrtg/mrtg.cfg
#Options[_]: growright, bits

↓

Options[_]: growright, bits

■インデックスファイルの作成

[root@localhost ~]# indexmaker /etc/mrtg/mrtg.cfg > /var/www/mrtg/index.html

今回の場合は以下のURLで表示されるはず
http://192.168.1.166/mrtg/

■cronの設定(5分毎)

[root@localhost ~]# vim /etc/cron.d/mrtg
[root@localhost ~]# cat /etc/cron.d/mrtg
*/5 * * * * root LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です