Esempio n. 1
0
def format_ticket(t):

    ggus_t = get_ggus_ticket(ticket_id(t))
    assigned_time = ggus_t.assigned_time()
    age = (datetime.now() - assigned_time).days

    warning = ""

    # if ticket_status(t) == 'on hold' and ticket_related_issue(t) is None:
    #    warning = "on hold ticket without related issue!".upper()

    template=Template("""${url} \"${desc}\"
                SU: ${su}
                Prio: ${prio}
                Age: ${age}
                Related issue: ${related}""")

    ticket_str = template.substitute({"url":ticket_url(t),
                         "desc": ticket_short_description(t),
                         "su": ticket_su(t),
                         "prio": ticket_priority(t),
                         "age": "%d days old" % age,
                         "related": None })

    if len(warning) > 0:
        ticket_str = ticket_str + "\n\t\t\tWARNING: %s" % warning

    return ticket_str
Esempio n. 2
0
def format_ticket_html(t):

    template_str = """
        <tr>
        <td>${su}</td>
        <td><a href="https://ggus.eu/ws/ticket_info.php?ticket=${id}">${id}</a></td>
        <td>${status}</td>
        <td class="prio_${prio_class}">${prio}</td>
        <td><h5>${desc}</h5></td>
        <td><span class=\"badge\">${age}</span></td>
        </tr>"""

    ggus_t = get_ggus_ticket(ticket_id(t))
    assigned_time = ggus_t.assigned_time()
    age = (datetime.now() - assigned_time).days


    template = Template(template_str)
    ticket_str = template.substitute({"id":ticket_id(t),
                         "desc": ticket_short_description(t),
                         "su": ticket_su(t),
                         "prio_class" : ticket_priority(t).replace(' ','_'),
                         "prio": ticket_priority(t),
                         "age": age,
                         "related": None,
                         "status": ticket_status(t)
                         })

    return ticket_str
Esempio n. 3
0
def print_on_hold_report():
    print "Producing on-hold tickets status report. Please be patient..."
    print "As of %s the following tickets are in on-hold status but don't have a related issue registered in GGUS." % datetime.now()
    tickets = get_tickets(open_on_hold_tickets())
    for t in filter(lambda x:ticket_related_issue(x) is None, sorted(tickets, key=ticket_su)):
        ggus_t = get_ggus_ticket(ticket_id(t))
        assigned_time = ggus_t.get_sla_compliance_values()[ticket_su(t)].assigned_time
        print "%-22s: https://ggus.eu/tech/ticket_show.php?ticket=%s ( %-3d days old ) %-15s %-15s \"%s\"" %(ticket_su(t),
                                                                                           ticket_id(t),
                                                                                           (datetime.now()-assigned_time).days,
                                                                                           ticket_priority(t),
                                                                                           ticket_status(t),
                                                                                           ticket_short_description(t))
