Install MRTG monitoring software for Ubuntu Server

Source: Internet
Author: User
Tags ftp connection mrtg
Install MRTG monitoring software for Ubuntu Server: 1: install network traffic monitoring [default 5 minute collection once] switch to Super User: sudo-sH install software: apt-getinstallapache2apt-getinstallmrtgapt-getinstallsnmpd edit snmpd: vim/etc/snmp/snmpd install MRTG monitoring software on the Ubuntu Server:

I. install network traffic monitoring [collection once every 5 minutes by default]

Switch to Super User:
Sudo-sH

Install software:
Apt-get install apache2
Apt-get install mrtg
Apt-get install snmpd

Edit snmpd:
Vim/etc/snmp/snmpd. conf



Find a similar row and change it to the following: (modify only to block or release)
# Sec. name source community
# Com2sec paranoid default public # kommentieren
Com2sec readonly default public # <-auskommentieren
# Com2sec readwrite default private

Restart the snmpd service:
/Etc/init. d/snmpd restart

Regenerate the mrtg configuration file:
Login maker public @ localhost>/etc/mrtg. cfg

(Note) use the following command to monitor only one IP address:
Registrant maker public@192.168.0.1>/etc/mrtg. cfg

Generate the home page of mrtg:
Indexmaker/etc/mrtg. cfg>/var/www/mrtg/index.html

Access:
Http: // localhost/mrtg/

2. install CPU load monitoring [collection once every 5 minutes by default]

Switch to Super User:
Sudo-sH

Install software:
Apt-get install sysstat

Create a CPU script:
Mkdir/opt/mrtg
Vim/opt/mrtg. cpu
#! /Bin/bash
Cpuusr = '/usr/bin/sar-u 1 3 | grep Average | awk {print $3 }'
Cpusys = '/usr/bin/sar-u 1 3 | grep Average | awk {print $5 }'
UPtime = '/usr/bin/uptime | awk {print $3 "" $4 "" $5 }'
Echo $ cpuusr
Echo $ cpusys
Echo $ UPtime
Hostname

Run the following script:
Chmod + 755/opt/mrtg. cpu

Modify/etc/mrtg. cfg and add the cpu project to the end of the file.
Target [cpu]: '/opt/mrtg. cpu'
MaxBytes [cpu]: 100
Options [cpu]: gauge, nopercent, growright
YLegend [cpu]: CPU loading (%)
Lelegend [cpu]: %
LegendO [cpu]: CPU us;
LegendI [cpu]: CPU sy;
Title [cpu]: CPU Loading
PageTop [cpu]: CPU Loading

Regenerate the index page:
Indexmaker/etc/mrtg. cfg>/var/www/mrtg/index.html

3. install the WWW connection count monitoring function. [collection is performed once every 5 minutes by default]

Switch to Super User:
Sudo-sH

Create a WWW script:
Mkdir/opt/mrtg
Vim/opt/mrtg. www
#! /Bin/bash
All = 'netstat-a | grep www | awk {print $5} | sort | wc-l | awk {print $1-1 }'
User = 'netstat-a | grep www | awk {print $5} | cut-d ": "-f1 | sort | uniq | wc-l | awk {print $1-1 }'
If ["$ all" = "-1"]; then
Echo 0
Else
Echo $ all
Fi
If ["$ user" = "-1"]; then
Echo 0
Else
Echo $ user
Fi
UPtime = '/usr/bin/uptime | awk {print $3 "" $4 "" $5 }'
Echo $ UPtime
Hostname


Run the following script:
Chmod + 755/opt/mrtg. www

Modify/etc/mrtg. cfg and add the www project to the end of the file.
Target [www]: '/opt/mrtg. www'
MaxBytes [www]: 500
Options [www]: nopercent, growright
YLegend [www]: Online Users
ShortLegend [www]: %
LegendI [www]: Connect:
LegendO [www]: Online:
Title [www]: WWW Connect
PageTop [www]: WWW Connect

Regenerate the index page:
Indexmaker/etc/mrtg. cfg>/var/www/mrtg/index.html 4 install memory usage monitoring [collection once every 5 minutes by default]

Switch to Super User:
Sudo-sH

Create a RAM script:
Mkdir/opt/mrtg
Vim/opt/mrtg. ram
#! /Bin/bash
# Run this script to check the mem usage.
Totalmem = '/usr/bin/free | grep Mem | awk {print $2 }'


Usef8 = '/usr/bin/free | grep Mem | awk {print $3 }'
UPtime = '/usr/bin/uptime | awk {print $3 "" $4 "" $5 }'
Echo $ totalmem
Echo $ usedmem
Echo $ UPtime
Hostname


Run the following script:
Chmod + 755/opt/mrtg. ram

Modify/etc/mrtg. cfg and add the ram project to the end of the file.
Target [ram]: '/opt/mrtg. Ram'
# Unscaled [ram]: dwym
MaxBytes [ram]: 2048000
Title [ram]: Memory
ShortLegend [ram]: &
Kmg [ram]: kB, MB
Kilo [ram]: 1024
YLegend [ram]: Memory Usage:
Legend1 [ram]: Total Memory:
Legend2 [ram]: Used Memory:
LegendI [ram]: Total Memory:
LegendO [ram]: Used Memory:
Options [ram]: growright, gauge, nopercent
PageTop [ram]: Memory

Regenerate the index page:
Indexmaker/etc/mrtg. cfg>/var/www/mrtg/index.html


5. install FTP connection monitoring [collection once every 5 minutes by default]

Switch to Super User:
Sudo-sH

Create an FTP script:
Mkdir/opt/mrtg
Vim/opt/mrtg. ftp
#! /Bin/bash
All = 'netstat-a | grep ftp | awk {print $5} | sort | wc-l | awk {print $1-1 }'
User = 'netstat-a | grep ftp | awk {print $5} | cut-d ": "-f1 | sort | uniq | wc-l | awk {print $1-1 }'
If ["$ all" = "-1"]; then
Echo 0
Else
Echo $ all
Fi
If ["$ user" = "-1"]; then
Echo 0
Else
Echo $ user
Fi
UPtime = '/usr/bin/uptime | awk {print $3 "" $4 "" $5 }'

[1] [2] [3] Next page

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.