Chinaunix首页 | 论坛 | 博客
  • 博客访问: 815596
  • 博文数量: 127
  • 博客积分: 3662
  • 博客等级: 中校
  • 技术积分: 1371
  • 用 户 组: 普通用户
  • 注册时间: 2010-08-02 12:36
个人简介

Linux&MySQL&PHP&Nginx&Apache&MSSQL&Shell

文章分类

全部博文(127)

文章存档

2016年(1)

2015年(8)

2014年(14)

2013年(26)

2012年(17)

2011年(28)

2010年(33)

分类: LINUX

2011-04-20 20:28:55

一、安装GD

1、安装libpng

#tar xvf libpng-1.2.10.tar.tar

#cd libpng-1.2.10

#./configure  --prefix=/usr/local/png

#make;make install

#ln -s /usr/local/png/lib/* /usr/lib/

 

2、安装jpeg

#mkdir /usr/local/jpeg

#mkdir /usr/local/jpeg/bin

#mkdir /usr/local/jpeg/lib

#mkdir /usr/local/jpeg/include

#mkdir /usr/local/jpeg/man

#mkdir /usr/local/jpeg/man/man1

#tar xvf jpegsrc.v7.tar.tar

#cd jpeg-7

#./configure --prefix=/usr/local/jpeg --enable-shared --enable-static

#make;make install

#ln -s /usr/local/jpeg/lib/* /usr/lib/

 

3、安装 freetype

#tar xvf freetype-2.3.9.tar.tar

#cd freetype-2.3.9

#./configure --prefix=/usr/local/freetype

#make;make install

 

4、安装fontconfig

#tar zxvf fontconfig-2.4.2.tar.gz

#cd fontconfig-2.4.2

#./configure        --prefix=/usr/local/fontconfig --with-freetype-config=/usr/local/freetype/bin/freetype-config

#make;make install

 

5、安装GD

#tar zxvf gd-2.0.32.tar.gz

#cd gd-2.0.32

#./configure --prefix=/usr/local/gd --with-png=/usr/local/png --with-jpeg=/usr/local/jpeg --with- freetype=/usr/local/freetype --with-fontconfig=/usr/local/fontconfig

 

** Configuration summary for gd 2.0.32:**

   Support for PNG library:          yes

   Support for JPEG library:         yes

   Support for Freetype 2.x library:    yes

   Support for Fontconfig library:     yes

   Support for Xpm library:          no

   Support for pthreads:             yes

 

#cp /usr/local/png/include/png.h ./

#cp /usr/local/png/include/pngconf.h ./

#make;make install

 

6、安装zlib-1.2.3.tar.gz

tar zxvf zlib-1.2.3.tar.gz

cd zlib-1.2.3

./configure --prefix=/usr/local/zlib

make && make install

 

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

安装Apache

./configure --prefix=/usr/local/apache --enable-modules=most --enable-proxy --enable-proxy-ajp --enable-ssl

make && make install

 

二、安装MRTG

   tar -zxvf mrtg-2.13.2.tar.gz

   cd mrtg-2.13.2

   ./configure --prefix=/usr/local/mrtg --with-gd=/usr/local/gd --with-gd-lib=/usr/local/gd/lib --with-gd-inc=/usr/local/gd/include --with-png=/usr/local/png --with-png-lib=/usr/local/png/lib --with-zlib=/usr/local/zlib --with-zlib-lib=/usr/local/zlib/lib

  make

  make install

 

三、调整参数,对端口进行流量监控

1、 生成mrtg.cfg文件,用于存放mrtg配置信息

#mkdir /usr/local/mrtg/etc

#/usr/local/mrtg/bin/cfgmaker --output /usr/local/mrtg/etc/mrtg.cfg public@121.52.209.160

 

2、修改mrtg.cfg文件参数

#mkdir /usr/local/apache/htdocs/mrtg

#vi /usr/local/mrtg/etc/mrtg.cfg

     Workdir后的路径改成/usr/local/apache/htdocs/mrtg   :指定mrtg的工作目录

     #Options[_]: growright, bits  :前面的#去掉

     在加入一行Language:Chinese :使mrtg支持中文

 

3env LANG=C /usr/local/mrtg/bin/mrtg /usr/local/mrtg/etc/mrtg.cfg   :多执行几遍,直到不出现信息

然后显示的信息如下

/usr/local/mrtg/bin/rateup Can't remove 121.52.209.160_4227866.old updating log file

 

4、生成页面文件

# /usr/local/mrtg/bin/indexmaker --output /usr/local/apache/htdocs/mrtg/index.html --title=ruishengIDC --sort=title --sort=name --sort=descr --sort=original /usr/local/mrtg/etc/mrtg.cfg

 

 

5、让数据自动刷新

  crontab -e

然后写入*/5 * * * * env LANG=C /usr/local/mrtg/bin/mrtg /usr/local/mrtg/etc/mrtg.cfg

 

service crond restart

service httpd restart

service snmpd restart

 

