- 1 Developing Event Handlers
- 2 Examples
- 3 Reference Information
Developing Event Handlers
You can put your own PHP scripts containing functions to be called when specific events occur within FreeNATS. Each event handler function takes a single data array parameter containing specific indexed values.
To create an event handler you simple create a PHP file containing one (or more functions), place it in the server/base/site/events directory (all .php files are included from this directory on startup as long as site.include.events is set to 1) and then register the event handler functions against various event types.
You may also like to see the developing with FreeNATS documentation for some globally available features and information.
Events and Data Types
All data arrays contain
event => the event id (i.e. alert_open)
An alert is opened
nodeid => the node id
An alert is closed
nodeid => the node id
The beginning of a node test sequence
nodeid => the node id in_schedule => (bool) schedule says to be tested, if false will not actually be tested
The end of a node test sequence
nodeid => the node id alertlevel => the "highest" alert level of all tests
The start of a localtest (server-side PHP test)
nodeid => the node id testid => the full (class included) test id testtype => the test type
The end of a localtest (server-side PHP test)
nodeid => the node id testid => the test id testtype => the test type alertlevel => the alert level of the test
Set alert level for a node
nodeid => the node id alertlevel => the new (current) alert level oldalertlevel => the previous alert level
Called when an alert action is flushed with data (for message queue alert actions only). Called when there is something in the message queue and the flush routine has been called.
Must return true to clear the message data - false to leave if you don't want to handle that message queue
aaid => alert action id name => alert action name data => alert action data (on different lines)
Nodeside data pull has been called
nodeid => node id success => (bool) was the pull successful
Nodeside data has been pushed
nodeid => node id
Nodeside processing has been called
nodeid => nodeid alertlevel => "highest alert level"