ヘルスアクション¶
項目
ヘルスアクションは特定の条件に応じてタスクを実行、またはヘルスチェックの状態を修復するために使用します。ヘルスチェックと同様にヘルスアクションはhealth.xmlで構成され、定期的にヘルスシステムによって実行されます。
ヘルスアクションは通常、1つ以上のヘルスコンディションを伴いますが必須ではありません。すべてのアクションが関連付けられているコンディションの評価で決まり、一回の期間ごとに実行される可能性があります。コンディションが無いヘルスアクションは、期間ごとに一度実行されます。
<health:ActionSequence>¶
子に設定されているヘルスアクションを順に実行します。
属性¶
なし
設定例¶
<health:ActionSequence>
  <health:DumpThreads/>
  <health:DumpHeap/>
  <health:IfHealthCritical time="5m"/>
</health:ActionSequence>
<health:CallJmxOperation>¶
パラメータを指定して、JMX MBeanのオペレーションを実行します。
属性¶
| 属性名 | 説明 | 型 | デフォルト | 
|---|---|---|---|
| objectName | JMX MBeanの名前。 | String | なし | 
| operation | メソッドの名前。 | String | なし | 
| operationIndex | 複数のメソッドが一致する場合のユニークなインデックス。 | int | -1 | 
| param | 適切な型に変換されるメソッドのパラメータ。 | boolean | なし | 
設定例¶
<health:CallJmxOperation>
  <objectName>java.lang:type=Threading</objectName>
  <operation>resetPeakThreadCount</operation>
  <health:IfNotRecent time='5m'/>
</health:CallJmxOperation>
<health:DumpHeap>¶
メモリヒープダンプを生成します。
ヒープダンプは、Resinの内部ログデータベースとログファイルに記録されます。ログファイルには、info レベルで記録されます。
属性¶
| 属性名 | 説明 | 型 | デフォルト | 
|---|---|---|---|
| hprof | ユーザが読めるタイプのダンプではなく、HPROFフォーマットのダンプを生成します。 | boolean | false | 
| hprof-path | HPROFファイルの出力パス。(hprof がtrueの場合) | String | log/heap.hprof | 
| hprof-path-format | タイムスタンプのトークンを使用して、動的に出力パスを生成するフォーマットを記述します。 | String | なし | 
| log | ヒープダンプをResinの内部データベースに格納されるのに加えて、サーバ·ログに書き込みます。 | boolean | true | 
設定例¶
<health:DumpHeap>
  <hprof>true</hprof>
  <hprof-path-format>${resin.home}/log/dump-%H:%M:%S.%s.hprof</hprof-path-format>
  <health:OnAbnormalStop/>
</health:DumpHeap>
<health:DumpHprofHeap>¶
以下の設定と同様の意味をもつヘルスアクションです。
<health:DumpHeap>
  <hprof>true</hprof>
</health:DumpHeap>
<health:DumpJmx>¶
すべてのJMX属性および値のダンプを生成するヘルスアクションです。
JMXダンプは、Resinの内部ログデータベースとログファイルに記録されます。ログファイルには、info レベルで記録されます。
属性¶
| 属性名 | 説明 | 型 | デフォルト | 
|---|---|---|---|
| log | JMXダンプをResinの内部データベースに格納されるのに加えて、サーバ·ログに書き込みます。 | boolean | true | 
設定例¶
<health:DumpJmx/>
<health:DumpThreads>¶
スレッドダンプを生成します。
スレッドダンプは、Resinの内部ログデータベースとログファイルに記録されます。ログファイルには、info レベルで記録されます。
属性¶
| 属性名 | 説明 | 型 | デフォルト | 
|---|---|---|---|
| only-active | 現在アクティブなスレッドのみ出力します。(RUNNABLE の状態) | boolean | false | 
| log | スレッドダンプをResinの内部データベースに格納されるのに加えて、サーバ·ログに書き込みます。 | boolean | true | 
設定例¶
<health:DumpThreads>
  <only-active>false</only-active>
</health:DumpThreads>
<health:ExecCommand>¶
オペレーティングシステムのシェルコマンドを実行します。
属性¶
| 属性名 | 説明 | 型 | デフォルト | 
|---|---|---|---|
| command | 実行するコマンド。dir が設定されている場合は、相対パスで実行します。 | String | なし | 
| dir | 実行するディレクトリのパス。 | java.io.File で使用可能なパス | なし | 
| timeout | コマンド実行のタイムアウト。完了していない場合、コマンドがkillされるまでの時間。 | 期間 | 2s | 
| env | コマンドに使用する環境変数。 | 名前/値 の組み合わせ | なし(システムの環境変数はデフォルトで使用可能) | 
設定例¶
<health:ExecCommand>
  <dir>/tmp</dir>
  <command>remediation.sh</command>
  <timeout>2s</timeout>
  <env>
    <name>resin_home</name>
    <value>${resin.home}</value>
  </env>
  <env>
    <name>password</name>
    <value>foo</value>
  </env>
