Bug 702690 - [RHQ 3.0.1][apache] The plugin doesn't reflect the true runtime configuration of apache server which forces monitoring to not be available in all cases
[RHQ 3.0.1][apache] The plugin doesn't reflect the true runtime configuration...
Product: RHQ Project
Classification: Other
Component: Documentation (Show other bugs)
All All
urgent Severity high (vote)
: ---
: ---
Assigned To: Deon Ballard
Mike Foley
Depends On: 694476 700461 700616
  Show dependency treegraph
Reported: 2011-05-06 11:28 EDT by Deon Ballard
Modified: 2012-06-28 14:14 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 700616
Last Closed: 2012-06-28 14:14:15 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Deon Ballard 2011-05-06 11:28:56 EDT
The apache plug-ins documentation needs to be updated if there is a 2.4.2 release.

+++ This bug was initially created as a clone of Bug #700616 +++

This is a tracking bug for the port of the fix for 694476 over to RHQ 3.0.x branch.

+++ This bug was initially created as a clone of Bug #694476 +++

Description of problem:
The apache plugin doesn't take into account the conditional aspects of the configuration.

For example a VirtualHost that is nested inside an IfModule or IfDefine directive isn't discovered even if it is actually "in effect".

Note that nesting definitions inside conditional directives is a common practice even if VirtualHosts are not that usual to be nested (but it's not a rare occurence to see such configuration).

This makes the inventory not reflect the true state of the runtime configuration of the apache server.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. edit httpd.conf and nest a virtual host definition inside an ifmodule that checks for a module that IS being loaded
2. start the apache server
3. discover it using RHQ
Actual results:
the nested vhost isn't discovered

Expected results:
the nested vhost should be discovered if it is in effect.

Additional info:

This obviously is not limited to just vhosts but any directives.

The problem with IfDefine is that the values it uses are passed to the apache executable as parameters. Are we able to read those with our process scan?

--- Additional comment from lkrejci@redhat.com on 2011-04-08 09:20:50 EDT ---

Note that if we successfully implemented this, we could get rid of the imperfect matching rules between what's in the configuration files and what SNMP provides.

SNMP reports the vhost hostnames according to the values specified in the ServerName directives. But in the following (legal and realistic) example, the SNMP reports the same hostname and port for 2 different vhosts, which makes our current matching techniques unusable:

<VirtualHost _default_:80>
    DocumentRoot /var/www/common
    ServerName public-hostname.com:80

    DocumentRoot /var/www/special
    ServerName public-hostname.com:80

The usecase for the above configuration is that the actual server is hidden behind a load-balancer / internet-facing server that relays the requests to our instance. Our instance is configured to report back the hostname of that 'front server'. But the front server has some rules out of our control to direct "special class" of requests to the "special" vhost, while all other will go to the common one.

Because we currently cannot assume that the vhosts discovered by the plugin are the same (because we leave out the conditionally defined ones) as the actual ones reported by SNMP (i.e. the runtime configuration), we cannot distinguish which of the 2 discovered vhosts corresponds to which in the SNMP report, because there are 2 records in the SNMP report with the same hostname and port.

If we successfully managed to parse out the actual runtime configuration, we could match the discovered vhosts and the SNMP records merely by their indices.

I think detecting the runtime configuration is doable if we watch out for several gotchas:

1) IfDefine can theoretically refer to -D variables hardcoded at compile time to the apache binary (but we should be able to detect those using the utilities we already have in the plugin code)

2) Names used in IfModule are potentially different to the ones in corresponding LoadModule directives but this is rare. We could solve this by having a map in the plugin configuration to cover for the exceptional cases which we wouldn't handle by default.

3) some modules are compiled in - the list of these can be retrieved by executing "httpd -l"

--- Additional comment from lkrejci@redhat.com on 2011-04-13 11:55:52 EDT ---

In the commit below I actually implemented 2 things at once. I updated the name of this bug to take that into account.

