Link to home
Start Free TrialLog in
Avatar of XK8ER
XK8ERFlag for United States of America

asked on

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

Avatar of sukumade
sukumade
Flag of United States of America image

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?
Avatar of XK8ER

ASKER

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
seems to me like the cut command is different in freebsd, no?
ASKER CERTIFIED SOLUTION
Avatar of Rance_Hall
Rance_Hall

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
Avatar of Rance_Hall
Rance_Hall

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?
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)
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
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)