</health:ExecCommand>
<health:FailSafeRestart>¶
Resinを設定した時間に再起動します。通常、シャットダウン情報を集めるためにActionSequenceとともに使用します。
設定例¶
<health:ActionSequence>
  <health:FailSafeRestart timeout="10m"/>
  <health:DumpThreads/>
  <health:DumpHeap/>
  <health:StartProfiler active-time="5m"/>
  <health:Restart/>
  <health:IfHealthCritical time="5m"/>
</health:ActionSequence>
<health:PdfReport>¶
PHPスクリプトからPDFレポートを生成するヘルスアクションです。
属性¶
| 属性名 | 説明 | 型 | デフォルト | 
|---|---|---|---|
| path | PDFを生成する.phpファイルのパス。 | String | ${resin.home}/doc/admin/pdf-gen.php | 
| report | レポートタイプのキー。 | String | Summary | 
| period | レポートに出力する過去期間。 | 期間 | 7D | 
| log-directory | PDFを出力するディレクトリ。 | String | ${resin.logDirectory} | 
設定例¶
<health:PdfReport>
  <path>${resin.home}/doc/admin/pdf-gen.php</path>
  <report>Summary</report>
  <period>7D</report>
  <health:IfCron value="0 0 * * 0"/>
</health:PdfReport>
<health:ScoreboardReport>¶
関連したスレッドのグループについて簡潔なスレッドアクティビティレポートを生成します。
属性¶
| 属性名 | 説明 | 型 | デフォルト | 
|---|---|---|---|
| log | PDFレポートに加えて、サーバ·ログに書き込みます。 | boolean | false | 
| type | スコアボードレポートのタイプ。 | String | resin | 
| greedy | falseの場合、スレッドが複数のグループに分類されます。 | boolean | true | 
設定例¶
<health:ScoreboardReport>
  <health:OnAbnormalStop/>
</health:ScoreboardReport>
<health:SendMail>¶
現在のResinのヘルスステータスの概要を記載したメールを送信します。
属性¶
| 属性名 | 説明 | 型 | デフォルト | 
|---|---|---|---|
| to | メールの送信先アドレス | String | なし | 
| from | メールの送信元アドレス | String | resin@localhost | 
設定例¶
<health:SendMail>
  <to>admin@yourdomain.com</to>
  <to>another_admin@yourdomain.com</to>
  <from>resin@yourdomain.com</from>
</health:SendMail>
<health:Snapshot>¶
以下に示す一連のアクションを実行します。
- スレッドダンプ
 - ヒープダンプ
 - JMXダンプ
 - PDFレポート
 
これらはサーバの問題をデバッグするために必要な全ての情報を想定しており、システム自体のスナップショットを生成することを目的にされたアクションです。
このアクションは通常、予期しない問題に対して実行されることを想定しています。
属性¶
| 属性名 | 説明 | 型 | デフォルト | 
|---|---|---|---|
| log | PDFレポートに加えて、サーバ·ログに書き込みます。 | boolean | false | 
| path | PDFを生成する.phpファイルのパス。 | String | ${resin.home}/doc/admin/pdf-gen.php | 
| report | レポートタイプのキー。 | String | Summary | 
| period | レポートに出力する過去期間。 | 期間 | 7D | 
設定例¶
<health:Snapshot>
  <health:OnAbnormalStop/>
</health:Snapshot>
<health:StartProfiler>¶
プロファイラ開始します。結果は、Resinの内部ログデータベースとログファイルに記録されます。ログファイルには、info レベルで記録されます。
属性¶
| 属性名 | 説明 | 型 | デフォルト | 
|---|---|---|---|
| active-time | プロファイラを実行する時間 | 期間 | 5秒(5s) | 
| sampling-rate | サンプリングレート | 期間 | 10ミリ秒(10ms) | 
| depth | スタックトレースの深さ。 | int | 16 | 
設定例¶
<health:ActionSequence>
  <health:FailSafeRestart timeout="10m"/>
  <health:DumpThreads/>
  <health:DumpHeap/>
  <health:StartProfiler active-time="5m"/>
  <health:Restart/>
  <health:IfHealthCritical time="5m"/>
</health:ActionSequence>