Link to home
Start Free TrialLog in
Avatar of david_32
david_32

asked on

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

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
Avatar of Jim P.
Jim P.
Flag of United States of America image

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?
Avatar of david_32
david_32

ASKER

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
//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");
}
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?
ASKER CERTIFIED SOLUTION
Avatar of Jim P.
Jim P.
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial