Das Modul basiert auf HttpUtils und stellt sämtliche Werte einer durch Apaches mod_status erzeugten Server-Status-Page als Readings zur Verfügung. Da die Anzahl an Readings leicht in die hunderte gehen kann, sind verschiedene Readings-Gruppen per Attribut zu aktivieren. Details dazu unten.
Getestet gegen Server Version: Apache/2.4.10 (Raspbian) PHP/5.6.29-0+deb8u1 OpenSSL/1.0.1t
Commandref:
ApacheStatus ApacheStatus queries a server-statuspage generated by Apaches mod_status (https://httpd.apache.org/docs/2.4/mod/mod_status.html) and generates various readings from it. The query is repeated in a given interval.
Prerequisites
- HTML::TreeBuilder::XPath needs to be installed. (debian: apt-get install libhtml-treebuilder-xpath-perl)
- mod_status needs to be enabled in Apache
- server-status-page must be accessible for fhem (/etc/apache2/mods-enabled/status.conf may restrict access)
Define define <name> ApacheStatus <URL> [<INTERVAL>] Example:
define APACHESTATUS ApacheStatus http://localhost/server-status 300 URL is the url of a server-statuspage generated by mod_status. User and password for HTTP basic authentication may be provided in standard notation: http://user:pass@host
INTERVAL is the refresh interval in seconds. Default: 300
Since
ApacheStatus is designed to create very differentiated readings from the info mod_status provides, it can easily make for hundreds of readings. To avoid that, you'll have to explicitly enable groups of readings by setting associated attributes. For details see below.
A newly created device has some attributes set to default values:
- autoReset: yes
- disabled: no
- event-on-change-reading: .*
- keepBuf: no
- keepOldReadings: no
- readingsChilds: no
- readingsChildColumnDesc: no
- readingsChildsRowFilter: !request:^OPTIONS !request:^NULL
- readingsChildsColumnFilter: req conn child client request
- readingsClients: no
- readingsScoreboard: no
- readingsServer: no
- readingsSSL: no
Caution: If your editing fhem.cfg to add a new device none of these attributes are set automatically
Set
- allreadings yes|no
Sets all readings-attributes to "yes" or "no" - disable
Disables automatic refresh (enabled by default) - enable
Enables automatic refresh - reset
Deletes all readings and rereads them - refresh
Immediately refreshes all readings
Attributes
- autoReset yes|no
Since most attributes do effect the creation of readings, the module automatically resets all readings when changing attributes. Set to "no" to disable this behaviour. May be usefull if you want to keep outdated readings (see keepOldReadings bellow). Default: yes - disabled yes|no
Disables automatic refresh. disabledForIntervals has higher precedence then disabled=no. Default: no - disabledForIntervals (http://fhem.de/commandref.html#disabledForIntervals)
- httpVersion #
HTTP-Version to send to the server. Inherited from HttpUtils. Default: 1.0 - keepBuf yes|no
Keep server-status-HTML in the internal value 'buf'? Default: no - keepOldReadings yes|no
Keep readings which aren't present in the last fetch of server-status? Caution: set DEVICE reset deletes all readings regardless of keepOldReadings. Default: no - localnetwork <regex>
Regular expression that matches all adresses in your local network. It is used to distinguish local clients from external clients when counting client requests. localhost-adresses (127.0.0.1, ::1) are always counted to the local network automatically
Example: 192.168.178 - readingsChildColumnDesc yes|no
The server-status page contains a description of all columns of the table with child-information (see below). If set to yes, these descriptions are transfered as readings. Default: no - readingsChilds yes|no
Create readings of the table with child-information ("Srv PID Acc.."). For each row and each colum a single reading is created. Caution: This can easily make for hundrets of readings, avoid usage without readingsChildsRowFilter/readingsChildsColumnFilter. Default: no - readingsChildsRowFilter <column:regex> <column:regex> ...
Only include rows of readings of child-information, when at least one condition inthe space separated list of colum:regex-pairs is met.
column is the title of a column of that table (e.g. "srv", "pid", "acc") and may be preceeded with an ! to negate the following regex.
regex is a regular expression describing the value of a cell
Example: request:^GET !client:^127.0.0.1$
creates readings only if the request-cell starts whith "GET" and the client-cell is not "127.0.0.1" - readingsChildsColumnsFilter <column> <column> ...
If the attribute is set, readings are included only for columns that are listed here. Otherwise all columns are included.
Example: client request
creates readings only for columns client and request - readingsClients yes|no
Create readings for the count of requests per client? Default: no - readingsSSL yes|no
Create readings from the SSL/TLS session cache status-table? This table is not always included in server-status. Default: no - readingsServer yes|no
Create readings from server information (top of status-page)? Default: no - readingsScoreboard yes|no
Create readings from the scoreboard? Default: no - timeout #
Timeout to wait for servers response. Inherited from HttpUtils. Default: 2 - readingFnAttributes (http://fhem.de/commandref.html#readingFnAttributes)
Values of STATE
- defined
device is defined - fetching
device is fetching it's URL - parsing
device is parsing HTML (response from fetching URL) - done
device is done parsing and waiting for the next run - disabled
device is disabled - error
an error occured
Das Modul kann dazu dienen für bestimmte HTTP-Requests in Fhem-Events auszulösen um zB auf externe Requests zu reagieren. Hauptsächlich sehe ich darin aber ein Analysetool: Ich suche grade die Ursache für öfter auftretende "Aussetzer" (mehrsekündiger Stillstand) in Fhem, bzw. FHEMWEB. Apache ist als Proxy für Requests an FHEMWEB vorgeschaltet. Ich benutze die Readings um die Anzahl Requests verschiedener lokaler Clients in Relation zu Load und Responsetime zu plotten. Bisher übrigens leider ohne Erkenntnisse über den Verursacher :-)