SUMMARY:Wrapper for top ?

From: Shridhar Deuskar (deuskar@cat.com)
Date: Thu Apr 17 1997 - 16:54:45 CDT


SM's:

As usual this list proved itself once again ! I got a lot of responses. I liked
David Schiffrin's( daves@adnc.com )suggestion the best and I have included it
below:
-------------------------------------------------------------
Just replace top with a wrapper like this:

#!/bin/sh
/usr/local/bin/top -d200

This will run for 200 iterations (at 5 seconds) and then exit.

try man top for more info.

-dave
-------------------------------------------------------------

However how do I prevent user's from running the "real" top ?

Paul O'Donnel(pod@ms.com) suggested:
-------------------------------------------------------------
mv top top.real

Create a shell script called top, which does:

intr -t num_seconds top.real
-------------------------------------------------------------

Peter Allan had the following suggestion:
-------------------------------------------------------------
I wrote a wrapper for rup, to make it easier to run
from a script without me there to press ^C.
I enclose it below.

You may also want to stop users running the original version.
I have an xload wrapper where I put the sgid bit
on the wrapper, not on xload. (It prevents rshd
from keeping a user's home directory open - which
interferes with the umount in my backup script.)
I haven't got top, but I'd expect it to have a
s[ug]id bit.

#include <stdio.h>
#include <ctype.h>
#include <time.h>
#include <sys/wait.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>

int *statusp;
int pid,arg,state;
int options = NULL;

main(argc, argv,envp)
int argc;
char *argv[];
char *envp[];
{
        pid = fork();
        if (pid == 0) {
                execl("/usr/ucb/rup", "rup", (char) 0);
        }
        else {
               sleep(10);
                kill(pid,15);
        }
}
-- Peter Allan peter.allan@aeat.co.uk

---------------------------------------------------------------------------
Many people suggested disabling top. Also, is their any info. on how much
performance degradation takes place by constantly running "top" ?
I don't want to take such a drastic step though it might have to be done in
the future ! Thanks to the following for their suggestions:

Rahul Roy <roy@bluestone.COM>
Daniel Baker (dbaker@cuckoo.com)
Rich Kulawiec <rsk@itw.com>

Shridhar Deuskar

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Shridhar Deuskar | Caterpillar, Inc. | deuskar@cat.com
 System Manager | Engine Division MOS 7 | (309) 578 8262 Tel.
                    | Rt. 29 at Galena Rd. | (309) 578 7221 Fax
                    | Mossville, IL 61552-0610|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:11:51 CDT