public DataSourceItem(Data_source ds, string friendlyname, Color color, string uuid, IXenObject xo) : this(ds, friendlyname, color, uuid) { DataSet dataSet = DataSet.Create(uuid, xo); DataType = dataSet.Type; }
/// <summary> /// Asserts off the event thread, for use when copying off the updater thread. Invokes onto event thread to update the sets safely. /// </summary> /// <param name="SetsAdded"></param> internal void CopyLoad(List <DataSet> SetsAdded) { Program.AssertOffEventThread(); if (SetsAdded == null) { return; } foreach (DataSet set in SetsAdded) { Palette.LoadSetColor(set); DataSet copy = DataSet.Create(set.Uuid, set.XenObject, set.Show, set.TypeString); foreach (DataPoint p in set.Points) { copy.AddPoint(new DataPoint(p.X, p.Y)); } Program.Invoke(Program.MainWindow, delegate { AddSet(copy); }); } }
/// <summary> /// UpdaterThread Thread /// </summary> private void RRD_Update_InspectCurrentNode(XmlReader reader, IXenObject xo) { if (reader.NodeType == XmlNodeType.Element) { LastNode = reader.Name; if (LastNode == "row") { ValueCount = 0; } } if (reader.NodeType != XmlNodeType.Text) { return; } if (LastNode == "entry") { string str = reader.ReadContentAsString(); SetsAdded.Add(DataSet.Create(str, xo)); } else if (LastNode == "t") { string str = reader.ReadContentAsString(); CurrentTime = new DateTime((Convert.ToInt64(str) * TimeSpan.TicksPerSecond) + TimeUtil.TicksBefore1970).ToLocalTime().Ticks; } else if (LastNode == "v") { if (SetsAdded.Count <= ValueCount) { return; } DataSet set = SetsAdded[ValueCount]; string str = reader.ReadContentAsString(); set.AddPoint(str, CurrentTime, SetsAdded); ValueCount++; } }
/// <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++; } }