...
Notification environment variables
comThe default com.sos.scheduler.notification.plugins.notifier.SystemNotifierProcessBuilderPlugin
plugin used by the SystemMonitorNotification / Notification / NotificationCommand
Setelement sets the following variables as environment variables:
Service variables
Tables variables
Service variables
Expand |
---|
|
Name | Description |
---|
SCHEDULER_MON_SERVICE_STATUS
| | SCHEDULER_MON_SERVICE_NAME
| | SCHEDULER_MON_SERVICE_MESSAGE_PREFIX
| | SCHEDULER_MON_SERVICE_COMMAND
| |
|
Tables variables
Expand |
---|
|
All tables variables (see tables variables explanation) have the prefix SCHEDULER_MON_TABLE_
e.g.: SCHEDULER_MON_TABLE_MON_N_ID
SCHEDULER_MON_TABLE_MON_N_SCHEDULER_ID
...
|
Here you go an example of an XML file used for notifying a specific System Monitor (op5 Monitor) and using NotificationCommand:
Code Block |
---|
|
<?xml version="1.0" encoding="utf-8"?>
<SystemMonitorNotification xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="SystemMonitorNotification_v1.0.xsd">
<Notification>
<!--
configure system monitor service name and command for send notification to OP5 system monitor using nsca Client
%<VARIABLE>% spelling on NotificationCommand element will be used for all Operating Systems (Windows, Unix)
cmd /c (Windows) e.g /bin/sh -c (Unix) must be separated by | from following command
notification command substitution in this case:
All Environment variables e.g. %TEMP% or %JAVA_HOME%
%SERVICE_NAME% Error Service (service_name_on_error)
%SERVICE_STATUS% 1 if error occured (service_status_on_error)
0 if error recovered (service_status_on_success)
%SERVICE_MESSAGE_PREFIX% ERROR if error occured
RECOVERED if error recovered
TIMER if performance check
%ORDER_HISTORY_ID% ... table field name of result row for message string(see table definition SCHEDULER_MON_NOTIFICATIONS)
-->
<NotificationMonitor service_name_on_error="Error Service" service_status_on_error="1" service_status_on_success="0">
<NotificationCommand>
<![CDATA[cmd /c | echo my_nsca_service_host:%SERVICE_NAME%:%SERVICE_STATUS%:%SERVICE_MESSAGE_PREFIX%history id=%ORDER_HISTORY_ID%, step =%ORDER_STEP_STATE%, error=%ERROR_TEXT%, check = %CHECK_TEXT% | C:\nsca\send_nsca.exe -H nsca_server_host -c C:\nsca\send_nsca.cfg -d : ]]>
</NotificationCommand>
</NotificationMonitor>
<NotificationObject>
<!--
configure job chains and number of send operations for same problem (if problem is recovered or acknowledged no error notifications will be sended) for sending error notifications
requirement: monitoring of this job chains must be configured in CheckHistoryConfiguration.xml
-->
<JobChains>
<JobChain notifications="10" name="samples/sample_jobChain_1"/>
<JobChain notifications="10" name="samples/sample_jobChain_2"/>
</JobChains>
<Timers>
<Timer>
<!--
configure job chains and number of send operations to same check
requirement: timer check for this job chain must be configured in CheckHistoryConfiguration.xml
-->
<JobChains>
<JobChain notifications="1" name="samples/sample_jobChain_1"/>
</JobChains>
</Timer>
</Timers>
</NotificationObject>
</Notification>
</SystemMonitorNotification> |
Example SystemMonitorNotification_zabbix.xml
Here is an except of an XML file used for notifying a specific System Monitor (Zabbix Monitor) and using NotificationCommand under Linux
Code Block |
---|
language | xml |
---|
title | SystemMonitorNotification_zabbix.xml |
---|
|
...
<!--
zabbix_sender Zabbix sender installed on the JobScheduler host
localhost Hostname of the zabbix server
Zabbix_server JobScheduler Agent name(host name) that registred on Zabbix
samples.job1 Item key of zabbix (replace "/" to "." of JOB_NAME
-->
<NotificationCommand>
<![CDATA[/bin/sh -c | zabbix_sender -z localhost -s zabbix_server -k samples.job1 -o %ERROR%]]>
</NotificationCommand>
... |
Code Block |
---|
language | xml |
---|
title | Sample NotificationCommand Unix. Start the notification program directly. |
---|
|
...
<!--
Note: "> /tmp/command_output.txt" used to simulate the starting of the notification program
Note: "/bin/sh -c" is separated by "|" from following command
%SERVICE_NAME% value of Attribute "service_name_on_error" or "service_name_on_success"
%SERVICE_STATUS% value of Attribute "service_status_on_error" or "service_status_on_success"
%SERVICE_MESSAGE_PREFIX% ERROR if error occured
RECOVERED if error recovered
TIMER if performance check
%ORDER_HISTORY_ID% ... table field name of result row for message string(see table definition SCHEDULER_MON_NOTIFICATIONS)
e.g.: %ID%, %TASK_ID% etc.
-->
<NotificationCommand>
<![CDATA[/bin/sh -c | echo "%JAVA_HOME% %SERVICE_NAME%:%SERVICE_STATUS%:%SERVICE_MESSAGE_PREFIX%history id=%ORDER_HISTORY_ID%, step =%ORDER_STEP_STATE%, error=%ERROR_TEXT%, check = %CHECK_TEXT%" > /tmp/command_output.txt
</NotificationCommand>
... |
Code Block |
---|
language | xml |
---|
title | Sample NotificationCommand Unix. Start the notification via script file. |
---|
|
...
<!--
Note: "/bin/sh -c" is separated by "|" from following command
-->
<NotificationCommand><![CDATA[/bin/sh -c | /tmp/command.sh]</NotificationCommand>
...
|
These variables can be used when the NotificationCommand calls the notification client not directly, but a shell script, that make the logical implementation for sending of the notification messages.
Code Block |
---|
language | bash |
---|
title | Sample NotificationCommand Unix. Script file (/tmp/command.sh). |
---|
|
1) configured command in the SystemMonitorNotification_xxx.xml file
<NotificationCommand><![CDATA[/tmp/command.sh]</NotificationCommand>
2) content of the /tmp/command.sh file
#! /bin/sh
# Note: "> /tmp/command_output.txt" used to simulate the starting of the notification client
#
echo $SCHEDULER_MON_SERVICE_NAME:$SCHEDULER_MON_SERVICE_STATUS:$SCHEDULER_MON_SERVICE_MESSAGE_PREFIX history id = $SCHEDULER_MON_TABLE_ORDER_HISTORY_ID > /tmp/command_output.txt
|
Service variables
Expand |
---|
|
Name | Description |
---|
SCHEDULER_MON_SERVICE_STATUS
| Value of attribute service_name_on_error or service_name_on_success | SCHEDULER_MON_SERVICE_NAME
| Value of attribute service_status_on_error or service_status_on_success | SCHEDULER_MON_SERVICE_MESSAGE_PREFIX
| ERROR if error occured RECOVERED if error recovered TIMER if performance check
| SCHEDULER_MON_SERVICE_COMMAND
| |
|
Tables variables
Expand |
---|
|
All tables variables (see tables variables explanation) have the prefix SCHEDULER_MON_TABLE_
e.g.: SCHEDULER_MON_TABLE_MON_N_ID
SCHEDULER_MON_TABLE_MON_N_SCHEDULER_ID
...
|
Here you go an example of an XML file used for notifying a specific System Monitor (op5 Monitor) and using NotificationCommand:
Code Block |
---|
|
<?xml version="1.0" encoding="utf-8"?>
<SystemMonitorNotification xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="SystemMonitorNotification_v1.0.xsd">
<Notification>
<!--
configure system monitor service name and command for send notification to OP5 system monitor using nsca Client
%<VARIABLE>% spelling on NotificationCommand element will be used for all Operating Systems (Windows, Unix)
cmd /c (Windows) e.g /bin/sh -c (Unix) must be separated by | from following command
notification command substitution in this case:
All Environment variables e.g. %TEMP% or %JAVA_HOME%
%SERVICE_NAME% Error Service (service_name_on_error)
%SERVICE_STATUS% |
Code Block |
---|
language | bash |
---|
title | Sample NotificationCommand Unix. Script file (/tmp/command.sh). |
---|
|
#! /bin/sh
# Note: "> /tmp/command_output.txt" used to simulate the starting of the notification program
#
# JobScheduler Monitoring Interface has set the following environment variables for this script:
# $SCHEDULER_MON_SERVICE_NAME 1 if error occured value of Attribute "(service_namestatus_on_error" or "service_name_on_success"
# $SCHEDULER_MON_SERVICE_STATUS)
value of Attribute "service_status_on_error" or "service_status_on_success"
# $SCHEDULER_MON_SERVICE_MESSAGE_PREFIX 0 if ERRORerror recovered (service_status_on_success)
if error occured %SERVICE_MESSAGE_PREFIX% ERROR if error occured
# RECOVERED if error recovered
RECOVERED if error recovered TIMER if performance check
%ORDER_HISTORY_ID% ... table field
#name of result row for message string(see table definition SCHEDULER_MON_NOTIFICATIONS)
-->
<NotificationMonitor service_name_on_error="Error Service" service_status_on_error="1" service_status_on_success="0">
TIMER if performance check
# $SCHEDULER_MON_TABLE_FIELD_<field name> table field name of result row for message string(see table definition SCHEDULER_MON_NOTIFICATIONS)
# <NotificationCommand>
<![CDATA[cmd /c | echo my_nsca_service_host:%SERVICE_NAME%:%SERVICE_STATUS%:%SERVICE_MESSAGE_PREFIX%history id=%ORDER_HISTORY_ID%, step =%ORDER_STEP_STATE%, error=%ERROR_TEXT%, check = %CHECK_TEXT% | C:\nsca\send_nsca.exe -H nsca_server_host -c C:\nsca\send_nsca.cfg -d : ]]>
</NotificationCommand>
</NotificationMonitor>
<NotificationObject>
<!--
e.g.: $SCHEDULER_MON_TABLE_FIELD_ID, $SCHEDULER_MON_TABLE_FIELD_TASK_ID etc.
echo $JAVA_HOME $SCHEDULER_MON_SERVICE_NAME:$SCHEDULER_MON_SERVICE_STATUS:$SCHEDULER_MON_SERVICE_MESSAGE_PREFIX history id = $SCHEDULER_MON_TABLE_FIELD_ORDER_HISTORY_ID > /tmp/command_output.txt
|
Explanation
- SystemMonitorNotification can contain several Notification definitions for notification of error or success conditions
- Notification (required) contain one NotificationMonitor
- NotificationMonitor (required) contains the configuration for delivery notifications to System Monitor and has the following attributes
- service_name_on_error (optional) - Service name to send of error/recovery messages. One of service_name_on_error or service_name_on_success must be set.
- service_name_on_success (optional) - Service name to send of success messages if order is successfully completed. One of service_name_on_error or service_name_on_success must be set.
- service_status_on_error (optional) - Service status (e.g. CRITICAL or WARNING) to send of error messages. If not set - CRITICAL will be sended
- service_status_on_success (optional) - Service status (e.g. SUCCESS) to send of success messages. If not set - OK will be sended
- NotificationMonitor can has one of the following elements
- NotificationCommand (optional) command line for calling of the extern script for system notification
- NotificationInterface (optional) calling API for system notification (currently for NSCA notifications). This Element has the following attributes
- service_host (required) - hostname for the host the notification are sent from (the way it is named at the System Monitor)
- monitor_port (required) - port of System Monitor to receive notifications
- monitor_host (required) - hostname of System Monitor
- monitor_encryption (required) - specifies that the communication with the System Monitor is encrypted. NONE, XOR, TRIPLE_DES encryptions are available.
- NotificationObject (required) contains the configuration of objects, which will be sended to System Monitor
- JobChains (optional) - can contain several JobChain definitions
- JobChain (required) has the following attributes (one of scheduler_id or name must be set):
- notifications (optional) - Number of notifications for the same problem (if problem is recovered or acknowledged - no notification will be sended). By default - 1
- scheduler_id (optional) - JobScheduler instance with the given identification. By default - JobChain will be checked in all JobScheduler instances that logged into the same database
- name (optional) - Job chain name including possible folder names. By default - all JobChains for defined scheduler_id are checked
- step_from (optional) - Start Job node name for checking
- step_to (optional) - End Job node name for checking
- Timers (optional) - can contain several Timer definitions
- Timer (required) has the following elements
- JobChains (optional) - can contain several JobChain definitions for performance notification
- JobChain (required) has the following attributes (one of scheduler_id or name must be set):
- notifications (optional) - Number of notifications for the same check. By default - 1
- scheduler_id (optional) - JobScheduler instance with the given identification. By default - JobChain will be checked in all JobScheduler instances that logged into the same database
- name (optional) - Job chain name including possible folder names. By default - all JobChains for defined scheduler_id are checked
- step_from (optional) - Start Job node name for checking
- step_to (optional) - End Job node name for checking
...
configure job chains and number of send operations for same problem (if problem is recovered or acknowledged no error notifications will be sended) for sending error notifications
requirement: monitoring of this job chains must be configured in CheckHistoryConfiguration.xml
-->
<JobChains>
<JobChain notifications="10" name="samples/sample_jobChain_1"/>
<JobChain notifications="10" name="samples/sample_jobChain_2"/>
</JobChains>
<Timers>
<Timer>
<!--
configure job chains and number of send operations to same check
requirement: timer check for this job chain must be configured in CheckHistoryConfiguration.xml
-->
<JobChains>
<JobChain notifications="1" name="samples/sample_jobChain_1"/>
</JobChains>
</Timer>
</Timers>
</NotificationObject>
</Notification>
</SystemMonitorNotification> |
Example SystemMonitorNotification_zabbix.xml
Here is an except of an XML file used for notifying a specific System Monitor (Zabbix Monitor) and using NotificationCommand under Linux
Code Block |
---|
language | xml |
---|
title | SystemMonitorNotification_zabbix.xml |
---|
|
...
<!--
zabbix_sender Zabbix sender installed on the JobScheduler host
localhost Hostname of the zabbix server
Zabbix_server JobScheduler Agent name(host name) that registred on Zabbix
samples.job1 Item key of zabbix (replace "/" to "." of JOB_NAME
-->
<NotificationCommand>
<![CDATA[/bin/sh -c | zabbix_sender -z localhost -s zabbix_server -k samples.job1 -o %ERROR%]]>
</NotificationCommand>
... |
Code Block |
---|
language | xml |
---|
title | Sample NotificationCommand Unix. Start the notification program directly. |
---|
|
...
<!--
Note: "> /tmp/command_output.txt" used to simulate the starting of the notification program
Note: "/bin/sh -c" is separated by "|" from following command
%SERVICE_NAME% value of Attribute "service_name_on_error" or "service_name_on_success"
%SERVICE_STATUS% value of Attribute "service_status_on_error" or "service_status_on_success"
%SERVICE_MESSAGE_PREFIX% ERROR if error occured
RECOVERED if error recovered
TIMER if performance check
|
Code Block |
---|
|
....
<!--
notification message substitution in this case:
All Environment variables e.g. %TEMP% or %JAVA_HOME%
%ORDER_HISTORY_ID% ... table field name of result row for building message string(see table definition SCHEDULER_MON_NOTIFICATIONS)
-->
<NotificationMonitor service_name_on_error="Error Service">
<NotificationInterface service_host="my_nsca_service_host" monitor_port="5667" monitor_host="nsca_server_host" monitor_encryption="XOR">
order history id=%ORDER_HISTORY_ID%, job chain=%JOB_CHAIN_NAME%, order id=%ORDERe.g.: %ID%, %TASK_ID% etc.
-->
<NotificationCommand>
<![CDATA[/bin/sh -c | echo "%JAVA_HOME% %SERVICE_NAME%:%SERVICE_STATUS%:%SERVICE_MESSAGE_PREFIX%history id=%ORDER_HISTORY_ID%, step =%ORDER_STEP_STATE%, error=%ERROR_TEXT%, check = %CHECK_TEXT%
" </NotificationInterface>
> /tmp/command_output.txt
</NotificationCommand>
... |
JobScheduler - Job Chains
...