Esempio n. 4
0
def print_ticket_history(ticket_list):
    for ticket_no in ticket_list:
        try:
            ticket = get_ticket(ticket_no)
        
            ggus_ticket = get_ggus_ticket(ticket_no)
            print "##########"
            print "Ticket: %s" % ticket_url(ticket)
            print "Summary: %s" % ticket_short_description(ticket)
            print "SU: %s" % ticket_su(ticket)
            print 'Last change: %s' % ticket_date_of_change(ticket)
            print "Priority: %s" % ticket_priority(ticket)
            print "Status: %s" % ticket_status(ticket)
            print
            print "Status History: "
            print
            ggus_ticket.print_status_history()
            print
            print "Priority History: "
            print
            ggus_ticket.print_priority_history()
            print
            print "SLA compliance values:"
            print
            val = ggus_ticket.get_sla_compliance_values2()
            counter = 0
            for v in val:
                
                
                if v.sla_delay:
                    sla_check_str = "Delay: %d business minutes (i.e. %d business hours, or  %d business days)" % (v.sla_delay,
                                                                                                                   v.sla_delay // 60,
                                                                                                                   v.sla_delay // 480)
                else:
                    sla_check_str = "SLA Check OK"    
                
                print "#", counter, " (%s)" % v.su, sla_check_str
                print "Priority when assigned: %s" % v.priority_when_assigned
                print "Assigned to SU %s on: %s" % (v.su, v.assigned_time)
                print "SLA constraint: %s" % sla_constraints[v.priority_when_assigned]
                print "Expected takeover: %s" % v.expected_takeover_time
                print "Actual takeover: %s" % v.out_of_assigned_time
                print "Out of assign status: %s" % v.out_of_assigned_status
                print
                counter = counter + 1
            print "##########"
            print 
            
        except WebFault:
            print >> stderr, "Error loading ticket %s" % (ticket_no)
Esempio n. 5
0
def print_eta_status_report():
    print "Producing ETA status report. Please be patient..."
    
    tickets = get_tickets(open_very_urgent_and_top_priority_tickets())
    print "As of %s there are %d very urgent and top priority tickets which have ETA not set." % (datetime.now(), len(tickets))
    print
    for t in filter(lambda x:ticket_eta(x) is None, sorted(tickets, key=ticket_priority)):
        ggus_t = get_ggus_ticket(ticket_id(t))
        assigned_time = ggus_t.get_sla_compliance_values()[ticket_su(t)].assigned_time
        print "%-22s: https://ggus.eu/tech/ticket_show.php?ticket=%s ( %-3d days old ) %-15s %-18s \"%s\"" %(ticket_su(t),
                                                                                           ticket_id(t),
                                                                                           (datetime.now()-assigned_time).days,
                                                                                           ticket_priority(t),
                                                                                           ticket_status(t),
                                                                                           ticket_short_description(t))
Esempio n. 6
0
def print_ksa_1_2(start_date,end_date=datetime.now()):
    print >>sys.stderr, "Producing KSA1.2 kpi csv file for period %s-%s. Please be patient..." % (format_date(start_date),format_date(end_date))
    
    csv_header = "su,%s" % ','.join(priorities)

    try:    
        tickets = get_tickets(third_level_closed_tickets_in_period(start_date,end_date))
    
    except WebFault:
        print >> stderr, "No closed tickets found in period %s-%s" % (format_date(start_date), format_date(end_date))
        return
    
    su_classification = classify_su(tickets)
    
    sus = sorted(su_classification.keys(), key=str.lower)
    print csv_header
    
    for su in sus:
        prios = classify_priority(su_classification[su])
        print "%s,%d,%d,%d,%d" % (su,
                                  average_solution_time([get_ggus_ticket(ticket_id(t)) for t in prios[priorities[0]]]).days,
                                  average_solution_time([get_ggus_ticket(ticket_id(t)) for t in prios[priorities[1]]]).days,
                                  average_solution_time([get_ggus_ticket(ticket_id(t)) for t in prios[priorities[2]]]).days,
                                  average_solution_time([get_ggus_ticket(ticket_id(t)) for t in prios[priorities[3]]]).days)
Esempio n. 7
0
def print_assigned_tickets_report(assigned_priority_classification=None):
    
    now = datetime.now()
    
    if assigned_priority_classification is None:
        assigned_priority_classification = {}
        for i in priorities:
            assigned_priority_classification[i] = []
        
        for t in get_tickets(emi_third_level_assigned_tickets()):
            assigned_priority_classification[ticket_priority(t)].append(t)
    
    for p in priorities:
        if len(assigned_priority_classification[p]) == 0:
            continue
        else:
            print p, ":"
            num_violations = 0
            for t in assigned_priority_classification[p]:
                
                ggus_ticket = get_ggus_ticket(ticket_id(t))
                
                assigned_time = ggus_ticket.get_sla_compliance_values()[ticket_su(t)].assigned_time
                bc = BusinessCalendar(assigned_time)
                
                resolution_date = bc.add_business_time(sla_constraints[p])
                
                if resolution_date >= now:
                    sla_violation_string = "SLA check: OK (Assigned on: %s. To be taken in charge before %s)" % (assigned_time, resolution_date)
                else:
                    if now.day != resolution_date.day:
                        bd_delay = BusinessCalendar(resolution_date).count_business_days(now)
                        delay = "%s work days" % bd_delay
                    else:
                        delay = "%s hours" % (now - resolution_date)
                    
                    sla_violation_string = "SLA VIOLATION: Delay: %s (Assigned on: %s. Had to be taken in charge before %s)" % (delay, assigned_time, resolution_date)
                    num_violations = num_violations + 1
                
                print "\t(%s) \"%s\" https://ggus.eu/tech/ticket_show.php?ticket=%s\n\t%s" % (ticket_su(t),
                                                                                              ticket_short_description(t),
                                                                                              ticket_id(t),
                                                                                              sla_violation_string)
                print
            
            print "Of the %d %s tickets, %d violate the SLA " % (len(assigned_priority_classification[p]), p, num_violations)
            print
Esempio n. 8
0
def ticket_resolution_delay(ticket):
    ggus_ticket = get_ggus_ticket(ticket_id(ticket))
    return ggus_ticket_resolution_delay(ggus_ticket)
Esempio n. 9
0
     
 except WebFault, e:
     print >>stderr, "Error query for all EMI tickets: %s" % e
     exit(-1)
 
 su_classification = classify_su(tickets,emi_support_units)
 print_su_classification(su_classification)
 print
 
 sus = sorted(su_classification.keys(), key=str.lower)
 
 start_time = time.time()
 print "su;ticket_url;status;priority;creation_time;last_assigned_time;solution_time;time_to_solution_in_days;sla_delay_in_hours"
 for su in sus:
     for t in su_classification[su]:
         ggus_ticket = get_ggus_ticket(ticket_id(t))
         
         if ggus_ticket.solution_time():
             time_to_solution = "%d" % ggus_ticket.solution_time().days
         else:
             time_to_solution = ""
             
         last_solution_time = ggus_ticket.last_solution_time()
         if not last_solution_time:
             last_solution_time = ""
         
         delay_in_minutes = ggus_ticket_resolution_delay(ggus_ticket)
          
         print "%s;%s;%s;%s;%s;%s;%s;%s;%s" % (su,
                                               ticket_url(t),
                                               ticket_status(t),