Lotus Notes/Domino (R) をこよなく愛して。。。。 -59ページ目

はや10年

ふと気が付いたのですが、このBlogは今年の5月で10年経っています。


2005年5月に書き始めてから、はや10年。


IBM退職後、書くペースは落ちていますが、よく続けているものだと、自分でも驚きます。



いい加減な内容もあるかと思いますが、もう歳なので、ボチボチと続けて行きますので、今後もご愛読よろしくお願い致します。

Domino AdministratorでのMail監視 -10-

<話題の履歴>


Domino AdministratorでのMail監視 -1-

Domino AdministratorでのMail監視 -2-

Domino AdministratorでのMail監視 -3-

Domino AdministratorでのMail監視 -4-

Domino AdministratorでのMail監視 -5-

Domino AdministratorでのMail監視 -6-

Domino AdministratorでのMail監視 -7-

Domino AdministratorでのMail監視 -8-

Domino AdministratorでのMail監視 -9-



前回は、Windows BatchでRouter Task Statusを把握して処理するProgramを完成させました。

今回は、AgentからRouter Task Statusを把握して処理するProgramを作ってみたいと思います。


以前、Remote Console Commandの戻り値をPrintしてみて、内容が変であることから出来ないと決めつけてしまっていたLotusScriptでの処理ですが、戻り値に制御Codeが含まれているのか? Printした場合に正常に表示されていないだけで内容は問題ないことが分かって来ました。


まず、それを確かめる為に、単純に以下のCodeを書いてみます。


 Sub Initialize
 Dim ss As New NotesSession
 Dim cons_res As String
 cons_res = ss.Sendconsolecommand("", "show tasks only")
 Print cons_res
 If InStr(cons_res , "Router") > 0 Then
 Print "Router is running"
 cons_res = ss.Sendconsolecommand("", "tell router status")
 Print cons_res
 Else
 Print "Router is not running"
 cons_res = ss.Sendconsolecommand("", "tell router status")
 Print cons_res
 End If
 End Sub


Routerが稼働している状態で実行すると以下のようになります。


> tell amgr run "test\mbcheck.nsf" 'ConsCmd'
[0EA4:0022-0854] 2015/05/09 09:05:22 AMgr: Start executing agent 'ConsCmd' in'test\mbcheck.nsf'
> show tasks only >C:\Users\ADMINI~1\AppData\Local\Temp\notes048967\rem55532.con

> tell router status >C:\Users\ADMINI~1\AppData\Local\Temp\notes048967\rem65748.con
SMTP Server Idle: Idle IdlenAgent Manager: Agent printing:
[0EA4:0022-0854] 2015/05/09 09:05:23 Agent Manager: Agent printing: Router is running

[02EC:0002-09AC] Msgs State Via Destination

[02EC:0002-09AC] Transfer Threads: Max = 25; Total = 0; Inactive = 0; Max Concurrent = 12
[02EC:0002-09AC] Delivery Threads: Max = 25; Total = 1; Inactive = 0
[02EC:0002-09AC] Dispatch Threads: Max = 4; Total = 2; Inactive = 2
[02EC:0002-09AC] Sweep Threads: Max = 4; Total = 2; Inactive = 2
[0EA4:0022-0854] 2015/05/09 09:05:23 Agent Manager: Agent printing: Command has been executed on remote server. Use 'Live' console option, in future, to view response from server.
[0EA4:0022-0854] 2015/05/09 09:05:23 AMgr: Agent 'ConsCmd' in 'test\mbcheck.nsf' completed execution


PrintされているConsole CommandのResponseは滅茶苦茶ですが、InstrによるRouter Taskの判断は正常に行われていることが分かります。

また、続いて実行した"tell router status"はCommandが実行されたというResponseが取れています。

残念ながらTell Commandを実行した場合は、その結果の内容は取得できません。


次にRouterを止めて実行してみます。


> tell amgr run "test\mbcheck.nsf" 'ConsCmd'
[0EA4:0023-0820] 2015/05/09 09:11:46 AMgr: Start executing agent 'ConsCmd' in 'test\mbcheck.nsf'
> show tasks only >C:\Users\ADMINI~1\AppData\Local\Temp\notes048967\rem65453.con

Schedule Manager Idleutive '1': Idlerequests on TCP Port:80 ng:
[0EA4:0023-0820] 2015/05/09 09:11:47 Agent Manager: Agent printing: Router is not running
> tell router status >C:\Users\ADMINI~1\AppData\Local\Temp\notes048967\rem47273.con
[0EA4:0023-0820] 2015/05/09 09:11:47 Agent Manager: Agent printing: The ROUTER Command has been executed on remote server. Use 'Live' console option, in future, to view response from server.
[0EA4:0023-0820] 2015/05/09 09:11:47 AMgr: Agent 'ConsCmd' in 'test\mbcheck.nsf' completed execution


この場合も、PrintされているConsole CommandのResponseは滅茶苦茶ですが、InstrによるRouter Taskの判断は正常に行われていることが分かります。

また、続いて実行した"tell router status"はConsole Logで見ると変な状態ですが、Console Commandを実行すると以下が返って来ますので、この値が取れているのではないかと思われます。


