Package tigase.stats

Examples of tigase.stats.StatRecord


    return new XMPPIOService();
  }

  public List<StatRecord> getStatistics() {
    List<StatRecord> stats = super.getStatistics();
    stats.add(new StatRecord(getName(), "Total disconnects", "long",
        totalNodeDisconnects, Level.INFO));

    stats.add(new StatRecord(getName(), "Last day disconnects", "array",
        Arrays.toString(lastDay), Level.FINE));
    stats.add(new StatRecord(getName(), "Last hour disconnects", "array",
        Arrays.toString(lastHour), Level.INFO));
    return stats;
  }
View Full Code Here


    return defs;
  }

  public List<StatRecord> getStatistics() {
    List<StatRecord> stats = new LinkedList<StatRecord>();
    stats.add(new StatRecord(getName(), "Number of VHosts", "int",
            repo.size(), Level.INFO));
    stats.add(new StatRecord(getName(), "Checks: is local domain", "long",
            isLocalDomainCalls, Level.FINER));
    stats.add(new StatRecord(getName(), "Checks: is anonymous domain", "long",
            isAnonymousEnabledCalls, Level.FINER));
    stats.add(new StatRecord(getName(), "Get components for local domain", "long",
            getComponentsForLocalDomainCalls, Level.FINER));
    stats.add(new StatRecord(getName(), "Get components for non-local domain", "long",
            getComponentsForNonLocalDomainCalls, Level.FINER));
    return stats;
  }
View Full Code Here

  public abstract void processPacket(Packet packet);

  public List<StatRecord> getStatistics() {
    List<StatRecord> stats = new LinkedList<StatRecord>();
    stats.add(new StatRecord(getName(), "Last second packets", "int",
        seconds[(sec_idx == 0 ? 59 : sec_idx - 1)], Level.FINE));
    stats.add(new StatRecord(getName(), "Last minute packets", "int",
        minutes[(min_idx == 0 ? 59 : min_idx - 1)], Level.FINE));
    //     long curr_hour = 0;
    //     for (long min: minutes) { curr_hour += min; }
    //for (int sec: seconds) { curr_hour += sec; }
    //curr_hour += curr_second;
    //     if (curr_hour > statAddedMessagesOk) {
    //       // This is not a dirty hack!! It looks weird but this is correct.
    //       // Last second, minute and hour are calculated in different threads
    //       // from the main packets processing thread and sometimes might
    //       // be out of sync. It does look odd on stats page so this statements
    //       // saves from long explanations to non-techies.
    //       curr_hour = statAddedMessagesOk;
    //     }
    stats.add(new StatRecord(getName(), "Last hour packets", "int",
        curr_hour, Level.FINE));
    stats.add(new StatRecord(getName(), StatisticType.MSG_RECEIVED_OK,
        statReceivedMessagesOk, Level.FINE));
    stats.add(new StatRecord(getName(), StatisticType.MSG_SENT_OK,
        statSentMessagesOk, Level.FINE));
    stats.add(new StatRecord(getName(), StatisticType.QUEUE_WAITING,
        (in_queue.size() + out_queue.size()), Level.FINEST));
    stats.add(new StatRecord(getName(), StatisticType.MAX_QUEUE_SIZE,
        maxQueueSize, Level.FINEST));
    stats.add(new StatRecord(getName(), StatisticType.IN_QUEUE_OVERFLOW,
        statReceivedMessagesEr, Level.FINEST));
    stats.add(new StatRecord(getName(), StatisticType.OUT_QUEUE_OVERFLOW,
        statSentMessagesEr, Level.FINEST));
    long res = 0;
    for (long ppt : processPacketTimings) {
      res += ppt;
    }
    stats.add(new StatRecord(getName(),
            "Average processing time on last " +
            processPacketTimings.length + " runs [ms]", "long",
        (res/processPacketTimings.length), Level.FINEST));
    return stats;
  }
