UJP - 技術情報2 : macOS High SierraにMRTGを設定 MacOSX/HigiSierra/mrtg

Life is fun and easy!

不正IP報告数

Okan Sensor
 
メイン
ログイン
ブログ カテゴリ一覧

Page Top

はじめに anchor.png Edit

 MRTGとは,マルチルータトラフィックグラファーの略.ルータのIN/OUTトラフィックをグラフ化するツールで,古典的なもの.たくさんのサーバを管理するにはZabbixなどが良いのだろうけれど,今回もシンプルに構築するので,MRTGを選んだ.

Page Top

インストール anchor.png Edit

 インストールはHomeBrewでおこなった.特に問題もなかった.

$ brew info mrtg🆑
mrtg: stable 2.17.7 (bottled)🈁
Multi router traffic grapher
https://oss.oetiker.ch/mrtg/
/usr/local/Cellar/mrtg/2.17.7 (110 files, 2.4MB) *
  Poured from bottle on 2019-05-07 at 00:48:32
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/mrtg.rb
==> Dependencies
Required: gd ✔
==> Analytics
install: 30 (30 days), 76 (90 days), 458 (365 days)
install_on_request: 26 (30 days), 69 (90 days), 381 (365 days)
build_error: 0 (30 days)
$

 インストールされたか,コマンドの場所を確認.  まずは,mrtgコマンド.

$ which mrtg🆑
/usr/local/bin/mrtg🈁
$

 そして,設定ファイルを自動的に作成してくれる,cfgmakerの場所を確認.

$ which cfgmaker🆑
/usr/local/bin/cfgmaker🈁
$
Page Top

初期設定 anchor.png Edit

 まずは,SNMPD.CONFにあるコミュニティ名を確認.

$ grep com2sec /etc/snmp/snmpd.conf🆑
com2sec local     localhost       private🈁
com2sec mynetwork NETWORK/24      public
$

 "private"だとわかった.  cfgmakerコマンドを指定し,privateコミュニティの初期設定を行う.

$ cfgmaker private@localhost > mrtg.cfg🆑
Subroutine SNMP_Session::pack_sockaddr_in6 redefined at /System/Library/Perl/5.18/Exporter.pm
line 66.  at /usr/local/bin/../lib/mrtg2/SNMP_Session.pm line 149.
Subroutine SNMPv1_Session::pack_sockaddr_in6 redefined at /System/Library/Perl/5.18/Exporter.pm
line 66.  at /usr/local/bin/../lib/mrtg2/SNMP_Session.pm line 604.
--base: Get Device Info on private@localhost:
--base: Vendor Id: Unknown Vendor - 1.3.6.1.4.1.8072.3.2.255
--base: Populating confcache
--base: Get Interface Info
--base: Walking ifIndex
--snpd:   private@localhost: -> 1 -> ifIndex = 1
--snpd:   private@localhost: -> 2 -> ifIndex = 2
--snpd:   private@localhost: -> 3 -> ifIndex = 3
--snpd:   private@localhost: -> 4 -> ifIndex = 4
--snpd:   private@localhost: -> 5 -> ifIndex = 5
--snpd:   private@localhost: -> 6 -> ifIndex = 6
--snpd:   private@localhost: -> 7 -> ifIndex = 7
--snpd:   private@localhost: -> 8 -> ifIndex = 8
--snpd:   private@localhost: -> 9 -> ifIndex = 9
--snpd:   private@localhost: -> 10 -> ifIndex = 10
--snpd:   private@localhost: -> 11 -> ifIndex = 11
--snpd:   private@localhost: -> 12 -> ifIndex = 12
--base: Walking ifType
--snpd:   private@localhost: -> 1 -> ifType = 24
--snpd:   private@localhost: -> 2 -> ifType = 55
--snpd:   private@localhost: -> 3 -> ifType = 57
--snpd:   private@localhost: -> 4 -> ifType = 1
--snpd:   private@localhost: -> 5 -> ifType = 1
--snpd:   private@localhost: -> 6 -> ifType = 6
--snpd:   private@localhost: -> 7 -> ifType = 6
--snpd:   private@localhost: -> 8 -> ifType = 6
--snpd:   private@localhost: -> 9 -> ifType = 6
--snpd:   private@localhost: -> 10 -> ifType = 209
--snpd:   private@localhost: -> 11 -> ifType = 1
--snpd:   private@localhost: -> 12 -> ifType = 23
--base: Walking ifAdminStatus
--snpd:   private@localhost: -> 1 -> ifAdminStatus = 1
--snpd:   private@localhost: -> 2 -> ifAdminStatus = 2
--snpd:   private@localhost: -> 3 -> ifAdminStatus = 2
--snpd:   private@localhost: -> 4 -> ifAdminStatus = 2
--snpd:   private@localhost: -> 5 -> ifAdminStatus = 2
--snpd:   private@localhost: -> 6 -> ifAdminStatus = 1
--snpd:   private@localhost: -> 7 -> ifAdminStatus = 1
--snpd:   private@localhost: -> 8 -> ifAdminStatus = 2
--snpd:   private@localhost: -> 9 -> ifAdminStatus = 1
--snpd:   private@localhost: -> 10 -> ifAdminStatus = 1
--snpd:   private@localhost: -> 11 -> ifAdminStatus = 1
--snpd:   private@localhost: -> 12 -> ifAdminStatus = 1
--base: Walking ifOperStatus
--snpd:   private@localhost: -> 1 -> ifOperStatus = 1
--snpd:   private@localhost: -> 2 -> ifOperStatus = 2
--snpd:   private@localhost: -> 3 -> ifOperStatus = 2
--snpd:   private@localhost: -> 4 -> ifOperStatus = 2
--snpd:   private@localhost: -> 5 -> ifOperStatus = 2
--snpd:   private@localhost: -> 6 -> ifOperStatus = 1
--snpd:   private@localhost: -> 7 -> ifOperStatus = 2
--snpd:   private@localhost: -> 8 -> ifOperStatus = 2
--snpd:   private@localhost: -> 9 -> ifOperStatus = 1
--snpd:   private@localhost: -> 10 -> ifOperStatus = 1
--snpd:   private@localhost: -> 11 -> ifOperStatus = 1
--snpd:   private@localhost: -> 12 -> ifOperStatus = 1
--base: Walking ifMtu
--snpd:   private@localhost: -> 1 -> ifMtu = 16384
--snpd:   private@localhost: -> 2 -> ifMtu = 1280
--snpd:   private@localhost: -> 3 -> ifMtu = 1280
--snpd:   private@localhost: -> 4 -> ifMtu = 0
--snpd:   private@localhost: -> 5 -> ifMtu = 0
--snpd:   private@localhost: -> 6 -> ifMtu = 1500
--snpd:   private@localhost: -> 7 -> ifMtu = 1500
--snpd:   private@localhost: -> 8 -> ifMtu = 2304
--snpd:   private@localhost: -> 9 -> ifMtu = 1500
--snpd:   private@localhost: -> 10 -> ifMtu = 1500
--snpd:   private@localhost: -> 11 -> ifMtu = 2000
--snpd:   private@localhost: -> 12 -> ifMtu = 1280
--base: Walking ifSpeed
--snpd:   private@localhost: -> 1 -> ifSpeed = 0
--snpd:   private@localhost: -> 2 -> ifSpeed = 0
--snpd:   private@localhost: -> 3 -> ifSpeed = 0
--snpd:   private@localhost: -> 4 -> ifSpeed = 0
--snpd:   private@localhost: -> 5 -> ifSpeed = 0
--snpd:   private@localhost: -> 6 -> ifSpeed = 1000000000
--snpd:   private@localhost: -> 7 -> ifSpeed = 0
--snpd:   private@localhost: -> 8 -> ifSpeed = 10000000
--snpd:   private@localhost: -> 9 -> ifSpeed = 0
--snpd:   private@localhost: -> 10 -> ifSpeed = 0
--snpd:   private@localhost: -> 11 -> ifSpeed = 0
--snpd:   private@localhost: -> 12 -> ifSpeed = 100000000
$

 自動作成された設定ファイルを確認.

