Current version 1.0_01 stable
Maintain java process(es) in complex unix environment may be a nightmare for system administrators. Many tricks were used by me and my collegues to grep a java process we wish to terminate. Some of those commands (very simple) are:
Or much more complex if you know which parameters desired process should have
Or even write possible pid of the java process if you have access and wish to change startup scripts.
But none from above can give you a 100% gurantiee that you killing right process or even you 'ps' gave you correct result because command line was very very very long.
One of the possibility to solve problem above and to know exactly were your java process lives - is write a pid file of the process. So you don't need to worry about correct ps or bash child process.
Starting from java 1.5 command line supports external agents with very simple syntax like -agentlib:MyLib=my,very,favorite,params. And many java startup scripts supports additional java parameters via well known environment variables like JAVA_OPTS. So you need not to mangle original startup scripts and just pass additonal parameters to java using those variables.
This project is about to help system administrators and other java process maintainers know where the java process lives using very little agent library I've called PidAgent.
All that this agent doing is writing a pid into file specified in the command line. That's all.
You may download current release from here
$ tar -xzf pidagent-XXX.tar.gz && cd pidagent-XXX && ./configure && make && make install
NOTE: by default configure uses a /usr/local as installation folder, so if you don't have a write access to it the command above will probably fail. Pass a standard --prefix option to the configure script to use a writable folder.
$ ./configure --help will describe all possible options it supports
--with-java-home=[path] the location of the java you wish to compile pidagent against
--enable-debug enable little debug output
--enable-m32 force 32 bit compilation on 64 bit platform
$ java -agentlib:PidAgent=/var/pid/java.pid
And of course you need to make PidAgent shared object accessible for loading, for example via LD_LIBARARY_PATH if your system supports it
FC4,FC6,FC8 32 and 64 bit, FreeBSD 7.0 i386
Building process will also build a executable with very simple command line interface
[PIDAGENT_HOME]/bin/pidagent can give you an answers on two questions
Mike P. Mikhailov : mike at sibtel.ru
Any comments and/or suggestions are very welcome
Enjoy