資安論壇

行政院 國家資通安全會報 - 技術服務中心 - 資安論壇 http://forum.icst.org.tw/
現在的時間是 週三 9月 08, 2010 9:54 am

所有顯示的時間為 UTC + 8 小時




發表新文章 回覆主題  [ 12 篇文章 ] 
發表人 內容
 文章主題 : [教學][研究] F7 (Fedora 7) 上安裝 MRTG (yum安裝)
文章發表於 : 週五 11月 30, 2007 5:36 pm 
離線

註冊時間: 週三 9月 25, 2002 10:57 am
文章: 7435
來自: R.O.C
F7 (Fedora 7) 上如何安裝 MRTG ?
FC7 (Fedora Core 7) 上如何安裝 MRTG ?

有人有確實測試成功的確實方法嗎 ? 舊方法似乎行不通了

MRTG - mrtg-unix-guide (官方用 tar.gz 方式安裝)
http://oss.oetiker.ch/mrtg/doc/mrtg-unix-guide.en.html
(缺少 snmp 安裝和設定)

MRTG 安裝 (FC5) (yum安裝)
http://apt.nc.hcc.edu.tw/web/student_se ... .html#mrtg
(缺少 snmp 設定好像不夠; yum 要安裝 net-snmp* 而非 net-snmp 否則 snmpwalk 沒安裝)

FC3 (Fedora Core 3) 上安裝 MRTG 步驟
http://forum.icst.org.tw/phpBB2/viewtopic.php?t=8168

FC4 (Fedora Core 4) 上如何安裝 MRTG
http://forum.icst.org.tw/phpBB2/viewtopic.php?t=7014


最後由 lu 於 週一 4月 14, 2008 2:23 pm 編輯,總共編輯了 3 次。

回頂端
   
 
 文章主題 :
文章發表於 : 週五 11月 30, 2007 5:37 pm 
離線

註冊時間: 週三 9月 25, 2002 10:57 am
文章: 7435
來自: R.O.C
學生用伺服器建置流程(Fedora Core X 版)
http://apt.nc.hcc.edu.tw/web/student_se ... .html#mrtg

MRTG - Multi Router Traffic Grapher
MRTG 官方網站:http://oss.oetiker.ch/mrtg/

yum -y install net-snmp mrtg gd libpng zlib

產生設定檔:

mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.bak
vi /etc/snmp/snmpd.conf

com2sec local localhost public
com2sec mynetwork 192.168.128.0/24 public

group MyRWGroup any local
group MyROGroup any mynetwork
group MyRWGroup any otherv3user

view all included .1 80
access MyROGroup "" any noauth 0 all none none
access MyRWGroup "" any noauth 0 all all all

syslocation Fedora Core 5
syscontact sysadm <sysadm@xxx.xxx.edu.tw>

啟動 snmpd:

/etc/rc.d/init.d/snmpd start
chkconfig snmpd on

確認 snmpd 有執行

[root@localhost ~]# service snmpd restart

[root@localhost ~]# service snmpd status
snmpd (pid 3168) is running...

建立放置網頁的資料夾:

mkdir /var/www/mrtg/web

產生 mrtg.cfg:

cfgmaker --global 'WorkDir: /var/www/mrtg/web' \
--global 'Options[_]: growright' \
--output /etc/mrtg/mrtg.cfg \
public@192.168.128.0

出現下面錯誤

--base: Get Device Info on public@192.168.128.129:
SNMP Error:
no response received
SNMPv1_Session (remote host: "192.168.128.129" [192.168.128.129].161)
community: "public"
request ID: 1382243586
PDU bufsize: 8000 bytes
timeout: 2s
retries: 5
backoff: 1)
at /usr/bin/../lib/mrtg2/SNMP_util.pm line 627
SNMPWALK Problem for 1.3.6.1.2.1.1 on public@192.168.128.129::::::v4only
at /usr/bin/cfgmaker line 924
WARNING: Skipping public@192.168.128.129: as no info could be retrieved

--base: Writing /etc/mrtg/mrtg.cfg

修改 mrtg.cfg:

cp /etc/mrtg/mrtg.cfg /etc/mrtg/mrtg.cfg.bak
vi /etc/mrtg/mrtg.cfg

#在 20行 Options[_]: growright 這一行下面加上

Language:big5

註:修改此檔案的內容(假如有需要的話)

產生網頁:

env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg

#執行三次

產生索引頁:

若有多個機器要監控,可以用索引頁來放置多個機器的圖表

cd /var/www/mrtg/web
indexmaker /etc/mrtg/mrtg.cfg > index.html

設定瀏覽範圍:

cp /etc/httpd/conf.d/mrtg.conf /etc/httpd/conf.d/mrtg.conf.bak
vi /etc/httpd/conf.d/mrtg.conf

Alias /mrtg /var/www/mrtg
<Location /mrtg>
Order deny,allow
Deny from all
Allow from 127.0.0.1 修改成--> Allow from 192.168.1.0/255.255.255.0
Allow from ::1
# Allow from .example.com
</Location>

/etc/rc.d/init.d/httpd restart

測試:http://IP/mrtg/web/

定時更新:more /etc/cron.d/mrtg

MRTG 官方文件:http://oss.oetiker.ch/mrtg/doc/


回頂端
   
 
 文章主題 :
文章發表於 : 週五 11月 30, 2007 5:39 pm 
離線

註冊時間: 週三 9月 25, 2002 10:57 am
文章: 7435
來自: R.O.C
MRTG - mrtg-unix-guide (官方用 tar.gz 方式安裝)
http://oss.oetiker.ch/mrtg/doc/mrtg-unix-guide.en.html

確認 snmpd 有執行

[root@localhost ~]# service snmpd status
snmpd (pid 3168) is running...


執行

cfgmaker --global 'WorkDir: /var/www/mrtg'
--global 'Options[_]: bits,growright'
--output /etc/mrtg/mrtg.cfg \
community@192.168.128.129

出現錯誤

--base: Get Device Info on community@192.168.128.129:
SNMP Error:
no response received
SNMPv1_Session (remote host: "192.168.128.129" [192.168.128.129].161)
community: "community"
request ID: 756210021
PDU bufsize: 8000 bytes
timeout: 2s
retries: 5
backoff: 1)
at /usr/bin/../lib/mrtg2/SNMP_util.pm line 627
SNMPWALK Problem for 1.3.6.1.2.1.1 on community@192.168.128.129::::::v4only
at /usr/bin/cfgmaker line 924
WARNING: Skipping community@192.168.128.129: as no info could be retrieved

--base: Writing /etc/mrtg/mrtg.cfg


該如何解決?


回頂端
   
 
 文章主題 :
文章發表於 : 週五 11月 30, 2007 5:40 pm 
離線

註冊時間: 週三 9月 25, 2002 10:57 am
文章: 7435
來自: R.O.C
FC4 (Fedora Core 4) 上如何安裝 MRTG
http://forum.icst.org.tw/phpBB2/viewtopic.php?t=7014

使用非官方的 install.mrtg.sh 安裝

wget http://people.ee.ethz.ch/~oetiker/webto ... rtg.tar.gz
下載不再提供, 改用下面的失敗, 似乎上面的套件自己有改過

http://oss.oetiker.ch/mrtg/pub/mrtg.tar.gz


回頂端
   
 
 文章主題 :
文章發表於 : 週一 12月 03, 2007 4:15 pm 
離線

