Strona 1 z 1

MRTG bez SNMP - nie działają skrypty

: 29 grudnia 2009, 16:08
autor: galoonik
Witam wszystkich!
Korzystając z opisu ze strony: LINK wykonałem konfiguracje oraz po kopiowałem skrypty. Niestety z niewiadomych mi przyczyn zwracają puste wartości i przy odpalaniu mrtg dostaję komunikat błędu:

Kod: Zaznacz cały

2009-12-29 17:43:11: WARNING: Problem with External get 'sh /etc/mrtg/system network eth0':
   Expected a Number for 'in' but got ''

2009-12-29 17:43:11: WARNING: Problem with External get 'sh /etc/mrtg/system network eth0':
   Expected a Number for 'out' but got ''

expr: syntax error
2009-12-29 17:43:11: WARNING: Problem with External get 'sh /etc/mrtg/system swap':
   Expected a Number for 'in' but got ''

2009-12-29 17:43:11: WARNING: Problem with External get 'sh /etc/mrtg/system swap':
   Expected a Number for 'out' but got ''

awk: ./cpu
awk: ^ syntax error
awk: ./cpu
awk:   ^ unterminated regexp
Warning: unknown mime-type for "++" -- using "application/octet-stream"
Error: no such file "++"
Warning: unknown mime-type for "quite some time" -- using "application/octet-stream"
Error: no such file "quite some time"
Warning: unknown mime-type for "domain.com}." -- using "application/octet-stream"
Error: no such file "domain.com}."
2009-12-29 17:43:11: WARNING: Could not get any data from external command '/usr/bin/awk ./cpu /{print $2+$3; print $2+$3+$4; print "quite some time"; print "domain.com"}.</proc/stat'
Maybe the external command did not even start. (Illegal seek)

2009-12-29 17:43:11: WARNING: Problem with External get '/usr/bin/awk ./cpu /{print $2+$3; print $2+$3+$4; print "quite some time"; print "domain.com"}.</proc/stat':
   Expected a Number for 'in' but nothing'

2009-12-29 17:43:11: WARNING: Problem with External get '/usr/bin/awk ./cpu /{print $2+$3; print $2+$3+$4; print "quite some time"; print "domain.com"}.</proc/stat':
   Expected a Number for 'out' but nothing'

2009-12-29 17:43:11: ERROR: Target[index][_IN_] ' $target->[0]{$mode} ' did not eval into defined data
2009-12-29 17:43:11: ERROR: Target[index][_OUT_] ' $target->[0]{$mode} ' did not eval into defined data
2009-12-29 17:43:11: ERROR: Target[swap][_IN_] ' $target->[3]{$mode} ' did not eval into defined data
2009-12-29 17:43:11: ERROR: Target[swap][_OUT_] ' $target->[3]{$mode} ' did not eval into defined data
2009-12-29 17:43:11: ERROR: Target[cpu][_IN_] ' $target->[6]{$mode} ' did not eval into defined data
2009-12-29 17:43:11: ERROR: Target[cpu][_OUT_] ' $target->[6]{$mode} ' did not eval into defined data

/etc/mrtg/system

Kod: Zaznacz cały

#!/bin/sh

TYPE=$1
PARAM=$2

if [ "$TYPE" = "load" ]; then
INDATA=`cat /proc/loadavg | cut -d ' ' -f2 | sed 's/\.//g' | sed 's/^0//g'`
OUTDATA=`cat /proc/loadavg | cut -d ' ' -f3 | sed 's/\.//g' | sed 's/^0//g'`
fi

if [ "$TYPE" = "processes" ]; then
INDATA=`cat /proc/loadavg | cut -d ' ' -f4 | cut -d '/' -f 2`
OUTDATA=`cat /proc/loadavg | cut -d ' ' -f4 | cut -d '/' -f 1`
fi

if [ "$TYPE" = "network" ]; then
LINE=`cat /proc/net/dev | grep $PARAM | sed s/$PARAM://`
INDATA=`echo $LINE | awk '{print $1}' `
OUTDATA=`echo $LINE | awk '{print $9}' `
fi

if [ "$TYPE" = "swap" ]; then
SWAPFREE=`cat /proc/meminfo | grep .SwapFree. | sed 's/ //g' | cut -d ':' -f2 | cut -d 'k' -f1`
SWAPTOTAL=`cat /proc/meminfo | grep "SwapTotal" | sed 's/ //g' | cut -d ':' -f2 | cut -d 'k' -f1`
SWAPUSED=`expr $SWAPTOTAL . $SWAPFREE`
INDATA=$SWAPFREE
OUTDATA=$SWAPUSED
fi

if [ "$TYPE" = "uptime" ]; then
INDATA=`cat /proc/uptime | cut -d ' '  -f1`
OUTDATA=`cat /proc/uptime | cut -d ' '  -f2`
fi

if [ "$TYPE" = "tcp" ]; then
INDATA=`netstat -an | grep -c ESTABLISHED`
OUTDATA=$INDATA
fi

if [ "$TYPE" = "memory" ]; then
INDATA=`free -bt | grep buffers\/cache | awk '{print $3}'`
OUTDATA=`free -bt | grep buffers\/cache | awk '{print $4}'`
fi

echo $INDATA
echo $OUTDATA
echo `uptime | cut -d"," -f1,2`
echo $TYPE
Pozdrawiam!

: 30 grudnia 2009, 09:50
autor: mendeczka
Chłopie to jest tak jak na pałę kopiuje się wszystko. Teraz ładnie musisz dostosować ten skrypt pod swój sprzęt (system) - przeanalizować go

Kod: Zaznacz cały

syntax error - błąd składni (w programowaniu, wskazuje nierozpoznane słowo, symbol czy strukturę)

Kod: Zaznacz cały

domain.com - nie znajduje takiego pliku bądź domeny