$ cat mrtg.cfg🆑
# Created by
# /usr/local/bin/cfgmaker private@localhost


### Global Config Options

#  for UNIX
# WorkDir: /home/http/mrtg

#  or for NT
# WorkDir: c:\mrtgdata

### Global Defaults

#  to get bits instead of bytes and graphs growing to the right
# Options[_]: growright, bits

EnableIPv6: no

######################################################################
# System: zeus.local
# Description: Darwin zeus.local 17.7.0 Darwin Kernel Version 17.7.0:
Wed Feb 27 00:43:23 PST 2019; root:xnu-4570.71.35~1/RELEASE_X86_64 x86_64
# Contact: サーバ管理者メールアドレス
# Location: BCP
######################################################################


### Interface 1 >> Descr: 'lo0' | Name: 'lo0' | Ip: '127.0.0.1' | Eth: 'No Ethernet Id' ###
### The following interface is commented out because:
### * it is a Software Loopback interface
### * has no ifSpeed property
#
# Target[localhost_1]: 1:private@localhost:
# SetEnv[localhost_1]: MRTG_INT_IP="127.0.0.1" MRTG_INT_DESCR="lo0"
# MaxBytes[localhost_1]: 0
# Title[localhost_1]: Traffic Analysis for 1 -- zeus.local
# PageTop[localhost_1]: <h1>Traffic Analysis for 1 -- zeus.local</h1>
# 		<div id="sysdetails">
# 			<table>
# 				<tr>
# 					<td>System:</td>
# 					<td>zeus.local in BCP</td>
# 				</tr>
# 				<tr>
# 					<td>Maintainer:</td>
# 					<td>サーバ管理者メールアドレス</td>
# 				</tr>
# 				<tr>
# 					<td>Description:</td>
# 					<td>lo0  </td>
# 				</tr>
# 				<tr>
# 					<td>ifType:</td>
# 					<td>softwareLoopback (24)</td>
# 				</tr>
# 				<tr>
# 					<td>ifName:</td>
# 					<td>lo0</td>
# 				</tr>
# 				<tr>
# 					<td>Max Speed:</td>
# 					<td>0.0 Bytes/s</td>
# 				</tr>
# 				<tr>
# 					<td>Ip:</td>
# 					<td>127.0.0.1 (localhost)</td>
# 				</tr>
# 			</table>
# 		</div>


