home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-01-10 | 75.7 KB | 2,608 lines |
- Newsgroups: comp.sources.x
- From: kssingvo@cip.informatik.uni-erlangen.de (Klaus Singvogel)
- Subject: v21i087: perf - A better perfmeter clone, Part01/01
- Message-ID: <1994Jan10.200324.4117@sparky.sterling.com>
- X-Md4-Signature: b347abb4eb0111c977ba2f444fc7ea1f
- Keywords: X11,xview,perfmeter
- Sender: chris@sparky.sterling.com (Chris Olson)
- Reply-To: rfkoenig@immd4.informatik.uni-erlangen.de
- Organization: Student Pool, CSD, University of Erlangen, Germany
- Date: Mon, 10 Jan 1994 20:03:24 GMT
- Approved: chris@sterling.com
-
- Submitted-by: kssingvo@cip.informatik.uni-erlangen.de (Klaus Singvogel)
- Posting-number: Volume 21, Issue 87
- Archive-name: perf/part01
- Environment: X11, XView
-
-
- perf - report kernel statistics visually.
-
- perf is a XView program that reports kernel statistics for a given host
- (or for the localhost if no host is specified).
-
- Features are:
- Scrollback, multi column support, multi color support for displaying
- subvalues like e.g. usr, nice & sys in *one* (here: cpu) field, displaying
- statistics of a remote host and much more.
-
- The displayed window consists of one or more fields, each showing a
- specified parameter. The name of the parameter and of its components are
- shown in the lower left corner of the field, the maximum value of the
- visible data in the lower right corner.
-
- Tested on HP/UX, SunOS 4.1.x, Linux with different C compilers.
-
- perf can also be found on ftp.informatik.uni-erlangen.de:
- pub/Linux/LOCAL/rstatd/perf.tgz.
- For Linux you need the kernel patch and rstatd, found in the same
- directory.
-
- For a first look, configure, compile and start it; click with the "right"
- button into the display window. You will get a new window, in which you
- can set many parameters. "apply" Button to activate the parameters.
- "Hide window" or another right button click into the display window will
- remove the paramter window.
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of shell archive."
- # Contents: perf perf/Imakefile perf/LICENSE perf/Makefile.simple
- # perf/README perf/README.linux perf/icon.xbm perf/perf.1
- # perf/perf.c perf/rstattest.c
- # Wrapped by kssingvo@medusa on Wed Nov 24 14:05:14 1993
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test ! -d 'perf' ; then
- echo shar: Creating directory \"'perf'\"
- mkdir 'perf'
- fi
- if test -f 'perf/Imakefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'perf/Imakefile'\"
- else
- echo shar: Extracting \"'perf/Imakefile'\" \(383 characters\)
- sed "s/^X//" >'perf/Imakefile' <<'END_OF_FILE'
- X#include <XView.tmpl>
- X
- XSYS_LIBRARIES = -lrpcsvc
- XDEPLIBS = XViewClientDepLibs
- XLOCAL_LIBRARIES = XViewClientLibs
- X
- XMAKEFILE_SIMPLE = Makefile.simple
- XICON = icon.xbm
- XSRCS = perf.c
- XALLFILES = $(MAKEFILE_SIMPLE) $(SRCS) $(ICON)
- X
- XPROGRAMS = perf rstattest
- X
- XAllTarget($(PROGRAMS))
- XSingleProgramTarget(perf,perf.o,$(LOCAL_LIBRARIES), /**/)
- X
- X#include <XView.prog>
- END_OF_FILE
- if test 383 -ne `wc -c <'perf/Imakefile'`; then
- echo shar: \"'perf/Imakefile'\" unpacked with wrong size!
- fi
- # end of 'perf/Imakefile'
- fi
- if test -f 'perf/LICENSE' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'perf/LICENSE'\"
- else
- echo shar: Extracting \"'perf/LICENSE'\" \(17982 characters\)
- sed "s/^X//" >'perf/LICENSE' <<'END_OF_FILE'
- X GNU GENERAL PUBLIC LICENSE
- X Version 2, June 1991
- X
- X Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- X 675 Mass Ave, Cambridge, MA 02139, USA
- X Everyone is permitted to copy and distribute verbatim copies
- X of this license document, but changing it is not allowed.
- X
- X Preamble
- X
- X The licenses for most software are designed to take away your
- Xfreedom to share and change it. By contrast, the GNU General Public
- XLicense is intended to guarantee your freedom to share and change free
- Xsoftware--to make sure the software is free for all its users. This
- XGeneral Public License applies to most of the Free Software
- XFoundation's software and to any other program whose authors commit to
- Xusing it. (Some other Free Software Foundation software is covered by
- Xthe GNU Library General Public License instead.) You can apply it to
- Xyour programs, too.
- X
- X When we speak of free software, we are referring to freedom, not
- Xprice. Our General Public Licenses are designed to make sure that you
- Xhave the freedom to distribute copies of free software (and charge for
- Xthis service if you wish), that you receive source code or can get it
- Xif you want it, that you can change the software or use pieces of it
- Xin new free programs; and that you know you can do these things.
- X
- X To protect your rights, we need to make restrictions that forbid
- Xanyone to deny you these rights or to ask you to surrender the rights.
- XThese restrictions translate to certain responsibilities for you if you
- Xdistribute copies of the software, or if you modify it.
- X
- X For example, if you distribute copies of such a program, whether
- Xgratis or for a fee, you must give the recipients all the rights that
- Xyou have. You must make sure that they, too, receive or can get the
- Xsource code. And you must show them these terms so they know their
- Xrights.
- X
- X We protect your rights with two steps: (1) copyright the software, and
- X(2) offer you this license which gives you legal permission to copy,
- Xdistribute and/or modify the software.
- X
- X Also, for each author's protection and ours, we want to make certain
- Xthat everyone understands that there is no warranty for this free
- Xsoftware. If the software is modified by someone else and passed on, we
- Xwant its recipients to know that what they have is not the original, so
- Xthat any problems introduced by others will not reflect on the original
- Xauthors' reputations.
- X
- X Finally, any free program is threatened constantly by software
- Xpatents. We wish to avoid the danger that redistributors of a free
- Xprogram will individually obtain patent licenses, in effect making the
- Xprogram proprietary. To prevent this, we have made it clear that any
- Xpatent must be licensed for everyone's free use or not licensed at all.
- X
- X The precise terms and conditions for copying, distribution and
- Xmodification follow.
- X
- X GNU GENERAL PUBLIC LICENSE
- X TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
- X
- X 0. This License applies to any program or other work which contains
- Xa notice placed by the copyright holder saying it may be distributed
- Xunder the terms of this General Public License. The "Program", below,
- Xrefers to any such program or work, and a "work based on the Program"
- Xmeans either the Program or any derivative work under copyright law:
- Xthat is to say, a work containing the Program or a portion of it,
- Xeither verbatim or with modifications and/or translated into another
- Xlanguage. (Hereinafter, translation is included without limitation in
- Xthe term "modification".) Each licensee is addressed as "you".
- X
- XActivities other than copying, distribution and modification are not
- Xcovered by this License; they are outside its scope. The act of
- Xrunning the Program is not restricted, and the output from the Program
- Xis covered only if its contents constitute a work based on the
- XProgram (independent of having been made by running the Program).
- XWhether that is true depends on what the Program does.
- X
- X 1. You may copy and distribute verbatim copies of the Program's
- Xsource code as you receive it, in any medium, provided that you
- Xconspicuously and appropriately publish on each copy an appropriate
- Xcopyright notice and disclaimer of warranty; keep intact all the
- Xnotices that refer to this License and to the absence of any warranty;
- Xand give any other recipients of the Program a copy of this License
- Xalong with the Program.
- X
- XYou may charge a fee for the physical act of transferring a copy, and
- Xyou may at your option offer warranty protection in exchange for a fee.
- X
- X 2. You may modify your copy or copies of the Program or any portion
- Xof it, thus forming a work based on the Program, and copy and
- Xdistribute such modifications or work under the terms of Section 1
- Xabove, provided that you also meet all of these conditions:
- X
- X a) You must cause the modified files to carry prominent notices
- X stating that you changed the files and the date of any change.
- X
- X b) You must cause any work that you distribute or publish, that in
- X whole or in part contains or is derived from the Program or any
- X part thereof, to be licensed as a whole at no charge to all third
- X parties under the terms of this License.
- X
- X c) If the modified program normally reads commands interactively
- X when run, you must cause it, when started running for such
- X interactive use in the most ordinary way, to print or display an
- X announcement including an appropriate copyright notice and a
- X notice that there is no warranty (or else, saying that you provide
- X a warranty) and that users may redistribute the program under
- X these conditions, and telling the user how to view a copy of this
- X License. (Exception: if the Program itself is interactive but
- X does not normally print such an announcement, your work based on
- X the Program is not required to print an announcement.)
- X
- XThese requirements apply to the modified work as a whole. If
- Xidentifiable sections of that work are not derived from the Program,
- Xand can be reasonably considered independent and separate works in
- Xthemselves, then this License, and its terms, do not apply to those
- Xsections when you distribute them as separate works. But when you
- Xdistribute the same sections as part of a whole which is a work based
- Xon the Program, the distribution of the whole must be on the terms of
- Xthis License, whose permissions for other licensees extend to the
- Xentire whole, and thus to each and every part regardless of who wrote it.
- X
- XThus, it is not the intent of this section to claim rights or contest
- Xyour rights to work written entirely by you; rather, the intent is to
- Xexercise the right to control the distribution of derivative or
- Xcollective works based on the Program.
- X
- XIn addition, mere aggregation of another work not based on the Program
- Xwith the Program (or with a work based on the Program) on a volume of
- Xa storage or distribution medium does not bring the other work under
- Xthe scope of this License.
- X
- X 3. You may copy and distribute the Program (or a work based on it,
- Xunder Section 2) in object code or executable form under the terms of
- XSections 1 and 2 above provided that you also do one of the following:
- X
- X a) Accompany it with the complete corresponding machine-readable
- X source code, which must be distributed under the terms of Sections
- X 1 and 2 above on a medium customarily used for software interchange; or,
- X
- X b) Accompany it with a written offer, valid for at least three
- X years, to give any third party, for a charge no more than your
- X cost of physically performing source distribution, a complete
- X machine-readable copy of the corresponding source code, to be
- X distributed under the terms of Sections 1 and 2 above on a medium
- X customarily used for software interchange; or,
- X
- X c) Accompany it with the information you received as to the offer
- X to distribute corresponding source code. (This alternative is
- X allowed only for noncommercial distribution and only if you
- X received the program in object code or executable form with such
- X an offer, in accord with Subsection b above.)
- X
- XThe source code for a work means the preferred form of the work for
- Xmaking modifications to it. For an executable work, complete source
- Xcode means all the source code for all modules it contains, plus any
- Xassociated interface definition files, plus the scripts used to
- Xcontrol compilation and installation of the executable. However, as a
- Xspecial exception, the source code distributed need not include
- Xanything that is normally distributed (in either source or binary
- Xform) with the major components (compiler, kernel, and so on) of the
- Xoperating system on which the executable runs, unless that component
- Xitself accompanies the executable.
- X
- XIf distribution of executable or object code is made by offering
- Xaccess to copy from a designated place, then offering equivalent
- Xaccess to copy the source code from the same place counts as
- Xdistribution of the source code, even though third parties are not
- Xcompelled to copy the source along with the object code.
- X
- X 4. You may not copy, modify, sublicense, or distribute the Program
- Xexcept as expressly provided under this License. Any attempt
- Xotherwise to copy, modify, sublicense or distribute the Program is
- Xvoid, and will automatically terminate your rights under this License.
- XHowever, parties who have received copies, or rights, from you under
- Xthis License will not have their licenses terminated so long as such
- Xparties remain in full compliance.
- X
- X 5. You are not required to accept this License, since you have not
- Xsigned it. However, nothing else grants you permission to modify or
- Xdistribute the Program or its derivative works. These actions are
- Xprohibited by law if you do not accept this License. Therefore, by
- Xmodifying or distributing the Program (or any work based on the
- XProgram), you indicate your acceptance of this License to do so, and
- Xall its terms and conditions for copying, distributing or modifying
- Xthe Program or works based on it.
- X
- X 6. Each time you redistribute the Program (or any work based on the
- XProgram), the recipient automatically receives a license from the
- Xoriginal licensor to copy, distribute or modify the Program subject to
- Xthese terms and conditions. You may not impose any further
- Xrestrictions on the recipients' exercise of the rights granted herein.
- XYou are not responsible for enforcing compliance by third parties to
- Xthis License.
- X
- X 7. If, as a consequence of a court judgment or allegation of patent
- Xinfringement or for any other reason (not limited to patent issues),
- Xconditions are imposed on you (whether by court order, agreement or
- Xotherwise) that contradict the conditions of this License, they do not
- Xexcuse you from the conditions of this License. If you cannot
- Xdistribute so as to satisfy simultaneously your obligations under this
- XLicense and any other pertinent obligations, then as a consequence you
- Xmay not distribute the Program at all. For example, if a patent
- Xlicense would not permit royalty-free redistribution of the Program by
- Xall those who receive copies directly or indirectly through you, then
- Xthe only way you could satisfy both it and this License would be to
- Xrefrain entirely from distribution of the Program.
- X
- XIf any portion of this section is held invalid or unenforceable under
- Xany particular circumstance, the balance of the section is intended to
- Xapply and the section as a whole is intended to apply in other
- Xcircumstances.
- X
- XIt is not the purpose of this section to induce you to infringe any
- Xpatents or other property right claims or to contest validity of any
- Xsuch claims; this section has the sole purpose of protecting the
- Xintegrity of the free software distribution system, which is
- Ximplemented by public license practices. Many people have made
- Xgenerous contributions to the wide range of software distributed
- Xthrough that system in reliance on consistent application of that
- Xsystem; it is up to the author/donor to decide if he or she is willing
- Xto distribute software through any other system and a licensee cannot
- Ximpose that choice.
- X
- XThis section is intended to make thoroughly clear what is believed to
- Xbe a consequence of the rest of this License.
- X
- X 8. If the distribution and/or use of the Program is restricted in
- Xcertain countries either by patents or by copyrighted interfaces, the
- Xoriginal copyright holder who places the Program under this License
- Xmay add an explicit geographical distribution limitation excluding
- Xthose countries, so that distribution is permitted only in or among
- Xcountries not thus excluded. In such case, this License incorporates
- Xthe limitation as if written in the body of this License.
- X
- X 9. The Free Software Foundation may publish revised and/or new versions
- Xof the General Public License from time to time. Such new versions will
- Xbe similar in spirit to the present version, but may differ in detail to
- Xaddress new problems or concerns.
- X
- XEach version is given a distinguishing version number. If the Program
- Xspecifies a version number of this License which applies to it and "any
- Xlater version", you have the option of following the terms and conditions
- Xeither of that version or of any later version published by the Free
- XSoftware Foundation. If the Program does not specify a version number of
- Xthis License, you may choose any version ever published by the Free Software
- XFoundation.
- X
- X 10. If you wish to incorporate parts of the Program into other free
- Xprograms whose distribution conditions are different, write to the author
- Xto ask for permission. For software which is copyrighted by the Free
- XSoftware Foundation, write to the Free Software Foundation; we sometimes
- Xmake exceptions for this. Our decision will be guided by the two goals
- Xof preserving the free status of all derivatives of our free software and
- Xof promoting the sharing and reuse of software generally.
- X
- X NO WARRANTY
- X
- X 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
- XFOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
- XOTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
- XPROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
- XOR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- XMERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
- XTO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
- XPROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
- XREPAIR OR CORRECTION.
- X
- X 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
- XWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
- XREDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
- XINCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
- XOUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
- XTO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
- XYOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
- XPROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
- XPOSSIBILITY OF SUCH DAMAGES.
- X
- X END OF TERMS AND CONDITIONS
- X
- X Appendix: How to Apply These Terms to Your New Programs
- X
- X If you develop a new program, and you want it to be of the greatest
- Xpossible use to the public, the best way to achieve this is to make it
- Xfree software which everyone can redistribute and change under these terms.
- X
- X To do so, attach the following notices to the program. It is safest
- Xto attach them to the start of each source file to most effectively
- Xconvey the exclusion of warranty; and each file should have at least
- Xthe "copyright" line and a pointer to where the full notice is found.
- X
- X <one line to give the program's name and a brief idea of what it does.>
- X Copyright (C) 19yy <name of author>
- X
- X This program is free software; you can redistribute it and/or modify
- X it under the terms of the GNU General Public License as published by
- X the Free Software Foundation; either version 2 of the License, or
- X (at your option) any later version.
- X
- X This program is distributed in the hope that it will be useful,
- X but WITHOUT ANY WARRANTY; without even the implied warranty of
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X GNU General Public License for more details.
- X
- X You should have received a copy of the GNU General Public License
- X along with this program; if not, write to the Free Software
- X Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X
- XAlso add information on how to contact you by electronic and paper mail.
- X
- XIf the program is interactive, make it output a short notice like this
- Xwhen it starts in an interactive mode:
- X
- X Gnomovision version 69, Copyright (C) 19yy name of author
- X Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- X This is free software, and you are welcome to redistribute it
- X under certain conditions; type `show c' for details.
- X
- XThe hypothetical commands `show w' and `show c' should show the appropriate
- Xparts of the General Public License. Of course, the commands you use may
- Xbe called something other than `show w' and `show c'; they could even be
- Xmouse-clicks or menu items--whatever suits your program.
- X
- XYou should also get your employer (if you work as a programmer) or your
- Xschool, if any, to sign a "copyright disclaimer" for the program, if
- Xnecessary. Here is a sample; alter the names:
- X
- X Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- X `Gnomovision' (which makes passes at compilers) written by James Hacker.
- X
- X <signature of Ty Coon>, 1 April 1989
- X Ty Coon, President of Vice
- X
- XThis General Public License does not permit incorporating your program into
- Xproprietary programs. If your program is a subroutine library, you may
- Xconsider it more useful to permit linking proprietary applications with the
- Xlibrary. If this is what you want to do, use the GNU Library General
- XPublic License instead of this License.
- END_OF_FILE
- if test 17982 -ne `wc -c <'perf/LICENSE'`; then
- echo shar: \"'perf/LICENSE'\" unpacked with wrong size!
- fi
- # end of 'perf/LICENSE'
- fi
- if test -f 'perf/Makefile.simple' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'perf/Makefile.simple'\"
- else
- echo shar: Extracting \"'perf/Makefile.simple'\" \(204 characters\)
- sed "s/^X//" >'perf/Makefile.simple' <<'END_OF_FILE'
- XCC = cc
- XXHOME = /local/X11R5
- XCFLAGS = -O -I$(XHOME)/include
- X
- XPO = perf.o
- XLDFLAGS = -L$(XHOME)/lib -lxview -lolgx -lX11 -lrpcsvc #-lBSD
- X
- Xperf:$(PO)
- X $(CC) -o $@ $(PO) $(LDFLAGS)
- X
- Xclean:
- X -rm -f $(PO) perf
- END_OF_FILE
- if test 204 -ne `wc -c <'perf/Makefile.simple'`; then
- echo shar: \"'perf/Makefile.simple'\" unpacked with wrong size!
- fi
- # end of 'perf/Makefile.simple'
- fi
- if test -f 'perf/README' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'perf/README'\"
- else
- echo shar: Extracting \"'perf/README'\" \(175 characters\)
- sed "s/^X//" >'perf/README' <<'END_OF_FILE'
- X1) You should have XView 3.0 or later
- X2) how to build perf:
- X xmkmf
- X make
- X3) start it with
- X perf
- X or
- X perf -\?
- X
- X
- XBug reports to rfkoenig@informatik.uni-erlangen.de
- END_OF_FILE
- if test 175 -ne `wc -c <'perf/README'`; then
- echo shar: \"'perf/README'\" unpacked with wrong size!
- fi
- # end of 'perf/README'
- fi
- if test -f 'perf/README.linux' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'perf/README.linux'\"
- else
- echo shar: Extracting \"'perf/README.linux'\" \(326 characters\)
- sed "s/^X//" >'perf/README.linux' <<'END_OF_FILE'
- XHow to get perf running
- X1) You should have linux-pl12+ and the XView 3.2 port for Linux
- X2) install rstatd & librpcsvc.a
- X3) build & start perf
- X export IMAKEINCLUDE="-I/usr/openwin/lib/config"
- X (setenv IMAKEINCLUDE "-I/usr/openwin/lib/config")
- X xmkmf
- X make
- X perf &
- X
- X
- XBug reports to rfkoenig@informatik.uni-erlangen.de
- END_OF_FILE
- if test 326 -ne `wc -c <'perf/README.linux'`; then
- echo shar: \"'perf/README.linux'\" unpacked with wrong size!
- fi
- # end of 'perf/README.linux'
- fi
- if test -f 'perf/icon.xbm' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'perf/icon.xbm'\"
- else
- echo shar: Extracting \"'perf/icon.xbm'\" \(2704 characters\)
- sed "s/^X//" >'perf/icon.xbm' <<'END_OF_FILE'
- X#define icon_width 64
- X#define icon_height 64
- Xstatic char icon_bits[] = {
- X 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
- X 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
- X 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
- X 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
- X 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
- X 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,
- X 0x00,0xf0,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0x1f,
- X 0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0x7f,0x00,0xff,0x03,0xfc,0xff,0xff,0xff,
- X 0x7f,0xc0,0xff,0x0f,0xf8,0xff,0xff,0xff,0xff,0xc0,0xff,0x3f,0xf0,0xff,0xff,
- X 0xff,0xff,0xc0,0xff,0x3f,0xe0,0xff,0xff,0xff,0xff,0xc0,0xff,0x7f,0xe0,0xff,
- X 0xff,0xff,0xff,0xc0,0xff,0xff,0xc0,0xff,0xff,0xff,0xff,0xc0,0xff,0xff,0xc0,
- X 0xff,0xff,0xff,0xff,0xc0,0xff,0xff,0xc0,0xff,0xff,0xff,0xff,0xc0,0xff,0xff,
- X 0xc0,0xff,0xff,0xff,0xff,0xc0,0xff,0xff,0xc0,0xff,0xff,0xff,0xff,0xc0,0xff,
- X 0xff,0xc0,0xff,0xff,0xff,0xff,0xc0,0xff,0xff,0xc0,0xff,0xff,0xff,0xff,0xc0,
- X 0xff,0x7f,0xe0,0xff,0xff,0xff,0xff,0xc0,0xff,0x7f,0xe0,0xff,0xff,0xff,0xff,
- X 0xc0,0xff,0x3f,0xe0,0xff,0xff,0xff,0xff,0xc0,0xff,0x1f,0xf0,0xff,0xff,0xff,
- X 0xff,0xc0,0xff,0x0f,0xf8,0xff,0xff,0xff,0xff,0xc0,0xff,0x03,0xfc,0xff,0xff,
- X 0xff,0xff,0x00,0x00,0x00,0xfe,0xff,0x3f,0xf8,0xff,0x00,0x00,0x80,0xff,0xff,
- X 0x9f,0xf1,0xff,0x00,0x00,0xf0,0xff,0xff,0xcf,0xf3,0xff,0xc0,0xff,0xff,0xff,
- X 0xff,0xc7,0xff,0xff,0xc0,0xff,0xff,0xff,0xff,0xc7,0xff,0xff,0xc0,0xff,0xff,
- X 0xff,0xff,0xc7,0xff,0xff,0xc0,0xff,0x81,0x7f,0x1c,0x01,0xfe,0xff,0xc0,0x7f,
- X 0x1c,0x0f,0x04,0xc6,0xff,0xff,0xc0,0x3f,0x3e,0x3e,0x38,0xc6,0xff,0xff,0xc0,
- X 0x3f,0x7f,0x7c,0xfc,0xc7,0xff,0xff,0xc0,0x1f,0x7f,0x7c,0xfc,0xc7,0xff,0xff,
- X 0xc0,0x1f,0x00,0x7c,0xfc,0xc7,0xff,0xff,0xc0,0x1f,0xff,0x7f,0xfc,0xc7,0xff,
- X 0xff,0xc0,0x1f,0xff,0x7f,0xfc,0xc7,0xff,0xff,0xc0,0x1f,0xff,0x7f,0xfc,0xc7,
- X 0xff,0xff,0xc0,0x1f,0xff,0x7f,0xfc,0xc7,0xff,0x7f,0x80,0x3f,0xfe,0x7d,0xfc,
- X 0xc7,0xff,0x3f,0x00,0x3f,0xfe,0x7e,0xfc,0xc7,0xff,0x07,0x00,0x70,0x7c,0x3f,
- X 0xfc,0xc7,0xff,0x07,0x00,0xf0,0x81,0x0f,0xf0,0x01,0xff,0xff,0xff,0xff,0xff,
- X 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
- X 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
- X 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
- X 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
- X 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
- X 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
- X 0xff,0xff};
- END_OF_FILE
- if test 2704 -ne `wc -c <'perf/icon.xbm'`; then
- echo shar: \"'perf/icon.xbm'\" unpacked with wrong size!
- fi
- # end of 'perf/icon.xbm'
- fi
- if test -f 'perf/perf.1' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'perf/perf.1'\"
- else
- echo shar: Extracting \"'perf/perf.1'\" \(4909 characters\)
- sed "s/^X//" >'perf/perf.1' <<'END_OF_FILE'
- X.TH PERF 1 "15 September 1993"
- X.SH NAME
- Xperf \- report kernel statistics visually
- X.SH SYNOPSIS
- X.B perf
- X[-a] [-sampletime sec]
- X.if n .ti +0.5i
- X[-drawline] [-nosmooth] [-drawone] [-noadd]
- X.if n .ti +0.5i
- X[-noreset] [-scrollback sampled-values] [-columns cols]
- X.if n .ti +0.5i
- X[-col1 color] [-col2 color] [-col3 color]
- X.if n .ti +0.5i
- X[-col4 color] [-foreground color] [-background color]
- X.if n .ti +0.5i
- X[-cpu] [-disk] [-page] [-swap] [-interrupts]
- X.if n .ti +0.5i
- X[-packets] [-errors] [-collisions] [-context] [-load]
- X.if n .ti +0.5i
- X[host]
- X
- X.SH DESCRIPTION
- X.B perf
- Xis an XView program that reports kernel statistics for a given
- X.B host
- X(or for the localhost if no host is specified). The program is
- Xa frontend to the rstatd(8) daemon.
- X.PP
- XThe displayed window consists of one or more fields, each showing a specified
- Xparameter. The name of the parameter and of its components are shown in the
- Xlower left corner of the field, the maximum value of the visible data in the
- Xlower right corner.
- X
- X.SH OPTIONS
- X.TP
- X.B -sampletime sec
- XQuery the rstatd each
- X.B sec
- Xseconds for new data. Default is 2.
- X.TP
- X.B -drawline
- XDraw only a line instead of a filled block.
- X.TP
- X.B -nosmooth
- XIf the drawing is filled, do not smooth the data.
- X.TP
- X.B -drawone
- XShow only the sum of multiple subvalues like e.g. usr, nice & sys.
- XThis is the default on monochrome diplays.
- X.TP
- X.B -noadd
- XDo not draw the subvalues on top of each other. This means, that
- Xsome subvalues may be completely hidden, if following ones are
- Xgreater. Use the drawline option in such cases.
- X.TP
- X.B -noreset
- XDo not readjust the maximum value shown in the lower right corner.
- X.TP
- X.B -scrollback sampled-values
- XSet the scrollback buffer to
- X.B sampled-values.
- XDefault is 200, i.e. 20 minutes if sampletime is 2.
- XThe total number of samples stored is field_width_in_pixels + scrollback.
- X.TP
- X.B -columns cols
- XDisplay the fields in
- X.B cols
- Xcolumns. Default is 1.
- X.TP
- X.B -col[1-4] color -forground color -background color
- XThe first subvalue is drawn with the color col1, the second with col2 and so on.
- X.B color
- Xmust be of the form
- X.B #rrggbb,
- Xwhere
- X.B rr
- Xis the red component,
- X.B gg
- Xthe green and
- X.B bb
- Xthe blue one
- X(e.g #ff0000 is red).
- XDefaults:
- X.if n .ti +0.5i
- Xcol1: #000000 (black)
- X.if n .ti +0.5i
- Xcol2: #a0a0a0
- X.if n .ti +0.5i
- Xcol3: #c0c0c0
- X.if n .ti +0.5i
- Xcol3: #e0e0e0
- X.if n .ti +0.5i
- Xcol4: #ffffff (white)
- X.if n .ti +0.5i
- Xforeground is black and background is white.
- X.PP
- X.if n .ti -1i
- XThe following options specify, which statistic values are displayed:
- X.TP
- X.B -cpu
- XPercent of cpu being used.
- X.TP
- X.B -disk
- XDisk transfers per second.
- X.TP
- X.B -page
- XPages paged per second.
- X.TP
- X.B -swap
- XPages swapped per second.
- X.TP
- X.B -interrupts
- XNumber of device interrupts in a second.
- X.TP
- X.B -packets
- XNetwork packets per second.
- X.TP
- X.B -errors
- XErrors per second on receiving packets.
- X.TP
- X.B -collisions
- XCollisions per second detected on the network.
- X.TP
- X.B -context
- XNumber of context switches per second.
- X.TP
- X.B -load
- XLoad average.
- X.TP
- X.B -a
- XAll of the above 10 options.
- X
- X.SH KEYBOARD ACCELERATORS
- X.TP
- X.B a
- XToggle the noadd option.
- X.TP
- X.B q
- XQuit the program.
- X.TP
- X.B s
- XToggle solid drawing.
- X.TP
- X.B o
- XToggle smooth option.
- X.TP
- X.B 1
- XToggle the drawone option.
- X.TP
- X.B ?
- XBring up the properties window.
- X.TP
- X.B NL (NewLine)
- XRestore all scrollback windows to the current values.
- X.SH Mouse (Pointer device) Usage
- X.TP
- X.B Right Mouse Button
- XYou can bring up the
- X.B properties window
- Xby clicking the right mouse button.
- XDon't forget to select the 'Apply' button after changing values.
- X.if n .ti +0.0i
- XIf you click the right mouse button over one of the displayed fields
- Xwhile pressing the
- X.B SHIFT
- Xkey, you can change values valid only for this field. You can reset
- Xthis settings by selecting the 'No special flags' button.
- X.TP
- X.B Left Mouse Button
- XIf you click in a field with the left mouse button, the exact value of the
- Xsample will be displayed in the properties window.
- XIf you drag the field, you can examine the sampled values in the
- Xscrollback history.
- X.TP
- X.B Middle Mouse Button
- XYou can scroll more than one field at once by selecting all of them first with
- Xthe middle mouse button.
- X.SH X RESOURCES
- X.TP
- XFollowing X Resources are examined during startup:
- X.if n .ti +0.5i
- Xperf.sampletime
- X.if n .ti +0.5i
- Xperf.drawline
- X.if n .ti +0.5i
- Xperf.nosmooth
- X.if n .ti +0.5i
- Xperf.drawone
- X.if n .ti +0.5i
- Xperf.noreset
- X.if n .ti +0.5i
- Xperf.scrollback
- X.if n .ti +0.5i
- Xperf.columns
- X.if n .ti +0.5i
- Xperf.col1
- X.if n .ti +0.5i
- Xperf.col2
- X.if n .ti +0.5i
- Xperf.col3
- X.if n .ti +0.5i
- Xperf.col4
- X.if n .ti +0.5i
- Xperf.foreground
- X.if n .ti +0.5i
- Xperf.background
- X.TP
- XNote: Options take precedence over X Resources.
- X.SH FEATURES/BUGS
- X.PP
- XThe maximum scrollback is limited to 20000 values. This is because by
- Xinitiating a scrollback the whole history will be drawn on a single
- Xpixmap and this can be a memory hog. Besides X limits the size
- Xof a pixmap to 2^15 pixels (if I'm right).
- X.SH ATHOR
- X.PP
- XRudolf Koenig, 1993
- END_OF_FILE
- if test 4909 -ne `wc -c <'perf/perf.1'`; then
- echo shar: \"'perf/perf.1'\" unpacked with wrong size!
- fi
- # end of 'perf/perf.1'
- fi
- if test -f 'perf/perf.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'perf/perf.c'\"
- else
- echo shar: Extracting \"'perf/perf.c'\" \(41015 characters\)
- sed "s/^X//" >'perf/perf.c' <<'END_OF_FILE'
- X/*
- X * Copyright (C) 1993 Rudolf Koenig
- X *
- X * This program is free software; you can redistribute it and/or modify
- X * it under the terms of the GNU General Public License as published by
- X * the Free Software Foundation; either version 2, or (at your option)
- X * any later version.
- X *
- X * This program is distributed in the hope that it will be useful,
- X * but WITHOUT ANY WARRANTY; without even the implied warranty of
- X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X * GNU General Public License for more details.
- X *
- X * You should have received a copy of the GNU General Public License
- X * along with this program (see the file COPYING); if not, write to the
- X * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X */
- X
- X#include <xview/xview.h>
- X#include <xview/font.h>
- X#include <xview/canvas.h>
- X#include <xview/panel.h>
- X#include <xview/notify.h>
- X#include <xview/defaults.h>
- X#include <xview/icon.h>
- X#include "icon.xbm"
- X#include <rpc/rpc.h>
- X#include <rpcsvc/rstat.h>
- X#include <stdio.h>
- X
- Xextern int fork();
- X
- X#define PROGNAME "perf"
- X
- X#define CPU 1
- X#define PKTS 2
- X#define PAGE 3
- X#define SWAP 4
- X#define INTR 5
- X#define DISK 6
- X#define CTXT 7
- X#define LOAD 8
- X#define COLL 9
- X#define ERRS 10
- X
- X#define NUMCOLS 6
- X#define WHITE 4
- X#define BLACK 5
- X
- X
- Xstruct pm
- X{
- X int offset;
- X int starttime;
- X int startvalidx;
- X int posx, posy, width;
- X GC colorgc[NUMCOLS];
- X Pixmap pm;
- X} pm;
- X
- Xstruct values
- X{
- X int type;
- X char *name;
- X char *subname[4];
- X int numvalues;
- X int **values, *last;
- X int maxval, maxval_to_show;
- X int active;
- X unsigned int
- X special:1,
- X draw_line:1,
- X add_values:1,
- X no_smooth:1,
- X draw_one:1,
- X no_reset:1,
- X selected:1;
- X int scrollback;
- X int sec_perpixel,
- X lastsec; /* Amount to wait till next shift */
- X int xpos, ypos;
- X int validx;
- X struct pm *pm;
- X} values[] =
- X{
- X { CPU, "cpu", {"usr","nice","sys",0},3,0,0,100,-1, },
- X { DISK,"disk",{"1", "2", "3","4"},4,0,0, 1,-1, },
- X { PAGE,"page",{"in", "out", 0, 0},2,0,0, 1,-1, },
- X { SWAP,"swap",{"in", "out", 0, 0},2,0,0, 1,-1, },
- X { INTR,"interrupts",{0,0, 0, 0},1,0,0, 1,-1, },
- X { PKTS,"packets",{"in","out",0, 0},2,0,0, 1,-1, },
- X { ERRS,"errors", {"in","out",0, 0},2,0,0, 1,-1, },
- X { COLL,"collisions",{0,0, 0, 0},1,0,0, 1,-1, },
- X { CTXT,"context",{0, 0, 0, 0},1,0,0, 1,-1, },
- X { LOAD,"load",{0, 0, 0, 0},1,0,0,256, 1, },
- X { 0, 0, {0, 0, 0, 0},0,0,0, 0, 0, }
- X}, *active = 0;
- X
- X
- X
- XFrame fr, pfr;
- XCanvas ca;
- XPanel pn;
- XPanel_item pi_sels, pi_mach, pi_check, pi_spp, pi_cols, pi_msg,
- X pi_apply, pi_hide, pi_fork, pi_nosp, pi_scbk;
- XDisplay *dpy;
- XWindow win;
- Xint screen;
- XXv_Font font;
- XXFontStruct *font_info;
- XGC bwingc, wingc;
- Xint win_x, real_win_y, win_y = 0,
- X fontheight, depth, nrcurr_active,
- X width1, width2, height1, lost_connection = 0;
- Xchar **argv;
- X
- X/* Options */
- Xint sec_perpixel = 2, lastsec = 0, scrollback = 600, columns = 1,
- X add_values, noadd = 0,
- X no_reset = 0, draw_line = 0, no_smooth = 0, draw_one = 0;
- Xchar *host = 0;
- Xint defcol[NUMCOLS] =
- X { 0x000000, 0xa0a0a0, 0xc0c0c0, 0xe0e0e0, 0xffffff, 0x000000 };
- Xint defidx[NUMCOLS];
- X
- Xstruct opts
- X{
- X char *name;
- X int *param;
- X int needsarg;
- X} opts[] =
- X{
- X { "drawline", &draw_line, 0 },
- X { "nosmooth", &no_smooth, 0 },
- X { "drawone", &draw_one, 0 },
- X { "noadd", &noadd, 0 },
- X { "sampletime", &sec_perpixel, 1 },
- X { "noreset", &no_reset, 0 },
- X { "scrollback", &scrollback, 1 },
- X { "columns", &columns, 1 },
- X { "col1", &defcol[0], 1 },
- X { "col2", &defcol[1], 1 },
- X { "col3", &defcol[2], 1 },
- X { "col4", &defcol[3], 1 },
- X { "foreground", &defcol[BLACK], 1 },
- X { "background", &defcol[WHITE], 1 },
- X { 0, 0, 0 },
- X};
- X
- X#define FSET(v, flag) (v->special ? v->flag : flag)
- X#define VALUES_LENGTH(v) (FSET(v, scrollback)+width2)
- X
- Xstruct statstime sx;
- Xint just_started = 1, diffdisk, min_spp;
- XNotify_value update();
- X
- Xdo_alarm(t)
- X int t;
- X{
- X struct itimerval timer;
- X
- X timer.it_value.tv_sec = timer.it_interval.tv_sec = t;
- X timer.it_value.tv_usec = timer.it_interval.tv_usec = 0;
- X notify_enable_rpc_svc(1);
- X notify_set_itimer_func(fr, update, ITIMER_REAL, &timer, NULL);
- X}
- X
- X/* indx is needed by repaint, scrollback... */
- Xstatic void
- XDrawPixels(val, p, indx, col)
- X struct values *val;
- X struct pm *p;
- X int indx, col;
- X{
- X int x, y, i, oldv, newv, old, new,
- X **vals = val->values,
- X vl = VALUES_LENGTH(val);
- X
- X old = new = 0;
- X x = val->xpos * width1 + col;
- X y = val->ypos * height1 + height1 - fontheight;
- X
- X if(FSET(val, add_values))
- X {
- X for(i = 0; i < val->numvalues; i++)
- X {
- X new += vals[i][indx];
- X old += vals[i][(indx-1+vl) % vl];
- X }
- X if(new > val->maxval) new = val->maxval;
- X if(old > val->maxval) old = val->maxval;
- X }
- X
- X for(i = 0; i < val->numvalues; i++)
- X {
- X if(!FSET(val, add_values))
- X {
- X new = vals[i][indx];
- X old = vals[i][(indx-1+vl) % vl];
- X }
- X newv = (double)((height1-fontheight) * new) / (double)val->maxval;
- X oldv = (double)((height1-fontheight) * old) / (double)val->maxval;
- X
- X if(FSET(val, draw_line))
- X {
- X XDrawLine(dpy, p->pm, p->colorgc[i], x-1, y - oldv, x, y - newv);
- X }
- X else
- X {
- X XDrawLine(dpy, p->pm, p->colorgc[i], x, y, x, y - newv);
- X
- X if(!FSET(val, no_smooth))
- X {
- X if(newv > oldv)
- X XDrawLine(dpy, p->pm, p->colorgc[i],
- X x - 1, y - oldv, x - 1, y - oldv - (newv - oldv ) / 2);
- X else
- X XDrawLine(dpy, p->pm, p->colorgc[i],
- X x, y - newv, x, y - newv - (oldv - newv ) / 2);
- X }
- X }
- X
- X if(FSET(val, draw_one))
- X break;
- X if(FSET(val, add_values))
- X {
- X new -= vals[i][indx];
- X old -= vals[i][(indx-1+vl) % vl];
- X }
- X }
- X}
- X
- Xstatic int
- Xnextmax(v)
- X int v;
- X{
- X int m;
- X
- X for(m = 10; ; m *= 10)
- X if(v < m)
- X break;
- X m /= 10;
- X if(v > m * 5)
- X return m * 10;
- X if(v > m * 2)
- X return m * 5;
- X else if(v > m)
- X return m * 2;
- X else
- X return m;
- X}
- X
- X/* from can be larger then to*/
- Xstatic int
- Xrescale(val, from, to)
- X struct values *val;
- X int from, to;
- X{
- X int j, k, sum, max, tlen;
- X int changed = 0;
- X
- X if(val->type == CPU)
- X return 0;
- X tlen = VALUES_LENGTH(val);
- X max = (val->type == LOAD) ? 256 : 1;
- X
- X for(j = from; ; j = (j+1) % tlen)
- X {
- X for(sum = 0, k = val->numvalues - 1; k >= 0; k--)
- X sum += val->values[k][j];
- X if(sum > max)
- X if(val->type == LOAD)
- X while(sum > max) max *= 2;
- X else
- X max = sum;
- X if(j == to)
- X break;
- X }
- X if(val->type == LOAD)
- X {
- X val->maxval_to_show = max / 256;
- X changed = (val->maxval > max);
- X val->maxval = max;
- X }
- X else
- X {
- X changed = (val->maxval > nextmax(max));
- X val->maxval = nextmax(max);
- X }
- X return changed;
- X}
- X
- Xstatic void
- Xfill_last(sxp)
- X struct statstime *sxp;
- X{
- X int i, j, sum;
- X struct values *v;
- X
- X for(i = 0; values[i].numvalues; i++)
- X {
- X v = &values[i];
- X if(v->special && v->lastsec)
- X continue;
- X switch(v->type)
- X {
- X case CPU:
- X for(j = 0; j < 4; j++)
- X v->last[j] = sxp->cp_time[j];
- X break;
- X case DISK:
- X for(sum = j = 0; j < 4; j++)
- X v->last[j] = sxp->dk_xfer[j];
- X break;
- X case PAGE:
- X v->last[0] = sxp->v_pgpgin;
- X v->last[1] = sxp->v_pgpgout;
- X break;
- X case SWAP:
- X v->last[0] = sxp->v_pswpin;
- X v->last[1] = sxp->v_pswpout;
- X break;
- X case INTR:
- X v->last[0] = sxp->v_intr;
- X break;
- X case PKTS:
- X v->last[0] = sxp->if_ipackets;
- X v->last[1] = sxp->if_opackets;
- X break;
- X case ERRS:
- X v->last[0] = sxp->if_ierrors;
- X v->last[1] = sxp->if_oerrors;
- X break;
- X case COLL:
- X v->last[0] = sxp->if_collisions;
- X break;
- X case CTXT:
- X v->last[0] = sxp->v_swtch;
- X break;
- X case LOAD:
- X break;
- X }
- X }
- X}
- X
- Xstatic void
- Xinc()
- X{
- X int i;
- X struct values *v;
- X
- X for(i = 0; values[i].numvalues; i++)
- X {
- X v = &values[i];
- X if(!FSET(v, lastsec))
- X v->validx = (v->validx+1) % VALUES_LENGTH(v);
- X if(v->special)
- X v->lastsec = (v->lastsec+min_spp) % v->sec_perpixel;
- X }
- X lastsec = (lastsec+min_spp) % sec_perpixel;
- X}
- X
- XNotify_value
- Xupdate()
- X{
- X int i, j, redraw, from, to,
- X sum, sum1, x, y;
- X double d;
- X struct values *v;
- X static void dopaint();
- X
- X redraw = 0;
- X
- X if(!values[0].last) /* Called before initialization */
- X return;
- X if(rstat(host, &sx))
- X {
- X static char noconn[]="Lost connection";
- X int dir, ascent, descent;
- X XCharStruct or;
- X
- X /* Draw 'Lost Connection' in every field */
- X if(lost_connection)
- X return NOTIFY_DONE;
- X XTextExtents(font_info, noconn, strlen(noconn),&dir,&ascent,&descent,&or);
- X
- X for(i = 0; values[i].numvalues; i++)
- X if(values[i].active)
- X {
- X XDrawImageString(dpy, pm.pm, pm.colorgc[WHITE],
- X values[i].xpos * width2 + (width2 - or.width)/2,
- X values[i].ypos * height1 + (height1 - fontheight + ascent)/2,
- X noconn, strlen(noconn));
- X }
- X lost_connection = 1;
- X XCopyArea(dpy, pm.pm, win, wingc, 0, 0, win_x, real_win_y, 0, 0);
- X XFlush(dpy);
- X return NOTIFY_DONE;
- X }
- X
- X if(lost_connection || just_started) /* Connection alive again */
- X {
- X if(just_started)
- X {
- X do_alarm(min_spp);
- X if(sx.dk_xfer[0] + sx.dk_xfer[1] +
- X sx.dk_xfer[2] + sx.dk_xfer[3] > 200)
- X diffdisk = 0;
- X else
- X diffdisk = 1;
- X }
- X just_started = lost_connection = 0;
- X fill_last(&sx);
- X sleep(1);
- X rstat(host, &sx);
- X redraw = 1;
- X }
- X/* Check for working rstatd */
- X if(!sx.cp_time[3]) /* No idle tick since boot ??? */
- X {
- X printf("Buggy rstatd around? (Or perhaps no kernel support?)\n");
- X exit(-1);
- X }
- X
- X/* Let's scroll back */
- X for(i = 0; values[i].numvalues; i++)
- X {
- X v = &values[i];
- X if(v->active && !FSET(v, lastsec))
- X {
- X x = v->xpos * width1;
- X y = v->ypos * height1;
- X
- X XCopyArea(dpy, pm.pm, pm.pm, pm.colorgc[BLACK],
- X x+1, y, width2-1, height1-fontheight+2, x, y);
- X XDrawLine(dpy, pm.pm, pm.colorgc[WHITE],
- X x+width2-1, y, x+width2-1, y+height1);
- X }
- X }
- X
- X
- X/* Let's update */
- X for(i = 0; values[i].numvalues; i++)
- X {
- X v = &values[i];
- X if(FSET(v, lastsec))
- X continue;
- X/*
- Xprintf("%s,", v->name); fflush(stdout);
- X*/
- X switch(v->type)
- X {
- X case CPU:
- X for(j = sum = 0; j < 4; j++)
- X sum += sx.cp_time[j] - v->last[j];
- X if(!sum) /* Huhh?? But it happens!! */
- X {
- X fill_last(&sx);
- X return;
- X }
- X for(j = 0; j < 3; j++)
- X {
- X d = 100.0 * (sx.cp_time[j] - v->last[j])/(double)sum;
- X v->values[j][v->validx] = (int)(d+0.5);
- X }
- X break;
- X case PKTS:
- X sum = sx.if_ipackets - v->last[0];
- X sum1 = sx.if_opackets - v->last[1];
- X v->values[0][v->validx] = sum;
- X v->values[1][v->validx] = sum1;
- X#define CHECKMAX(a) if(a > v->maxval) { if(v->active) redraw = 1; v->maxval = nextmax(a); }
- X CHECKMAX(sum+sum1);
- X break;
- X case PAGE:
- X sum = sx.v_pgpgin - v->last[0];
- X sum1 = sx.v_pgpgout - v->last[1];
- X v->values[0][v->validx] = sum;
- X v->values[1][v->validx] = sum1;
- X CHECKMAX(sum+sum1);
- X break;
- X case SWAP:
- X sum = sx.v_pswpin - v->last[0];
- X sum1 = sx.v_pswpout - v->last[1];
- X v->values[0][v->validx] = sum;
- X v->values[1][v->validx] = sum1;
- X CHECKMAX(sum+sum1);
- X break;
- X case INTR:
- X v->values[0][v->validx] = sx.v_intr - v->last[0];
- X CHECKMAX(v->values[0][v->validx]);
- X break;
- X case DISK:
- X for(sum = j = 0; j < 4; j++)
- X {
- X v->values[j][v->validx] = sx.dk_xfer[j];
- X if(!diffdisk)
- X {
- X v->values[j][v->validx] -= v->last[j];
- X if(v->values[j][v->validx] < 0)
- X {
- X /* It IS diffdisk, we should delete/reinterpret the data */
- X v->values[j][v->validx] += v->last[j];
- X diffdisk = 1;
- X }
- X }
- X sum += v->values[j][v->validx];
- X }
- X CHECKMAX(sum);
- X break;
- X case CTXT:
- X v->values[0][v->validx] = sx.v_swtch - v->last[0];
- X CHECKMAX(v->values[0][v->validx]);
- X break;
- X case COLL:
- X v->values[0][v->validx] = sx.if_collisions - v->last[0];
- X CHECKMAX(v->values[0][v->validx]);
- X break;
- X case LOAD:
- X v->values[0][v->validx] = sx.avenrun[0];
- X while(v->values[0][v->validx] > v->maxval)
- X {
- X v->maxval *= 2;
- X v->maxval_to_show *= 2;
- X if(v->active) redraw = 1;
- X }
- X break;
- X case ERRS:
- X sum = sx.if_ierrors - v->last[0];
- X sum1 = sx.if_oerrors - v->last[1];
- X v->values[0][v->validx] = sum;
- X v->values[1][v->validx] = sum1;
- X CHECKMAX(sum+sum1);
- X break;
- X }
- X }
- X fill_last(&sx);
- X
- X/* Let's rescale, if necessary */
- X for(i = j = 0; values[i].numvalues; i++)
- X {
- X v = &values[i];
- X if(FSET(v, lastsec))
- X continue;
- X from = (v->validx + 1 - width2 + VALUES_LENGTH(v)) % VALUES_LENGTH(v);
- X to = v->validx;
- X
- X if(!(FSET(v, no_reset) || v->pm || (v->validx % 20)))
- X redraw += rescale(v, from, to);
- X }
- X
- X if(redraw)
- X {
- X inc();
- X dopaint(1);
- X }
- X else
- X {
- X for(i = 0; values[i].numvalues; i++)
- X {
- X v = &values[i];
- X if(v->active && !FSET(v, lastsec))
- X {
- X DrawPixels(v, &pm, v->validx, width2-1);
- X if(!v->pm)
- X {
- X x = v->xpos * width1; y = v->ypos * height1;
- X XCopyArea(dpy, pm.pm, win, wingc,
- X x, y, width2, height1-fontheight+2, x, y);
- X }
- X }
- X }
- X inc();
- X XFlush(dpy);
- X }
- X
- X return NOTIFY_DONE;
- X}
- X
- Xstatic void
- XFreePM(p)
- X struct pm *p;
- X{
- X int i;
- X
- X if(p->pm)
- X XFreePixmap(dpy, p->pm);
- X for(i = 0; i < NUMCOLS; i++)
- X if(p->colorgc[i])
- X XFreeGC(dpy, p->colorgc[i]);
- X}
- X
- Xstatic void
- XCreatePM(p, x, y)
- X struct pm *p;
- X int x, y;
- X{
- X XGCValues gcv;
- X int i;
- X
- X FreePM(p);
- X p->pm = XCreatePixmap(dpy, win, x, y, depth);
- X
- X gcv.font = xv_get(font, XV_XID);
- X
- X for(i = 0; i < NUMCOLS; i++)
- X {
- X gcv.background = i == WHITE ? defidx[BLACK] : defidx[WHITE];
- X gcv.foreground = defidx[i];
- X p->colorgc[i] = XCreateGC(dpy, p->pm,
- X GCFont|GCBackground|GCForeground,&gcv);
- X }
- X XFillRectangle(dpy, p->pm, p->colorgc[WHITE], 0, 0, x, y);
- X}
- X
- Xstatic void
- Xrealloc_values(v, oldlen, newlen)
- X struct values *v;
- X int oldlen, newlen;
- X{
- X int j, l, k,
- X *np, *op;
- X
- X if(oldlen == newlen)
- X return;
- X
- X if(!v->values) /* Let's initialize */
- X {
- X v->values = (int **)malloc(sizeof(int *) * v->numvalues);
- X for(l = 0; l < v->numvalues; l++)
- X v->values[l] = (int *)calloc(sizeof(int), newlen);
- X v->last = (int *)malloc(sizeof(int) * (v->type==CPU ? 4 : v->numvalues));
- X v->validx = newlen - 1;
- X return;
- X }
- X
- X/* Realloc a ringbuffer */
- X for(l = 0; l < v->numvalues; l++)
- X {
- X np = (int *)calloc(sizeof(int), newlen);
- X op = v->values[l];
- X if(newlen > oldlen)
- X {
- X k = newlen - oldlen;
- X for(j = 0; j < k; j++)
- X np[j] = 0;
- X
- X for(k = v->validx; j < newlen; j++, k = (k+1) % oldlen)
- X np[j] = op[k];
- X }
- X else
- X {
- X k = (v->validx + oldlen - newlen + 1) % oldlen;
- X for(j = 0; j < newlen; j++)
- X np[j] = op[(k+j)%oldlen];
- X }
- X free(op);
- X v->values[l] = np;
- X }
- X v->validx = newlen - 1;
- X}
- X
- Xstatic void
- XDrawText(v, drawtime)
- X struct values *v;
- X int drawtime;
- X{
- X int j, where, dir, ascent, descent;
- X int drone = FSET(v, draw_one);
- X int height = (v->ypos+1) * height1;
- X XCharStruct or;
- X char *ti, buf[16];
- X
- X if(drawtime)
- X {
- X ti = (char *)ctime((time_t *)&drawtime) + 11; ti[8] = '\0';
- X if(!pm.width)
- X {
- X XTextExtents(font_info, ti, 8, &dir, &ascent, &descent, &or);
- X v->pm->posx = width2 - 1 - or.width;
- X v->pm->posy = height1 - 1 - descent;
- X v->pm->width = or.width;
- X }
- X XDrawImageString(dpy, pm.pm, pm.colorgc[BLACK],
- X v->xpos*width1 + v->pm->posx,
- X v->ypos*height1 + v->pm->posy, ti, 8);
- X return;
- X }
- X
- X /* Draw text (cpu) */
- X XTextExtents(font_info, v->name, strlen(v->name), &dir,&ascent,&descent,&or);
- X XDrawImageString(dpy, pm.pm, pm.colorgc[BLACK],
- X v->xpos*width1+2, height-descent-1, v->name, strlen(v->name));
- X where = v->xpos*width1 + 2+or.width;
- X
- X /* Draw more text (sys nice usr) */
- X for(j = 0; !drone && j < 4 && v->subname[j]; j++)
- X {
- X char *str = v->subname[j];
- X
- X XDrawImageString(dpy, pm.pm, pm.colorgc[j],
- X where + 5, height-descent-1, str, strlen(str));
- X XTextExtents(font_info, str, strlen(str),
- X &dir,&ascent,&descent,&or);
- X where += 5 + or.width;
- X }
- X sprintf(buf, "%d", v->maxval_to_show == -1 ? v->maxval : v->maxval_to_show);
- X XTextExtents(font_info,buf,strlen(buf),&dir,&ascent,&descent,&or);
- X XDrawImageString(dpy, pm.pm, pm.colorgc[BLACK],
- X v->xpos * width1 + width2 - 2 - or.width,
- X height-descent-1, buf, strlen(buf));
- X}
- X
- Xstatic void
- Xdopaint(doit)
- X int doit;
- X{
- X int x, y, i, j, k, vl, oldwidth2,
- X size_changed, dir, ascent, descent;
- X XCharStruct or;
- X struct values *v;
- X
- X x = xv_get(canvas_paint_window(ca), XV_WIDTH);
- X y = xv_get(canvas_paint_window(ca), XV_HEIGHT) -1;
- X
- X size_changed = (win_x != x || real_win_y != y);
- X if(size_changed || doit)
- X {
- X CreatePM(&pm, x, y);
- X
- X win_x = x; win_y = real_win_y = y;
- X if(strcmp(host, "localhost"))
- X {
- X win_y = real_win_y - fontheight;
- X XTextExtents(font_info, host, strlen(host),
- X &dir, &ascent, &descent, &or);
- X XDrawImageString(dpy, pm.pm, pm.colorgc[BLACK],
- X (x-or.width)/2, real_win_y-descent-2, host, strlen(host));
- X }
- X oldwidth2 = width2;
- X width1 = win_x / columns;
- X width2 = width1 - 3;
- X height1 = win_y / ((nrcurr_active + columns - 1) / columns);
- X
- X for(i = 0; values[i].numvalues; i++)
- X {
- X v = &values[i];
- X vl = VALUES_LENGTH(v);
- X realloc_values(v, FSET(v, scrollback) + oldwidth2, vl);
- X
- X if(v->active)
- X {
- X DrawText(v, 0);
- X
- X k = (v->validx - width2 + 1 + vl) % vl;
- X for(j = 1; j < width2; j++)
- X {
- X DrawPixels(&values[i], &pm, k, j);
- X k = (k+1) % vl;
- X }
- X }
- X }
- X }
- X /* Copy the stripes */
- X if(size_changed || just_started)
- X XFillRectangle(dpy, win, wingc, 0, 0, x, y);
- X for(i = 0; values[i].numvalues; i++)
- X {
- X v = &values[i];
- X if(!v->active)
- X continue;
- X x = v->xpos * width1; y = v->ypos * height1;
- X if(!v->pm)
- X {
- X XCopyArea(dpy, pm.pm, win, wingc, x, y, width2, height1, x, y);
- X }
- X else
- X {
- X XCopyArea(dpy, pm.pm, win, wingc,
- X x, y+height1-fontheight+1, width2, fontheight,
- X x, y+height1-fontheight+1);
- X x = FSET(v, scrollback);
- X XCopyArea(dpy, v->pm->pm, win, wingc,
- X x-v->pm->offset, 0, width2, height1-fontheight+1,
- X v->xpos * width1, v->ypos * height1);
- X }
- X }
- X if(real_win_y - win_y)
- X XCopyArea(dpy, pm.pm, win, wingc, 0,win_y,win_x,real_win_y-win_y,0,win_y);
- X for(i = 1; i < columns; i++)
- X {
- X x = (width1 * (i-1)) + width2 + 1;
- X XDrawLine(dpy, win, bwingc, x, 0, x, win_y);
- X }
- X XFlush(dpy);
- X}
- X
- Xstatic int
- Xcheckbox()
- X{
- X int i, v, oldval = 0, from, to, vl;
- X struct values *p;
- X
- X v = xv_get(pi_check, PANEL_VALUE);
- X if(active)
- X {
- X oldval |= active->draw_line ? 0 : 1;
- X oldval |= active->no_smooth ? 0 : 2;
- X oldval |= active->draw_one ? 4 : 0;
- X oldval |= active->no_reset ? 0 : 8;
- X oldval |= active->add_values?16 : 0;
- X
- X active->draw_line = (v & 1) ? 0 : 1;
- X active->no_smooth = (v & 2) ? 0 : 1;
- X active->draw_one = (v & 4) ? 1 : 0;
- X active->add_values= (v &16) ? 1 : 0;
- X if((v&8) && active->no_reset)
- X {
- X vl = VALUES_LENGTH(active);
- X from = (active->validx + 1 - width2 + vl) % vl;
- X to = active->validx-1;
- X rescale(active, from, to);
- X }
- X active->no_reset = (v & 8) ? 0 : 1;
- X
- X if(!active->draw_line && depth == 1)
- X active->draw_one = 1;
- X return (v != oldval);
- X }
- X else
- X {
- X oldval |= draw_line ? 0 : 1;
- X oldval |= no_smooth ? 0 : 2;
- X oldval |= draw_one ? 4 : 0;
- X oldval |= no_reset ? 0 : 8;
- X oldval |= add_values?16 : 0;
- X
- X draw_line = !(v & 1);
- X no_smooth = !(v & 2);
- X draw_one = (v & 4);
- X add_values= (v & 16);
- X if((v&8) && no_reset)
- X {
- X for(i = 0; values[i].numvalues; i++)
- X {
- X p = &values[i];
- X if(p->special)
- X continue;
- X vl = VALUES_LENGTH(p);
- X from = (p->validx + 1 - width2 + vl) % vl;
- X to = p->validx-1;
- X rescale(p, from, to);
- X }
- X }
- X no_reset = !(v & 8);
- X
- X if(!draw_line && depth == 1)
- X draw_one = 1;
- X return (v != oldval);
- X }
- X}
- X
- Xstatic int
- Xselection(pi, v, e)
- X Panel_item pi;
- X int v;
- X Event *e;
- X{
- X int i, j, max;
- X int oldnr, changed = 0;
- X
- X if(!v)
- X {
- X v = 1;
- X xv_set(pi, PANEL_VALUE, v, NULL);
- X }
- X
- X oldnr = nrcurr_active;
- X for(i = 0; values[i].numvalues; i++)
- X {
- X if(values[i].active && !(v & (1<<i)))
- X {
- X for(j = 0; values[j].numvalues; j++)
- X if(values[j].active > values[i].active)
- X values[j].active--;
- X values[i].active = 0;
- X nrcurr_active--;
- X changed++;
- X }
- X else if(!values[i].active && (v & (1<<i)))
- X {
- X for(max = j = 0; values[j].numvalues; j++)
- X if(values[j].active > max)
- X max = values[j].active;
- X values[i].active = max+1;
- X nrcurr_active++;
- X changed++;
- X }
- X }
- X if(oldnr != nrcurr_active)
- X {
- X int diff, newheight;
- X
- X /* just_started = 1; */
- X if(nrcurr_active < columns)
- X columns = nrcurr_active;
- X
- X if(xv_get(pi_cols, PANEL_VALUE) != columns)
- X return changed;
- X
- X newheight = height1*((nrcurr_active+columns-1)/columns)+real_win_y-win_y;
- X diff = xv_get(fr, XV_HEIGHT) - xv_get(canvas_paint_window(ca), XV_HEIGHT);
- X xv_set(canvas_paint_window(ca), XV_HEIGHT, newheight+1, NULL);
- X xv_set(fr, XV_HEIGHT, newheight+1+diff, NULL);
- X if(nrcurr_active < columns)
- X {
- X diff = xv_get(fr,XV_WIDTH) - xv_get(canvas_paint_window(ca),XV_WIDTH);
- X xv_set(canvas_paint_window(ca),XV_WIDTH,width1*columns, NULL);
- X xv_set(fr, XV_WIDTH, width1*columns+diff, NULL);
- X }
- X }
- X
- X return changed;
- X}
- X
- Xstatic void
- Xspp()
- X{
- X int i, min, v = xv_get(pi_spp, PANEL_VALUE);
- X
- X if(active)
- X {
- X active->sec_perpixel = v;
- X active->lastsec = 0;
- X }
- X else
- X {
- X sec_perpixel = v;
- X lastsec = 0;
- X }
- X
- X/* Ahem.. correct gcd would be better... */
- X min = sec_perpixel;
- X for(i = 0; values[i].numvalues; i++)
- X if(values[i].special && min != values[i].sec_perpixel)
- X {
- X if(min % values[i].sec_perpixel == 0)
- X min = values[i].sec_perpixel;
- X else if(values[i].sec_perpixel % min != 0)
- X min = 1;
- X }
- X
- X if(min != min_spp)
- X {
- X min_spp = min;
- X do_alarm(min_spp);
- X }
- X}
- X
- Xstatic int
- Xmachine()
- X{
- X char *s = (char *)xv_get(pi_mach, PANEL_VALUE);
- X int i, j;
- X extern void bzero();
- X struct values *v;
- X
- X if(!s || !*s)
- X s = "localhost";
- X if(!strcmp(s, host))
- X return 0;
- X free(host);
- X for(i = 0; values[i].numvalues; i++)
- X {
- X v = &values[i];
- X for(j = 0; j < v->numvalues; j++)
- X bzero(v->values[j], sizeof(int) * VALUES_LENGTH(v));
- X rescale(v, 0, VALUES_LENGTH(v)-1);
- X }
- X host = strdup(s);
- X just_started = 1;
- X
- X return 1;
- X}
- X
- Xstatic void
- Xset_columns()
- X{
- X int i;
- X
- X for(i = 0; values[i].numvalues; i++)
- X if(values[i].active)
- X {
- X values[i].xpos = (values[i].active-1) % columns;
- X values[i].ypos = (values[i].active-1) / columns;
- X }
- X}
- X
- Xstatic int
- Xdocolumns()
- X{
- X int i, newheight, newwidth, diffw, diffh;
- X if((i = xv_get(pi_cols, PANEL_VALUE)) == columns)
- X return 0;
- X columns = i > nrcurr_active ? nrcurr_active : i;
- X
- X newwidth = width1 * columns;
- X newheight = height1 * ((nrcurr_active+columns-1)/columns) + real_win_y-win_y;
- X diffh = xv_get(fr, XV_HEIGHT) - xv_get(canvas_paint_window(ca), XV_HEIGHT);
- X diffw = xv_get(fr, XV_WIDTH) - xv_get(canvas_paint_window(ca), XV_WIDTH);
- X
- X xv_set(canvas_paint_window(ca),
- X XV_HEIGHT, newheight + 1, XV_WIDTH, newwidth, NULL);
- X xv_set(fr, XV_HEIGHT, newheight+diffh+1, XV_WIDTH, newwidth+diffw, NULL);
- X return 1;
- X}
- X
- Xstatic void
- Xdoscrollback()
- X{
- X int i, oldlen = 0, v = xv_get(pi_scbk, PANEL_VALUE);
- X struct values *val;
- X
- X if(active)
- X {
- X oldlen = VALUES_LENGTH(active);
- X active->special = 1;
- X active->scrollback = v;
- X realloc_values(active, oldlen, VALUES_LENGTH(active));
- X }
- X else
- X {
- X for(i = 0; values[i].numvalues; i++)
- X {
- X val = &values[i];
- X if(!(val->special))
- X {
- X oldlen = VALUES_LENGTH(val);
- X break;
- X }
- X }
- X scrollback = v;
- X for(i = 0; values[i].numvalues; i++)
- X {
- X val = &values[i];
- X if(!(val->special))
- X realloc_values(val, oldlen, VALUES_LENGTH(val));
- X }
- X }
- X}
- X
- Xstatic int
- Xapply(i, e)
- X Panel_item i;
- X Event *e;
- X{
- X int redraw = 0;
- X
- X if(!active)
- X {
- X redraw += selection(pi_sels, xv_get(pi_sels, PANEL_VALUE), e);
- X redraw += docolumns();
- X redraw += machine();
- X set_columns();
- X }
- X doscrollback();
- X spp();
- X redraw += checkbox();
- X
- X if(redraw)
- X dopaint(1);
- X return XV_OK;
- X}
- X
- Xstatic int
- Xhide(i, e)
- X Panel_item i;
- X Event *e;
- X{
- X xv_set(pfr, XV_SHOW, FALSE, NULL);
- X return XV_OK;
- X}
- X
- Xstatic int
- Xnosp_proc()
- X{
- X int i;
- X
- X if(active)
- X active->special = 0;
- X else
- X {
- X for(i = 0; values[i].numvalues; i++)
- X values[i].special = 0;
- X }
- X dopaint(1);
- X return XV_OK;
- X}
- X
- Xstatic int
- Xdofork()
- X{
- X switch(fork())
- X {
- X case -1:
- X perror("fork");
- X return XV_OK;
- X case 0:
- X/* Not very nice, but xview isn't reentrant */
- X execvp(argv[0], argv);
- X perror(argv[0]);
- X return XV_OK;
- X default:
- X return XV_OK;
- X }
- X}
- X
- Xstatic void
- Xcreate_pfr()
- X{
- X int i, v, y;
- X
- X
- X pfr = xv_create(fr, FRAME_CMD, FRAME_LABEL, PROGNAME, NULL);
- X pn = xv_get(pfr, FRAME_CMD_PANEL);
- X xv_set(pn, WIN_ROW_GAP, xv_get(pn, WIN_ROW_GAP)/3, NULL);
- X
- X for(v = i = 0; values[i].numvalues; i++)
- X if(values[i].active)
- X v |= (1 << i);
- X pi_sels = xv_create(pn, PANEL_TOGGLE,
- X XV_X, xv_col(pn, 1),
- X XV_Y, xv_row(pn, 0),
- X PANEL_CHOICE_STRINGS,
- X values[0].name, values[1].name, values[2].name, values[3].name,
- X values[4].name, values[5].name, values[6].name, values[7].name,
- X values[8].name, values[9].name, NULL,
- X PANEL_CHOICE_NCOLS, 5,
- X PANEL_VALUE, v,
- X NULL);
- X
- X
- X y = xv_get(pi_sels, XV_Y) + xv_get(pi_sels, XV_HEIGHT) + xv_row(pn, 1);
- X
- X pi_check = xv_create(pn, PANEL_CHECK_BOX,
- X XV_Y, y,
- X PANEL_LAYOUT, PANEL_VERTICAL,
- X PANEL_CHOICE_STRINGS,
- X "Solid graph (s)", "Smooth if solid (o)", "Show sum only (1)",
- X "Autoreset", "Add values (a)", NULL,
- X NULL);
- X xv_set(pi_check,
- X XV_X, xv_get(pi_sels, XV_X) + xv_get(pi_sels, XV_WIDTH) -
- X xv_get(pi_check, XV_WIDTH),
- X NULL);
- X
- X pi_mach = xv_create(pn, PANEL_TEXT,
- X XV_Y, y, XV_X, xv_get(pi_sels, XV_X),
- X PANEL_LABEL_STRING, "Machine:",
- X PANEL_VALUE, host,
- X PANEL_VALUE_DISPLAY_LENGTH, 16,
- X NULL);
- X
- X pi_spp = xv_create(pn, PANEL_NUMERIC_TEXT,
- X XV_Y, xv_get(pi_mach, XV_Y) + xv_get(pi_mach, XV_HEIGHT) + xv_row(pn, 1)/2,
- X XV_X, xv_get(pi_sels, XV_X),
- X PANEL_LABEL_STRING, "Sample time (sec):",
- X PANEL_VALUE, sec_perpixel,
- X PANEL_MIN_VALUE, 1,
- X PANEL_VALUE_DISPLAY_LENGTH, 4,
- X NULL);
- X
- X pi_scbk = xv_create(pn, PANEL_NUMERIC_TEXT,
- X XV_Y, xv_get(pi_spp, XV_Y) + xv_get(pi_spp, XV_HEIGHT) + xv_row(pn, 1)/2,
- X XV_X, xv_get(pi_sels, XV_X),
- X PANEL_LABEL_STRING, "Scrollback (values):",
- X PANEL_MIN_VALUE, 0,
- X PANEL_MAX_VALUE, 20000,
- X PANEL_VALUE, scrollback,
- X PANEL_VALUE_DISPLAY_LENGTH, 5,
- X NULL);
- X
- X pi_cols = xv_create(pn, PANEL_NUMERIC_TEXT,
- X XV_Y, xv_get(pi_scbk, XV_Y) + xv_get(pi_scbk, XV_HEIGHT) + xv_row(pn, 1)/2,
- X XV_X, xv_get(pi_sels, XV_X),
- X PANEL_LABEL_STRING, "Columns:",
- X PANEL_INACTIVE, TRUE,
- X PANEL_MAX_VALUE, 10, PANEL_MIN_VALUE, 1,
- X PANEL_VALUE, columns,
- X PANEL_VALUE_DISPLAY_LENGTH, 2,
- X NULL);
- X
- X pi_nosp = xv_create(pn, PANEL_BUTTON,
- X XV_Y, xv_get(pi_cols, XV_Y) + xv_get(pi_cols, XV_HEIGHT) + xv_row(pn, 1)/2,
- X XV_X, xv_get(pi_sels, XV_X),
- X PANEL_LABEL_STRING, "No special flags",
- X PANEL_NOTIFY_PROC, nosp_proc,
- X NULL);
- X pi_fork = xv_create(pn, PANEL_BUTTON,
- X XV_Y, xv_get(pi_nosp, XV_Y),
- X XV_X, xv_get(pi_nosp, XV_X) + xv_get(pi_nosp, XV_WIDTH) + xv_col(pn, 1),
- X PANEL_LABEL_STRING, "Fork",
- X PANEL_NOTIFY_PROC, dofork,
- X NULL);
- X pi_msg = xv_create(pn, PANEL_MESSAGE,
- X XV_Y, xv_get(pi_nosp, XV_Y) + xv_get(pi_nosp, XV_HEIGHT) + xv_row(pn, 1)/3,
- X XV_X, xv_get(pi_sels, XV_X),
- X NULL);
- X
- X window_fit_width(pn);
- X pi_apply = xv_create(pn, PANEL_BUTTON,
- X XV_Y, xv_get(pi_fork, XV_Y) + xv_get(pi_fork, XV_HEIGHT) + xv_row(pn, 1),
- X PANEL_LABEL_STRING, "Apply",
- X PANEL_NOTIFY_PROC, apply,
- X NULL);
- X xv_set(pi_apply,
- X XV_X, xv_get(pn, XV_WIDTH)/3 - xv_get(pi_apply, XV_WIDTH)/2,
- X NULL);
- X
- X pi_hide = xv_create(pn, PANEL_BUTTON,
- X XV_Y, xv_get(pi_apply, XV_Y),
- X PANEL_LABEL_STRING, "Hide window",
- X PANEL_NOTIFY_PROC, hide,
- X NULL);
- X xv_set(pi_hide,
- X XV_X, 2*xv_get(pn, XV_WIDTH)/3 - xv_get(pi_hide, XV_WIDTH)/2,
- X NULL);
- X
- X window_fit(pn);
- X window_fit(pfr);
- X}
- X
- Xstatic void
- Xgrayout(val)
- X struct values *val;
- X{
- X int v = val ? 1 : 0;
- X char buf[256];
- X
- X xv_set(pi_sels, PANEL_INACTIVE, v, NULL);
- X xv_set(pi_mach, PANEL_INACTIVE, v, NULL);
- X xv_set(pi_cols, PANEL_INACTIVE, v, NULL);
- X xv_set(pi_fork, PANEL_INACTIVE, v, NULL);
- X if(strcmp(host, "localhost"))
- X sprintf(buf, "%s (%s)", val ? active->name : PROGNAME, host);
- X else
- X sprintf(buf, "%s", val ? active->name : PROGNAME);
- X xv_set(pfr, FRAME_LABEL, buf, NULL);
- X
- X v = 0;
- X if(val && val->special)
- X {
- X if(!val->draw_line) v |= 1; if(!val->no_smooth) v |= 2;
- X if(val->draw_one) v |= 4; if(!val->no_reset) v |= 8;
- X if(val->add_values) v |= 16;
- X }
- X else
- X {
- X if(!draw_line) v |= 1; if(!no_smooth) v |= 2;
- X if(draw_one) v |= 4; if(!no_reset) v |= 8;
- X if(add_values) v |= 16;
- X }
- X xv_set(pi_check, PANEL_VALUE, v, NULL);
- X xv_set(pi_spp,
- X PANEL_VALUE, (val && val->special) ? val->sec_perpixel : sec_perpixel,
- X NULL);
- X xv_set(pi_scbk,
- X PANEL_VALUE, (val && val->special) ? val->scrollback : scrollback,
- X NULL);
- X xv_set(pi_msg, PANEL_LABEL_STRING, "", NULL);
- X}
- X
- Xstatic struct values *
- Xpostoval(e)
- X Event *e;
- X{
- X int i, j = event_y(e)/height1, k = event_x(e)/width1;
- X
- X for(i = 0; values[i].numvalues; i++)
- X if(values[i].active && values[i].xpos == k && values[i].ypos == j)
- X break;
- X if(!values[i].numvalues)
- X return 0;
- X return &values[i];
- X}
- X
- Xstatic void
- Xreset_scrolled(ifzero)
- X int ifzero;
- X{
- X int i, xx, yy;
- X struct values *v;
- X
- X for(i = 0; values[i].numvalues; i++)
- X if(values[i].pm)
- X {
- X if(!(ifzero && values[i].pm->offset))
- X {
- X v = &values[i];
- X
- X xx = v->xpos * width1; yy = v->ypos * height1;
- X
- X XFillRectangle(dpy, pm.pm, pm.colorgc[WHITE],
- X xx + v->pm->posx, yy + height1 - fontheight + 1,
- X v->pm->width, fontheight);
- X DrawText(v, 0);
- X
- X XCopyArea(dpy, pm.pm, win, wingc,
- X xx + v->pm->posx, yy + height1 - fontheight + 2,
- X v->pm->width,fontheight,
- X xx + v->pm->posx, yy + height1 - fontheight + 2);
- X
- X v->selected = 0;
- X FreePM(v->pm);
- X free(v->pm);
- X v->pm = 0;
- X }
- X }
- X else if(values[i].selected)
- X values[i].selected = 0;
- X}
- X
- Xstatic void
- Xevent_proc(w, e)
- X Xv_window w;
- X Event *e;
- X{
- X static int lastx, dragged;
- X struct values *v;
- X int i, x, y;
- X
- X if(event_is_ascii(e))
- X {
- X if(event_is_up(e))
- X return;
- X switch(event_action(e))
- X {
- X case 'q': case 'Q':
- X exit(0);
- X break;
- X case 's': case 'S':
- X draw_line = !draw_line;
- X if(!draw_line && depth == 1)
- X draw_one = 1;
- X dopaint(1);
- X break;
- X case 'o': case 'O':
- X no_smooth = !no_smooth;
- X dopaint(1);
- X break;
- X case 'a':
- X add_values = !add_values;
- X dopaint(1);
- X break;
- X case '1':
- X draw_one = !draw_one;
- X if(!draw_line && depth == 1)
- X draw_one = 1;
- X dopaint(1);
- X break;
- X case '?': case 'h':
- X if(!pfr)
- X create_pfr();
- X xv_set(pfr, XV_SHOW, TRUE, NULL);
- X break;
- X case 10: /* CR/NL */
- X case 13:
- X reset_scrolled(0);
- X dopaint(1);
- X return;
- X }
- X return;
- X }
- X switch(event_action(e))
- X {
- X case WIN_RESIZE:
- X lost_connection = 0;
- X x = e->ie_xevent->xconfigure.width;
- X y = e->ie_xevent->xconfigure.height;
- X if(x <= win_x && y <= real_win_y)
- X {
- X reset_scrolled(0);
- X dopaint(0);
- X }
- X break;
- X case WIN_REPAINT:
- X x = xv_get(canvas_paint_window(ca), XV_WIDTH);
- X y = xv_get(canvas_paint_window(ca), XV_HEIGHT) -1;
- X if(x != win_x || y != real_win_y)
- X reset_scrolled(0);
- X dopaint(0);
- X break;
- X case LOC_DRAG:
- X if(!dragged)
- X return;
- X dragged = 2;
- X for(i = 0; values[i].numvalues; i++)
- X if(values[i].selected)
- X {
- X int k, off;
- X
- X v = &values[i];
- X
- X if(!v->pm)
- X {
- X int mx, my, vl, j, k;
- X
- X vl = VALUES_LENGTH(v);
- X if(!v->pm)
- X v->pm = (struct pm *)calloc(1, sizeof(pm));
- X CreatePM(v->pm, vl, height1-fontheight+2);
- X v->pm->width = v->pm->offset = 0;
- X v->pm->starttime = time(0);
- X v->pm->startvalidx = v->validx;
- X mx = v->xpos; my = v->ypos;
- X v->xpos = v->ypos = 0;
- X
- X k = (v->validx + 1) % vl;
- X for(j = 1; j < vl; k %= vl)
- X DrawPixels(v, v->pm, k++, j++);
- X v->xpos = mx; v->ypos = my;
- X }
- X
- X off = v->pm->offset + event_x(e) - lastx;
- X k = v->special ? v->scrollback : scrollback;
- X if(off < 0) off = 0;
- X if(off > k) off = k;
- X if(off != v->pm->offset)
- X {
- X int xx = v->xpos * width1,
- X yy = v->ypos * height1;
- X
- X v->pm->offset = off;
- X DrawText(v, v->pm->starttime -
- X (off * FSET(v, sec_perpixel)));
- X XCopyArea(dpy, v->pm->pm, win, wingc,
- X k - off, 0, width2, height1-fontheight+2, xx, yy);
- X XCopyArea(dpy, pm.pm, win, wingc,
- X xx + v->pm->posx, yy + height1 - fontheight+2,
- X v->pm->width,fontheight,
- X xx + v->pm->posx, yy + height1 - fontheight+2);
- X }
- X }
- X lastx = event_x(e);
- X break;
- X case ACTION_ADJUST:
- X case MS_MIDDLE:
- X if(event_is_up(e) || !(v = postoval(e)))
- X return;
- X v->selected = 1;
- X break;
- X case ACTION_SELECT:
- X case MS_LEFT:
- X if(event_is_down(e))
- X {
- X lastx = event_x(e);
- X dragged = 1;
- X if(!(v = postoval(e)))
- X return;
- X if(!v->selected)
- X {
- X for(i = 0; values[i].numvalues; i++)
- X values[i].selected = 0;
- X v->selected = 1;
- X }
- X }
- X else
- X {
- X char buf[128];
- X
- X if(dragged)
- X {
- X lastx = -1;
- X if(dragged == 2)
- X {
- X reset_scrolled(1);
- X dragged = 0;
- X return;
- X }
- X dragged = 0;
- X }
- X if(!(v = postoval(e)))
- X return;
- X y = VALUES_LENGTH(v);
- X x = v->pm ? v->pm->startvalidx - v->pm->offset : v->validx;
- X x -= ((width1 * v->xpos) + width2 - event_x(e));
- X x = (x + y) % y;
- X sprintf(buf, "%s: ", v->name);
- X if(v->type == LOAD)
- X {
- X sprintf(buf+strlen(buf), "%.2f",
- X (double)v->values[0][x]/256.0);
- X }
- X else
- X {
- X for(y = 0; y < v->numvalues; y++)
- X sprintf(buf+strlen(buf), "%s %d ",
- X v->subname[y]?v->subname[y] : "", v->values[y][x]);
- X }
- X if(pi_msg)
- X xv_set(pi_msg, PANEL_LABEL_STRING, buf, NULL);
- X }
- X break;
- X case ACTION_MENU:
- X case MS_RIGHT:
- X if(event_is_up(e))
- X return;
- X if(!pfr)
- X create_pfr();
- X if(event_shift_is_down(e))
- X {
- X active = postoval(e);
- X grayout(active);
- X }
- X else
- X {
- X if(xv_get(pfr, XV_SHOW))
- X {
- X xv_set(pfr, XV_SHOW, FALSE, NULL);
- X return;
- X }
- X active = NULL;
- X grayout(0);
- X }
- X xv_set(pfr, XV_SHOW, TRUE, NULL);
- X break;
- X }
- X
- X}
- X
- Xvoid
- Xgetdefault(name, value)
- X char *name;
- X int *value;
- X{
- X static char none[] = "NONE";
- X char *str, buffer[128];
- X
- X sprintf(buffer, "%s.%s", PROGNAME, name);
- X str = defaults_get_string(buffer, buffer, none);
- X if(!strcmp(str, none))
- X return;
- X if(!strcmp(str, "True") || !strcmp(str, "true") ||
- X !strcmp(str, "Yes") || !strcmp(str, "yes"))
- X {
- X *value = 1;
- X return;
- X }
- X if(*str == '#')
- X *value = strtol(str+1, NULL, 16);
- X else
- X *value = strtol(str, NULL, 0);
- X}
- X
- Xvoid
- Xmain(ac, av)
- X int ac;
- X char *av[];
- X{
- X XColor col;
- X XGCValues gcv;
- X int i, rows, len;
- X
- X argv = (char **)calloc(ac+1, sizeof(char *));
- X for(i = 0; i < ac; i++)
- X argv[i] = strdup(av[i]);
- X xv_init(XV_INIT_ARGC_PTR_ARGV, &ac, av, NULL);
- X
- X/* X - Resources */
- X for(i = 0; opts[i].name; i++)
- X getdefault(opts[i].name, opts[i].param);
- X
- X/* Argument parsing... */
- X for(av++; ac > 1; ac--, av++)
- X {
- X if(*av[0] != '-')
- X {
- X host = strdup(av[0]);
- X continue;
- X }
- X for(i = 0; opts[i].name; i++)
- X if(!strcmp(av[0]+1, opts[i].name))
- X {
- X if(opts[i].needsarg)
- X {
- X if(!av[1] || !*av[1])
- X {
- X fprintf(stderr, "%s: Option %s needs an argument\n",
- X PROGNAME, av[0]);
- X exit(-1);
- X }
- X if(*av[1] == '#')
- X *opts[i].param = strtol(av[1]+1, NULL, 16);
- X else
- X *opts[i].param = strtol(av[1], NULL, 0);
- X av++; ac--;
- X }
- X else
- X *opts[i].param = 1;
- X goto next;
- X }
- X if(!strcmp(av[0]+1, "a"))
- X {
- X for(i = 0; values[i].numvalues; i++)
- X if(!values[i].active)
- X values[i].active = ++nrcurr_active;
- X goto next;
- X }
- X for(i = 0; values[i].numvalues; i++)
- X if(!strcmp(av[0]+1, values[i].name))
- X {
- X if(!values[i].active)
- X values[i].active = ++nrcurr_active;
- X goto next;
- X }
- X
- X/* No valid option: print usage */
- Xusage:
- X fprintf(stderr, "Usage: %s [-a]\n\t", PROGNAME);
- X for(len = 8,i = 0; opts[i].name; i++)
- X {
- X fprintf(stderr, "[-%s%s] ",opts[i].name,opts[i].needsarg?" <arg>":"");
- X len += strlen(opts[i].name) + 4 + (opts[i].needsarg ? 6 : 0);
- X if(len > 60)
- X {
- X fprintf(stderr, "\n\t");
- X len = 8;
- X }
- X }
- X for(i = 0; values[i].numvalues; i++)
- X {
- X fprintf(stderr, "[-%s] ", values[i].name);
- X len += strlen(values[i].name) + 4;
- X if(len > 60)
- X {
- X fprintf(stderr, "\n\t");
- X len = 8;
- X }
- X }
- X fprintf(stderr,
- X "[host]\n\nKeyboard accelerators: a,q,s,o,1,?,NL\n");
- X exit(-1);
- Xnext:
- X continue;
- X }
- X
- X add_values = !noadd;
- X if(!host)
- X host = strdup("localhost");
- X if(!nrcurr_active)
- X {
- X nrcurr_active = 1;
- X values[0].active =1;
- X }
- X if(scrollback < 0) scrollback = 0;
- X if(sec_perpixel < 1) sec_perpixel = 1;
- X if(columns < 1) columns = 1;
- X if(columns > 10) columns = 10;
- X min_spp = sec_perpixel;
- X set_columns();
- X
- X rows = (nrcurr_active + columns - 1) / columns;
- X fr = xv_create(0, FRAME,
- X FRAME_LABEL, PROGNAME,
- X XV_WIDTH, (columns > 3 ? columns * 100 : columns * 200) + 3,
- X XV_HEIGHT, (rows > 3 ? rows * 60 : rows * 100) + 10,
- X FRAME_SHOW_FOOTER, FALSE,
- X FRAME_SHOW_RESIZE_CORNER, TRUE,
- X FRAME_SHOW_HEADER, FALSE,
- X NULL);
- X
- X do_alarm(min_spp);
- X
- X ca = xv_create(fr, CANVAS,
- X XV_X, 0, XV_Y, 0,
- X CANVAS_RETAINED, FALSE,
- X CANVAS_AUTO_CLEAR, FALSE,
- X CANVAS_AUTO_SHRINK, TRUE,
- X CANVAS_AUTO_EXPAND, TRUE,
- X NULL);
- X window_fit(fr);
- X xv_set(canvas_paint_window(ca),
- X WIN_EVENT_PROC, event_proc,
- X WIN_CONSUME_EVENTS,
- X WIN_ASCII_EVENTS, WIN_RESIZE, WIN_REPAINT,
- X WIN_MOUSE_BUTTONS, LOC_DRAG, NULL,
- X NULL);
- X
- X dpy = (Display *)xv_get(fr, XV_DISPLAY);
- X win = xv_get(canvas_paint_window(ca), XV_XID);
- X screen = xv_get(xv_get(fr, XV_SCREEN), SCREEN_NUMBER);
- X font = xv_get(fr, XV_FONT);
- X font_info =(XFontStruct *)xv_get(font, FONT_INFO);
- X#if 0
- X /* Returns -66+4 for the 5x7 :-( */
- X fontheight = xv_get(font, FONT_SIZE) + 4;
- X#else
- X {
- X int dm, as, ds;
- X XCharStruct ov;
- X
- X XTextExtents(font_info, "Cpgf", 4, &dm, &as, &ds, &ov);
- X fontheight = as+ds+4;
- X }
- X#endif
- X
- X/* ICON */
- X {
- X Pixmap pm;
- X Server_image sim;
- X Icon icon;
- X
- X pm = XCreatePixmapFromBitmapData(dpy, win,
- X icon_bits, icon_width, icon_height, 0, 1, 1);
- X sim = (Server_image)xv_create(0,
- X SERVER_IMAGE, SERVER_IMAGE_PIXMAP, pm, NULL);
- X icon = xv_create(fr, ICON, XV_WIDTH, icon_width, XV_HEIGHT, icon_height,
- X ICON_IMAGE, sim, ICON_MASK_IMAGE, sim, NULL);
- X xv_set(fr, FRAME_ICON, icon, NULL);
- X }
- X
- X defidx[0] = defidx[1] = defidx[2] = defidx[3] =
- X defidx[BLACK] = BlackPixel(dpy, screen);
- X defidx[WHITE] = WhitePixel(dpy, screen);
- X
- X if((depth = xv_get(fr, XV_DEPTH)) > 1)
- X {
- X col.flags = DoRed|DoGreen|DoBlue;
- X
- X for(i = 0; i < NUMCOLS; i++)
- X {
- X col.pixel = BlackPixel(dpy, screen);
- X col.red = (defcol[i] & 0xff0000) >> 8;
- X col.green = (defcol[i] & 0x00ff00);
- X col.blue = (defcol[i] & 0x0000ff) << 8;
- X XAllocColor(dpy, DefaultColormap(dpy, screen), &col);
- X defidx[i] = col.pixel;
- X }
- X }
- X gcv.foreground = defidx[WHITE];
- X wingc = XCreateGC(dpy, win, GCForeground,&gcv);
- X gcv.foreground = defidx[BLACK];
- X bwingc = XCreateGC(dpy, win, GCForeground,&gcv);
- X
- X if(!draw_line && depth == 1)
- X draw_one = 1;
- X
- X xv_main_loop(fr);
- X}
- END_OF_FILE
- if test 41015 -ne `wc -c <'perf/perf.c'`; then
- echo shar: \"'perf/perf.c'\" unpacked with wrong size!
- fi
- # end of 'perf/perf.c'
- fi
- if test -f 'perf/rstattest.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'perf/rstattest.c'\"
- else
- echo shar: Extracting \"'perf/rstattest.c'\" \(988 characters\)
- sed "s/^X//" >'perf/rstattest.c' <<'END_OF_FILE'
- X/* Copyright (c) 1993 by Rudolf Koenig */
- X#include <rpc/rpc.h>
- X#include <rpcsvc/rstat.h>
- X#include <stdio.h>
- X
- Xmain(ac, av)
- X int ac;
- X char *av[];
- X{
- X struct statstime sx;
- X
- X if(ac != 2)
- X exit(0);
- X for(;;)
- X {
- X if(rstat(av[1], &sx))
- X {
- X printf("No rstat...\n");
- X exit(0);
- X }
- X
- X printf("cp_time: %d %d %d %d\n",
- X sx.cp_time[0], sx.cp_time[1], sx.cp_time[2], sx.cp_time[3]);
- X printf("dk_xfer: %d %d %d %d\n",
- X sx.dk_xfer[0], sx.dk_xfer[1], sx.dk_xfer[2], sx.dk_xfer[3]);
- X printf("pgin: %u, pgout %u, pswpin %u pswpout %u, intr %u\n",
- X sx.v_pgpgin,sx.v_pgpgout,
- X sx.v_pswpin,sx.v_pswpout,
- X sx.v_intr);
- X printf("ipack: %d, opack %d, ierr %d oerr %d, collis %d\n",
- X sx.if_ipackets,sx.if_opackets,
- X sx.if_ierrors,sx.if_oerrors,
- X sx.if_collisions);
- X printf("avg: %g %g %g\n",
- X (double)sx.avenrun[0] / 256,
- X (double)sx.avenrun[1] / 256,
- X (double)sx.avenrun[2] / 256);
- X printf("context: %d\n", sx.v_swtch);
- X fflush(stdout);
- X sleep(1);
- X }
- X}
- END_OF_FILE
- if test 988 -ne `wc -c <'perf/rstattest.c'`; then
- echo shar: \"'perf/rstattest.c'\" unpacked with wrong size!
- fi
- # end of 'perf/rstattest.c'
- fi
- echo shar: End of shell archive.
- exit 0
-
- exit 0 # Just in case...
- --
- // chris@Sterling.COM | Send comp.sources.x submissions to:
- \X/ Amiga: The only way to fly! | sources-x@sterling.com
- "It's intuitively obvious to the most casual observer..."
- GCS d++(--) -p+ c++ !l u++ e+ m+(-) s++/++ n h--- f+ g+++ w+ t++ r+ y+
-