OpsMgr 2007 solution: Console Exception in the UNIX/Linux Servers view–"Value cannot be null"

toolsignI recently worked on this issue and since I didn't see the resulting solution published I thought it would be worth a mention here.

Symptoms

In this scenario, the Operations Manager 2007 R2 Cross Platform Agent with Cumulative Update 2 had been deployed to several Redhat Enterprise Linux servers.  Following the deployment, while checking the Health of the servers through the UNIX/Linux Servers view in the Administration Pane of the console the following error was received:

Value cannot be null
Parameter name: key

The following information was gathered when the operation was attempted.  The information may appear cryptic but provides context for the error.  The application will continue to run:

System.ArgumentNullException: Value cannot be null.
Parameter name: key
at System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
at Microsoft.SystemCenter.CrossPlatform.UI.Common.UnixComputerOperatingSystemHelper.JoinCollections(ReadOnlyCollection`1 managementServers, ReadOnlyCollection`1 unixcomputers, ReadOnlyCollection`1 operatingSystems)
at Microsoft.SystemCenter.CrossPlatform.UI.Common.UnixComputerOperatingSystemHelper.GetUnixComputerOperatingSystemInstances(String criteria)
at Microsoft.SystemCenter.CrossPlatform.UI.Administration.UnixAgentQuery.DoQuery(String criteria)
at Microsoft.EnterpriseManagement.Mom.Internal.UI.Cache.Query`1.DoQuery(String criteria, Nullable`1 lastModified)
at Microsoft.EnterpriseManagement.Mom.Internal.UI.Cache.Query`1.FullUpdateQuery(CacheSession session, IndexTable& indexTable, Boolean forceUpdate, DateTime queryTime)
at Microsoft.EnterpriseManagement.Mom.Internal.UI.Cache.Query`1.InternalSyncQuery(CacheSession session, IndexTable indexTable, UpdateReason reason, UpdateType updateType)
at Microsoft.EnterpriseManagement.Mom.Internal.UI.Cache.Query`1.InternalQuery(CacheSession session, UpdateReason reason)
at Microsoft.EnterpriseManagement.Mom.Internal.UI.Cache.Query`1.TryDoQuery(UpdateReason reason, CacheSession session)
at Microsoft.EnterpriseManagement.Mom.Internal.UI.Cache.Query`1.DoQueryJob(Object sender, ConsoleJobEventArgs args)
at Microsoft.EnterpriseManagement.Mom.Internal.UI.Console.ConsoleJobExceptionHandler.ExecuteJob(IComponent component, EventHandler`1 job, Object sender, ConsoleJobEventArgs args)

Cause

This was ultimately due to a NULL value for one of the objects in the related tables. 

Resolution

To begin with, the object with the NULL value must be identified.  The following SQL statement should return a list of objects from which you can parse for a NULL value in one of the fields.  The NULL value may correspond with a machine name Windows.Computer.

Please execute this query against the Root Management server (RMS) and any Management Severs (MS) servers until you find the offending NULL entry.  Simply replace the 'fqdn.of.managementserver' as noted below with the correct name:

SELECT [T].[Id], [T].[Name], [T].[Path], [T].[FullName], [T].[DisplayName], [T].[IsManaged], [T].[IsDeleted],
[T].[LastModified], [T].[TypedManagedEntityId], [T].[MonitoringClassId], [T].[TypedMonitoringObjectIsDeleted],
[T].[HealthState], [T].[StateLastModified], [T].[IsAvailable], [T].[AvailabilityLastModified], [T].[InMaintenanceMode],
[T].[MaintenanceModeLastModified], [PXH].[BaseManagedEntityId] AS [HealthServiceId],
[PXH].[DisplayName] AS [ProxyAgentPrincipalName] FROM dbo.ManagedEntityGenericView AS T
INNER JOIN dbo.ManagedType AS MT
ON MT.[BaseManagedTypeId] = 'B4A14FFD-52C8-064F-C936-67616C245B35'
INNER JOIN dbo.BaseManagedEntity AS BME
ON
BME.[BaseManagedEntityId] = T.[Id]
AND BME.[BaseManagedTypeId] = MT.[ManagedTypeId]
INNER JOIN dbo.Relationship AS R
ON R.[TargetEntityId] = T.[Id]
INNER JOIN dbo.BaseManagedEntity AS PXH
ON PXH.[BaseManagedEntityId] = R.[SourceEntityId]
WHERE ((
T.[IsDeleted] = 0 AND T.[TypedMonitoringObjectIsDeleted] = 0 AND R.[IsDeleted] = 0 AND
R.[RelationshipTypeId] = dbo.fn_ManagedTypeId_MicrosoftSystemCenterHealthServiceShouldManageEntity()
) AND ('fqdn.of.managementserver' = PXH.[DisplayName]))

In order to resolve the issue completely and in a supported manner, it was important to leverage the same underlying process by which an Agent is removed as that used by the Console when deleting an agent.  As a result, the following stored procedure was executed against the Operations Manager database using the GUID identified in the initial query above which contained the NULL value.

Cleanup process:

DECLARE @EntityId uniqueidentifier;
DECLARE @TimeGenerated datetime;

-- change "GUID" to the ID of the invalid entity
SET @EntityId = 'GUID';
SET @TimeGenerated = getutcdate();

BEGIN TRANSACTION

EXEC dbo.p_TypedManagedEntityDelete @EntityId, @TimeGenerated;

COMMIT TRANSACTION

Hope this helps,

Nicholas Dodge | Senior Support Escalation Engineer

The App-V Team blog: https://blogs.technet.com/appv/
The WSUS Support Team blog: https://blogs.technet.com/sus/
The SCMDM Support Team blog: https://blogs.technet.com/mdm/
The ConfigMgr Support Team blog: https://blogs.technet.com/configurationmgr/
The SCOM 2007 Support Team blog: https://blogs.technet.com/operationsmgr/
The SCVMM Team blog: https://blogs.technet.com/scvmm/
The MED-V Team blog: https://blogs.technet.com/medv/
The DPM Team blog: https://blogs.technet.com/dpm/
The OOB Support Team blog: https://blogs.technet.com/oob/
The Opalis Team blog: https://blogs.technet.com/opalis

clip_image001 clip_image002