註冊時間: 週三 9月 25, 2002 10:57 am
文章: 7435
來自: R.O.C
測試出一種可以安裝使用的方法 install.mrtg.fc7.sh

代碼:
#  Install MRTG on Fedora 7
# by Lu 2007/12/03

yum -y install net-snmp mrtg gd libpng zlib

#Download and Install
wget http://serveio.com/da/install.mrtg.sh
chmod +x install.mrtg.sh
./install.mrtg.sh

sed -i -e "s@/var/www/mrtg@/var/www/html/mrtg@"  /etc/httpd/conf.d/mrtg.conf

#Delete MRTG Wrong Path
sed -i -e "/mrtg/d"  /etc/crontab
#echo "Adding MRTG to /etc/crontab..."
echo "*/5 * * * * root env LANG=C /usr/bin/mrtg /var/www/html/mrtg/core/mrtg.cfg" >> /etc/crontab
echo "" >> /etc/crontab

#Run SNMP Deamon
service snmpd restart
chkconfig snmpd on

#To generate MRTG Log, suggest to run three times
env LANG=C /usr/bin/mrtg /var/www/html/mrtg/core/mrtg.cfg
env LANG=C /usr/bin/mrtg /var/www/html/mrtg/core/mrtg.cfg
env LANG=C /usr/bin/mrtg /var/www/html/mrtg/core/mrtg.cfg

service httpd restart
chkconfig httpd on
firefox http://localhost/mrtg &



下載的install.mrtg.sh內容如下

代碼:
#!/bin/bash

echo "MRTG Installer 1.0 ---------------------"
echo "By: Matt Savona (www.serveio.com)"
echo -e "----------------------------------------\n\n"

USER=`whoami`

if [ "$USER" != "root" ]; then
        echo "You must be logged in as root to use this installer!"
        exit 0;
fi

echo "Checking for previous MRTG installation..."

if [ -d /var/www/html/mrtg ]; then
        FILECOUNT=`ls /var/www/html/mrtg | wc -l`
        if [ "$FILECOUNT" -ge "1" ]; then
                echo "There appears to be files in /var/www/html/mrtg already! Exiting..."
                exit 0;
        else
                echo "The directory /var/www/html/mrtg exists, but there are no files. This is okay..."
        fi
else
        echo "The directory /var/www/html/mrtg does not exist. I will create it..."
        mkdir /var/www/html/mrtg
fi

echo "Creating necessary directories and preparing for installation..."

mkdir /var/www/html/mrtg/core
chmod 700 /var/www/html/mrtg/core

WD=`pwd`
cd /usr/local/src
rm -rf mrtg*

echo "Preparations complete..."

echo "Downloading the most recent MRTG and installing it..."
wget http://people.ee.ethz.ch/~oetiker/webtools/mrtg/pub/mrtg.tar.gz
tar zfx mrtg.tar.gz
cd mrtg*
./configure --with-gd=/usr/local/lib
make
make install

echo "MRTG has been installed..."
echo "Updating MRTG config and template..."

wget http://www.serveio.com/da/mrtgcfg.tar.gz
tar zfx mrtgcfg.tar.gz
chmod +x system
mv -f system /var/www/html/mrtg/core
mv -f mrtg.cfg /var/www/html/mrtg/core

echo "Update complete!"

echo "Adding MRTG to /etc/crontab..."
echo "*/5 * * * * root /usr/local/mrtg-2/bin/mrtg /var/www/html/mrtg/core/mrtg.cfg" >> /etc/crontab
echo "" >> /etc/crontab

echo "Executing MRTG for the first time (you may see some warnings)..."
/usr/local/mrtg-2/bin/mrtg /var/www/html/mrtg/core/mrtg.cfg
echo "If you see warnings above, it is generally safe to ignore."

echo "Cleaning up installation..."
rm -rf mrtg*
cd $WD
echo "Installation of MRTG complete!"


其中 /var/www/html/mrtg/core/mrtg.cfg 內容如下

代碼:


WorkDir: /var/www/html/mrtg

#RunAsDaemon:Yes

Interval:5

Options[_]: nopercent,growright,noinfo,gauge

MaxBytes[_]: 125000000

Xsize[_]: 600
Ysize[_]: 200
Ytics[_]: 10



###############################################################################
#
# HTML formatting stuff
#
###############################################################################

PageTop[^]: <table><tr><td><table><tr><td>Network</td></tr><tr><td><a>- Traffic</a><br><a>- Open Connections</a></td></tr><tr><td>&nbsp;</td></tr><tr><td>System Stats</td></tr><tr><td><a>- Load Averages</a><br><a>- Swap Memory</a><br><a>- Processes</a><br><a>- Uptime and Idle Time</a><br><a>- CPU</a><br><a>- Memory Usage</a></td></tr><tr><td>&nbsp;</td></tr></table></td><td>

PageFoot[^]: </td></tr></table>

AddHead[^]: <meta><style><body></style>



###############################################################################
#
# Stats
#
###############################################################################


#----------------------------
# Network
#----------------------------

Target[index]: `/var/www/html/mrtg/core/system network eth0`
Options[index]: nopercent, noinfo

Title[index]: Traffic Analysis for eth0
PageTop[index]: <h3>Traffic Analysis for eth0</h3>



#----------------------------
# TCP Connections
#----------------------------

Target[tcp]: `/var/www/html/mrtg/core/system tcp`

Title[tcp]: Established TCP Connections

PageTop[tcp]: <h3>Established TCP Connections</h3>

YLegend[tcp]: Connections

ShortLegend[tcp]: &nbsp;&nbsp;&nbsp;

LegendI[tcp]:

LegendO[tcp]: Established&nbsp;


#----------------------------
# Load
#----------------------------

Target[load]: `/var/www/html/mrtg/core/system load`
Options[load]: gauge, nopercent, noinfo
MaxBytes[load]: 3000

Title[load]: Load Averages
PageTop[load]: <h3>Load Averages</h3>

YLegend[load]: Load (10E-2)
ShortLegend[load]: (10E-2)&nbsp;
LegendI[load]: 5-minute stagger
LegendO[load]: 15-mintute stagger
Legend1[load]: Load Average over last 5 minutes&nbsp;
Legend2[load]: Load Average over last 15 minutes&nbsp;
Legend3[load]: Average over last 5 minutes
Legend4[load]: Average over last 15 minutes



#----------------------------
# Swap
#----------------------------

Target[swap]: `/var/www/html/mrtg/core/system swap`

Title[swap]: Swap Memory Usage

PageTop[swap]: <h3>Swap Memory Usage</h3>

YLegend[swap]: Swap Usage

ShortLegend[swap]: &nbsp;&nbsp;&nbsp;

LegendI[swap]:

LegendO[swap]: Used&nbsp;



#----------------------------
# Processes
#----------------------------

Target[processes]: `/var/www/html/mrtg/core/system processes`

Title[processes]: Processes

PageTop[processes]: <h3>Processes</h3>

YLegend[processes]: Processes

ShortLegend[processes]: &nbsp;&nbsp;&nbsp;

LegendI[processes]: Total&nbsp;

LegendO[processes]: Running&nbsp;



#----------------------------
# Uptime
#----------------------------

Target[uptime]: `/var/www/html/mrtg/core/system uptime`

Title[uptime]: Uptime and Idle Time

PageTop[uptime]: <h3>Uptime and Idle Time</h3>

YLegend[uptime]: Uptime (sec)

ShortLegend[uptime]: &nbsp;&nbsp;&nbsp;