### Interface 2 >> Descr: 'gif0' | Name: 'gif0' | Ip: 'No Ip' | Eth: 'No Ethernet Id' ###
### The following interface is commented out because:
### * it is administratively DOWN
### * it is operationally DOWN
### * has no ifSpeed property
#
# Target[localhost_2]: 2:private@localhost:
# SetEnv[localhost_2]: MRTG_INT_IP="No Ip" MRTG_INT_DESCR="gif0"
# MaxBytes[localhost_2]: 0
# Title[localhost_2]: Traffic Analysis for 2 -- zeus.local
# PageTop[localhost_2]: <h1>Traffic Analysis for 2 -- zeus.local</h1>
# 		<div id="sysdetails">
# 			<table>
# 				<tr>
# 					<td>System:</td>
# 					<td>zeus.local in BCP</td>
# 				</tr>
# 				<tr>
# 					<td>Maintainer:</td>
# 					<td>server@ujp.jp</td>
# 				</tr>
# 				<tr>
# 					<td>Description:</td>
# 					<td>gif0  </td>
# 				</tr>
# 				<tr>
# 					<td>ifType:</td>
# 					<td>100BaseVG (55)</td>
# 				</tr>
# 				<tr>
# 					<td>ifName:</td>
# 					<td>gif0</td>
# 				</tr>
# 				<tr>
# 					<td>Max Speed:</td>
# 					<td>0.0 Bytes/s</td>
# 				</tr>
# 				<tr>
# 					<td>Ip:</td>
# 					<td>No Ip (No DNS name)</td>
# 				</tr>
# 			</table>
# 		</div>


### Interface 3 >> Descr: 'stf0' | Name: 'stf0' | Ip: 'No Ip' | Eth: 'No Ethernet Id' ###
### The following interface is commented out because:
### * it is administratively DOWN
### * it is operationally DOWN
### * has no ifSpeed property
#
# Target[localhost_3]: 3:private@localhost:
# SetEnv[localhost_3]: MRTG_INT_IP="No Ip" MRTG_INT_DESCR="stf0"
# MaxBytes[localhost_3]: 0
# Title[localhost_3]: Traffic Analysis for 3 -- zeus.local
# PageTop[localhost_3]: <h1>Traffic Analysis for 3 -- zeus.local</h1>
# 		<div id="sysdetails">
# 			<table>
# 				<tr>
# 					<td>System:</td>
# 					<td>zeus.local in BCP</td>
# 				</tr>
# 				<tr>
# 					<td>Maintainer:</td>
# 					<td>server@ujp.jp</td>
# 				</tr>
# 				<tr>
# 					<td>Description:</td>
# 					<td>stf0  </td>
# 				</tr>
# 				<tr>
# 					<td>ifType:</td>
# 					<td>HIPPI Interface (57)</td>
# 				</tr>
# 				<tr>
# 					<td>ifName:</td>
# 					<td>stf0</td>
# 				</tr>
# 				<tr>
# 					<td>Max Speed:</td>
# 					<td>0.0 Bytes/s</td>
# 				</tr>
# 				<tr>
# 					<td>Ip:</td>
# 					<td>No Ip (No DNS name)</td>
# 				</tr>
# 			</table>
# 		</div>


### Interface 4 >> Descr: 'EHC253' | Name: 'EHC253' | Ip: 'No Ip' | Eth: 'No Ethernet Id' ###
### The following interface is commented out because:
### * it is administratively DOWN
### * it is operationally DOWN
### * has no ifSpeed property
#
# Target[localhost_4]: 4:private@localhost:
# SetEnv[localhost_4]: MRTG_INT_IP="No Ip" MRTG_INT_DESCR="EHC253"
# MaxBytes[localhost_4]: 0
# Title[localhost_4]: Traffic Analysis for 4 -- zeus.local
# PageTop[localhost_4]: <h1>Traffic Analysis for 4 -- zeus.local</h1>
# 		<div id="sysdetails">
# 			<table>
# 				<tr>
# 					<td>System:</td>
# 					<td>zeus.local in BCP</td>
# 				</tr>
# 				<tr>
# 					<td>Maintainer:</td>
# 					<td>server@ujp.jp</td>
# 				</tr>
# 				<tr>
# 					<td>Description:</td>
# 					<td>EHC253  </td>
# 				</tr>
# 				<tr>
# 					<td>ifType:</td>
# 					<td>Other (1)</td>
# 				</tr>
# 				<tr>
# 					<td>ifName:</td>
# 					<td>EHC253</td>
# 				</tr>
# 				<tr>
# 					<td>Max Speed:</td>
# 					<td>0.0 Bytes/s</td>
# 				</tr>
# 				<tr>
# 					<td>Ip:</td>
# 					<td>No Ip (No DNS name)</td>
# 				</tr>
# 			</table>
# 		</div>


### Interface 5 >> Descr: 'EHC250' | Name: 'EHC250' | Ip: 'No Ip' | Eth: 'No Ethernet Id' ###
### The following interface is commented out because:
### * it is administratively DOWN
### * it is operationally DOWN
### * has no ifSpeed property
#
# Target[localhost_5]: 5:private@localhost:
# SetEnv[localhost_5]: MRTG_INT_IP="No Ip" MRTG_INT_DESCR="EHC250"
# MaxBytes[localhost_5]: 0
# Title[localhost_5]: Traffic Analysis for 5 -- zeus.local
# PageTop[localhost_5]: <h1>Traffic Analysis for 5 -- zeus.local</h1>
# 		<div id="sysdetails">
# 			<table>
# 				<tr>
# 					<td>System:</td>
# 					<td>zeus.local in BCP</td>
# 				</tr>
# 				<tr>
# 					<td>Maintainer:</td>
# 					<td>server@ujp.jp</td>
# 				</tr>
# 				<tr>
# 					<td>Description:</td>
# 					<td>EHC250  </td>
# 				</tr>
# 				<tr>
# 					<td>ifType:</td>
# 					<td>Other (1)</td>
# 				</tr>
# 				<tr>
# 					<td>ifName:</td>
# 					<td>EHC250</td>
# 				</tr>
# 				<tr>
# 					<td>Max Speed:</td>
# 					<td>0.0 Bytes/s</td>
# 				</tr>
# 				<tr>
# 					<td>Ip:</td>
# 					<td>No Ip (No DNS name)</td>
# 				</tr>
# 			</table>
# 		</div>


