Example #1
0
        public bool IsSameQuery(InfluxQueryInfo q)
        {
            String v0 = this.NormalizeQuery();
            String v1 = q.NormalizeQuery();

            return(v0.Equals(v1));
        }
Example #2
0
        public InfluxQueryInfo Replace(String key, String val)
        {
            InfluxQueryInfo copy = new InfluxQueryInfo();

            copy.Database = this.Database;
            copy.Name     = this.Name.Replace(key, val);
            copy.Query    = this.Query.Replace(key, val);
            return(copy);
        }
Example #3
0
 public bool DropContinuousQuery(InfluxQueryInfo q)
 {
     if (String.IsNullOrWhiteSpace(q.Database))
     {
         throw new Exception("Missing database");
     }
     ExecutePostQuery("DROP CONTINUOUS QUERY \"" + q.Name + "\" ON \"" + q.Database + "\"", q.Database);
     return(true);
 }
Example #4
0
 public bool CreateContinuousQuery(InfluxQueryInfo q)
 {
     if (String.IsNullOrWhiteSpace(q.Database))
     {
         throw new Exception("Missing database");
     }
     ExecutePostQuery(q.Query, q.Database);
     return(true);
 }
Example #5
0
        public IDictionary <String, InfluxQueryInfo> ShowContinuousQueries(string db)
        {
            HttpWebRequest req = GetWebRequest("query?q=SHOW CONTINUOUS QUERIES");

            req.Method = "GET";

            Dictionary <string, InfluxQueryInfo> queries = new Dictionary <string, InfluxQueryInfo>();

            using (HttpWebResponse res = req.GetResponse() as HttpWebResponse)
            {
                JsonTextReader reader = new JsonTextReader(
                    new StreamReader(res.GetResponseStream()));

                JObject results = (JObject)((JArray)JObject.Load(reader).GetValue("results")).First;
                JArray  series  = (JArray)results.GetValue("series");
                foreach (JToken t in series)
                {
                    JObject dbqs   = (JObject)t;
                    String  dbname = dbqs.GetValue("name").Value <string>();
                    if (dbname.Equals(db))
                    {
                        JArray values = dbqs.GetValue("values") as JArray;
                        if (values != null && values.Count > 0)
                        {
                            foreach (JToken v in values)
                            {
                                JArray          aa = v as JArray;
                                InfluxQueryInfo q  = new InfluxQueryInfo();
                                q.Database      = dbname;
                                q.Name          = v[0].Value <string>();
                                q.Query         = v[1].Value <string>();
                                queries[q.Name] = q;
                            }
                        }
                        break;
                    }
                }
            }
            return(queries);
        }