Is there another way to monitor a running Java process than to use PID with Monit?
1 Answers
You cannot use monit without PID file. If your process does not create a PID file you will have to create a wrapper to start the program and create PID file for monit. See here in official Monit FAQs.
Edit:
Monit has a way other than PID file which is process name. But for this process name should be unique. From the documentation:
CHECK PROCESS [unique name] PIDFILE [path] | MATCHING [regex]
[path] is the absolute path to the program's pid-file. A pid-file is a file, containing a Process's unique ID. If the pid-file does not exist or does not contain the PID number of a running process, Monit will call the entry's start method if defined.
[regex] is an alternative to using PID files and uses process name pattern matching to find the process to monitor. The first match is used so this form of check is most useful if the process name is unique. Pid-file should be used where possible as it defines expected pid exactly (pattern matching won't be useful for processes which start a child process using fork/clone as the child will match the same pattern temporarily). You can test if a process match a pattern from the command-line using monit procmatch "regex-pattern". This will lists all processes matching or not, the regex-pattern.

- 5,006
- 1
- 19
- 36