Apache HTTP Server Configuration Check

Microsoft.ApacheHTTPServer.ManagedServer.Unix.ConfigurationCheck.Monitor (UnitMonitor)

This monitor runs a script to check Apache configuration, and alerts if warnings or errors are found in the configuration.

Knowledge Base article:

Summary

There is a configuration problem with the Apache HTTP Server configuration files. The server may not start correctly if it is restarted. This monitor runs the httpd or apache2ctl program with the –t option to validate configuration. An error or warning state is set if the program finds a problem with the configuration.

Causes

The configuration (in httpd.conf or an include file) is incorrect. Review the alert message and context for details of the configuration problem.

Resolutions

Resolve the configuration problem that was reported.

Element properties:

TargetMicrosoft.ApacheHTTPServer.ManagedServer.Unix
Parent MonitorSystem.Health.ConfigurationState
CategoryConfigurationHealth
EnabledTrue
Alert GenerateTrue
Alert SeverityMatchMonitorHealth
Alert PriorityNormal
Alert Auto ResolveTrue
Monitor TypeMicrosoft.Oss.ShellScript.Status.ThreeState.MonitorType
RemotableTrue
AccessibilityPublic
Alert Message
Apache HTTP Server Configuration
The configuration for the Apache HTTP Server is not ok. See the alert context to review warnings or errors. Results: {0} {1}
RunAsDefault

Source Code:

<UnitMonitor ID="Microsoft.ApacheHTTPServer.ManagedServer.Unix.ConfigurationCheck.Monitor" Accessibility="Public" Target="Microsoft.ApacheHTTPServer.ManagedServer.Unix" TypeID="Oss!Microsoft.Oss.ShellScript.Status.ThreeState.MonitorType" ParentMonitorID="Health!System.Health.ConfigurationState" Enabled="onStandardMonitoring">
<Category>ConfigurationHealth</Category>
<AlertSettings AlertMessage="Microsoft.ApacheHTTPServer.ManagedServer.Unix.ConfigurationCheck.AlertMessage">
<AlertOnState>Warning</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>MatchMonitorHealth</AlertSeverity>
<AlertParameters>
<AlertParameter1>$Data/Context///*[local-name()="StdOut"]$</AlertParameter1>
<AlertParameter2>$Data/Context///*[local-name()="StdErr"]$</AlertParameter2>
</AlertParameters>
</AlertSettings>
<OperationalStates>
<OperationalState HealthState="Success" MonitorTypeStateID="StatusOK" ID="StatusOK"/>
<OperationalState HealthState="Warning" MonitorTypeStateID="StatusWarning" ID="StatusWarning"/>
<OperationalState HealthState="Error" MonitorTypeStateID="StatusError" ID="StatusError"/>
</OperationalStates>
<Configuration>
<Interval>14400</Interval>
<TargetSystem>$Target/Host/Property[Type="Unix!Microsoft.Unix.Computer"]/NetworkName$</TargetSystem>
<Script>
#!/bin/bash

if [ -x "/usr/sbin/apache2ctl" ]
then
result=`/usr/sbin/apache2ctl -t `
fi

if [ -x "/usr/sbin/httpd" ]
then
result=`/usr/sbin/httpd -t `
fi

if [ -x "/usr/local/apache2/bin/apachectl" ]
then
result=`/usr/local/apache2/bin/apachectl -t `
fi

printf "$result"
exit 0</Script>
<ScriptArgs/>
<Timeout>120</Timeout>
<UserName>$RunAs[Name="Unix!Microsoft.Unix.ActionAccount"]/UserName$</UserName>
<Password>$RunAs[Name="Unix!Microsoft.Unix.ActionAccount"]/Password$</Password>
<WarningStatus>[w|W]arn</WarningStatus>
<ErrorStatus>Syntax [E|e]rr</ErrorStatus>
</Configuration>
</UnitMonitor>