Red Hat Bugzilla – Bug 813845
name and baseName fields are not set correctly on ProcessInfo objects for processes running as a different user than the RHQ Agent
Last modified: 2015-02-01 18:27:52 EST
For example, I started an Apache server on Fedora as follows:
In the ProcessInfo that gets created for the corresponding process, the name field is set to "?", and the baseName field is set to "/use/sbin/httpd". This is incorrect - name should be "/usr/sbin/httpd", and baseName should be "httpd". The problem is the logic for initializing these fields is faulty.
The name logic is:
this.name = (procExe != null) ? procExe.getName() : UNKNOWN;
procExe is always null for processes running as different users, so instead we should be used procArgs as our first choice, since that is pretty much always set.
The basename logic is similar, except it tries to user procState.getName() as a fallback if procExe is null. It should also be using procArgs as its first choice, i.e.:
this.baseName = new File(procArgs).getName();
I forgot to mention the symptom of this bug that I encountered. When Apache httpd is running as root, and the RHQ Agent is running as another user, the Apache server is not discovered. The reason is that the ProcessInfo's baseName is incorrectly set to "/usr/sbin/httpd", and the process scan from the apache plugin's rhq-plugin.xml is:
<process-scan name="HttpdOnUnix" query="process|basename|match=httpd.*,process|basename|nomatch|parent=httpd.*"/>
Notice it's looking for a basename that matches the regex "httpd.*", and "/usr/sbin/httpd" will not match that.
Fixed in master:
Bulk closing of items that are on_qa and in old RHQ releases, which are out for a long time and where the issue has not been re-opened since.