Tuesday, February 28, 2012

Error installing SQL Server 2005 on a Server with Multicore Processor

A counterpart had flagged out that he has hit a roadblock while setting up SQL 2005 server in a clustered environment.
An error as below was found when the installation failed

The SQL Server service failed to start. For more information, see the SQL Server Books Online topics, "How to: View SQL Server 2005 Setup Log Files" and "Starting SQL Server Manually."

It was found that is an issue related to the number of cores in a CPU
The below was done to work around the issue on Windows 2003  and complete the installation

1.            To change the number of logical processors in Windows Server 2003, follow these steps:
a.            Click Start, click Run, type msconfig, and then click OK.
b.            In the System Configuration Utility dialog box, click the BOOT.INI tab.
c.             On the BOOT.INI tab, click Advanced Options.
d.            In the BOOT.INI Advanced Options dialog box, click to select the /NUMPROC= check box.
e.            In the list that is next to the /NUMPROC= check box, click 1, and then click OK.
f.             In the System Configuration Utility dialog box, click OK.
2.            Restart the server.
3.            Install SQL Server 2005.
4.            Install the latest service pack for SQL Server 2005.
5.            Restart the server by using all the processors. To do this, follow these steps:
a.            Click Start, click Run, type msconfig, and then click OK.
b.            In the System Configuration Utility dialog box, click the General tab.
c.             On the General tab, click Normal Startup - load all device drivers and services, and then clickOK.
d.            Restart the server.

More information of methods of workaround can be found in this KB from Microsoft

Wednesday, February 22, 2012

Retrieving SCOM monitor thresholds by Powershell

Part of managing the SCOM infrastructure will include knowing what thresholds are being configured for the countless monitors that are available from the many Management Packs that comes from Microsoft or other vendors.
To compile all these thresholds tying them to their respective counters and monitors proves to be a challenge.
There is some powershell cmdlets that are provided on the Microsoft Site that enables us to do that but the thresholds suck as “Logical Disk Free Space” does not appear in the exported CSV.
The result will be something as per the format in the screenshot below


I have made some amendments to the cmdlet to provide this as below.
Other thresholds that are missing can be added by getting the information of the tag from the management pack xml or using the SCOM Management Pack Authoring console that can be downloaded from http://www.microsoft.com/download/en/details.aspx?id=18222. (Example of the tag for the threshold I added for logical Disk Free Space is as the screenshot below)


