Ejemplo n.º 1
0
        /// <summary>
        /// UpdaterThread Thread
        /// </summary>
        private void RRD_Full_InspectCurrentNode(XmlReader reader, IXenObject xmo)
        {
            if (reader.NodeType == XmlNodeType.Element)
            {
                LastNode = reader.Name;
                if (LastNode == "row")
                {
                    CurrentTime += CurrentInterval * StepSize * TicksInOneSecond;
                    ValueCount   = 0;
                }
            }

            if (reader.NodeType == XmlNodeType.EndElement)
            {
                LastNode = reader.Name;
                if (LastNode == "rra")
                {
                    if (BailOut)
                    {
                        BailOut = false;
                        return;
                    }

                    ArchiveInterval i = GetArchiveIntervalFromFiveSecs(CurrentInterval);
                    if (i != ArchiveInterval.None)
                    {
                        Archives[i].CopyLoad(SetsAdded);
                    }

                    foreach (DataSet set in SetsAdded)
                    {
                        set.Points.Clear();
                    }
                    BailOut = false;
                }
            }

            if (reader.NodeType != XmlNodeType.Text)
            {
                return;
            }

            if (LastNode == "name")
            {
                string str = reader.ReadContentAsString();
                string id  = string.Format("{0}:{1}:{2}", xmo is Host ? "host" : "vm", Helpers.GetUuid(xmo), str);
                SetsAdded.Add(DataSet.Create(id, xmo, true, str));
            }
            else if (LastNode == "step")
            {
                string str = reader.ReadContentAsString();
                StepSize = long.Parse(str, CultureInfo.InvariantCulture);
            }
            else if (LastNode == "lastupdate")
            {
                string str = reader.ReadContentAsString();
                EndTime = long.Parse(str, CultureInfo.InvariantCulture);
            }
            else if (LastNode == "pdp_per_row")
            {
                string str = reader.ReadContentAsString();
                CurrentInterval = long.Parse(str, CultureInfo.InvariantCulture);

                long modInterval = EndTime % (StepSize * CurrentInterval);
                long stepCount   = CurrentInterval == 1 ? FiveSecondsInTenMinutes // 120 * 5 seconds in 10 minutes
                               : CurrentInterval == 12 ? MinutesInTwoHours        // 120 minutes in 2 hours
                               : CurrentInterval == 720 ? HoursInOneWeek          // 168 hours in a week
                               : DaysInOneYear;                                   // 366 days in a year

                CurrentTime = new DateTime((((EndTime - modInterval) - (StepSize * CurrentInterval * stepCount)) * TimeSpan.TicksPerSecond) + TimeUtil.TicksBefore1970).ToLocalTime().Ticks;
            }
            else if (LastNode == "cf")
            {
                string str = reader.ReadContentAsString();
                if (str != RrdCFAverage)
                {
                    BailOut = true;
                }
            }
            else if (LastNode == "v")
            {
                if (BailOut || SetsAdded.Count <= ValueCount)
                {
                    return;
                }

                DataSet set = SetsAdded[ValueCount];
                string  str = reader.ReadContentAsString();
                set.AddPoint(str, CurrentTime, SetsAdded);
                ValueCount++;
            }
        }