> tell router status

[06D4:0007-04AC] The ROUTER task either does not exist or does not accept "Tell" commands.


では、それを確かめてみます。

先程書いたCodeを以下のように修正します。


 Sub Initialize
 Dim ss As New NotesSession
 Dim cons_res As String
 cons_res = ss.Sendconsolecommand("", "show tasks only")
 Print cons_res
 If InStr(cons_res , "Router") > 0 Then
 Print "Router is running"
 cons_res = ss.Sendconsolecommand("", "tell router status")
 Print cons_res
 If InStr(cons_res , "The ROUTER task either does not exist") > 0 Then
 Print "Router is not responding"
 End If
 Else
 Print "Router is not running"
 cons_res = ss.Sendconsolecommand("", "tell router status")
 Print cons_res
 If InStr(cons_res , "The ROUTER task either does not exist") > 0 Then
 Print "Router is not responding"
 End If
 End If
 End Sub


Router Taskがshow tasks onlyで非稼働状態でRouterが応答しないというCaseを作るのは困難ですので、Router Taskを停止して実行してみると以下のようになります。


> tell amgr run "test\mbcheck.nsf" 'ConsCmd'
> show tasks only >C:\Users\ADMINI~1\AppData\Local\Temp\notes048967\rem31790.con

[0EA4:0024-0804] 2015/05/09 09:28:46 AMgr: Start executing agent 'ConsCmd' in 'test\mbcheck.nsf'
Schedule Manager Idleutive '1': Idlerequests on TCP Port:80 ng:
[0EA4:0024-0804] 2015/05/09 09:28:46 Agent Manager: Agent printing: Router is not running
> tell router status >C:\Users\ADMINI~1\AppData\Local\Temp\notes048967\rem06760.con
[0EA4:0024-0804] 2015/05/09 09:28:47 Agent Manager: Agent printing: The ROUTER Command has been executed on remote server. Use 'Live' console option, in future, to view response from server.
[0EA4:0024-0804] 2015/05/09 09:28:47 Agent Manager: Agent printing: Router is not responding
[0EA4:0024-0804] 2015/05/09 09:28:47 AMgr: Agent 'ConsCmd' in 'test\mbcheck.nsf' completed execution


Printされたtell router statusのResponseは変な状態ですが、判断は正常に行えていることが分かります。


実際の障害時を考えると、Domino AdministratorからはRouter Taskが稼働しているように見えていて、Routerが正常でないという状態の場合に、RouterへのTell Commandは受け付けられるのか?ということが最大のKeyとなります。

Tell Commandが受付られないという状況であれば、このProgramで状態の把握が出来ることは分かりました。



今回は、単純なSample ProgramでRemote Console CommandのResponseが正常に判断出来ることを確認しました。

次回は、この結果から、以前作成したAgentを修正してOSに頼らないRecovery処理を実現してみます。


<続く>

 

Domino AdministratorでのMail監視 -9-

<話題の履歴>


Domino AdministratorでのMail監視 -1-

Domino AdministratorでのMail監視 -2-

Domino AdministratorでのMail監視 -3-

Domino AdministratorでのMail監視 -4-

Domino AdministratorでのMail監視 -5-

Domino AdministratorでのMail監視 -6-

Domino AdministratorでのMail監視 -7-

Domino AdministratorでのMail監視 -8-



前回は、Task Statusを判断してTaskをReloadするWindows Batchを作成してみました。

今回は、このWindows Batchを使って、Mail滞留時の対応を行ってみます。


ここまで出来ていれば非常に簡単で、以前のCodeのMessage部分を以下のように修正します。


 'Print error message and reload router when over the threshold.
 If wait_cnt_all => Max_Wait Then
 Print "Wait over : " & CStr(wait_cnt_all) & " ( Threshold : " & CStr(Max_Wait) & " )"
 Print "Maybe router has some problem, router is restarted in a few minuttes."
 os_ret = Shell("reloadrouter.bat")
 End If
 'Print error message.
 If hold_cnt_all => Max_Hold Then
 Print "Hold over : " & CStr(hold_cnt_all) & " ( Threshold : " & CStr(Max_Hold) & " )"
 End If
 If dead_cnt_all => Max_Dead Then
 Print "Dead over : " & CStr(dead_cnt_all) & " ( Threshold : " & CStr(Max_Dead) & " )"
 End If


これで、Wait Countが閾値を超えた場合、Routerに何がしかの問題があると判断して、Shell関数でWindows Batchを起動し、Routerの再起動を行います。

実際に実行してみると、以下のようになります。

今回は、Routerが正常でない場合は再現が難しいので、Router Taskを停止して実行してみます。