LegendI[uptime]: Total Uptime&nbsp;

LegendO[uptime]: Idle Time&nbsp;



#----------------------------
# CPU
#----------------------------

Target[cpu]: `/usr/bin/awk '/cpu /{print $2+$3; print $2+$3+$4; print "quite some time"; print "domain.com"}'</proc/stat`

Title[cpu]: CPU Usage

PageTop[cpu]: <H3>CPU Usage</h3>

MaxBytes[cpu]: 100

Options[cpu]: nopercent,growright,noinfo,bits

LegendI[cpu]: &nbsp;user:

LegendO[cpu]: &nbsp;total:

Ylegend[cpu]: %CPU

ShortLegend[cpu]: %CPU

Legend1[cpu]: Time spent in user mode

Legend2[cpu]: Time spent in user mode + time spent in system mode

Legend3[cpu]: Maximum occurance of time spent in user mode

Legend4[cpu]: Maximum occurance of (time spent in user mode + time spent in system mode)



#----------------------------
# Memory
#----------------------------

Target[memory]: `/var/www/html/mrtg/core/system memory`
Options[memory]: gauge, noinfo
MaxBytes[memory]: 665536000

Title[memory]: Memory Utilization
PageTop[memory]: <H3>Memory Utilization</H3>

YLegend[memory]: Bytes
ShortLegend[memory]: B
LegendI[memory]: Used:
LegendO[memory]: Buffers + Cache:
Legend1[memory]: Free real memory
Legend2[memory]: Free swap memory
Legend3[memory]: Maximal 5 Minute Memory In Use
Legend4[memory]: Maximal 5 Minute Active Memory



測試可以使用, 只是討厭的是它安裝了一個自己的程式 /var/www/html/mrtg/core/system
會再找時間測試看看是否有方案


回頂端
   
 
 文章主題 :
文章發表於 : 週一 12月 03, 2007 5:28 pm 
離線

註冊時間: 週三 9月 25, 2002 10:57 am
文章: 7435
來自: R.O.C
找到另外一種可用方法 install.mrtg.fc7.yum.sh

代碼:
#  Install MRTG on Fedora 7
# by Lu 2007/12/03

yum -y install net-snmp mrtg gd libpng zlib

mkdir /var/www/html/netflow
chmod 777 /var/www/html/netflow

sed -i -e "s@/var/www/mrtg@/var/www/html/netflow@"  /etc/httpd/conf.d/mrtg.conf

sed -i -e "s@/var/www/mrtg@/var/www/html/netflow@"  /etc/mrtg/mrtg.cfg
sed -i -e "s@/var/lib/mrtg@/var/www/html/netflow@"  /etc/mrtg/mrtg.cfg
#delete old setting
sed -i -e "/eth0/d" /etc/mrtg/mrtg.cfg
#add new setting
echo "Target[eth0]: 2:public@127.0.0.1" >> /etc/mrtg/mrtg.cfg
echo "MaxBytes[eth0]: 1250000" >> /etc/mrtg/mrtg.cfg
echo "Title[eth0]: Traffic Analysis" >> /etc/mrtg/mrtg.cfg
echo "PageTop[eth0]: <H1>Stats for our Ethernet</H1>" >> /etc/mrtg/mrtg.cfg


#echo "Adding MRTG to /etc/crontab..."
sed -i -e "/mrtg/d"  /etc/crontab
echo "*/5 * * * * root env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg" >> /etc/crontab
echo "" >> /etc/crontab

#Run SNMP Deamon
echo "view systemview included .1.3.6.1.2.1.2.2.1.10" >> /etc/snmp/snmpd.conf
echo "view systemview included .1.3.6.1.2.1.2.2.1.16" >> /etc/snmp/snmpd.conf
service snmpd restart
chkconfig snmpd on

#To generate MRTG Log, suggest to run three times
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg

indexmaker --output=/var/www/html/netflow/index.html /etc/mrtg/mrtg.cfg

# Run MRTG
service httpd restart
chkconfig httpd on
firefox http://localhost/mrtg &

_________________
天道循環,生死不昧,真空妙有,還於本然!
諦聽我們的靈魂之聲,所有飄零的靈魂,此世虛幻,此生一夢,生者必死!
勢不可去盡,話不可說盡,福不可享盡,規矩不可行盡,凡事太盡,緣分勢必早盡!
免費貼圖空間 http://www.picfury.com/
免費貼圖空間 viewtopic.php?t=8816
免費上傳空間 viewtopic.php?t=6558


回頂端
   
 
 文章主題 :
文章發表於 : 週二 12月 04, 2007 2:23 pm 
離線

註冊時間: 週三 9月 25, 2002 10:57 am
文章: 7435
來自: R.O.C
簡化, 改用 yum 安裝 mrtg 時候的預設目錄 /var/www/mrtg , 安裝程式改為

代碼:
#  Install MRTG on Fedora 7
# by Lu 2007/12/04

yum -y install net-snmp mrtg gd libpng zlib

#delete old setting
sed -i -e "/eth0/d" /etc/mrtg/mrtg.cfg
#add new setting
echo "Target[eth0]: 2:public@127.0.0.1" >> /etc/mrtg/mrtg.cfg
echo "MaxBytes[eth0]: 1250000" >> /etc/mrtg/mrtg.cfg
echo "Title[eth0]: Traffic Analysis" >> /etc/mrtg/mrtg.cfg
echo "PageTop[eth0]: <H1>Stats for our Ethernet</H1>" >> /etc/mrtg/mrtg.cfg


#echo "Deleting old setting , Adding MRTG to /etc/crontab..."
sed -i -e "/mrtg/d"  /etc/crontab
echo "*/5 * * * * root env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg" >> /etc/crontab
echo "" >> /etc/crontab

#Run SNMP Deamon
echo "view systemview included .1.3.6.1.2.1.2.2.1.10" >> /etc/snmp/snmpd.conf
echo "view systemview included .1.3.6.1.2.1.2.2.1.16" >> /etc/snmp/snmpd.conf
service snmpd restart
chkconfig snmpd on

#To generate MRTG Log, suggest to run three times
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg

indexmaker --output=/var/www/mrtg/index.html /etc/mrtg/mrtg.cfg

# Run MRTG
service httpd restart
chkconfig httpd on
firefox http://localhost/mrtg &

_________________
天道循環,生死不昧,真空妙有,還於本然!
諦聽我們的靈魂之聲,所有飄零的靈魂,此世虛幻,此生一夢,生者必死!
勢不可去盡,話不可說盡,福不可享盡,規矩不可行盡,凡事太盡,緣分勢必早盡!
免費貼圖空間 http://www.picfury.com/
免費貼圖空間 viewtopic.php?t=8816
免費上傳空間 viewtopic.php?t=6558


回頂端
   
 
 文章主題 :
文章發表於 : 週三 12月 05, 2007 4:38 pm 
離線

註冊時間: 週三 9月 25, 2002 10:57 am
文章: 7435
來自: R.O.C
http://blog.csdn.net/imlogic/archive/20 ... 61609.aspx

監控CPU的方法(略做修改, 實際測試過可以)

yum –y install sysstat

1.Switch to super user (若用root可省略)

sudo -sH

2.Make a CPU script as bellows.

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

3. Change the right to able to run it
(原來網站寫 chmod +755 /opt/mrtg/mrtg.cpu , 755 前面不該有加號)

chmod 755 /etc/mrtg/cpu.sh

