예제 #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="arcDef"></param>
 public void AddArchive(ArcDef arcDef)
 {
     if (arcDefs.Contains(arcDef))
     {
         throw new RrdException("Archive already defined: " + arcDef.Dump());
     }
     arcDefs.Add(arcDef);
 }
예제 #2
0
 /// <summary>
 /// Checks of two Archive Definitions are equal.Archive definitions are considered equal
 /// if they have the same number of steps and the same consolidation function. It is not
 /// possible to create RRD file with two equal archive definitions.
 /// </summary>
 /// <param name="obj">Archive Definition to compare to.</param>
 /// <returns>True if equal, false otherwise.</returns>
 public new bool Equals(object obj)
 {
     if (obj is ArcDef)
     {
         ArcDef arcObj = (ArcDef)obj;
         return(consolFun.Equals(arcObj.consolFun) && steps == arcObj.steps);
     }
     return(false);
 }
예제 #3
0
        internal void RemoveArchive(string consolFun, int steps)
        {
            ArcDef arcDef = FindArchive(consolFun, steps);

            if (!arcDefs.Contains(arcDef))
            {
                throw new RrdException("Could not remove archive " + consolFun + "/" + steps);
            }
            arcDefs.Remove(arcDef);
        }
예제 #4
0
 internal ArcDef FindArchive(string consolFun, int steps)
 {
     for (int i = 0; i < arcDefs.Count; i++)
     {
         ArcDef arcDef = (ArcDef)arcDefs[i];
         if (arcDef.ConsolFun.Equals(consolFun) && arcDef.Steps == steps)
         {
             return(arcDef);
         }
     }
     throw new RrdException("Could not find archive " + consolFun + "/" + steps);
 }
예제 #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="parentDb"></param>
        /// <param name="arcDef"></param>
        public Archive(RrdDb parentDb, ArcDef arcDef)
        {
            this.parentDb = parentDb;
            consolFun     = new RrdString(arcDef.ConsolFun, this);
            xff           = new RrdDouble(arcDef.Xff, this);
            steps         = new RrdInt(arcDef.Steps, this);
            rows          = new RrdInt(arcDef.Rows, this);
            int n = parentDb.Header.DsCount;

            robins = new Robin[n];
            states = new ArcState[n];
            for (int i = 0; i < n; i++)
            {
                states[i] = new ArcState(this);
                robins[i] = new Robin(this, rows.Get());
            }
        }
예제 #6
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public string Dump()
        {
            StringBuilder buffer = new StringBuilder(RrdDb.RRDTOOL);

            buffer.Append(" create " + path);
            buffer.Append(" --start " + StartTime);
            buffer.Append(" --step " + Step + " ");
            for (int i = 0; i < dsDefs.Count; i++)
            {
                DsDef dsDef = (DsDef)dsDefs[i];
                buffer.Append(dsDef.Dump() + " ");
            }
            for (int i = 0; i < arcDefs.Count; i++)
            {
                ArcDef arcDef = (ArcDef)arcDefs[i];
                buffer.Append(arcDef.Dump() + " ");
            }
            return(buffer.ToString().Trim());
        }
예제 #7
0
 private void Validate()
 {
     if (!ArcDef.IsValidConsolFun(consolFun))
     {
         throw new RrdException("Invalid consolidation function in fetch request: " + consolFun);
     }
     if (fetchStart < 0)
     {
         throw new RrdException("Invalid start time in fetch request: " + fetchStart);
     }
     if (fetchEnd < 0)
     {
         throw new RrdException("Invalid end time in fetch request: " + fetchEnd);
     }
     if (fetchStart >= fetchEnd)
     {
         throw new RrdException("Invalid start/end time in fetch request: " + fetchStart +
                                "/" + fetchEnd);
     }
     if (resolution <= 0)
     {
         throw new RrdException("Invalid resolution in fetch request: " + resolution);
     }
 }