Solved

operations manager error with sql server in event log: GetSQL2005DBspace.js: 0

Posted on 2008-09-29
8
1,264 Views
Last Modified: 2008-11-01
Hi Folks,

I have a SQL Server 2005 Standard 64 bit machine which is monitored by SCOM 2007. The SCOM Agent is version 6.0.6278.0.

I am continously getting these errors in the event log:

Source Health Service Script
EventID:4000
 GetSQL2005DBSpace.js:0

It appears sqldmo.dll has been registered because I have found sqldmo.dll in the registry. The version of the dll is 2000.85.2004.0

Does anyone have any advice here? I believe I can run the  GetSQL2005DBSpace.js script manually to get more info - does anyone know how to do that
0
Comment
Question by:david_32
  • 3
  • 2
8 Comments
 
LVL 38

Expert Comment

by:Jim P.
ID: 22624044
I have no experience with SCOM so just throwing this out there from a quick google:

JS extensions indicate java script.

Is JS enabled on the server? On SQL?

Is the SCOM agent running under an account that has permissions to the SQL Server?

Can you read the javascript and post it here?

Are you patched with everything?
0
 

Author Comment

by:david_32
ID: 22639741
As far as WSUS is concerned we are patched with everything but I sent the sqldmo.dll version in case someone new if there was an update to that. I will check those other things.. ta
0
 

Author Comment

by:david_32
ID: 22647324
//Copyright (c) Microsoft Corporation. All rights reserved.

// Arguments (1)
// Arg 0: SQL Connection String

// Outputs a property bag for each database containing DB and Log Free space in MB and Percentage


var ScriptName = "Get SQL 2005 Database Space";

// Failure Conditions
var SCRIPT_ARG_FAILURE = -1;
var SCRIPT_ARG_FAILURE_MSG = "Invalid arguments passed to script";
var SQL_CONNECT_FAILURE = -2;
var SQL_CONNECT_FAILURE_MSG = "Could not connect to SQL";
var SQL_QUERY_FAILURE = -3;
var SQL_QUERY_FAILURE_MSG = "Failed to query databasize size information";
var SQL_DBLIST_FAILURE = -4;
var SQL_DBLIST_FAILURE_MSG = "Failed to enumerate databases";
var OPSMGR_API_FAILURE = -5;
var OPSMGR_API_FAILURE_MSG = "Failed to create Operations Manager scripting API object";

// Datbase States
var DB_EMERGENCYMODE = 32768
var DB_LOADING = 22
var DB_NORMAL = 0
var DB_OFFLINE = 512
var DB_RECOVERING = 192
var DB_STANDBY = 1024
var DB_SUSPECT = 256


var ScriptArgs = WScript.Arguments;

if (ScriptArgs.Length == 1)
{
      GetDBSize(ScriptArgs(0));
}

