Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Abiquo events catcher

This app enables you to execute commands when a new event of a concrete type is generated by Abiquo. This allows, for example, send an email when an user performs a login.

You can use the API to know the current event types https://wiki.abiquo.com/api/latest/EventsResource.html#list-events-types

Usage

Code Block
languagebash
 --api-endpoint (-ae) VAL     : Abiquo API URL to connect
 --api-password (-ap) VAL     : Abiquo API password
 --api-username (-au) VAL     : Abiquo API username
 --api-version (-av) VAL      : Override Abiquo version on API requests (default: current version)
 --database-file (-df) VAL    : Event-catcher Database file (default: ./catcherdb)
 --fetch-interval (-fi) N     : Fetch interval in minutes (default: 10)
 --first-fetch-delay (-ffd) N : Delay of first event fetch in minutes (default: 0)
 --first-fetch-range (-ffr) N : First fetch range in minutes (default: 60)
 --receivers-file (-rf) VAL   : Receivers INI file (default: ./receivers.ini)

How to configure catchers

It looks by default for receivers.ini in CWD. An example:

Code Block
[example-catch-1]
actions=TAGS_SYNC, LOGIN
command=echo.sh

[example-cath-2]
actions=LOGIN
command=sendemail.sh

Note that you can add as many catchers as you like.

Each command defined will executed by events-catcher with the following arguments:

Code Block
languagebash
> sh echo.sh "event_json" "entity_json"

Deployment

Create the working folder at /opt/abiquo/eventscatcher that contains:

  • The app eventscatcher.jar

  • The receivers config file receivers.ini

  • The bash scripts for the commands (like echo.sh, sendemail.sh or your own scripts)

Add a new service to systemd to run eventscatcher.

Let's create a new file called /etc/systemd/system/eventscatcher.service:

Code Block
    [Unit]
    Description=Abiquo eventscatcher systemd service
    After=network.target

    [Service]
    Type=simple
    User=tomcat
    WorkingDirectory=/opt/abiquo/eventscatcher
    ExecStart=/bin/java -jar /opt/abiquo/eventscatcher/eventscatcher.jar --api-endpoint {api.endpoint} --api-username {api.username} --api-password {api.password}

    [Install]
    WantedBy=multi-user.target

You will need:

  • Set the actual username after User= (make sure that the user has permissions on /opt/abiquo/eventscatcher)

  • Set the proper app args after --api-endpoint, --api-username and --api-password

  • Set the correct java binary after ExecStart

Just execute:

  • systemctl start eventscatcher.service to start the service

  • systemctl status eventscatcher.service to check the status

  • systemctl enable eventscatcher.service to start service on boot

Logging

There are two logs:

  • The app general log in CWD and named eventscatcher.log

  • The command executions log in CWD and name eventscatcher-executions.log