Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Commit

Permalink
replace TSDASH_PLOT_DIR envar with plot.tsdash.dir property
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiugh committed Jan 26, 2012
1 parent df850d8 commit 4b21852
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
7 changes: 4 additions & 3 deletions conf/tsdash.properties
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
hbase.tsdash.datatable=tsdb hbase.tsdash.datatable=tsdb
hbase.tsdash.uidtable=tsdb-uid hbase.tsdash.uidtable=tsdb-uid


hbase.zookeeper.quorum=localhost

# urlpattern is the pattern used to generate URLs of the plots generated by running Gnuplot # urlpattern is the pattern used to generate URLs of the plots generated by running Gnuplot
# The parameters are: # The parameters are:
# - %h host # - %h host
# - %p port # - %p port; by default is 8090
# - %f filename # - %f filename
plot.tsdash.urlpattern=http://%h:%p/plots/%f plot.tsdash.urlpattern=http://%h:%p/plots/%f


hbase.zookeeper.quorum=localhost plot.tsdash.dir=/var/www/tsdash/plots

1 change: 1 addition & 0 deletions server/.gitignore
Original file line number Original file line Diff line number Diff line change
@@ -1 +1,2 @@
build/ build/
bin/
6 changes: 6 additions & 0 deletions server/src/com/facebook/tsdb/tsdash/server/TsdbServlet.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public class TsdbServlet extends HttpServlet {
public static final String URL_PATTERN_PARAM = "plot.tsdash.urlpattern"; public static final String URL_PATTERN_PARAM = "plot.tsdash.urlpattern";
public static final String DEFAULT_URL_PATTERN = "http://%h:%p/plots/%f"; public static final String DEFAULT_URL_PATTERN = "http://%h:%p/plots/%f";
public static final int DEFAULT_PLOT_PORT = 8090; public static final int DEFAULT_PLOT_PORT = 8090;
public static final String PLOTS_DIR_PARAM = "plot.tsdash.dir";
public static final String DEFAULT_PLOTS_DIR = "/tmp";
public static String plotsDir = DEFAULT_PLOTS_DIR;
private static String URLPattern = DEFAULT_URL_PATTERN; private static String URLPattern = DEFAULT_URL_PATTERN;
private String hostname = null; private String hostname = null;


Expand All @@ -60,6 +63,9 @@ private static void loadConfiguration() {
URLPattern = tsdbConf.getProperty(URL_PATTERN_PARAM, URLPattern = tsdbConf.getProperty(URL_PATTERN_PARAM,
DEFAULT_URL_PATTERN); DEFAULT_URL_PATTERN);
logger.info("URL pattern: " + URLPattern); logger.info("URL pattern: " + URLPattern);
plotsDir = tsdbConf.getProperty(PLOTS_DIR_PARAM,
DEFAULT_PLOTS_DIR);
logger.info("Plots are being written to: " + plotsDir);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
System.err.println("Cannot find " + PROPERTIES_FILE); System.err.println("Cannot find " + PROPERTIES_FILE);
} catch (IOException e) { } catch (IOException e) {
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Random; import java.util.Random;


import com.facebook.tsdb.tsdash.server.TsdbServlet;
import com.facebook.tsdb.tsdash.server.model.Metric; import com.facebook.tsdb.tsdash.server.model.Metric;


public abstract class GnuplotProcess { public abstract class GnuplotProcess {
Expand All @@ -33,11 +34,6 @@ public abstract class GnuplotProcess {
public static final String BASH = "/bin/bash"; public static final String BASH = "/bin/bash";
public static final String GNUPLOT = "/usr/local/bin/gnuplot"; public static final String GNUPLOT = "/usr/local/bin/gnuplot";
private static Random rand = new Random(); private static Random rand = new Random();
private static String outputDir;

static {
outputDir = System.getenv(OUTPUT_DIR_ENV);
}


protected Process gnuplot; protected Process gnuplot;
protected BufferedWriter gnuplotStdin; protected BufferedWriter gnuplotStdin;
Expand All @@ -47,10 +43,6 @@ public abstract class GnuplotProcess {
protected int plotNo = 0; protected int plotNo = 0;


public GnuplotProcess() throws Exception { public GnuplotProcess() throws Exception {
if (outputDir == null) {
throw new Exception("Output dir not specified. Please set "
+ OUTPUT_DIR_ENV + " envirnonment variable");
}
id = rand.nextInt(); id = rand.nextInt();
if (id < 0) { if (id < 0) {
id = - id; id = - id;
Expand All @@ -68,11 +60,11 @@ protected String getPipeFilename(int pipeNo) {
} }


protected static String noDataFilename() { protected static String noDataFilename() {
return outputDir + "/no_data.jpg"; return TsdbServlet.plotsDir + "/no_data.jpg";
} }


protected String getOutputFilename(GnuplotOptions options) { protected String getOutputFilename(GnuplotOptions options) {
return String.format("%s/%d-%d.%s", outputDir, id, plotNo, return String.format("%s/%d-%d.%s", TsdbServlet.plotsDir, id, plotNo,
options.getTerminal()); options.getTerminal());
} }


Expand Down

0 comments on commit 4b21852

Please sign in to comment.