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.cmd

REM Stop the performance monitoring service
monitor \\DBserver stop
REM Perform NTFS compression on the perf log
compact /c d:\PerfData\NT03Perf.log
REM 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.log
REM Re-start the performance monitoring service
monitor \\DBServer start

RenameAppendDate.vbs

Please see the generic script entitled "Rename/move file with date appended between filename and file extension".


Adding this job to the scheduler

AT 11:59PM /EVERY:M,T,W,Th,F,S,Su "D:\Scheduled\SwitchPMLog.cmd"