Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

freebsd load command

Posted on 2008-11-13
12
Medium Priority
?
357 Views
Last Modified: 2012-06-27
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

0
Comment
Question by:XK8ER
9 Comments
 
LVL 3

Expert Comment

by:sukumade
ID: 22953453
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
 
LVL 1

Author Comment

by:XK8ER
ID: 22953558
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
 
LVL 3

Expert Comment

by:sukumade
ID: 22953761
seems to me like the cut command is different in freebsd, no?
0
Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

 
LVL 8

Accepted Solution

by:
Rance_Hall earned 2000 total points
ID: 22953955
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
 
LVL 3

Expert Comment

by:sukumade
ID: 22953995
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
 
LVL 8

Expert Comment

by:Rance_Hall
ID: 22954101
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
 
LVL 3

Expert Comment

by:lqw
ID: 22955260
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
 
LVL 8

Expert Comment

by:Rance_Hall
ID: 22959823
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
 
LVL 8

Expert Comment

by:Rance_Hall
ID: 23096100
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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension . This reminded me of questions that come up here at EE along the lines of, "How can I tell the type of file from its cont…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses
Course of the Month15 days, 15 hours left to enroll

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question