freebsd load command

hello there,
im running this in linux server but i cant run it on freebsd.
can someone help me out.. thanks
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

Open in new window

LVL 1
XK8ERAsked:
Who is Participating?
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.

sukumadeCommented:
What are the error messages you are getting when running the command? Has the variable $TYPE been set in the environment? Are the switches you provided for cat, vut, and sed the same as in linux?
0
XK8ERAuthor Commented:
linux command doesnt work on freebsd so i have to use sysctl vm.loadavg instead..

*********linux system**********
[(01:37 PM)][(root@dedicated)] [(~)] $ cat /proc/loadavg
2.73 2.51 2.24 3/195 16583
[(01:37 PM)][(root@dedicated)] [(~)] $ uptime
 13:37:31 up 4 days,  2:28,  1 user,  load average: 2.73, 2.51, 2.24
[(01:37 PM)][(root@dedicated)] [(~)] $ cat /proc/loadavg | cut -d ' ' -f2 | sed 's/\.//g' | sed 's/^0//g'
251
[(01:37 PM)][(root@dedicated)] [(~)] $ cat /proc/loadavg | cut -d ' ' -f3 | sed 's/\.//g' | sed 's/^0//g'
224
*****************************

$ sysctl vm.loadavg
vm.loadavg: { 0.09 0.27 0.38 }

then doing this
$ sysctl vm.loadavg | cut -d ' ' -f3 | sed 's/\.//g' | sed 's/^0//g'
09

the 09 its supposed to be 009

then
$ sysctl vm.loadavg | cut -d ' ' -f2 | sed 's/\.//g' | sed 's/^0//g'
{

all im trying to do is show the same as linux
0
sukumadeCommented:
seems to me like the cut command is different in freebsd, no?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Rance_HallCommented:
the cut command may be different in FreeBSD but thats not the first problem.


you can mount the proc file system in FreeBSD it has been deprecated and not mounted by default.

mount proc, add it to your /etc/fstab so that it mounts at startup

and try your command again.


Now, as to the output of commands, freebsd does not have the same output as linux in most commands.


ifconfig is different....

it could be cut thats different but in this case, I dont think so.

I think sed is your culprit.

R

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
sukumadeCommented:
i would say try cut -f4 instead of f2 on the second statement and i believe rance is correct regarding sed since it is not replacing/removing the proper characters
0
Rance_HallCommented:
stop chaining all your commands together, strip them all off and add them back one at a time, study the output each time.

what did you get,  what did you think you were supposed to get,

where is it broke?

at the cut, the first sed, or the second sed, or is your original data input not what you think it is?
0
lqwCommented:
I posted this in your other thread, try

uptime |awk '{print $8 $9 $10}'

you could tr -d the comma, if you only need one of those (tried with openbsd but should be similar anywhere)
0
Rance_HallCommented:
on freebsd you dont need the second sed, the first on that strips out the '.' seems to return the data you want.

Im not really sure why you thought you needed the second one.

R
0
Rance_HallCommented:
My comment (22953955) had the needed hint for him to answer and then the next day when there was no comment I provided the final answer (22959823)
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.