test2

Wednesday 7 September 2016

Control-M SQL Queries

You may watch the video here 
https://www.youtube.com/watch?v=qrC-JhJqfRg

These queries can also be automated using Control-M database. Run these queries against enterprise manager database. I have tested it on postgres. You may need to change syntax a bit as per database.

1--> To check number of jobs loaded daily

select net_date, jobs from net_report;

2--> To check number of jobs executed today 

SELECT job_mem_name , sched_table as folder, application, start_time, end_time,
case when ended_status=16 then 'Ended OK' else 'Not Ok' end as Status
from runinfo_history
where start_time > Current_Date

3--> To check number of jobs executed between a time period

SELECT job_mem_name , sched_table as folder, application, start_time, end_time,
case when ended_status=16 then 'Ended OK' else 'Not Ok' end as Status
from runinfo_history
where start_time  between '2016-09-01 00:00:00' and '2016-09-10 23:59:59'

4--> To check number of failed jobs today


SELECT job_mem_name , sched_table as folder, application, start_time, end_time,
case when ended_status=16 then 'Ended OK' else 'Not Ok' end as Status
from runinfo_history
where start_time > Current_Date
and ended_status=32

5--> To check number of failed jobs between a time period

SELECT job_mem_name , sched_table as folder, application, start_time, end_time,
case when ended_status=16 then 'Ended OK' else 'Not Ok' end as Status
from runinfo_history
where start_time  between '2016-09-01 00:00:00' and '2016-09-10 23:59:59'
and ended_status=32


6--> To check number of jobs which completed successfully today

SELECT job_mem_name , sched_table as folder, application, start_time, end_time,
case when ended_status=16 then 'Ended OK' else 'Not Ok' end as Status
from runinfo_history
where start_time > Current_Date
and ended_status=16

7--> To check number of jobs which completed successfully between a time period

SELECT job_mem_name , sched_table as folder, application, start_time, end_time,
case when ended_status=16 then 'Ended OK' else 'Not Ok' end as Status
from runinfo_history
where start_time  between '2016-09-01 00:00:00' and '2016-09-10 23:59:59'
and ended_status=16


8--> To check number of jobs which executed on a particular server in a time period

SELECT job_mem_name , sched_table as folder, application, start_time, end_time,
case when ended_status=16 then 'Ended OK' else 'Not Ok' end as Status , node_id as Server
from runinfo_history
where start_time  between '2016-09-01 00:00:00' and '2016-09-10 23:59:59'
and ended_status=16 and node_id='<Server IP or Hostname>'


9--> To check count of jobs which ended ok and not ok today

select 'OK' Status, sum( case when ended_status=16 then 1 else 0 end) as Count from runinfo_history where ended_status=16
and start_time > current_date
group by ended_status

union all

select 'Not OK' Status, sum( case when ended_status=32 then 1 else 0 end) as Count from runinfo_history where ended_status=32
and start_time> current_date
group by ended_status


10--> To check count of success and failed jobs for a particular application folder

select * from
(
select 'OK' Status, sum( case when ended_status=16 then 1 else 0 end) as Count from runinfo_history where ended_status=16
and start_time Between '2016-09-01 00:00:00' and '2016-09-30 23:59:59' and application like '%a%'
group by ended_status

union all

select 'Not OK' Status, sum( case when ended_status=32 then 1 else 0 end) as Count from runinfo_history where ended_status=32
and start_time Between '2016-09-01 00:00:00' and '2016-09-30 23:59:59' and application like '%a%'
group by ended_status
) Table1


11--> To check count of success and failed jobs , application wise

select * from
(
select application, 'OK' Status, sum( case when ended_status=16 then 1 else 0 end) as Count from runinfo_history where ended_status=16
and start_time Between '2016-09-01 00:00:00' and '2016-09-30 23:59:59'
group by application, ended_status

union all

select application, 'Not OK' Status, sum( case when ended_status=32 then 1 else 0 end) as Count from runinfo_history where ended_status=32
and start_time Between '2016-09-01 00:00:00' and '2016-09-30 23:59:59'
group by application, ended_status
) Table1
order by 1

15 comments:

  1. Thank you very much for the information Vikas :-)

    ReplyDelete
  2. Thanks so much for those queries.

    ReplyDelete
    Replies
    1. Great to know that it is helpful. Please let me know if you need any other queries.

      Delete
  3. Is there any way to audit user actions done in the AJF, e.g. rerun/free etc.? I can't find the table that contains these records.

    ReplyDelete
    Replies
    1. Please refer to audit_activities table.
      Also data in these tables will only be available if auditing is turned on. You can turn on auditing from configuration manager.
      Just try a simple "select * from audit_actvities;" query and see the result.

      Delete
  4. Thank you for the queries!

    Is there a way to have for a requested job the list of his "Waiting Info" ?

    The goal is to know, at a certain time of the day, the list of jobs blocking the execution of the requested job.

    Thanks a lot!

    ReplyDelete
  5. To fetch how all job details configured in a datacenter, with all its parameter

    ReplyDelete
  6. How to get the list of of waiting jobs from AJF which are in hold state and doesn't have any waiting condition to meet.

    ReplyDelete
  7. How to fetch the waiting info from AJF.

    ReplyDelete
  8. Hello, please anyone know a query to have the list of jobs scheduled for a certain date?

    I'm trying to do a report with job scheduled that have not run...

    Thanks, Paolo.

    ReplyDelete
    Replies
    1. I share the query on server db (ctrlmdb) for list jobs active that has not run (not 100% sure that is correct):

      select caj.* from cmr_ajf_jobs caj where caj.runcount = 0

      Delete
  9. Please provide me query to get the list of jobs on a specific date(probably old dates)

    ReplyDelete
  10. I need to know how many jobs loaded in AJF on a specific ODATE....it might be very old dates.around 200 days back ODATE.....can any one help me with query/somet way

    ReplyDelete
  11. Need Query to get jobs under one connection profile in Control-M DB. Thanks in advance

    ReplyDelete