{"id":127,"date":"2007-01-14T17:04:31","date_gmt":"2007-01-14T15:04:31","guid":{"rendered":"http:\/\/contoso.se\/blog\/?p=127"},"modified":"2007-01-14T17:04:31","modified_gmt":"2007-01-14T15:04:31","slug":"monitor-file-and-directory-size","status":"publish","type":"post","link":"http:\/\/contoso.se\/blog\/?p=127","title":{"rendered":"Monitor file and directory size"},"content":{"rendered":"<p>This script will monitor file and directory size. It will generate performance data back to the management server. You can view this information under performance view in Operators Console or\/and in reports. This first example will monitor the size C:\\pagefile.sys<br \/>\n<code>Set objFSO = CreateObject(\"Scripting.FileSystemObject\")<br \/>\nSet objFile = objFSO.GetFile(\"c:\\pagefile.sys\")<br \/>\nCreatePerfData \"File\",\"File Size\",objFile.Path,objFile.Size<\/code><code>Sub CreatePerfData(strObjectName,strCounterName,strInstanceName,numValue)<br \/>\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 Set objPerfData = ScriptContext.CreatePerfData<br \/>\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 objPerfData.ObjectName = strObjectName<br \/>\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 objPerfData.CounterName =strCounterName<br \/>\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 objPerfData.InstanceName = strInstanceName<br \/>\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 objPerfData.Value = numValue<br \/>\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 ScriptContext.Submit objPerfData<br \/>\nEnd Sub<br \/>\n<\/code><br \/>\nThis example will monitor the size of all subfolders under C:\\\u00c2\u00a0<br \/>\n<code><br \/>\nSet objFSO = CreateObject(\"Scripting.FileSystemObject\")<br \/>\nSet objFolder = objFSO.GetFolder(\"C:\\\")<br \/>\nSet colSubfolders = objFolder.Subfolders<br \/>\nFor Each objSubfolder in colSubfolders<br \/>\nCreatePerfData \"File\",\"File Size\",objSubfolder.Path,objSubfolder.Size<br \/>\nNext<br \/>\nSub CreatePerfData(strObjectName,strCounterName,strInstanceName,numValue)<br \/>\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 \u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 Set objPerfData = ScriptContext.CreatePerfData<br \/>\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 \u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 objPerfData.ObjectName = strObjectName<br \/>\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 \u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 objPerfData.CounterName =strCounterName<br \/>\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 \u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 objPerfData.InstanceName = strInstanceName<br \/>\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 \u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 objPerfData.Value = numValue<br \/>\n\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 \u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 ScriptContext.Submit objPerfData<br \/>\nEnd Sub<br \/>\n<\/code><\/p>\n<ol>\n<li>Insert the script as a new script in Administrator Console<\/li>\n<li>Create a event rule that run the script every X minute<\/li>\n<li>Commit configuration change and wait until the script has run<\/li>\n<li>Open Operator Console, click performance, click you server and choose your new FILE performance objects, click draw graph<\/li>\n<\/ol>\n<p>There is a guide about how to create performance data reports at <a href=\"http:\/\/www.momresources.org\">momresources.org<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This script will monitor file and directory size. It will generate performance data back to the management server. You can view this information under performance view in Operators Console or\/and in reports. This first example will monitor the size C:\\pagefile.sys Set objFSO = CreateObject(&#8220;Scripting.FileSystemObject&#8221;) Set objFile = objFSO.GetFile(&#8220;c:\\pagefile.sys&#8221;) CreatePerfData &#8220;File&#8221;,&#8221;File Size&#8221;,objFile.Path,objFile.SizeSub CreatePerfData(strObjectName,strCounterName,strInstanceName,numValue) \u00c2\u00a0\u00c2\u00a0\u00c2\u00a0 Set objPerfData &hellip; <a href=\"http:\/\/contoso.se\/blog\/?p=127\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[2,13],"tags":[],"_links":{"self":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/127"}],"collection":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=127"}],"version-history":[{"count":0,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/127\/revisions"}],"wp:attachment":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=127"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=127"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=127"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}