package com.kendelong.util.monitoring.graphite;

import java.util.Random;

import org.junit.Ignore;
import org.junit.Test;

public class GraphiteClientTest
{

	@Test
	@Ignore
	public void test() throws Exception
	{
		GraphiteClient gc = new GraphiteClient();
		gc.setAppName("gc");
		gc.setStatsdHost("127.0.0.1");
		gc.setStatsdPort(8125);
		gc.setServerEnv("test");
		gc.init();
		
		System.out.println("Starting...");
		
		Random random = new Random();
		for(int i = 0; i < 10000; i++)
		{
			gc.increment("theTesterIncrement");
			gc.count("theTesterCount", 1);
			gc.time("theTesterTime", (long) (300*(1 + random.nextDouble() - 0.5)));
			Thread.sleep(100);
			if(i%100 == 0) System.out.println("Count: " + i);
		}
		
		System.out.println("Done");
	}

}

@@ -300,16 +300,21 @@
 t(%221
-27.0.0.1
+92.168.59.103
 %22);%0A
@@ -512,26 +512,32 @@
 nt(%22
-theTesterI
+a.foo%22);%0A%09%09%09gc.i
 ncrement
 %22);%0A
@@ -532,16 +532,23 @@
 ncrement
+(%22b.foo
 %22);%0A%09%09%09g
@@ -767,11 +767,492 @@
 e%22);%0A%09%7D%0A
+%09%0A%09/*%0A%09 * gc.increment(%22a.foo%22);%0A%09 * gc.increment(%22b.foo%22);%0A%09 * %0A%09 * a.foo.count = 100%0A%09 * Grafana buckets are 10 seconds wide!%0A%09 * %0A%09 * a.foo.rate = 10%0A%09 * sumSeries(*.foo.rate) = 20%0A%09 * %0A%09 * $ docker run -p 8000:80/tcp -p 8125:8125/udp -p 8126:8126/tcp --name grafana cooniur/grafana_graphite%0A%09 * http://192.168.59.103:8000/#/dashboard/db/welcome?panelId=3&fullscreen&edit%0A%09 * That IP is the IP of the boot2docker VM!  %0A%09 * Shown when%0A%09 *   - you start boot2docker%0A%09 * %0A%09 * %0A%09 */
 %0A%7D%0A

test metrics using it with Grafana