PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.ruby > linux: getting the "load" values without using "top"
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
linux: getting the "load" values without using "top"

Réponse
 
LinkBack Outils de la discussion
Vieux 01/04/2008, 15h49   #1
James Dinkel
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut linux: getting the "load" values without using "top"

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.
--
Posted via http://www.ruby-forum.com/.

  Réponse avec citation
Vieux 01/04/2008, 15h56   #2
pat eyler
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: linux: getting the "load" values without using "top"

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.


look at the contents of /proc/loadavg



> --
> Posted via http://www.ruby-forum.com/.
>
>




--
thanks,
-pate
-------------------------
Duty makes us do things, Love make us do things well.
http://on-ruby.blogspot.com http://on-erlang.blogspot.com
http://on-soccer.blogspot.com

  Réponse avec citation
Vieux 01/04/2008, 15h56   #3
ts
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: linux: getting the "load" values without using "top"

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.


Well, it's in /proc/loadavg no ? Juste read this file.


Guy Decoux

  Réponse avec citation
Vieux 01/04/2008, 16h02   #4
M. Edward (Ed) Borasky
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: linux: getting the "load" values without using "top"

pat eyler wrote:
> 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.

>
> look at the contents of /proc/loadavg
>
>
>
>> --
>> Posted via http://www.ruby-forum.com/.
>>
>>

>
>
>


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.

  Réponse avec citation
Vieux 01/04/2008, 16h08   #5
James Dinkel
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: linux: getting the "load" values without using "top"

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.

--
Posted via http://www.ruby-forum.com/.

  Réponse avec citation
Vieux 01/04/2008, 16h15   #6
Robert Dober
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: linux: getting the "load" values without using "top"

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.
>
> 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
>
> --
>
>
> Posted via http://www.ruby-forum.com/.
>
>




--
http://ruby-smalltalk.blogspot.com/

---
Whereof one cannot speak, thereof one must be silent.
Ludwig Wittgenstein

  Réponse avec citation
Vieux 01/04/2008, 16h20   #7
James Dinkel
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: linux: getting the "load" values without using "top"

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.

Thanks,
James
--
Posted via http://www.ruby-forum.com/.

  Réponse avec citation
Vieux 01/04/2008, 16h27   #8
Robert Dober
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: linux: getting the "load" values without using "top"

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.

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.

--
http://ruby-smalltalk.blogspot.com/

---
Whereof one cannot speak, thereof one must be silent.
Ludwig Wittgenstein

  Réponse avec citation
Vieux 01/04/2008, 16h29   #9
Robert Klemme
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: linux: getting the "load" values without using "top"

2008/4/1, James Dinkel <jdinkel@gmail.com>:
> 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

--
use.inject do |as, often| as.you_can - without end

  Réponse avec citation
Vieux 01/04/2008, 17h08   #10
Ben Bleything
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: linux: getting the "load" values without using "top"

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.


The uptime command will report it, if for whatever reason you don't have
or can't use the /proc option.

Ben

  Réponse avec citation
Vieux 01/04/2008, 18h58   #11
Rodrigo Bermejo
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: linux: getting the "load" values without using "top"

Robert Dober wrote:
> 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.
>>
>> 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
>>
>> --
>>
>>
>> Posted via http://www.ruby-forum.com/.
>>
>>

>
>
>
> --
> http://ruby-smalltalk.blogspot.com/
>
> ---
> Whereof one cannot speak, thereof one must be silent.
> Ludwig Wittgenstein


A secure aproach can be SNMP*
You can use it from the localhost or somewhere else

http://snmplib.rubyforge.org/

* What is SNMP?

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.
--
Posted via http://www.ruby-forum.com/.

  Réponse avec citation
Vieux 04/04/2008, 18h07   #12
Stafford A. Rau
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: linux: getting the "load" values without using "top"

* pat eyler <pat.eyler@gmail.com> [080401 07:58]:
> 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.

>
> look at the contents of /proc/loadavg


Ruby Geek! ;-)

--Stafford (Very very newbie wanna-be Ruby Geek)

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 06h25.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,21914 seconds with 20 queries