|
Użytkownik |
Rejestracja: sobota, 7 sierpnia 2004, 07:16 Posty: 194
|
Konfigurator:
#!/bin/sh
#. /etc/rc.conf
[ -z $SCRIPT ] && SCRIPT=/tmp/nndconf.sh BACKTITLE="Konfigurator NND" CONFIG_NAME="mrtg" CONFIG_DESCR="Konfiguracja statystyk MRTG"
# Zmienne plikow i katalogow mrtg_conf_dir="/etc/mrtg" script_dir=$mrtg_conf_dir mrtg_conf_file="mrtg.conf" mrtg_www_dir="/var/www/html/mrtg" mrtg_ip_file="ipki.txt" tmp_dir="/tmp" interfejsy_file="interfejs" tytul_strony="Statystyki serwera NND" msg_cancel="Konfiguracja przerwana przez u?ytkownika\n\nNie zapisano ?adnych zmian.\n" title_koniec=" Konfiguracja zako?czona " title_cancel=" Konfiguracja przerwana " # Zmienne dodatkowe bkg=e0e0e0 txt=00007f OK=1 arpscan_installed=0
info() { dialog --stdout --backtitle "$CONFIG_DESCR" \ --title " $1 " \ --colors \ --no-shadow \ --no-collapse \ --ok-label "$3" \ --msgbox \ "$2" 0 0 }
konfiguruj() {
grep -w '^DAEMONS.*httpd' /etc/rc.conf >/dev/null [ $? = 0 ] && mrtg_www_dir="/var/www/html/mrtg"
www_dir=`dialog --stdout --title "Wyb?r katalogu WWW" --backtitle "$CONFIG_DESCR" \ --inputbox "Wpisz scie?k? do katalogu twojego serwera WWW." 10 40 \ "$mrtg_www_dir" ` if [ $? == 0 ]; then [ "$www_dir" != "" ] && mrtg_www_dir=$www_dir else return 1 fi
# Przygotowanie listy interfejsow ifconfig|grep encap|awk '{print $1}'|grep -v ^lo>$tmp_dir/$interfejsy_file
for each in `cat /proc/net/dev | grep -E "^(.*):" | grep -v lo | cut -f 1 -d ':'` do IFACES="$IFACES $each $each on"; done
wybor_interfejsow=`dialog --stdout --clear --separate-output --title "Wybor interfejsow routera" \ --backtitle "$CONFIG_DESCR" --separate-output --checklist \ "Zaznacz interfejsy, na ktorych chcesz zliczac:" 16 70 10 $IFACES`
[ $? != 0 ] && return 1
# Przygotowanie pliku z adresami IP sieci lokalnej (za maskarada) >$tmp_dir/$mrtg_ip_file grep "^" /etc/hosts | grep -v "^#"|grep [0123456789] |while read IP nazwa ; do echo $IP >> $tmp_dir/$mrtg_ip_file done
for each in `cat $tmp_dir/$mrtg_ip_file`;do ADDRESSES="$ADDRESSES $each $each on"; done
wybor_ip=`dialog --stdout --clear --separate-output --title "Wybor adresow IP sieci lokalnej" \ --backtitle "$CONFIG_DESCR" --separate-output --checklist \ "Zaznacz adresy IP sieci lokalnej, na ktorych chcesz zliczac:\n\nUWAGA - ten sam IP nie mo?e by? zaznaczony dwukrotnie !!!" 22 70 12 $ADDRESSES`
[ $? != 0 ] && return 1
for each in `mount | awk -F"\/| " '/hd/ {print $3}'` do DISKS="$DISKS $each $each on"; done for each in `mount | awk -F"\/| " '/sd/ {print $3}'` do DISKS="$DISKS $each $each on"; done for each in `mount | awk -F"\/| " '/cc/ {print $4}'` do DISKS="$DISKS $each $each on"; done # for each in `mount|grep hd|sed s/\\\\/dev\\\\///|awk '{print $1}'` # do DISKS="$DISKS $each $each on"; # done # for each in `mount|grep sd|sed s/\\\\/dev\\\\///|awk '{print $1}'` # do DISKS="$DISKS $each $each on"; # done
wybor_dysk=`dialog --stdout --clear --separate-output --title "Wybor dyskow twardych" \ --backtitle "$CONFIG_DESCR" --separate-output --checklist \ "Zaznacz dyski twarde, ktore chcesz monitorowac:" 16 70 10 $DISKS`
[ $? != 0 ] && return 1
MEMORY="mem mem on swap swap on";
wybor_mem=`dialog --stdout --clear --separate-output --title "Wybor pamieci routera" \ --backtitle "$CONFIG_DESCR" --separate-output --checklist \ "Zaznacz rodzaje pamieci, ktore chcesz monitorowac:" 16 70 10 $MEMORY`
[ $? != 0 ] && return 1
info "Informacja" "W nast?pnym oknie zostaniesz poproszony o wybranie sposobu - skryptu do zliczania aktywnych host?w.\n\n Sugerowany skrypt to 'hosty.iptables' - zlicza on aktywne hosty na podstawie generowanego przez nie ruchu w sieci. Nie wymaga konfiguracji.\n\n Skrypt 'hosty.arpscan' skanuje sie? za pomoc? protoko?u ARP. Jego wykonanie zajmuje wi?cej czasu i zasob?w, ni? w przypadku skryptu 'hosty.iptables', szczeg?lnie dla du?ej sieci, jednak jest on dok?adniejszy - wykryje ka?dy w??czony komputer, cho?by nie przesy?a? ?adnych danych.\n\n UWAGA - aby korzysta? ze skryptu 'hosty.arpscan', nalezy zainstalowa? pakiet 'arpscan' oraz dokona? konfiguracji skryptu, wpisuj?c w nim interfejsy i zakresy adres?w IP do skanowania (informacje znajdziesz w skrypcie - /etc/mrtg/hosty.arpscan)." \ "Dalej" hosty=`dialog --stdout --backtitle "$BACKTITLE" \ --title " Skrypt do zliczania aktywnych host?w " \ --colors \ --no-shadow \ --no-collapse \ --cancel-label "Zako?cz" \ --yes-label "Akceptuj" \ --radiolist \ " Wybierz spos?b - skrypt do zliczania aktywnych host?w: " 12 60 2 \ "iptables" " - hosty.iptables (sugerowany)" "on" \ "arpscan" " - hosty.arpscan" "off"`
[ $? != 0 ] && return 1 case $hosty in 'arpscan') hosty_opt='iptables' ;; 'iptables') hosty_opt='arpscan' ;; esac
return 0
} # <----------------- END konfiguruj() ------------------------------
zapisz_konfiguracje() {
[ ! -d $mrtg_conf_dir ] && mkdir -p $mrtg_conf_dir
[ ! -d $mrtg_www_dir ] && mkdir -p $mrtg_www_dir
#BACKUP if [ -f $mrtg_conf_dir/$mrtg_conf_file ]; then data=`date +%Y%m%d-%H%M-` mv $mrtg_conf_dir/$mrtg_conf_file $mrtg_conf_dir/${data}${mrtg_conf_file}.bak > /dev/null 2>&1 msg_konf="\nNowe pliki konfiguracyjne zosta?y utworzone.\n\nStary konfig zapisano jako\n $mrtg_conf_dir/${data}${mrtg_conf_file}.bak\n\n" else msg_konf="\nPliki konfiguracyjne oraz indeks strony WWW zosta?y utworzone.\n\nJe?li chcesz, aby MRTG startowa? razem z systemem, \ zajrzyj do pliku /etc/rc.conf i usu? wykrzyknik przed 'mrtg' w zmiennej 'DAEMONS'.\n\n" fi
# Prekonfiguracja cat > $script_dir/mrtg.run <<!EOF #!/bin/bash while :; do sleep 300 mrtg /etc/mrtg/mrtg.conf 1>/dev/null 2>&1 #mrtg /etc/mrtg/mrtg.conf 1>/etc/mrtg/mrtg.log 2>&1 done !EOF chmod +x $script_dir/mrtg.run
cat > $mrtg_conf_dir/$mrtg_conf_file <<!EOF ###################################################################### # Multi Router Traffic Grapher -- Example Configuration File ###################################################################### # This file is for use with mrtg-2.0
Language: polish # Parametry globalne WorkDir: $mrtg_www_dir XSize[_]: 500 YSize[_]: 80 Options[_]: growright, gauge, nopercent, integer, nobanner, noinfo BodyTag[_]: <BODY LEFTMARGIN="1" TOPMARGIN="1" bgcolor="$bkg" text="$txt" link="#dd3333" vlink="#dd33dd" alik="#A90000"> PageFoot[_]: </center>
!EOF
for each in $wybor_interfejsow do echo "## Interfejs $each" >>$mrtg_conf_dir/$mrtg_conf_file; echo "Target[$each]: \`awk -F \":( *)| +\" '/$each/ {print \$3\"\\n\"\$11}' /proc/net/dev\`" >>$mrtg_conf_dir/$mrtg_conf_file; echo "MaxBytes[$each]: 12500000" >>$mrtg_conf_dir/$mrtg_conf_file; echo "Options[$each]: growright, nopercent, integer, nobanner, noinfo" >>$mrtg_conf_dir/$mrtg_conf_file; echo "Title[$each]: $each" >>$mrtg_conf_dir/$mrtg_conf_file; echo "kilo[$each]: 1024" >>$mrtg_conf_dir/$mrtg_conf_file; echo "ShortLegend[$each]: B/s" >>$mrtg_conf_dir/$mrtg_conf_file; echo "YLegend[$each]: B/s" >>$mrtg_conf_dir/$mrtg_conf_file; echo "PageTop[$each]:<center> <H1>$each</H1>" >>$mrtg_conf_dir/$mrtg_conf_file; echo "" >>$mrtg_conf_dir/$mrtg_conf_file; done
>$mrtg_conf_dir/$mrtg_ip_file for i in $wybor_ip do echo "## Komp $i" >>$mrtg_conf_dir/$mrtg_conf_file; echo "Target[$i]: \`iptables -t mangle -L mrtg_traffic -v -x -n | awk '/ $i / {print \$2}'\`" >>$mrtg_conf_dir/$mrtg_conf_file; echo "MaxBytes[$i]: 12500000" >>$mrtg_conf_dir/$mrtg_conf_file; echo "Options[$i]: growright, nopercent, integer, nobanner, noinfo" >>$mrtg_conf_dir/$mrtg_conf_file; #echo "Title[$i]: $i     [ `resolveip -s $i` ]">>$mrtg_conf_dir/$mrtg_conf_file; echo "Title[$i]: $i     [ $i ]">>$mrtg_conf_dir/$mrtg_conf_file; echo "kilo[$i]: 1024" >>$mrtg_conf_dir/$mrtg_conf_file; echo "ShortLegend[$i]: B/s" >>$mrtg_conf_dir/$mrtg_conf_file; echo "YLegend[$i]: B/s" >>$mrtg_conf_dir/$mrtg_conf_file; #echo "PageTop[$i]:<center> <H1>$i     [ `resolveip -s $i` ]</H1>" >>$mrtg_conf_dir/$mrtg_conf_file; echo "PageTop[$i]:<center> <H1>$i     [ $i ]</H1>" >>$mrtg_conf_dir/$mrtg_conf_file; echo "" >>$mrtg_conf_dir/$mrtg_conf_file; echo $i >>$mrtg_conf_dir/$mrtg_ip_file; done
cat >>$mrtg_conf_dir/$mrtg_conf_file <<!EOF
## Ilosc uzytkownikow Target[hosty]: \`$script_dir/hosty.$hosty\` #Target[hosty]: \`$script_dir/hosty.$hosty_opt\` Title[hosty]: Ilo?? u?ytkownik?w PageTop[hosty]: <center> <H1>Ilo?? u?ytkownik?w</H1> MaxBytes[hosty]: 300 kilo[hosty]: 1000 ShortLegend[hosty]: YLegend[hosty]: ilosc Legend1[hosty]: Aktywne Legend2[hosty]: Wszystkie LegendI[hosty]: aktywne LegendO[hosty]: wszystkie #Options[hosty]: growright, gauge, nopercent, integer, nobanner, noinfo, nolegend
## Procek Target[cpu]: \`awk '/cpu /{print \$4; print \$2+\$3+\$4}' /proc/stat\` Title[cpu]: U?ycie procesora na serwerze PageTop[cpu]: <center> <H1>U?ycie procesora na serwerze</H1> MaxBytes[cpu]: 100 Unscaled[cpu]: ymwd Options[cpu]: growright, nopercent, integer, nobanner, noinfo LegendI[cpu]: user: LegendO[cpu]: total: Ylegend[cpu]: % ShortLegend[cpu]: % Legend1[cpu]: Czas spedzony trybie user Legend2[cpu]: Czas spedzony trybie user + czas spedzony trybie system
!EOF
for i in $wybor_dysk do echo "## DYSK $i" >>$mrtg_conf_dir/$mrtg_conf_file; echo "Target[$i]: \`df|awk '/$i/ {print \$3\"\\n\"\$4}'\`" >>$mrtg_conf_dir/$mrtg_conf_file; echo "MaxBytes[$i]: `df|grep $i|awk '{print $2}'`" >>$mrtg_conf_dir/$mrtg_conf_file; echo "#Options[$i]: gauge, growright" >>$mrtg_conf_dir/$mrtg_conf_file; echo "Unscaled[$i]: ymdw" >>$mrtg_conf_dir/$mrtg_conf_file; echo "Title[$i]: Dysk $i" >>$mrtg_conf_dir/$mrtg_conf_file; echo "kMG[$i]:K,M,G,T" >>$mrtg_conf_dir/$mrtg_conf_file; echo "kilo[$i]: 1024" >>$mrtg_conf_dir/$mrtg_conf_file; echo "ShortLegend[$i]:B" >>$mrtg_conf_dir/$mrtg_conf_file; echo "YLegend[$i]: Megabajty" >>$mrtg_conf_dir/$mrtg_conf_file; echo "PageTop[$i]:<CENTER> <H1>Zajetosc dysku $i</H1>" >>$mrtg_conf_dir/$mrtg_conf_file; echo "LegendI[$i]: Used:">>$mrtg_conf_dir/$mrtg_conf_file; echo "LegendO[$i]: Free:">>$mrtg_conf_dir/$mrtg_conf_file; echo "Legend1[$i]: Obszar zajety">>$mrtg_conf_dir/$mrtg_conf_file; echo "Legend2[$i]: Obszar wolny">>$mrtg_conf_dir/$mrtg_conf_file; echo "" >>$mrtg_conf_dir/$mrtg_conf_file; done
if [ `cat /proc/meminfo|grep Swap:|awk '{print $2}'` ]; then if [ "`echo $wybor_mem|grep swap`" != "" ]; then echo "## Swap">>$mrtg_conf_dir/$mrtg_conf_file; echo "Target[swap]: \`awk '/Swap:/ {print \$3\"\\n\"\$2}' /proc/meminfo\`">>$mrtg_conf_dir/$mrtg_conf_file; echo "#Options[swap]: gauge,growright">>$mrtg_conf_dir/$mrtg_conf_file; echo "MaxBytes[swap]: `cat /proc/meminfo|grep Swap:|awk '{print $2}'`" >>$mrtg_conf_dir/$mrtg_conf_file; echo "LegendI[swap]: Used:">>$mrtg_conf_dir/$mrtg_conf_file; echo "LegendO[swap]: Total:">>$mrtg_conf_dir/$mrtg_conf_file; echo "kilo[swap]: 1024">>$mrtg_conf_dir/$mrtg_conf_file; echo "ShortLegend[swap]:B">>$mrtg_conf_dir/$mrtg_conf_file; echo "Ylegend[swap]: Megabajty">>$mrtg_conf_dir/$mrtg_conf_file; echo "Title[swap]: Pami?? swap">>$mrtg_conf_dir/$mrtg_conf_file; echo "PageTop[swap]:<CENTER> <H1>Pami?? Swap</H1>">>$mrtg_conf_dir/$mrtg_conf_file; echo "Legend1[swap]: Swap uzywany">>$mrtg_conf_dir/$mrtg_conf_file; echo "Legend2[swap]: Swap calkowity">>$mrtg_conf_dir/$mrtg_conf_file; echo " " >>$mrtg_conf_dir/$mrtg_conf_file; fi fi
if [ "`echo $wybor_mem|grep mem`" != "" ]; then echo "## Pami??">>$mrtg_conf_dir/$mrtg_conf_file; echo "Target[mem]: \`awk '/Mem:/ {print \$3\"\\n\"\$2}' /proc/meminfo\`" >>$mrtg_conf_dir/$mrtg_conf_file; echo "MaxBytes[mem]: `cat /proc/meminfo|grep Mem:|awk '{print $2}'`" >>$mrtg_conf_dir/$mrtg_conf_file; echo "#Options[mem]: gauge, growright" >>$mrtg_conf_dir/$mrtg_conf_file; echo "Unscaled[mem]: ymdw" >>$mrtg_conf_dir/$mrtg_conf_file; echo "Title[mem]: Pami?? fizyczna" >>$mrtg_conf_dir/$mrtg_conf_file; echo "kilo[mem]: 1024" >>$mrtg_conf_dir/$mrtg_conf_file; echo "ShortLegend[mem]:B" >>$mrtg_conf_dir/$mrtg_conf_file; echo "YLegend[mem]: Megabajty" >>$mrtg_conf_dir/$mrtg_conf_file; echo "LegendI[mem]: Used:">>$mrtg_conf_dir/$mrtg_conf_file; echo "LegendO[mem]: Total:">>$mrtg_conf_dir/$mrtg_conf_file; echo "PageTop[mem]:<center> <H1>Pami?? fizyczna</H1>" >>$mrtg_conf_dir/$mrtg_conf_file; echo "Legend1[mem]: Pamiec uzywana">>$mrtg_conf_dir/$mrtg_conf_file; echo "Legend2[mem]: Pamiec calkowita">>$mrtg_conf_dir/$mrtg_conf_file; echo "" >>$mrtg_conf_dir/$mrtg_conf_file; fi
echo "## Procesy">>$mrtg_conf_dir/$mrtg_conf_file; echo "Target[procesy]: \`awk -F\" |/\" '{print \$5-1\"\\n\"\$4-2}' /proc/loadavg\`">>$mrtg_conf_dir/$mrtg_conf_file; echo "#Options[procesy]: growright, gauge, nopercent, integer">>$mrtg_conf_dir/$mrtg_conf_file; echo "MaxBytes[procesy]: 30000">>$mrtg_conf_dir/$mrtg_conf_file; echo "kilo[procesy]: 1000">>$mrtg_conf_dir/$mrtg_conf_file; echo "Title[procesy]: Ilo?? proces?w">>$mrtg_conf_dir/$mrtg_conf_file; echo "PageTop[procesy]: <center> <H1>Ilo?? proces?w w systemie</H1>">>$mrtg_conf_dir/$mrtg_conf_file; echo "ShortLegend[procesy]: ">>$mrtg_conf_dir/$mrtg_conf_file; echo "YLegend[procesy]: Procesy">>$mrtg_conf_dir/$mrtg_conf_file; echo "Legend1[procesy]: Ilo?? wszystkich proces?w w systemie">>$mrtg_conf_dir/$mrtg_conf_file; echo "Legend2[procesy]: Ilo?? dzia?aj?cych proces?w">>$mrtg_conf_dir/$mrtg_conf_file; echo "LegendI[procesy]: procesy:">>$mrtg_conf_dir/$mrtg_conf_file; echo "LegendO[procesy]: dzia?aj?ce:">>$mrtg_conf_dir/$mrtg_conf_file;
grep -w '^DAEMONS.*mrtg' /etc/rc.conf >/dev/null [ $? = 0 ] || sed -i "/^DAEMONS=/s/)$/ !mrtg)/" /etc/rc.conf
mv $mrtg_www_dir/index.html $mrtg_www_dir/`date +%Y%m%d-%H%M`index.html &>/dev/null
/usr/local/mrtg-2/bin/indexmaker \ --title="$tytul_strony" \ --bodyopt="bgcolor=\"#$bkg\" text=\"#$txt\"" \ --pagetop="<center>" \ --pageend="</center>" \ --columns=1 \ --addhead="<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-2\">" \ --output=$mrtg_www_dir/index.html $mrtg_conf_dir/$mrtg_conf_file
title_conf="Konfiguracja zako?czona."
} # <-------------------- END zapisz_konfiguracje() ----------------------------------------
instaluj_arpscan() { if [ "$hosty" == "arpscan" ]; then pacman -Q arpscan > /dev/null 2>&1 if [ $? != 0 ]; then wybor=`dialog --stdout --backtitle "$CONFIG_DESCR" \ --title " Instalacja pakietu 'arpscan' " \ --colors \ --no-shadow \ --no-collapse \ --no-label "Nie" \ --yes-label "Tak" \ --yesno "Jako skrypt zliczaj?cy hosty online wybra?e? 'hosty.arpscan' wymagaj?cy pakietu 'arpscan'.\n\n Pakiet 'arpscan' nie jest zainstalowany.\n\nCzy chcesz go teraz zainstalowa? ?" 0 0` if [ $? == 0 ]; then pacman -Sy --noconfirm arpscan > /dev/null 2>&1 if [ $? != 0 ]; then msg_arpscan="\n\nWyst?pi? b??d podczas instalacji pakietu 'arpscan' !!!\n\nSprawd? ustawienia repozytori?w w pliku\n /etc/pacman.conf\ni spr?buj zainstalowa? pakiet ponownie poleceniem\n pacman -Sy arpscan" else msg_arpscan="\n\nPakiet 'arpscan' zosta? zainstalowany." fi else msg_arpscan="\n\nNie zapomnij zainstalowa? pakietu 'arpscan' !!!" fi fi fi }
# < ------------------ END instaluj_arpscan() ----------------------------
konfig_aktual() {
info "Informacja" "W nast?pnym oknie wybierz wykresy, dla kt?rych dane maj? by? zbierane przy u?yciu nowych skrypt?w.\n\n Usuni?cie zaznaczenia z kt?rej? pozycji spowoduje, ?e dane dla odpowiadaj?cego jej wykresu, b?d? zbierane przy u?yciu dotychczasowego skryptu." "Dalej"
wybor=`dialog --stdout --backtitle "$CONFIG_DESCR" \ --title " Skrypty do pobierania danych " \ --colors \ --no-shadow \ --no-collapse \ --cancel-label "Zako?cz" \ --yes-label "Akceptuj" \ --separate-output \ --checklist \ " Wybierz wykresy, dla kt?rych dane maj? by? zbierane przy u?yciu NOWYCH skrypt?w.
Nie zaznaczone - pozostawia dotychczasowy skrypt. " 0 0 7 \ "1" "Ruch na interfejsach" "on" \ "2" "Ruch host?w" "on" \ "3" "Swap" "on" \ "4" "Pami??" "on" \ "5" "Procesy" "on" \ "6" "Obci??enie procka" "on" \ "7" "Dyski" "on"`
if [ $? == 0 ]; then for i in $wybor; do case $i in 1) interfejsy='zmien' ;; 2) ipki='zmien' ;; 3) swap='zmien' ;; 4) memory='zmien' ;; 5) procesy='zmien' ;; 6) procek='zmien' ;; 7) dyski='zmien' ;; esac done else return 1 fi
info "Informacja" "W nast?pnym oknie zostaniesz poproszony o wybranie sposobu (skryptu), kt?rego MRTG ma u?ywa? do zliczania aktywnych host?w.\n\n Sugerowany skrypt to 'hosty.iptables' - zlicza on aktywne hosty na podstawie generowanego przez nie ruchu w sieci. Nie wymaga konfiguracji.\n\n Skrypt 'hosty.arpscan' skanuje sie? za pomoc? protoko?u ARP. Jego wykonanie zajmuje wi?cej czasu i zasob?w, ni? w przypadku skryptu 'hosty.iptables', szczeg?lnie dla du?ej sieci, jednak jest on dok?adniejszy - wykryje ka?dy w??czony komputer, cho?by nie przesy?a? ?adnych danych.\n UWAGA - aby korzysta? z tego skryptu, nalezy zainstalowa? pakiet 'arpscan' oraz dokona? konfiguracji skryptu, wpisuj?c w nim interfejsy i zakresy adres?w IP do skanowania (informacje znajdziesz w skrypcie - /etc/mrtg/hosty.arpscan)." \ "Dalej" hosty=`dialog --stdout --backtitle "$CONFIG_DESCR" \ --title " Skrypt do zliczania aktywnych host?w " \ --colors \ --no-shadow \ --no-collapse \ --cancel-label "Zako?cz" \ --yes-label "Akceptuj" \ --radiolist \ " Wybierz skrypt, za pomoc? kt?rego MRTG ma zlicza? aktywne hosty: " 12 50 3 \ "bez zmian" "Pozostaw dotychczasowy skrypt" "off" \ "iptables" "hosty.iptables (sugerowany)" "on" \ "arpscan" "hosty.arpscan" "off"`
[ $? != 0 ] && return 1 case $hosty in 'arpscan') hosty_opt='iptables' ;; 'iptables') hosty_opt='arpscan' ;; esac return 0 } # <------------- END konfig_aktual() --------------------------------------
aktualizuj() {
data=`date +%Y%m%d-%H%M_` cp $mrtg_conf_dir/$mrtg_conf_file $mrtg_conf_dir/${data}${mrtg_conf_file}.bak > /dev/null 2>&1
[ "$ipki" == "zmien" ] && \ sed -i -e "s:^Target\[\(.*\)\.\(.*\)\.\(.*\)\.\(.*\)\]\(.*\):#Target\[\1.\2.\3.\4\]\5\n\ Target\[\1.\2.\3.\4\]\: \`iptables -t mangle -L mrtg_traffic -v -x -n | awk '/ \1.\2.\3.\4 / {print \$2}'\`:" $mrtg_conf_dir/$mrtg_conf_file
[ "$interfejsy" == "zmien" ] && \ sed -i -e "s:^Target\[eth\(.*\)\]\(.*\):#Target\[eth\1\]\2\n\ Target\[eth\1\]\: \`awk -F \"\:( *)| +\" '/eth\1/ {print \$3\"\\\n\"\$11}' /proc/net/dev\`:" \ -e "s:^Target\[ppp\(.*\)\]\(.*\):#Target\[ppp\1\]\2\n\ Target\[ppp\1\]\: \`awk -F \"\:( *)| +\" '/ppp\1/ {print \$3\"\\\n\"\$11}' /proc/net/dev\`:" $mrtg_conf_dir/$mrtg_conf_file
[ "$hosty" != "bez zmian" ] && \ sed -i -e "s:^Target\[hosty\]\:\(.*\):Target\[hosty\]\: \`$script_dir/hosty.$hosty\`\n\ #Target\[hosty\]\: \`$script_dir/hosty.$hosty_opt\`\n#Target\[hosty\]\:\1:" $mrtg_conf_dir/$mrtg_conf_file
[ "$swap" == "zmien" ] && \ sed -i -e "s:^Target\[swap\]\(.*\):#Target\[swap\]\1\n\ Target\[swap\]\: \`awk '/Swap\:/ {print \$3\"\\\n\"\$2}' /proc/meminfo\`:" $mrtg_conf_dir/$mrtg_conf_file
[ "$memory" == "zmien" ] && \ sed -i -e "s:^Target\[mem\]\(.*\):#Target\[mem\]\1\n\ Target\[mem\]\: \`awk '/Mem\:/ {print \$3\"\\\n\"\$2}' /proc/meminfo\`:" $mrtg_conf_dir/$mrtg_conf_file
[ "$procesy" == "zmien" ] && \ sed -i -e "s:^Target\[procesy\]\(.*\):#Target\[procesy\]\1\n\ Target\[procesy\]\: \`awk -F\" |/\" '{print \$5-1\"\\\n\"\$4-2}' /proc/loadavg\`:" \ -e "s:\\\ :\\\:g" $mrtg_conf_dir/$mrtg_conf_file
[ "$procek" == "zmien" ] && \ sed -i -e "s:^Target\[cpu\]\(.*\):#Target\[cpu\]\1\n\ Target\[cpu\]\: \`awk '/cpu /{print \$4; print \$2+\$3+\$4}' /proc/stat\`:" $mrtg_conf_dir/$mrtg_conf_file
[ "$dyski" == "zmien" ] && \ sed -i -e "s:^Target\[\([h|s]\)d\([a-z][0-9]\)\]\(.*\):#Target\[\1d\2\]\3\n\ Target\[\1d\2\]\: \`df|awk '/\1d\2/ {print \$3\"\\\n\"\$4}'\`:" $mrtg_conf_dir/$mrtg_conf_file
msg_konf="Plik /etc/mrtg/mrtg.conf zosta? zaktualizowany.\n\nStary konfig zapisano jako\n $mrtg_conf_dir/${data}${mrtg_conf_file}.bak" title_konf="Aktualizacja zako?czona" } # <------------ END aktualizuj() -----------------------------------
# ------------------- MAIN ----------------------------------------->
if [ -f $mrtg_conf_dir/$mrtg_conf_file ]; then
info "Informacja" "Je?li chcesz na nowo \"od zera\" skonfigurowa? MRTG, w nastepnym oknie wybierz pierwsz? opcj? - 'Nowa'.\n Zostan? wygenerowane nowe pliki konfiguracyjne i nowy indeks strony www. Je?li do /etc/mrtg/mrtg.conf by?y dopisywane dodatkowe wykresy - zostan? one utracone, przy czym dotychczasowe pliki konfiguracyjne b?d? zarchiwizowane.\n\n Je?li chcesz zaktualizowa? polecenia i skrypty do zbierania danych, w nast?pnym oknie wybierz opcj? - 'Aktualizacja'\n Plik konfiguracyjny /etc/mrtg/mrtg.conf zostanie zaktualizowany (przedtem wykonana zostanie kopia zapasowa), za? indeks strony www pozostanie nie zmieniony." \ "Dalej"
tryb=`dialog --stdout --backtitle "$BACKTITLE" \ --title " Wyb?r trybu konfiguracji " \ --colors \ --no-shadow \ --no-collapse \ --cancel-label "Rezygnuj" \ --yes-label "OK" \ --radiolist \ " Wybierz tryb konfiguracji: " 12 70 2 \ " Nowa " " - wygeneruje ponownie pliki konfiguracyjne" "on" \ " Aktualizacja" " - aktualizacja mrtg.conf" "off"`
else tryb=' Nowa ' fi
if [ $? == 0 ]; then case $tryb in ' Nowa ') konfiguruj [ $? != 0 ] && OK=0 || zapisz_konfiguracje ;; ' Aktualizacja') konfig_aktual [ $? != 0 ] && OK=0 || aktualizuj ;; esac if [ "$hosty" == "arpscan" ]; then msg_hosty="\n\nNie zapomnij wyedytowa? pliku /etc/mrtg/hosty.arpscan !!!" instaluj_arpscan fi else OK=0 fi
[ $OK == 1 ] && info "$title_koniec" "${msg_konf}${msg_arpscan}${msg_hosty}" "OK" \ || info "$title_cancel" "$msg_cancel" "OK"
rm -f $tmp_dir/$mrtg_ip_file > /dev/null 2>&1 rm -f $tmp_dir/$interfejsy_file > /dev/null 2>&1
clear
# Nie edytuj poni?ej tej linii ------------------------>
tmp=`dialog --stdout --backtitle "$BACKTITLE" \\ --title " Konfiguracja Zako?czona " --radiolist \\ "
Konfiguracja $CONFIG_NAME zako?czona. Chcesz konfigurowa? inn? us?ug??
" 13 60 2 \\ "nie" "wyj?cie z nndconf" "on" \\ "tak" "powr?t do listy wyboru us?ug" "off"`
case $tmp in tak) clear exec $SCRIPT ;; *) rm -f $SCRIPT clear exit 0 ;; esac
a to wynik mrtg.conf: ###################################################################### # Multi Router Traffic Grapher -- Example Configuration File ###################################################################### # This file is for use with mrtg-2.0
Language: polish # Parametry globalne WorkDir: /var/www/html/mrtg XSize[_]: 500 YSize[_]: 80 Options[_]: growright, gauge, nopercent, integer, nobanner, noinfo BodyTag[_]: <BODY LEFTMARGIN="1" TOPMARGIN="1" bgcolor="e0e0e0" text="00007f" link="#dd3333" vlink="#dd33dd" alik="#A90000"> PageFoot[_]: </center>
## Interfejs eth1 Target[eth1]: `awk -F ":( *)| +" '/eth1/ {print $3"\n"$11}' /proc/net/dev` MaxBytes[eth1]: 12500000 Options[eth1]: growright, nopercent, integer, nobanner, noinfo Title[eth1]: eth1 kilo[eth1]: 1024 ShortLegend[eth1]: B/s YLegend[eth1]: B/s PageTop[eth1]:<center> <H1>eth1</H1>
## Interfejs eth0 Target[eth0]: `awk -F ":( *)| +" '/eth0/ {print $3"\n"$11}' /proc/net/dev` MaxBytes[eth0]: 12500000 Options[eth0]: growright, nopercent, integer, nobanner, noinfo Title[eth0]: eth0 kilo[eth0]: 1024 ShortLegend[eth0]: B/s YLegend[eth0]: B/s PageTop[eth0]:<center> <H1>eth0</H1>
## Interfejs pan0 Target[pan0]: `awk -F ":( *)| +" '/pan0/ {print $3"\n"$11}' /proc/net/dev` MaxBytes[pan0]: 12500000 Options[pan0]: growright, nopercent, integer, nobanner, noinfo Title[pan0]: pan0 kilo[pan0]: 1024 ShortLegend[pan0]: B/s YLegend[pan0]: B/s PageTop[pan0]:<center> <H1>pan0</H1>
## Komp 127.0.0.1 Target[127.0.0.1]: `iptables -t mangle -L mrtg_traffic -v -x -n | awk '/ 127.0.0.1 / {print $2}'` MaxBytes[127.0.0.1]: 12500000 Options[127.0.0.1]: growright, nopercent, integer, nobanner, noinfo Title[127.0.0.1]: 127.0.0.1     [ 127.0.0.1 ] kilo[127.0.0.1]: 1024 ShortLegend[127.0.0.1]: B/s YLegend[127.0.0.1]: B/s PageTop[127.0.0.1]:<center> <H1>127.0.0.1     [ 127.0.0.1 ]</H1>
## Komp 192.168.100.1 Target[192.168.100.1]: `iptables -t mangle -L mrtg_traffic -v -x -n | awk '/ 192.168.100.1 / {print $2}'` MaxBytes[192.168.100.1]: 12500000 Options[192.168.100.1]: growright, nopercent, integer, nobanner, noinfo Title[192.168.100.1]: 192.168.100.1     [ 192.168.100.1 ] kilo[192.168.100.1]: 1024 ShortLegend[192.168.100.1]: B/s YLegend[192.168.100.1]: B/s PageTop[192.168.100.1]:<center> <H1>192.168.100.1     [ 192.168.100.1 ]</H1>
## Komp 192.168.100.222 Target[192.168.100.222]: `iptables -t mangle -L mrtg_traffic -v -x -n | awk '/ 192.168.100.222 / {print $2}'` MaxBytes[192.168.100.222]: 12500000 Options[192.168.100.222]: growright, nopercent, integer, nobanner, noinfo Title[192.168.100.222]: 192.168.100.222     [ 192.168.100.222 ] kilo[192.168.100.222]: 1024 ShortLegend[192.168.100.222]: B/s YLegend[192.168.100.222]: B/s PageTop[192.168.100.222]:<center> <H1>192.168.100.222     [ 192.168.100.222 ]</H1>
## Komp 192.168.100.223 Target[192.168.100.223]: `iptables -t mangle -L mrtg_traffic -v -x -n | awk '/ 192.168.100.223 / {print $2}'` MaxBytes[192.168.100.223]: 12500000 Options[192.168.100.223]: growright, nopercent, integer, nobanner, noinfo Title[192.168.100.223]: 192.168.100.223     [ 192.168.100.223 ] kilo[192.168.100.223]: 1024 ShortLegend[192.168.100.223]: B/s YLegend[192.168.100.223]: B/s PageTop[192.168.100.223]:<center> <H1>192.168.100.223     [ 192.168.100.223 ]</H1>
## Komp 192.168.100.224 Target[192.168.100.224]: `iptables -t mangle -L mrtg_traffic -v -x -n | awk '/ 192.168.100.224 / {print $2}'` MaxBytes[192.168.100.224]: 12500000 Options[192.168.100.224]: growright, nopercent, integer, nobanner, noinfo Title[192.168.100.224]: 192.168.100.224     [ 192.168.100.224 ] kilo[192.168.100.224]: 1024 ShortLegend[192.168.100.224]: B/s YLegend[192.168.100.224]: B/s PageTop[192.168.100.224]:<center> <H1>192.168.100.224     [ 192.168.100.224 ]</H1>
## Komp 192.168.100.225 Target[192.168.100.225]: `iptables -t mangle -L mrtg_traffic -v -x -n | awk '/ 192.168.100.225 / {print $2}'` MaxBytes[192.168.100.225]: 12500000 Options[192.168.100.225]: growright, nopercent, integer, nobanner, noinfo Title[192.168.100.225]: 192.168.100.225     [ 192.168.100.225 ] kilo[192.168.100.225]: 1024 ShortLegend[192.168.100.225]: B/s YLegend[192.168.100.225]: B/s PageTop[192.168.100.225]:<center> <H1>192.168.100.225     [ 192.168.100.225 ]</H1>
## Komp 192.168.100.226 Target[192.168.100.226]: `iptables -t mangle -L mrtg_traffic -v -x -n | awk '/ 192.168.100.226 / {print $2}'` MaxBytes[192.168.100.226]: 12500000 Options[192.168.100.226]: growright, nopercent, integer, nobanner, noinfo Title[192.168.100.226]: 192.168.100.226     [ 192.168.100.226 ] kilo[192.168.100.226]: 1024 ShortLegend[192.168.100.226]: B/s YLegend[192.168.100.226]: B/s PageTop[192.168.100.226]:<center> <H1>192.168.100.226     [ 192.168.100.226 ]</H1>
## Komp 192.168.100.227 Target[192.168.100.227]: `iptables -t mangle -L mrtg_traffic -v -x -n | awk '/ 192.168.100.227 / {print $2}'` MaxBytes[192.168.100.227]: 12500000 Options[192.168.100.227]: growright, nopercent, integer, nobanner, noinfo Title[192.168.100.227]: 192.168.100.227     [ 192.168.100.227 ] kilo[192.168.100.227]: 1024 ShortLegend[192.168.100.227]: B/s YLegend[192.168.100.227]: B/s PageTop[192.168.100.227]:<center> <H1>192.168.100.227     [ 192.168.100.227 ]</H1>
## Komp 192.168.100.228 Target[192.168.100.228]: `iptables -t mangle -L mrtg_traffic -v -x -n | awk '/ 192.168.100.228 / {print $2}'` MaxBytes[192.168.100.228]: 12500000 Options[192.168.100.228]: growright, nopercent, integer, nobanner, noinfo Title[192.168.100.228]: 192.168.100.228     [ 192.168.100.228 ] kilo[192.168.100.228]: 1024 ShortLegend[192.168.100.228]: B/s YLegend[192.168.100.228]: B/s PageTop[192.168.100.228]:<center> <H1>192.168.100.228     [ 192.168.100.228 ]</H1>
## Komp 192.168.100.229 Target[192.168.100.229]: `iptables -t mangle -L mrtg_traffic -v -x -n | awk '/ 192.168.100.229 / {print $2}'` MaxBytes[192.168.100.229]: 12500000 Options[192.168.100.229]: growright, nopercent, integer, nobanner, noinfo Title[192.168.100.229]: 192.168.100.229     [ 192.168.100.229 ] kilo[192.168.100.229]: 1024 ShortLegend[192.168.100.229]: B/s YLegend[192.168.100.229]: B/s PageTop[192.168.100.229]:<center> <H1>192.168.100.229     [ 192.168.100.229 ]</H1>
## Komp 192.168.100.230 Target[192.168.100.230]: `iptables -t mangle -L mrtg_traffic -v -x -n | awk '/ 192.168.100.230 / {print $2}'` MaxBytes[192.168.100.230]: 12500000 Options[192.168.100.230]: growright, nopercent, integer, nobanner, noinfo Title[192.168.100.230]: 192.168.100.230     [ 192.168.100.230 ] kilo[192.168.100.230]: 1024 ShortLegend[192.168.100.230]: B/s YLegend[192.168.100.230]: B/s PageTop[192.168.100.230]:<center> <H1>192.168.100.230     [ 192.168.100.230 ]</H1>
## Komp 192.168.100.231 Target[192.168.100.231]: `iptables -t mangle -L mrtg_traffic -v -x -n | awk '/ 192.168.100.231 / {print $2}'` MaxBytes[192.168.100.231]: 12500000 Options[192.168.100.231]: growright, nopercent, integer, nobanner, noinfo Title[192.168.100.231]: 192.168.100.231     [ 192.168.100.231 ] kilo[192.168.100.231]: 1024 ShortLegend[192.168.100.231]: B/s YLegend[192.168.100.231]: B/s PageTop[192.168.100.231]:<center> <H1>192.168.100.231     [ 192.168.100.231 ]</H1>
## Komp 192.168.100.232 Target[192.168.100.232]: `iptables -t mangle -L mrtg_traffic -v -x -n | awk '/ 192.168.100.232 / {print $2}'` MaxBytes[192.168.100.232]: 12500000 Options[192.168.100.232]: growright, nopercent, integer, nobanner, noinfo Title[192.168.100.232]: 192.168.100.232     [ 192.168.100.232 ] kilo[192.168.100.232]: 1024 ShortLegend[192.168.100.232]: B/s YLegend[192.168.100.232]: B/s PageTop[192.168.100.232]:<center> <H1>192.168.100.232     [ 192.168.100.232 ]</H1>
## Komp 192.168.100.233 Target[192.168.100.233]: `iptables -t mangle -L mrtg_traffic -v -x -n | awk '/ 192.168.100.233 / {print $2}'` MaxBytes[192.168.100.233]: 12500000 Options[192.168.100.233]: growright, nopercent, integer, nobanner, noinfo Title[192.168.100.233]: 192.168.100.233     [ 192.168.100.233 ] kilo[192.168.100.233]: 1024 ShortLegend[192.168.100.233]: B/s YLegend[192.168.100.233]: B/s PageTop[192.168.100.233]:<center> <H1>192.168.100.233     [ 192.168.100.233 ]</H1>
## Komp 192.168.100.234 Target[192.168.100.234]: `iptables -t mangle -L mrtg_traffic -v -x -n | awk '/ 192.168.100.234 / {print $2}'` MaxBytes[192.168.100.234]: 12500000 Options[192.168.100.234]: growright, nopercent, integer, nobanner, noinfo Title[192.168.100.234]: 192.168.100.234     [ 192.168.100.234 ] kilo[192.168.100.234]: 1024 ShortLegend[192.168.100.234]: B/s YLegend[192.168.100.234]: B/s PageTop[192.168.100.234]:<center> <H1>192.168.100.234     [ 192.168.100.234 ]</H1>
## Komp 192.168.100.235 Target[192.168.100.235]: `iptables -t mangle -L mrtg_traffic -v -x -n | awk '/ 192.168.100.235 / {print $2}'` MaxBytes[192.168.100.235]: 12500000 Options[192.168.100.235]: growright, nopercent, integer, nobanner, noinfo Title[192.168.100.235]: 192.168.100.235     [ 192.168.100.235 ] kilo[192.168.100.235]: 1024 ShortLegend[192.168.100.235]: B/s YLegend[192.168.100.235]: B/s PageTop[192.168.100.235]:<center> <H1>192.168.100.235     [ 192.168.100.235 ]</H1>
## Komp 192.168.100.236 Target[192.168.100.236]: `iptables -t mangle -L mrtg_traffic -v -x -n | awk '/ 192.168.100.236 / {print $2}'` MaxBytes[192.168.100.236]: 12500000 Options[192.168.100.236]: growright, nopercent, integer, nobanner, noinfo Title[192.168.100.236]: 192.168.100.236     [ 192.168.100.236 ] kilo[192.168.100.236]: 1024 ShortLegend[192.168.100.236]: B/s YLegend[192.168.100.236]: B/s PageTop[192.168.100.236]:<center> <H1>192.168.100.236     [ 192.168.100.236 ]</H1>
## Komp 192.168.100.237 Target[192.168.100.237]: `iptables -t mangle -L mrtg_traffic -v -x -n | awk '/ 192.168.100.237 / {print $2}'` MaxBytes[192.168.100.237]: 12500000 Options[192.168.100.237]: growright, nopercent, integer, nobanner, noinfo Title[192.168.100.237]: 192.168.100.237     [ 192.168.100.237 ] kilo[192.168.100.237]: 1024 ShortLegend[192.168.100.237]: B/s YLegend[192.168.100.237]: B/s PageTop[192.168.100.237]:<center> <H1>192.168.100.237     [ 192.168.100.237 ]</H1>
## Komp 192.168.100.238 Target[192.168.100.238]: `iptables -t mangle -L mrtg_traffic -v -x -n | awk '/ 192.168.100.238 / {print $2}'` MaxBytes[192.168.100.238]: 12500000 Options[192.168.100.238]: growright, nopercent, integer, nobanner, noinfo Title[192.168.100.238]: 192.168.100.238     [ 192.168.100.238 ] kilo[192.168.100.238]: 1024 ShortLegend[192.168.100.238]: B/s YLegend[192.168.100.238]: B/s PageTop[192.168.100.238]:<center> <H1>192.168.100.238     [ 192.168.100.238 ]</H1>
## Komp 192.168.100.239 Target[192.168.100.239]: `iptables -t mangle -L mrtg_traffic -v -x -n | awk '/ 192.168.100.239 / {print $2}'` MaxBytes[192.168.100.239]: 12500000 Options[192.168.100.239]: growright, nopercent, integer, nobanner, noinfo Title[192.168.100.239]: 192.168.100.239     [ 192.168.100.239 ] kilo[192.168.100.239]: 1024 ShortLegend[192.168.100.239]: B/s YLegend[192.168.100.239]: B/s PageTop[192.168.100.239]:<center> <H1>192.168.100.239     [ 192.168.100.239 ]</H1>
## Komp 192.168.100.240 Target[192.168.100.240]: `iptables -t mangle -L mrtg_traffic -v -x -n | awk '/ 192.168.100.240 / {print $2}'` MaxBytes[192.168.100.240]: 12500000 Options[192.168.100.240]: growright, nopercent, integer, nobanner, noinfo Title[192.168.100.240]: 192.168.100.240     [ 192.168.100.240 ] kilo[192.168.100.240]: 1024 ShortLegend[192.168.100.240]: B/s YLegend[192.168.100.240]: B/s PageTop[192.168.100.240]:<center> <H1>192.168.100.240     [ 192.168.100.240 ]</H1>
## Komp 192.168.100.241 Target[192.168.100.241]: `iptables -t mangle -L mrtg_traffic -v -x -n | awk '/ 192.168.100.241 / {print $2}'` MaxBytes[192.168.100.241]: 12500000 Options[192.168.100.241]: growright, nopercent, integer, nobanner, noinfo Title[192.168.100.241]: 192.168.100.241     [ 192.168.100.241 ] kilo[192.168.100.241]: 1024 ShortLegend[192.168.100.241]: B/s YLegend[192.168.100.241]: B/s PageTop[192.168.100.241]:<center> <H1>192.168.100.241     [ 192.168.100.241 ]</H1>
## Komp 192.168.100.242 Target[192.168.100.242]: `iptables -t mangle -L mrtg_traffic -v -x -n | awk '/ 192.168.100.242 / {print $2}'` MaxBytes[192.168.100.242]: 12500000 Options[192.168.100.242]: growright, nopercent, integer, nobanner, noinfo Title[192.168.100.242]: 192.168.100.242     [ 192.168.100.242 ] kilo[192.168.100.242]: 1024 ShortLegend[192.168.100.242]: B/s YLegend[192.168.100.242]: B/s PageTop[192.168.100.242]:<center> <H1>192.168.100.242     [ 192.168.100.242 ]</H1>
## Komp 192.168.100.243 Target[192.168.100.243]: `iptables -t mangle -L mrtg_traffic -v -x -n | awk '/ 192.168.100.243 / {print $2}'` MaxBytes[192.168.100.243]: 12500000 Options[192.168.100.243]: growright, nopercent, integer, nobanner, noinfo Title[192.168.100.243]: 192.168.100.243     [ 192.168.100.243 ] kilo[192.168.100.243]: 1024 ShortLegend[192.168.100.243]: B/s YLegend[192.168.100.243]: B/s PageTop[192.168.100.243]:<center> <H1>192.168.100.243     [ 192.168.100.243 ]</H1>
## Komp 192.168.100.244 Target[192.168.100.244]: `iptables -t mangle -L mrtg_traffic -v -x -n | awk '/ 192.168.100.244 / {print $2}'` MaxBytes[192.168.100.244]: 12500000 Options[192.168.100.244]: growright, nopercent, integer, nobanner, noinfo Title[192.168.100.244]: 192.168.100.244     [ 192.168.100.244 ] kilo[192.168.100.244]: 1024 ShortLegend[192.168.100.244]: B/s YLegend[192.168.100.244]: B/s PageTop[192.168.100.244]:<center> <H1>192.168.100.244     [ 192.168.100.244 ]</H1>
## Komp 192.168.100.245 Target[192.168.100.245]: `iptables -t mangle -L mrtg_traffic -v -x -n | awk '/ 192.168.100.245 / {print $2}'` MaxBytes[192.168.100.245]: 12500000 Options[192.168.100.245]: growright, nopercent, integer, nobanner, noinfo Title[192.168.100.245]: 192.168.100.245     [ 192.168.100.245 ] kilo[192.168.100.245]: 1024 ShortLegend[192.168.100.245]: B/s YLegend[192.168.100.245]: B/s PageTop[192.168.100.245]:<center> <H1>192.168.100.245     [ 192.168.100.245 ]</H1>
## Komp 192.168.100.246 Target[192.168.100.246]: `iptables -t mangle -L mrtg_traffic -v -x -n | awk '/ 192.168.100.246 / {print $2}'` MaxBytes[192.168.100.246]: 12500000 Options[192.168.100.246]: growright, nopercent, integer, nobanner, noinfo Title[192.168.100.246]: 192.168.100.246     [ 192.168.100.246 ] kilo[192.168.100.246]: 1024 ShortLegend[192.168.100.246]: B/s YLegend[192.168.100.246]: B/s PageTop[192.168.100.246]:<center> <H1>192.168.100.246     [ 192.168.100.246 ]</H1>
## Komp 192.168.100.247 Target[192.168.100.247]: `iptables -t mangle -L mrtg_traffic -v -x -n | awk '/ 192.168.100.247 / {print $2}'` MaxBytes[192.168.100.247]: 12500000 Options[192.168.100.247]: growright, nopercent, integer, nobanner, noinfo Title[192.168.100.247]: 192.168.100.247     [ 192.168.100.247 ] kilo[192.168.100.247]: 1024 ShortLegend[192.168.100.247]: B/s YLegend[192.168.100.247]: B/s PageTop[192.168.100.247]:<center> <H1>192.168.100.247     [ 192.168.100.247 ]</H1>
## Komp 192.168.100.248 Target[192.168.100.248]: `iptables -t mangle -L mrtg_traffic -v -x -n | awk '/ 192.168.100.248 / {print $2}'` MaxBytes[192.168.100.248]: 12500000 Options[192.168.100.248]: growright, nopercent, integer, nobanner, noinfo Title[192.168.100.248]: 192.168.100.248     [ 192.168.100.248 ] kilo[192.168.100.248]: 1024 ShortLegend[192.168.100.248]: B/s YLegend[192.168.100.248]: B/s PageTop[192.168.100.248]:<center> <H1>192.168.100.248     [ 192.168.100.248 ]</H1>
## Komp 192.168.100.249 Target[192.168.100.249]: `iptables -t mangle -L mrtg_traffic -v -x -n | awk '/ 192.168.100.249 / {print $2}'` MaxBytes[192.168.100.249]: 12500000 Options[192.168.100.249]: growright, nopercent, integer, nobanner, noinfo Title[192.168.100.249]: 192.168.100.249     [ 192.168.100.249 ] kilo[192.168.100.249]: 1024 ShortLegend[192.168.100.249]: B/s YLegend[192.168.100.249]: B/s PageTop[192.168.100.249]:<center> <H1>192.168.100.249     [ 192.168.100.249 ]</H1>
## Komp 192.168.100.250 Target[192.168.100.250]: `iptables -t mangle -L mrtg_traffic -v -x -n | awk '/ 192.168.100.250 / {print $2}'` MaxBytes[192.168.100.250]: 12500000 Options[192.168.100.250]: growright, nopercent, integer, nobanner, noinfo Title[192.168.100.250]: 192.168.100.250     [ 192.168.100.250 ] kilo[192.168.100.250]: 1024 ShortLegend[192.168.100.250]: B/s YLegend[192.168.100.250]: B/s PageTop[192.168.100.250]:<center> <H1>192.168.100.250     [ 192.168.100.250 ]</H1>
## Komp 192.168.100.251 Target[192.168.100.251]: `iptables -t mangle -L mrtg_traffic -v -x -n | awk '/ 192.168.100.251 / {print $2}'` MaxBytes[192.168.100.251]: 12500000 Options[192.168.100.251]: growright, nopercent, integer, nobanner, noinfo Title[192.168.100.251]: 192.168.100.251     [ 192.168.100.251 ] kilo[192.168.100.251]: 1024 ShortLegend[192.168.100.251]: B/s YLegend[192.168.100.251]: B/s PageTop[192.168.100.251]:<center> <H1>192.168.100.251     [ 192.168.100.251 ]</H1>
## Komp 192.168.100.252 Target[192.168.100.252]: `iptables -t mangle -L mrtg_traffic -v -x -n | awk '/ 192.168.100.252 / {print $2}'` MaxBytes[192.168.100.252]: 12500000 Options[192.168.100.252]: growright, nopercent, integer, nobanner, noinfo Title[192.168.100.252]: 192.168.100.252     [ 192.168.100.252 ] kilo[192.168.100.252]: 1024 ShortLegend[192.168.100.252]: B/s YLegend[192.168.100.252]: B/s PageTop[192.168.100.252]:<center> <H1>192.168.100.252     [ 192.168.100.252 ]</H1>
## Komp 192.168.100.253 Target[192.168.100.253]: `iptables -t mangle -L mrtg_traffic -v -x -n | awk '/ 192.168.100.253 / {print $2}'` MaxBytes[192.168.100.253]: 12500000 Options[192.168.100.253]: growright, nopercent, integer, nobanner, noinfo Title[192.168.100.253]: 192.168.100.253     [ 192.168.100.253 ] kilo[192.168.100.253]: 1024 ShortLegend[192.168.100.253]: B/s YLegend[192.168.100.253]: B/s PageTop[192.168.100.253]:<center> <H1>192.168.100.253     [ 192.168.100.253 ]</H1>
## Komp 192.168.100.254 Target[192.168.100.254]: `iptables -t mangle -L mrtg_traffic -v -x -n | awk '/ 192.168.100.254 / {print $2}'` MaxBytes[192.168.100.254]: 12500000 Options[192.168.100.254]: growright, nopercent, integer, nobanner, noinfo Title[192.168.100.254]: 192.168.100.254     [ 192.168.100.254 ] kilo[192.168.100.254]: 1024 ShortLegend[192.168.100.254]: B/s YLegend[192.168.100.254]: B/s PageTop[192.168.100.254]:<center> <H1>192.168.100.254     [ 192.168.100.254 ]</H1>
## Ilosc uzytkownikow Target[hosty]: `/etc/mrtg/hosty.iptables` #Target[hosty]: `/etc/mrtg/hosty.arpscan` Title[hosty]: Ilo?? u?ytkownik?w PageTop[hosty]: <center> <H1>Ilo?? u?ytkownik?w</H1> MaxBytes[hosty]: 300 kilo[hosty]: 1000 ShortLegend[hosty]: YLegend[hosty]: ilosc Legend1[hosty]: Aktywne Legend2[hosty]: Wszystkie LegendI[hosty]: aktywne LegendO[hosty]: wszystkie #Options[hosty]: growright, gauge, nopercent, integer, nobanner, noinfo, nolegend
## Procek Target[cpu]: `awk '/cpu /{print $4; print $2+$3+$4}' /proc/stat` Title[cpu]: U?ycie procesora na serwerze PageTop[cpu]: <center> <H1>U?ycie procesora na serwerze</H1> MaxBytes[cpu]: 100 Unscaled[cpu]: ymwd Options[cpu]: growright, nopercent, integer, nobanner, noinfo LegendI[cpu]: user: LegendO[cpu]: total: Ylegend[cpu]: % ShortLegend[cpu]: % Legend1[cpu]: Czas spedzony trybie user Legend2[cpu]: Czas spedzony trybie user + czas spedzony trybie system
## DYSK sda1 Target[sda1]: `df|awk '/sda1/ {print $3"\n"$4}'` MaxBytes[sda1]: 12396968 #Options[sda1]: gauge, growright Unscaled[sda1]: ymdw Title[sda1]: Dysk sda1 kMG[sda1]:K,M,G,T kilo[sda1]: 1024 ShortLegend[sda1]:B YLegend[sda1]: Megabajty PageTop[sda1]:<CENTER> <H1>Zajetosc dysku sda1</H1> LegendI[sda1]: Used: LegendO[sda1]: Free: Legend1[sda1]: Obszar zajety Legend2[sda1]: Obszar wolny
## DYSK sda6 Target[sda6]: `df|awk '/sda6/ {print $3"\n"$4}'` MaxBytes[sda6]: 60476036 #Options[sda6]: gauge, growright Unscaled[sda6]: ymdw Title[sda6]: Dysk sda6 kMG[sda6]:K,M,G,T kilo[sda6]: 1024 ShortLegend[sda6]:B YLegend[sda6]: Megabajty PageTop[sda6]:<CENTER> <H1>Zajetosc dysku sda6</H1> LegendI[sda6]: Used: LegendO[sda6]: Free: Legend1[sda6]: Obszar zajety Legend2[sda6]: Obszar wolny
## Pami?? Target[mem]: `awk '/Mem:/ {print $3"\n"$2}' /proc/meminfo` MaxBytes[mem]: Options[mem]: gauge, growright Unscaled[mem]: ymdw Title[mem]: Pami?? fizyczna kilo[mem]: 1024 ShortLegend[mem]:B YLegend[mem]: Megabajty LegendI[mem]: Used: LegendO[mem]: Total: PageTop[mem]:<center> <H1>Pami?? fizyczna</H1> Legend1[mem]: Pamiec uzywana Legend2[mem]: Pamiec calkowita
## Procesy Target[procesy]: `awk -F" |/" '{print $5-1"\n"$4-2}' /proc/loadavg` #Options[procesy]: growright, gauge, nopercent, integer MaxBytes[procesy]: 30000 kilo[procesy]: 1000 Title[procesy]: Ilo?? proces?w PageTop[procesy]: <center> <H1>Ilo?? proces?w w systemie</H1> ShortLegend[procesy]: YLegend[procesy]: Procesy Legend1[procesy]: Ilo?? wszystkich proces?w w systemie Legend2[procesy]: Ilo?? dzia?aj?cych proces?w LegendI[procesy]: procesy: LegendO[procesy]: dzia?aj?ce:
i teraz jak z konsoli ucruchomię : mrtg.run #!/bin/bash while :; do sleep 300 mrtg /etc/mrtg/mrtg.conf 1>/dev/null 2>&1 mrtg /etc/mrtg/mrtg.conf 1>/etc/mrtg/mrtg.log 2>&1 done
czarny ekran i nic się nie dzieje Ale jak wpiszę z kosoli mrtg mrtg.conf dostaje odpowiedź: ERROR: CFG Error in "maxbytes[mem]", line 461: must be a Number bigger than 0
logi sie nie tworza więc ich nie mam
Edit: Saturas - na przyszłość wstawiaj znaczniki [code]"
|
|