4. Modify /etc/mrtg.cfg and add the following lines at the end of file

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

MaxBytes[cpu]: 100

Options[cpu]: gauge, nopercent, growright

YLegend[cpu]: CPU loading (%)

ShortLegend[cpu]: %

LegendO[cpu]: &nbsp; CPU us;

LegendI[cpu]: &nbsp; CPU sy;

Title[cpu]: CPU Loading

PageTop[cpu]: <H1>CPU Loading</H1>

5.Regenerate index page
(修改 mrtg.cfg 符合實際)

indexmaker /etc/mrtg/mrtg.cfg > /var/www/mrtg/index.html

完成程式 install.mrtg.fc7.sh 如下
代碼:

echo -e "\033[42;31m"
echo "Install MRTG on Fedora 7"
echo "by Lu 2007/12/05"
echo -e "\033[0m"


echo -e "\033[32mKill nptd on running...\033[0m"
ProcessID="`ps aux | grep ntpd | awk '{print $2}' `"
for i in $ProcessID
do
  echo $i
  kill -9 $i
done
ntpdate tick.stdtime.gov.tw

echo -e "\033[32mKill yum on running...\033[0m"
ProcessID="`ps aux | grep yum | awk '{print $2}' `"
for i in $ProcessID
do
  echo $i
  kill -9 $i
done
echo -e "\033[32myum -y install net-snmp mrtg gd libpng zlib sysstat\033[0m"
yum -y install net-snmp mrtg gd libpng zlib sysstat

echo -e "\033[32mModify /etc/mrtg/mrtg.cfg\033[0m"
#delete old setting
sed -i -e "/eth0/d" /etc/mrtg/mrtg.cfg
#add new setting
echo "Target[eth0]: 2:public@127.0.0.1" >> /etc/mrtg/mrtg.cfg
echo "MaxBytes[eth0]: 1250000" >> /etc/mrtg/mrtg.cfg
echo "Title[eth0]: Traffic Analysis" >> /etc/mrtg/mrtg.cfg
echo "PageTop[eth0]: <H1>Stats for our Ethernet</H1>" >> /etc/mrtg/mrtg.cfg


echo -e "\033[32mModify /etc/crontab\033[0m"
#echo "Deleting old setting , Adding MRTG to /etc/crontab..."
sed -i -e "/mrtg/d"  /etc/crontab
echo "*/5 * * * * root env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg" >> /etc/crontab
echo "" >> /etc/crontab

echo -e "\033[32mModify /etc/snmp/snmpd.conf\033[0m"
#Run SNMP Deamon
echo "view systemview included .1.3.6.1.2.1.2.2.1.10" >> /etc/snmp/snmpd.conf
echo "view systemview included .1.3.6.1.2.1.2.2.1.16" >> /etc/snmp/snmpd.conf
service snmpd restart
chkconfig snmpd on

echo -e "\033[32menv LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg\033[0m"
echo -e "\033[32menv LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg\033[0m"
echo -e "\033[32menv LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg\033[0m"
#To generate MRTG Log, suggest to run three times
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg

echo -e "\033[32mindexmaker --output=/var/www/mrtg/index.html /etc/mrtg/mrtg.cfg\033[0m"
indexmaker --output=/var/www/mrtg/index.html /etc/mrtg/mrtg.cfg

# Run MRTG
echo -e "\033[32mservice httpd restart\033[0m"
service httpd restart
echo -e "\033[32mchkconfig httpd on\033[0m"
chkconfig httpd on
#firefox http://localhost/mrtg &



echo -e "\033[32m********** Set CPU Monitor **********\033[0m"
#yum -y install sysstat

echo -e "\033[32mMake /etc/mrtg/cpu.sh\033[0m"
echo "#!/bin/bash" > /etc/mrtg/cpu.sh
echo "cpuusr=\`/usr/bin/sar -u 1 3 | grep Average | awk '{print \$3}'\`  " >> /etc/mrtg/cpu.sh
echo "cpusys=\`/usr/bin/sar -u 1 3 | grep Average | awk '{print \$5}'\`  " >> /etc/mrtg/cpu.sh
echo "UPtime=\`/usr/bin/uptime | awk '{print \$3\"\"\$4\"\"\$5}'\`  " >> /etc/mrtg/cpu.sh
echo "echo \$cpuusr  " >> /etc/mrtg/cpu.sh
echo "echo \$cpusys  " >> /etc/mrtg/cpu.sh
echo "echo \$UPtime  " >> /etc/mrtg/cpu.sh
echo "hostname  " >> /etc/mrtg/cpu.sh

#/bin/cp -f cpu.sh /etc/mrtg/cpu.sh
chmod 755 /etc/mrtg/cpu.sh

echo -e "\033[32mModify /etc/mrtg/mrtg.cfg\033[0m"

echo " "  >> /etc/mrtg/mrtg.cfg
echo "Target[cpu]: \`/etc/mrtg/cpu.sh\`  " >> /etc/mrtg/mrtg.cfg
echo "MaxBytes[cpu]: 100  " >> /etc/mrtg/mrtg.cfg
echo "Options[cpu]: gauge, nopercent, growright    " >> /etc/mrtg/mrtg.cfg
echo "YLegend[cpu]: CPU loading (%)  " >> /etc/mrtg/mrtg.cfg
echo "ShortLegend[cpu]: %  " >> /etc/mrtg/mrtg.cfg
echo "LegendO[cpu]: &nbsp; CPU us;  " >> /etc/mrtg/mrtg.cfg
echo "LegendI[cpu]: &nbsp; CPU sy;  " >> /etc/mrtg/mrtg.cfg
echo "Title[cpu]: CPU Loading  " >> /etc/mrtg/mrtg.cfg
echo "PageTop[cpu]: <H1>CPU Loading</H1>  " >> /etc/mrtg/mrtg.cfg

#To generate MRTG Log, suggest to run three times
echo -e "\033[32menv LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg\033[0m"
echo -e "\033[32menv LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg\033[0m"
echo -e "\033[32menv LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg\033[0m"
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg

echo -e "\033[32mindexmaker --output=/var/www/mrtg/index.html /etc/mrtg/mrtg.cfg\033[0m"
indexmaker /etc/mrtg/mrtg.cfg > /var/www/mrtg/index.html

echo -e "\033[32mfirefox http://localhost/mrtg &\033[0m"
firefox http://localhost/mrtg &





_________________
天道循環,生死不昧,真空妙有,還於本然!
諦聽我們的靈魂之聲,所有飄零的靈魂,此世虛幻,此生一夢,生者必死!
勢不可去盡,話不可說盡,福不可享盡,規矩不可行盡,凡事太盡,緣分勢必早盡!
免費貼圖空間 http://www.picfury.com/
免費貼圖空間 viewtopic.php?t=8816
免費上傳空間 viewtopic.php?t=6558


回頂端
   
 
 文章主題 :
文章發表於 : 週三 12月 05, 2007 5:12 pm 
離線

註冊時間: 週三 9月 25, 2002 10:57 am
文章: 7435
來自: R.O.C
再加上 Memory 監督功能, 完成安裝程式 install.mrtg.fc7.yum.sh 如下

代碼:

echo -e "\033[42;31m"
echo "Install MRTG on Fedora 7"
echo "by Lu 2007/12/05"
echo -e "\033[0m"


echo -e "\033[32mKill nptd on running...\033[0m"
ProcessID="`ps aux | grep ntpd | awk '{print $2}' `"
for i in $ProcessID
do
  echo $i
  kill -9 $i
