You want to know which computers Purging Maintenance retires or deletes, and when. You may also see computers change to Retired, or disappear from the console, without anyone taking action on them.
Purging Maintenance (SMP Console > Settings > Notification Server > Purging Maintenance) retires or deletes managed computers that stop sending data for a set period. The console shows the settings. It does not list the computers those settings affect.
Is there a way to tell if your client machines belongs to active or disabled purge settings, and if any of these machines will be purged and if so when will this occur?
This article provides three read-only SQL queries:
Use these queries before you enable Purging Maintenance, before you shorten the retire or delete period, and when you investigate computers that changed to Retired unexpectedly.
ITMS 8.7.x, 8.8.x
Purging Maintenance acts on a computer based on how long ago the SMP Server (Symantec Management Platform or Notification Server (NS)) last received data for it. The settings are in the section Purge computers managed by this NS, which have not reported data for:. Retire and Delete are separate options. Each has its own period. Retire sets the computer status to Retired. Delete removes the computer from the database.
For each computer, the SMP Server records the date it last received AeX AC Client Agent data. The date is in ResourceUpdateSummary.ModifiedDate for data class 9E6F402A-6A45-4CBA-9299-C2323F73A506. When that date is older than the retire or delete period, the computer is a candidate. A computer that checks in but sends no data can still age out.
The SMP Server selects computers with the stored procedure spGetComputersToPurge. A computer is selected only when all of these conditions are true:
If a retired or deleted computer comes back online with the agent installed, it checks in again. A retired computer changes back to Active. A deleted computer is recreated in the database.
The SMP Server calculates the cutoff date in its own code, outside SQL. The queries in this article use calendar units (DATEADD) for months and years. A projected date can differ from the actual purge by up to a few days around month ends. Purging Maintenance also runs on a schedule (NS.Purging Maintenance.{de4a3a7c-2147-463e-8a06-a23b6c6e719b} scheduled task), so a computer that becomes due is processed at the next run, not at the exact projected time.
This query reads the computer purge settings that Steps 2 and 3 use. Run it first. It confirms that the settings are readable and shows the exact unit values stored.
This query is a sample provided as-is. Broadcom Support does not modify or extend it.
-- Step 1: current Purging Maintenance computer settings (read-only) DECLARE @State XML = (SELECT CAST(CAST(State AS NVARCHAR(MAX)) AS XML) FROM Item WHERE Guid = 'de4a3a7c-2147-463e-8a06-a23b6c6e719b');
SELECT @State.value('(item/purgeComputers/@enabled)[1]', 'nvarchar(20)') AS PurgeComputersEnabled, @State.value('(item/purgeComputers/retire/enabled)[1]', 'nvarchar(20)') AS RetireEnabled, @State.value('(item/purgeComputers/retire/duration)[1]', 'int') AS RetireDuration, @State.value('(item/purgeComputers/retire/unit)[1]', 'nvarchar(20)') AS RetireUnit, @State.value('(item/purgeComputers/delete/enabled)[1]', 'nvarchar(20)') AS DeleteEnabled, @State.value('(item/purgeComputers/delete/duration)[1]', 'int') AS DeleteDuration, @State.value('(item/purgeComputers/delete/unit)[1]', 'nvarchar(20)') AS DeleteUnit; |
The query returns one row.
Column | Typical values | What it means |
|---|---|---|
PurgeComputersEnabled | True / False | Whether the section Purge computers managed by this NS, which have not reported data for: is enabled. False means neither Retire nor Delete runs. |
RetireEnabled | True / False | Whether the Retire option is selected. |
RetireDuration | Whole number, for example 3 | The number of units in the retire period. |
RetireUnit | A unit name, for example Days, Weeks, Months, Years | The unit for the retire period. Steps 2 and 3 recognize values that start with Day, Week, Month, or Year. |
DeleteEnabled | True / False | Whether the Delete option is selected. |
DeleteDuration | Whole number, for example 12 | The number of units in the delete period. |
DeleteUnit | Same as RetireUnit | The unit for the delete period. |
Note If every column is NULL, the query did not find the Purging Maintenance item or the XML paths differ in your release. Run SELECT State FROM Item WHERE Guid = 'de4a3a7c-2147-463e-8a06-a23b6c6e719b' and inspect the XML. A duration or unit can show a value even when its action is disabled. The console keeps the last value entered. |
This query is a sample provided as-is. Broadcom Support does not modify or extend it.
This query applies the eligibility rules from "How Purging Maintenance selects computers" to every computer and calculates when each computer becomes due.
Option | Default | Effect |
|---|---|---|
@LookAheadDays | 0 | Number of days ahead to include. 0 lists computers due now. 7 also lists computers that become due within the next 7 days. |
@ShowAll | 0 | 0 lists only computers that are due or due within the look-ahead window. 1 lists every computer, with its status. |
Note Do not change the values under Constants: do not change. They identify the Purging Maintenance item, the Client Agent data class, the asset status association, and the Active status. |
/* Step 2: computers due for retire or delete by Purging Maintenance (read-only). Age is measured from the last AeX AC Client Agent data the NS received (data class 9E6F402A-6A45-4CBA-9299-C2323F73A506). Settings are read from the Purging Maintenance item State XML. */
-- Options: change these before you run the query DECLARE @LookAheadDays INT = 0; -- 0 = due now; 7 = also show computers due in the next 7 days DECLARE @ShowAll BIT = 0; -- 0 = due computers only; 1 = all computers
-- Constants: do not change DECLARE @PurgeItemGuid UNIQUEIDENTIFIER = 'de4a3a7c-2147-463e-8a06-a23b6c6e719b'; DECLARE @ClientAgentClass UNIQUEIDENTIFIER = '9E6F402A-6A45-4CBA-9299-C2323F73A506'; DECLARE @AssetStatusAssoc UNIQUEIDENTIFIER = '3028166F-C0D6-41d8-9CB7-F64852E0FD01'; DECLARE @StatusActive UNIQUEIDENTIFIER = '0A0203A5-D2B6-49f1-A53B-5EC31A89437C'; DECLARE @ThisNS UNIQUEIDENTIFIER = (SELECT Guid FROM vThisNS); DECLARE @IsParent BIT = CASE WHEN EXISTS (SELECT 1 FROM HierarchyNode WHERE ParentGuid = @ThisNS) THEN 1 ELSE 0 END; DECLARE @Now DATETIME = GETDATE(); DECLARE @Horizon DATETIME = DATEADD(DAY, @LookAheadDays, @Now);
-- Read the Purging Maintenance settings once DECLARE @State XML = (SELECT CAST(CAST(State AS NVARCHAR(MAX)) AS XML) FROM Item WHERE Guid = @PurgeItemGuid);
DECLARE @PurgeEnabled BIT = CASE WHEN @State.value('(item/purgeComputers/@enabled)[1]', 'nvarchar(20)') = 'True' THEN 1 ELSE 0 END; DECLARE @RetireEnabled BIT = CASE WHEN @PurgeEnabled = 1 AND @State.value('(item/purgeComputers/retire/enabled)[1]', 'nvarchar(20)') = 'True' THEN 1 ELSE 0 END; DECLARE @DeleteEnabled BIT = CASE WHEN @PurgeEnabled = 1 AND @State.value('(item/purgeComputers/delete/enabled)[1]', 'nvarchar(20)') = 'True' THEN 1 ELSE 0 END; DECLARE @RetireDuration INT = @State.value('(item/purgeComputers/retire/duration)[1]', 'int'); DECLARE @RetireUnit NVARCHAR(20) = @State.value('(item/purgeComputers/retire/unit)[1]', 'nvarchar(20)'); DECLARE @DeleteDuration INT = @State.value('(item/purgeComputers/delete/duration)[1]', 'int'); DECLARE @DeleteUnit NVARCHAR(20) = @State.value('(item/purgeComputers/delete/unit)[1]', 'nvarchar(20)');
DECLARE @PurgeMethod NVARCHAR(30) = CASE WHEN @PurgeEnabled = 0 THEN 'Purging disabled' WHEN @RetireEnabled = 1 AND @DeleteEnabled = 1 THEN 'Retire & Delete' WHEN @RetireEnabled = 1 THEN 'Retire' WHEN @DeleteEnabled = 1 THEN 'Delete' ELSE 'No computer action enabled' END;
-- 1 when an enabled action has a unit this query does not recognize DECLARE @UnitError BIT = CASE WHEN @RetireEnabled = 1 AND NOT (@RetireUnit LIKE 'Year%' OR @RetireUnit LIKE 'Month%' OR @RetireUnit LIKE 'Week%' OR @RetireUnit LIKE 'Day%') THEN 1 WHEN @DeleteEnabled = 1 AND NOT (@DeleteUnit LIKE 'Year%' OR @DeleteUnit LIKE 'Month%' OR @DeleteUnit LIKE 'Week%' OR @DeleteUnit LIKE 'Day%') THEN 1 WHEN @RetireEnabled = 1 AND @RetireUnit IS NULL THEN 1 WHEN @DeleteEnabled = 1 AND @DeleteUnit IS NULL THEN 1 ELSE 0 END;
SELECT c.Guid AS '_ItemGuid', c.Name, cid.Domain, ip.[IP Address], cid.[Client Date], c.IsManaged, ISNULL(st.Name, 'None (treated as Active)') AS 'Asset Status', rus.ModifiedDate AS 'Last Client Agent Data Received', DATEDIFF(DAY, rus.ModifiedDate, @Now) AS 'Days Since Last Client Agent Data', @PurgeMethod AS 'Computer Purge Setting', CASE WHEN @RetireEnabled = 1 THEN CONCAT(@RetireDuration, ' ', @RetireUnit) END AS 'Retire After', CASE WHEN @DeleteEnabled = 1 THEN CONCAT(@DeleteDuration, ' ', @DeleteUnit) END AS 'Delete After', p.RetireDate AS 'Projected Retire Date', p.DeleteDate AS 'Projected Delete Date', CASE WHEN rus.ModifiedDate IS NULL THEN 'No Client Agent data record' WHEN c.IsManaged = 0 THEN 'Unmanaged - not purged' WHEN c.ResourceItemDeleted = 1 THEN 'Deleted resource - not purged' WHEN e.OwnedHere = 0 THEN 'Owned by child NS - not purged here' WHEN @PurgeEnabled = 0 THEN 'Purging disabled' WHEN @UnitError = 1 THEN 'Unit not recognized - run Step 1' WHEN p.DeleteDate <= @Now THEN 'Delete due now' WHEN p.RetireDate <= @Now THEN 'Retire due now' WHEN p.DeleteDate <= @Horizon THEN 'Delete within look-ahead' WHEN p.RetireDate <= @Horizon THEN 'Retire within look-ahead' WHEN @RetireEnabled = 1 AND @DeleteEnabled = 0 AND e.IsActive = 0 THEN 'Not Active - not retired' ELSE 'Not due' END AS 'Purge Status' FROM vRM_Computer_Item c LEFT JOIN Inv_AeX_AC_Identification cid ON cid._ResourceGuid = c.Guid LEFT JOIN ResourceUpdateSummary rus ON rus.ResourceGuid = c.Guid AND rus.InventoryClassGuid = @ClientAgentClass LEFT JOIN ResourceAssociation ras ON ras.ParentResourceGuid = c.Guid AND ras.ResourceAssociationTypeGuid = @AssetStatusAssoc LEFT JOIN Item st ON st.Guid = ras.ChildResourceGuid LEFT JOIN HierarchyNode hn ON hn.ParentGuid = @ThisNS AND hn.ChildGuid = c.OwnerNSGuid OUTER APPLY ( SELECT TOP 1 t.[IP Address] FROM vTcpIpAddress t WHERE t._ResourceGuid = c.Guid ORDER BY t.[IP Address] ) ip CROSS APPLY ( SELECT OwnedHere = CASE WHEN @IsParent = 0 OR c.OwnerNSGuid = @ThisNS OR hn.ChildGuid IS NULL THEN 1 ELSE 0 END, IsActive = CASE WHEN ras.ChildResourceGuid IS NULL OR ras.ChildResourceGuid = @StatusActive THEN 1 ELSE 0 END ) e CROSS APPLY ( SELECT RetireDate = CASE WHEN @RetireEnabled = 1 AND c.IsManaged = 1 AND c.ResourceItemDeleted = 0 AND rus.ModifiedDate IS NOT NULL AND e.OwnedHere = 1 AND e.IsActive = 1 THEN CASE WHEN @RetireUnit LIKE 'Year%' THEN DATEADD(YEAR, @RetireDuration, rus.ModifiedDate) WHEN @RetireUnit LIKE 'Month%' THEN DATEADD(MONTH, @RetireDuration, rus.ModifiedDate) WHEN @RetireUnit LIKE 'Week%' THEN DATEADD(WEEK, @RetireDuration, rus.ModifiedDate) WHEN @RetireUnit LIKE 'Day%' THEN DATEADD(DAY, @RetireDuration, rus.ModifiedDate) END END, DeleteDate = CASE WHEN @DeleteEnabled = 1 AND c.IsManaged = 1 AND c.ResourceItemDeleted = 0 AND rus.ModifiedDate IS NOT NULL AND e.OwnedHere = 1 THEN CASE WHEN @DeleteUnit LIKE 'Year%' THEN DATEADD(YEAR, @DeleteDuration, rus.ModifiedDate) WHEN @DeleteUnit LIKE 'Month%' THEN DATEADD(MONTH, @DeleteDuration, rus.ModifiedDate) WHEN @DeleteUnit LIKE 'Week%' THEN DATEADD(WEEK, @DeleteDuration, rus.ModifiedDate) WHEN @DeleteUnit LIKE 'Day%' THEN DATEADD(DAY, @DeleteDuration, rus.ModifiedDate) END END ) p WHERE @ShowAll = 1 OR p.DeleteDate <= @Horizon OR p.RetireDate <= @Horizon ORDER BY CASE WHEN rus.ModifiedDate IS NULL THEN 1 ELSE 0 END, -- no record last rus.ModifiedDate ASC, -- oldest first c.Name; |
Note The query returns one IP address per computer, the lowest in sort order. A computer with several network adapters still appears once. Adjusting the queries
|
Column | Typical values | What it means |
|---|---|---|
_ItemGuid | GUID | The computer resource GUID. Use it to search for the computer in other queries or in the console. |
Name | Computer name | The computer name in the CMDB. |
Domain | Domain or workgroup name, or NULL | From the computer identification data. NULL means the CMDB has no identification row for the computer. |
IP Address | IPv4 or IPv6 address, or NULL | One address reported by the computer. NULL means no address is recorded. |
Client Date | Date and time, or NULL | The date and time the computer reported in its identification data. A date far from the Last Client Agent Data Received value points to a computer clock problem. |
IsManaged | 1 / 0 | 1 means the computer is managed by an agent. 0 means unmanaged. Purging Maintenance acts only on 1. |
Asset Status | Active, Retired, other status names, or None (treated as Active) | The computer asset status. Retire acts only on Active computers or computers with no status. |
Last Client Agent Data Received | Date and time, or NULL | The date the NS last received Client Agent data for the computer. Purging Maintenance measures age from this date. NULL means no record, and the computer is never purged. |
Days Since Last Client Agent Data | Whole number, or NULL | Days between Last Client Agent Data Received and now. Compare it with the Retire After and Delete After periods. |
Computer Purge Setting | Retire & Delete, Retire, Delete, Purging disabled, No computer action enabled | The overall setting from Step 1. The value is the same on every row. |
Retire After | For example 3 Months, or NULL | The retire period. NULL means Retire is disabled. |
Delete After | For example 12 Months, or NULL | The delete period. NULL means Delete is disabled. |
Projected Retire Date | Date and time, or NULL | Last Client Agent Data Received plus the retire period. A date in the past means the computer is due. NULL means Retire does not apply to this computer. The Purge Status column gives the reason. |
Projected Delete Date | Date and time, or NULL | Last Client Agent Data Received plus the delete period. A date in the past means the computer is due. NULL means Delete does not apply to this computer. |
Purge Status | See the next table | What Purging Maintenance does with the computer. |
Value | What it means | What to do |
|---|---|---|
Delete due now | The delete period has passed. The next Purging Maintenance run deletes the computer. | If the computer is still in use, find out why the NS has not received its data. Check the agent on the computer. |
Retire due now | The retire period has passed. The next run sets the status to Retired. | Same as above. |
Delete within look-ahead | The computer becomes due for delete within @LookAheadDays. | Check the agent before the date passes. |
Retire within look-ahead | The computer becomes due for retire within @LookAheadDays. | Check the agent before the date passes. |
Not due | The computer is eligible, and the periods have not passed. | No action. |
Not Active - not retired | Only Retire is enabled, and the asset status is not Active. Retire skips the computer. | No action, unless you expect the computer to be retired. |
Unmanaged - not purged | IsManaged is 0. Purging Maintenance skips unmanaged computers. | Clean up unmanaged computers by other means. See KB 181580 for Active Directory imported computers. |
Deleted resource - not purged | The resource is already marked deleted. | No action. |
Owned by child NS - not purged here | Parent NS only. A child NS owns the computer and purges it. | Run the query on the child NS that owns the computer. |
No Client Agent data record | The NS has never received Client Agent data for the computer. Purging Maintenance cannot measure its age and never purges it. | Check whether the agent is installed and sending data. |
Purging disabled | The computer purge section is disabled. | No computer is retired or deleted. |
Unit not recognized - run Step 1 | An enabled action uses a unit value that does not start with Day, Week, Month, or Year. | Run Step 1, note the unit value, and add it to the CASE expressions in Step 2. |
Step 2 reproduces the selection rules. Step 3 runs the selection itself. It reads the retire and delete periods, calculates each cutoff date, and calls spGetComputersToPurge with that cutoff. The procedure returns the computers whose Client Agent data is older than the cutoff and that meet the eligibility rules.
/* Step 3: computers the NS selects today, using the stored procedure Purging Maintenance calls (spGetComputersToPurge). Read-only. */ DECLARE @State XML = (SELECT CAST(CAST(State AS NVARCHAR(MAX)) AS XML) FROM Item WHERE Guid = 'de4a3a7c-2147-463e-8a06-a23b6c6e719b'); DECLARE @Now DATETIME = GETDATE();
DECLARE @RetireDuration INT = @State.value('(item/purgeComputers/retire/duration)[1]', 'int'); DECLARE @RetireUnit NVARCHAR(20) = @State.value('(item/purgeComputers/retire/unit)[1]', 'nvarchar(20)'); DECLARE @DeleteDuration INT = @State.value('(item/purgeComputers/delete/duration)[1]', 'int'); DECLARE @DeleteUnit NVARCHAR(20) = @State.value('(item/purgeComputers/delete/unit)[1]', 'nvarchar(20)');
-- Cutoff = now minus the configured period. Data older than the cutoff is due. DECLARE @RetireCutoff DATETIME = CASE WHEN @RetireUnit LIKE 'Year%' THEN DATEADD(YEAR, -@RetireDuration, @Now) WHEN @RetireUnit LIKE 'Month%' THEN DATEADD(MONTH, -@RetireDuration, @Now) WHEN @RetireUnit LIKE 'Week%' THEN DATEADD(WEEK, -@RetireDuration, @Now) WHEN @RetireUnit LIKE 'Day%' THEN DATEADD(DAY, -@RetireDuration, @Now) END; DECLARE @DeleteCutoff DATETIME = CASE WHEN @DeleteUnit LIKE 'Year%' THEN DATEADD(YEAR, -@DeleteDuration, @Now) WHEN @DeleteUnit LIKE 'Month%' THEN DATEADD(MONTH, -@DeleteDuration, @Now) WHEN @DeleteUnit LIKE 'Week%' THEN DATEADD(WEEK, -@DeleteDuration, @Now) WHEN @DeleteUnit LIKE 'Day%' THEN DATEADD(DAY, -@DeleteDuration, @Now) END;
CREATE TABLE #Retire (Guid UNIQUEIDENTIFIER); CREATE TABLE #Delete (Guid UNIQUEIDENTIFIER);
IF @RetireCutoff IS NOT NULL INSERT #Retire EXEC spGetComputersToPurge @Time = @RetireCutoff, @onlyActive = 1; IF @DeleteCutoff IS NOT NULL INSERT #Delete EXEC spGetComputersToPurge @Time = @DeleteCutoff, @onlyActive = 0;
SELECT 'Retire' AS [Action], @RetireCutoff AS [Cutoff], c.Guid AS '_ItemGuid', c.Name FROM #Retire r JOIN vRM_Computer_Item c ON c.Guid = r.Guid UNION ALL SELECT 'Delete', @DeleteCutoff, c.Guid, c.Name FROM #Delete d JOIN vRM_Computer_Item c ON c.Guid = d.Guid ORDER BY [Action], Name;
DROP TABLE #Retire; DROP TABLE #Delete; |
Caution spGetComputersToPurge only reads data. Do not run the other procedures Purging Maintenance uses (spResourceDelete, spPurgeAssociatedData, spDeleteAllItemReferences). They delete data. Step 3 does not check whether Purging Maintenance is enabled. It lists the computers the settings select if they run. Check Step 1 to see whether each action is enabled. |
Column | Typical values | What it means |
|---|---|---|
Action | Retire / Delete | Which setting selected the computer. Retire calls the procedure with Active-only filtering. Delete calls it without. |
Cutoff | Date and time | Now minus the configured period. Computers whose Client Agent data is older than this date are selected. If the unit is not recognized, the query does not calculate a cutoff and returns no rows for that action. |
_ItemGuid | GUID | The computer resource GUID. |
Name | Computer name | The computer name in the CMDB. |
Symptom | Likely cause | Resolution and verification |
|---|---|---|
Step 1 returns NULL in every column | The Purging Maintenance item GUID or the XML paths differ in your release. | Run SELECT State FROM Item WHERE Guid = 'de4a3a7c-2147-463e-8a06-a23b6c6e719b' and inspect the XML. |
Step 2 returns no rows | Purging is disabled, or no computer has passed a period. | Set @ShowAll = 1. Check the Computer Purge Setting and Purge Status columns. |
Purge Status shows "Unit not recognized - run Step 1" | The stored unit value does not start with Day, Week, Month, or Year. | Run Step 1. Add the actual value to the CASE expressions in Steps 2 and 3. |
A computer shows a retire date in the past but is never retired | Purging Maintenance has not run since the date passed, or the asset status changed after the query ran. | Run Step 3. If the computer is listed, wait for the next run or click Purge Now. If it is not listed, run Step 2 again and check Asset Status. |
On a parent NS, child-site computers never purge | A child NS owns the computers. | Purge Status shows "Owned by child NS". Run the queries on the child NS. See KB How Purging works in a Hierarchy. |
Computers changed to Retired unexpectedly | Purging Maintenance retired them. | Run Step 2 with @ShowAll = 1. Check Retire After and Last Client Agent Data Received. |
Step 3 fails with a permission error | The SQL login cannot execute stored procedures. | Run the query with a login that has EXECUTE permission in the CMDB database. |