==Kurulumlar==
Mrtg, verileri SNMP'den alır. Verileri de web üzerinden göstereceğimiz için
apache kuracağız. Bu sebeple MRTG ile beraber SNMP ve Apache2 kurmamız gerekiyor.
# apt-get install snmpd mrtg apache2
==SNMP ayarları==
Ardından SNMP sunucusunun konfigurasyon dosyasını değiştirmemiz gerekiyor, bu dosyayı herhani bir metin editörü ile açın.
# /etc/snmp/snmpd.conf
Bu dosyada aşağıdaki satırın başına, # koyun ki bu satır yorum satırı olarak algılansın.
com2sec paranoid default public
Ve aşağıdaki satırı ekleyin.
com2sec readonly default public
Ve SNMP sunucusunu yeniden başlatın.
/etc/init.d/snmpd restart
==MRTG Ayarları==
# mkdir /etc/mrtg
=Ağ Trafiği:
cfgmaker --output=/etc/mrtg/traffic.cfg \
--ifdesc=ip --ifref=descr \
--global "WorkDir: /var/www/mrtg/" \
--global "Options[_]: bits,growright" \
public@localhost
=Cpu:
/etc/mrtg/cpu.cfg:
WorkDir: /var/www/mrtg
LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt
Target[localhost.cpu]:ssCpuRawUser.0&ssCpuRawUser.0:public@127.0.0.1 + ssCpuRawSystem.0&ssCpuRawSystem.0:public@127.0.0.1 + ssCpuRawNice.0&ssCpuRawNice.0:public@127.0.0.1
RouterUptime[localhost.cpu]: public@127.0.0.1
MaxBytes[localhost.cpu]: 100
Title[localhost.cpu]: CPU Load
PageTop[localhost.cpu]: Active CPU Load %
Unscaled[localhost.cpu]: ymwd
ShortLegend[localhost.cpu]: %
YLegend[localhost.cpu]: CPU Utilization
Legend1[localhost.cpu]: Active CPU in % (Load)
Legend2[localhost.cpu]:
Legend3[localhost.cpu]:
Legend4[localhost.cpu]:
LegendI[localhost.cpu]: Active
LegendO[localhost.cpu]:
Options[localhost.cpu]: growright,nopercent
=Cpu Sıcaklığı:
/etc/mrtg/mrtg-cpu.cfg
LoadMIBs: /usr/share/snmp/mibs/LM-SENSORS-MIB.txt
Target[localhost.cpu-temp]: .1.3.6.1.4.1.2021.13.16.2.1.3.1&.1.3.6.1.4.1.2021.13.16.2.1.3.1:public@localhost
PageTop[localhost.cpu-temp]: CPU Temperature
WorkDir: /var/www/mrtg
Options[localhost.cpu-temp]: nopercent,growright,gauge,noinfo,pngdate,nobanner
Factor[localhost.cpu-temp]: 0.001
PNGTitle[localhost.cpu-temp]: CPU Temperature
Title[localhost.cpu-temp]: CPU Temperature
kMG[localhost.cpu-temp]: C
MaxBytes[localhost.cpu-temp]: 100000
YLegend[localhost.cpu-temp]: Temperature (c)
ShortLegend[localhost.cpu-temp]: C
LegendI[localhost.cpu-temp]: CPU Temperature:
LegendO[localhost.cpu-temp]:
Legend1[localhost.cpu-temp]: CPU Temperature
Legend2[localhost.cpu-temp]:
XSize[localhost.cpu-temp]: 360
YSize[localhost.cpu-temp]: 75
Colours[localhost.cpu-temp]: DKBLUE#61A0DF,DKBLUE#0000DD,DARKGREEN#006600,VIOLET#FF00FF
=Bellek:
/etc/mrtg/mem.cfg:
LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt
Target[localhost.mem]: memAvailReal.0&memAvailReal.0:public@localhost
PageTop[localhost.mem]: Free Memory
WorkDir: /var/www/mrtg
Options[localhost.mem]: nopercent,growright,gauge,noinfo
Title[localhost.mem]: Free Memory
MaxBytes[localhost.mem]: 1000000
kMG[localhost.mem]: k,M,G,T,P,X
YLegend[localhost.mem]: bytes
ShortLegend[localhost.mem]: bytes
LegendI[localhost.mem]: Free Memory:
LegendO[localhost.mem]:
Legend1[localhost.mem]: Free memory, not including swap, in bytes
=Swap:
/etc/mrtg/swap.cfg:
LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt
Target[localhost.swap]: memAvailSwap.0&memAvailSwap.0:public@localhost
PageTop[localhost.swap]: Swap Memory
WorkDir: /var/www/mrtg
Options[localhost.swap]: nopercent,growright,gauge,noinfo
Title[localhost.swap]: Free Swap Memory
MaxBytes[localhost.swap]: 1000000
kMG[localhost.swap]: k,M,G,T,P,X
YLegend[localhost.swap]: bytes
ShortLegend[localhost.swap]: bytes
LegendI[localhost.swap]: Free Memory:
LegendO[localhost.swap]:
Legend1[localhost.swap]: Swap memory avail, in bytes
=Ping:
/etc/mrtg/ping.cfg:
WorkDir: /var/www/mrtg
Title[localhost.ping]: Round Trip Time
PageTop[localhost.ping]: Round Trip Time
Target[localhost.ping]: `/etc/mrtg/ping.sh`
MaxBytes[localhost.ping]: 2000
Options[localhost.ping]: growright,unknaszero,nopercent,gauge
LegendI[localhost.ping]: Pkt loss %
LegendO[localhost.ping]: Avg RTT
YLegend[localhost.ping]: RTT (ms)
=Disk:
/etc/mrtg/disk.cfg:
WorkDir: /var/www/mrtg/
Title[localhost.disk]: Disk Usage
PageTop[localhost.disk]: Free Disk Storage
Target[localhost.disk]: `/etc/mrtg/disk.sh`
#MaxBytes[localhost.disk]: 3779571220480 378060509184
#MaxBytes[localhost.disk]: 3870280929771520
MaxBytes[localhost.disk]: 387133961404416
kMG[localhost.disk]: k,M,G,T,P,X
Options[localhost.disk]: nopercent,growright,gauge,noinfo
LegendI[localhost.disk]: Free Disk
LegendO[localhost.disk]: Used Disk
YLegend[localhost.disk]: bytes
ShortLegend[localhost.disk]: bytes
Legend1[localhost.disk]: Available disk storage, in bytes
Legend2[localhost.disk]: Used disk storage, in bytes
=ping.sh:
/etc/mrtg/ping.sh:
#!/bin/sh
PING="/bin/ping"
# Google, for example
ADDR="google.com"
DATA=`$PING -c10 -s500 $ADDR -q 2>/dev/null`
if [ "$?" -eq "2" ]; then
echo 0
echo 0
exit 0
fi
LOSS=`echo $DATA | awk '{print $18 }' | tr -d %`
echo $LOSS
if [ $LOSS = 100 ];
then
echo 0
else
echo $DATA | awk -F/ '{print $5 }'
fi
=disk.sh:
/etc/mrtg/disk.sh:
#!/bin/sh
df |grep sda1| awk '{print $4}'
df |grep sda1| awk '{print $3}'
==Apache için index sayfasını oluşturmak==
/usr/bin/indexmaker --output=/var/www/mrtg/index.html \
--title="MRTG Istatistikleri :)" \
--sort=name \
--enumerate \
/etc/mrtg/traffic.cfg \
/etc/mrtg/cpu.cfg \
/etc/mrtg/disk.cfg \
/etc/mrtg/mem.cfg \
/etc/mrtg/swap.cfg \
/etc/mrtg/ping.cfg
==Crontab Ayarları==
/etc/cron.d/mrtg:
*/5 * * * * env LANG=C mrtg /etc/mrtg/cpu.cfg
*/5 * * * * env LANG=C mrtg /etc/mrtg/disk.cfg
*/5 * * * * env LANG=C mrtg /etc/mrtg/mem.cfg
*/5 * * * * env LANG=C mrtg /etc/mrtg/ping.cfg
*/5 * * * * env LANG=C mrtg /etc/mrtg/swap.cfg
*/5 * * * * env LANG=C mrtg /etc/mrtg/traffic.cfg
Kaynak:
http://www.debian-administration.org/articles/366
http://gentoo-wiki.com/HOWTO_SNMP_and_MRTG_Made_Easy
Ağustos 11, 2008
Debian/Ubuntu üzerinde MRTG
Kaydol:
Kayıt Yorumları (Atom)

0 yorum:
Yorum Gönder