View Full Code Here

    long hours = (uptime - (days * 24 * HOUR)) / HOUR;
    long minutes = (uptime - (days * 24 * HOUR + hours * HOUR)) / MINUTE;
    long seconds =
      (uptime - (days * 24 * HOUR + hours * HOUR + minutes * MINUTE)) / SECOND;
    //    StringBuilder sb = new StringBuilder();
    stats.add(new StatRecord(getName(), "Uptime", "time"""
        + (days > 0 ? days + " day, " : "")
        + (hours > 0 ? hours + " hour, " : "")
        + (minutes > 0 ? minutes + " min, " : "")
        + (seconds > 0 ? seconds + " sec" : "")
        , Level.INFO));
//    Runtime runtime = Runtime.getRuntime();
    // Run GC for more accurate memory readings
    //runtime.gc();
//    long maxMem = runtime.maxMemory();
//    long totalMem = runtime.totalMemory();
//    long freeMem = runtime.freeMemory();
//    stats.add(new StatRecord(getName(), "Max JVM mem", "long", maxMem,
//        Level.FINEST));
//    stats.add(new StatRecord(getName(), "Total JVM mem", "long", totalMem,
//        Level.FINEST));
//    stats.add(new StatRecord(getName(), "Free JVM mem", "long", freeMem,
//        Level.FINEST));

    OperatingSystemMXBean osBean = ManagementFactory.getOperatingSystemMXBean();
    NumberFormat format = NumberFormat.getNumberInstance();
    format.setMaximumFractionDigits(4);
    stats.add(new StatRecord(getName(), "Load average", "double",
            format.format(osBean.getSystemLoadAverage()), Level.INFO));
    stats.add(new StatRecord(getName(), "CPUs no", "int",
            osBean.getAvailableProcessors(), Level.FINEST));

    ThreadMXBean thBean = ManagementFactory.getThreadMXBean();
    stats.add(new StatRecord(getName(), "Threads count", "int",
            thBean.getThreadCount(), Level.FINEST));
    long cpuTime = 0;
    for (long thid : thBean.getAllThreadIds()) {
      cpuTime += thBean.getThreadCpuTime(thid);
    }
//    stats.add(new StatRecord(getName(), "Threads CPU time", "long", cpuTime,
//        Level.FINEST));
    double cpuUsage = (new Long(cpuTime).doubleValue() / 1000000) / new Long(
            uptime).doubleValue();
    format = NumberFormat.getPercentInstance();
    format.setMaximumFractionDigits(2);
    stats.add(new StatRecord(getName(), "CPU usage", "double",
            format.format(cpuUsage), Level.INFO));
    MemoryUsage heap = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
    MemoryUsage nonHeap =
            ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage();

    format = NumberFormat.getIntegerInstance();
    if (format instanceof DecimalFormat) {
      DecimalFormat decf = (DecimalFormat)format;
      decf.applyPattern(decf.toPattern()+" KB");
    }
    stats.add(new StatRecord(getName(), "Max Heap mem", "long",
            format.format(heap.getMax()/1024), Level.INFO));
    stats.add(new StatRecord(getName(), "Used Heap", "long",
            format.format(heap.getUsed()/1024), Level.INFO));
    stats.add(new StatRecord(getName(), "Free Heap", "long",
            format.format((heap.getMax() - heap.getUsed())/1024), Level.INFO));
    stats.add(new StatRecord(getName(), "Max NonHeap mem", "long",
            format.format(nonHeap.getMax()/1024), Level.INFO));
    stats.add(new StatRecord(getName(), "Used NonHeap", "long",
            format.format(nonHeap.getUsed()/1024), Level.INFO));
    stats.add(new StatRecord(getName(), "Free NonHeap", "long",
            format.format((nonHeap.getMax() - nonHeap.getUsed())/1024), Level.INFO));

    return stats;
  }
