public static void testGetData() { OpentsdbClient client = new OpentsdbClient(opentsdburl); try { Dictionary <string, string> tagMap = new Dictionary <string, string>(); tagMap.Add("waterpump", "waterpump4"); string resContent = client.getData("current", tagMap, OpentsdbClient.AGGREGATOR_AVG, "1m", "2018-03-27 10:20:00", "2018-03-27 10:25:00"); Console.WriteLine(resContent); //log.info(">>>" + resContent); //Dictionary<string, string> tagMap = new Dictionary<string, string>(); //tagMap.Add("host", "szawd"); //OpenTSDB.Client.opentsdb.client.response.QueryLastResponse res = client.queryLastData("sys.batch.test6", tagMap, 500); //if (null != res) //{ // Console.WriteLine(res.value); //} } catch (Exception e) { Console.WriteLine(e.Message); } }
public void testGetData2() { OpentsdbClient client = new OpentsdbClient(opentsdburl); try { Dictionary <string, string> tagMap = new Dictionary <string, string>(); tagMap.Add("chl", "hqdApp"); IDictionary <string, Dictionary <string, object> > tagsValuesMap = (IDictionary <string, Dictionary <string, object> >)client.getData("metric-t", tagMap, OpentsdbClient.AGGREGATOR_SUM, "1h", "2016-06-27 10:00:00", "2016-06-30 11:00:00", "yyyyMMdd hh"); foreach (var it in tagsValuesMap) { string tags = it.Key.ToString(); Console.WriteLine(">> tags: " + tags); IDictionary <string, Object> tvMap = tagsValuesMap[tags]; foreach (var it2 in tvMap) { string time = it2.Key.ToString(); Console.WriteLine(" >> " + time + " <-> " + tvMap[time]); } } } catch (Exception e) { Console.WriteLine(e.Message); } }