User Tools

Site Tools


api:taskscheduler

TaskScheduler

This features is available in version 0.6 or higher.

The TaskScheduler adds the availability to yourCMDB, to execute actions driven by events. At the moment, the following events exists in yourCMDB:

  • objectAdded
  • objectChanged
  • objectDeleted

You can also define your own custom events for specific object types using objecttype configuration.

The following actions are available at the moment:

class namedescription
TaskSchedulerActionExec executes an external script
TaskSchedulerActionExport executes an export task of the yourCMDB exportAPI

concept

setup

To setup TaskScheduler, use the possibility of your operating system, to execute the script <yourCMDB-Dir>/scripts/taskscheduler.php every minute.

For example you can use the following line for cron in /etc/crontab:

  • * * * * root /opt/yourcmdb/scripts/taskscheduler.php

The taskscheduler.php script will check, if there are jobs to execute and will execute them.

configuration

To configure TaskScheduler, use the taskscheduler-configuration.xml file in the <yourCMDB>/etc directory. Please see the following example:

<taskscheduler-configuration>
        <task trigger="event" event="objectAdded" objecttype="router" action="TaskSchedulerActionExec" actionParameter="/root/nodeAdded.sh ${objectId}" />
        <task trigger="event" event="objectAdded" objecttype="router" action="TaskSchedulerActionExec" actionParameter="/root/nodeAdded2.sh ${objectType}" />
        <task trigger="event" event="objectAdded" objecttype="router" action="TaskSchedulerActionExec" actionParameter="/root/nodeAdded3.sh" />
        <task trigger="event" event="objectAdded" objecttype="switch" action="TaskSchedulerActionExport" actionParameter="example" />
</taskscheduler-configuration>

A task is defined by using the <task> tag. Each task needs a trigger, action and actionParameter.

trigger

At the moment, only the trigger “event” is implemented. So a task can be triggered by a yourCMDB event. For the trigger event, the parameter event and objecttype must be set, where you define the event type and the object type given by the event.

action/actionParameter

The action will be executed by the TaskScheduler. You can give actionParameters to the action. The following actions are implemented at the moment:

action classdescriptionparameterparameter example
TaskSchedulerActionExecexecutes a script given in the parameterscript/binary to execute/root/nodeAdded.sh ${objectId}
TaskSchedulerActionExportexecutes a task of the yourCMDB exportAPItasknameexample

You can use the following variables in the actionParameter string

variabledescription
${objectId}will be replaced by the objectId defined in the trigger-event
${objectType}will be replaced by the object type defined in the trigger-event
api/taskscheduler.txt · Last modified: 2017/07/24 11:43 (external edit)