Monday, November 14, 2011

Batch file to start performance counters on system startup

Create folder on the c: drive
copy 7za.exe to c:\perflogs
open perfmon and create the counters you wish to use
Add each counter name you created to the batch code under
:logmans in this format logman start countername

Create a schedule task that will run the created batch file at system startup
On reboot all csv files will be added to a zip file called performance{date}.zip
Then performance counters will be started.

REM Tony Unger
REM 8/26/2011
REM Initial Release 1.0
REM This batch file that compress all file in the c:\perflog directory to
performance%date:~4,2%%date:~7,2%%date:~10, then purges all the old entries
rem then it starts the performance log again
7za.exe a -tzip c:\perflogs\performance%date:~4,2%%date:~7,2%%date:~10, c:\perflogs\*.csv
if exist c:\perflogs\performance%date:~4,2%%date:~7,2%%date:~10, goto PurgeOldRecords
del *.blg
del *.csv
goto logmans
logman start DiskSpace
logman start Memory
logman start CPU
logman start SQLMemory
go to exit

No comments:

Post a Comment