Solved

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

Posted on 2008-09-29
8
1,260 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

MS Access 2003 or later To MySQL Migration Project Hello All, this is my second article in the category of MS-OFFICE Automation. In internet I am not able to find any comprehensive resource on the Migration of MS Access back-end to MySQL so I fin…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Viewers will learn the different options available in the Backstage view in Excel 2013.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

707 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

12 Experts available now in Live!

Get 1:1 Help Now