Trigger Alert for Long Running Jobs in CPS

Hello,
I am currently trying to make a trigger so that I can monitor the long running jobs in the underlying ERP. Can you help me on the APIs to use?
Im trying to modify my previous alert - Chekcing of failed jobs
  // only check error jobs
  if (jcsPostRunningContext.getNewStatus().equals(JobStatus.Error)) {
    String alertList = "email address ";
    String [] group = alertList.split(",");
    for (int i = 0; i < group.length; i++) {
      JobDefinition jobDefinition = jcsSession.getJobDefinitionByName("System_Mail_Send");
      Job aJob = jobDefinition.prepare();
      aJob.getJobParameterByName("To").setInValueString(group<i>);
      aJob.getJobParameterByName("Subject").setInValueString("Job " + jcsJob.getJobId() + " failed");
      aJob.getJobParameterByName("Text").setInValueString(jcsJob.getDescription());
Im trying to look for the API so I can subtract the system time and the start time of the job and compare it to 8 hours?
if (jcsPostRunningContext.getNewStatus().equals(JobStatus.Error)) {    <--  Can I have it as ( ( Start Run Time - System Time ) > 8 Hours )
Or is there an easier way? Can somebody advise me on how to go about this one?

Hi,
You can do it using the api:
if ((jcsJob,getRunEnd().getUTCMilliSecs() - jcsJob.getRunStart().getUTCMilliSecs()) > (8*24*60*1000))
This has the drawback that you will only be notified when the job finally ends (maybe more then 8 hours!).
The more easier and integrated method is using the Runtime Limits tab on your Job Definition or Job Chain. This method can raise an event when the Runtime Limit is reached. The event can trigger your notification method.
Regards Gerben

Similar Messages

  • RZ20 - Is there an alert for long running transactions?

    In RZ20 is there an alert for long running transactions?

    http://help.sap.com/saphelp_nw04s/helpdata/en/9c/f78b3ba19dfe47e10000000a11402f/content.htm
    This document clearly explains your problem.
    "Reward points if useful"

  • Email configuration for long running jobs

    Hi Experts,
    We are using CPS Redwood for Job scheduling .Version is M33.92-68971
    Is there any configurtion which can do in CPS so that it will send email to users if a particular job runs for more than specified duration
    Say we keep a limit that if any job runs for more than 2 hours and not compelted it should send email to a particular DL
    Is this possible
    Please suggest
    Regards,
    Murali

    Hi Murali,
    You can achieve this through alerting.
    Under alerting -->Job definition Alert source->Create new Job definition alerts source.
    Fill the required details, Job pattern(U can give job name if the name if no other job name exist with similar pattern)
    Under status select running and put delay amount to 2 and  delay units as hours.
    Create job default alert escalation , alert source email(not required if u already handling alert through alerting gateway)
    Regards,
    Ravindranath Reddy

  • Alert monitor for long running background jobs

    Hello,
    I have to configure an alert moniter for long running background jobs which are running more than 20000 secs using rule based. I have created a rule based MTE and assigend MTE class CCMS_GET_MTE_BY_CLASS to virtual node but i dont find a node to specify the time.
    could any one guide me how can i do this.
    Thanks,
    Kasi

    Hi *,
    I think the missing bit is where to set the maximum runtime. The runtime is set in the collection method and not the MTE class.
    process:  rz20 --> SAP CCMS Technical Expert Monitors --> All Contexts on local application server --> background --> long-running jobs. Click on 'Jobs over Runtime Limits' then properties, click the methods tab then double click 'CCMS_LONGRUNNING_JOB_COLLECT', in the parameters tab you can then set the maximum runtime.
    If you need to monitor specific jobs, follow the process (http://help.sap.com/saphelp_nw70/helpdata/en/1d/ab3207b610e3408fff44d6b1de15e6/content.htm) to create the rule based monitor, then follow this process to set the runtime.
    Hope this helps.
    Regards,
    Riyaan.
    Edited by: Riyaan Mahri on Oct 22, 2009 5:07 PM
    Edited by: Riyaan Mahri on Oct 22, 2009 5:08 PM

  • Prgess indicator on long running jobs

    I have an FX application that is directly linked to my database. The program allows all DML operations as well as user defined actions (action commands and various other methods). I have the same application running in Swing, SWT, Canoo ULC and al works just fine. In each of the other front end types, the application automatically displays a busy indicator when a long running job is executed. Now I need this in FX.
    My application is basically a Rich Client framework which allows the same business logic and forms to have different front ends depending on customer requirements. The application is built by customers in a 4GL style development tool. The application is actually built at run time and the data is provided by the user through various services. Because I am building an FX program for a framework, I don't know when the user may execute a long running job when, for example, a button is pressed. I have full control over the retrieval and modification of data but not user interaction. I am therefore looking for a busy indicator that comes automatically when the main thread is waiting.
    Any help would be great!

    Hi guys and thanks for your answers
    I may have stretched the mark with "long running jobs" by these I mean a database query, a price calculation, order process etc. These are standard jobs that are issued on a Rich Client application. Basically I have a screen which will execute a query, and I want to give the user feedback when the query is executing so that he doesn't think that the application has hung. In Swing I have done this by creating my own event queue with a delay timer:
    public class WaitCursorEventQueue extends EventQueue implements DelayTimerCallback
        private final CursorManager cursorManager;
        private final DelayTimer    waitTimer;
        public WaitCursorEventQueue(int delay)
            this.waitTimer = new DelayTimer(this, delay);
            this.cursorManager = new CursorManager(waitTimer);
        public void close()
            waitTimer.quit();
            pop();
        protected void dispatchEvent(AWTEvent event)
            cursorManager.push(event.getSource());
            waitTimer.startTimer();
            try
                super.dispatchEvent(event);
            finally
                waitTimer.stopTimer();
                cursorManager.pop();
        public AWTEvent getNextEvent() throws InterruptedException
            waitTimer.stopTimer(); // started by pop(), this catches modal dialogs
            // closing that do work afterwards
            return super.getNextEvent();
        public void trigger()
            cursorManager.setCursor();
    }I then implemented this into my application like this:
    _eventQueue = new WaitCursorEventQueue(TIMEOUT);
    Toolkit.getDefaultToolkit().getSystemEventQueue().push(_eventQueue);Now each time the application waits for a specific time, the cursor will become a wait timer. This give s the user a visual feedback so that he knows that the application is working and not just hung. By doing this, I do not need to wrap each user callout in a timer. Much easier like this!
    I would like to implement the same in FX.
    Edited by: EntireJ on Dec 15, 2011 12:34 AM

  • How to research a long running job from 3 days ago

    Re: How to research a long running job from 3 days ago
    Client called to say that a job that normally runs for 6 hours ran for 18 hours on 11/01. 11/01 was a Saturday, and end of month. The long running job writes to a log and I can from the log that that the problem started right around 10:43am. Every step
    before 10:43 was taking the normal amount of time. Then at 10:43 a step that takes seconds hung for 12 hours. After 12 hours the step finished and the job completed successfully.
    I looked at the SQL Log, Event Log, Job History (for all jobs). What else can I look at to try and resolve an issue that happened on 11/01/2014?

    It does execute an SSIS package.
    Personally I feel this as kind of bug in SSIS package but I am not expert in SSIS so I would move it to SSIS forum. Please update your question giving complete information what SSIS package does.
    Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it
    My Technet Wiki Article
    MVP

  • Re:How to determine the long running jobs in a patch

    Hi ,
    How to determine the long running jobs in a patch .
    Regards

    Hi,
    Check the below MY ORACLE SUPPORT note:
    Note.252422.1 .... Check Completed Long Running Jobs In Oracle Apps.
    Best regards,
    Rafi

  • Profiler execution plan ONLY for long running queries

    The duration only applies to specific profiler events however I'd like to capture the execution plan ONLY for queries over 10 minutes.
    Is there a way to do this using Xevents?
    Anyone knows?
    Thanks!
    Paula

    I've wanted that too but could not find a way to get it from profiler.
    But it may be possible with xevents (or without xevents!) to watch for long-running queries and then get the plan from the cache,where it will probably stick for some time, using DMVs.
    Josh

  • Long Running Jobs based on average time of last 5 run

    Hi Experts,
    I need a query to find out the Long Running Jobs, based on average time of last 5 run.
    Could you please help me.
    Thanks in advance. 
    --------------------------------- Devender Bijania

    SELECT 
        [sJOB].[name] AS [JobName]
        , CASE 
            WHEN [sJOBH].[run_date] IS NULL OR [sJOBH].[run_time] IS NULL THEN NULL
            ELSE CAST(
                    CAST([sJOBH].[run_date] AS CHAR(8))
                    + ' ' 
                    + STUFF(
                        STUFF(RIGHT('000000' + CAST([sJOBH].[run_time] AS VARCHAR(6)),  6)
                            , 3, 0, ':')
                        , 6, 0, ':')
                    AS DATETIME)
          END AS [LastRunDateTime]
        , CASE [sJOBH].[run_status]
            WHEN 0 THEN 'Failed'
            WHEN 1 THEN 'Succeeded'
            WHEN 2 THEN 'Retry'
            WHEN 3 THEN 'Canceled'
            WHEN 4 THEN 'Running' -- In Progress
          END AS [LastRunStatus]
        , STUFF(
                STUFF(RIGHT('000000' + CAST([sJOBH].[run_duration] AS VARCHAR(6)),  6)
                    , 3, 0, ':')
                , 6, 0, ':') 
            AS [LastRunDuration (HH:MM:SS)]
          , CASE [sJOBSCH].[NextRunDate]
            WHEN 0 THEN NULL
            ELSE CAST(
                    CAST([sJOBSCH].[NextRunDate] AS CHAR(8))
                    + ' ' 
                    + STUFF(
                        STUFF(RIGHT('000000' + CAST([sJOBSCH].[NextRunTime] AS VARCHAR(6)),  6)
                            , 3, 0, ':')
                        , 6, 0, ':')
                    AS DATETIME)
          END AS [NextRunDateTime]
    FROM 
        [msdb].[dbo].[sysjobs] AS [sJOB]
        LEFT JOIN (
                    SELECT
                        [job_id]
                        , MIN([next_run_date]) AS [NextRunDate]
                        , MIN([next_run_time]) AS [NextRunTime]
                    FROM [msdb].[dbo].[sysjobschedules]
                    GROUP BY [job_id]
                ) AS [sJOBSCH]
            ON [sJOB].[job_id] = [sJOBSCH].[job_id]
        LEFT JOIN (
                    SELECT 
                        [job_id]
                        , [run_date]
                        , [run_time]
                        , [run_status]
                        , [run_duration]
                        , [message]
                        , ROW_NUMBER() OVER (
                                                PARTITION BY [job_id] 
                                                ORDER BY [run_date] DESC, [run_time] DESC
                          ) AS RowNumber
                    FROM [msdb].[dbo].[sysjobhistory]
                    WHERE [step_id] = 0
                ) AS [sJOBH]
            ON [sJOB].[job_id] = [sJOBH].[job_id]
            AND [sJOBH].[RowNumber] = 1
    ORDER BY [LastRunDateTime] desc,
             [LastRunDuration (HH:MM:SS)] DESC
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Considerations for long running publication extensions

    We are considering implementing a post processing publication extension which may take several minutes to execute.   One of our concerns with this strategy is that the publication extension may bog down the Adaptive Processing Server.  
    Are there any general considerations / recommendations for long running post processing publication extensions?  
    Thanks!

    Generally creating a new thread is an expensive process. Well, everything is relative. My laptop can create & run & stop 7,000+ threads per second, test program below, YMMV. If you are dealing with thousands of thread creations per second, pooling may be sensible; if not, premature optimization is the root of all evil, etc.
    public class ThreadSpeed
        public static void main(String args[])
         throws Exception
            System.out.println("Ignore the first few timings.");
            System.out.println("They may include Hotspot compilation time.");
            System.out.println("I hope you are running me with \"java -server\"!");
         for (int n = 0; n < 5; n++)
             doit();
            System.out.println("Did you run me with \"java -server\"?  You should!");
        public static void doit()
         throws Exception
            long start = System.currentTimeMillis();
            for (int n = 0; n < 10000; n++) {
             Thread thread = new Thread(new MyRunnable());
             thread.start();
             thread.join();
            long end = System.currentTimeMillis();
            System.out.println("thread time " + (end - start) + " ms");
        static class MyRunnable
         implements Runnable
         public void run()
    }Edited by: sjasja on Jan 14, 2010 2:20 AM

  • Tracking completion status for long running DML operations

    Does anybody know:
    Is there any possibility to track a completion status for long running DML operations (for example how many rows is inserted)?
    For example if I execute an INSERT statement which is working for several hours it is very important to estimate the total time for this operation.
    Thanks forward

    I'm working with Oracle8 in present, and unfortunately this solution (V$SESSION_LONGOPS)cannot help me.
    On Oracle8 it works, but with some restrictions:
    - You must be using the cost-based optimizer
    - Set the TIMED_STATISTICS or SQL_TRACE parameter to TRUE
    - Gather statistics for your objects with the ANALYZE statement or the DBMS_STATS package.

  • Is there any time out defined for long running transaction?

    hi, 
    i have to make one big data transferring script , though transaction is not required here, but i was planning to,
    please tel me is there any time out for long running transactions.i have to run the script from database it self
    yours sincerley

    Can you show us an example of your script? You can divide the transaction into small chunks to reduce time and locking/blocking as well.
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Trigger alert for Messages in 'To be delivered' status

    Hello Experts,
    We are doing proactive monitoring in our system,so we check for all messages which are in error and alert configuration is enabled which takes care of this.
    But we had a critical issue where adapter queue was locked and hence,messages were in status 'To be delivered' for a long time.
    There were no alerts triggered as there was no error.
    The problem resolved by itself after sometime.
    But such delays are not acceptable in some critical scenarios.
    Can anyone please help us and let us know know how can we trigger alerts in such cases,say,if a message is in status 'To be delivered' for more than 30 minutes ,an alert should be raised.
    Also,in RWB Message Monitoring Audit log,I can see message start time as 12:25 and end time as 13:57,i.e. a difference of 1 hr 32 minutes.
    Is this data stored in some table in ABAP stack,so that I can take this data and create an ABAP report to trigger a mail if this threshold is reached?
    Kindly help.
    Regards,
    Shweta

    But we had a critical issue where adapter queue was locked and hence,messages were in status 'To be delivered' for a
    long time.
    There were no alerts triggered as there was no error.
    We have to do the monitoring manually. Alerts wont be raised in such cases.
    Is this data stored in some table in ABAP stack,so that I can take this data and create an ABAP report to trigger a mail if this
    threshold is reached?
    Data in the table SXMSPMAST may help.
    Regards,
    Abhishek.

  • ProgressIndicator and  hourglass for long running processes

    Hi all,
    Iam using Oracle ADF 10g with EJBs.
    I have a long running process for which I want to give the user an indication of its progress. The process is run upon clicking a submit button.
    I have tested the use of the combination of progressIndicator + poll according to the example of Gerger consulting( http://gergerconsulting.blogspot.com/2007/04/adf-faces-progressindicator-example-for.html) but it did not work. The problem is that my long running process hangs the page and the progress bar does not work until the process has finished.
    I have seen a similar post in this foum (Re: How to run long background jobs in ADF applications where a user complains that there is not an Oracle method for running asynchronous processes from Oracle ADF.
    I've tested to isolate my asynchronous process with the progressIndicator + poll in a single ADF page. The process is being activated from an invokeAction from the executables of the pagedef file. But again the process hangs the page and the progressIndicator does not display at all.
    So I have abandoned the idea of the progress indicator and Iam thinking of using an hourglass.
    Is there an example or guidelines of how I can do it?

    Thanks John for your reply,
    Iam still working on the progressIndicator. I have read the discussion thoroughly quite many times.
    One thing I have not yet figured out from your discussion is how you manage to create the long-running-process thread within an action method within the managed bean and make the thread still be active, while the parent action method has finished.
    Usually the managed beans attached to a .jspx pages has request scope. So a commandButton's action method (that will spawn the long running thread) will finish much earlier than the thread and it will kill the thread.
    Thanks,
    Dimitris

  • This is urgent please help!  long running job in sm37 but not in sm66

    Hi,
    Can someone please help for an explanation as to why if you call sm37, you can see that the job is long running (example about 70,000 sec), but when you look at the PID where the job is running in sm66 it does not show 70,000 sec but only around 6,000 sec.
    Can someone please explain why?  Thank you very much

    For background processes, additional information is available for the background job that is currently running. You can only display this information, if you are logged onto the instance where the job is running, or if you choose Settings and deselect Display only abbreviated information, avoid RFC. In any case, the job must still be running.
    Regards
    Anilsai

Maybe you are looking for