Solved

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

Posted on 2008-09-29
8
1,278 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Viewers will learn the different options available in the Backstage view in Excel 2013.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…

717 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