commit 24dd3ebadfca65618caad06ab45887a09d0f3972
Author: Lukas Krejci <lkrejci@redhat.com>
Date:   Wed Apr 13 17:50:24 2011 +0200

    BZ 694476 - We now correctly determine the runtime configuration of the apache server
    by taking into account the list of loaded modules and -D options passed to it on commandline.
    With this in place, it is possible to deterministically match the discovered vhost resources
    with the vhosts from the list returned by the SNMP plugin merely knowing the ordering in which
    the SNMP plugin returns the list.
    This commit contains both of the above fixes.

--- Additional comment from lkrejci@redhat.com on 2011-04-14 09:06:25 EDT ---

commit 5e6b9a0580eb8373a33e5054b184f4d91a674681
Author: Lukas Krejci <lkrejci@redhat.com>
Date:   Thu Apr 14 14:59:50 2011 +0200

    BZ 694476 - the user is now only expected to list the non-standard module mappings instead of all modules in the plugin config. This enables a clear and simple upgrade path from prev
    Also made the loaded module detection more robust.

--- Additional comment from lkrejci@redhat.com on 2011-04-20 09:53:10 EDT ---

commit c8f7388581b8d3c00c17ecf4732f77481c83a86e
Author: Lukas Krejci <lkrejci@redhat.com>
Date:   Wed Apr 20 15:01:33 2011 +0200

    BZ 694476 - Adding support for the IfVersion directive in detecting the runtime configuration.

--- Additional comment from lkrejci@redhat.com on 2011-04-28 14:27:50 EDT ---

This bug depends on bug 700461 because the apache plugin depends on up-to-date native process info being available so that it can determine the correct runtime configuration.

--- Additional comment from lkrejci@redhat.com on 2011-05-06 11:11:16 EDT ---

Fixed by the following commits in release-3.0.1 branch:


Apart from a number of internal changes to support extracting the runtime configuration of the apache instance, there are 4 user-facing changes:

1) Virtual hosts inside IfModule, IfDefine or IfVersion directives (or combination thereof) are discovered as long as they are active in the current runtime configuration of the apache instance

2) The "SNMP WWW Service Index" property in the connection settings of the virtual hosts was re-introduced (it used to exist in read-only form in RHQ 1.x but was removed in RHQ 3.0.(0|1)). It is now writeable by the user so that it is possible to assign correct values to the RHQ3-discovered resources without re-inventorying them.

3) The Apache server resource has a new operation called "Detect SNMP WWW Service Index values for Virtual Hosts". This outputs a mapping from virtual host resource key to a corresponding SNMP WWW Service Index value as discovered by the plugin. This is to aid the users in assigning those values to individual inventoried vhost resources (the plugin is only able to assign the value during the discovery, an already inventoried resource has to be edited manually).

4) Reading or updating the configuration of virtual hosts that contain additional If* directives is not supported (the previous version of the plugin would be oblivious about the configuration contained inside the conditional directives and could therefore break the configuration altogether).

The SNMP WWW Service Index value for virtual hosts is dependent on the position of the virtual host in the configuration files. Therefore whenever a new vhost is added to the configuration of the apache instance (either manually or using RHQ), the values for all vhosts should be checked if they are still correct. If the new vhost is added in such a place in the configuration files that it is inserted "in the middle of" the pre-existing vhosts in the runtime configuration, the SNMP WWW Service Index values will have to be manually updated for all vhosts that end up *before* that vhost (this might seem paradoxical, but is a consequence of the fact that apache internally stores the vhosts in the reverse order they are defined in (with exception of the "main server" vhost that is always first)).

The runtime configuration of an apache instance is a union of all configuration files filtered by conditional If* directives. The union is produced by replacing each "Include" directive by the contents of the files it specifies (if there is more than 1 file included using a single directive, the files are included in the alphabetical order).

Note that the connection property and operation is only present in the RHQ 3 codebase. RHQ4 (bug 694476) doesn't need these because the value of the SNMP WWW Service Index is determined and automatically updated internally at runtime and no user intervention is needed.
Comment 1 Deon Ballard 2011-12-04 23:32:32 EST
It looks like the autogenerated docs have been updated to bring in the changes from bug 700616.
Comment 2 Deon Ballard 2012-06-28 14:14:15 EDT
This is not in the 3.x apache documentation, since it is not related to RHQ4.

Note You need to log in before you can comment on or make changes to this bug.