Develop:Events

From FreeNATS Wiki
Jump to: navigation, search

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.


Examples

System Log (syslog) Example and First Introduction

Console Text Echo Example


Reference Information

Events and Data Types

All data arrays contain

event => the event id (i.e. alert_open)

alert_open

An alert is opened

nodeid => the node id

alert_close

An alert is closed

nodeid => the node id

node_test_start

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

node_test_finish

The end of a node test sequence

nodeid => the node id
alertlevel => the "highest" alert level of all tests

localtest_start

The start of a localtest (server-side PHP test)

nodeid => the node id
testid => the full (class included) test id
testtype => the test type

localtest_finish

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_alerts

Set alert level for a node

nodeid => the node id
alertlevel => the new (current) alert level
oldalertlevel => the previous alert level

alert_action

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_pull

Nodeside data pull has been called

nodeid => node id
success => (bool) was the pull successful

nodeside_push

Nodeside data has been pushed

nodeid => node id

nodeside_process

Nodeside processing has been called

nodeid => nodeid
alertlevel => "highest alert level"