View Full Code Here

    return services.size();
  }

  public List<StatRecord> getStatistics() {
    List<StatRecord> stats = super.getStatistics();
    stats.add(new StatRecord(getName(), "Open connections", "int",
        services.size(), Level.FINE));
//     StringBuilder sb = new StringBuilder("All connected: ");
//     for (IOService serv: services.values()) {
//       sb.append("\nService ID: " + getUniqueId(serv)
//         + ", local-hostname: " + serv.getSessionData().get("local-hostname")
View Full Code Here

    } // end of switch (service.connectionType())
  }

  public List<StatRecord> getStatistics() {
    List<StatRecord> stats = super.getStatistics();
    stats.add(new StatRecord(getName(), "Open s2s connections", "int",
        servicesByHost_Type.size(), Level.INFO));
    int waiting = 0;
    for (Queue<Packet> q: waitingPackets.values()) {
      waiting += q.size();
    }
    stats.add(new StatRecord(getName(), "Packets queued", "int",
        waiting, Level.INFO));
    stats.add(new StatRecord(getName(), "Connecting s2s connections", "int",
        connectingByHost_Type.size(), Level.FINE));
    stats.add(new StatRecord(getName(), "Handshaking s2s connections", "int",
        handshakingByHost_Type.size(), Level.FINER));
//     StringBuilder sb = new StringBuilder("Handshaking: ");
//     for (IOService serv: handshakingByHost_Type.values()) {
//       sb.append("\nService ID: " + getUniqueId(serv)
//         + ", local-hostname: " + serv.getSessionData().get("local-hostname")
//         + ", remote-hostname: " + serv.getSessionData().get("remote-hostname")
//         + ", is-connected: " + serv.isConnected()
//         + ", connection-type: " + serv.connectionType());
//     }
//     log.finest(sb.toString());
    LinkedList<String> waiting_qs = new LinkedList<String>();
    for (Map.Entry<String, ServerPacketQueue> entry: waitingPackets.entrySet()) {
      if (entry.getValue().size() > 0) {
        waiting_qs.add(entry.getKey() + ":  " + entry.getValue().size());
      }
    }
    if (waiting_qs.size() > 0) {
      stats.add(new StatRecord(getName(), "Packets queued for each connection",
          waiting_qs,  Level.FINER));
    }
    ArrayList<String> all_s2s = new ArrayList<String>(servicesByHost_Type.keySet());
    Collections.sort(all_s2s);
    stats.add(new StatRecord(getName(), "s2s connections", all_s2s,  Level.FINEST));
    return stats;
  }
View Full Code Here

    }
  }

  public List<StatRecord> getStatistics() {
    List<StatRecord> stats = super.getStatistics();
    stats.add(new StatRecord(getName(), "Open connections", "int",
        connectionsByFrom.size(), Level.FINE));
    stats.add(new StatRecord(getName(), "Registered accounts", "long",
        user_repository.getUsersCount(), Level.INFO));
    stats.add(new StatRecord(getName(), "Open authorized sessions", "int",
        sessionsByNodeId.size(), Level.INFO));
    stats.add(new StatRecord(getName(), "Closed connections", "long",
        closedConnections, Level.FINER));
    return stats;
  }
View Full Code Here

              ", outgoingIsNull(): " + conn.outgoingIsNull() +
              ", outgoingActive: " + conn.isOutgoingConnected() +
              ", OutgoingState: " + conn.getOutgoingState().toString() +
              ", db_keys.size(): " + conn.getDBKeysSize());
    }
     stats.add(new StatRecord(getName(), "Open s2s connections", "int",
         open_s2s_connections, Level.INFO));
    stats.add(new StatRecord(getName(), "Packets queued", "int",
        waiting_packets, Level.INFO));
    stats.add(new StatRecord(getName(), "Connected servers", "int",
        connected_servers, Level.FINE));
    stats.add(new StatRecord(getName(), "Connection instances", "int",
        server_connections_instances, Level.FINER));
    return stats;
  }
View Full Code Here

    } // end of for (RosterItem ri: roster.values())
  }

  public List<StatRecord> getStats() {
    List<StatRecord> stats = new LinkedList<StatRecord>();
    stats.add(new StatRecord(getJID(), "Roster size", "int",
        roster.size(), Level.INFO));
    stats.add(new StatRecord(getJID(), "Packets received", "long",
        packets_received, Level.INFO));
    stats.add(new StatRecord(getJID(), "Packets sent", "long",
        packets_sent, Level.INFO));
    int moderation_needed = 0;
    for (RosterItem ri: roster.values()) {
      moderation_needed += (ri.isModerationAccepted() ? 0 : 1);
    } // end of for (RosterItem ri: roster)
    stats.add(new StatRecord(getJID(), "Awaiting moderation", "int",
        moderation_needed, Level.INFO));
    return stats;
  }
View Full Code Here

TOP

Related Classes of tigase.stats.StatRecord

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.