Table of Contents
EBox framework has an event architecture which allows to develop new events and a transport way to do it easily. This event architecture is split in two components: watchers and dispatchers.
The event watchers are responsible for observing a determined event that may happen within eBox system. Some events might be the following: check eBox state or its services, services out of control, disk free space. It is also possible to add a security layer since you can track security attacks such as Denial of Service (DoS) among others.
In order to develop one, you must create a Perl package which is
a subclass from
EBox::Event::Watcher::Base
and its
namespace must be EBox::Event::Watcher
, for
example, to implement a disk free space watcher which informs if
any partition is running out of free space, it could be called
EBox::Event::Watcher::DiskFreeSpace
. This
will be its constructor:
Example 9.1.
EBox::Event::Watcher::DiskFreeSpace
constructor
sub new { my ($class) = @_; my $self = $class->SUPER::new( period => 600, domain => 'ebox', ); bless( $self, $class); return $self; }
The arguments meaning:
The following methods must be overridden in order to have a valid watcher:
run
It will check if the event we want to monitor. Here
it is where the logic lies. It should return
undef if no event has
happened or a list reference
of EBox::Event
if one or more
events have happened and they should be informed.
_name
The event watcher displayable name. Our example could return __('Disk Free Space'). This element along with the event description will be shown at the configuration table in order to be enabled.
_description
The event watcher displayable description. It should show a clarifying information about what the event watcher does. Our example could be __('Check if there is enough free space in any available partition').
Once you have developed and deployed it, you may enable it at
Configure
events editing enable
field at the chose event watcher. Then enable service if
needed and "Save changes" as usual to restart
ebox-events module to make it work.