done
ntpdate tick.stdtime.gov.tw

echo -e "\033[32mKill yum on running...\033[0m"
ProcessID="`ps aux | grep yum | awk '{print $2}' `"
for i in $ProcessID
do
  echo $i
  kill -9 $i
done
echo -e "\033[32myum -y install net-snmp mrtg gd libpng zlib sysstat\033[0m"
yum -y install net-snmp mrtg gd libpng zlib sysstat

echo -e "\033[32mModify /etc/mrtg/mrtg.cfg\033[0m"
#delete old setting
sed -i -e "/eth0/d" /etc/mrtg/mrtg.cfg
#add new setting
echo "Target[eth0]: 2:public@127.0.0.1" >> /etc/mrtg/mrtg.cfg
echo "MaxBytes[eth0]: 1250000" >> /etc/mrtg/mrtg.cfg
echo "Title[eth0]: Traffic Analysis" >> /etc/mrtg/mrtg.cfg
echo "PageTop[eth0]: <H1>Stats for our Ethernet</H1>" >> /etc/mrtg/mrtg.cfg


echo -e "\033[32mModify /etc/crontab\033[0m"
#echo "Deleting old setting , Adding MRTG to /etc/crontab..."
sed -i -e "/mrtg/d"  /etc/crontab
echo "*/5 * * * * root env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg" >> /etc/crontab
echo "" >> /etc/crontab

echo -e "\033[32mModify /etc/snmp/snmpd.conf\033[0m"
#Run SNMP Deamon
echo "view systemview included .1.3.6.1.2.1.2.2.1.10" >> /etc/snmp/snmpd.conf
echo "view systemview included .1.3.6.1.2.1.2.2.1.16" >> /etc/snmp/snmpd.conf
service snmpd restart
chkconfig snmpd on

#To generate MRTG Log, suggest to run three times
echo -e "\033[32menv LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg\033[0m"
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
echo -e "\033[32menv LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg\033[0m"
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
echo -e "\033[32menv LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg\033[0m"
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg

echo -e "\033[32mindexmaker --output=/var/www/mrtg/index.html /etc/mrtg/mrtg.cfg\033[0m"
indexmaker --output=/var/www/mrtg/index.html /etc/mrtg/mrtg.cfg

# Run MRTG
echo -e "\033[32mservice httpd restart\033[0m"
service httpd restart
echo -e "\033[32mchkconfig httpd on\033[0m"
chkconfig httpd on
#firefox http://localhost/mrtg &



echo -e "\033[32m********** Set CPU Monitor **********\033[0m"
#yum -y install sysstat

echo -e "\033[32mMake /etc/mrtg/cpu.sh\033[0m"
echo "#!/bin/bash" > /etc/mrtg/cpu.sh
echo "cpuusr=\`/usr/bin/sar -u 1 3 | grep Average | awk '{print \$3}'\`  " >> /etc/mrtg/cpu.sh
echo "cpusys=\`/usr/bin/sar -u 1 3 | grep Average | awk '{print \$5}'\`  " >> /etc/mrtg/cpu.sh
echo "UPtime=\`/usr/bin/uptime | awk '{print \$3\"\"\$4\"\"\$5}'\`  " >> /etc/mrtg/cpu.sh
echo "echo \$cpuusr  " >> /etc/mrtg/cpu.sh
echo "echo \$cpusys  " >> /etc/mrtg/cpu.sh
echo "echo \$UPtime  " >> /etc/mrtg/cpu.sh
echo "hostname  " >> /etc/mrtg/cpu.sh

#/bin/cp -f cpu.sh /etc/mrtg/cpu.sh
chmod 755 /etc/mrtg/cpu.sh

echo -e "\033[32mModify /etc/mrtg/mrtg.cfg\033[0m"

echo " "  >> /etc/mrtg/mrtg.cfg
echo "Target[cpu]: \`/etc/mrtg/cpu.sh\`  " >> /etc/mrtg/mrtg.cfg
echo "MaxBytes[cpu]: 100  " >> /etc/mrtg/mrtg.cfg
echo "Options[cpu]: gauge, nopercent, growright    " >> /etc/mrtg/mrtg.cfg
echo "YLegend[cpu]: CPU loading (%)  " >> /etc/mrtg/mrtg.cfg
echo "ShortLegend[cpu]: %  " >> /etc/mrtg/mrtg.cfg
echo "LegendO[cpu]: &nbsp; CPU us;  " >> /etc/mrtg/mrtg.cfg
echo "LegendI[cpu]: &nbsp; CPU sy;  " >> /etc/mrtg/mrtg.cfg
echo "Title[cpu]: CPU Loading  " >> /etc/mrtg/mrtg.cfg
echo "PageTop[cpu]: <H1>CPU Loading</H1>  " >> /etc/mrtg/mrtg.cfg

#To generate MRTG Log, suggest to run three times
echo -e "\033[32menv LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg\033[0m"
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
echo -e "\033[32menv LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg\033[0m"
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
echo -e "\033[32menv LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg\033[0m"
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg

echo -e "\033[32mindexmaker --output=/var/www/mrtg/index.html /etc/mrtg/mrtg.cfg\033[0m"
indexmaker /etc/mrtg/mrtg.cfg > /var/www/mrtg/index.html

echo -e "\033[32mfirefox http://localhost/mrtg &\033[0m"
#firefox http://localhost/mrtg &





echo -e "\033[32m********** Set Memory Monitor **********\033[0m"

echo -e "\033[32myum -y install sysstat\033[0m"
#yum -y install sysstat

echo -e "\033[32mMake /etc/mrtg/mem.sh\033[0m"

echo "#!/bin/bash  " > /etc/mrtg/mem.sh
echo "# run this script to check the mem usage.  " >> /etc/mrtg/mem.sh
echo "totalmem=\`/usr/bin/free |grep Mem |awk '{print \$2}'\`  " >> /etc/mrtg/mem.sh
echo "usedmem=\`/usr/bin/free |grep Mem |awk '{print \$3}'\`  " >> /etc/mrtg/mem.sh
echo "UPtime=\`/usr/bin/uptime | awk '{print \$3\"\"\$4\"\"\$5}'\`  " >> /etc/mrtg/mem.sh
echo "echo \$totalmem  " >> /etc/mrtg/mem.sh
echo "echo \$usedmem  " >> /etc/mrtg/mem.sh
echo "echo \$UPtime  " >> /etc/mrtg/mem.sh
echo "hostname  " >> /etc/mrtg/mem.sh


#/bin/cp -f mem.sh /etc/mrtg/mem.sh
chmod 755 /etc/mrtg/mem.sh

echo -e "\033[32mModify /etc/mrtg/mrtg.cfg\033[0m"

