このタスクについて
Custom1およびCustom2イベント・ルールを使用して、NPSソフトウェアでイベントとして定義されていない条件について、独自に設計したイベントを定義し、生成することができます。 例えば、カスタム・イベントを使用してユーザーのログイン情報を追跡したりできますが、そのようなカスタム・イベントを使用して、複雑なイベントを作成することもできます。
カスタム・イベントを定義する場合は、nzevent generate コマンドを使用して、イベントをトリガーするプロセスも定義する必要があります。 通常、これらのイベントは顧客が作成したスクリプトによって生成され、既存のNPSイベントまたは監視したい他の条件に応じて呼び出されます。
カスタム・イベント・ルールを作成するには、以下の手順を実行します。
手順
- 新しいイベントタイプを定義するには、「nzevent addコマンドを使用する。
カスタム・イベントは、既存のイベント・タイプを基に作成するものではありません。 この例では、3 つの異なるカスタム・イベントを作成します。 nNewRule4 および NewRule5 は、イベント・タイプを区別するために変数 eventType を使用します。 NewRule6 イベント・タイプは、カスタム変数を使用して、それを標準のイベント・タイプと比較します。
[nz@nzhost ~]$ nzevent add -eventType custom1 -name NewRule4
-notifyType email -dst myemail@company.com -msg "NewRule4 message"
-eventArgsExpr '$eventType==RandomCustomEvent'
[nz@nzhost ~]$ nzevent add -eventType custom1 -name NewRule5
-notifyType email -dst myemail@company.com -msg "NewRule5 message"
-eventArgsExpr '$eventType==sysStateChanged'
[nz@nzhost ~]$ nzevent add -eventType custom1 -name NewRule6
-notifyType email -dst myemail@company.com -msg "NewRule6 message"
-eventArgsExpr '$randomEventType==sysStateChanged'
- nzevent generateコマンドを使用して、カスタム・イベントをトリガーする。
[nz@nzhost ~]$ nzevent generate -eventtype custom1
-eventArgs 'eventType=RandomCustomEvent'
[nz@nzhost ~]$ nzevent generate -eventtype custom1
-eventArgs 'eventType=sysStateChanged'
[nz@nzhost ~]$ nzevent generate -eventtype custom1
-eventArgs 'randomEventType=sysStateChanged'
- これらのカスタムイベントが生成されると、指定された宛先に電子メールが送信され、'/nz/kit/log/eventmgr/eventmgr.logファイルに以下のメッセージが記録される:
2015-11-24 09:43:31.820612 EST (16210) Info: received & processing event
type =custom1, event args = 'eventType=RandomCustomEvent' event source =
'User initiated event'
2015-11-24 09:43:31.820724 EST (16210) Info: invoking mail notifier,
cmd = '/nz/kit.7.2.1.0.45837/sbin/sendMail -dst "myemail@company.com"
-msg "NewRule4 message"'
2015-11-24 09:43:31.838814 EST (16210) Info: received & processing event
type =custom1, event args = 'eventType=sysStateChanged' event source =
'User initiated event'
2015-11-24 09:43:31.838920 EST (16210) Info: invoking mail notifier,
cmd = '/nz/kit.7.2.1.0.45837/sbin/sendMail -dst "myemail@company.com"
-msg "NewRule5 message"'
2015-11-24 09:43:32.745636 EST (16210) Info: received & processing event
type =custom1, event args = 'randomEventType=sysStateChanged' event
source = 'User initiated event'
2015-11-24 09:43:32.745802 EST (16210) Info: invoking mail notifier,
cmd = '/nz/kit.7.2.1.0.45837/sbin/sendMail -dst "myemail@company.com"
-msg "NewRule6 message"'
次の作業
カスタム・イベントの発生時に必要に応じて nzevent
generate コマンドを実行するスクリプトを作成することを検討してください。