home *** CD-ROM | disk | FTP | other *** search
- From decwrl!shelby!rutgers!usc!samsung!uunet!allbery Tue Jan 30 09:20:20 PST 1990
- Article 1318 of comp.sources.misc:
- Path: decwrl!shelby!rutgers!usc!samsung!uunet!allbery
- From: gwollman@JHMAIL.HCF.JHU.EDU (GAWollman)
- Newsgroups: comp.sources.misc
- Subject: v10i048: readstats... simple process-statistics program
- Message-ID: <77901@uunet.UU.NET>
- Date: 28 Jan 90 18:33:43 GMT
- Sender: allbery@uunet.UU.NET
- Lines: 143
- Approved: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
-
- Posting-number: Volume 10, Issue 48
- Submitted-by: gwollman@JHMAIL.HCF.JHU.EDU (GAWollman)
- Archive-name: readstats.c
-
- Mr. Moderator, I don't know why I decided to send this program, but I
- am. It is a ridiculously simple program to read a set of statistics
- from the standard input, form an average, and print out the result.
- The Makefile is longer than the program.
- I let it speak for itself... there is also a readme file.
-
- -GAWollman
- "All societies are based on rules to protect pregnant women and children.
- . . . As racial survival is the only universal morality, no other bases
- is possible." - Lazarus Long [RAH, _TEFL_]
- ---------------Hopkins doesn't *want* my opinions------------------------
-
- ----------cut here------------
- #! /bin/sh
- # This is a shell archive, meaning:
- # 1. Remove everything above the #! /bin/sh line.
- # 2. Save the resulting text in a file.
- # 3. Execute the file with /bin/sh (not csh) to create:
- # readstats.c
- # Makefile
- # README
- # This archive created: Fri Jan 26 19:16:53 1990
- export PATH; PATH=/bin:/usr/bin:$PATH
- echo shar: "extracting 'readstats.c'" '(364 characters)'
- if test -f 'readstats.c'
- then
- echo shar: "will not over-write existing file 'readstats.c'"
- else
- sed 's/^X//' << \SHAR_EOF > 'readstats.c'
- X#include <stdio.h>
- X
- Xint main(argc,argv)
- Xint argc;
- Xchar **argv;
- X{
- X /* actually, we don't need the arguments yet */
- X int count_proc=0,count_rn=0;
- X int i;
- X
- X while(!feof(stdin)) {
- X scanf("%d",&i);
- X count_proc += i - 1;
- X scanf("%d",&i);
- X count_rn += i;
- X }
- X printf("%4.2f%% of all processes are RN\n",(double)count_rn * 100.0 /
- X (double)count_proc);
- X return 0;
- X}
- X
- SHAR_EOF
- if test 364 -ne "`wc -c < 'readstats.c'`"
- then
- echo shar: "error transmitting 'readstats.c'" '(should have been 364 cha
- fi
- fi
- echo shar: "extracting 'Makefile'" '(643 characters)'
- if test -f 'Makefile'
- then
- echo shar: "will not over-write existing file 'Makefile'"
- else
- sed 's/^X//' << \SHAR_EOF > 'Makefile'
- X#
- X# god, this is so disgustingly simple, I don't know why I
- X# bother with a makefile...
- X#
- X
- X# define this to the correct flag to use shared C libraries
- XSHLIBS= -lc_s
- X
- X# define this to be where you want the program installed, if at all
- XDESTDIR=/i/ins4/.gwollman/bin
- X
- Xall: readstats
- X
- Xclean:
- X rm -f core
- X rm -f a.out
- X#not that we generate any of these....
- X
- Xreadstats: readstats.c
- X cc -o readstats readstats.c $(SHLIBS)
- X
- X# what could be simpler than that...
- X
- Xinstall:
- X cp readstats $(DESTDIR)/readstats
- X chmod 555 $DESTDIR/readstats
- X# chown bin $DESTDIR/readstats
- X# chgrp bin $DESTDIR/readstats
- X
- X# ... the makefile is longer than the program... !
- SHAR_EOF
- if test 643 -ne "`wc -c < 'Makefile'`"
- then
- echo shar: "error transmitting 'Makefile'" '(should have been 643 charac
- fi
- fi
- echo shar: "extracting 'README'" '(849 characters)'
- if test -f 'README'
- then
- echo shar: "will not over-write existing file 'README'"
- else
- sed 's/^X//' << \SHAR_EOF > 'README'
- X...
- XReadstats is a program I created for a personal survey I am doing
- Xto find out how many people are using the RN newsreader at any one
- Xtime. It is a very simple program, which reads pairs of numbers from
- Xthe standard input and writes a percentage, total (second number) /
- Xtotal (first number), to the standard output:
- X
- X 9.42% of all processes are RN
- X
- Xwhich you would probably want to change, unless you *were* counting RNs
- Xon your system.
- X
- XTo make the count work, I have a line like this in all my .profiles:
- X
- X(ps -a | tee /tmp/rn.stats | wc -l ; grep "rn" /tmp/rn.stats | \
- X wc -l) >>rn.stats
- X
- XAs you can see, my count does not include system processes. This is
- Xbecause we have about fifteen getty's running at one time, not to mention
- Xother denizens of a 3B4000.
- X
- XEnjoy!
- X
- X-GAWollman
- X
- XCopyright 1990, Garrett A. Wollman. No rights reserved.
- X
- SHAR_EOF
- if test 849 -ne "`wc -c < 'README'`"
- then
- echo shar: "error transmitting 'README'" '(should have been 849 characte
- fi
- fi
- exit 0
- # End of shell archive
-
-
-