I would like to get some of the information provided by the "top"
command into my ruby program, in particular the "load" values. The only
way I can think of is to use popen3 to run "top -n 1" and parse the
output, but I would like to not have to call an external command and do
it using pure ruby.
I would like to get some of the information provided by the "top"
command into my ruby program, in particular the "load" values. The only
way I can think of is to use popen3 to run "top -n 1" and parse the
output, but I would like to not have to call an external command and do
it using pure ruby.
look at the contents of /proc/loadavg
···
On Tue, Apr 1, 2008 at 8:49 AM, James Dinkel <jdinkel@gmail.com> wrote:
The uptime command will report it, if for whatever reason you don't have
or can't use the /proc option.
Ben
···
On Tue, Apr 01, 2008, James Dinkel wrote:
I would like to get some of the information provided by the "top"
command into my ruby program, in particular the "load" values. The only
way I can think of is to use popen3 to run "top -n 1" and parse the
output, but I would like to not have to call an external command and do
it using pure ruby.
On Tue, Apr 1, 2008 at 8:49 AM, James Dinkel <jdinkel@gmail.com> wrote:
I would like to get some of the information provided by the "top"
command into my ruby program, in particular the "load" values. The only
way I can think of is to use popen3 to run "top -n 1" and parse the
output, but I would like to not have to call an external command and do
it using pure ruby.
Yeah ... that will work. But I'm curious why the OP's application cares about the load averages. My experience has been that there isn't a lot to be gained from it. "Real" load balancing is a bit more complicated, if that's what he's trying to do.
On Tue, Apr 1, 2008 at 8:49 AM, James Dinkel <jdinkel@gmail.com> wrote:
> I would like to get some of the information provided by the "top"
> command into my ruby program, in particular the "load" values. The only
> way I can think of is to use popen3 to run "top -n 1" and parse the
> output, but I would like to not have to call an external command and do
> it using pure ruby.
Oh, thanks, I did not realize it was kept in a file.
I'm wanting this because this script currently blows up the server if
run when the load is too high. I'll just have the script sleep for 5
minutes until the load is under a certain threshold.
Oh, thanks, I did not realize it was kept in a file.
I'm wanting this because this script currently blows up the server if
run when the load is too high. I'll just have the script sleep for 5
minutes until the load is under a certain threshold.
Sorry for being negative, but what will happen if the load goes up
again while your script is running?
Maybe you just cannot run this script safely on that server.
Just curious what that script does, maybe you can run it on a nice
level that will allow the server to survive, seems
much a saver approach to me.
Cheers
Robert
···
On Tue, Apr 1, 2008 at 5:08 PM, James Dinkel <jdinkel@gmail.com> wrote:
Oh, thanks, I did not realize it was kept in a file.
It's not exactly a file. But it is mounted in a special file system
and can be read like a file or device.
I'm wanting this because this script currently blows up the server if
run when the load is too high. I'll just have the script sleep for 5
minutes until the load is under a certain threshold.
That's what process priorities are for. You can find out via "man
nice". Maybe there's even a Ruby library method that allows to lower
the priority of the current process.
Kind regards
robert
···
2008/4/1, James Dinkel <jdinkel@gmail.com>:
--
use.inject do |as, often| as.you_can - without end
Sorry for being negative, but what will happen if the load goes up
again while your script is running?
I'm pretty sure the server will blow up.
Maybe you just cannot run this script safely on that server.
Just curious what that script does, maybe you can run it on a nice
level that will allow the server to survive, seems
much a saver approach to me.
I don't know what "a nice level" is, but I will look into it.
Oh, thanks, I did not realize it was kept in a file.
I'm wanting this because this script currently blows up the server if
run when the load is too high. I'll just have the script sleep for 5
minutes until the load is under a certain threshold.
Sorry for being negative, but what will happen if the load goes up
again while your script is running?
Maybe you just cannot run this script safely on that server.
Just curious what that script does, maybe you can run it on a nice
level that will allow the server to survive, seems
much a saver approach to me.
Cheers
Robert
SNMP is the Simple Network Management Protocol. This protocol provides
the capability to monitor and manage switches, routers, printers,
desktops, and other equipment in your network.
···
On Tue, Apr 1, 2008 at 5:08 PM, James Dinkel <jdinkel@gmail.com> wrote:
It simply runs your program with less or more priority, but I guess
you can type "man nice" as you have
indicated above.
Good luck.
R.
···
On Tue, Apr 1, 2008 at 5:20 PM, James Dinkel <jdinkel@gmail.com> wrote:
Robert Dober wrote:
> Sorry for being negative, but what will happen if the load goes up
> again while your script is running?
I'm pretty sure the server will blow up.
> Maybe you just cannot run this script safely on that server.
> Just curious what that script does, maybe you can run it on a nice
> level that will allow the server to survive, seems
> much a saver approach to me.
I don't know what "a nice level" is, but I will look into it.