ot Krasen Tsonevski(10-02-2008)
reiting (30)
[ dobre ]
[ zle ]
Variant za otpechatvane
Nastoiashtata statiia ne e izcherpatelno rukovodstvo po temata, a
prosto spodelen opit. Ne pretendiram, che sum poznavach i
spetsialist v oblastta. Vuzmozhno e i da sum dopusnal i niakoia
greshka pri pisaneto na tazi statiia, za koeto molia da me
izvinite! Pri Ubuntu & Debian raboti !
1.Nuzhni paketi
net-snmp --> http://net-snmp.sourceforge.net/
gd --> http://www.libgd.org/
mrtg --> http://oss.oetiker.ch/mrtg/
dcron --> predpolagam, che distroto Vi shte go ima :)
apache --> http://www.apache.org/
2. Suzdavane na rabottna direktoriia
mkdir /etc/mrtg/
mkdir /etc/cron.mrtg
mkdir -p /var/www/mrtg/
3. Promiana na snmpd.conf
pico /etc/snmp/snmpd.conf
----------------------------------------------------------
com2sec local 127.0.0.1/32
public
com2sec local 192.168.20.0/24 public
group MyROGroup v1 local
group MyROGroup v2c local
group MyROGroup usm local
view all included .1
80
access MyROGroup "" any
noauth exact all
none none
syslocation MyLocation
syscontact Me <>
------------------------------------------------------------
4. Puskane na demona
/etc/init.d/snmpd start
/sbin/rc-update add snmpd default
5. Konfiguratsionnen fail
pico /etc/mrtg/mrtg.cfg
Dobaviame slednite redove za:
5.1 CPU
WorkDir: /var/www/mrtg/
LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt
Target[localhost.cpu]:ssCpuRawUser.0&ssCpuRawUser.0: +
ssCpuRawSystem.0&ssCpuRawSystem.0: +
ssCpuRawNice.0&ssCpuRawNice.0:
RouterUptime[localhost.cpu]:
MaxBytes[localhost.cpu]: 100
Title[localhost.cpu]: CPU Load
PageTop[localhost.cpu]: <H1>Active CPU Load
%</H1>
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]:
5.2 CPU Temp
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]: <H1>CPU
Temperature</H1>
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]:
#Unscaled[localhost.cpu-temp]: ymwd
#WithPeak[localhost.cpu-temp]: ymwd
XSize[localhost.cpu-temp]: 360
YSize[localhost.cpu-temp]: 75
#YTics[localhost.cpu-temp]: 10
Colours[localhost.cpu-temp]:
DKBLUE#61A0DF,DKBLUE#0000DD,DARKGREEN#006600,VIOLET#FF00FF
5.3 Memory
LoadMIBs: /usr/share/snmp/mibs/HOST-RESOURCES-MIB.txt
Target[localhost.mem]:
.1.3.6.1.4.1.2021.4.6.0&.1.3.6.1.4.1.2021.4.6.0:public@localhost
PageTop[localhost.mem]: <H1>Free
Memory</H1>
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
5.4 Open TCP Connection
Target[tcpopen]:
.1.3.6.1.2.1.6.9.0&.1.3.6.1.2.1.6.9.0:public@localhost
Options[tcpopen]: nopercent,growright,gauge,noinfo
WorkDir: /var/www/mrtg
Title[tcpopen]: Open TCP connections
PageTop[tcpopen]: <h1>Open TCP
connections</h1>
MaxBytes[tcpopen]: 1000000
YLegend[tcpopen]: # conns
ShortLegend[tcpopen]: connections
LegendI[tcpopen]: Connections:
LegendO[tcpopen]:
Legend1[tcpopen]: Open TCP connections
5.5 Swap
LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt
Target[localhost.swap]:
memAvailSwap.0&memAvailSwap.0:public@localhost
PageTop[localhost.swap]: <H1>Swap
Memory</H1>
WorkDir: /var/www/mrtg
Options[localhost.swap]:
nopercent,growright,gauge,noinfo
Title[localhost.swap]: Free 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
5.6 Ping
WorkDir: /var/www/mrtg
Title[localhost.ping]: Round Trip Time
PageTop[localhost.ping]: <H1>Round Trip
Time</H1>
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)
5.7 Network Stats
EnableIPv6: no
WorkDir: /home/www/mrtg
Options[_]: bits,growright
Refresh: 300
RunAsDaemon: Yes
Title[ppp0]: eth0 Network Stats
Target[ppp0]:`/etc/mrtg/net.sh eth0`
MaxBytes[ppp0]: 1250000
--------------------------------------------------------------
6. Script
Ping.sh
pico /etc/mrtg/ping.sh
-------------------------------------------------------------
#!/bin/sh
PING="/bin/ping"
# Google, for example
ADDR="google.com"
DATA=`$PING -c10 -s500 $ADDR -q `
LOSS=`echo $DATA | awk '{print $18 }' | tr -d %`
echo $LOSS
if [ $LOSS = 100 ];
then
echo
0
else
echo $DATA | awk -F/ '{print $5
}'
fi
----------------------------------------------------
pico /etc/mrtg/net.sh
-----------------------------------------------------
#!/bin/bash
#/usr/local/mrtg-2/bin/ifstat.sh
/sbin/ip -s link show dev $1|grep -A 1 RX|tail -n1 |awk
'{print $1}'
/sbin/ip -s link show dev $1|grep -A 1 TX|tail -n1 |awk
'{print $1}'
echo $1
echo $1
--------------------------------------------------------
/bin/chmod +x /etc/mrtg/ping.sh
/bin/chmod +X /etc/mrtg/net.sh
7. Index Page
/usr/bin/indexmaker --output=/var/www/mrtg/index.html \
--title="Power Under Control :)" \
--sort=name \
--enumerate \
/etc/mrtg/mrtg.cfg
8.Run MRTG
/usr/bin/mrtg --daemon /etc/mrtg/mrtg.cfg
9. Test
lynx http://localhost/mrtg/
Ami tova e! Ima oshte mnogo vuzmozhnosti ot roda na FTP SSH
WWW MYSQL IRC stats na broi kanektsii i temperatura na vashiia
hard i taka natatak, no mislia che tova e nai neobhodimoto ;)
<< | Kak da gledame BEZPLATNO bulgarska televiziia po internet? >>
|