FreeBSD problem while running script

hello there,
I am trying to run this script called system.sh but im getting lots of errors..
it runs great in my other system running on centos v5.2
can someone help me out here!!


/etc/crontab: 28 lines, 855 characters
[root@v-2-eu15-d967-104 /usr/local/src]# env LANG=C /usr/local/mrtg-2/bin/mrtg /usr/home/domains/domain.com/www/mrtg/mrtg.cfg
cat: /proc/net/dev: No such file or directory
2008-11-13 05:19:17: WARNING: Problem with External get '/usr/home/domains/domain.com/www/mrtg/system.sh network eth0':
   Expected a Number for 'in' but got ''

2008-11-13 05:19:17: WARNING: Problem with External get '/usr/home/domains/domain.com/www/mrtg/system.sh network eth0':
   Expected a Number for 'out' but got ''

cat: /proc/loadavg: No such file or directory
cat: /proc/loadavg: No such file or directory
2008-11-13 05:19:17: WARNING: Problem with External get '/usr/home/domains/domain.com/www/mrtg/system.sh load':
   Expected a Number for 'in' but got ''

2008-11-13 05:19:17: WARNING: Problem with External get '/usr/home/domains/domain.com/www/mrtg/system.sh load':
   Expected a Number for 'out' but got ''

cat: /proc/meminfo: No such file or directory
cat: /proc/meminfo: No such file or directory
expr: syntax error
2008-11-13 05:19:17: WARNING: Problem with External get '/usr/home/domains/domain.com/www/mrtg/system.sh swap':
   Expected a Number for 'in' but got ''

2008-11-13 05:19:17: WARNING: Problem with External get '/usr/home/domains/domain.com/www/mrtg/system.sh swap':
   Expected a Number for 'out' but got ''

cat: /proc/loadavg: No such file or directory
cat: /proc/loadavg: No such file or directory
2008-11-13 05:19:17: WARNING: Problem with External get '/usr/home/domains/domain.com/www/mrtg/system.sh processes':
   Expected a Number for 'in' but got ''

2008-11-13 05:19:17: WARNING: Problem with External get '/usr/home/domains/domain.com/www/mrtg/system.sh processes':
   Expected a Number for 'out' but got ''

cat: /proc/uptime: No such file or directory
cat: /proc/uptime: No such file or directory
2008-11-13 05:19:17: WARNING: Problem with External get '/usr/home/domains/domain.com/www/mrtg/system.sh uptime':
   Expected a Number for 'in' but got ''

2008-11-13 05:19:17: WARNING: Problem with External get '/usr/home/domains/domain.com/www/mrtg/system.sh uptime':
   Expected a Number for 'out' but got ''

cannot open /proc/stat: No such file or directory
2008-11-13 05:19:17: 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. (Bad file descriptor)

2008-11-13 05:19:17: 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'

2008-11-13 05:19:17: 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'

free: not found
free: not found
2008-11-13 05:19:17: WARNING: Problem with External get '/usr/home/domains/domain.com/www/mrtg/system.sh memory':
   Expected a Number for 'in' but got ''

2008-11-13 05:19:17: WARNING: Problem with External get '/usr/home/domains/domain.com/www/mrtg/system.sh memory':
   Expected a Number for 'out' but got ''

2008-11-13 05:19:17: ERROR: Target[index][_IN_] ' $target->[0]{$mode} ' did not eval into defined data
2008-11-13 05:19:17: ERROR: Target[index][_OUT_] ' $target->[0]{$mode} ' did not eval into defined data
2008-11-13 05:19:17: ERROR: Target[load][_IN_] ' $target->[2]{$mode} ' did not eval into defined data
2008-11-13 05:19:17: ERROR: Target[load][_OUT_] ' $target->[2]{$mode} ' did not eval into defined data
2008-11-13 05:19:17: ERROR: Target[swap][_IN_] ' $target->[3]{$mode} ' did not eval into defined data
2008-11-13 05:19:17: ERROR: Target[swap][_OUT_] ' $target->[3]{$mode} ' did not eval into defined data
2008-11-13 05:19:17: ERROR: Target[processes][_IN_] ' $target->[4]{$mode} ' did not eval into defined data
2008-11-13 05:19:17: ERROR: Target[processes][_OUT_] ' $target->[4]{$mode} ' did not eval into defined data
2008-11-13 05:19:17: ERROR: Target[uptime][_IN_] ' $target->[5]{$mode} ' did not eval into defined data
2008-11-13 05:19:17: ERROR: Target[uptime][_OUT_] ' $target->[5]{$mode} ' did not eval into defined data
2008-11-13 05:19:17: ERROR: Target[cpu][_IN_] ' $target->[6]{$mode} ' did not eval into defined data
2008-11-13 05:19:17: ERROR: Target[cpu][_OUT_] ' $target->[6]{$mode} ' did not eval into defined data
2008-11-13 05:19:17: ERROR: Target[memory][_IN_] ' $target->[7]{$mode} ' did not eval into defined data
2008-11-13 05:19:17: ERROR: Target[memory][_OUT_] ' $target->[7]{$mode} ' did not eval into defined data
#Copy and paste the following
 
###Start of script called system####
 
#!/bin/sh
 
TYPE=$1
PARAM=$2
 
if [ "$TYPE" = "load" ]; then
INDATA=`cat /proc/loadavg | cut -d ' ' -f2 | sed 's/\.//g' | sed 's/^0//g'`
#INDATA=`cat /proc/loadavg | cut -d ' ' -f2`
OUTDATA=`cat /proc/loadavg | cut -d ' ' -f3 | sed 's/\.//g' | sed 's/^0//g'`
#OUTDATA=`cat /proc/loadavg | cut -d ' ' -f3`
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
 
###End of system script####

Open in new window

LVL 1
XK8ERAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

cjl7freelance for hireCommented:
Well,

Linux and FreeBSD are not the same thing. So just taking a script from linux (especially one that assumes a lot of stuff) will not work.

So you either write a new one for FreeBSD or stick to linux.

//jonas
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
lqwCommented:
First thing is, /proc is a linux thing. Even if you activate it under xBSD (maybe FreeBSD has it by default, don't know), it will look different from Linux.

So cjl7 is right: you will have to change your script, especially because of your usage of /proc, to accomplish similar things under xBSD

lqw
0
XK8ERAuthor Commented:
can you guys help me fix the script?
0
XK8ERAuthor Commented:
the one that I need the most would be the server load
0
lqwCommented:
try

uptime |awk '{print $8 $9 $10}'
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.