コード例 #1
0
  public void startMetrics() {
    try {
      Metrics metrics = new Metrics(this);

      Graph graph = metrics.createGraph("Durability");

      graph.addPlotter(
          new Metrics.Plotter("Obsidian Durability Per Server") {

            @Override
            public String getColumnName() {
              return String.valueOf(config.getoDurability());
            }

            @Override
            public int getValue() {
              return 1;
            }
          });

      metrics.start();
    } catch (IOException e) {
      LOG.log(Level.WARNING, "Failed to submit the stats D:"); // Failed to submit the stats :-(
    }
  }
コード例 #2
0
 private void startStats() {
   try {
     Metrics metrics = new Metrics(this);
     Graph graph = metrics.createGraph("Carpets");
     graph.addPlotter(
         new Metrics.Plotter("Total") {
           @Override
           public int getValue() {
             int i = 0;
             for (Carpet c : carpets.all()) {
               i = i + 1;
             }
             return i;
           }
         });
     graph.addPlotter(
         new Metrics.Plotter("Current") {
           @Override
           public int getValue() {
             int i = 0;
             for (Carpet c : carpets.all()) {
               if (c == null || !c.isVisible()) {
                 continue;
               }
               i = i + 1;
             }
             return i;
           }
         });
     metrics.start();
   } catch (IOException e) {
     log.warning("Failed to submit stats.");
   }
 }
