{"id":30,"date":"2025-03-10T20:30:06","date_gmt":"2025-03-10T20:30:06","guid":{"rendered":"http:\/\/qatools.net\/?p=30"},"modified":"2025-11-06T13:38:45","modified_gmt":"2025-11-06T13:38:45","slug":"windows-tool-perfmon","status":"publish","type":"post","link":"http:\/\/qatools.net\/index.php\/2025\/03\/10\/windows-tool-perfmon\/","title":{"rendered":"Windows Tool: Perfmon \/ Logman"},"content":{"rendered":"\n<p>Perfmon is a gui tool on windows to start\/stop a performance collection and then view the results. It is natively available on windows.   Logman is a command line tool that also can start\/stop performance collection and create counters.  Both tools invoke the same underlying code but logman is useful for using inside scripts.<\/p>\n\n\n\n<p>Perfmon: <a href=\"https:\/\/learn.microsoft.com\/en-us\/windows-server\/administration\/windows-commands\/perfmon\">https:\/\/learn.microsoft.com\/en-us\/windows-server\/administration\/windows-commands\/perfmon<\/a><\/p>\n\n\n\n<p>Logman: <a href=\"https:\/\/learn.microsoft.com\/en-us\/windows-server\/administration\/windows-commands\/logman\">https:\/\/learn.microsoft.com\/en-us\/windows-server\/administration\/windows-commands\/logman<\/a><\/p>\n\n\n\n<p>Basic steps for a performance gathering activity:<br>1. Create a &#8220;User defined&#8221; &#8220;Data Collector Set&#8221;. Name it and add some &#8220;counters&#8221;<\/p>\n\n\n\n<p>2. Start the collecter set and let it run for a period, say 10 minutes.<\/p>\n\n\n\n<p>3. Stop the set<\/p>\n\n\n\n<p>4. parse, transform the results and view them<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>The steps for perfmon are pretty intuitive.   Here is an excellent blog for the above steps: <a href=\"https:\/\/knowledge.ni.com\/KnowledgeArticleDetails?id=kA03q000000YHEICA4&amp;l=en-US\">https:\/\/knowledge.ni.com\/KnowledgeArticleDetails?id=kA03q000000YHEICA4&amp;l=en-US<\/a><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>The same steps in logmon are listed below:<\/p>\n\n\n\n<p>From dos administrator command prompt:<br>1.  Select a name, for e.g my_perf<br>2. query if that user defined data collector set exists: <br><em><strong>logman query my_perf > NUL 2>&amp;1<\/strong><\/em><\/p>\n\n\n\n<p>3. If it exists, stop and delete it<\/p>\n\n\n\n<p><strong>i<em>f errorlevel 0 (<br>logman stop my_perf > NUL 2>&amp;1<br>logman delete my_perf > NUL 2>&amp;1<br>)<\/em><\/strong><\/p>\n\n\n\n<p>4. Create a set of performance counters you are interested in a text file, for e.g my_counters.txt with some counters as in the example below:<br><strong><em>&#8220;\\Processor(_Total)\\% Privileged Time&#8221;<br>&#8220;\\Processor(_Total)\\% Processor Time&#8221;<br>&#8220;\\Processor(_Total)\\% User Time&#8221;<br>&#8220;\\PhysicalDisk(_Total)\\Disk Transfers\/sec&#8221;<br>&#8220;\\PhysicalDisk(_Total)\\Disk Writes\/sec&#8221;<br>&#8220;\\PhysicalDisk(_Total)\\Disk Reads\/sec&#8221;<br>&#8220;\\PhysicalDisk(_Total)\\Disk Bytes\/sec&#8221;<\/em><\/strong><\/p>\n\n\n\n<p>5. Select a stat interval, for example 10 seconds<\/p>\n\n\n\n<p><strong><em>set STAT_INTERVAL=10<\/em><\/strong><\/p>\n\n\n\n<p>6. Create a directory to store the results:<br>   <strong><em>set OUTPUT_DIR=c:\\my_perf<br>   cmd \/c mkdir %OUTPUT_DIR% > NUL 2>&amp;1<\/em><\/strong><\/p>\n\n\n\n<p>7. Optionally set codepage to utf-8. This is useful if you want to use your scripts to parse the results and show a specific value.  Scripts work better if the results are in utf-8 codepage.<br><br><strong><em>chcp 65001\u00a0 > NUL 2>&amp;1<\/em><\/strong><\/p>\n\n\n\n<p>8. Create data collector set:<br><strong><em>logman create counter my_perf -f bin -si %STAT_INTERVAL% -o %OUTPUT_DIR%\\\\my_perf -cf\u00a0 my_counters.txt > NUL 2>&amp;1<\/em><\/strong><\/p>\n\n\n\n<p>9. Start the collector set: This creates a file with a .blg extension.<br><strong><em>logman start my_perf > NUL 2>&amp;1<\/em><\/strong><\/p>\n\n\n\n<p>10. Wait 10 minutes or so and stop the collector<br><br><strong><em>logman stop my_perf > NUL 2>&amp;1<\/em><\/strong><\/p>\n\n\n\n<p>11. View the results.  You can use perfmon for this step or convert the blg file to a csv file and then write a script to split the one csv file into multiple csv files by process, counter etc.  Then create an html graph or table using each individual csv file<\/p>\n\n\n\n<p><strong><em>for %%f in (%OUTPUT_DIR%\\*.blg) do (<br>relog %%f \/f csv \/o %OUTPUT_DIR%\\%%~nf.csv > NUL 2>&amp;1)<\/em><\/strong><\/p>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\"><\/div><\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Perfmon is a gui tool on windows to start\/stop a performance collection and then view the results. It is natively available on windows. Logman is a command line tool that also can start\/stop performance collection and create counters. Both tools invoke the same underlying code but logman is useful for using inside scripts. Perfmon: https:\/\/learn.microsoft.com\/en-us\/windows-server\/administration\/windows-commands\/perfmon [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-30","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/qatools.net\/index.php\/wp-json\/wp\/v2\/posts\/30","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/qatools.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/qatools.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/qatools.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/qatools.net\/index.php\/wp-json\/wp\/v2\/comments?post=30"}],"version-history":[{"count":3,"href":"http:\/\/qatools.net\/index.php\/wp-json\/wp\/v2\/posts\/30\/revisions"}],"predecessor-version":[{"id":94,"href":"http:\/\/qatools.net\/index.php\/wp-json\/wp\/v2\/posts\/30\/revisions\/94"}],"wp:attachment":[{"href":"http:\/\/qatools.net\/index.php\/wp-json\/wp\/v2\/media?parent=30"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/qatools.net\/index.php\/wp-json\/wp\/v2\/categories?post=30"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/qatools.net\/index.php\/wp-json\/wp\/v2\/tags?post=30"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}