四:mrtg.cfg其他相关监控

1CPU

################CPU######################

Target[cpu]: `/opt/mrtg/cpu.sh`

MaxBytes[cpu]: 12500000

Title[cpu]: CPU

Options[cpu]: gauge,nopercent,growright

YLegend[cpu]: CPU loading (%)

ShortLegend[cpu]:%

LegendO[cpu]: & CPU USER;

LegendI[cpu]: & CPU SYSTEM;

PageTop[cpu]:

CPU

;

2:MEM

###############    MEM  512M  #################

Target[mem]:`/opt/mrtg/mem.sh`

Unscaled[mem]: dwym

MaxBytes[mem]: 512000

Title[mem]:Memory

ShortLegend[mem]: &

kmg[mem]:kB,MB

kilo[mem]:1024

YLegend[mem]: Memory Usage

Legend1[mem]: Total Memory

Legend2[mem]: Used Memory

LegendI[mem]: Total Memory

LegendO[mem]: Used Memory

Options[mem]: growright,gauge,nopercent

PageTop[mem]:

Memory

;

 

################### Swap 1024M #######################

Target[swap]:`/opt/mrtg/swap.sh`

Unscaled[swap]: dwym

MaxBytes[swap]: 1024000

Title[swap]:Memory State of Server

ShortLegend[swap]: &

kmg[swap]:kB,MB

kilo[swap]:1024

YLegend[swap]: Swap Usage

Legend1[swap]: Total Swap

Legend2[swap]: Used Swap

LegendI[swap]: Total Swap

LegendO[swap]: Used Swap

Options[swap]: growright,gauge,nopercent

PageTop[swap]:

Swap

;

 

################## Disk Space 10G  #########################

Target[disk]: `/opt/mrtg/df.pl`

Title[disk]: Disk Space

Unscaled[disk]: dwym

MaxBytes[disk]: 10000000

kmg[disk]: KB,MB,GB

LegendI[disk]: Total Disk Space

LegendO[disk]: Used Disk Space

Legend1[disk]: Total Disk Space

Legend2[disk]: Used Disk Space

YLegend[disk]:  Megabytes

ShortLegend[disk]: &

Options[disk]: growright,gauge,nopercent

PageTop[disk]:

Disk Space

;

 

################## Disk I/O 100K/sec  /DEV/SDA  ##########

# If you want monitor more disk, please copy below create

# now monitor job, and copy & modify the diskperf.sh to setting disk.

Target[diskIO]: `/opt/mrtg/diskperf.sh`

Title[diskIO]: Disk HDA I/O Utilization Report

Unscaled[diskIO]: dwym

MaxBytes[diskIO]: 100

PageTop[diskIO]:

Disk I/O Utilization Report

;

kmg[diskIO]: KB,MB,GB

LegendI[diskIO]: Disk I/O KBread/sec

LegendO[diskIO]: Disk I/O KBwrite/sec

Legend1[diskIO]: Disk I/O KBread/sec

Legend2[diskIO]: Disk I/O KBwrite/sec

YLegend[diskIO]:  Megabytes

ShortLegend[diskIO]: &

Options[diskIO]: growright,gauge,nopercent

 

注:相关脚本

[cpu.sh]

#!/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

echo $hostname

 

[mem.sh]

#!/bin/bash

# This script to monitor the mem usage.

totalmem=`/usr/bin/free |grep Mem |awk '{print $2}'`

usedmem=`/usr/bin/free |grep Mem |awk '{print $3}'`

echo "$totalmem"

echo "$usedmem"

 

[swap.sh]

#!/bin/bash

# This script to monitor the swap usage.

totalswap=`/usr/bin/free |grep Swap |awk '{print $2}'`

usedswap=`/usr/bin/free |grep Swap |awk '{print $3}'`

echo "$totalswap"

echo "$usedswap"

 

[df.pl]

#!/usr/bin/perl

# output(df -kl) looks like this:

# Filesystem           1k-blocks      Used Available Use% Mounted on

# /dev/md0              95645100  30401312  64272080  33% /

# /dev/hde1                14119      1159     12231   9% /boot

#

# In which case, this script returns :

# 95659219

# 30402503

# when run.

foreach $filesystem (`df -kl | grep -v "Filesystem"`)

{

  @df = split(/\s+/,$filesystem);

  $total += $df[1];

  $usage += $df[2];

}

print "$total\n";

print "$usage\n";

 

[diskperf.sh]

#!/bin/bash

# This script will monitor the KBread/sec &KBwriten/sec of Disk.

# Creater: CCC IT loren  ext:2288   2005/8/3

# As sda ,sdb,sdc,sdd,hda.

# disk=sda

hd=sda

disk=/dev/$hd

KBread_sec=`iostat -x $disk|grep $hd |awk '{print $8}'`

KBwrite_sec=`iostat -x $disk|grep $hd |awk '{print $9}'`

echo "$KBread_sec"

echo "$KBwrite_sec"

echo "$hostname"

 

阅读(3143) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~