コード例 #3
0
ファイル: CSS.java プロジェクト: tnt996/CommandSync
  public void onEnable() {
    String[] data = loadConfig();
    if (data[3].equals("UNSET")) {
      debugger.debug(
          "!!! THE CONFIG FILE CONTAINS UNSET VALUES - YOU MUST FIX THEM BEFORE THE PLUGIN WILL WORK !!! ");
      return;
    }
    try {
      server = new ServerSocket(Integer.parseInt(data[1]), 50, InetAddress.getByName(data[0]));
      debugger.debug("Opened server on " + data[0] + ":" + data[1] + ".");
      new ClientListener(this, Integer.parseInt(data[2]), data[3]).start();
    } catch (Exception e) {
      e.printStackTrace();
    }
    loadData();
    try {
      Metrics metrics = new Metrics(this);
      Graph graph1 = metrics.createGraph("Total queries sent");
      graph1.addPlotter(
          new Metrics.Plotter() {
            public int getValue() {
              return oq.size();
            }

            public String getColumnName() {
              return "Total queries sent";
            }
          });
      Graph graph2 = metrics.createGraph("Total servers linked");
      graph2.addPlotter(
          new Metrics.Plotter() {
            public int getValue() {
              return qc.keySet().size();
            }

            public String getColumnName() {
              return "Total servers linked";
            }
          });
      metrics.start();
      getProxy().getPluginManager().registerListener(this, new EventListener(this));
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
コード例 #4
0
ファイル: Main.java プロジェクト: Hurricaaane/ThisLogMustDie
  public void startMetrics() {

    try {
      log("Starting Metrics");
      Metrics metrics = new Metrics(this);
      Metrics.Graph fitersCount = metrics.createGraph("Number of filters");
      for (final String name : filterCountMap.keySet()) {
        fitersCount.addPlotter(
            new Metrics.Plotter(name) {

              @Override
              public int getValue() {
                // System.out.println("metrics:"+name+":"+filterCountMap.get(name));
                return filterCountMap.get(name);
              }
            });
      }
      metrics.start();
    } catch (IOException e) {
      log("Cannot start Metrics...");
    }
  }
コード例 #5
0
  private void initMetrics() {
    try {
      Metrics metrics = new Metrics(this);
      Metrics.Graph g = metrics.createGraph("TekkitRestrict Stats");

      g.addPlotter(
          new Metrics.Plotter("Total Safezones") {
            @Override
            public int getValue() {
              return TRSafeZone.zones.size();
            }
          });

      g.addPlotter(
          new Metrics.Plotter("Recipe blocks") {
            @Override
            public int getValue() {
              try {
                int size = 0;
                List<String> ssr =
                    tekkitrestrict.config.getStringList(ConfigFile.Advanced, "RecipeBlock");
                for (String s : ssr) {

                  try {
                    size += TRItemProcessor.processItemString(s).size();
                  } catch (TRException e) {
                    continue;
                  }
                }
                ssr =
                    tekkitrestrict.config.getStringList(ConfigFile.Advanced, "RecipeFurnaceBlock");
                for (String s : ssr) {
                  try {
                    size += TRItemProcessor.processItemString(s).size();
                  } catch (TRException e) {
                    continue;
                  }
                }
                return size;
              } catch (Exception ex) {
                return 0;
              }
            }
          });

      g.addPlotter(
          new Metrics.Plotter("Disabled items") {
            @Override
            public int getValue() {
              try {
                return TRNoItem.getBannedItemsAmount();
              } catch (Exception ex) {
                return 0;
              }
            }
          });
      metrics.start();
    } catch (IOException e) {
      Warning.load("Metrics failed to start.", false);
    }
  }
コード例 #6
0
ファイル: MetricsHandler.java プロジェクト: Thidox/GiantBanks
  public MetricsHandler(final GiantBanks plugin) {
    final config conf = config.Obtain();

    try {
      Metrics metrics = new Metrics(plugin);

      if (conf.getBoolean(plugin.getName() + ".metrics.send.database")) {
        Graph graph = metrics.createGraph("Database Engine");
        graph.addPlotter(
            new Metrics.Plotter(Database.Obtain().getType()) {

              @Override
              public int getValue() {
                return 1;
              }
            });
      }

      if (conf.getBoolean(plugin.getName() + ".metrics.send.updater")) {
        Graph graph = metrics.createGraph("Update warning");
        graph.addPlotter(
            new Metrics.Plotter(
                (conf.getBoolean(plugin.getName() + ".Updater.checkForUpdates")
                    ? "Enabled"
                    : "Disabled")) {

              @Override
              public int getValue() {
                return 1;
              }
            });
      }

      if (conf.getBoolean(plugin.getName() + ".metrics.send.logging")) {
        Graph graph = metrics.createGraph("Use logging");
        graph.addPlotter(
            new Metrics.Plotter(
                (conf.getBoolean(plugin.getName() + ".log.useLogging") ? "Yes" : "No")) {

              @Override
              public int getValue() {
                return 1;
              }
            });
      }

      if (conf.getBoolean(plugin.getName() + ".metrics.send.cache")) {
        Graph graph = metrics.createGraph("Using caching");
        graph.addPlotter(
            new Metrics.Plotter(
                (conf.getBoolean(plugin.getName() + ".cache.useCache") ? "Yes" : "No")) {

              @Override
              public int getValue() {
                return 1;
              }
            });

        graph = metrics.createGraph("Cache");
        graph.addPlotter(
            new Metrics.Plotter("Banks") {

              @Override
              public int getValue() {
                return (conf.getBoolean(plugin.getName() + ".cache.cache.banks") ? 1 : 0);
              }
            });

        graph.addPlotter(
            new Metrics.Plotter("Accounts") {

              @Override
              public int getValue() {
                return (conf.getBoolean(plugin.getName() + ".cache.cache.accounts") ? 1 : 0);
              }
            });

        graph.addPlotter(
            new Metrics.Plotter("Types") {

              @Override
              public int getValue() {
                return (conf.getBoolean(plugin.getName() + ".cache.cache.types") ? 1 : 0);
              }
            });
      }

      if (conf.getBoolean(plugin.getName() + ".metrics.send.permEngine")) {
        Graph graph = metrics.createGraph("Permissions engine");
        graph.addPlotter(
            new Metrics.Plotter(plugin.getPermHandler(true).getEngineName()) {

              @Override
              public int getValue() {
                return 1;
              }
            });
      }

      /*if(conf.getBoolean(plugin.getName() + ".metrics.send.ecoEngine")) {
      	Graph graph = metrics.createGraph("Economy engine");
      	graph.addPlotter(new Metrics.Plotter(plugin.getEcoHandler().getEngineName()) {

      		@Override
      		public int getValue() {
      			return 1;
      		}
      	});
      }*/

      /*if(conf.getBoolean(plugin.getName() + ".metrics.send.gbl")) {
      	Graph graph = metrics.createGraph("Using GiantBanks Location");
      	graph.addPlotter(new Metrics.Plotter((plugin.useLocation() ? "Yes" : "No")) {

      		@Override
      		public int getValue() {
      			return 1;
      		}
      	});
      }*/

      metrics.start();
    } catch (IOException e) {
      plugin.getLogger().warning("Failed to load metrics!");
      if (conf.getBoolean(plugin.getName() + ".global.debug")) {
        e.printStackTrace();
      }
    }
  }