Cleaning up USM Maintenance Schedules

book

Article ID: 106216

calendar_today

Updated On:

Products

DX Infrastructure Management NIMSOFT PROBES

Issue/Introduction

The maintenance_mode probe does not archive expired maintenance schedules. As a result, this may impact the user response times in UMP. 

Environment

UIM 9.X and earlier

Resolution

Attached is an MS SQL script containing 3 queries that can be used to help.

  1.    "Cleanup of empty schedules"
  2.    "Cleanup of maintenance schedules older than 60 days"
  3.    "Cleanup of old maintenance WINDOWS"

Anyone of these 3 queries can be run as seen fit. It is advisable to backup the tables before running the script.
You may also change the "DELETE" to a "SELECT" before running.

Note: Be careful when cleaning up Schedules and Windows. In addition to the nas probe suppressing alarms the windows are
    also used by SLA Reports, and USM graphs (graphs will display maintenance windows, shaded grey area). If reducing the
    number of days to keep please check to see if these are needed for SLA's or graphs.

Note: for older installs it may be necessary to change the database name in the scripts from CA_UIM to NimsoftSLM.

 

 

For Oracle DB, here is the Steps:

below is the converted script.

 

Before running this script in Production environment, please do a test it in your test environment and validate results and then execute in production.

 

MOST IMPORTANT: please take backup of maintenance_window,maintenance_schedule,maintenance_schedule_members tables before executing in production:

 

declare
cursor devicecursor is
select ms.schedule_id as sch_id from maintenance_schedule ms left join maintenance_schedule_members msm 
on msm.schedule_id=ms.schedule_id where msm.cs_id IS NULL;
v_ctr pls_integer := 0;
begin
for rec in devicecursor
loop
v_ctr := v_ctr + 1;
delete from maintenance_schedule ms where ms.schedule_id=rec.sch_id;
delete from maintenance_window mw where mw.schedule_id = rec.sch_id;
if (mod(v_ctr, 1000) = 0) then
    commit;
  end if;
end loop;
commit;
end;
/
--- Cleanup of maintenance schedules older than 60 days

declare
cursor plancursor is
select ms.schedule_id as sch_id from maintenance_schedule ms left join
maintenance_schedule_members msm on msm.schedule_id=ms.schedule_id
left join
cm_computer_system ccs on
ccs.cs_id=msm.cs_id
where ms.recurrence_pattern =0
and ms.recurrence_period=0
and ms.start_time < trunc(sysdate) - 60
and ms.duration < 86400;
v_ctr pls_integer := 0;
begin
for rec in plancursor
loop
v_ctr := v_ctr + 1;
delete from maintenance_schedule_members msm where msm.schedule_id=rec.sch_id;
delete from maintenance_window mw where mw.schedule_id = rec.sch_id;
delete from maintenance_schedule ms where ms.schedule_id = rec.sch_id;
if (mod(v_ctr, 1000) = 0) then
    commit;
  end if;
end loop;
commit;
end;
/

--- Cleanup of old maintenance WINDOWS
declare
cursor windowcursor is
select mw.window_id as win_id from maintenance_window mw where mw.schedule_id is NULL;
v_ctr pls_integer := 0;
begin
for rec in windowcursor
loop
v_ctr := v_ctr + 1;
delete from maintenance_window mw where mw.window_id=rec.win_id;
if (mod(v_ctr, 1000) = 0) then
    commit;
  end if;
end loop;
commit;
end;
/

declare 
cursor windowcursor2 is
select mw.window_id as win_id from maintenance_window mw where mw.end_time < trunc(sysdate) - 60;
v_ctr pls_integer := 0;
begin
for rec in windowcursor2
loop
v_ctr := v_ctr + 1;
delete from maintenance_window mw where mw.window_id=rec.win_id;
if (mod(v_ctr, 1000) = 0) then
    commit;
  end if;
end loop;
commit;
end;
/

Additional Information

  • No probes need to be stopped in order to do this clean up.
  • You can check what is happening in the following ways:
    • If you want to know if records are removed you could do a simple:
      • select count(*) from <tablename> for each table before and after.
      • You could run the delete query multiple times the first time it should show you X number of rows deleted the second time 0 rows.


Please consider the maintenance_mode probe release notes for important fixes:
http://techdocs.broadcom.com/content/broadcom/techdocs/us/en/ca-enterprise-software/it-operations-management/ca-unified-infrastructure-management-probes/GA/alphabetical-probe-articles/maintenance-mode-maintenance-mode/maintenance-mode-release-notes.html

 

Version Description State Date
9.02

What's New:

  • Updated this probe as part of addressing CVE-2018-13820 and CVE-2018-13819 vulnerabilities in CA UIM 9.0.2.

  • Updated this probe as part of removing known security vulnerabilities in CA UIM 9.0.2 by using the upgraded MariaDB components.

  • Updated this probe as part of supporting TLS v1.2 in CA UIM for establishing secure communication with the UIM databases: Microsoft SQL Server and Oracle. For more information about how to enable TLS v1.2 support in CA UIM, see TLS v1.2 Support for Microsoft SQL Server and TLS v1.2 Support for Oracle.

Fixed Defects:

  • After DST changes, Western Australia schedules windows is not synchronized. It still shows only 2 hours difference instead of 3. (Support Case: 00879457)
  • Added the MAINTENANCE_WINDOW purge task, where the MAINTENANCE_WINDOW entries are purged when the corresponding MAINTENANCE_SCHEDULE is deleted. (Support Case: 01184935)

Attachments

1558536578942Cleanup_maintenance_schedules.sql get_app