function GetDBSize(SQLConnectionString)
{
      var SQLServer;
      try
      {
            SQLServer = GetDMOServer(SQLConnectionString);
      }
      catch (e)
      {
            PrintError(e);
            FailScript(e, SQL_CONNECT_FAILURE_MSG);
      }

      var opsmgrAPI;
      try
      {
            opsmgrAPI = new ActiveXObject("MOM.ScriptAPI");
      }
      catch (e)
      {
            PrintError(e);
            FailScript(e, OPSMGR_API_FAILURE_MSG);
      }
      // This loop runs SQLServer.Databases.Count + the number of deleted databases BETWEEN dbs starting from id 1 to the last
      // database which is not deleted/detached times.
      var delDbCount = 0;
      
      for (i=1; i <= SQLServer.Databases.Count + delDbCount; i++)
      {
            try
            {
                  var currentDB = SQLServer.Databases.ItemByID(i);
            }
            catch (e)
            {
                  // If database is deleted/detached just move to the next
                  delDbCount = delDbCount + 1;
                  continue;

            }


            if ((currentDB.Status == DB_NORMAL ) || (currentDB.Status == DB_STANDBY))
            {
                  var propertyBag = opsmgrAPI.CreateTypedPropertyBag(2);
                  var logSize, logAvailable, dbSize, dbAvailable;
                  logSize = currentDB.TransactionLog.Size;
                  
                  if (logSize < 1)
                  {
                        logAvailable = 0;
                  }
                  else
                  {
                        logAvailable = currentDB.TransactionLog.SpaceAvailableInMB;
                  }

                  dbSize = currentDB.Size - logSize
                  dbAvailable = currentDB.SpaceAvailableInMB - logAvailable
                  propertyBag.AddValue("Database", currentDB.Name);
                  propertyBag.AddValue("TransactionLogSize", logSize);
                  //propertyBag.AddValue("TransactionLogUsed", logSize - logAvailable);
                  propertyBag.AddValue("TransactionLogFree", logAvailable);                  

                  if (logAvailable == 0)
                  {
                        propertyBag.AddValue("TransactionLogPercentFree", 0);
                        //propertyBag.AddValue("TransactionLogUsedPercent", 100 );
                  }
                  else
                  {
                        propertyBag.AddValue("TransactionLogPercentFree", 100 * logAvailable / logSize);
                        //propertyBag.AddValue("TransactionLogUsedPercent", 100 * (logSize - logAvailable) / logSize);
                  }
                  
            
                  if ((currentDB.Name == "tempdb") || (currentDB.Name == "master") || (currentDB.Name == "msdb"))
                  {
                        propertyBag.AddValue("DBSize", dbSize);
                        propertyBag.AddValue("DBFree", 0);
                        propertyBag.AddValue("DBPercentFree", 0);
                  }
                  else
                  {
                        propertyBag.AddValue("DBSize", dbSize);
                        //propertyBag.AddValue("DBUsed", dbSize - dbAvailable);
                        propertyBag.AddValue("DBFree", dbAvailable);
                        propertyBag.AddValue("DBPercentFree", 100 * dbAvailable / dbSize);
                        //propertyBag.AddValue("DBUsedPercent", 100 * (dbSize - dbAvailable) / dbSize);
                  }
                  opsmgrAPI.AddItem(propertyBag);
            }
      }
      opsmgrAPI.ReturnItems();
                  
      SQLServer.Close();
            

}

function GetDMOServer(SQLConnectionString)
{
      if (SQLConnectionString != "")
      {
            var SQLServer = new ActiveXObject("SQLDMO.SQLServer");
            SQLServer.LoginSecure = true;
            SQLServer.Connect(SQLConnectionString);
            return SQLServer;
      }
      else
      {
            return null;
      }
            
}

function FailScript(error, sMessage)
{
  var opsmgrAPI;

  opsmgrAPI = new ActiveXObject("MOM.ScriptAPI");

  opsmgrAPI.LogScriptEvent("GetSQL2005DBSpace.js", 4000, 1, sMessage & ". " & error.m_sDescription);


}


function PrintError(error)
{
    WScript.Echo("============================= BEGIN SCRIPT ERROR =================================\n");
    WScript.Echo("Script Name           : " + ScriptName);
    WScript.Echo("Error Type        : " + error);
    WScript.Echo("Error Number      : " + error.number);
    WScript.Echo("Error Code        : " + (error.number & 0xFFFF));
    WScript.Echo("Win32 Facility    : " + (error.number>>16 & 0x1FFF));
    WScript.Echo("Error Source      : " + error.Source);
    WScript.Echo("Error Description : " + error.description);
    WScript.Echo("============================== END SCRIPT ERROR ==================================\n");
}
0
 

Author Comment

by:david_32
ID: 22647369
I found in a newsgroup that this error could be resolved after updating to MP 6.0.6247.5. How do I know what management pack I am on?
0
 
LVL 38

Accepted Solution

by:
Jim P. earned 500 total points
ID: 22649654
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The canonical version of this article is on my web site here: http://iconoun.com/articles/collisions/ A companion presentation is available here: http://iconoun.com/articles/collisions/Unicode_Presentation.pdf
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now