Software metering provides the server-side SMS_FileUsageSummary WMI class, which is created to hold periodic summary information for metered files.

An instance of SMS_FileUsageSummary provides information about the number of distinct users, the summary period start time, and the interval width of the summary. There are two different interval widths: 15 minutes and 60 minutes. Each interval width keeps track of the distinct user/computer combinations that were using the file during that period. The 15 minute interval widths are particularly useful because they are the closest approximation to concurrent usage.

Other classes are required for extracting further information from SMS_FileUsageSummary. For example, the SMS_MeteredFiles object provides the summarized file name from the FileID property in SMS_FileUsageSummary.

The following script obtains file usage summary data and shows how instances of SMS_FileUsageSummary can be read.

For additional information about using file usage summary data in WMI, see the SMS 2003 SDK.

Example

On Error Resume Next

Dim Services
Dim ProviderLoc
Dim Location

Dim strMeteredFilesClass
Dim strClass
Dim colMeteredFiles
Dim colFileUsageSummary
Dim objSummariedFile
Dim objMeteredFile

strMeteredFilesClass="SMS_MeteredFiles"
strClass="SMS_FileUsageSummary"

Set ProviderLoc = GetObject("winmgmts:{impersonationLevel=impersonate}!root/sms:SMS_ProviderLocation")

If err.number<>0 Then
	wscript.echo "Couldn't get SMS Provider"
	wscript.quit
End If

For Each Location In ProviderLoc.Instances_
	 If Location.ProviderForLocalSite = True Then
		Set Services = GetObject("winmgmts:" & Location.NamespacePath)
		Exit For
	End If
Next

'Get SMS_MeteredFiles--used to match FileID to a file name.

Set colMeteredFiles=Services.InstancesOf(strMeteredFilesClass)

If err.number<>0 Then
	wscript.echo "Couldn't get Metered Files"
	wscript.quit
End If

'Get the summarized files.

Set colFileUsageSummary = Services.InstancesOf(strClass)
If err.number<>0 Then
	wscript.echo "Couldn't get Summarized files"
	wscript.quit
End if

For Each objSummariedFile In colFileUsageSummary

	For Each objMeteredFile In colMeteredFiles

		If objMeteredFile.MeteredFileID=objSummariedFile.FileID Then
			wscript.echo "File Name:" & objMeteredFile.FileName
			Exit For 
		End If
	Next
	wscript.echo "File ID:" & objSummariedFile.FileID
	wscript.echo "Distinct User Count:" & objSummariedFile.DistinctUserCount
	wscript.echo "Interval Start:" & objSummariedFile.IntervalStart
	wscript.echo "Interval Width:" & objSummariedFile.IntervalWidth
	wscript.echo "Site Code:" & objSummariedFile.SiteCode

	wscript.echo
Next

Compiling the Code

  • Requires Windows 2000 Server SP2 or later.

  • Requires an SMS 2003 Site Server.

See Also