IEnumerable <Flot> GetFlotData(DateTime aStart, DateTime aEnd)
        {
            var tObjects = new List <Flot>();

            FetchData data = Helper.RrdDb.createFetchRequest(ConsolFuns.CF_AVERAGE, aStart.ToTimestamp(), aEnd.ToTimestamp(), 1).fetchData();

            Int64[]    times  = data.getTimestamps();
            double[][] values = data.getValues();

            for (int a = 1; a <= Snapshot.SnapshotCount; a++)
            {
                var obj = new Flot();

                var list = new List <double[]>();
                for (int b = 0; b < times.Length; b++)
                {
                    double[] current = { times[b] * 1000, values[a][b] };
                    list.Add(current);
                }
                obj.Data = list.ToArray();
                obj.Type = a;

                tObjects.Add(obj);
            }

            return(tObjects.ToArray());
        }
Example #2
0
        public void SetArchiveDumpData(FetchData data)
        {
            DataListView.Items.Clear();
            DataListView.BeginUpdate();
            DateTime[] dates = data.getDateTimestamps();
            int        count = dates.Length;

            double[] values = data.getValues()[0];
            for (var i = 0; i < count; i++)
            {
                if (double.IsNaN(data.getValues()[0][i]))
                {
                    continue;
                }
                ListViewItem lvi = DataListView.Items.Add(dates[i].ToString());
                lvi.SubItems.Add(values[i].ToString());
            }
            DataListView.EndUpdate();
        }
Example #3
0
        public RemoteFetchData FetchData(string databaseName, long startTimeTick, long endTimeTick, string consolFunctionName, long resolution)
        {
            RrdDb database = null;

            try
            {
                log.DebugFormat("Read data from {0}", databaseName);

                var    nameValueCollection = (NameValueCollection)ConfigurationManager.GetSection("rrdbfileserver");
                string dataBasePath        = nameValueCollection["databasepath"];

                log.DebugFormat("Database path:{0}", dataBasePath + databaseName);
                database = new RrdDb(dataBasePath + databaseName, true);
                FetchRequest fetchRequest = new FetchRequest(null, consolFunctionName, startTimeTick, endTimeTick, resolution);
                FetchData    data         = database.fetchData(fetchRequest);
                database.close();

                RemoteFetchData remoteData = new RemoteFetchData();
                remoteData.Timestamps          = data.getTimestamps();
                remoteData.Values              = data.getValues();
                remoteData.ArchiveEndTimeTicks = data.getArcEndTime();
                remoteData.ArchiveSteps        = data.getArcStep();
                remoteData.DatasourceNames     = data.getDsNames();
                if (debugEnabled)
                {
                    log.DebugFormat("Read data from {0} to {1}.", rrd4n.Common.Util.getDate(startTimeTick), rrd4n.Common.Util.getDate(endTimeTick));
                }
                return(remoteData);
            }
            catch (Exception ex)
            {
                log.Error("Fetchdata exception", ex);
                throw;
            }
            finally
            {
                if (database != null)
                {
                    database.close();
                }
            }
        }
Example #4
0
        public rrd4n.DataAccess.Data.FetchData GetData(rrd4n.DataAccess.Data.FetchRequest request)
        {
            RrdDb rrdDb = null;

            try
            {
                string dataPath;
                if (DataPath.Contains("${APPDATA}"))
                {
                    dataPath  = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
                    dataPath += DataPath.Substring(10);
                }
                else
                {
                    dataPath = DataPath;
                }


                rrdDb = new RrdDb(dataPath + request.DatabasePath);
                FetchRequest coreRequest   = new FetchRequest(rrdDb.getPath(), request.ConsolidateFunctionName, request.FetchStart, request.FetchEnd, request.Resolution);
                FetchData    coreFetchData = rrdDb.fetchData(coreRequest);

                return(new rrd4n.DataAccess.Data.FetchData(coreFetchData.getArcStep(), coreFetchData.getArcEndTime(), coreFetchData.getDsNames())
                {
                    Values = coreFetchData.getValues(),
                    Timestamps = coreFetchData.getTimestamps()
                });
            }
            finally
            {
                if (rrdDb != null)
                {
                    rrdDb.close();
                }
            }
        }
Example #5
0
 public void SetArchiveDumpData(FetchData data)
 {
    DataListView.Items.Clear();
    DataListView.BeginUpdate();
    DateTime[] dates = data.getDateTimestamps();
    int count = dates.Length;
    double[] values = data.getValues()[0];
    for (var i = 0; i < count; i++)
    {
       if (double.IsNaN(data.getValues()[0][i]))
          continue;
       ListViewItem lvi = DataListView.Items.Add(dates[i].ToString());
       lvi.SubItems.Add(values[i].ToString());
    }
    DataListView.EndUpdate();
 }