You may have multiple regex's, each generating its own events. This avoids connecting for each regex, rather it is is read one time for all. You may optionally specify a subsitution string that behaves similar to 'sed' to customize the generated events.
If you supply a substitution string, rather than copying the original complete matching string, the
substitution string is used, replacing all occurances of the special charcters \[0-9]
with the associated substring matches. Note: \0 matches the whole expression, while
\1,\2 through \9 are substring matches 1, 2 through 9. For example, say you are
watching a web server, you might want a special message if you start getting
file not found responses. The regex is:
Regex's are POSIX 1003.2 "extended" form.
NOTE: If you are NOT measuring triptime, then the httphandler will check the Last-Modified: timestamp via a HEAD request before doing the GET and applying the regex matching. If the file has not been modified since the last handler, then noregex matching will be done.
Wire keywords (standard handler keywords documented in Wire )
Example:
set noconnect create event { name: "noconnect" priority: 1 }
set four-oh-four create event { name: "file not found" priority: 1 }
set oracle-error create event { name: "oracle error" priority: 1 }
create handler http {
url: http://webserver.mydomain.com
noconnect: $noconnect
match: $four-oh-four "" "HTTP/.* 404" "webserver home page is missing!"
match: $oracle-error "" "ORA-[0-9][0-9][0-9][0-9][0-9][0-9]" ""
timeout: 5
cycletime: 60
}
Events generated:
| Event Name | Type | Description |
|---|---|---|
| connect | AW_EVENT_TYPE_STRING | Was able to connect, send string of "url" |
| noconnect | AW_EVENT_TYPE_STRING | Was NOT able to connect, send string of "url" |
| service | AW_EVENT_TYPE_STRING | Found valid HTTP header, send string of "url" |
| noservice | AW_EVENT_TYPE_STRING | Did NOT find valid HTTP header, send string of "url" |
| match | AW_EVENT_TYPE_STRING | Regex match in line of HTTP header or body, send string of matching line or substitution |
| nomatch | AW_EVENT_TYPE_STRING | No regex match in any line of HTTP header or body, send string of "url" |
| triptime | AW_EVENT_TYPE_INT32 | Estimated round trip time in usec |
#include "regexmatch.h"
#include "sysnet.h"
#include "monitor.h"
#include "wire.h"
Go to the source code of this file.
Data Structures | |
| struct | aw_httphandler_cevents_t |
| Events generated for connect(). More... | |
| struct | aw_httphandler_mirror_t |
| Holds events_sig, filename, and fd for mirroring the file that we GET. More... | |
| struct | aw_httphandler_regex_t |
| Specifies a regex and associated events. More... | |
| struct | aw_httphandler_revents_t |
| Events generated for regex matching. More... | |
| struct | aw_httphandler_state_t |
| State of handler during probing. More... | |
| struct | aw_httphandler_t |
| Handler object. More... | |
| struct | aw_httphandler_watcher_t |
| Compiled regex, associated events and state. More... | |
Defines | |
| #define | AW_HTTPHANDLER_LASTMODIFIED_BUFFER_SIZE 64 |
| #define | AW_HTTPHANDLER_READ_BUFFER_SIZE 4096 |
Enumerations | |
| enum | aw_httphandler_state_cd_t { AW_HTTPHANDLER_IDLE, AW_HTTPHANDLER_WAIT_HEAD_CONNECT, AW_HTTPHANDLER_WAIT_HEAD_WRITE, AW_HTTPHANDLER_WAIT_HEAD_READ, AW_HTTPHANDLER_WAIT_GET_CONNECT, AW_HTTPHANDLER_WAIT_GET_WRITE, AW_HTTPHANDLER_WAIT_GET_READ, AW_HTTPHANDLER_DONE } |
| The state codes for each state on handler, nominal path is straight thru. More... | |
Functions | |
| aw_httphandler_t * | aw_create_httphandler (const byte_t *url, const aw_httphandler_cevents_t *cevents, const aw_timestamp_t timeout, u_int32_t nregexs, const aw_httphandler_regex_t *regexs, const byte_t *mirror_filename, const aw_event_sig_t *mirror_updated, int32_t(*regevent)(aw_handler_t *h, aw_address_t *eventid, u_int32_t index), int32_t(*regmaskevent)(aw_handler_t *h, aw_address_t *eventid, u_int32_t index), const aw_alarm_sched_t *sched, aw_logger_t *logger) |
| Create a http handler. | |
| void | aw_free_httphandler (aw_httphandler_t *p) |
| Free handler and all associated resources. | |
| aw_handler_t * | aw_wire_httphandler (aw_wire_mkhandler_args_t *args) |
| Create a http handler using "wire". See header doc for keyword documentation. | |
|
|
|
|
|
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
Create a http handler. aw_create_httphandler
|
|
|
Free handler and all associated resources. aw_free_httphandler
|
|
|
Create a http handler using "wire". See header doc for keyword documentation. aw_wire_httphandler |