MID サーバーホストのプロセスごとの CPU とメモリの使用率をリモートで監視する方法Summary<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: #000000; } span { font-size: 12pt; font-family: Lato; color: #000000; } h2 { font-size: 24pt; font-family: Lato; color: black; } h3 { font-size: 18pt; font-family: Lato; color: black; } h4 { font-size: 14pt; font-family: Lato; color: black; } a { font-size: 12pt; font-family: Lato; color: #00718F; } a:hover { font-size: 12pt; color: #024F69; } a:target { font-size: 12pt; color: #032D42; } a:visited { font-size: 12pt; color: #00718f; } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } MID サーバーの問題のデバッグ中は、テストを実行しながら CPU 使用率などのホストサーバーのパフォーマンスメトリクスを継続的に監視すると役立つ場合があります。これには通常、MID サーバーホストのリモート デスクトップが必要であり、タスク マネージャーやパフォーマンス モニターなどのツールを使用する必要があります。ただし、これはコマンドラインからも実行できるため、プローブコマンドを実行しているかのように、インスタンスを介してリモートで実行できます。 Release<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: #000000; } span { font-size: 12pt; font-family: Lato; color: #000000; } h2 { font-size: 24pt; font-family: Lato; color: black; } h3 { font-size: 18pt; font-family: Lato; color: black; } h4 { font-size: 14pt; font-family: Lato; color: black; } a { font-size: 12pt; font-family: Lato; color: #00718F; } a:hover { font-size: 12pt; color: #024F69; } a:target { font-size: 12pt; color: #032D42; } a:visited { font-size: 12pt; color: #00718f; } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } 全て Instructions<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: #000000; } span { font-size: 12pt; font-family: Lato; color: #000000; } h2 { font-size: 24pt; font-family: Lato; color: black; } h3 { font-size: 18pt; font-family: Lato; color: black; } h4 { font-size: 14pt; font-family: Lato; color: black; } a { font-size: 12pt; font-family: Lato; color: #00718F; } a:hover { font-size: 12pt; color: #024F69; } a:target { font-size: 12pt; color: #032D42; } a:visited { font-size: 12pt; color: #00718f; } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } Windows Server の場合、 typeperf コマンドは、タスクマネージャーまたはパフォーマンスモニターと同じパフォーマンスデータを出力します。https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/typeperf Linux top コマンドは同等です。http://man7.org/linux/man-pages/man1/top.1.html これらは、「コマンド」プローブを使用して MID サーバーホストで実行できます。「コマンド」トピックの ECC キュー出力の形成方法については、次のドキュメントを参照してください。https://docs.servicenow.com/csh?topicname=ecc-queue-mid-server.html&version=latest#manage-ecc-queue-content 次のコマンドを使用して、使用可能なすべてのカウンターを一覧表示できます。 typeperf -q 例 1:ホストの CPU とメモリー CPU、使用中のメモリ、利用可能なメモリ: typeperf "\Processor(_total)\% Processor Time" "\Memory\Committed Bytes" "\Memory\Available Bytes" -si 10 -sc 6 出力は CSV 形式で、実行中のすべてのプロセスの CPU 使用率を 6 回 (-sc)、10 秒間隔 (-si) でリストします。 "(PDH-CSV 4.0)","\\XXX\Processor(_total)\% Processor Time","\\XXX\Memory\Committed Bytes","\\XXX\Memory\Available Bytes""08/03/2020 17:05:38.187","3.492081","26921250816.000000","5113982976.000000""08/03/2020 17:05:48.189","3.832699","26869493760.000000","5143330816.000000""08/03/2020 17:05:58.191","3.407628","26836049920.000000","5165826048.000000""08/03/2020 17:06:08.192","3.106549","26834079744.000000","5164392448.000000""08/03/2020 17:06:18.193","4.319378","26830151680.000000","5168476160.000000""08/03/2020 17:06:28.195","3.806544","26825379840.000000","5251788800.000000" 結果を ECC キュー入力レコードペイロードからテキストエディターにコピーし、そこで.csvファイルとして保存する必要があります。その後、Excel などで開くことができます。 例 2:すべてのプロセスの CPU typeperf "\Process(*)\% Processor Time" -si 10 -sc 6 列ラベルがプロセス名になります。各行は、特定のタイムスタンプのスナップショットになります。上記の例では、10 秒間隔で 6 行のデータが得られます。全体像を把握したい場合は、120 行、60 秒間隔など、別のことをすることができます。 メインの MID サーバーサービスプロセスは、次のような名前で表示される場合があります。 wrapper-windows-x86-64#1java#1wmi_collector#1 特定のプローブに対して MID サーバーによって起動されるプロセスは、次のようになります。 パワーシェル#38ホスト#41 注:これらのプロセスはJavaアプリケーションの外部にあるため、独自のCPUとメモリを使用します。このメモリ使用量は、MID サーバーに割り当てられた Java ヒープ領域に追加されます。 例 3:すべてのプロセスの PID、CPU、メモリ、およびハンドル typeperf "\Process(*)\ID Process" "\Process(*)\% Processor Time" "\Process(*)\Working Set" "\Process(*)\Working Set - Private" "\Process(*)\Handle Count" -si 10 -sc 6 残念ながら、出力はプロセスではなくカウンター順であるため、読み取りには理想的ではありません。 特定のプロセスに絞り込むこともできます。たとえば、「Java」と「PowerShell」のすべてのもの: typeperf "\Process(java*)\ID Process" "\Process(java*)\% Processor Time" "\Process(java*)\Working Set" "\Process(java*)\Working Set - Private" "\Process(java*)\Handle Count" "\Process(java*)\ID Process" "\Process(powershell*)\% Processor Time" "\Process(powershell*)\Working Set" "\Process(powershell*)\Working Set - Private" "\Process(powershell*)\Handle Count" -si 10 -sc 6 注: プロセスが使用しているメモリ量を確認するために「ワーキングセット」と「ワーキングセット - プライベート」を使用することは、完全に信頼できるわけではありませんが、それでも便利です。 例 4:インスタンス内のスケジュール済みスクリプトにすべてをまとめる 目的の MID サーバーとカウンター用にカスタマイズされた次のスクリプト例を、定期的なスケジュールスクリプト (sysauto_script) で使用できます。 // Scheduled script to run periodically, to create jobs for a set of MID Servers // Uses a combination of examples 1 and 3 from this KB, but runs once for each job // https://hi.service-now.com/kb_view.do?sysparm_article=KB0824725 // This will result in the counters for the host memory in general, and each running process, // in CSV format in the payload of the input in the ECC Queue // v1 2020-08-05 David Piper // ----------------------------------- // Setup: // The command line. //Backslashes need escaping (\ to \\)// be careful with quotes and apostrophes var command = 'typeperf "\\Processor(_total)\\% Processor Time" "\\Memory\\Committed Bytes" "\\Memory\\Available Bytes" "\\Process(*)\\ID Process" "\\Process(*)\\% Processor Time" "\\Process(*)\\Working Set" "\\Process(*)\\Working Set - Private" "\\Process(*)\\Handle Count" -sc 1'; // Define which MID Servers get the job // You can define the filter on a list view of MID Servers, and then copy the query string into this variable.// be careful with quotes and apostrophes var encodedQuery = "name=ProdDiscoMid^status=Up"; // ----------------------------------- var midGr = new GlideRecord('ecc_agent'); midGr.addEncodedQuery(encodedQuery); // This limits which MID Servers are involved. midGr.query(); var eccGr = new GlideRecord('ecc_queue'); while(midGr.next()) { eccGr.initialize(); // new record eccGr.agent = 'mid.server.' + midGr.name; eccGr.name = command; // the command may be croped, so put it in the payload as well eccGr.queue = 'output'; eccGr.topic = 'Command'; eccGr.state = 'ready'; eccGr.priority = 1; //expedited, so discovery's 2 standard ones are not in the way eccGr.payload = '<parameters><parameter name="name" value="' + escapeXml(command) + '"/><parameter name="skip_sensor" value="true"/></parameters>'; eccGr.insert(); } function escapeXml(unsafe) { return unsafe.replace(/[<>&'"]/g, function (c) { switch (c) { case '<': return '<'; case '>': return '>'; case '&': return '&'; case '\'': return '''; case '"': return '"'; } }); }