CData Virtuality Server は、ローカルとグローバルの2種類の通知をサポートしています。
ローカル通知を作成または削除するには、カンマ区切りのジョブID リストを指定します:
SELECT
*
FROM
(CALL SYSADMIN.enableJobEmailNotification(jobIds =>
'15, 18'
, jobStatuses =>
'FAILED, success'
, recipients =>
'[email protected]'
, subjectTemplate =>
'DV Report - local subject'
, messageTemplate =>
'DV Report - Local message - description: %description%'
)) a;;
SELECT
*
FROM
(CALL SYSADMIN.disableJobEmailNotification(jobIds =>
'15, 18'
)) a;;
プロシージャ呼び出しは、両方の場合において、追加または削除された通知エンティティのID を返します。
グローバル通知は、ジョブの引数に "*"を渡すことによって定義することができ、globalNotification
フラグがTRUE
に設定され、jobId
がNULL であることによってシステムテーブルで識別されます:
SELECT
*
FROM
(CALL SYSADMIN.enableJobEmailNotification(jobIds =>
'*'
, jobStatuses =>
'FAILED, SUcceSS'
, recipients =>
'[email protected]'
, subjectTemplate =>
'DV Report - global subject'
, messageTemplate =>
'DV Report - Global message - description: %Description%'
)) a ;;
SELECT
*
FROM
(CALL SYSADMIN.disableJobEmailNotification(jobIds =>
'*'
)) a ;;
通知を有効にするプロシージャがすでに存在する通知(ローカルとグローバルの両方)で呼び出された場合、古い値は新しい値で上書きされます。
To correctly use the email notification mechanism for jobs, setting the appropriate SMTP configuration in CData Virtuality Server is necessary. This can be done using the UTILS.setSmtpConfiguration()
procedure or manually changing the configuration in dvserver-standalone.xml.
Statuses and Recipients
この2つの引数はNULLや空にはできません。システムは、正しいステータス(SUCCESS
, FAILED
, など)が提供されているかどうか、また受信者が有効なE メールアドレスであるかどうかを検証します。
ローカル通知が指定されたジョブに対して定義され、グローバル通知が有効になっている場合、システムはローカル通知とグローバル通知の両方からステータスと受信者を組み合わせます。例えば、SUCCESS
ステータスでローカル通知が定義され、FAILED
ジョブの場合にグローバル通知が定義されると、システムはこのジョブが成功または失敗した場合に通知を送信します。
受信者の組み合わせは、ローカルおよびグローバル通知で定義されたすべての受信者にメールを送信する場合と同様です。
Templates for Subject and Body of the Email Message
新しい通知を有効にする手順は、通知メールに適用されるカスタムテンプレートを指定するために、subjectTemplate
、messageTemplate
(両方ともNULL可能)の2つのパラメータを受け入れます。指定しない場合は、デフォルトのテンプレートが使用されます。
件名とメッセージテンプレートでは、関連するジョブの現在の値に置き換えられるプレースホルダを指定することができます。これらは、現在の実装でサポートされているプレースホルダーです(CASEは区別されません):
Placeholder | Description |
---|---|
| ID of the job |
| Description of the job |
| Execution time of the job |
| Status of the job |
| Failure reason if the status is |
ローカル通知とグローバル通知の両方がジョブに対して定義されている場合、システムは件名と本文メッセージのテンプレートを使用したローカル通知を優先します。ローカル通知に対してテンプレートが定義されていない ( NULL
) 場合、NULLでなければ、システムはグローバル通知で定義されたテンプレートを使用します。グローバル通知にテンプレートが定義されていない場合、デフォルトのテンプレートが適用されます。
メールはHTMLで送信され、HTMLタグは本文のフォーマット(色、スタイルなど)を変更することができます。
以下のヘッダーとフッタは、メール生成時にシステムによって自動的に追加されます:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Datavirtuality Report</title>
</head>
<body>
</body>
</html>
Default Subject and Message Templates
前述したように、テンプレートが定義されていない場合はデフォルトのものが適用されます。
特に、件名とメッセージのデフォルトテンプレートはそれぞれ以下のように定義されています:
Datavirtuality Report - %status% - Job: %description% (jobId:%id%)
<h4>Datavirtuality Report:</h4>
<div>
Job ID: %id% <br />
Job Description: %description% <br />
Job Status: %status% <br />
Failure Reason: %failurereason% <br />
Execution time: %time%
</div>
Slack Notifications
Enabling/Disabling/Deleting Local and Global Notifications
SYSADMIN.enableJobSlackNotification
手続 は特定のジョブに対する通知を作成し、SYSADMIN.disableJobSlackNotification
手続 は既存の通知を無効にします。通知を完全に削除する必要がある場合は、SYSADMIN.deleteSlackNotification
プロシージャを使用できます。
ローカルとグローバルの2種類のNotificationを定義することができます。
A local notification takes precedence over a global notification. This means that if the global notification is enabled and the job is not excluded from the global, and the job has its specific notification, then the message and its type will be taken from the notification for the specific job, not from the global one.
ローカル ジョブ ID のカンマ区切りリスト を指定することで、通知を有効、無効、または削除できます:
CALL
"SYSADMIN.enableJobSlackNotification"
(
"jobIds"
=>
'13, 11, 9, 14'
,
"jobStatuses"
=>
'FAILED,FAILED_AUTORETRY'
,
"webHookURL"
=> <Slack WebHook URL>,
"message"
=>
'Job %id% with description %description% fails due to %failurereason%'
,
"isFormattedSlackMessage"
=>
false
);;
CALL
"SYSADMIN.disableJobSlackNotification"
(
"jobIds"
=>
'13,11'
);;
CALL
"SYSADMIN.deleteSlackNotification"
(
"jobIds"
=>
'13,11'
);;
グローバル 通知は、ジョブの引数 に "*"を渡すことで定義できます:
CALL
"SYSADMIN.enableJobSlackNotification"
(
"jobIds"
=>
'*'
,
"jobStatuses"
=>
'SUCCESS'
,
"webHookURL"
=> <Slack WebHook URL>,
"message"
=>
'Job %id% with description %description% fails due to %failurereason%'
,
"isFormattedSlackMessage"
=>
false
);;
CALL
"SYSADMIN.disableJobSlackNotification"
(
"jobIds"
=>
'*'
);;
CALL
"SYSADMIN.deleteSlackNotification"
(
"jobIds"
=>
'*'
);;
Sending Notifications
SYSADMIN.sendSlackNotification
プロシージャで任意のSlack 通知を送信できます:
CALL
"SYSADMIN.sendSlackNotification"
(
"message"
=>
'{"text":"JSON format"}'
,
"webHookURL"
=> <Slack WebHook URL>,
"isFormattedSlackMessage"
=>
true
);;
CALL
"SYSADMIN.sendSlackNotification"
(
"message"
=>
'A plain format'
,
"webHookURL"
=> <Slack WebHook URL>
);;