Changeset 0335d9d261b5f2b2c4d7a1d1e1a8ebc851b17ffa

Show
Ignore:
Timestamp:
09/24/09 23:50:27 (5 years ago)
Author:
Dan Di Spaltro <dan.dispaltro@gmail.com>
git-committer:
Dan Di Spaltro <dan.dispaltro@gmail.com> 1253836227 +0000
git-parent:

[7666f798ce5023fb2d514f6ea370156ce06a1102]

git-author:
Dan Di Spaltro <dan.dispaltro@gmail.com> 1253836227 +0000
Message:

Updated the the connector bits to parse jlog instead of xml.
closes #185

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/java/Makefile.in

    re591eb5 r0335d9d  
    3030        com/omniti/reconnoiter/broker/AMQListener.java \ 
    3131        com/omniti/reconnoiter/broker/BrokerFactory.java \ 
    32         com/omniti/reconnoiter/event/NoitEvent.java \ 
     32        com/omniti/reconnoiter/event/NoitCheck.java \ 
     33        com/omniti/reconnoiter/event/NoitStatus.java \ 
     34        com/omniti/reconnoiter/event/NoitMetricText.java \ 
    3335        com/omniti/reconnoiter/event/NoitMetricNumeric.java \ 
    3436        com/omniti/reconnoiter/event/StratconStatement.java \ 
     
    4042        com/omniti/reconnoiter/StratconMessage.java 
    4143 
    42 SUPPORT=lib/activemq-all-5.2.0.jar lib/antlr-runtime-3.1.1.jar lib/esper-3.1.0.jar \ 
     44SUPPORT=lib/activemq-all-5.2.0.jar lib/antlr-runtime-3.1.1.jar lib/esper-3.2.0.jar \ 
    4345        lib/log4j-1.2.15.jar lib/spring-beans-2.5.5.jar lib/spring-context-2.5.5.jar \ 
    4446        lib/cglib-nodep-2.2.jar lib/commons-pool-1.4.jar lib/commons-dbcp-1.2.2.jar \ 
  • src/java/com/omniti/reconnoiter/EventHandler.java

    r699c97c r0335d9d  
    88import com.espertech.esper.client.UpdateListener; 
    99import com.omniti.reconnoiter.broker.IMQBroker; 
    10 import com.omniti.reconnoiter.event.NoitEvent; 
    11 import com.omniti.reconnoiter.event.NoitMetricNumeric; 
    12 import com.omniti.reconnoiter.event.StratconQueryBase; 
    13 import com.omniti.reconnoiter.event.StratconStatement; 
    14 import com.omniti.reconnoiter.event.StratconQuery; 
    15 import com.omniti.reconnoiter.event.StratconQueryStop; 
     10import com.omniti.reconnoiter.event.*; 
    1611 
    1712public class EventHandler { 
     
    6459      } 
    6560    } 
    66     else if(m instanceof NoitEvent) { 
    67       epService.getEPRuntime().sendEvent(((NoitEvent) m).getDocument()); 
     61    else if(m instanceof NoitMetricText) { 
     62      epService.getEPRuntime().sendEvent(m); 
    6863    } 
    6964    else if(m instanceof NoitMetricNumeric) { 
    70       epService.getEPRuntime().sendEvent((NoitMetricNumeric) m); 
     65      epService.getEPRuntime().sendEvent(m); 
     66    } 
     67    else if(m instanceof NoitCheck) { 
     68      epService.getEPRuntime().sendEvent(m); 
     69    } 
     70    else if(m instanceof NoitStatus) { 
     71      epService.getEPRuntime().sendEvent(m); 
    7172    } 
    7273        } 
  • src/java/com/omniti/reconnoiter/IEPEngine.java

    r699c97c r0335d9d  
    1414import com.omniti.reconnoiter.MQListener; 
    1515import com.omniti.reconnoiter.broker.BrokerFactory; 
    16 import com.omniti.reconnoiter.event.NoitEvent; 
    1716import com.omniti.reconnoiter.StratconConfig; 
    1817import com.espertech.esper.client.*; 
     
    3231    config.addEventTypeAutoName("com.omniti.reconnoiter.event"); 
    3332    EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider(config); 
    34     NoitEvent.registerTypes(epService); 
    3533 
    3634    MQListener l = new MQListener(epService, BrokerFactory.getBroker(sconf)); 
  • src/java/com/omniti/reconnoiter/StratconConfig.java

    r4c3fb9b r0335d9d  
    5151    catch (SAXException e) { 
    5252        System.err.println("Bad XML: " + e.getMessage()); 
    53         return; 
    5453    } 
    5554    catch (IOException e) { 
    5655        System.out.println("Bad file: " + e.getMessage()); 
    57         return; 
    5856    } 
    5957  } 
  • src/java/com/omniti/reconnoiter/StratconMessage.java

    r99a21c2 r0335d9d  
    2020 
    2121public class StratconMessage { 
    22   private static DocumentBuilderFactory factory = null; 
    23   private static DocumentBuilder parser = null; 
    2422 
    25   static { 
    26     if(factory == null) { 
    27       factory = DocumentBuilderFactory.newInstance(); 
    28       factory.setIgnoringComments(true); 
    29       factory.setCoalescing(true); // Convert CDATA to Text nodes 
    30       factory.setNamespaceAware(false); // No namespaces: this is default 
    31       factory.setValidating(false); // Don't validate DTD: also default 
     23  // This is the text type in the noit_log.h 
     24  public final static String METRIC_STRING = "s"; 
     25   
     26  public static String[] parseToArray(String jlog, int num) { 
     27    // Get rid of the null parameter 
     28    return jlog.substring(0, jlog.length()-1).split("[\t]", num); 
     29  } 
     30 
     31  protected String getPrefix() { 
     32     return null; 
     33  } 
     34 
     35  protected int getLength() { 
     36     return -1; 
     37  } 
     38 
     39  // Check and make sure 
     40  public StratconMessage(String[] parts) throws Exception { 
     41    if (!parts[0].equals(this.getPrefix())) { 
     42      throw new Exception("Incorrect state prefix:" + getPrefix() + " not applicable for " + getClass()); 
    3243    } 
    33     if(parser == null) { 
    34       try { 
    35         parser = factory.newDocumentBuilder(); 
    36       } catch(Exception e) { } 
     44    if (parts.length != getLength()) { 
     45      throw new Exception("Incorrect amount of parts parsed, tossing message."); 
    3746    } 
    3847  } 
    3948 
    40   public static StratconMessage makeMessage(String xml) { 
    41     InputSource source = new InputSource(new StringReader(xml)); 
    42  
     49  public static StratconMessage makeMessage(String jlog) { 
     50    String[] parts; 
     51    // The numbers of the parse are pulled from stratcon and 
     52    // +1 for the extra remote 
    4353    try { 
    44       Document document = parser.parse(source); 
    45       Element e = document.getDocumentElement(); 
    46       String tag = e.getTagName(); 
    47       // We have events 
    48       if(tag.equals("NoitStatus") || 
    49          tag.equals("NoitMetricText") || 
    50          tag.equals("NoitCheck")) 
    51         return new NoitEvent(document); 
    52       else if(tag.equals("NoitMetricNumeric")) { 
    53         // Numerics have a value that can be in scientific notation. 
    54         // This document gets passed places that do Xpath 1.0 queries 
    55         // which don't understand scientific notation... we have to hack it. 
    56         return new NoitMetricNumeric(document); 
     54      switch (jlog.charAt(0)) { 
     55        case 'C': 
     56          parts = parseToArray(jlog, 7); 
     57          return new NoitCheck(parts); 
     58        case 'S': 
     59          parts = parseToArray(jlog, 8); 
     60          return new NoitStatus(parts); 
     61        case 'M': 
     62          parts = parseToArray(jlog, 7); 
     63          if (parts[5].equals(METRIC_STRING)) { 
     64            return new NoitMetricText(parts); 
     65          } else { 
     66            return new NoitMetricNumeric(parts); 
     67          } 
     68        case 'D': 
     69          parts = parseToArray(jlog, 4); 
     70          return new StratconStatement(parts); 
     71        case 'Q': 
     72          parts = parseToArray(jlog, 5); 
     73          return new StratconQuery(parts); 
     74        case 'q': 
     75          parts = parseToArray(jlog, 3); 
     76          return new StratconQueryStop(parts); 
    5777      } 
    58       // and requests 
    59       else if(tag.equals("StratconStatement")) 
    60         return new StratconStatement(document); 
    61       else if(tag.equals("StratconQuery")) 
    62         return new StratconQuery(document); 
    63       else if(tag.equals("StratconQueryStop")) 
    64         return new StratconQueryStop(document); 
    6578    } 
    6679    catch(Exception e) { 
  • src/java/com/omniti/reconnoiter/broker/AMQBroker.java

    r4c3fb9b r0335d9d  
    1717 
    1818public class AMQBroker implements IMQBroker { 
    19    
    20   private StratconConfig config; 
    2119 
    2220  public AMQBroker(StratconConfig config) { 
    23     this.config = config; 
    24     // TODO Auto-generated constructor stub 
    2521  } 
    2622 
    27   private ActiveMQConnectionFactory connectionFactory; 
    28   private Connection connection; 
    29   private Session session; 
    30   private Destination destination; 
    3123  private MessageConsumer consumer; 
    3224 
    3325  public void connect() { 
    3426    BrokerFactory.getAMQBrokerService(); 
    35     connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616"); 
     27    ActiveMQConnectionFactory connectionFactory=new ActiveMQConnectionFactory("tcp://localhost:61616"); 
    3628    try { 
    37       connection = connectionFactory.createConnection(); 
     29      Connection connection=connectionFactory.createConnection(); 
    3830      connection.start(); 
    39       session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); 
    40       destination = session.createQueue("noit.firehose"); 
     31      Session session=connection.createSession(false, Session.AUTO_ACKNOWLEDGE); 
     32      Destination destination=session.createQueue("noit.firehose"); 
    4133   
    4234      consumer = session.createConsumer(destination); 
     
    5143      try { 
    5244        message = consumer.receive(1000); 
    53       } catch(Exception e) { 
    54          
     45      } catch(Exception ignored) { 
    5546      } 
    5647      if (message != null && message instanceof TextMessage) { 
     
    6960    return new AMQListener(epService, sq); 
    7061  } 
    71  
    7262} 
  • src/java/com/omniti/reconnoiter/broker/RabbitBroker.java

    re372885 r0335d9d  
    1515 
    1616 
    17 public class RabbitBroker implements IMQBroker, Runnable  { 
     17public class RabbitBroker implements IMQBroker  { 
    1818 
    1919  private Channel channel; 
     
    2929  private String alertQueue; 
    3030  private String alertExchangeName; 
    31   private StratconConfig config ; 
    3231 
    3332  public RabbitBroker(StratconConfig config) { 
    34     this.config = config; 
    3533    this.userName = config.getBrokerParameter("username", "guest"); 
    3634    this.password = config.getBrokerParameter("password", "guest"); 
     
    110108    return new RabbitListener(epService, sq, channel, alertExchangeName, alertQueue); 
    111109  } 
    112  
    113   public void run() { 
    114   } 
    115  
    116110} 
  • src/java/com/omniti/reconnoiter/broker/RabbitListener.java

    ra3f2dff r0335d9d  
    1515  private EPServiceProvider epService; 
    1616  private StratconQuery sq; 
    17   private EPStatement statement; 
    1817  private String routingKey; 
    1918  private String exchangeName; 
     
    2524      this.epService = epService; 
    2625      this.sq = sq; 
    27       this.statement = sq.getStatement(); 
     26      EPStatement statement=sq.getStatement(); 
    2827      this.routingKey = routingKey + sq.getName(); 
    2928      this.exchangeName = exchangeName; 
    3029      this.channel = channel; 
    31       // TODO Document this mapping 
    3230       
    33  
    3431      // Create the connection and add an exchange 
    3532      channel.exchangeDeclare(exchangeName, "topic", false, false, false, null);   
     
    4138   
    4239  public void update(EventBean[] newEvents, EventBean[] oldEvents) { 
    43     // TODO Auto-generated method stub 
    44     System.err.println("AMQOutput -> dispatch"); 
     40    System.err.println("RMQOutput -> dispatch"); 
    4541    for(int i = 0; i < newEvents.length; i++) { 
    4642      EventBean event = newEvents[i]; 
     
    5248      try { 
    5349        byte[] messageBodyBytes = output.getBytes(); 
    54         channel.basicPublish(exchangeName, routingKey, MessageProperties.PERSISTENT_TEXT_PLAIN, messageBodyBytes); 
     50        channel.basicPublish(exchangeName, routingKey, MessageProperties.TEXT_PLAIN, messageBodyBytes); 
    5551      }  catch(Exception e) { 
    5652        System.err.println(e); 
  • src/java/com/omniti/reconnoiter/event/NoitMetricNumeric.java

    r2220278 r0335d9d  
    1111import com.omniti.reconnoiter.StratconMessage; 
    1212 
    13 import org.w3c.dom.Document; 
    14 import org.w3c.dom.Element; 
    15 import org.w3c.dom.Node; 
    16 import org.w3c.dom.NodeList; 
    17 import org.w3c.dom.Text; 
    18  
    1913public class NoitMetricNumeric extends StratconMessage { 
    2014    private String uuid; 
     
    2317    private String noit; 
    2418 
    25     protected String get_string(Element e, String tag) throws NoitMetricNumericException { 
    26       NodeList vals = e.getElementsByTagName(tag); 
    27       if(vals.getLength() != 1) 
    28         throw new NoitMetricNumericException("Bad XML: tag " + tag + " (" + vals.getLength() + ")"); 
    29       Node n = vals.item(0); 
    30       Node tn = n.getFirstChild(); 
    31       if(tn.getNextSibling() != null) 
    32         throw new NoitMetricNumericException("Bad XML: " + tag + " has siblings"); 
    33       if(tn.getNodeType() != Node.TEXT_NODE) 
    34         throw new NoitMetricNumericException("Bad XML: " + tag + " not text"); 
    35       Text text_node = (Text)tn; 
    36       return text_node.getNodeValue(); 
    37     } 
    38     protected Double get_double(Element e, String tag) throws NoitMetricNumericException { 
    39       Double d = null; 
     19  protected String getPrefix() { 
     20     return "M"; 
     21   } 
     22   /* 
     23   'M' REMOTE TIMESTAMP UUID NAME TYPE VALUE 
     24    */ 
     25   public NoitMetricNumeric(String[] parts) throws Exception { 
     26      super(parts); 
     27      noit = parts[1]; 
     28      uuid = parts[3]; 
     29      name = parts[4]; 
    4030      try { 
    41         d = new Double(get_string(e, tag)); 
    42       } catch(NumberFormatException nfe) { 
     31        value = Double.valueOf(parts[6]); 
     32      } catch (NumberFormatException nfe) { 
     33        value = null; 
    4334      } 
    44       return d; 
    45     } 
    4635 
    47     public NoitMetricNumeric(Document document) throws NoitMetricNumericException { 
    48       Element e = document.getDocumentElement(); 
    49       String tag = e.getTagName(); 
    50       if(!tag.equals("NoitMetricNumeric")) 
    51         throw new NoitMetricNumericException("Bad XML"); 
    52       uuid = get_string(e,"id"); 
    53       name = get_string(e,"name"); 
    54       value = get_double(e, "value"); 
    55       noit = get_string(e,"remote"); 
    56     } 
     36   } 
    5737 
    58     public String getuuid() { return uuid; } 
    59     public String getname() { return name; } 
    60     public Double getvalue() { return value; } 
    61     public String getnoit() { return noit; } 
     38    public String getUuid() { return uuid; } 
     39    public String getName() { return name; } 
     40    public Double getValue() { return value; } 
     41    public String getNoit() { return noit; } 
    6242 
    63     private class NoitMetricNumericException extends Exception { 
    64       public NoitMetricNumericException(String s) { 
    65         super(s); 
    66       } 
    67     } 
     43  protected int getLength() { 
     44     return 7; 
     45   } 
    6846} 
  • src/java/com/omniti/reconnoiter/event/StratconQuery.java

    ra3f2dff r0335d9d  
    1313import com.espertech.esper.client.UpdateListener; 
    1414import java.util.UUID; 
    15 import javax.xml.xpath.XPath; 
    16 import javax.xml.xpath.XPathFactory; 
    17 import javax.xml.xpath.XPathConstants; 
    18 import javax.xml.xpath.XPathExpressionException; 
    19 import org.w3c.dom.Document; 
    2015 
    2116public class StratconQuery extends StratconQueryBase { 
     
    2318  protected String name; 
    2419 
    25   public StratconQuery(Document d) { 
    26     XPath xpath = XPathFactory.newInstance().newXPath(); 
    27     try { 
    28       String id = (String) xpath.evaluate("/StratconQuery/id", d, XPathConstants.STRING); 
    29       if(id == null) uuid = UUID.randomUUID(); 
    30       else uuid = UUID.fromString(id); 
    31       name = (String) xpath.evaluate("/StratconQuery/name", d, XPathConstants.STRING); 
    32       expression = (String) xpath.evaluate("/StratconQuery/expression", d, XPathConstants.STRING); 
    33     } 
    34     catch(XPathExpressionException e) { 
    35     } 
     20  protected String getPrefix() { 
     21     return "Q"; 
     22   } 
     23 
     24  /*  'Q' REMOTE ID NAME QUERY  */ 
     25  public StratconQuery(String[] parts) throws Exception { 
     26    super(parts); 
     27    String id = parts[2]; 
     28    name = parts[3]; 
     29    expression = parts[4]; 
     30    if(id == null) 
     31      uuid = UUID.randomUUID(); 
     32    else 
     33      uuid = UUID.fromString(id); 
     34 
    3635    if(name == null) name = "default"; 
    3736    if(uuid == null) uuid = UUID.randomUUID(); 
     
    4746    statement.destroy(); 
    4847  } 
     48 
     49  protected int getLength() { 
     50    return 5; 
     51  } 
    4952} 
  • src/java/com/omniti/reconnoiter/event/StratconQueryBase.java

    ra3f2dff r0335d9d  
    1919  protected String expression; 
    2020 
     21  public StratconQueryBase(String parts[]) throws Exception { 
     22    super(parts); 
     23  } 
     24 
    2125  public UUID getUUID() { 
    2226    return uuid; 
  • src/java/com/omniti/reconnoiter/event/StratconQueryStop.java

    ra3f2dff r0335d9d  
    1414import org.w3c.dom.Element; 
    1515 
    16 public class StratconQueryStop extends StratconMessage { 
    17   private UUID uuid; 
     16public class StratconQueryStop extends StratconQueryBase { 
    1817 
    19   public StratconQueryStop(Document d) { 
    20     Element e = d.getDocumentElement(); 
    21     uuid = UUID.fromString(e.getTextContent()); 
     18   protected String getPrefix() { 
     19     return "q"; 
     20   } 
     21 
     22/*  'q' REMOTE ID */ 
     23  public StratconQueryStop(String[] parts) throws Exception { 
     24    super(parts); 
     25    uuid = UUID.fromString(parts[2]); 
    2226  } 
    2327  public UUID getUUID() { 
    2428    return uuid; 
    2529  } 
     30 
     31  protected int getLength() { 
     32    return 3; 
     33  } 
    2634   
    2735} 
  • src/java/com/omniti/reconnoiter/event/StratconStatement.java

    ra3f2dff r0335d9d  
    1010 
    1111import com.omniti.reconnoiter.event.StratconQueryBase; 
     12import com.espertech.esper.client.UpdateListener; 
     13 
    1214import java.util.UUID; 
    1315import javax.xml.xpath.XPath; 
     
    1820 
    1921public class StratconStatement extends StratconQueryBase { 
    20   public StratconStatement(Document d) { 
    21     XPath xpath = XPathFactory.newInstance().newXPath(); 
    22     try { 
    23       String id = (String) xpath.evaluate("/StratconStatement/id", d, XPathConstants.STRING); 
    24       if(id == null) uuid = UUID.randomUUID(); 
    25       else uuid = UUID.fromString(id); 
    26       expression = (String) xpath.evaluate("/StratconStatement/expression", d, XPathConstants.STRING); 
    27     } 
    28     catch(XPathExpressionException e) { 
    29     } 
    30     if(uuid == null) uuid = UUID.randomUUID(); 
     22 
     23   protected String getPrefix() { 
     24     return "D"; 
     25   } 
     26 
     27   /*  'D' REMOTE ID QUERY  */ 
     28   public StratconStatement(String[] parts) throws Exception { 
     29      super(parts); 
     30      String id = parts[2]; 
     31      expression = parts[3]; 
     32      if(id == null) 
     33        uuid = UUID.randomUUID(); 
     34      else 
     35        uuid = UUID.fromString(id); 
     36   } 
     37 
     38  protected int getLength() { 
     39    return 4; 
    3140  } 
    3241} 
  • src/java/run-iep.sh.in

    r660168e r0335d9d  
    22 
    33JAVA=@JAVA@ 
    4 JPARAMS="-Xms512m -Xmx512m -server -XX:+UseParNewGC" 
     4JPARAMS="-Xms32m -Xmx512m -XX:+UseConcMarkSweepGC -XX:+UseParNewGC" 
    55JARS="reconnoiter.jar activemq-all-5.2.0.jar antlr-runtime-3.1.1.jar \ 
    66        esper-3.2.0.jar log4j-1.2.15.jar \ 
  • src/stratcon_iep.c

    rb9a4230 r0335d9d  
    4141#include "noit_conf.h" 
    4242#include "noit_check.h" 
    43 #include "noit_xml.h" 
    4443 
    4544#include <sys/types.h> 
     
    5251#endif 
    5352#include <assert.h> 
    54 #include <libxml/parser.h> 
    55 #include <libxml/tree.h> 
    56 #include <libxml/xmlsave.h> 
    5753#ifdef OPENWIRE 
    5854#include "amqcs.h" 
     
    7975  char *line;       /* This is a copy and gets trashed during processing */ 
    8076  char *remote; 
    81   xmlDocPtr doc; 
    8277  char *doc_str; 
    8378  apr_pool_t *pool; 
     
    8782start_iep_daemon(); 
    8883 
    89 static int 
    90 bust_to_parts(char *in, char **p, int len) { 
    91   int cnt = 0; 
    92   char *s = in; 
    93   while(cnt < len) { 
    94     p[cnt++] = s; 
    95     while(*s && *s != '\t') s++; 
    96     if(!*s) break; 
    97     *s++ = '\0'; 
    98   } 
    99   while(*s) s++; /* Move to end */ 
    100   if(s > in && *(s-1) == '\n') *(s-1) = '\0'; /* chomp */ 
    101   return cnt; 
    102 } 
    103  
    104 #define ADDCHILD(a,b) \ 
    105   xmlNewTextChild(root, NULL, (xmlChar *)(a), (xmlChar *)(b)) 
    106 #define NEWDOC(xmldoc,n,stanza) do { \ 
    107   xmlNodePtr root; \ 
    108   xmldoc = xmlNewDoc((xmlChar *)"1.0"); \ 
    109   root = xmlNewDocNode(xmldoc, NULL, (xmlChar *)(n), NULL); \ 
    110   xmlDocSetRootElement(xmldoc, root); \ 
    111   stanza \ 
    112 } while(0) 
    113  
    114  
    115 static xmlDocPtr 
    116 stratcon_iep_doc_from_status(char *data, char *remote) { 
    117   xmlDocPtr doc; 
    118   char *parts[7]; 
    119   if(bust_to_parts(data, parts, 7) != 7) return NULL; 
    120   /* 'S' TIMESTAMP UUID STATE AVAILABILITY DURATION STATUS_MESSAGE */ 
    121   NEWDOC(doc, "NoitStatus", 
    122          { 
    123            ADDCHILD("remote", remote); 
    124            ADDCHILD("id", parts[2]); 
    125            ADDCHILD("state", parts[3]); 
    126            ADDCHILD("availability", parts[4]); 
    127            ADDCHILD("duration", parts[5]); 
    128            ADDCHILD("status", parts[6]); 
    129          }); 
    130   return doc; 
    131 } 
    132  
    133 static xmlDocPtr 
    134 stratcon_iep_doc_from_check(char *data, char *remote) { 
    135   xmlDocPtr doc; 
    136   char *parts[6]; 
    137   if(bust_to_parts(data, parts, 6) != 6) return NULL; 
    138   /* 'C' TIMESTAMP UUID TARGET MODULE NAME */ 
    139   NEWDOC(doc, "NoitCheck", 
    140          { 
    141            ADDCHILD("remote", remote); 
    142            ADDCHILD("id", parts[2]); 
    143            ADDCHILD("target", parts[3]); 
    144            ADDCHILD("module", parts[4]); 
    145            ADDCHILD("name", parts[5]); 
    146          }); 
    147   return doc; 
    148 } 
    149  
    150 static xmlDocPtr 
    151 stratcon_iep_doc_from_metric(char *data, char *remote) { 
    152   xmlDocPtr doc; 
    153   char *parts[6]; 
    154   const char *rootname = "NoitMetricNumeric"; 
    155   const char *valuename = "value"; 
    156   if(bust_to_parts(data, parts, 6) != 6) return NULL; 
    157   /*  'M' TIMESTAMP UUID NAME TYPE VALUE */ 
    158  
    159   if(*parts[4] == METRIC_STRING) { 
    160     rootname = "NoitMetricText"; 
    161     valuename = "message"; 
    162   } 
    163   NEWDOC(doc, rootname, 
    164          { 
    165            ADDCHILD("remote", remote); 
    166            ADDCHILD("id", parts[2]); 
    167            ADDCHILD("name", parts[3]); 
    168            ADDCHILD(valuename, parts[5]); 
    169          }); 
    170   return doc; 
    171 } 
    172  
    173 static xmlDocPtr 
    174 stratcon_iep_doc_from_statement(char *data, char *remote) { 
    175   xmlDocPtr doc; 
    176   char *parts[3]; 
    177   if(bust_to_parts(data, parts, 3) != 3) return NULL; 
    178   /*  'D' ID QUERY  */ 
    179  
    180   NEWDOC(doc, "StratconStatement", 
    181          { 
    182            ADDCHILD("id", parts[1]); 
    183            ADDCHILD("expression", parts[2]); 
    184          }); 
    185   return doc; 
    186 } 
    187  
    188 static xmlDocPtr 
    189 stratcon_iep_doc_from_query(char *data, char *remote) { 
    190   xmlDocPtr doc; 
    191   char *parts[4]; 
    192   if(bust_to_parts(data, parts, 4) != 4) return NULL; 
    193   /*  'Q' ID NAME QUERY  */ 
    194  
    195   NEWDOC(doc, "StratconQuery", 
    196          { 
    197            ADDCHILD("id", parts[1]); 
    198            ADDCHILD("name", parts[2]); 
    199            ADDCHILD("expression", parts[3]); 
    200          }); 
    201   return doc; 
    202 } 
    203  
    204 static xmlDocPtr 
    205 stratcon_iep_doc_from_querystop(char *data, char *remote) { 
    206   xmlDocPtr doc; 
    207   char *parts[2]; 
    208   if(bust_to_parts(data, parts, 2) != 2) return NULL; 
    209   /*  'Q' ID */ 
    210  
    211   NEWDOC(doc, "StratconQueryStop", 
    212          { 
    213            xmlNodeSetContent(root, (xmlChar *)parts[1]); 
    214          }); 
    215   return doc; 
    216 } 
    217  
    218 static xmlDocPtr 
    219 stratcon_iep_doc_from_line(char *data, char *remote) { 
    220   if(data) { 
    221     switch(*data) { 
    222       case 'C': return stratcon_iep_doc_from_check(data, remote); 
    223       case 'S': return stratcon_iep_doc_from_status(data, remote); 
    224       case 'M': return stratcon_iep_doc_from_metric(data, remote); 
    225       case 'D': return stratcon_iep_doc_from_statement(data, remote); 
    226       case 'Q': return stratcon_iep_doc_from_query(data, remote); 
    227       case 'q': return stratcon_iep_doc_from_querystop(data, remote); 
    228     } 
    229   } 
    230   return NULL; 
    231 } 
    23284 
    23385static float 
     
    537389      } 
    538390 
    539  
    540  
    541 /* 
    542       We don't use login/pass 
    543       apr_hash_set(frame.headers, "login", APR_HASH_KEY_STRING, ""); 
    544       apr_hash_set(frame.headers, "passcode", APR_HASH_KEY_STRING, ""); 
    545 */ 
    546391      frame.body = NULL; 
    547392      frame.body_length = -1; 
     
    604449      if(job->remote) free(job->remote); 
    605450      if(job->doc_str) free(job->doc_str); 
    606       if(job->doc) xmlFreeDoc(job->doc); 
    607451      if(job->pool) apr_pool_destroy(job->pool); 
    608452      free(job); 
     
    619463    return 0; 
    620464  } 
    621   job->doc = stratcon_iep_doc_from_line(job->line, job->remote); 
    622   if(job->doc) { 
    623     job->doc_str = noit_xmlSaveToBuffer(job->doc); 
    624     if(job->doc_str) { 
    625       /* Submit */ 
    626       if(driver && driver->pool && driver->connection) { 
    627         apr_status_t rc; 
     465  /* Submit */ 
     466  if(driver && driver->pool && driver->connection) { 
     467    apr_status_t rc; 
     468    int line_len = strlen(job->line); 
     469    int remote_len = strlen(job->remote); 
    628470#ifdef OPENWIRE 
    629         ow_ActiveMQQueue *dest; 
    630         ow_ActiveMQTextMessage *message; 
    631  
    632         apr_pool_create(&job->pool, driver->pool); 
    633         message = ow_ActiveMQTextMessage_create(job->pool); 
    634         message->content = 
    635           ow_byte_array_create_with_data(job->pool,strlen(job->doc_str), 
    636                                          job->doc_str); 
    637         dest = ow_ActiveMQQueue_create(job->pool); 
    638         dest->physicalName = ow_string_create_from_cstring(job->pool,"TEST.QUEUE");          
    639         rc = amqcs_send(driver->connection, 
    640                         (ow_ActiveMQDestination*)dest, 
    641                         (ow_ActiveMQMessage*)message, 
    642                         1,4,0,job->pool); 
    643         if(rc != APR_SUCCESS) { 
    644           noitL(noit_error, "MQ send failed, disconnecting\n"); 
    645           if(driver->connection) amqcs_disconnect(&driver->connection); 
    646           driver->connection = NULL; 
    647        
     471    ow_ActiveMQQueue *dest; 
     472    ow_ActiveMQTextMessage *message; 
     473 
     474    apr_pool_create(&job->pool, driver->pool); 
     475    message = ow_ActiveMQTextMessage_create(job->pool); 
     476    message->content = 
     477      ow_byte_array_create_with_data(job->pool,strlen(job->doc_str), 
     478                                     job->doc_str); 
     479    dest = ow_ActiveMQQueue_create(job->pool); 
     480    dest->physicalName = ow_string_create_from_cstring(job->pool,"TEST.QUEUE");          
     481    rc = amqcs_send(driver->connection, 
     482                    (ow_ActiveMQDestination*)dest, 
     483                    (ow_ActiveMQMessage*)message, 
     484                    1,4,0,job->pool); 
     485    if(rc != APR_SUCCESS) { 
     486      noitL(noit_error, "MQ send failed, disconnecting\n"); 
     487      if(driver->connection) amqcs_disconnect(&driver->connection); 
     488      driver->connection = NULL; 
     489   
    648490#else 
    649         stomp_frame out; 
    650  
    651         apr_pool_create(&job->pool, driver->pool); 
    652  
    653         out.command = "SEND"; 
    654         out.headers = apr_hash_make(job->pool); 
    655         if (driver->exchange) 
    656           apr_hash_set(out.headers, "exchange", APR_HASH_KEY_STRING, driver->exchange); 
    657  
    658         apr_hash_set(out.headers, "destination", APR_HASH_KEY_STRING, "/queue/noit.firehose"); 
    659         apr_hash_set(out.headers, "ack", APR_HASH_KEY_STRING, "auto"); 
    660        
    661         out.body_length = -1; 
    662         out.body = job->doc_str; 
    663         rc = stomp_write(driver->connection, &out, job->pool); 
    664         if(rc != APR_SUCCESS) { 
    665           noitL(noit_error, "STOMP send failed, disconnecting\n"); 
    666           if(driver->connection) stomp_disconnect(&driver->connection); 
    667           driver->connection = NULL; 
    668         } 
     491    stomp_frame out; 
     492 
     493    job->doc_str = (char*)calloc(line_len + 1 /* \t */ + 
     494        remote_len + 2, 1); 
     495    strncpy(job->doc_str, job->line, 2); 
     496    strncat(job->doc_str, job->remote, remote_len); 
     497    strncat(job->doc_str, "\t", 1); 
     498    strncat(job->doc_str, job->line + 2, line_len - 2); 
     499 
     500    apr_pool_create(&job->pool, driver->pool); 
     501 
     502    out.command = "SEND"; 
     503    out.headers = apr_hash_make(job->pool); 
     504    if (driver->exchange) 
     505      apr_hash_set(out.headers, "exchange", APR_HASH_KEY_STRING, driver->exchange); 
     506 
     507    apr_hash_set(out.headers, "destination", APR_HASH_KEY_STRING, "/queue/noit.firehose"); 
     508    apr_hash_set(out.headers, "ack", APR_HASH_KEY_STRING, "auto"); 
     509   
     510    out.body_length = -1; 
     511    out.body = job->doc_str; 
     512    rc = stomp_write(driver->connection, &out, job->pool); 
     513    if(rc != APR_SUCCESS) { 
     514      noitL(noit_error, "STOMP send failed, disconnecting\n"); 
     515      if(driver->connection) stomp_disconnect(&driver->connection); 
     516      driver->connection = NULL; 
     517    } 
    669518#endif 
    670       } 
    671       else { 
    672         noitL(noit_error, "Not submitting event, no MQ\n"); 
    673       } 
    674     } 
    675519  } 
    676520  else { 
    677     noitL(noit_iep, "no iep handler for: '%s'\n", job->line); 
     521    noitL(noit_iep, "no iep handler for: '%s'\n", job->line);  
    678522  } 
    679523  return 0; 
     
    818662                           &info->command)) { 
    819663    noitL(noit_error, "No IEP start command provided.  You're on your own.\n"); 
    820     goto bail; 
     664    // goto bail; 
     665    // If you want to start it as a seperate process 
     666    return; 
    821667  } 
    822668  if(pipe(info->stdin_pipe) != 0 ||