利用snmp和mrtg監控linux服務器的網絡流量
<!--[if !supportLists]-->一、<!--[endif]-->環境
snmpd、mrtg服務器:station2.example.com: 192.168.32.32
被監控客戶端:station3.example.com:192.168.32.33
<!--[if !supportLists]-->二、<!--[endif]-->snmp服務器端安裝和配置(station2)
<!--[if !supportLists]-->1. <!--[endif]-->snmp安裝
[root@station2 ~]# yum install net-snmp.i386
[root@station2 ~]#yuminstall net-snmp-devel.i386
[root@station2 ~]#yum install net-snmp-utils.i386
<!--[if !supportLists]-->2. <!--[endif]-->snmp配置
[root@station2 ~]# snmptranslate -On SNMPv2-MIB::system
.1.3.6.1.2.1.1 #查看system在mib中oid號
[root@station2 ~]#cp /etc/snmp/snmpd /etc/snmp/snmpd.orig
#備份snmpd文件,默認情況下在運行snmpconf命令進行配置snmp是會覆蓋此文件
[root@station2 ~]# snmpconf
The following installed configuration files were found:
1: ./snmpd.conf
2: /etc/snmp/snmpd.conf
Would you like me to read them in? Their content will be merged with the
output files created by this session.
Valid answer examples: "all", "none","3","1,2,5"
Read in which (default = all): 2
#讀取/etc/snmp/snmpd.conf文件內容,並將其內容加入到新配置文件中
I can create the following types of configuration files for you.
Select the file type you wish to create:
(you can create more than one as you run this program)
1: snmpd.conf
2: snmptrapd.conf
3: snmp.conf
Other options: quit
Select File: 1
#選擇配置文件名,默認路徑在當前目錄下
The configuration information which can be put into snmpd.conf is divided
into sections. Select a configuration section for snmpd.conf
that you wish to create:
1: Trap Destinations
2: System Information Setup
3: Monitor Various Aspects of the Running Host
4: Extending the Agent
5: Access Control Setup
6: Agent Operating Mode
Other options: finished
Select section: 5
#選擇配置類型,5是訪問配置,要通過snmp監控系統信息,得先配置訪問控制
Section: Access Control Setup
Description:
This section defines who is allowed to talk to your running
snmp agent.
Select from:
1: a SNMPv3 read-write user
2: a SNMPv3 read-only user
3: a SNMPv1/SNMPv2c read-only access community name
4: a SNMPv1/SNMPv2c read-write access community name
Other options: finished, list
Select section: 3
#范圍權限,選擇3通過community(訪問密碼)進行只讀訪問
Configuring: rocommunity
Description:
a SNMPv1/SNMPv2c read-only access community name
arguments: community [default|hostname|network/bits] [oid]
The community name to add read-only access for: example
#example是community即訪問密碼
The hostname or network address to accept this community name from [RETURN for all]: 0.0.0.0/0 #可訪問得網段
The OID that this community should be restricted to [RETURN for no-restriction]: #snmp監控類型,回車則表示監控所有信息。
Finished Output: rocommunity example 0.0.0.0/0
Section: Access Control Setup
Description:
This section defines who is allowed to talk to your running
snmp agent.
Select from:
1: a SNMPv3 read-write user
2: a SNMPv3 read-only user
3: a SNMPv1/SNMPv2c read-only access community name
4: a SNMPv1/SNMPv2c read-write access community name
Other options: finished, list
Select section: finished #保存配置
The configuration information which can be put into snmpd.conf is divided
into sections. Select a configuration section for snmpd.conf
that you wish to create:
1: Trap Destinations
2: System Information Setup
3: Monitor Various Aspects of the Running Host
4: Extending the Agent
5: Access Control Setup
6: Agent Operating Mode
Other options: finished
Select section: finished
I can create the following types of configuration files for you.
Select the file type you wish to create:
(you can create more than one as you run this program)
1: snmpd.conf
2: snmptrapd.conf
3: snmp.conf
Other options: quit
Select File: quit
Error: An snmpd.conf file already exists in this directory.
'overwrite', 'skip', 'rename' or 'append'? : overwrite #覆蓋原配置文件
The following files were created:
snmpd.conf
These files should be moved to /usr/share/snmp if you
want them used by everyone on the system. In the future, if you add
the -i option to the command line I'll copy them there automatically for you.
Or, if you want them for your personal use only, copy them to