Queries to collect data before Id migration/Migrating from Professional to Enterprise Edition

Queries to collect data before Id migration/Migrating from Professional to Enterprise Edition

Collect query output from Managed server / Professional Edition:

To check Id range :
  1. Select min(resourceid),max(resourceid) as AM_ManagedObject from AM_ManagedObject where resourceid > 10000000;
  2. Select count(*) as AM_ManagedObject_Count  from AM_ManagedObject;
  3. Select min(Id),max(Id) as Alert from Alert;
  4. Select min(Id),max(Id) as Event from Event;
  5. Select min(RELATIONSHIPID),max(RELATIONSHIPID) as AM_PARENTCHILDMAPPER from AM_PARENTCHILDMAPPER;
NOTE: Before collecting below query output ensure that the Query tool max row count value has been updated with max value.
To check MO count list based on its type:
select m.displayname as ParentName,m.type as ParentType,m1.type as ChildType,count(m1.type) from AM_ManagedObject m join AM_PARENTCHILDMAPPER p on m.resourceid=p.parentid join AM_ManagedObject m1 on m1.resourceid=p.childid and m.type!='HAI' group by m1.type,m.displayname,m.type order by 4 desc;
To check MO count based on resource name: 
select m.displayname as ParentName,m.type as ParentType,m1.type as ChildType,m1.resourcename as ChildName,count(m1.resourcename) from AM_ManagedObject  m join AM_PARENTCHILDMAPPER p on m.resourceid=p.parentid join AM_ManagedObject  m1 on m1.resourceid=p.childid and m.type!='HAI' group by m1.type,m.displayname,m.type,m1.resourcename order by 5 desc;
To check stray entries in AM_ManagedObject:
select TYPE,count(TYPE) from AM_ManagedObject where RESOURCEID not in (Select PARENTID from AM_PARENTCHILDMAPPER) and RESOURCEID not in (Select CHILDID from AM_PARENTCHILDMAPPER) and TYPE not like '%_TEMPLATE%' and TYPE not in (Select distinct(RESOURCEGROUP) from AM_ManagedResourceType) and type not in (Select distinct(RESOURCETYPE) from AM_ManagedResourceType) and TYPE not in ('DUMMY','Interface','Script Monitors') group by TYPE order by 2 desc;
To check database size:
For PGSQL
select table_schema as schema_name, ((pg_database_size(current_database())) / (1024 * 1024)) as "database_size in MB" from information_schema.tables where table_schema=current_schema()  group by schema_name
For Microsoft SQL
select name,sum(CONVERT(DECIMAL(10,2),(size * 8.00) / 1024.00)) As 'database_size (MB)' from master.sys.master_files where name in (select DB_NAME()) group by name;

Collect query output from Admin server:

select * from AM_MAS_Server;


                  New to ADManager Plus?

                    New to ADSelfService Plus?