echo " "  >> /etc/mrtg/mrtg.cfg
echo "Target[ram]: \`/etc/mrtg/mem.sh\`  " >> /etc/mrtg/mrtg.cfg
echo "#Unscaled[ram]: dwym  " >> /etc/mrtg/mrtg.cfg
echo "MaxBytes[ram]: 2048000  " >> /etc/mrtg/mrtg.cfg
echo "Title[ram]:Memory  " >> /etc/mrtg/mrtg.cfg
echo "ShortLegend[ram]: &  " >> /etc/mrtg/mrtg.cfg
echo "kmg[ram]:kB,MB  " >> /etc/mrtg/mrtg.cfg
echo "kilo[ram]:1024  " >> /etc/mrtg/mrtg.cfg
echo "YLegend[ram]: &nbsp; Memory Usage :  " >> /etc/mrtg/mrtg.cfg
echo "Legend1[ram]: &nbsp; Total Memory :  " >> /etc/mrtg/mrtg.cfg
echo "Legend2[ram]: &nbsp; Used Memory :  " >> /etc/mrtg/mrtg.cfg
echo "LegendI[ram]: &nbsp; Total Memory :  " >> /etc/mrtg/mrtg.cfg
echo "LegendO[ram]: &nbsp; Used Memory :  " >> /etc/mrtg/mrtg.cfg
echo "Options[ram]: growright,gauge,nopercent  " >> /etc/mrtg/mrtg.cfg
echo "PageTop[ram]:<H1>Memory</H1>  " >> /etc/mrtg/mrtg.cfg

#To generate MRTG Log, suggest to run three times
echo -e "\033[32menv LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg\033[0m"
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
echo -e "\033[32menv LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg\033[0m"
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
echo -e "\033[32menv LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg\033[0m"
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg

echo -e "\033[32mindexmaker --output=/var/www/mrtg/index.html /etc/mrtg/mrtg.cfg\033[0m"
indexmaker /etc/mrtg/mrtg.cfg > /var/www/mrtg/index.html

echo -e "\033[32mfirefox http://localhost/mrtg &\033[0m"
firefox http://localhost/mrtg &



_________________
天道循環,生死不昧,真空妙有,還於本然!
諦聽我們的靈魂之聲,所有飄零的靈魂,此世虛幻,此生一夢,生者必死!
勢不可去盡,話不可說盡,福不可享盡,規矩不可行盡,凡事太盡,緣分勢必早盡!
免費貼圖空間 http://www.picfury.com/
免費貼圖空間 viewtopic.php?t=8816
免費上傳空間 viewtopic.php?t=6558


回頂端
   
 
 文章主題 :
文章發表於 : 週四 12月 06, 2007 4:19 pm 
離線

註冊時間: 週三 9月 25, 2002 10:57 am
文章: 7435
來自: R.O.C
Advanced MRTG for Linux
http://www.linuxhomenetworking.com/wiki ... _for_Linux

_________________
天道循環,生死不昧,真空妙有,還於本然!
諦聽我們的靈魂之聲,所有飄零的靈魂,此世虛幻,此生一夢,生者必死!
勢不可去盡,話不可說盡,福不可享盡,規矩不可行盡,凡事太盡,緣分勢必早盡!
免費貼圖空間 http://www.picfury.com/
免費貼圖空間 viewtopic.php?t=8816
免費上傳空間 viewtopic.php?t=6558


回頂端
   
 
 文章主題 :
文章發表於 : 週一 12月 10, 2007 10:11 am 
離線

註冊時間: 週四 12月 02, 2004 7:35 pm
文章: 26
您可以參考我的這一篇筆記看可不可以解決您的問題
http://www.pmail.idv.tw/linux-lean/mrtg.html


回頂端
   
 
 文章主題 :
文章發表於 : 週一 4月 14, 2008 2:23 pm 
離線

註冊時間: 週三 9月 25, 2002 10:57 am
文章: 7435
來自: R.O.C
範例再做些改良

1. 備份設定檔
2. 增加其他主機
3. 增加其他網卡

如果使用 eth1 或其他, public@127.0.0.1 前面的數字, 可用 ip link 查看
(一般 eth0 是 2 , eth1 是3 , ... )

有哪些網卡可用 mii-tool 查

代碼:

[root@fc7 ~]# mii-tool
eth0: negotiated 100baseTx-HD, link ok
eth1: no autonegotiation, 100baseTx-HD, link ok
eth2: negotiated 100baseTx-FD, link ok
eth3: no link



ip link 直接下命令即可 (注意 ip 和 link 間有空格)

代碼:

[root@fc7 ~]# ip link

1: lo: <LOOPBACK> mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:11:25:8f:85:c8 brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST> mtu 1500 qdisc noop qlen 1000
link/ether 00:11:25:8f:85:c9 brd ff:ff:ff:ff:ff:ff
4: sit0: <NOARP> mtu 1480 qdisc noop
link/sit 0.0.0.0 brd 0.0.0.0
5: vmnet1: <BROADCAST> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:50:56:c0:00:01 brd ff:ff:ff:ff:ff:ff
6: vmnet8: <BROADCAST> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:50:56:c0:00:08 brd ff:ff:ff:ff:ff:ff



修改的程式碼如下, 僅供參考

代碼:
echo -e "\033[42;31m"
echo "Install MRTG on Fedora 7"
echo "by Lu 2008/04/14"
echo -e "\033[0m"


echo -e "\033[32mKill nptd on running...\033[0m"
ProcessID="`ps aux | grep ntpd | awk '{print $2}' `"
for i in $ProcessID
do
  echo $i
  kill -9 $i
done
ntpdate tick.stdtime.gov.tw

echo -e "\033[32mKill yum on running...\033[0m"
ProcessID="`ps aux | grep yum | awk '{print $2}' `"
for i in $ProcessID
do
  echo $i
  kill -9 $i
done
echo -e "\033[32myum -y install net-snmp mrtg gd libpng zlib sysstat\033[0m"
yum -y install net-snmp mrtg gd libpng zlib sysstat

echo -e "\033[32mModify /etc/mrtg/mrtg.cfg\033[0m"
if [ ! -s  /etc/mrtg/mrtg.cfg.OLD ]; then
/bin/cp -f  /etc/mrtg/mrtg.cfg  /etc/mrtg/mrtg.cfg.OLD
fi
/bin/cp -f  /etc/mrtg/mrtg.cfg.OLD  /etc/mrtg/mrtg.cfg
#delete old setting
sed -i -e "/eth0/d" /etc/mrtg/mrtg.cfg
#add new setting
echo "Target[eth0]: 2:public@127.0.0.1" >> /etc/mrtg/mrtg.cfg
echo "MaxBytes[eth0]: 1250000" >> /etc/mrtg/mrtg.cfg
echo "Title[eth0]: Traffic Analysis" >> /etc/mrtg/mrtg.cfg
echo "PageTop[eth0]: <H1>127.0.0.1 eth0</H1>" >> /etc/mrtg/mrtg.cfg

mii-tool
ip  link

echo "Target[192.168.20.116][eth0]: 2:public@192.168.20.116" >> /etc/mrtg/mrtg.cfg
echo "MaxBytes[192.168.20.116][eth0]: 1250000" >> /etc/mrtg/mrtg.cfg
echo "Title[192.168.20.116][eth0]: Traffic Analysis" >> /etc/mrtg/mrtg.cfg
echo "PageTop[192.168.20.116][eth0]: <H1>OpenVPN 192.168.20.116 eth0</H1>" >> /etc/mrtg/mrtg.cfg
echo " "

echo "Target[192.168.10.2][eth1]: 3:public@192.168.10.2" >> /etc/mrtg/mrtg.cfg
echo "MaxBytes[192.168.10.2][eth1]: 1250000" >> /etc/mrtg/mrtg.cfg
echo "Title[192.168.10.2][eth1]: Traffic Analysis" >> /etc/mrtg/mrtg.cfg
echo "PageTop[192.168.10.2][eth1]: <H1>OpenVPN 192.168.10.2 eth1</H1>" >> /etc/mrtg/mrtg.cfg
echo " "

