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]: <H1> CPU Loading </H1>
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]: <H1> WWW Connect </H1>
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]: <H1> Memory </H1>
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