### Interface 6 >> Descr: 'en3' | Name: 'en3' | Ip: '192.168.100.10' | Eth: '00-6c-8f-44-8a-32' ###

Target[localhost_6]: 6:private@localhost:
SetEnv[localhost_6]: MRTG_INT_IP="192.168.100.10" MRTG_INT_DESCR="en3"
MaxBytes[localhost_6]: 125000000
Title[localhost_6]: Traffic Analysis for 6 -- zeus.local
PageTop[localhost_6]: <h1>Traffic Analysis for 6 -- zeus.local</h1>
		<div id="sysdetails">
			<table>
				<tr>
					<td>System:</td>
					<td>zeus.local in BCP</td>
				</tr>
				<tr>
					<td>Maintainer:</td>
					<td>server@ujp.jp</td>
				</tr>
				<tr>
					<td>Description:</td>
					<td>en3  </td>
				</tr>
				<tr>
					<td>ifType:</td>
					<td>ethernetCsmacd (6)</td>
				</tr>
				<tr>
					<td>ifName:</td>
					<td>en3</td>
				</tr>
				<tr>
					<td>Max Speed:</td>
					<td>125.0 MBytes/s</td>
				</tr>
				<tr>
					<td>Ip:</td>
					<td>192.168.100.10 (No DNS name)</td>
				</tr>
			</table>
		</div>


### Interface 7 >> Descr: 'en0' | Name: 'en0' | Ip: 'No Ip' | Eth: 'No Ethernet Id' ###
### The following interface is commented out because:
### * it is operationally DOWN
### * has no ifSpeed property
#
# Target[localhost_7]: 7:private@localhost:
# SetEnv[localhost_7]: MRTG_INT_IP="No Ip" MRTG_INT_DESCR="en0"
# MaxBytes[localhost_7]: 0
# Title[localhost_7]: Traffic Analysis for 7 -- zeus.local
# PageTop[localhost_7]: <h1>Traffic Analysis for 7 -- zeus.local</h1>
# 		<div id="sysdetails">
# 			<table>
# 				<tr>
# 					<td>System:</td>
# 					<td>zeus.local in BCP</td>
# 				</tr>
# 				<tr>
# 					<td>Maintainer:</td>
# 					<td>server@ujp.jp</td>
# 				</tr>
# 				<tr>
# 					<td>Description:</td>
# 					<td>en0  </td>
# 				</tr>
# 				<tr>
# 					<td>ifType:</td>
# 					<td>ethernetCsmacd (6)</td>
# 				</tr>
# 				<tr>
# 					<td>ifName:</td>
# 					<td>en0</td>
# 				</tr>
# 				<tr>
# 					<td>Max Speed:</td>
# 					<td>0.0 Bytes/s</td>
# 				</tr>
# 				<tr>
# 					<td>Ip:</td>
# 					<td>No Ip (No DNS name)</td>
# 				</tr>
# 			</table>
# 		</div>


### Interface 8 >> Descr: 'p2p0' | Name: 'p2p0' | Ip: 'No Ip' | Eth: 'No Ethernet Id' ###
### The following interface is commented out because:
### * it is administratively DOWN
### * it is operationally DOWN
#
# Target[localhost_8]: 8:private@localhost:
# SetEnv[localhost_8]: MRTG_INT_IP="No Ip" MRTG_INT_DESCR="p2p0"
# MaxBytes[localhost_8]: 1250000
# Title[localhost_8]: Traffic Analysis for 8 -- zeus.local
# PageTop[localhost_8]: <h1>Traffic Analysis for 8 -- zeus.local</h1>
# 		<div id="sysdetails">
# 			<table>
# 				<tr>
# 					<td>System:</td>
# 					<td>zeus.local in BCP</td>
# 				</tr>
# 				<tr>
# 					<td>Maintainer:</td>
# 					<td>server@ujp.jp</td>
# 				</tr>
# 				<tr>
# 					<td>Description:</td>
# 					<td>p2p0  </td>
# 				</tr>
# 				<tr>
# 					<td>ifType:</td>
# 					<td>ethernetCsmacd (6)</td>
# 				</tr>
# 				<tr>
# 					<td>ifName:</td>
# 					<td>p2p0</td>
# 				</tr>
# 				<tr>
# 					<td>Max Speed:</td>
# 					<td>1250.0 kBytes/s</td>
# 				</tr>
# 				<tr>
# 					<td>Ip:</td>
# 					<td>No Ip (No DNS name)</td>
# 				</tr>
# 			</table>
# 		</div>


