Mam taki skrypt w mrtg
plik mrtg.cfg
Kod: Zaznacz cały
######################################
# Multi Router Traffic Grapher -- Example Configuration File
######################################
# This file is for use with mrtg-2.0
Language: polish
# Parametry globalne
WorkDir: /home/www/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[_]: [/align]
Target[eth0]: `/etc/mrtg/eth0`
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]:[align=center] <H1>eth0</H1>
Target[ip130]: `/etc/mrtg/ip_acct 10.0.0.130`
MaxBytes[ip130]: 12500000
Title[ip130]: Obciazenie na 10.0.0.130
Options[ip130]: growright, nopercent, integer, nobanner, noinfo
WithPeak[ip130]: wmy
YTics[ip130]: 10
ShortLegend[ip130]: B/s
YLegend[ip130]: Bajty/sekundy
PageTop[ip130]: <H1>Stats for our Ethernet</H1>
Kod: Zaznacz cały
#!/bin/bash
/usr/sbin/iptables -v -n -x -L mrtg_traffic | grep $1 | head -1 | awk '{print $2}'
/usr/sbin/iptables -v -n -x -L mrtg_traffic | grep $1 | tail -1 | awk '{print $2}'
uptime | sed -e 's/^.*up *//g' -e 's/, *[0-9] *u.*$//g'
hostname
Kod: Zaznacz cały
#!/bin/bash
PPP=`cat /proc/net/dev | grep -w eth0`
IPPP=`echo $PPP | awk '{print $1" "$2}' | awk -F: '{print $2}' | awk '{print $1}'`
OPPP=`echo $PPP | awk -F: '{print $2}' | awk '{print $9}'`
echo $IPPP
echo $OPPP
uptime | sed -e 's/^.*up *//g' -e 's/, *[0-9] *u.*$//g'
hostname
Kod: Zaznacz cały
2008-03-31 20:20:02: ERROR: Target[ip130][_IN_] ' $target->[1]{$mode} ' evaluated to 'NaN' instead of a number
2008-03-31 20:20:02: ERROR: Target[ip130][_OUT_] ' $target->[1]{$mode} ' did not eval into defined data
2008-03-31 20:25:02: WARNING: Problem with External get '/etc/mrtg/ip_acct 10.0.0.130':
Expected a Number for 'out' but got 'debian'