CA Service Management

  • 1.  Incident downtime calculation

    Posted Aug 17, 2017 08:41 AM

    Hello,

     

    Our incident managers want to have a vision, directly on incidents, of the concerned application downtime.

    The downtime will be calculated according to a calendar containing the opening times of the support team.

     

    So, I need to refresh the downtime on every save of incident, and I know there's a function pdmDownTime that is available for business intelligence, and I wanted to know if a similar function is available in spel language.

     

    Thanks for your future answers,

     

    Chris.



  • 2.  Re: Incident downtime calculation

    Posted Aug 17, 2017 09:30 AM

    Hi,

     

    Assuming that pdmDownTime calculates the different between Outage End Date and Outage Start Date, you can use the following steps to implement a field which captures this information.  Props to Gutis for providing me with this spel a while I was still learning.

     

    1. Open WSP and navigate to CR object

    2. Add column to capture outage (Input the Name, Field Type, and Display name. All other options can be ignored)

    2.1 Name: zOutageDuration

    2.2 Field Type: Duration

    2.3 Display Name: Total Outage Time

    3. Press Save and then Save and Publish

    4. Create a spel file with the following contents and place in nx_root/site/mods/magic.

    cr::zCalculateOutage(...)
    {
         string method;
         method ="cr::zCalculateOutage";
         logf(MILESTONE, "%s started", method);
         
         if (!is_empty(outage_start_time) && !is_empty(outage_end_time))
              {
              duration outage;
              outage=outage_end_time-outage_start_time;
              uuid who; 
              send_wait(0,top_object(), "call_attr", "cnt", "current_user_id"); 
              who=msg[0]; 
              send_wait(0, top_object(), "call_attr", "api", "update_object_super", who, persistent_id, 0, "zOutageDuration", outage); 
              }
         if (is_empty(outage_start_time) && !is_empty(outage_end_time))
              {     
              set_error(1);
              set_return_data("Please provide Outage start time");
              logf(MILESTONE, "%s ended", method);
              return;
              }

         logf(MILESTONE, "%s ended", method);          
    }

    5. Create a .mod file with the following contents and place in nx_root/site/mods/magic

    MODIFY cr     POST_VALIDATE zCalculateOutage() 10000 FILTER(outage_start_time{} || outage_end_time {});

    6. Run pdm_publish on background or primary server to add column to db

    7. Perform rolling maintenance to push change to app/secondary servers

    8. Add the Outage Duration field to the incident form via WSP

    <PDM_MACRO name=dtlReadonly hdr="Outage Duration" attr=zOutageDuration>

    9. Test



  • 3.  Re: Incident downtime calculation

    Posted Aug 17, 2017 09:48 AM

    Hi,

     

    Thanks four answer,

     

    I 've already started to code a similar solution, but the issue is that it doesn't take account of the support team working hours calendar, so that solution works if the downtime occurs between the working hours

    of support team, but doesn't work if not.

     

    Chris.



  • 4.  Re: Incident downtime calculation

    Posted Aug 17, 2017 10:07 AM

    So you only want the duration to be calculated if the outage is during off hours? IE outside of the Business Hours workshift?



  • 5.  Re: Incident downtime calculation

    Posted Aug 17, 2017 10:42 AM

    I want it to be calculated for each case, and the simple operation outage_end_time-outage_start_time doesn't cover the case when off time occured between downtime.

     

    Exemple :

    Working hours are, every day, 7:00 AM to 07:00 PM.

    If a downtime start at 08:00 AM and  ends at 05:00 PM, that works, the downtime is 9 hours (05:00 PM - 08:00 AM).

    But if a downtime start at 08:00 AM and  ends at 09:00 AM next day, I have to substract the off hours of the calculated downtime to have the desired value : 13 hours, and not 25 hours.

     

    That's why I want to know if there is a spel function that calculate this according a SDM working hour calendar.



  • 6.  Re: Incident downtime calculation
    Best Answer

    Posted Aug 17, 2017 11:41 AM

    I think you can use the abs2work function to calculate the outage time in business hours.  I haven't used this function before and it would be a bit more complicated than a simple end date - start date operation.



  • 7.  Re: Incident downtime calculation

    Posted Sep 04, 2017 04:50 AM

    Hello,

     

    Thanks a lot, I was able to do what I wanted with this function.

     

    Here's the code :

     

    cr::zcalc_dispo(...) {
         double dispo_minoree, pourcentage_indispo;
         int mois, temps_mensuel,duree_indispo;
         string calendrier, cur_date, annee;
         date debut_mois, fin_mois;
         
         send_wait(0, top_object(), "call_attr", "api", "get_val_for_wc", "wrkshft", format("sym ='%s'","Calendrier_BDF"),"sched");

         if (msg_error()) { 
           logf(ERROR, "Error for getting calendar %s",msg[0]); 
         } 
         else  {
              calendrier = msg[0];
         }

         cur_date = (string)now();
         mois = (int)substr((string)cur_date,0,2);
         annee = substr(cur_date,6,4);
         debut_mois = (date)format("%d/01/%s 00:00:00",mois,annee);
         mois = mois +1;
         fin_mois = (date)format("%d/01/%s 00:00:00",mois,annee);
         logf(SIGNIFICANT, "zcalc_dispo : zlast_outage_time %d",zlast_outage_time); 

         temps_mensuel = workshift_abs2work(calendrier,debut_mois,fin_mois);
         logf(SIGNIFICANT, "zcalc_dispo : temps_mensuel %d",temps_mensuel); 

         duree_indispo = workshift_abs2work(calendrier,outage_start_time,outage_end_time);
         logf(SIGNIFICANT, "zcalc_dispo : duree_indispo %d",duree_indispo); 

         pourcentage_indispo = (double)100*(duree_indispo-zlast_outage_time)/temps_mensuel;
         logf(SIGNIFICANT, "zcalc_dispo : pourcentage_indispo %f",pourcentage_indispo); 

         dispo_minoree = zconcerned_application.zdispo_minoree - pourcentage_indispo;
         logf(SIGNIFICANT, "zcalc_dispo : dispo_minoree %f",dispo_minoree); 

         uuid who;
         send_wait(0,top_object(), "call_attr", "cnt", "current_user_id");
         who=msg[0];

        macro::upd_val("zappl", format("name='%s'",zconcerned_application.name),5,3,"zdispo_minoree",dispo_minoree); 
                          
         logf(SIGNIFICANT, "zcalc_dispo : zconcerned_application.zdispo_minoree %f",zconcerned_application.zdispo_minoree); 

         zlast_outage_time = duree_indispo;
         logf(SIGNIFICANT, "zcalc_dispo : zlast_outage_time %d",zlast_outage_time); 
    }


  • 8.  Re: Incident downtime calculation

    Posted Sep 04, 2017 01:47 PM

    That's great!  Thanks for sharing.