]> jfr.im git - irc/rizon/moo.git/commitdiff
Delete grapher
authorAdam <redacted>
Tue, 29 Mar 2022 23:37:51 +0000 (19:37 -0400)
committerAdam <redacted>
Tue, 29 Mar 2022 23:38:00 +0000 (19:38 -0400)
12 files changed:
grapher/grapher.yml.template [deleted file]
grapher/pom.xml [deleted file]
grapher/src/main/java/net/rizon/moo/plugin/grapher/DataSourceType.java [deleted file]
grapher/src/main/java/net/rizon/moo/plugin/grapher/Graph.java [deleted file]
grapher/src/main/java/net/rizon/moo/plugin/grapher/RoundRobinArchiveType.java [deleted file]
grapher/src/main/java/net/rizon/moo/plugin/grapher/conf/GrapherConfiguration.java [deleted file]
grapher/src/main/java/net/rizon/moo/plugin/grapher/grapher.java [deleted file]
grapher/src/main/java/net/rizon/moo/plugin/grapher/graphs/ServerUserGraph.java [deleted file]
grapher/src/main/java/net/rizon/moo/plugin/grapher/graphs/TotalOlineGraph.java [deleted file]
grapher/src/main/java/net/rizon/moo/plugin/grapher/graphs/TotalServerGraph.java [deleted file]
grapher/src/main/java/net/rizon/moo/plugin/grapher/graphs/TotalUserGraph.java [deleted file]
pom.xml

