Advertisement

05.14.2008 at 03:12PM PDT, ID: 23403375
[x]
Attachment Details

VBSCRIPT GetWMIPercent MSSQLSERVER call fails 0x80041010

Asked by paultormey in VB Script, MS SQL Server

Tags: Microsoft, SQL Server, 2000, GetWMIPercent("Win32_PerfRawData_MSSQLSERVER_SQLServerBufferManager

Sql server 2000 standard edition at SP3.

Using VBSCRIPT to extract WMI details and call to the SQL object fails with error '0x80041010'

Here is the line of code that fails:
strOutput = strOutput & CheckReverseValue(GetWMIPercent("Win32_PerfRawData_MSSQLSERVER_SQLServerBufferManager","@","Buffercachehitratio","Buffercachehitratio_Base"),"Buffer Cache Hit Ratio",iBufferCacheHitRatioWarn, iBufferCacheHitRatioAlarm)

Just before this we do 3 other WMI calls that work, here is one of them:
strOutput = strOutput & CheckValue(GetWMIPercent("Win32_PerfRawData_PerfDisk_PhysicalDisk.Name","""" & DiskInstance.Name & """","PercentDiskReadTime","PercentDiskReadTime_Base"),DiskInstance.name & " % Disk Read Time",iPerDiskReadTimeWarn,iPerDiskReadTimeAlarm)  

Start Free Trial
[+][-]05.14.2008 at 03:43PM PDT, ID: 21569309

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.14.2008 at 04:18PM PDT, ID: 21569479

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]05.14.2008 at 05:12PM PDT, ID: 21569724

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.14.2008 at 05:23PM PDT, ID: 21569774

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: VB Script, MS SQL Server
Tags: Microsoft, SQL Server, 2000, GetWMIPercent("Win32_PerfRawData_MSSQLSERVER_SQLServerBufferManager
Sign Up Now!
Solution Provided By: RobSampson
Participating Experts: 1
Solution Grade: B
 
 
[+][-]05.14.2008 at 05:40PM PDT, ID: 21569831

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.14.2008 at 05:51PM PDT, ID: 21569855

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.14.2008 at 06:36PM PDT, ID: 21570036

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.14.2008 at 06:39PM PDT, ID: 21570051

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.14.2008 at 07:31PM PDT, ID: 21570246

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.14.2008 at 07:46PM PDT, ID: 21570328

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.14.2008 at 07:50PM PDT, ID: 21570351

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.14.2008 at 07:52PM PDT, ID: 21570359

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.14.2008 at 07:55PM PDT, ID: 21570373

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.16.2008 at 04:50PM PDT, ID: 21587253

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.28.2008 at 06:22PM PDT, ID: 21665650

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • Automotive
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Displays / Monitors
  • Handhelds / PDAs
  • Components
  • Peripherals
  • Laptops/Notebooks
  • Servers
  • Misc
  • Apple
  • Embedded Hardware
  • Networking Hardware
  • Storage
  • Desktops
  • New Users
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMware
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Virtualization
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • Web Computing
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Consulting
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMware
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Automation
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Web Services
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Web Computing
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Lounge
  • Business Travel
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
  • Automotive
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
05.14.2008 at 03:43PM PDT, ID: 21569309
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
'==========================================================================
'
' VBScript Source File 
'
' NAME: bb-sqlserver.vbs
'
' AUTHOR: Oliver Bassett , gen-i
' DATE  : 20/09/2003
'
' MODIFIED: Paul Tormey, Fisher & Paykel Appliances
' Installed on MAO in "C:\Program Files\Hobbit Monitor Feed\bb-sqlserver.vbs"
'
' COMMENT:  This script will check a range or parameters in SQL server
'           via it's windows performance counters using WMI. It will then Warn
'           or Alarm as configured and report the information back to the 
'           configured Big Brother Server. You require the Big Brother client
'           to be already installed.
'
' NOTES: You may need to change the extPath setting which currently tries
'		to read the Professional Edition Client Reg Key.
'
' LICENSE: 
' Copyright (c) 2003, Gen-i Limited
' All rights reserved.
'
' Redistribution and use in source and binary forms, with or without 
' modification, are permitted provided that the following conditions are met:
'
' 	- 	Redistributions of source code must retain the above copyright notice, 
'		this list of conditions and the following disclaimer. 
'	-	Redistributions in binary form must reproduce the above copyright notice, 
'		this list of conditions and the following disclaimer in the documentation 
'		and/or other materials provided with the distribution. 
' 	-	Neither the name of Gen-i Limited nor the names of its contributors 
'		may be used to endorse or promote products derived from this software without 
'		specific prior written permission. 
'
' THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
' EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 
' OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
' SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
' SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
' OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
' HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 
' TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
' EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
'
' VERSION HISTORY:
'					0.1		-	Initial Release
'					0.2		-	Fixed UserConnections which were using the settings from
'								Deadlocks rather than their own Warn/Alarm values
'								Thanks to Erik Damsgaard, CSC Managed Web Services
'								For pointing this out
'==========================================================================
 
strAlarmState = "green"
strTestName = "MAO"
'Physical Disk Settings
    '% Disk Read Time
    iPerDiskReadTimeWarn=5
    iPerDiskReadTimeAlarm=10
    '% Disk Write Time
    iPerDiskWriteTimeWarn=5
    iPerDiskWriteTimeAlarm=10
    'Current Disk Queue Length
    iCurDiskQueueLengthWarn=10
    iCurDiskQueueLengthAlarm=20
 
'SQL Buffer Cache Hit Ratio
    iBufferCacheHitRatioWarn=90
    iBufferCacheHitRatioAlarm=85
'SQL Lock Timeouts /sec
    iLockTimeoutsWarn=50
    iLockTimeoutsAlarm=100   
'SQL Dead Locks /sec
    iDeadLocksWarn=2
    iDeadLocksAlarm=5
    
'User Connections
	iUserConnectionsWarn=30
	iUserConnectionsAlarm=70
    
'SQL Data and Log Files (KB)
'These settings are stored in an associative array per database and then all these 
'associative arrays are stored in a Main one.
'To add a new set of database logs to be monitored:
'1. Create an Associative Array for it: Set a[DatabaseName]DatabaseSetting = CreateObject("scripting.dictionary")
'2. Add the warning and alarm levels for the monitoring: a[DatabaseName]DatabaseSetting.add "DataFileWarn", 10000
'   The above will add a warning for the Data file and set it at 10000KB.
'   You will need to add warnings and alarms for both the data file and the log file.
'3. Next you need to add this to the main array. 
'   The format is: aSQLDataFileSettings.add "[DatabaseName]", a[DatabaseName]DatabaseSetting
'
' Thats it, it should just work now.
 
 
' Master Database Settings
Set aMasterDatabaseSetting = CreateObject("scripting.dictionary")
aMasterDatabaseSetting.add "DataFileWarn", 15000
aMasterDatabaseSetting.add "DataFileAlarm", 20000
aMasterDatabaseSetting.add "LogFileWarn", 2000
aMasterDatabaseSetting.add "LogFileAlarm", 4000
 
' Model Database Settings
Set aModelDatabaseSetting = CreateObject("scripting.dictionary")
aModelDatabaseSetting.add "DataFileWarn", 15000
aModelDatabaseSetting.add "DataFileAlarm", 20000
aModelDatabaseSetting.add "LogFileWarn", 2000
aModelDatabaseSetting.add "LogFileAlarm", 4000
 
'Main Array
SET aSQLDataFileSettings = CreateObject("scripting.dictionary")
aSQLDataFileSettings.add "master", aMasterDatabaseSetting
aSQLDataFileSettings.add "model", aModelDatabaseSetting
 
 
Const EVENT_SUCCESS = 0
 
strOutput   = ""
Set ws = WScript.CreateObject("WScript.Shell")
extPath = ws.RegRead("HKLM\SOFTWARE\Quest Software\BigBrother\bbnt\ExternalPath\")
Set objShell = Wscript.CreateObject("Wscript.Shell")
 
' ========================================
' Main Code Starts Here
 
'Physical Disk
Set colDisk = GetObject("winmgmts:").InstancesOf("Win32_PerfRawData_PerfDisk_PhysicalDisk")
strOutput = strOutput & vbcrlf &"Physical Disk Information:" & vbCrLf
 
' Write Events to the Local Event Log
 
objShell.LogEvent EVENT_SUCCESS, _
    "bb-sqlserver Hobbit feeder"
 
For each DiskInstance in ColDisk
    '% Disk Read Time
    strOutput = strOutput & CheckValue(GetWMIPercent("Win32_PerfRawData_PerfDisk_PhysicalDisk.Name","""" & DiskInstance.Name & """","PercentDiskReadTime","PercentDiskReadTime_Base"),DiskInstance.name & " % Disk Read Time",iPerDiskReadTimeWarn,iPerDiskReadTimeAlarm)   
    '% Disk Write Time
    strOutput = strOutput & CheckValue(GetWMIPercent("Win32_PerfRawData_PerfDisk_PhysicalDisk.Name","""" & DiskInstance.Name & """","PercentDiskWriteTime","PercentDiskWriteTime_Base"),DiskInstance.name & " % Disk Write Time",iPerDiskWriteTimeWarn,iPerDiskWriteTimeAlarm)
    'Current Disk Queue Length
    strOutput = strOutput & CheckValue(GetWMIValue("Win32_PerfRawData_PerfDisk_PhysicalDisk.Name","""" & DiskInstance.Name & """","CurrentDiskQueueLength"),DiskInstance.name & " Current Disk Queue Length",iCurDiskQueueLengthWarn,iCurDiskQueueLengthAlarm)
Next
 
' SQL Server
strOutput = strOutput & vbcrlf & "SQL Server Information:" & vbcrlf
'Buffer Cache Hit Ration
strOutput = strOutput & CheckReverseValue(GetWMIPercent("Win32_PerfRawData_MSSQLSERVER_SQLServerBufferManager","@","Buffercachehitratio","Buffercachehitratio_Base"),"Buffer Cache Hit Ratio",iBufferCacheHitRatioWarn, iBufferCacheHitRatioAlarm)
'Lock Information
strOutput = strOutput & CheckValue(GetWMIValue("Win32_PerfRawData_MSSQLSERVER_SQLServerLocks.Name","""_Total""","LockTimeoutsPersec"),"Locks Timeouts/sec",iLockTimeoutsWarn, iLockTimeoutsAlarm)
strOutput = strOutput & CheckValue(GetWMIValue("Win32_PerfRawData_MSSQLSERVER_SQLServerLocks.Name","""_Total""","NumberofDeadlocksPersec"),"Number of Deadlocks/sec",iDeadLocksWarn, iDeadLocksAlarm)
'User Connections
strOutput = strOutput & CheckValue(GetWMIValue("Win32_PerfRawData_MSSQLSERVER_SQLServerGeneralStatistics","@","UserConnections"),"Number of User Connections",iUserConnectionsWarn, iUserConnectionsAlarm)
 
'SQL Data and Log Files
Set colDatabases = GetObject("winmgmts:").InstancesOf("Win32_PerfRawData_MSSQLSERVER_SQLServerDatabases")
 
strOutput = strOutput & vbcrlf & "SQL Server Data and Log File Information:" & vbcrlf
For each DatabaseInstance in colDatabases
    If aSQLDataFileSettings.exists(DatabaseInstance.name) then
        'Check Values
        strOutput = strOutput & CheckValue(GetWMIValue("Win32_PerfRawData_MSSQLSERVER_SQLServerDatabases","""" & DatabaseInstance.name & """","DataFilesSizeKB"),DatabaseInstance.name & vbTab & "Data File Size(KB)",aSQLDataFileSettings.item(DatabaseInstance.name).item("DataFileWarn"), aSQLDataFileSettings.item(DatabaseInstance.name).item("DataFileAlarm"))
        strOutput = strOutput & CheckValue(GetWMIValue("Win32_PerfRawData_MSSQLSERVER_SQLServerDatabases","""" & DatabaseInstance.name & """","LogFilesSizeKB"),DatabaseInstance.name & vbTab & "Log File Size(KB)",aSQLDataFileSettings.item(DatabaseInstance.name).item("LogFileWarn"), aSQLDataFileSettings.item(DatabaseInstance.name).item("LogFileAlarm"))
        strOutput = strOutput & vbcrlf
    elseif DatabaseInstance.Name = "_Total" then
        ' Skipping Display of Totals at this stage. May re-add later
        
        ' strOutput = strOutput & vbcrlf & "Total Data File Size:" & vbTab & GetWMIValue("Win32_PerfRawData_MSSQLSERVER_SQLServerDatabases.Name","""" & DatabaseInstance.name & """","DataFilesSizeKB") & vbcrlf
        ' strOutput = strOutput & vbcrlf & "Total Log File Size:" & vbTab & GetWMIValue("Win32_PerfRawData_MSSQLSERVER_SQLServerDatabases.Name","""" & DatabaseInstance.name & """","LogFilesSizeKB") & vbcrlf
    else
        ' Write Data Information Directly Out without running the Value Check
        ' Datafile
        strOutput = strOutput & "&clear" & " " & DatabaseInstance.name & vbTab & "Data File Size(KB)" & ":" & vbTab & GetWMIValue("Win32_PerfRawData_MSSQLSERVER_SQLServerDatabases.Name","""" & DatabaseInstance.name & """","DataFilesSizeKB") & vbcrlf
        ' Logfile
        strOutput = strOutput & "&clear" & " " & DatabaseInstance.name & vbTab & "Log File Size(KB)" & ":" & vbTab & GetWMIValue("Win32_PerfRawData_MSSQLSERVER_SQLServerDatabases.Name","""" & DatabaseInstance.name & """","LogFilesSizeKB") & vbcrlf
        strOutput = strOutput & vbcrlf
    end if
Next
 
 
' Write the file for BB
WriteFile extPath, strTestName, strAlarmState, strOutput
 
'===========================================================
' FUNCTIONS and SUBS start here
 
' This is used to get a percentage value from WMI. It requires the value and the base objects.
' It then returns the percentage
FUNCTION GetWMIPercent(strCollection,strInstance,strObject,strBaseObject)
' Write Events to the Local Event Log
 
objShell.LogEvent EVENT_SUCCESS, _
    "bb-sqlserver Hobbit feeder: " & vbCrLf & "strCollection = " & strCollection & vbCrLf & "strInstance = " & strInstance
 
    SET counterCollection = GETOBJECT("winmgmts:" & strCollection & "=" & strInstance)
    FOR EACH cntproperty IN counterCollection.properties_
        IF cntproperty.name = strObject THEN
            iObjectValue = cntproperty
        ELSEIF cntproperty.name = strBaseObject THEN
            iObjectBaseValue = cntproperty
        END IF
    NEXT
    GetWMIPercent = ROUND(CDBL(iObjectValue) / CDBL(iObjectBaseValue) * CDBL(100),0)
END FUNCTION
 
' This is used to pull a value from WMI.
FUNCTION GetWMIValue(strCollection,strInstance,strObject)
    Set counterCollection = GetObject("winmgmts:" & strCollection & "=" & strInstance)
    FOR EACH cntproperty IN counterCollection.properties_
        IF cntproperty.name = strObject THEN
            iObjectValue = cntproperty
        END IF
    NEXT
    GetWMIValue = iObjectValue
END FUNCTION
 
' This is used to check the actual value against the warning and alarm.
FUNCTION CheckValue(iObjectValue,strObjectDesc,iWarnValue,iAlarmValue) 
    IF iWarnValue > iAlarmValue THEN
        CheckValue = "&red" & " " & strObjectDesc & ":" & vbTab & "Object is Misconfigured"
        IF strAlarmState <> "red" THEN
            strAlarmState = "red"
        END IF
    ELSE
        IF iObjectValue > iWarnValue THEN
            IF iObjectValue > iAlarmValue THEN
                CheckValue = "&red" & " " & strObjectDesc & ":" & vbTab & iObjectValue & vbcrlf
                SetAlarmStatus  "red"
            ELSE
                CheckValue = "&yellow" & " " & strObjectDesc & ":" & vbTab & iObjectValue & vbcrlf
                SetAlarmStatus "yellow"
            END IF
        ELSE
            CheckValue = "&green" & " " & strObjectDesc & ":" & vbTab & iObjectValue & vbcrlf
        END IF
    END IF
END FUNCTION
 
' This is used to check the actual value against the warning and alarm.
' This one the alarm will be a lower value than the warning. (Values Decrease rather than increase)
FUNCTION CheckReverseValue(iObjectValue,strObjectDesc,iWarnValue,iAlarmValue) 
    IF iWarnValue < iAlarmValue THEN
        CheckReverseValue = "&red" & " " & strObjectDesc & ":" & vbTab & "Object is Misconfigured"
        IF strAlarmState <> "red" THEN
            strAlarmState = "red"
        END IF
    ELSE
        IF iObjectValue < iWarnValue THEN
            IF iObjectValue < iAlarmValue THEN
                CheckReverseValue = "&red" & " " & strObjectDesc & ":" & vbTab & iObjectValue & vbcrlf
                SetAlarmStatus  "red"
            ELSE
                CheckReverseValue = "&yellow" & " " & strObjectDesc & ":" & vbTab & iObjectValue & vbcrlf
                SetAlarmStatus "yellow"
            END IF
        ELSE
            CheckReverseValue = "&green" & " " & strObjectDesc & ":" & vbTab & iObjectValue & vbcrlf
        END IF
    END IF
END FUNCTION
 
 
' This is called to set the overall alarm status.
SUB SetAlarmStatus(strnewAlarmState)
    IF strnewAlarmState = "red" THEN
        strAlarmState = strnewAlarmState
    ELSEIF strnewAlarmState = "yellow" THEN
        IF strAlarmState <> "red" THEN
            strAlarmState = strnewAlarmState
        END IF
    END IF
END SUB
 
 
' This SUB is used for outputting the file to the external's directory in bb
SUB WriteFile(strExtPath, strTestName, strAlarmState, strOutput)
    Set fso = CreateObject("Scripting.FileSystemObject")	
    strOutput = strAlarmState & " " & Date & " " & Time & vbcrlf & vbcrlf & strOutput & vbcrlf
    Set f = fso.OpenTextFile(strExtPath & "\" & strTestName , 8 , TRUE)
    f.Write strOutput
    f.Close
    Set fso = Nothing
END SUB
Open in New Window
 
05.14.2008 at 04:18PM PDT, ID: 21569479
Hi, can "instance" be "@"?

Use Scriptomatic to enumerate the "Win32_PerfRawData_MSSQLSERVER_SQLServerBufferManager" class and see if there is an entry with "@" as the instance name....

Regards,

Rob.
Assisted Solution
 
05.14.2008 at 05:12PM PDT, ID: 21569724
Thanks Rob,

But even if I remove that particular line of code it fails on the next extraction of LockTimeoutsPersec.

So I commented out the code until:
   "For each DatabaseInstance in colDatabases..."
Now that fails. Looks as if any reference to any MSSQLServer objects fails.

any idea?
 
05.14.2008 at 05:23PM PDT, ID: 21569774
I'm not sure if Win32_PerfRawData_MSSQLSERVER_SQLServerDatabases will give you the database instances.....check WBEMTest or Scriptomatic to enumerate that class and see if the database instances are listed...

Here is one way of enumerating instances, via the registry:

                    strServerName = "mysqlserver"
                    Set objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!" & strServerName & "\root\default:StdRegProv")
                      strKeyPath = "SOFTWARE\Microsoft\Microsoft SQL Server"
                      strValueName = "InstalledInstances"
                      objRegistry.GetMultiStringValue HKEY_LOCAL_MACHINE,strKeyPath, strValueName,arrValues
                        If IsNull(arrValues) = 0 Then 'It's a SQL Server! Enumerate it's instances
                          strMsg = strServerName & " is running the following SQL Instance(s): "
                          For Each strValue In arrValues
                              If strValue = "MSSQLSERVER" Then strValue = "Default Instance"
                                strMsg = strMsg & vbCrLf & strValue
                          Next
                          MsgBox strMsg
                        End If
                     Set objRegistry = Nothing


Regards,

Rob.
Accepted Solution
 
05.14.2008 at 05:40PM PDT, ID: 21569831
Hi Rob,

I followed the advice on http://www.computerperformance.co.uk/vbscript/wmi_wbemtest.htm
and still get this error when running against the "Win32_PerfRawData_MSSQLSERVER_SQLServerBufferManager" class.
When I use WBEMTEST
Number: 0x80041010
Facility: WMI
Description: Invalid class

When I run against class "Win32_PerfRawData_PerfDisk_PhysicalDisk" I get back correct info.

I'll play a bit longer with WBEMTEST and see where I get.

Still think that something is wrong with the MSSQLSERVER classes...
 
05.14.2008 at 05:51PM PDT, ID: 21569855
On my SQLServer 2000 machine, when I run Scriptomatic against Win32_PerfRawData_MSSQLSERVER_SQLServerBufferManager it gives me results, with not error....

Rob.
 
05.14.2008 at 06:36PM PDT, ID: 21570036
Hi Rob,

Thanks for that info...as I suspected looks as if the class provider is not registered!

Went to another of our development servers and the MSSQLSERVER classes are available there.

Now I just need to see how I repair the above class.

 
05.14.2008 at 06:39PM PDT, ID: 21570051
 
05.14.2008 at 07:31PM PDT, ID: 21570246
Okay...found some constructive info.

Thanks for your pointer to WBEMTEST and also information found at http://www.computerperformance.co.uk/vbscript/index.htm

What I've found using WBEMTEST is that on my initial dev server we don't have class
"win32_PerfRawData_MSSQLSERVER_SQLServerBufferManager".

We do have "Win32_PerfRawData_MSSQLDTC_MSSQLDTCBufferManager".

Looks as if these values must have been derived during the MS SQL Server installation.


 
05.14.2008 at 07:46PM PDT, ID: 21570328
Hmm. OK, hopefully a re-install of SQL Server isn't required......but I'm not sure.....
 
05.14.2008 at 07:50PM PDT, ID: 21570351
No, not this time round. As the utility is destined for specific prod and dev servers, I will be lazy and code for these 2 instances.

Thanks
Paul
 
05.14.2008 at 07:52PM PDT, ID: 21570359
OK, cool.  Did you MS Artcile about WMIADEM help to rebuild the classes?

Rob.
 
05.14.2008 at 07:55PM PDT, ID: 21570373
Hi Rob,

Didn't rebuild the classes but found that they were loaded with the different names - MSSQLSERVER or MSSQLDTC.

Cheers
Paul
 
05.16.2008 at 04:50PM PDT, ID: 21587253
OK.  So if you have solved your problem, did one of my comments help you, or would you like to make a request that one of you comments be accepted as an answer? You should be able to do that from the menus somewhere.

Regards,

Rob.
 
05.28.2008 at 06:22PM PDT, ID: 21665650
Great!  Thanks for closing the question Paul.

Regards,

Rob.
 
 
20080716-EE-VQP-32 / EE_QW_2_20070628