Ejemplo n.º 1
0
        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());
        }
Ejemplo n.º 2
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();
                }
            }
        }
Ejemplo n.º 3
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();
                }
            }
        }