> tell amgr run "Test\MBCheck.nsf" 'ChkMailboxDoc'
[0EA4:001D-0AC8] 2015/05/06 15:39:40 AMgr: Start executing agent 'ChkMailboxDoc' in 'Test\MBCheck.nsf'
[0EA4:001D-0AC8] 2015/05/06 15:39:40 Agent Manager: Agent printing: Mail box ( 1 ) All : 7
[0EA4:001D-0AC8] 2015/05/06 15:39:40 Agent Manager: Agent printing: Wait: 5
[0EA4:001D-0AC8] 2015/05/06 15:39:40 Agent Manager: Agent printing: Hold: 2
[0EA4:001D-0AC8] 2015/05/06 15:39:40 Agent Manager: Agent printing: Dead: 0
[0EA4:001D-0AC8] 2015/05/06 15:39:40 Agent Manager: Agent printing: Mail box ( 2 ) All : 7
[0EA4:001D-0AC8] 2015/05/06 15:39:40 Agent Manager: Agent printing: Wait: 5
[0EA4:001D-0AC8] 2015/05/06 15:39:40 Agent Manager: Agent printing: Hold: 2
[0EA4:001D-0AC8] 2015/05/06 15:39:40 Agent Manager: Agent printing: Dead: 0
[0EA4:001D-0AC8] 2015/05/06 15:39:40 Agent Manager: Agent printing: All mail boxes ( Mail boxes : 2 ) :14
[0EA4:001D-0AC8] 2015/05/06 15:39:40 Agent Manager: Agent printing: Wait: 10

[0EA4:001D-0AC8] 2015/05/06 15:39:40 Agent Manager: Agent printing: Hold: 4
[0EA4:001D-0AC8] 2015/05/06 15:39:40 Agent Manager: Agent printing: Dead: 0
[0EA4:001D-0AC8] 2015/05/06 15:39:40 Agent Manager: Agent printing: Wait over: 10 ( Threshold : 10 )
[0EA4:001D-0AC8] 2015/05/06 15:39:40 Agent Manager: Agent printing: Maybe router has some problem, router is restarted in a few minuttes.
[0EA4:001D-0AC8] 2015/05/06 15:39:40 Agent Manager: Agent printing: Hold over: 4 ( Threshold : 0 )
[0EA4:001D-0AC8] 2015/05/06 15:39:40 Agent Manager: Agent printing: Dead over: 0 ( Threshold : 0 )
[0EA4:001D-0AC8] 2015/05/06 15:39:40 AMgr: Agent 'ChkMailboxDoc' in 'Test\MBCheck.nsf' completed execution
> show tasks only >C:\IBM\Domino\tasklist.txt
> load router
[083C:0002-0CDC] 2015/05/06 15:39:41 Router: Mail Router started for domain LOTUS
[083C:0002-0CDC] 2015/05/06 15:39:41 Router: Internet SMTP host domsvr in domain lotus.com
[083C:000E-0894] 2015/05/06 15:39:41 Router: Message 00248CBC delivered to Admin/Lotus


これでEvent Monitorの助けを借りずにRouterの再起動が行えるようになりました。

今回はTestの為に、Agentは手動で起動していますが、Agentを5分置きとか10分置きで定期実行するように設定すれば、Routerが原因でMail滞留が起こった場合には対応は可能となります。

Agentを定期実行する場合、RouterのHause Keepingの時間を避けることが重要です。

RouterはDefaultでは朝4:00からHause Keepingを開始し、Mail.boxを順番に止めてMaintenanceを行いますが、この実行中にAgentが実行されてしまうと、Maintenance中のMail.boxを開こうとして、Maintenanceが完了するまでMail.box Openが待たされることになるからです。

以下のように期間を設定して、Maintenance期間に実行されないように設定します。



MailMonitoring_10


ここでは30分を設定していますが、この値は環境により異なりますので、Log.nsfから平常時のMaintenance終了までの時間を確認した上で設定してください。


設定したら、定期実行AgentがScheduleされていることを以下のCommandで確認します。


> tell amgr sche
[0EA4:0002-0718] S S 15:54 今日 ChkMailboxDoc Test\MBCheck.nsf



これである程度のMail滞留監視は出来るようになりましたが、賢明な皆さんはお気付きだと思いますが、このAgentでの監視にはまだまだ課題が存在します。


RouterでMailが滞留する場合、転送先の相手が応答しないためにMailが配信できず滞留してしまうこともあります。

この場合は、Routerが問題ではなく相手の問題ですので、Routerを再起動してみたところで現象は改善されません。

また、Agentを5分おきとかに実行したとして、一気に大量のMailが溜まり、次のAgentの実行時間までにRouterがMailを処理できずに、閾値を超えている場合、再度無駄にRouterが再起動されることになります。


後者の場合は、Agentを改造して、前回のMail Waitの数よりも滞留数が減少している場合にはRouterの再起動は行わないように改善することも出来ると思います。

前者の場合は、Routerが報告するErrorをCheckして処理するのは非常に面倒です。

もし、このAgentを改造して実現するとしたら、Routerの再起動処理を実行した回数を記憶して、連続して5回以上実行させないなどの制御を入れることだと思います。



さて、このシリーズの途中で戻り値が変だからと放置していたRemote Server Console Commandによる処理ですが、Printするとデタラメな戻り値のように見えますが、内容としてはちゃんと取得できているようです。



今回は、Windows BatchでRouter Task Statusを把握して処理するProgramを完成させました。

次回は、AgentからRouter Task Statusを把握して処理するProgramを作ってみたいと思います。


<続く>