echo "Target[10.3.0.100][eth2]: 4:public@10.3.0.100" >> /etc/mrtg/mrtg.cfg
echo "MaxBytes[10.3.0.100][eth2]: 1250000" >> /etc/mrtg/mrtg.cfg
echo "Title[10.3.0.100][eth2]: Traffic Analysis" >> /etc/mrtg/mrtg.cfg
echo "PageTop[10.3.0.100][eth2]: <H1>OpenVPN 10.3.0.100 eth2</H1>" >> /etc/mrtg/mrtg.cfg
echo " "

echo "Target[192.168.10.19][eth0]: 2:public@192.168.10.19" >> /etc/mrtg/mrtg.cfg
echo "MaxBytes[192.168.10.19][eth0]: 1250000" >> /etc/mrtg/mrtg.cfg
echo "Title[192.168.10.19][eth0]: Traffic Analysis" >> /etc/mrtg/mrtg.cfg
echo "PageTop[192.168.10.19][eth0]: <H1>OfflineDB 192.168.10.19 eth0</H1>" >> /etc/mrtg/mrtg.cfg
echo " "

echo -e "\033[32mModify /etc/crontab\033[0m"
#echo "Deleting old setting , Adding MRTG to /etc/crontab..."
sed -i -e "/mrtg/d"  /etc/crontab
echo "*/5 * * * * root env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg" >> /etc/crontab
echo "" >> /etc/crontab

echo -e "\033[32mModify /etc/snmp/snmpd.conf\033[0m"

if [ ! -s  /etc/snmp/snmpd.conf.OLD ]; then
/bin/cp -f  /etc/snmp/snmpd.conf  /etc/snmp/snmpd.conf.OLD
#Run SNMP Deamon
echo "view systemview included .1.3.6.1.2.1.2.2.1.10" >> /etc/snmp/snmpd.conf
echo "view systemview included .1.3.6.1.2.1.2.2.1.16" >> /etc/snmp/snmpd.conf
service snmpd restart
chkconfig snmpd on
fi

echo -e "\033[32mModify /etc/httpd/conf.d/mrtg.conf\033[0m"
if [ ! -s  /etc/httpd/conf.d/mrtg.conf.OLD ]; then
/bin/cp -f  /etc/httpd/conf.d/mrtg.conf  /etc/httpd/conf.d/mrtg.conf.OLD
fi
/bin/cp -f  /etc/httpd/conf.d/mrtg.conf.OLD  /etc/httpd/conf.d/mrtg.conf
#Allow monitor from anywhere
sed -i -e "s@Deny from all@#Deny from all@" /etc/httpd/conf.d/mrtg.conf


#To generate MRTG Log, suggest to run three times
echo -e "\033[32menv LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg\033[0m"
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
echo -e "\033[32menv LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg\033[0m"
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
echo -e "\033[32menv LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg\033[0m"
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg

echo -e "\033[32mindexmaker --output=/var/www/mrtg/index.html /etc/mrtg/mrtg.cfg\033[0m"
indexmaker --output=/var/www/mrtg/index.html /etc/mrtg/mrtg.cfg

# Run MRTG
echo -e "\033[32mservice httpd restart\033[0m"
service httpd restart
echo -e "\033[32mchkconfig httpd on\033[0m"
chkconfig httpd on
#firefox http://localhost/mrtg &



echo -e "\033[32m********** Set CPU Monitor **********\033[0m"
#yum -y install sysstat

echo -e "\033[32mMake /etc/mrtg/cpu.sh\033[0m"
echo "#!/bin/bash" > /etc/mrtg/cpu.sh
echo "cpuusr=\`/usr/bin/sar -u 1 3 | grep Average | awk '{print \$3}'\`  " >> /etc/mrtg/cpu.sh
echo "cpusys=\`/usr/bin/sar -u 1 3 | grep Average | awk '{print \$5}'\`  " >> /etc/mrtg/cpu.sh
echo "UPtime=\`/usr/bin/uptime | awk '{print \$3\"\"\$4\"\"\$5}'\`  " >> /etc/mrtg/cpu.sh
echo "echo \$cpuusr  " >> /etc/mrtg/cpu.sh
echo "echo \$cpusys  " >> /etc/mrtg/cpu.sh
echo "echo \$UPtime  " >> /etc/mrtg/cpu.sh
echo "hostname  " >> /etc/mrtg/cpu.sh

#/bin/cp -f cpu.sh /etc/mrtg/cpu.sh
chmod 755 /etc/mrtg/cpu.sh

echo -e "\033[32mModify /etc/mrtg/mrtg.cfg\033[0m"

sed -i -e "/cpu/d" /etc/mrtg/mrtg.cfg
echo " "  >> /etc/mrtg/mrtg.cfg
echo "Target[cpu]: \`/etc/mrtg/cpu.sh\`  " >> /etc/mrtg/mrtg.cfg
echo "MaxBytes[cpu]: 100  " >> /etc/mrtg/mrtg.cfg
echo "Options[cpu]: gauge, nopercent, growright    " >> /etc/mrtg/mrtg.cfg
echo "YLegend[cpu]: CPU loading (%)  " >> /etc/mrtg/mrtg.cfg
echo "ShortLegend[cpu]: %  " >> /etc/mrtg/mrtg.cfg
echo "LegendO[cpu]: &nbsp; CPU us;  " >> /etc/mrtg/mrtg.cfg
echo "LegendI[cpu]: &nbsp; CPU sy;  " >> /etc/mrtg/mrtg.cfg
echo "Title[cpu]: CPU Loading  " >> /etc/mrtg/mrtg.cfg
echo "PageTop[cpu]: <H1>CPU Loading</H1>  " >> /etc/mrtg/mrtg.cfg

#To generate MRTG Log, suggest to run three times
echo -e "\033[32menv LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg\033[0m"
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
echo -e "\033[32menv LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg\033[0m"
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
echo -e "\033[32menv LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg\033[0m"
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg

echo -e "\033[32mindexmaker --output=/var/www/mrtg/index.html /etc/mrtg/mrtg.cfg\033[0m"
indexmaker /etc/mrtg/mrtg.cfg > /var/www/mrtg/index.html

echo -e "\033[32mfirefox http://localhost/mrtg &\033[0m"
#firefox http://localhost/mrtg &





echo -e "\033[32m********** Set Memory Monitor **********\033[0m"

echo -e "\033[32myum -y install sysstat\033[0m"
#yum -y install sysstat

echo -e "\033[32mMake /etc/mrtg/mem.sh\033[0m"

echo "#!/bin/bash  " > /etc/mrtg/mem.sh
echo "# run this script to check the mem usage.  " >> /etc/mrtg/mem.sh
echo "totalmem=\`/usr/bin/free |grep Mem |awk '{print \$2}'\`  " >> /etc/mrtg/mem.sh
echo "usedmem=\`/usr/bin/free |grep Mem |awk '{print \$3}'\`  " >> /etc/mrtg/mem.sh
echo "UPtime=\`/usr/bin/uptime | awk '{print \$3\"\"\$4\"\"\$5}'\`  " >> /etc/mrtg/mem.sh
echo "echo \$totalmem  " >> /etc/mrtg/mem.sh
echo "echo \$usedmem  " >> /etc/mrtg/mem.sh
echo "echo \$UPtime  " >> /etc/mrtg/mem.sh
echo "hostname  " >> /etc/mrtg/mem.sh


