Monitor CPU, traffic, disk space, memory with SNMP+MRTG

Source: Internet
Author: User

1. Install SNMP

Yum Install net-snmp*-y

2, Modify the/etc/snmpd.conf (can be directly emptied content)

① Add rocommunity Public

② Find Disk modification (Df–k view) can have multiple, see the situation

disk/$size

Disk/boot $size 1

[Disk/home $size 2 ...]

3. Start

/ETC/INIT.D/SNMPD restart

4, installation MRTG

Yum Install mrtg*-y

5 Write the following to/etc/mrtg/mrtg.cfg, direct overwrite (the yellow background needs to be changed)

############################################################

# Multi Router Traffic Grapher--Example Configuration File

############################################################

#

#Minimal mrtg.cfg

Htmldir:/VAR/WWW/MRTG

Imagedir:/VAR/WWW/MRTG

LogDir:/VAR/LIB/MRTG

Threshdir:/VAR/LIB/MRTG

#####################################################

#moniting LAN Interface

#####################################################

Target[eth1_lan]:/10.0.0.99:[email protected]localhost:

Options[eth1_lan]: growright

Directory[eth1_lan]: eth1

Maxbytes[eth1_lan]: 100000000

Kmg[eth1_lan]: k,m,g

Ylegend[eth1_lan]: Bytes per Second

Shortlegend[eth1_lan]: b/S

Legend1[eth1_lan]: inflow per second (unit Bytes)

Legend2[eth1_lan]: outflow per second (unit Bytes)

Legendi[eth1_lan]: inflow:

Legendo[eth1_lan]: outflow:

Title[eth1_lan]: eth1 network traffic [inflow + outflow]

Pagetop[eth1_lan]: network traffic [inflow + outflow]

###################################################

#Moniting CPU Load[use+free]

###################################################

Target[cpuload]:. 1.3.6.1.4.1.2021.11.50.0&.1.3.6.1.4.1.2021.11.53.0:[email protected]:

Options[cpuload]: Nopercent,growright

Directory[cpuload]: CPU

Maxbytes[cpuload]: 100

Unscaled[cpuload]: Dwym

Ylegend[cpuload]: CPU utilization

Shortlegend[cpuload]:%

Legend1[cpuload]: CPU usage load (%)

Legend2[cpuload]: CPU idle (%)

Legendi[cpuload]: use:

Legendo[cpuload]: idle:

Title[cpuload]: CPU Load [use + idle]

Pagetop[cpuload]: Load [use + idle]

###################################################

#Moniting used memory and Swap [Mem+swap] Free-k

###################################################

Target[memory]:. 1.3.6.1.2.1.25.2.3.1.6.1&.1.3.6.1.2.1.25.2.3.1.6.3:[email protected]:

Options[memory]: Gauge,growright

Directory[memory]: Mem

Maxbytes1[memory]: 327252

Maxbytes2[memory]: 1023992

#MaxBytesX [Memory]: 1023992 can be multiple, see the situation

Kmg[memory]: k,m,g

Kilo[memory]: 1024

Unscaled[memory]: Dwym

Ylegend[memory]: Mem Bytes

Shortlegend[memory]: B

Legend1[memory]: mem Used (Bytes)

Legend2[memory]: swap Used (Bytes)

Legendi[memory]: mem used:

Legendo[memory]: swap used:

Title[memory]: memory usage [Mem+swap]

Pagetop[memory]: memory usage [mem+swap]

###################################################

#Moniting disk size [/+/boot] Df-k

###################################################

Target[disk]:. 1.3.6.1.4.1.2021.9.1.8.1&.1.3.6.1.4.1.2021.9.1.8.2:[email protected]:

Options[disk]: Gauge,growright

Directory[disk]: Disk

Maxbytes1[disk]: 11087104

Maxbytes2[disk]: 495844

Kmg[disk]: k,m,g

Kilo[disk]: 1024

Unscaled[disk]: Dwym

Ylegend[disk]: Disk Bytes

Shortlegend[disk]: B

Legend1[disk]: The root partition has used space

Legend2[disk]: Boot partition used space

Legendi[disk]: root partition is used:

Legendo[disk]: Boot partition is used:

Title[disk]: hard disk space [root partition +boot partition]

Pagetop[disk]: hard disk space [root partition +boot partition]

6, cp/etc/cron.d/mrtg/etc/mrtg/

7, VI/ETC/MRTG/MRTG, change to the following content:

#!/bin/bash

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

8. Execute 3 times

/etc/mrtg/mrtg

/etc/mrtg/mrtg

/etc/mrtg/mrtg

9. Implementation

indexmaker--output/var/www/mrtg/index.html–title= "System State Monitor"/etc/mrtg/mrtg.cfg

Modify the Apache configuration file httpd.conf

ALIAS/MRTG "/VAR/WWW/MRTG"

<directory "/VAR/WWW/MRTG" >

Options indexes

AllowOverride None

Order Deny,allow

Deny from all

Allow from all

</Directory>

One by one, restart httpd

Visit http://localhost/mrtg/

if garbled, change the code

Transferred from: http://my.oschina.net/fufangchun/blog/86883

Use SNMP+MRTG to monitor CPU, traffic, disk space, memory

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.