@@ -0,0 +1,2406 @@
+package com.nitorcreations.willow.deployer.statistics;%0A%0Aimport java.lang.reflect.InvocationTargetException;%0Aimport java.util.Properties;%0Aimport java.util.concurrent.TimeUnit;%0Aimport java.util.logging.Level;%0A%0Aimport javax.inject.Named;%0A%0Aimport org.apache.commons.beanutils.PropertyUtils;%0Aimport org.hyperic.sigar.ProcCpu;%0Aimport org.hyperic.sigar.Sigar;%0Aimport org.hyperic.sigar.SigarException;%0Aimport org.hyperic.sigar.ptql.MalformedQueryException;%0Aimport org.hyperic.sigar.ptql.ProcessQuery;%0Aimport org.hyperic.sigar.ptql.ProcessQueryFactory;%0A%0Aimport com.nitorcreations.willow.messages.ProcessCPU;%0A%0A@Named(%22ptql%22)%0Apublic class PTQLStatisticsSender extends AbstractStatisticsSender %7B%0A  protected Sigar sigar = new Sigar();%0A  private ProcessQuery query;%0A  private long nextProcCpus = System.currentTimeMillis();%0A  private long interval = - 1;%0A%0A  @Override%0A  public void setProperties(Properties properties) %7B%0A    String q = properties.getProperty(%22query%22);%0A    if (q == null) throw new IllegalArgumentException(%22Must define a query%22);%0A    interval = Long.parseLong(properties.getProperty(%22interval%22, %225000%22));%0A    try %7B%0A      query = ProcessQueryFactory.getInstance().getQuery(q);%0A    %7D catch (MalformedQueryException e) %7B%0A      throw new IllegalArgumentException(%22Invalid query%22, e);%0A    %7D%0A  %7D%0A%0A%0A  @Override%0A  public void execute() %7B%0A    if (query == null) %7B%0A      throw new IllegalStateException(%22Tried to start unconfigured statistics sender%22);%0A    %7D%0A    ProcCpu pCStat;%0A    long now = System.currentTimeMillis();%0A    if (now %3E nextProcCpus) %7B%0A      try %7B%0A        for (long pid : query.find(sigar)) %7B%0A          if (pid %3E 0) %7B%0A            pCStat = sigar.getProcCpu(pid);%0A            String pName = sigar.getProcState(pid).getName().replaceAll(%22%5C%5CW%22, %22_%22);%0A            ProcessCPU msg = new ProcessCPU();%0A            PropertyUtils.copyProperties(msg, pCStat);%0A            msg.addTags(%22category_processcpu_%22 + pName + %22_%22 + pid);%0A            transmitter.queue(msg);%0A          %7D%0A        %7D%0A      %7D catch (SigarException %7C IllegalAccessException %7C InvocationTargetException %7C NoSuchMethodException e) %7B%0A        logger.log(Level.WARNING, %22Failed to Process CPU statistics%22, e);%0A      %7D%0A      nextProcCpus = nextProcCpus + interval;%0A    %7D%0A    try %7B%0A      TimeUnit.MILLISECONDS.sleep(interval);%0A    %7D catch (InterruptedException e) %7B%0A      logger.info(%22Process statistics interrupted%22);%0A      return;%0A    %7D%0A  %7D%0A%0A%7D%0A

Add missing class