- fix UP/DOWN summary on nodes page.
[monitor.git] / monitor / wrapper / mailer.py
index 4a0d661..1b45f0e 100755 (executable)
@@ -52,7 +52,7 @@ def getTicketStatus(ticket_id):
        if ticket_id == None or ticket_id == "":
                return {}
 
-       cmd = "rt show -t ticket -f id,subject,status,queue,created %s" % (ticket_id)
+       cmd = "rt show -t ticket -f id,subject,status,queue,created,told %s" % (ticket_id)
        print cmd
        (f_in, f_out, f_err) = os.popen3(cmd)
        value = f_out.read()
@@ -66,6 +66,7 @@ def getTicketStatus(ticket_id):
                r_values[key] = r_values[key].strip()
 
        r_values['Created'] = calendar.timegm(time.strptime(r_values['Created']))
+       #r_values['Told'] = calendar.timegm(time.strptime(r_values['Told']))
        return r_values
 
 def setAdminCCViaRT(ticket_id, to):
@@ -194,7 +195,8 @@ def emailViaRT(subject, text, to, ticket_id=None):
                cmd = "rt correspond -m - %s" % ticket_id
                print cmd
                (f_in, f_out, f_err) = os.popen3(cmd)
-               f_in.write(text)
+               #f_in.write(input[:32000])
+               f_in.write(text[:32000])
                f_in.flush()
                f_in.close()
                value = f_out.read()
@@ -231,6 +233,7 @@ def emailViaRT_NoTicket(subject, text, to):
        input_text += "Queue: %s\n" % config.RT_QUEUE
        for recipient in to:
                input_text += "AdminCc: %s\n" % recipient
+       #input_text += "AdminCc: %s\n" % config.cc_email
        input_text += "Text: %s"
 
        # Add a space for each new line to get RT to accept the file.
@@ -240,7 +243,12 @@ def emailViaRT_NoTicket(subject, text, to):
                cmd = "rt create -i -t ticket"
                print cmd
                (f_in, f_out, f_err) = os.popen3(cmd)
-               f_in.write(input_text % (subject, spaced_text))
+               input = input_text % (subject, spaced_text)
+               print "length: %s" % len(input)
+               # NOTE: RT hangs with larger input, probably due to some internal
+               # buffering.  So, chop off messages at 32000
+               #f_in.write(input[:32000])
+               f_in.write(input[:32000])
                f_in.flush()
                f_in.close()
                value = f_out.read()