---
title: "mrtg"
author: "jedy"
date: "2005-12-02T11:33:00Z"
tags: []
slug: "mrtg"
draft: false
lastmod: "2005-12-02T11:33:00Z"
id: 304759
url: "https://jedy.iteye.com/blog/304759"
---

スイッチでSNMPの設定  
1\. SNMPエージェントを有効にします。また、認証トラップをオンにして、不正なSNMPアクセスに対してトラップを発生するよう設定します。

enable snmp  
enable snmp authenticate\_trap

2\. CREATE SNMP COMMUNITY コマンドで、SNMP コミュニティーを作成します。ここでは、読み出しのみが可能なコミュニティー「public」を作成します。

create snmp community=public access=read manager=192.168.2.129

MANAGERはSNMPオペレーションを許可許可するホストのIPアドレス。

3\. SHOW SNMP COMMUNITY コマンドで、SNMP モジュールの情報を表示します。

show snmp community=public

SNMP community information:  
Name ............................ public  
Access .......................... read-only  
Status .......................... Enabled  
Traps ........................... Disabled  
Open access ..................... No  
Manager ......................... 192.168.2.129

サーバでmrtgの設定  
rpmでmrtgをインストールします。  
自動的にapacheのconf.dに設定ファイルを追加します。

mrtgの設定ファイルを作成します。  
cfgmaker --output=/etc/mrtg/mrtg.cfg public@192.168.2.142

このIPはスイッチのIP。

mrtg.cfgでWorkDirを/var/www/mrtg/netに設定します。  
設定ファイルをテストします。  
mrtg /etc/mtrg/mrtg.cfg

多分、警告があります。  
3回これを実行して、警告がなくなります。

このエラーがあったら、

\-----------------------------------------------------------------------  
ERROR: Mrtg will most likely not work propperly when the environment  
variable LANG is set to UTF-8. Please run mrtg in an environment  
where this is not the case:

env LANG=C /usr/bin/mrtg ...  
\-----------------------------------------------------------------------

このコマンドを実行します。

env LANG=en\_US mrtg /etc/mtrg/mrtg.cfg

Indexページを作成します。  
indexmaker --output=/var/www/mrtg/net/index.html --title='Traffic of Switch' /etc/mrtg/mrtg.cfg

crontabに追加します。  
\*/5 * * * * /usr/bin/mrtg /etc/mrtg/mrtg.cfg &gt; /dev/nul 2&gt;&1

http://localhost/mrtg/net/index.html