Ejemplo n.º 1
0
 @Counter
 public void process(CounterBasket pw) {
   if (CounterConstants.TOMCAT.equals(ObjTypeDetector.objType) == false) {
     return;
   }
   getMBeanServer();
   if ((collectCnt <= 40 && collectCnt % 5 == 0) || ObjTypeDetector.dirtyConfig) {
     if (ObjTypeDetector.dirtyConfig) {
       AgentHeartBeat.clearSubObjects();
       ObjTypeDetector.dirtyConfig = false;
     }
     getContextList();
   }
   collectCnt++;
   for (CtxObj ctx : ctxList) {
     if (ctx.valueType == ValueEnum.DECIMAL) {
       try {
         MeterKey key = new MeterKey(ctx.mbeanHash, ctx.counter);
         long v = CastUtil.clong(server.getAttribute(ctx.mbean, ctx.attrName));
         if (deltas.contains(ctx.counter)) {
           v = getDelta(key, v);
           MeterResource meter = getMeter(key);
           meter.add(v);
           v = (long) meter.getSum(60);
           long sum = (long) meter.getSum(300) / 5;
           pw.getPack(ctx.objName, TimeTypeEnum.REALTIME).add(ctx.counter, new DecimalValue(v));
           pw.getPack(ctx.objName, TimeTypeEnum.FIVE_MIN).add(ctx.counter, new DecimalValue(sum));
         } else {
           MeterResource meter = getMeter(key);
           meter.add(v);
           double d = meter.getAvg(30);
           double avg = meter.getAvg(300);
           FloatValue value = new FloatValue((float) d);
           FloatValue avgValue = new FloatValue((float) avg);
           pw.getPack(ctx.objName, TimeTypeEnum.REALTIME).add(ctx.counter, value);
           pw.getPack(ctx.objName, TimeTypeEnum.FIVE_MIN).add(ctx.counter, avgValue);
         }
       } catch (Exception e) {
         errors.add(ctx.attrName);
         collectCnt = 0;
         Logger.println("A902", e);
       }
     }
   }
   // long cpu2 = SysJMX.getCurrentThreadCPU();
 }