Back to Scripting | Manage MONITOR Service performance logs
These scripts manage the performance data logs generated by the MONITOR service. Performance logs will simply continue to grow if the MONITOR service is simply turned on and never turned off. This particular job stops the MONITOR service on the local host (thus unlocking the perf log file), compresses the file using NTFS compression, moves/renames the perf log with by appending a date stamp to the file name, then restarts the MONITOR service (which creates a new file with the original name). (Please see the article on monitoring for information on the MONITOR service.)
This script below assumes that the MONITOR service will be run continuously, thus requiring the performance logs to be "switched" nightly. Alternatively, the CMD file could be constructed such that it starts the MONITOR service, and uses SOON to schedule another CMD file that will stop the MONITOR service and rename the performance log file. This approach would be more appropriate if the MONITOR service only needed to be run from 8 a.m until 5 p.m, or only on demand.
SwitchPMLog.cmdREM Stop the performance monitoring servicemonitor \\DBserver stopREM Perform NTFS compression on the perf logcompact /c d:\PerfData\NT03Perf.logREM Run the VBscript to rename the perf log with a date stamp.cscript d:\SharedScripts\RenameAppendDate.vbs d:\PerfData\NT03Perf.log d:\PerfData\Offline\NT03Perf.logREM Re-start the performance monitoring servicemonitor \\DBServer startRenameAppendDate.vbs
Please see the generic script entitled "Rename/move file with date appended between filename and file extension".
Adding this job to the schedulerAT 11:59PM /EVERY:M,T,W,Th,F,S,Su "D:\Scheduled\SwitchPMLog.cmd"