瀏覽模式: 普通 | 列表

MRTG計算方式

勞大師說:

MRTG 取值是五分鐘一次
CACTI 預設也是五分鐘取一次。
假設在相同的時間點出發  12:00
12:05 取到的值為x
12:10 取到的值為y
那12:10 的值會得到  (y-x) / 8 / 1024 or 1000 / 300s = z kbps/s
不準的原因是因為大家的出發點就和時間可能不一樣
mrtg、cacti  會有取值效能的問題,不論是機器、頻寬多少都會影響。

如果假設server 皆對一個ntp server校時ok , 頻寬相同的情況下 取出來的值不會差太多。
mrtg 取值不能小於五分鐘,即使排程每分鐘抓一次值,也是畫五分鐘的值。
如果用snmpget 去取值的話 就是當下的值了
就自己要去做加減的動作

更正一下 snmpget 抓的值要*8

我比對00:30分的數值是:

snmpget (1984522365-1963830061)/1000*8/300=551.7kbps
mrtg 550.6 kbps
cacti 534k
標籤: mrtg

MRTG 超出限制流量警告

目的: 當流量超過我所限制的值以上時,寄信警告

設定方式,在 mrtg.cfg 裡加入
ThreshDir: /tmp/thresh
ThreshMaxI[_]: 625000
#ThreshMinI[_]: 1
ThreshMaxO[_]: 625000
#ThreshMinO[_]: 1
ThreshProgI[_]: /bin/mrtg_alert_in.sh
ThreshProgO[_]: /bin/mrtg_alert_out.sh
參數中文說明可參考http://sjsmit.blogspot.com/2005/03/threshold-checkingmrtg.html

這裡我會用到的有 ThreshDir、ThreshMaxI、ThreshMaxO、ThreshProgI、ThreshProgO

當流量超過 625000 就透過 /bin/mrtg_alert_in.sh 去警告通知

[閱讀全文]

標籤: MRTG

如何使用 RRDTOOL 教學文件

Apache 模組 mod_watch - 畫每個網站的 mrtg 圖

環境
cross.tw 192.168.1.93
cross2.tw 192.168.1.93

1.) 下載 http://updates.interworx.info/iworx/legacy/sources/
2.) 安裝 mod_watch 給 Apache
   a.) 在編譯時讓程式知道 apxs 在那裡
      vi Makefile.dso

#
# The location of apxs utility.
#
APXS=/usr/sbin/apxs

   b.) 開始編譯

      make -f Makefile.dso install

[閱讀全文]

munin - 監控主機,用 rrdtool 畫負載圖

Munin 是一個使用 RRDTOOL 工具將數值圖形化並透過網頁顯示,比如系統 CPU 負載、記憶體大小、郵件佇列數等等任何只要你能使用它本身提供的 plugins 或自寫的。
Munin 也有 maseter/node 概念,意思就是可以中央控管圖形化每台主機的狀態。

1.) 安裝 munin munin-node
Munin is a server/node pair that graphs, htmlifies and optionally sends out notifications about data it gathers. It's designed to let it be easy to graph new datasources.

Munin-node is a perlscript listening to port 4949 using the Net::Server Perl module. It reads all the scripts in /etc/munin/plugins (or CONFDIR/plugins/, to be more spesific) on startup. The node accepts these commands:
2.) 設定 munin master

more /etc/munin/munin.conf
# 預設內容如下
dbdir   /var/lib/munin                                 # 儲存 rrd 資料檔
htmldir /var/www/html/munin                    # 儲存圖檔,會根據下面定義好的群組在此目錄底下建立群組目錄

[閱讀全文]

Mrtg + 其它應用

由 top指令得到 mysql的 CPU百分值

top -b -u mysql -n1 | grep mysqld | awk '{print $9}'

free指令取得記憶體容使用量

#!/bin/bash

memtotal=`free -m | grep "Mem:" | awk '{print $2}'`
memused=`free -m | grep "Mem:" | awk '{print $3}'`
memfree=`free -m | grep "Mem:" | awk '{print $4}'`

echo $memused
echo $memfree
echo $memtotal

   vi mrtg-mem.cfg

[閱讀全文]

標籤: 監控 mrtg

MRTG + sysstat + cpu loading on linux

[1] apt-get install sysstat

[2] mkdir /var/www/mrtg/cpu

[3] 利用sysstat 的 sar程式,來作監測CPU的script
      
      安裝套件
      apt-get install sysstat

      vi mrtg-sar.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}'`
echo $cpuusr
echo $cpusys

      測式

[閱讀全文]

標籤: 監控 mrtg