### Interface 9 >> Descr: 'en1' | Name: 'en1' | Ip: 'No Ip' | Eth: 'No Ethernet Id' ###
### The following interface is commented out because:
### * has no ifSpeed property
#
# Target[localhost_9]: 9:private@localhost:
# SetEnv[localhost_9]: MRTG_INT_IP="No Ip" MRTG_INT_DESCR="en1"
# MaxBytes[localhost_9]: 0
# Title[localhost_9]: Traffic Analysis for 9 -- zeus.local
# PageTop[localhost_9]: <h1>Traffic Analysis for 9 -- zeus.local</h1>
# 		<div id="sysdetails">
# 			<table>
# 				<tr>
# 					<td>System:</td>
# 					<td>zeus.local in BCP</td>
# 				</tr>
# 				<tr>
# 					<td>Maintainer:</td>
# 					<td>server@ujp.jp</td>
# 				</tr>
# 				<tr>
# 					<td>Description:</td>
# 					<td>en1  </td>
# 				</tr>
# 				<tr>
# 					<td>ifType:</td>
# 					<td>ethernetCsmacd (6)</td>
# 				</tr>
# 				<tr>
# 					<td>ifName:</td>
# 					<td>en1</td>
# 				</tr>
# 				<tr>
# 					<td>Max Speed:</td>
# 					<td>0.0 Bytes/s</td>
# 				</tr>
# 				<tr>
# 					<td>Ip:</td>
# 					<td>No Ip (No DNS name)</td>
# 				</tr>
# 			</table>
# 		</div>


### Interface 10 >> Descr: 'bridge0' | Name: 'bridge0' | Ip: 'No Ip' | Eth: 'No Ethernet Id' ###
### The following interface is commented out because:
### * has no ifSpeed property
#
# Target[localhost_10]: 10:private@localhost:
# SetEnv[localhost_10]: MRTG_INT_IP="No Ip" MRTG_INT_DESCR="bridge0"
# MaxBytes[localhost_10]: 0
# Title[localhost_10]: Traffic Analysis for 10 -- zeus.local
# PageTop[localhost_10]: <h1>Traffic Analysis for 10 -- zeus.local</h1>
# 		<div id="sysdetails">
# 			<table>
# 				<tr>
# 					<td>System:</td>
# 					<td>zeus.local in BCP</td>
# 				</tr>
# 				<tr>
# 					<td>Maintainer:</td>
# 					<td>server@ujp.jp</td>
# 				</tr>
# 				<tr>
# 					<td>Description:</td>
# 					<td>bridge0  </td>
# 				</tr>
# 				<tr>
# 					<td>ifType:</td>
# 					<td>Uknown Interface Type (209)</td>
# 				</tr>
# 				<tr>
# 					<td>ifName:</td>
# 					<td>bridge0</td>
# 				</tr>
# 				<tr>
# 					<td>Max Speed:</td>
# 					<td>0.0 Bytes/s</td>
# 				</tr>
# 				<tr>
# 					<td>Ip:</td>
# 					<td>No Ip (No DNS name)</td>
# 				</tr>
# 			</table>
# 		</div>


### Interface 11 >> Descr: 'utun0' | Name: 'utun0' | Ip: 'No Ip' | Eth: 'No Ethernet Id' ###
### The following interface is commented out because:
### * has no ifSpeed property
#
# Target[localhost_11]: 11:private@localhost:
# SetEnv[localhost_11]: MRTG_INT_IP="No Ip" MRTG_INT_DESCR="utun0"
# MaxBytes[localhost_11]: 0
# Title[localhost_11]: Traffic Analysis for 11 -- zeus.local
# PageTop[localhost_11]: <h1>Traffic Analysis for 11 -- zeus.local</h1>
# 		<div id="sysdetails">
# 			<table>
# 				<tr>
# 					<td>System:</td>
# 					<td>zeus.local in BCP</td>
# 				</tr>
# 				<tr>
# 					<td>Maintainer:</td>
# 					<td>server@ujp.jp</td>
# 				</tr>
# 				<tr>
# 					<td>Description:</td>
# 					<td>utun0  </td>
# 				</tr>
# 				<tr>
# 					<td>ifType:</td>
# 					<td>Other (1)</td>
# 				</tr>
# 				<tr>
# 					<td>ifName:</td>
# 					<td>utun0</td>
# 				</tr>
# 				<tr>
# 					<td>Max Speed:</td>
# 					<td>0.0 Bytes/s</td>
# 				</tr>
# 				<tr>
# 					<td>Ip:</td>
# 					<td>No Ip (No DNS name)</td>
# 				</tr>
# 			</table>
# 		</div>


### Interface 12 >> Descr: 'ppp0' | Name: 'ppp0' | Ip: '192.168.20.231' | Eth: 'No Ethernet Id' ###

Target[localhost_12]: 12:private@localhost:
SetEnv[localhost_12]: MRTG_INT_IP="192.168.20.231" MRTG_INT_DESCR="ppp0"
MaxBytes[localhost_12]: 12500000
Title[localhost_12]: Traffic Analysis for 12 -- zeus.local
PageTop[localhost_12]: <h1>Traffic Analysis for 12 -- zeus.local</h1>
		<div id="sysdetails">
			<table>
				<tr>
					<td>System:</td>
					<td>zeus.local in BCP</td>
				</tr>
				<tr>
					<td>Maintainer:</td>
					<td>server@ujp.jp</td>
				</tr>
				<tr>
					<td>Description:</td>
					<td>ppp0  </td>
				</tr>
				<tr>
					<td>ifType:</td>
					<td>ppp (23)</td>
				</tr>
				<tr>
					<td>ifName:</td>
					<td>ppp0</td>
				</tr>
				<tr>
					<td>Max Speed:</td>
					<td>12.5 MBytes/s</td>
				</tr>
				<tr>
					<td>Ip:</td>
					<td>192.168.20.231 (No DNS name)</td>
				</tr>
			</table>
		</div>