PowerShell Cmdlet (To use copy the entire contents and save it as <your filename>.ps1

    function GetThreshold ([String] $configuration)
    {
    $config = [xml] ("<config>" + $configuration + "</config>")
    $threshold = $config.Config.Threshold
    if($threshold -eq $null)
   {
    $threshold = $config.Config.MemoryThreshold
    }
    if($threshold -eq $null)
    {
    $threshold = $config.Config.CPUPercentageThreshold
    }
    if($threshold -eq $null)
    {
    if($config.Config.Threshold1 -ne $null -and $config.Config.Threshold2 -ne $null)
    {
                    $threshold = "Error threshold is: " + $config.Config.Threshold1 + " Warning threshold is: " + $config.Config.Threshold2
    }
    }
    if($threshold -eq $null)
    {
    if($config.Config.ThresholdWarnSec -ne $null -and $config.Config.ThresholdErrorSec -ne $null)
    {
     $threshold = "warning threshold is: " + $config.Config.ThresholdWarnSec + " error threshold is: " + $config.Config.ThresholdErrorSec
    }
    }
if($threshold -eq $null)
{
if($config.Config.SystemDriveErrorPercentThreshold -ne $null -and $config.Config.SystemDriveErrorMBytesThreshold -ne $null -and $config.Config.NonSystemDriveErrorMBytesThreshold -ne $null -and $config.Config.SystemDriveWarningPercentThreshold -ne $null)
{
$threshold = "System Drive Error/Warning(%) is: " + $config.Config.SystemDriveErrorPercentThreshold + "% / " + $config.Config.SystemDriveWarningPercentThreshold + "% System Drive Error/Warning (MB) threshold is: " + $config.Config.SystemDriveErrorMBytesThreshold + "%/ " + $config.Config.SystemDriveWarningMBytesThreshold + ". " + "Non-System Drive Error/Warning (%) is : " + $config.Config.NonSystemDriveErrorPercentThreshold + "% / " + $config.Config.SystemDriveWarningPercentThreshold + "%. " + "% Non-System Drive Error/Warning (MB) threshold is: " + $config.Config.NonSystemDriveErrorMBytesThreshold + "%/ " + $config.Config.NonSystemDriveWarningMBytesThreshold
}
}
    if($threshold -eq $null)
    {
     if($config.Config.LearningAndBaseliningSettings -ne $null)
     {            
      $threshold = "no threshold (baseline monitor)"
    }
    }
    return $threshold
    }
Function GetFrequency ([String] $configuration)
{
$config = [xml] ("<config>" + $configuration + "</config>")
$Frequency = $config.Config.Frequency
if($Frequency -eq $null)
{
$frequency = $config.Config.Frequency;
}
 return ($frequency)
}
Function GetNumsamples ([String] $configuration)
{
$config = [xml] ("<config>" + $configuration + "</config>")
$Samples = $config.Config.Samples
if($Samples -eq $null)
{
$Samples = $config.Config.NumSamples;
}
 return ($Samples)
}
Function GetCounterName ([String] $configuration)
{
$config = [xml] ("<config>" + $configuration + "</config>")
$Counter = $config.Config.Counter
if($Counter -eq $null)
{
$Counter = $config.Config.CounterName;
}
 return ($Counter)
}
Function GetObject ([String] $configuration)
{
$config = [xml] ("<config>" + $configuration + "</config>")
$Object = $config.Config.Object
if($Object -eq $null)
{
$Object = $config.Config.ObjectName;
}
 return ($Object)
}

    $perfMonitors = get-monitor -Criteria:"IsUnitMonitor=1"

$perfMonitors | select-object @{Name="MP";Expression={ foreach-object {$_.GetManagementPack().DisplayName }}},@{name="Target";expression={foreach-object {(Get-MonitoringClass -Id:$_.Target.Id).DisplayName}}},DisplayName,enabled,@{name="Threshold";expression={foreach-object {GetThreshold $_.Configuration}}}, @{name="Frequency";expression={foreach-object {GetFrequency $_.Configuration}}}, @{name="Samples";expression={foreach-object {GetNumSamples $_.Configuration}}}, @{name="Counter";expression={foreach-object {GetCounterName $_.Configuration}}}, @{name="Object";expression={foreach-object {GetObject $_.Configuration}}} | sort Target, DisplayName | export-csv "c:\temp\monitor_thresholds.csv"

Thursday, February 16, 2012

Tracking IM usage in OCS 2007 R2

I could not find something generic that comes out of the box from Microsoft to perform retrieve the usage of Instant Messaging by users in my infrastructure setup for some auditing purposes.
The below is a little SQL query which I have written for the purpose to share.



A sample screenshot of the output is as below



 Declare  @user varchar(50)
Declare @ startdate,@enddate datetime

'Replace usersip with your user's SIP address
Set @user = 'usersip'
'Replace mm/dd/yyyy with appropriate dates
set @startdate = 'mm/dd/yyyy'
set @enddate = 'mm/dd/yyyy'

SELECT [SessionIdTime] as 'StartDate'
        ,[SessionEndTime] as 'EndDate'
      ,user1.UserUri as User1
      ,user2.UserUri as User2
      ,[User1MessageCount]
      ,[User2MessageCount]
     
  FROM SessionDetails

  left join dbo.Users user1 on user1.UserId = User1Id
  left join dbo.Users user2 on user2.UserId = User2Id

Where (datediff(hh, convert(date,SessionIdTime),@enddate)< datediff(hh,@startdate,  @enddate)) and user1.UserUri in (@user)