1Install net-snmp
# Yum install net-snmp-utils-y
# Snmpwalk-V 1-C public localhostip-MiB: ipadentifindex
Created directory:/var/lib/net-snmp/mib_indexes
Timeout: no response from localhost
No data can be extracted. We need to modify/etc/snmp/snmpd. conf.
# Vim/etc/snmp/snmpd. conf
# Com2secnotconfiguser default public
Com2sec local localhost public
Com2sec mynetwork 192.168.0.0/24(Network Segment) Public (Important group name)
# Group notconfiggroupv1 notconfiguser
# Group notconfiggroupv2c notconfiguser
Group myrwgroup V1 local
Group myrwgroup v2c local
Group myrwgroup USM local
Group myrogroup V1 mynetwork
Group myrogroup v2c mynetwork
Group myrogroup USM mynetwork
# View systemview embedded ded. 1.3.6.1.2.1.1
# View systemview embedded ded. 1.3.6.1.2.1.25.1.1
View All supported ded. 1 80
# Access notconfiggroup "" any noauth exact systemview none
Access myrogroup "" any noauth exact all none
Access myrwgroup "" any noauth exact all none
This part is actually something to describe.
Syslocation unknown (edit/etc/snmp/snmpd. conf)
Syscontact root <[email protected]> (Configure/etc/snmp. Local. conf)
Syslocation linux6.
Syscontact Vivek g GITE [email protected]
The above is the place to be modified!
#/Etc/init. d/snmpd restart
# Snmpwalk-V 1-C public localhost IP-MIB: ipadentifindex
IP-MIB: ipadentifindex.127.0.0.1 = integer: 1
IP-MIB: ipadentifindex.192.168.0.55 = integer: 2
Now we can extract the data.
# Chkconfig snmpd on
2Install MRTG
1) generate the configuration file
Login maker [email protected] *. *>/etc/MRTG/mrtg. cfg
2. Generate the index.html Homepage
Indexmaker -- output =/data/web/MRTG/index.html/etc/MRTG/mrtg. cfg
3) imaging
MRTG/etc/MRTG/mrtg. cfg
Now install MRTG, I am using mrtg-2.16.2-5.el6.x86_64
# Yum install-y MRTG
# Mkdir-P/var/www/html/mymrtg
[Email protected] *. *>/etc/MRTG/mrtg. cfg
If you want to add a host later, use [email protected] *. *>/etc/MRTG/mrtg. cfg
In this way, MRTG can automatically obtain information that can monitor devices (for Cisco switches, You can monitor traffic on individual ports), snmpwalk-V 2C-C public 192.168.123.111 if
Modify the configuration file Vim/etc/MRTG/mrtg. cfg
# For Unix
Workdir:/data/web/MRTG/114.20.92.153#This line removes comments and spaces and fills in the appropriate path
# Or for NT
# Workdir: C: \ mrtgdata
### Global ults
# To get bits instead of bytes and graphsgrowing to the right
Options [_]: growright, Bits#This line removes comments and spaces.
Runasdaemon: Yes#These two lines are added to automatically refresh once every five minutes.
Interval: 5
If you monitor a remote host, you need to install SNMP on the remote host for configuration and copy the local configuration file! The configuration file is as follows:
Com2seclocal localhost public
Com2sec mynetwork 192.168.0.0/24 public
Group myrwgroup V1 local
Group myrwgroup v2c local
Group myrwgroup USM local
Group myrogroup V1 mynetwork
Group myrogroup v2c mynetwork
Group myrogroup USM mynetwork
View All supported ded. 1 80
Access myrogroup "" any noauth exact all none
Access myrwgroup "" any noauth exact all none
Com2sec local localhost public
Com2sec mynetwork 192.168.0.0/24 public
Syslocation linux6.
Syscontact Vivek g GITE <[email protected]>
Dontlogtcpwrappersconnects Yes
#/Etc/init. d/snmpd restart
# Snmpwalk-V 1-C public localhostip-MiB: ipadentifindex
IP-MIB: ipadentifindex.127.0.0.1 = integer: 1
IP-MIB: ipadentifindex.192.168.0.222 = integer: 4
IP-MIB: ipadentifindex.192.168.122.1 = integer: 5
# Chkconfig snmpd on
# Indexmaker -- output =/var/www/html/mymrtg/index.html/etc/MRTG/mymrtg. cfg
Use of uninitialized value $ first in hash element at/usr/bin/indexmaker linemaker.An error occurs sometimes because the interface content in the generated/etc/MRTG/mymrtg. cfg file is injected and the comment lines under the following content are removed., Change to the following:
### Interface 1> descr: 'lo' | Name: 'lo' | IP: '2017. 0.0.1 '| ETH :''###
### The following interface is commented out because:
### * It is a software loopback interface
Target [localhost_1]: 1: [email protected]:
Setenv [localhost_1]: mrtg_int_ip = "127.0.0.1" mrtg_int_descr = "Lo"
Maxbytes [localhost_1]: 1250000
Title [localhost_1]: Traffic Analysis for 1 -- server26.example.com
Pagetop [localhost_1]: <Div id = "sysdetails">
<Table>
<Tr>
<TD> system: </TD>
<TD> server26.example.com in linux6. </TD>
</Tr>
<Tr>
<TD> maintainer: </TD>
<TD> Vivek g GITE & lt; [email protected] & gt; </TD>
</Tr>
<Tr>
<TD> Description: </TD>
<TD> lo </TD>
</Tr>
<Tr>
<TD> iftype: </TD>
<TD> softwareloopback (24) </TD>
</Tr>
<Tr>
<TD> ifname: </TD>
<TD> lo </TD>
</Tr>
<Tr>
<TD> max speed: </TD>
<TD> 1250.0 Kbytes/S </TD>
</Tr>
<Tr>
<TD> IP: </TD>
<TD> 127.0.0.1 (localhost. localdomain) </TD>
</Tr>
</Table>
</Div>
# Indexmaker -- output =/var/www/html/mymrtg/index.html/etc/MRTG/mymrtg. cfg(Generate a home page file)
# MRTG/etc/MRTG/mrtg. cfg(Start MRTG)
-----------------------------------------------------------------------
Error: MRTG will most likely not work properly when the environment
Variable Lang is set to UTF-8. Please runmrtg in an environment
Where this is not the case. Try thefollowing command to start:
ENV/usr/bin/MRTG/etc/MRTG/mymrtg. cfg
-----------------------------------------------------------------------
# ENV/usr/bin/MRTG/etc/MRTG/mymrtg. cfg
An error occurs when this command is run twice. If it is run three times, it is OK.
For convenience, we can write a crontab
# Crontab-e
*/5 */usr/bin/MRTG/etc/MRTG/mymrtg. cfg -- logging/var/log/mrtg. Log
Since the page access is based on httpd, remember to enable the HTTPd service!
You can also add code to each configuration file to automatically refresh the line every 5 minutes.
Runasdaemon: Yes
Interval: 5
Install MRTG traffic monitoring on centos