$

 コメントアウトされている部分は,今回利用しないのでざっと削除.  今回利用するのは次のように設定.

$ cat mrtg.cfg🆑
### Global Config Options

#  for UNIX
WorkDir: /Users/ujpadmin/mrtg🈁


### Global Defaults

#  to get bits instead of bytes and graphs growing to the right
 Options[_]: growright, bits

EnableIPv6: no

######################################################################
# System: zeus.local
# Contact: 管理者のメールアドレス
# Location: BCP
######################################################################

######################################################################
#Thunderbolt LAN
######################################################################
### Interface 6 >> Descr: 'en3' | Name: 'en3' | Ip: '192.168.100.10' | Eth: '00-6c-8f-44-8a-32' ###

Target[ThunderboltLAN]: 6:private@localhost:
SetEnv[ThunderboltLAN]: MRTG_INT_IP="192.168.100.10" MRTG_INT_DESCR="en3"
MaxBytes[ThunderboltLAN]: 125000000
Title[ThunderboltLAN]: Traffic Analysis for LAN -- zeus.local
PageTop[ThunderboltLAN]: <h1>Traffic Analysis for LAN -- zeus.local</h1>
		<div id="sysdetails">
			<table>
				<tr>
					<td>System:</td>
					<td>zeus.local in BCP</td>
				</tr>
				<tr>
					<td>Maintainer:</td>
					<td>管理者メールアドレス</td>
				</tr>
				<tr>
					<td>Description:</td>
					<td>en3  </td>
				</tr>
				<tr>
					<td>ifType:</td>
					<td>ethernetCsmacd (6)</td>
				</tr>
				<tr>
					<td>ifName:</td>
					<td>en3</td>
				</tr>
				<tr>
					<td>Max Speed:</td>
					<td>125.0 MBytes/s</td>
				</tr>
				<tr>
					<td>Ip:</td>
					<td>192.168.100.10 (No DNS name)</td>
				</tr>
			</table>
		</div>

######################################################################
#VPN
######################################################################
### Interface 12 >> Descr: 'ppp0' | Name: 'ppp0' | Ip: '192.168.20.231' | Eth: 'No Ethernet Id' ###

Target[VPN]: 12:private@localhost:
SetEnv[VPN]: MRTG_INT_IP="192.168.20.231" MRTG_INT_DESCR="ppp0"
MaxBytes[VPN]: 12500000
Title[VPN]: Traffic Analysis for VPN -- zeus.local
PageTop[VPN]: <h1>Traffic Analysis for VPN -- zeus.local</h1>
		<div id="sysdetails">
			<table>
				<tr>
					<td>System:</td>
					<td>zeus.local in BCP</td>
				</tr>
				<tr>
					<td>Maintainer:</td>
					<td>管理者メールアドレス</td>
				</tr>
				<tr>
					<td>Description:</td>
					<td>ppp0  </td>
				</tr>
				<tr>
					<td>ifType:</td>
					<td>ppp (23)</td>
				</tr>
				<tr>
					<td>ifName:</td>
					<td>ppp0</td>
				</tr>
				<tr>
					<td>Max Speed:</td>
					<td>12.5 MBytes/s</td>
				</tr>
				<tr>
					<td>Ip:</td>
					<td>192.168.20.231 (No DNS name)</td>
				</tr>
			</table>
		</div>


$

 これで問題ないと思う.

Page Top

MRTGを実行する anchor.png Edit

 mrtg.cfgファイルを読み込ませながら,mrtgコマンドを実行する.

$ mrtg mrtg.cfg🆑
-----------------------------------------------------------------------
ERROR: Mrtg will most likely not work properly when the environment
       variable LANG is set to UTF-8. Please run mrtg in an environment
       where this is not the case. Try the following command to start:

       env LANG=C /usr/local/bin/mrtg mrtg.cfg🈁
-----------------------------------------------------------------------
$

 環境変数がCである必要がある.  指定して3回実行.

$ mrtg mrtg.cfg🆑
Subroutine SNMP_Session::pack_sockaddr_in6 redefined at /System/Library/Perl/5.18/Exporter.pm line 66.
 at /usr/local/bin/../lib/mrtg2/SNMP_Session.pm line 149.
Subroutine SNMPv1_Session::pack_sockaddr_in6 redefined at /System/Library/Perl/5.18/Exporter.pm line 66.
 at /usr/local/bin/../lib/mrtg2/SNMP_Session.pm line 604.
2019-05-29 12:53:17, Rateup WARNING: /usr/local/bin/rateup could not read the primary log file for thunderboltlan
2019-05-29 12:53:17, Rateup WARNING: /usr/local/bin/rateup The backup log file for thunderboltlan was invalid as well
2019-05-29 12:53:17, Rateup WARNING: /usr/local/bin/rateup Can't rename thunderboltlan.log to thunderboltlan.old updating log file
2019-05-29 12:53:17, Rateup WARNING: /usr/local/bin/rateup could not read the primary log file for vpn
2019-05-29 12:53:17, Rateup WARNING: /usr/local/bin/rateup The backup log file for vpn was invalid as well
2019-05-29 12:53:17, Rateup WARNING: /usr/local/bin/rateup Can't rename vpn.log to vpn.old updating log file
$

 もう一度.

