Windows Process Resource Monitoring
====================================================================================
Shell script intended to run from a Windows bash shell (e.g., Cygwin, WSL). The
script takes one required parameter (the source file) and one optional parameter
(the interval between samples in whole seconds - default is 2). Order of the
argument parameters is significant. Examples:

To monitor the Chrome browser process...

$ win-proc-resource-mon.sh  chrome-on-desktop

To monitor the Firefox browser process at intervals of 5 seconds...

$ win-proc-resource-mon.sh  firefox-on-laptop  5


The input source file
====================================================================================
The source file name is used to open a file in the local folder with extension
"txt" as input to the Windows "TypePerf" shell command. The file contains valid
Windows performance counters for use with the TypePerf shell command, one per line,
as described in the following web pages:

https://ss64.com/nt/syntax-performance-counters.html
http://www.appadmintools.com/documents/windows-performance-counters-explained.

Refering back to the first example above, the script will attempt to open the file
"chrome-on-desktop.txt" and use the performance counters contained there. Example
performance counters:

"\Memory\Available MBytes"
"\Process(chrome)\% Processor Time"

Output
====================================================================================
The script will execute the TypePerf command using the input file and optional
interval and produce a CSV text file using the source input file name appended with
"-stats-YYYY-DAY-HHMMSS.csv". The performance counters will be used as the header
line and performance value records in the remaining lines.

Extending the example above, running the script on the morning of Dec 31, 2019 would
create a file named "chrome-on-desktop-stats-2019-365-093506.csv" containing the
following lines of text:

"Pacific Stan Time" , \Memory\Available MBytes" , "\Process(chrome)\% Processor Time"
"12/31/2019 09:35:08.193","3123","17.84127"
"12/31/2019 09:35:10.198","2900","24.81190"

Usage notes
====================================================================================
The source input file may contain as many performance counters as you'd like, for
any process that you may have running. The processes do not have to be running when
you start the script, and the processes can come and go while the script is running.

Example input file to monitor the available memory on the computer as well as both
Chrome and Firefox browsers:

"\Memory\Available MBytes"
"\Process(chrome)\% Processor Time"
"\Process(firefox)\% Processor Time"
"\Process(chrome)\IO Data Operations/sec"
"\Process(firefox)\IO Data Operations/sec"

Running Examples
====================================================================================
Use the example input file in this folder to get a feel for how the script operates.

(1) Navigate to the G2TerrainNav/cygwin folder in a Cygwin bash command window.

(2) After ensuring that the win-proc-resource-mon.sh file is executable, run the
script with the "reson-computer" parameter. The processes listed in the input file do
not need to exist for the utility to run correctly.

$ ./win-proc-resource-mon.sh reson-computer

After 10 seconds or so, Ctrl-C to stop the command script. Examine the CSV output
file to see what to expect. Note that the fields in the records for non-existant
processes have no values, but that all the records are present.

(3) Copy the reson-computer.txt file to typeperf.txt. Edit typeperf.txt and replace
"trn_server" with "typeperf" in at least one line, and save the file. Then run the
script again:

$ ./win-proc-resource-mon.sh typeperf

After 10 seconds or so, Ctrl-C to stop the command script. Examine the CSV output
file and note that the records for the "typeperf" process contain meaningful values.
