This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: a way to read the current cpu load from the shell or via a cmdline utility in cygwin?


On Sat, 27 Jul 2002, Jim George wrote:

> On Fri, 26 Jul 2002 18:07:01 -0400 (EDT)
> Igor Pechtchanski <pechtcha@cs.nyu.edu> wrote:
>
> > On Fri, 26 Jul 2002, Jim George wrote:
> >
> > > On Fri, 26 Jul 2002 11:44:03 -0400 (EDT)
> > > Igor Pechtchanski <pechtcha@cs.nyu.edu> wrote:
> > >
> > > > On Thu, 25 Jul 2002, Jim George wrote:
> > > >
> > > > > > On Thu, 25 Jul 2002, Greg McCrory wrote:
> > > > > >
> > > > > > > At 7/24/2002 11:38 PM -0400, Igor Pechtchanski wrote:
> > > > > > > >On Wed, 24 Jul 2002, Jim George wrote:
> > > > > > > >
> > > > > > > >Jim,
> > > > > > > >
> > > > > > > >I did a google search on "linux top cpu load".  Here's a top from the
> > > > > > > >first match: http://www.groupsys.com/topsrc/top-3.5beta9.tar.gz
> > > > > > > >It took about an hour to make it compile and run under cygwin 1.3.12-2 on
> > > > > > > >Win2k.  The patch is attached.
> > > > > > > >
> > > > > > > >Note: I just compiled and ran the code; I haven't verified the correctness
> > > > > > > >of the output.  It seemed to work without crashing, and the output looked
> > > > > > > >plausible.  I also haven't tested it on any system other than mine (above).
> > > > > > > >Try it at your own risk.
> > > > > > > >     Igor
> > > > > > >
> > > > > > > Notes on my quick attempt this morning:
> > > > > > >
> > > > > > > To get the ./Configure to run properly I needed a symbolic link to tcsh:
> > > > > > > ln -s /bin/tcsh /bin/csh
> > > > > >
> > > > > > Right, I have that too (from way back, no wonder I forgot to mention it).
> > > > > >
> > > > > > > Also chose module linux when asked.
> > > > > >
> > > > > > Yep.  Again, should have said that.
> > > > > >
> > > > > > > for owner, used SYSTEM instead of default root
> > > > > >
> > > > > > chown and chgrp didn't seem to work for me at all.  However, I don't have
> > > > > > a CYGWIN variable, so that might be the reason.  I don't miss it, though.
> > > > > >
> > > > > > > install script did not move the executable into the proper directory:
> > > > > >
> > > > > > I used /usr/bin/install as the install command.
> > > > > >
> > > > > > > ./install -o SYSTEM -m 4711 -g SYSTEM top /usr/local/bin
> > > > > > > chown: changing ownership of `/usr/local/bin/top': No such file or directory
> > > > > > > chgrp: changing group of `/usr/local/bin/top': No such file or directory
> > > > > > > chmod: changing permissions of `/usr/local/bin/top': No such file or directory
> > > > > > > make: *** [install-top] Error 1
> > > > > >
> > > > > > See http://cygwin.com/cygwin-ug-net/using-specialnames.html#AEN644
> > > > > > It may be necessary to use the local script after all, and re-write it to
> > > > > > boot.
> > > > > >
> > > > > > > I was able to install it manually and it appears to work.
> > > > > > > GMc
> > > > > >
> > > > > > Not quite correctly -- see
> > > > > > http://cygwin.com/ml/cygwin/2002-07/msg01995.html
> > > > > >   Igor
> > > > > Hi everyone,
> > > > >
> > > > >     well I got as far as compiling and installing, in the same way
> > > > >       that Greg did, but...
> > > > >
> > > > >     When I run top I get the following error..
> > > > >
> > > > >             top: proc filesystem not mounted on /proc
> > > > >                  type = 6
> > > > >
> > > > >     The output of mount is..
> > > > > [snip]
> > > > >     Can anyone tell me what I've done wrong?  Do I need to explicitly
> > > > >       mount /proc?
> > > >
> > > > No, /proc is a virtual filesystem that is already mounted.  However, top
> > > > checks something called a PROC_SUPER_MAGIC, which is a compile-time
> > > > constant, but seems to be different for every system.  The value in the
> > > > patch is for my system only (as I repeatedly said).  To determine what the
> > > > value is on your system, edit machine.c, and insert fprintf(stderr, "
> > > > type=%x\n", sb.f_type); in machine_init, right after it prints out the
> > > > above error message (but before the return).  Then recompile and run.
> > > > It'll still fail, but now you'll know what the value of PROC_SUPER_MAGIC
> > > > is for your system.  Edit machine.c and change the #define of
> > > > PROC_SUPER_MAGIC from 0x9fa0 (the value for my system) to whatever it is
> > > > on yours.  Recompile, and top should work.
> > > > I know this is tedious and non-portable.  Someone who knows how the value
> > > > is actually derived on each machine can come up with a better way.
> > > >       Igor
> > >
> > > Igor,
> > >         I went to make the change to machine.c that you suggested but
> > > the entry is already there right before the error return.
> > >         When I run top I get the type=6, so what is the number I should
> > > replace 0x9fa0 with, 0x0006?
> > > Regards,
> > > Jim
> >
> > Jim,
> > Right, sorry, I forgot that I included the printout in the patch...  Well,
> > that means less work for you. :-)
> > Yes, do replace 0x9fa0 with the value that was printed out (in your case,
> > 6).  The printout is in hex, you can just add a 0x in front of it (i.e.,
> > 0x6).  Adding leading 0's (e.g., 0x000006) won't make a difference.
> >       Igor
>
> Thanks Igor,
>         that did it.
>         Were you aware that you had competition?  There's a package
> called procps by Chris January at
> http://www.doc.ic.ac.uk/~ccj00/procps-010801.
>         Perhaps you could share experiences/code?
> Jim

Jim,
Yes, I saw the messages, thanks.  Contrary to the belief some people seem
to have, I'm not an author or maintainer of the top package - I just
looked on the net, found the source, and twiddled with it to make it
compile and run under cygwin.  I'm not even claiming it's the best out
there - it was the first match, that's all.  I'm sure Chris's tools are
better and more Cygwin-compatible.  My attempt was to fill the void, not
to provide the best there is.  I'm not even sure how most of the code
works - I'm only familiar with the parts I had to change to port it.  All
of my experiences are described right here on the list.
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha@cs.nyu.edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor@watson.ibm.com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

It took the computational power of three Commodore 64s to fly to the moon.
It takes a 486 to run Windows 95.  Something is wrong here. -- SC sig file


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]