$ mrtg mrtg.cfg🆑
Subroutine SNMP_Session::pack_sockaddr_in6 redefined at /System/Library/Perl/5.18/Exporter.pm line 66.
 at /usr/local/bin/../lib/mrtg2/SNMP_Session.pm line 149.
Subroutine SNMPv1_Session::pack_sockaddr_in6 redefined at /System/Library/Perl/5.18/Exporter.pm line 66.
 at /usr/local/bin/../lib/mrtg2/SNMP_Session.pm line 604.
$

 さらにもう一度.

$ mrtg mrtg.cfg🆑
Subroutine SNMP_Session::pack_sockaddr_in6 redefined at /System/Library/Perl/5.18/Exporter.pm line 66.
 at /usr/local/bin/../lib/mrtg2/SNMP_Session.pm line 149.
Subroutine SNMPv1_Session::pack_sockaddr_in6 redefined at /System/Library/Perl/5.18/Exporter.pm line 66.
 at /usr/local/bin/../lib/mrtg2/SNMP_Session.pm line 604.
$

 3回実行する理由は,初回はファイルが無いのでエラーがでるのだが,ここでは別のエラーがでている...

Page Top

SNMP_Session.pm line 149,SNMP_Session.pm line 604に anchor.png Edit

 このエラーは,Perlのバージョンが新しい場合に出る模様.  コードを書き換えれば修正される.次のように.バックアップを取った後に修正する.

$ cp -p /usr/local/bin/mrtg /usr/local/bin/mrtg.v00🆑
$ diff /usr/local/bin/mrtg.v00 /usr/local/bin/mrtg🆑
305c305
<             import Socket6;
---
>             Socket6->import(qw(inet_pton getaddrinfo));🈁
$

 もう1つ.

$ cp -p /usr/local/Cellar/mrtg/2.17.7/lib/mrtg2/SNMP_Session.pm /usr/local/Cellar/mrtg/2.17.7/lib/mrtg2/SNMP_Session.pm.v00🆑
$ diff /usr/local/Cellar/mrtg/2.17.7/lib/mrtg2/SNMP_Session.pm.v00 /usr/local/Cellar/mrtg/2.17.7/lib/mrtg2/SNMP_Session.pm🆑
149c149
<        Socket6->import(qw(pack_sockaddr_in6 inet_pton getaddrinfo));
---
>        Socket6->import(qw(inet_pton getaddrinfo));🈁
604c604
<         Socket6->import(qw(pack_sockaddr_in6 inet_pton getaddrinfo));
---
> 	Socket6->import(qw(inet_pton getaddrinfo));🈁
$

 再度実行してみる.

$ mrtg mrtg.cfg
$

 エラーは出なかった.ファイルを確認.

$ pwd🆑
/Users/ujpadmin/mrtg
$ ls -la🆑
total 288
drwxr-xr-x  22 ujpadmin staff   704 May 29 17:56 .
drwxr-xr-x+ 26 ujpadmin staff   832 May 29 17:29 ..
-rw-r--r--   1 ujpadmin staff   538 May 29 12:53 mrtg-l.png
-rw-r--r--   1 ujpadmin staff   414 May 29 12:53 mrtg-m.png
-rw-r--r--   1 ujpadmin staff  1759 May 29 12:53 mrtg-r.png
-rw-r--r--   1 ujpadmin staff  2542 May 29 17:00 mrtg.cfg
-rw-r--r--   1 ujpadmin staff 13435 May 29 12:44 mrtg.cfg.org
-rw-r--r--   1 ujpadmin staff     0 May 29 17:56 mrtg.ok
-rw-r--r--   1 ujpadmin staff  1798 May 29 17:56 thunderboltlan-day.png
-rw-r--r--   1 ujpadmin staff  1544 May 29 17:18 thunderboltlan-month.png
-rw-r--r--   1 ujpadmin staff  1688 May 29 17:56 thunderboltlan-week.png
-rw-r--r--   1 ujpadmin staff  1748 May 29 12:53 thunderboltlan-year.png
-rw-r--r--   1 ujpadmin staff  6362 May 29 17:56 thunderboltlan.html
-rw-r--r--   1 ujpadmin staff 49224 May 29 17:56 thunderboltlan.log
-rw-r--r--   1 ujpadmin staff 49206 May 29 17:29 thunderboltlan.old
-rw-r--r--   1 ujpadmin staff  1761 May 29 17:56 vpn-day.png
-rw-r--r--   1 ujpadmin staff  1514 May 29 17:18 vpn-month.png
-rw-r--r--   1 ujpadmin staff  1629 May 29 17:56 vpn-week.png
-rw-r--r--   1 ujpadmin staff  1748 May 29 12:53 vpn-year.png
-rw-r--r--   1 ujpadmin staff  6309 May 29 17:56 vpn.html
-rw-r--r--   1 ujpadmin staff 49223 May 29 17:56 vpn.log
-rw-r--r--   1 ujpadmin staff 49204 May 29 17:29 vpn.old
$

 ファイルができていることが確認できた.

Page Top

HTMLファイルを作成 anchor.png Edit

 MRTGのグラフをWebブラウザで参照するための,インデックスページを自動的に作成してくれる.  これは最初に1回実行すれば良いが,定義を追加した際に,毎回実行すれば良い.

 インデックス作成用のindexmakerコマンドを探す.