#/bin/cp -f mem.sh /etc/mrtg/mem.sh
chmod 755 /etc/mrtg/mem.sh

echo -e "\033[32mModify /etc/mrtg/mrtg.cfg\033[0m"

sed -i -e "/ram/d" /etc/mrtg/mrtg.cfg
echo " "  >> /etc/mrtg/mrtg.cfg
echo "Target[ram]: \`/etc/mrtg/mem.sh\`  " >> /etc/mrtg/mrtg.cfg
echo "#Unscaled[ram]: dwym  " >> /etc/mrtg/mrtg.cfg
echo "MaxBytes[ram]: 2048000  " >> /etc/mrtg/mrtg.cfg
echo "Title[ram]:Memory  " >> /etc/mrtg/mrtg.cfg
echo "ShortLegend[ram]: &  " >> /etc/mrtg/mrtg.cfg
echo "kmg[ram]:kB,MB  " >> /etc/mrtg/mrtg.cfg
echo "kilo[ram]:1024  " >> /etc/mrtg/mrtg.cfg
echo "YLegend[ram]: &nbsp; Memory Usage :  " >> /etc/mrtg/mrtg.cfg
echo "Legend1[ram]: &nbsp; Total Memory :  " >> /etc/mrtg/mrtg.cfg
echo "Legend2[ram]: &nbsp; Used Memory :  " >> /etc/mrtg/mrtg.cfg
echo "LegendI[ram]: &nbsp; Total Memory :  " >> /etc/mrtg/mrtg.cfg
echo "LegendO[ram]: &nbsp; Used Memory :  " >> /etc/mrtg/mrtg.cfg
echo "Options[ram]: growright,gauge,nopercent  " >> /etc/mrtg/mrtg.cfg
echo "PageTop[ram]:<H1>Memory</H1>  " >> /etc/mrtg/mrtg.cfg

#To generate MRTG Log, suggest to run three times
echo -e "\033[32menv LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg\033[0m"
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
echo -e "\033[32menv LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg\033[0m"
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
echo -e "\033[32menv LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg\033[0m"
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg

echo -e "\033[32mindexmaker --output=/var/www/mrtg/index.html /etc/mrtg/mrtg.cfg\033[0m"
indexmaker /etc/mrtg/mrtg.cfg > /var/www/mrtg/index.html

echo -e "\033[32mfirefox http://localhost/mrtg &\033[0m"
#firefox http://localhost/mrtg &





echo -e "\033[32m********** Set connections Monitor **********\033[0m"

echo -e "\033[32myum -y install sysstat\033[0m"
#yum -y install sysstat

echo -e "\033[32mMake /etc/mrtg/connections.sh\033[0m"

echo "#!/bin/bash  " > /etc/mrtg/connections.sh
echo "echo \`netstat -a | grep www|awk '{print \$5}'|sort | wc -l|awk '{print\$1 - 1}'\`  " >> /etc/mrtg/connections.sh
echo "# netstat -a | grep www|awk '{print \$5}'|sort| uniq  " >> /etc/mrtg/connections.sh
echo "echo \`netstat -a | grep www|awk '{print \$5}'|cut -d\":\" -f1|sort| uniq |wc -l | awk '{print \$1 - 1}'\`  " >> /etc/mrtg/connections.sh
echo "# netstat -a | grep www|awk '{print \$5}'|cut -d\":\" -f1|sort| uniq  " >> /etc/mrtg/connections.sh
echo "UPtime=\`/usr/bin/uptime | awk '{print \$3 " " \$4 " " \$5}'\`  " >> /etc/mrtg/connections.sh
echo "echo \$UPtime  " >> /etc/mrtg/connections.sh
echo "echo yourwebserver.host.name  " >> /etc/mrtg/connections.sh

#/bin/cp -f connections.sh /etc/mrtg/connections.sh
chmod 755 /etc/mrtg/connections.sh

echo -e "\033[32mModify /etc/mrtg/mrtg.cfg\033[0m"

sed -i -e "/connections/d" /etc/mrtg/mrtg.cfg
echo " "  >> /etc/mrtg/mrtg.cfg
echo "Target[connections]: \`/etc/mrtg/connections.sh\`  " >> /etc/mrtg/mrtg.cfg
echo "MaxBytes[connections]: 500  " >> /etc/mrtg/mrtg.cfg
echo "Options[connections]: gauge, nopercent, growright  " >> /etc/mrtg/mrtg.cfg
echo "YLegend[connections]: Online Users  " >> /etc/mrtg/mrtg.cfg
echo "ShortLegend[connections]: %  " >> /etc/mrtg/mrtg.cfg
echo "LegendI[connections]: &nbsp; connections (Input) :  " >> /etc/mrtg/mrtg.cfg
echo "LegendO[connections]: &nbsp; connections (Output) :  " >> /etc/mrtg/mrtg.cfg
echo "Title[connections]: WWW connections  " >> /etc/mrtg/mrtg.cfg
echo "PageTop[connections]: <H1> WWW connections </H1>  " >> /etc/mrtg/mrtg.cfg
#echo "<TABLE>  " >> /etc/mrtg/mrtg.cfg
#echo "  <TR><TD>System:</TD>   <TD>WWW connections</TD></TR>  " >> /etc/mrtg/mrtg.cfg
#echo "  <TR><TD>Maintainer:</TD> <TD>Lu</TD></TR>  " >> /etc/mrtg/mrtg.cfg
#echo "</TABLE>  " >> /etc/mrtg/mrtg.cfg


#To generate MRTG Log, suggest to run three times
echo -e "\033[32menv LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg\033[0m"
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
echo -e "\033[32menv LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg\033[0m"
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg
echo -e "\033[32menv LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg\033[0m"
env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg

echo -e "\033[32mindexmaker --output=/var/www/mrtg/index.html /etc/mrtg/mrtg.cfg\033[0m"
indexmaker /etc/mrtg/mrtg.cfg > /var/www/mrtg/index.html

echo -e "\033[32Setting :/etc/mrtg/mrtg.cfg\033[0m"
echo -e "\033[32Setting :/etc/httpd/conf.d/mrtg.conf\033[0m"

echo -e "\033[32mfirefox http://localhost/mrtg &\033[0m"
firefox http://localhost/mrtg &



相關文章

[教學][研究] MRTG 快速安裝程式 (CentOS 5.1)
http://forum.icst.org.tw/phpBB2/viewtopic.php?t=14871

[教學][研究] F7 (Fedora 7) 上安裝 MRTG (yum安裝)
http://forum.icst.org.tw/phpBB2/viewtopic.php?t=13689

FC4 (Fedora Core 4) 上如何安裝 MRTG
http://forum.icst.org.tw/phpBB2/viewtopic.php?t=7014

FC3 (Fedora Core 3) 上安裝 MRTG 步驟
http://forum.icst.org.tw/phpBB2/viewtopic.php?t=8168

監控網路鏈路流量負載軟體Mrtg使用指南
http://forum.icst.org.tw/phpBB2/viewtopic.php?t=7094


回頂端
   
 
顯示文章 :  排序  
發表新文章 回覆主題  [ 12 篇文章 ] 

所有顯示的時間為 UTC + 8 小時


誰在線上

正在瀏覽這個版面的使用者:沒有註冊會員 和 1 位訪客


不能 在這個版面發表主題
不能 在這個版面回覆主題
不能 在這個版面編輯您的文章
不能 在這個版面刪除您的文章

搜尋:
前往 :  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
正體中文語系由 竹貓星球 維護製作