Ubuntu服务器安装MRTG监控软件
安装apache:
apt-get install apache2
apt-get install snmp snmpd
编辑snmpd:
vim /etc/f
查到类似的行,修改为如下所示:(仅仅修改屏蔽或放开)
# sec.name source community
# com2sec paranoid default public # kommentieren
com2sec readonly default public # <- auskommentieren
#com2sec readwrite default private
vim /etc/f
查到类似的行,修改为如下所示:(仅仅修改屏蔽或放开)
# sec.name source community
# com2sec paranoid default public # kommentieren
com2sec readonly default public # <- auskommentieren
#com2sec readwrite default private
重启snmpd服务:
/etc/init.d/snmpd restart
/etc/init.d/snmpd restart
重新生成mrtg的配置文件:
cfgmaker public@localhost > /etc/mrtg.cfg
(注意)如果仅仅监视一个IP地址采用如下命令:
cfgmaker public@192.168.17.16 >> /etc/mrtg.cfg
生成mrtg的主页:
indexmaker /etc/mrtg.cfg > /var/www/mrtg/index.html
访问:
localhost/mrtg/
二安装CPU负载监视[默认5分钟采集一次]
cfgmaker public@localhost > /etc/mrtg.cfg
(注意)如果仅仅监视一个IP地址采用如下命令:
cfgmaker public@192.168.17.16 >> /etc/mrtg.cfg
生成mrtg的主页:
indexmaker /etc/mrtg.cfg > /var/www/mrtg/index.html
访问:
localhost/mrtg/
二安装CPU负载监视[默认5分钟采集一次]
切换到超级用户:
sudo -sH
安装软件:
apt-get install sysstat
建立CPU脚本:
mkdir /opt/mrtg
vim /opt/mrtg/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
使脚本可以执行:
chmod +755 /opt/mrtg/mrtg.cpu
修改 /etc/mrtg.cfg 在文件最后加入cpu项目
Target[cpu]: `/opt/mrtg/mrtg.cpu`
MaxBytes[cpu]: 100
Options[cpu]: gauge, nopercent, growright
YLegend[cpu]: CPU loading (%)
ShortLegend[cpu]: %
LegendO[cpu]: CPU us;
LegendI[cpu]: CPU sy;
echo $UPtime
hostname
使脚本可以执行:
chmod +755 /opt/mrtg/mrtg.cpu
修改 /etc/mrtg.cfg 在文件最后加入cpu项目
Target[cpu]: `/opt/mrtg/mrtg.cpu`
MaxBytes[cpu]: 100
Options[cpu]: gauge, nopercent, growright
YLegend[cpu]: CPU loading (%)
ShortLegend[cpu]: %
LegendO[cpu]: CPU us;
LegendI[cpu]: CPU sy;
Title[cpu]: CPU Loading
PageTop[cpu]: <H1>CPU Loading</H1>
重新生成索引页面:
indexmaker /etc/mrtg.cfg > /var/www/mrtg/index.html
三安装WWW连接数监视[默认5分钟采集一次]
切换到超级用户:
sudo -sH
建立WWW脚本:
mkdir /opt/mrtg
vim /opt/mrtg/mrtg.www
#!/bin/bash
PageTop[cpu]: <H1>CPU Loading</H1>
重新生成索引页面:
indexmaker /etc/mrtg.cfg > /var/www/mrtg/index.html
三安装WWW连接数监视[默认5分钟采集一次]
切换到超级用户:
sudo -sH
建立WWW脚本:
mkdir /opt/mrtg
vim /opt/mrtg/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}'` ubuntu vim命令
echo $UPtime
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}'` ubuntu vim命令
echo $UPtime
hostname
使脚本可以执行:
chmod +755 /opt/mrtg/mrtg.www
修改 /etc/mrtg.cfg 在文件最后加入www项目
Target[www]: `/opt/mrtg/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
使脚本可以执行:
chmod +755 /opt/mrtg/mrtg.www
修改 /etc/mrtg.cfg 在文件最后加入www项目
Target[www]: `/opt/mrtg/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>
重新生成索引页面:
indexmaker /etc/mrtg.cfg > /var/www/mrtg/index.html
重新生成索引页面:
indexmaker /etc/mrtg.cfg > /var/www/mrtg/index.html
四安装内存使用监视[默认5分钟采集一次]
切换到超级用户:
sudo -sH
建立RAM脚本:
mkdir /opt/mrtg
vim /opt/mrtg/mrtg.ram
#!/bin/bash
# run this script to check the mem usage.
totalmem=`/usr/bin/free |grep Mem |awk '{print $2}'`
切换到超级用户:
sudo -sH
建立RAM脚本:
mkdir /opt/mrtg
vim /opt/mrtg/mrtg.ram
#!/bin/bash
# run this script to check the mem usage.
totalmem=`/usr/bin/free |grep Mem |awk '{print $2}'`
usedmem=`/usr/bin/free |grep Mem |awk '{print $3}'`
UPtime=`/usr/bin/uptime | awk '{print $3""$4""$5}'`
echo $totalmem
echo $usedmem
echo $UPtime
hostname
使脚本可以执行:
chmod +755 /opt/mrtg/mrtg.ram
修改 /etc/mrtg.cfg 在文件最后加入ram项目
Target[ram]: `/opt/mrtg/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>
重新生成索引页面:
indexmaker /etc/mrtg.cfg > /var/www/mrtg/index.html
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>
重新生成索引页面:
indexmaker /etc/mrtg.cfg > /var/www/mrtg/index.html
五安装FTP连接数监视[默认5分钟采集一次]
切换到超级用户:
sudo -sH
建立FTP脚本:
mkdir /opt/mrtg
vim /opt/mrtg/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}'`
echo $all
fi
if [ "$user" = "-1" ]; then
echo 0
else
echo $user
fi
UPtime=`/usr/bin/uptime | awk '{print $3 " " $4 " " $5}'`
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论