$ locate indexmaker🆑
/usr/local/Cellar/mrtg/2.17.7/bin/indexmaker
/usr/local/Cellar/mrtg/2.17.7/share/doc/mrtg2/indexmaker.1
/usr/local/Cellar/mrtg/2.17.7/share/doc/mrtg2/indexmaker.pod
/usr/local/Cellar/mrtg/2.17.7/share/doc/mrtg2/indexmaker.txt
/usr/local/Cellar/mrtg/2.17.7/share/man/man1/indexmaker.1
/usr/local/bin/indexmaker
/usr/local/share/man/man1/indexmaker.1
$

 コマンドヘルプを確認.

$ /usr/local/bin/indexmaker -h🆑
Option h is ambiguous (headeradd, headeradd-file, headlevel, height, help)
Usage:
    indexmaker [options] mrtg.cfg [other.cfg ...]

Options:
     --output=filename   set output filename (default: stdout)

     --filter title=~regexp  select targets by matching regexp against titles
     --filter pagetop=~regexp  select targets by matching regexp against pagetop
     --filter name=~regexp  select targets by matchin regexp against name

     --addhead=text      insert this text between </TITLE> and </HEAD>
     --title=text        set title of generated index file
     --subtitle=text     add a subtitle to the generated index file
     --bodyopt=text      set body tag options
     --headlevel=number  use <Hnumber> at top of page (default: 1)
     --pagetop=text      insert this text between <BODY> and <H1>...</H1>
     --pageend=text      insert this text after the main body
     --pagetopend=text   use this text for pagetop or pageend if undefined
     --nolegend          do not add the Mrtg legend at the end of the page

     --columns=number    show graphs in a table with x columns (default: 2)
     --perhost           show graphs of the same host on a row
     --compact           try to make a vertically more compact page
     --optlog            log the used command line in the page (default: log)

     --sort=title        sort graphs by title
     --sort=name         sort graphs by their name
     --sort=descr        sort graphs by their description
     --sort=original     leave as is (default)

     --enumerate         add a sequence number to the title of each graph

     --picfirst          place pictures before text (default: text first)
     --width=number      set width of graphs (default: not set)
     --height=number
     --sidebyside        place text / pictures side by side (default: above/below)
     --bold              use bold text (default: bold)
     --clicktext         make the text link to the inner page (like the image)

     --show=day          pick which graph to show in the index (default)
     --show=week
     --show=month
     --show=year
     --show=none

     --section=h1        h1 tag from pagetop as section heading (default)
     --section=title     title as section headings for graphs
     --section=name      graph name as section heading
     --section=descr     graph description as section heading
     --section=ifname    interface name (ifName) as section heading
     --section=portname  port name entry in pagetop as section heading
     --sectionhost       Try to prepend the host to the section heading if missing

     --rrdviewer=path    path to rrdviewer (default: /cgi-bin/14all.cgi)
     --icondir=path      path to icondir
     --prefix=path       path from the location of the index.html to the graphs
     --headeradd=string  add string to the html page header
     --autoprefix        try to set prefix automatically

     --<opt>-file=file   read string argument for option <opt> from file

$

 今回は,パラメータを指定せずに,デフォルトで実行.  実行結果は標準出力にでてくるので,ファイルへリダイレクトする.

$ indexmaker mrtg.cfg > index.html🆑
$ ls -la index.html🆑
-rw-r--r-- 1 ujpadmin staff 2644 May 29 18:28 index.html🈁
$

 あとは,作成されたHTMLをWebブラウザで表示させる.

Page Top

番外 anchor.png Edit

 こんなエラーがでるとき.

$ mrtg mrtg.cfg
Subroutine SNMP_Session::pack_sockaddr_in6 redefined at /System/Library/Perl/5.18/Exporter.pm line 66.
 at /usr/local/bin/../lib/mrtg2/SNMP_Session.pm line 149.
Subroutine SNMPv1_Session::pack_sockaddr_in6 redefined at /System/Library/Perl/5.18/Exporter.pm line 66.
 at /usr/local/bin/../lib/mrtg2/SNMP_Session.pm line 604.
2020-08-11 00:55:54, Rateup WARNING: /usr/local/bin/rateup could not read the primary log file for gaia_lan
2020-08-11 00:55:54, Rateup WARNING: /usr/local/bin/rateup The backup log file for gaia_lan was invalid as well
2020-08-11 00:55:54, Rateup WARNING: /usr/local/bin/rateup Can't rename gaia_lan.log to gaia_lan.old updating log file
$

 vi /usr/bin/mrtgで開いて,次のように書き換える.

変更前:import Socket6
変更後:Socket6->import(qw(inet_pton getaddrinfo));

 次に,vi /usr/local/bin/../lib/mrtg2/SNMP_Session.pm で

変更前:if (eval {local $SIG{__DIE__};require Socket6;} &&
変更後:if (eval {local $SIG{__DIE__};Socket6->import(qw(inet_pton getaddrinfo));} &&

 原因は,Perlのバージョンアップとのこと.


トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   ページ新規作成 全ページ一覧 単語検索 最新ページの一覧   ヘルプ   最新ページのRSS 1.0 最新ページのRSS 2.0 最新ページのRSS Atom
Counter: 1250, today: 3, yesterday: 0
最終更新: 2020-08-11 (火) 01:14:11 (JST) (1316d) by nobuaki

広告スペース
Google