Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="path"></param>
        /// <param name="readOnly"></param>
        public RrdDb(string path, bool readOnly)
        {
            FileInfo rrdFile = new FileInfo(path);

            if (!rrdFile.Exists)
            {
                throw new IOException("Could not open file " + path + " [non existent]");
            }
            try
            {
                InitializeSetup(path, RrdFile.MODE_RESTORE, readOnly);
                // restore header
                header = new Header(this);
                // restore datasources
                int dsCount = header.DsCount;
                datasources = new Datasource[dsCount];
                for (int i = 0; i < dsCount; i++)
                {
                    datasources[i] = new Datasource(this);
                }
                // restore archives
                int arcCount = header.ArcCount;
                archives = new Archive[arcCount];
                for (int i = 0; i < arcCount; i++)
                {
                    archives[i] = new Archive(this);
                }
                FinalizeSetup();
            }
            catch (Exception e)
            {
                throw new RrdException(e);
            }
        }
Пример #2
0
        internal void Archive(Datasource datasource, double data, long numUpdates)
        {
            int dsIndex = GetDsIndex(datasource.DsName);

            for (int i = 0; i < archives.Length; i++)
            {
                archives[i].archive(dsIndex, data, numUpdates);
            }
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="other"></param>
        public void CopyStateTo(IRrdUpdatable other)
        {
            if (!(other is Datasource))
            {
                throw new RrdException("Cannot copy Datasource object to " + other.ToString());
            }
            Datasource datasource = (Datasource)other;

            if (!datasource.dsName.Get().Equals(dsName.Get()))
            {
                throw new RrdException("Incomaptible datasource names");
            }
            if (!datasource.dsType.Get().Equals(dsType.Get()))
            {
                throw new RrdException("Incomaptible datasource types");
            }
            datasource.lastValue.Set(lastValue.Get());
            datasource.nanSeconds.Set(nanSeconds.Get());
            datasource.accumValue.Set(accumValue.Get());
        }
Пример #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="rrdDef"></param>
 public RrdDb(RrdDef rrdDef)
 {
     rrdDef.Validate();
     InitializeSetup(rrdDef.Path, RrdFile.MODE_CREATE, false);
     // create header
     header = new Header(this, rrdDef);
     // create datasources
     DsDef[] dsDefs = rrdDef.DsDefs;
     datasources = new Datasource[dsDefs.Length];
     for (int i = 0; i < dsDefs.Length; i++)
     {
         datasources[i] = new Datasource(this, dsDefs[i]);
     }
     // create archives
     ArcDef[] arcDefs = rrdDef.ArcDefs;
     archives = new Archive[arcDefs.Length];
     for (int i = 0; i < arcDefs.Length; i++)
     {
         archives[i] = new Archive(this, arcDefs[i]);
     }
     // finalize
     FinalizeSetup();
     Util.Debug(rrdDef.RrdToolCommand);
 }