diff --git a/grapher/grapher.yml.template b/grapher/grapher.yml.template
deleted file mode 100644 (file)
index e6e5397..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-bin: /usr/bin/rrdtool
-dir: /home/adam/rizon/moo/graphs
\ No newline at end of file
diff --git a/grapher/pom.xml b/grapher/pom.xml
deleted file mode 100644 (file)
index e336100..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-       <modelVersion>4.0.0</modelVersion>
-
-       <parent>
-               <groupId>net.rizon</groupId>
-               <artifactId>moo</artifactId>
-               <version>3.0</version>
-       </parent>
-
-       <name>Grapher</name>
-
-       <groupId>net.rizon.moo</groupId>
-       <artifactId>grapher</artifactId>
-
-       <dependencies>
-               <dependency>
-                       <groupId>net.rizon.moo</groupId>
-                       <artifactId>moo</artifactId>
-                       <version>${project.version}</version>
-               </dependency>
-       </dependencies>
-       
-       <build>
-               <plugins>
-                       <plugin>
-                               <artifactId>maven-jar-plugin</artifactId>
-                               <configuration>
-                                       <archive>
-                                               <manifest>
-                                                       <mainClass>net.rizon.moo.plugin.grapher.grapher</mainClass>
-                                               </manifest>
-                                       </archive>
-                               </configuration>
-                       </plugin>
-               </plugins>
-       </build>
-</project>
diff --git a/grapher/src/main/java/net/rizon/moo/plugin/grapher/DataSourceType.java b/grapher/src/main/java/net/rizon/moo/plugin/grapher/DataSourceType.java
deleted file mode 100644 (file)
index 308c8e0..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-package net.rizon.moo.plugin.grapher;
-
-public enum DataSourceType
-{
-       DST_GAUGE;
-}
\ No newline at end of file
diff --git a/grapher/src/main/java/net/rizon/moo/plugin/grapher/Graph.java b/grapher/src/main/java/net/rizon/moo/plugin/grapher/Graph.java
deleted file mode 100644 (file)
index 12002f6..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-package net.rizon.moo.plugin.grapher;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.logging.Level;
-import net.rizon.moo.plugin.grapher.conf.GrapherConfiguration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public abstract class Graph implements Runnable
-{
-       private static final Logger logger = LoggerFactory.getLogger(Graph.class);
-
-       private static File rrd_bin,
-                       rrd_graphdir;
-       private static Runtime rt = Runtime.getRuntime();
-
-       private class dataSource
-       {
-               String name;
-               DataSourceType type;
-               long heartbeat;
-               long min;
-               long max;
-       }
-
-       private String name;
-       private long step;
-       private ArrayList<dataSource> dataSources = new ArrayList<dataSource>();
-       private RoundRobinArchiveType rra_type;
-       private long rra_steps;
-       private long rra_rows;
-
-       public Graph(GrapherConfiguration conf, String name)
-       {
-               this.name = name + ".rrd";
-               this.step = step;
-
-               rrd_bin = new File(conf.bin);
-               rrd_graphdir = new File(conf.dir);
-       }
-
-       private void exec(final String subcommand, final String args)
-       {
-               if (rrd_bin.exists() == false || rrd_bin.canExecute() == false)
-               {
-                       logger.warn("RRDTool binary does not exist or is not executable");
-                       return;
-               }
-
-               if (rrd_graphdir.exists() == false)
-                       rrd_graphdir.mkdir();
-
-               File database = new File(rrd_graphdir.getAbsolutePath() + File.separatorChar + this.name);
-               if (database.getParentFile() != null && database.getParentFile().exists() == false)
-                       database.getParentFile().mkdir();
-
-               if (database.exists() == false)
-               {
-                       String create_command = "create " + database.getAbsolutePath() + " --step " + this.step;
-
-                       for (int i = 0; i < this.dataSources.size(); ++i)
-                       {
-                               dataSource ds = this.dataSources.get(i);
-                               String ds_type = null;
-                               switch (ds.type)
-                               {
-                                       case DST_GAUGE:
-                                               ds_type = "GAUGE";
-                                               break;
-                               }
-
-                               if (ds_type == null)
-                               {
-                                       logger.warn("Unknown DataSourceType");
-                                       continue;
-                               }
-
-                               create_command += " DS:" + ds.name + ":" + ds_type + ":" + ds.heartbeat + ":" + ds.min + ":" + ds.max;
-                       }
-
-                       String rra_type = null;
-                       switch (this.rra_type)
-                       {
-                               case RRA_MAX:
-                                       rra_type = "MAX";
-                                       break;
-                       }
-
-                       if (rra_type == null)
-                       {
-                               logger.warn("Unknown RoundRobinArchiveType");
-                               return;
-                       }
-
-                       create_command += " RRA:" + rra_type + ":0.5:" + this.rra_steps + ":" + this.rra_rows;
-
-                       try
-                       {
-                               Process p = rt.exec(rrd_bin.getAbsolutePath() + " " + create_command);
-                               p.getInputStream().close();
-                               p.getOutputStream().close();
-                               p.getErrorStream().close();
-                       }
-                       catch (IOException ex)
-                       {
-                               logger.warn("Error executing RRDTool with \"" + create_command + "\"", ex);
-                       }
-               }
-
-               String command = subcommand + " " + database.getAbsolutePath() + " " + args;
-
-               try
-               {
-                       Process p = rt.exec(rrd_bin.getAbsolutePath() + " " + command);
-                       p.getInputStream().close();
-                       p.getOutputStream().close();
-                       p.getErrorStream().close();
-               }
-               catch (IOException ex)
-               {
-                       logger.warn("Error executing RRDTool with \"" + command + "\"", ex);
-               }
-       }
-
-       protected void addDataSource(final String name, DataSourceType type, long heartbeat, long min, long max)
-       {
-               dataSource ds = new dataSource();
-               ds.name = name;
-               ds.type = type;
-               ds.heartbeat = heartbeat;
-               ds.min = min;
-               ds.max = max;
-               this.dataSources.add(ds);
-       }
-
-       protected void setRRA(RoundRobinArchiveType rrat, long steps, long rows)
-       {
-               this.rra_type = rrat;
-               this.rra_steps = steps;
-               this.rra_rows = rows;
-       }
-
-       public void update(final String[] values)
-       {
-               String s = "N";
-               for (final String v : values)
-                       s += ":" + v;
-               this.exec("update", s);
-       }
-
-       public void update(long time, final String[] values)
-       {
-               String s = String.valueOf(time);
-               for (final String v : values)
-                       s += ":" + v;
-               this.exec("update", s);
-       }
-}
\ No newline at end of file
diff --git a/grapher/src/main/java/net/rizon/moo/plugin/grapher/RoundRobinArchiveType.java b/grapher/src/main/java/net/rizon/moo/plugin/grapher/RoundRobinArchiveType.java
deleted file mode 100644 (file)
index eaaf464..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-package net.rizon.moo.plugin.grapher;
-
-public enum RoundRobinArchiveType
-{
-       RRA_MAX
-}
\ No newline at end of file
diff --git a/grapher/src/main/java/net/rizon/moo/plugin/grapher/conf/GrapherConfiguration.java b/grapher/src/main/java/net/rizon/moo/plugin/grapher/conf/GrapherConfiguration.java
deleted file mode 100644 (file)
index 83cc8d6..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-package net.rizon.moo.plugin.grapher.conf;
-
-import net.rizon.moo.conf.Configuration;
-import net.rizon.moo.conf.ConfigurationException;
-import net.rizon.moo.conf.Validator;
-
-public class GrapherConfiguration extends Configuration
-{
-       public String bin, dir;
-
-       public static GrapherConfiguration load() throws Exception
-       {
-               return Configuration.load("grapher.yml", GrapherConfiguration.class);
-       }
-
-       @Override
-       public void validate() throws ConfigurationException
-       {
-               Validator.validatePath("Grapher bin", bin);
-               Validator.validatePath("Grapher dir", dir);
-       }
-}
diff --git a/grapher/src/main/java/net/rizon/moo/plugin/grapher/grapher.java b/grapher/src/main/java/net/rizon/moo/plugin/grapher/grapher.java
deleted file mode 100644 (file)
index 8f76b16..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-package net.rizon.moo.plugin.grapher;
-
-import com.google.common.eventbus.Subscribe;
-import com.google.inject.Inject;
-import io.netty.util.concurrent.ScheduledFuture;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-import net.rizon.moo.Command;
-
-import net.rizon.moo.Moo;
-import net.rizon.moo.Plugin;
-import net.rizon.moo.events.EventListener;
-import net.rizon.moo.events.OnReload;
-import net.rizon.moo.events.OnServerCreate;
-import net.rizon.moo.events.OnServerDestroy;
-import net.rizon.moo.irc.Server;
-import net.rizon.moo.plugin.grapher.conf.GrapherConfiguration;
-import net.rizon.moo.plugin.grapher.graphs.ServerUserGraph;
-import net.rizon.moo.plugin.grapher.graphs.TotalOlineGraph;
-import net.rizon.moo.plugin.grapher.graphs.TotalServerGraph;
-import net.rizon.moo.plugin.grapher.graphs.TotalUserGraph;
-import org.slf4j.Logger;
-
-public class grapher extends Plugin implements EventListener
-{
-       @Inject
-       private static Logger logger;
-
-       @Inject
-       private GrapherConfiguration conf;
-
-       @Inject
-       private TotalOlineGraph totalOlineGraph;
-
-       @Inject
-       private TotalServerGraph totalServerGraph;
-
-       @Inject
-       private TotalUserGraph totalUserGraph;
-
-       protected Map<Server, ServerUserGraph> serverGraphs = new HashMap<>();
-
-       private ScheduledFuture oline, server, user;
-
-       public grapher() throws Exception
-       {
-               super("Grapher", "Creates graphs");
-               conf = GrapherConfiguration.load();
-       }
-
-
-       @Override
-       public void start() throws Exception
-       {
-               oline = Moo.scheduleAtFixedRate(totalOlineGraph, 1, TimeUnit.MINUTES);
-               server = Moo.scheduleAtFixedRate(totalServerGraph, 1, TimeUnit.MINUTES);
-               user = Moo.scheduleAtFixedRate(totalUserGraph, 1, TimeUnit.MINUTES);
-       }
-
-       @Override
-       public void stop()
-       {
-               for (ServerUserGraph g : serverGraphs.values())
-                       g.future.cancel(false);
-
-               oline.cancel(false);
-               server.cancel(false);
-               user.cancel(false);
-       }
-       
-       @Subscribe
-       public void onServerCreate(OnServerCreate evt)
-       {
-               Server serv = evt.getServer();
-               
-               ServerUserGraph g = new ServerUserGraph(conf, serv);
-               ScheduledFuture future = Moo.scheduleAtFixedRate(g, 1, TimeUnit.MINUTES);
-               g.future = future;
-               
-               serverGraphs.put(serv, g);
-       }
-
-       @Subscribe
-       public void onServerDestroy(OnServerDestroy evt)
-       {
-               Server serv = evt.getServer();
-               
-               serverGraphs.remove(serv).future.cancel(false);
-       }
-
-       @Subscribe
-       public void onReload(OnReload evt)
-       {
-               try
-               {
-                       conf = GrapherConfiguration.load();
-               }
-               catch (Exception ex)
-               {
-                       evt.getSource().reply("Error reloading grapher configuration: " + ex.getMessage());
-                       
-                       logger.warn("Unable to reload configuration", ex);
-               }
-       }
-
-       @Override
-       public List<Command> getCommands()
-       {
-               return Arrays.asList();
-       }
-
-       @Override
-       protected void configure()
-       {
-               bind(grapher.class).toInstance(this);
-
-               bind(GrapherConfiguration.class).toInstance(conf);
-
-               bind(TotalOlineGraph.class);
-               bind(TotalServerGraph.class);
-               bind(TotalUserGraph.class);
-       }
-}
\ No newline at end of file
diff --git a/grapher/src/main/java/net/rizon/moo/plugin/grapher/graphs/ServerUserGraph.java b/grapher/src/main/java/net/rizon/moo/plugin/grapher/graphs/ServerUserGraph.java
deleted file mode 100644 (file)
index 269eed2..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-package net.rizon.moo.plugin.grapher.graphs;
-
-import io.netty.util.concurrent.ScheduledFuture;
-import net.rizon.moo.irc.Server;
-
-import net.rizon.moo.plugin.grapher.DataSourceType;
-import net.rizon.moo.plugin.grapher.Graph;
-import net.rizon.moo.plugin.grapher.RoundRobinArchiveType;
-import net.rizon.moo.plugin.grapher.conf.GrapherConfiguration;
-
-public class ServerUserGraph extends Graph
-{
-       private Server serv;
-       public ScheduledFuture future;
-
-       public ServerUserGraph(GrapherConfiguration config, Server s)
-       {
-               super(config, s.getName() + "-users");
-
-               this.serv = s;
-
-               this.addDataSource("users", DataSourceType.DST_GAUGE, 120, 0, 200000);
-               this.setRRA(RoundRobinArchiveType.RRA_MAX, 1, 525948); // 1 year
-       }
-
-       @Override
-       public void run()
-       {
-               final String[] data = { String.valueOf(serv.users) };
-               this.update(data);
-       }
-}
diff --git a/grapher/src/main/java/net/rizon/moo/plugin/grapher/graphs/TotalOlineGraph.java b/grapher/src/main/java/net/rizon/moo/plugin/grapher/graphs/TotalOlineGraph.java
deleted file mode 100644 (file)
index d11db25..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-package net.rizon.moo.plugin.grapher.graphs;
-
-import com.google.inject.Inject;
-import java.util.HashSet;
-import java.util.Set;
-import net.rizon.moo.irc.Server;
-import net.rizon.moo.irc.ServerManager;
-
-import net.rizon.moo.plugin.grapher.DataSourceType;
-import net.rizon.moo.plugin.grapher.Graph;
-import net.rizon.moo.plugin.grapher.RoundRobinArchiveType;
-import net.rizon.moo.plugin.grapher.conf.GrapherConfiguration;
-
-public class TotalOlineGraph extends Graph
-{
-       @Inject
-       private ServerManager serverManager;
-
-       @Inject
-       public TotalOlineGraph(GrapherConfiguration config)
-       {
-               super(config, "opers");
-
-               this.addDataSource("opers", DataSourceType.DST_GAUGE, 120, 0, 1000);
-               this.setRRA(RoundRobinArchiveType.RRA_MAX, 1, 525948); // 1 year
-       }
-
-       @Override
-       public void run()
-       {
-               Set<String> olines = new HashSet<>();
-               for (Server s : serverManager.getServers())
-                       if (s.olines != null)
-                               olines.addAll(s.olines.keySet());
-
-               if (olines.isEmpty() == false)
-               {
-                       final String[] data = { String.valueOf(olines.size()) };
-                       this.update(data);
-               }
-       }
-}
diff --git a/grapher/src/main/java/net/rizon/moo/plugin/grapher/graphs/TotalServerGraph.java b/grapher/src/main/java/net/rizon/moo/plugin/grapher/graphs/TotalServerGraph.java
deleted file mode 100644 (file)
index 4196668..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-package net.rizon.moo.plugin.grapher.graphs;
-
-import com.google.inject.Inject;
-import net.rizon.moo.irc.ServerManager;
-import net.rizon.moo.plugin.grapher.DataSourceType;
-import net.rizon.moo.plugin.grapher.Graph;
-import net.rizon.moo.plugin.grapher.RoundRobinArchiveType;
-import net.rizon.moo.plugin.grapher.conf.GrapherConfiguration;
-
-public class TotalServerGraph extends Graph
-{
-       @Inject
-       private ServerManager serverManager;
-       
-       @Inject
-       public TotalServerGraph(GrapherConfiguration config)
-       {
-               super(config, "servers");
-
-               this.addDataSource("servers", DataSourceType.DST_GAUGE, 120, 0, 1000);
-               this.setRRA(RoundRobinArchiveType.RRA_MAX, 1, 525948); // 1 year
-       }
-
-       @Override
-       public void run()
-       {
-               final String[] data = { String.valueOf(serverManager.getServers().length) };
-               this.update(data);
-       }
-}
diff --git a/grapher/src/main/java/net/rizon/moo/plugin/grapher/graphs/TotalUserGraph.java b/grapher/src/main/java/net/rizon/moo/plugin/grapher/graphs/TotalUserGraph.java
deleted file mode 100644 (file)
index 7aae3f8..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-package net.rizon.moo.plugin.grapher.graphs;
-
-import com.google.inject.Inject;
-import net.rizon.moo.irc.ServerManager;
-import net.rizon.moo.plugin.grapher.DataSourceType;
-import net.rizon.moo.plugin.grapher.Graph;
-import net.rizon.moo.plugin.grapher.RoundRobinArchiveType;
-import net.rizon.moo.plugin.grapher.conf.GrapherConfiguration;
-
-public class TotalUserGraph extends Graph
-{
-       @Inject
-       private ServerManager serverManager;
-       
-       @Inject
-       public TotalUserGraph(GrapherConfiguration config)
-       {
-               super(config, "users");
-
-               this.addDataSource("users", DataSourceType.DST_GAUGE, 120, 0, 200000);
-               this.setRRA(RoundRobinArchiveType.RRA_MAX, 1, 525948); // 1 year
-       }
-
-       @Override
-       public void run()
-       {
-               final String[] data = { String.valueOf(serverManager.cur_total_users) };
-               this.update(data);
-       }
-}
diff --git a/pom.xml b/pom.xml
index 7338c80ebebeca86eade2f289bc6143e7498d4b1..b61c24d444a3c0be377568b8c308951f5859708a 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -33,7 +33,6 @@
                <module>dnsblstats</module>
                <module>fun</module>
                <module>grafana</module>
-               <module>grapher</module>
                <module>logging</module>
                <module>mxbl</module>
                <module>osflood</module>