Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to allow Engineers create their Own Heap Dumps?

Status
Not open for further replies.

100mbs

MIS
Feb 14, 2002
142
US
I want the Engineers to be able to kick off a heap dump of a java application.

But right now the only person that can do it is the admin with the kill -3 PID#.

Is there a way that i can allow them to kick it off on their own?
 
i tried doing this in sudo but i only want them to run kill -3 and not all functions of kill like kill -9. Is this possible.

 
Best to write a root-owned script containing the commands you want to allow them to execute and give them access to that. Restricting the options in a sudo rule can be awkward...

Annihilannic.
 
you by chance have an example do you for a root-owned script to run kill -3 command?

 
Not tested much, but this one checks for process existence and numeric parameters.

Code:
#!/usr/bin/ksh

if [[ $# -lt 1 ]]
then
        print "usage: $0 <pids> ..."
        exit 1
fi

while [[ -n "$1" ]]
do
        if print $1 | egrep -qx '[0-9]+' && ps -p $1 > /dev/null
        then
                print kill -3 $1
        else
                print "invalid or non-existent process: $1"
                exit 2
        fi
        shift
done


Annihilannic.
 
Oh, and of course... remove the print before the kill once you're happy with it!

Annihilannic.
 
I agree. I would restrict them to sending only 3 to the processes in question, probably by grepping out the name or making sure the parent is correct.

BTW I believe there is an easier way to determine a process existence by sending a null kill (i forgot the signo) and
checking the return staus.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top