NTP Analyzer  0.8.2
Analyze the operation of time servers
Ntp.Analyzer.Graph.TrafficGraph Class Reference
Inheritance diagram for Ntp.Analyzer.Graph.TrafficGraph:
Collaboration diagram for Ntp.Analyzer.Graph.TrafficGraph:

Public Member Functions

 TrafficGraph (ITrafficGraphConfiguration configuration, Host host)
 
- Public Member Functions inherited from Ntp.Analyzer.Graph.GraphBase
Stream Generate ()
 
Stream Render ()
 

Protected Member Functions

override void AddPlots ()
 
override void LoadData ()
 
override void PreRender ()
 
- Protected Member Functions inherited from Ntp.Analyzer.Graph.GraphBase
 GraphBase (IGraphBaseConfiguration baseConfig)
 
LinePlot SetupPlot (string name, Color color, IList time, IList data)
 

Properties

override string YLabel [get]
 
- Properties inherited from Ntp.Analyzer.Graph.GraphBase
PlotSurface2D Surface [get, private set]
 
abstract string YLabel [get]
 
- Properties inherited from Ntp.Analyzer.Export.IStreamGenerator
IEnumerable< StreamDestinationDestinations [get]
 

Static Private Member Functions

static string FText (double value)
 

Private Attributes

readonly ITrafficGraphConfiguration config
 
readonly List< double > dropped = new List<double>()
 
readonly List< double > droppedAvg = new List<double>()
 
readonly Host host
 
readonly List< double > ignored = new List<double>()
 
readonly List< double > ignoredAvg = new List<double>()
 
readonly List< double > notSent = new List<double>()
 
readonly List< double > notSentAvg = new List<double>()
 
readonly List< double > received = new List<double>()
 
readonly List< double > receivedAvg = new List<double>()
 
readonly List< double > receivedAvgTot = new List<double>()
 
readonly List< double > sent = new List<double>()
 
readonly List< double > sentAvg = new List<double>()
 
readonly List< DateTime > time = new List<DateTime>()
 

Additional Inherited Members

- Public Attributes inherited from Ntp.Analyzer.Graph.GraphBase
IEnumerable< StreamDestinationDestinations => destinations
 
string ImageFileExtension => "png"
 
- Protected Attributes inherited from Ntp.Analyzer.Graph.GraphBase
TimeSpan GraphTimeSpan => new TimeSpan(baseConfig.Timespan, 0, 0, 0)
 

Detailed Description

Definition at line 34 of file TrafficGraph.cs.

Constructor & Destructor Documentation

Ntp.Analyzer.Graph.TrafficGraph.TrafficGraph ( ITrafficGraphConfiguration  configuration,
Host  host 
)
inline

Definition at line 36 of file TrafficGraph.cs.

37  : base(configuration)
38  {
39  config = configuration;
40  this.host = host;
41  }
readonly ITrafficGraphConfiguration config
Definition: TrafficGraph.cs:43

Member Function Documentation

override void Ntp.Analyzer.Graph.TrafficGraph.AddPlots ( )
inlineprotectedvirtual

Implements Ntp.Analyzer.Graph.GraphBase.

Definition at line 83 of file TrafficGraph.cs.

84  {
85  if (config.Received.HasValue)
86  {
87  var receivedPlot = SetupPlot("Packets received" + FText(config.Received.Value), Color.Green, time,
88  received);
89  Surface.Add(receivedPlot, PlotSurface2D.XAxisPosition.Bottom, PlotSurface2D.YAxisPosition.Left);
90  }
91 
92  if (config.ReceivedAvg.HasValue)
93  {
94  var receivedAvgPlot = SetupPlot(
95  "Packets received accumulated" + FText(config.ReceivedAvg.Value),
96  Color.Orange,
97  time,
98  receivedAvg);
99 
100  Surface.Add(receivedAvgPlot, PlotSurface2D.XAxisPosition.Bottom, PlotSurface2D.YAxisPosition.Left);
101 
102  var receivedAvgTotPlot = SetupPlot(
103  "Packets received since reset" + FText(config.ReceivedAvg.Value),
104  Color.Purple,
105  time,
107 
108  Surface.Add(receivedAvgTotPlot, PlotSurface2D.XAxisPosition.Bottom, PlotSurface2D.YAxisPosition.Left);
109  }
110 
111  if (config.Dropped.HasValue)
112  {
113  var droppedPlot = SetupPlot("Packets dropped" + FText(config.Dropped.Value), Color.Red, time, dropped);
114  Surface.Add(droppedPlot, PlotSurface2D.XAxisPosition.Bottom, PlotSurface2D.YAxisPosition.Left);
115  }
116 
117  if (config.Ignored.HasValue)
118  {
119  var ignoredPlot = SetupPlot("Packets ignored" + FText(config.Ignored.Value), Color.Blue, time, ignored);
120  Surface.Add(ignoredPlot, PlotSurface2D.XAxisPosition.Bottom, PlotSurface2D.YAxisPosition.Left);
121  }
122 
123  if (config.Sent.HasValue)
124  {
125  var sentPlot = SetupPlot("Packets sent" + FText(config.Sent.Value), Color.Black, time, sent);
126  Surface.Add(sentPlot, PlotSurface2D.XAxisPosition.Bottom, PlotSurface2D.YAxisPosition.Left);
127  }
128 
129  if (config.NotSent.HasValue)
130  {
131  var notSentPlot = SetupPlot("Packets not sent" + FText(config.NotSent.Value), Color.DarkRed, time,
132  notSent);
133  Surface.Add(notSentPlot, PlotSurface2D.XAxisPosition.Bottom, PlotSurface2D.YAxisPosition.Left);
134  }
135  }
readonly List< DateTime > time
Definition: TrafficGraph.cs:56
readonly List< double > notSent
Definition: TrafficGraph.cs:49
readonly ITrafficGraphConfiguration config
Definition: TrafficGraph.cs:43
readonly List< double > ignored
Definition: TrafficGraph.cs:47
readonly List< double > receivedAvg
Definition: TrafficGraph.cs:52
readonly List< double > received
Definition: TrafficGraph.cs:51
readonly List< double > receivedAvgTot
Definition: TrafficGraph.cs:53
LinePlot SetupPlot(string name, Color color, IList time, IList data)
Definition: GraphBase.cs:158
readonly List< double > dropped
Definition: TrafficGraph.cs:44
readonly List< double > sent
Definition: TrafficGraph.cs:54
static string FText(double value)
static string Ntp.Analyzer.Graph.TrafficGraph.FText ( double  value)
inlinestaticprivate

Definition at line 258 of file TrafficGraph.cs.

259  {
260  return Math.Abs(value - 1.0) > 0.0
261  ? " x " + value.ToString("0", CultureInfo.InvariantCulture)
262  : string.Empty;
263  }
override void Ntp.Analyzer.Graph.TrafficGraph.LoadData ( )
inlineprotectedvirtual

Implements Ntp.Analyzer.Graph.GraphBase.

Definition at line 137 of file TrafficGraph.cs.

References Ntp.Analyzer.Data.Sql.FilteredSqlDatabaseMapper< T >.FilterHost, Ntp.Analyzer.Data.Sql.FilteredSqlDatabaseMapper< T >.FilterTime, Ntp.Analyzer.Data.DataFace.HostIoReadings, and Ntp.Analyzer.Data.DataFace.Instance.

138  {
140  dataMapper.FilterHost = host;
141  dataMapper.FilterTime = DateTime.UtcNow.Subtract(GraphTimeSpan);
142 
143  var startTime = DateTime.MinValue;
144 
145  var firstTime = DateTime.MinValue;
146  long firstReceived = 0;
147  long firstIgnored = 0;
148  long firstDropped = 0;
149  long firstSent = 0;
150  long firstNotSent = 0;
151 
152  var lastTime = DateTime.MinValue;
153  long lastReceived = 0;
154  long lastIgnored = 0;
155  long lastDropped = 0;
156  long lastSent = 0;
157  long lastNotSent = 0;
158 
159  bool firstRun = true;
160  int disFactor = config.PacketRate;
161  int interval = config.PlotInterval*config.Timespan;
162 
163  foreach (var reading in dataMapper)
164  {
165  bool readNext = false;
166  var readingTime = config.GraphTime == DateTimeKind.Local
167  ? reading.RoundedLocalTime
168  : reading.RoundedUtcTime;
169 
170  if (!firstRun)
171  {
172  double minutes = readingTime.Subtract(lastTime).TotalMinutes;
173  double totalMinutes = readingTime.Subtract(firstTime).TotalMinutes;
174  double minutesSinceReset = readingTime.Subtract(startTime).TotalMinutes;
175 
176  if (minutes >= interval)
177  {
178  time.Add(readingTime);
179 
180  received.Add((reading.ReceivedPackets - lastReceived)*config.Received/minutes/disFactor ?? 0.0);
181  ignored.Add((reading.IgnoredPackets - lastIgnored)*config.Ignored/minutes/disFactor ?? 0.0);
182  dropped.Add((reading.DroppedPackets - lastDropped)*config.Dropped/minutes/disFactor ?? 0.0);
183  sent.Add((reading.PacketsSent - lastSent)*config.Sent/minutes/disFactor ?? 0.0);
184  notSent.Add((reading.PacketsNotSent - lastNotSent)*config.NotSent/minutes/disFactor ?? 0.0);
185  receivedAvg.Add((reading.ReceivedPackets - firstReceived)*config.ReceivedAvg/totalMinutes/
186  disFactor ?? 0.0);
187 
188  // TODO
189  if (config.ReceivedAvg.HasValue)
190  receivedAvgTot.Add(reading.ReceivedPackets*config.ReceivedAvg.Value/minutesSinceReset/
191  disFactor);
192  else
193  receivedAvgTot.Add(0.0);
194 
195  if (config.IgnoredAvg.HasValue)
196  ignoredAvg.Add((reading.IgnoredPackets - firstIgnored)*config.IgnoredAvg.Value/totalMinutes/
197  disFactor);
198  else
199  ignoredAvg.Add(0.0);
200 
201  if (config.DroppedAvg.HasValue)
202  droppedAvg.Add((reading.DroppedPackets - firstDropped)*config.DroppedAvg.Value/totalMinutes/
203  disFactor);
204  else
205  droppedAvg.Add(0.0);
206 
207  if (config.SentAvg.HasValue)
208  sentAvg.Add((reading.PacketsSent - firstSent)*config.SentAvg.Value/totalMinutes/disFactor);
209  else
210  sentAvg.Add(0.0);
211 
212  if (config.NotSentAvg.HasValue)
213  notSentAvg.Add((reading.PacketsNotSent - firstNotSent)*config.NotSentAvg.Value/totalMinutes/
214  disFactor);
215  else
216  notSentAvg.Add(0.0);
217 
218  readNext = true;
219  }
220  }
221  else
222  {
223  int hours = reading.TimeSinceReset/(60*60);
224  int mins = (reading.TimeSinceReset - hours*60*60)/60;
225  int seconds = reading.TimeSinceReset - hours*60*60 - mins*60;
226  var span = new TimeSpan(hours, mins, seconds);
227  startTime = readingTime.Subtract(span);
228 
229  firstTime = readingTime;
230  firstReceived = reading.ReceivedPackets;
231  firstIgnored = reading.IgnoredPackets;
232  firstDropped = reading.DroppedPackets;
233  firstSent = reading.PacketsSent;
234  firstNotSent = reading.PacketsNotSent;
235  }
236 
237  if (firstRun || readNext)
238  {
239  lastTime = readingTime;
240  lastReceived = reading.ReceivedPackets;
241  lastIgnored = reading.IgnoredPackets;
242  lastDropped = reading.DroppedPackets;
243  lastSent = reading.PacketsSent;
244  lastNotSent = reading.PacketsNotSent;
245  }
246 
247  firstRun = false;
248  }
249  }
readonly List< DateTime > time
Definition: TrafficGraph.cs:56
DateTime FilterTime
Gets or sets the time to use when extracting data. Only readings with a timestamp later than FilterTi...
readonly List< double > notSent
Definition: TrafficGraph.cs:49
readonly List< double > notSentAvg
Definition: TrafficGraph.cs:50
readonly ITrafficGraphConfiguration config
Definition: TrafficGraph.cs:43
readonly List< double > ignored
Definition: TrafficGraph.cs:47
readonly List< double > receivedAvg
Definition: TrafficGraph.cs:52
Singleton facade class used to access memory persistent data.
Definition: DataFace.cs:30
readonly List< double > received
Definition: TrafficGraph.cs:51
readonly List< double > receivedAvgTot
Definition: TrafficGraph.cs:53
static DataFace Instance
Gets the Singleton instance.
Definition: DataFace.cs:51
readonly List< double > ignoredAvg
Definition: TrafficGraph.cs:48
readonly List< double > sentAvg
Definition: TrafficGraph.cs:55
readonly List< double > dropped
Definition: TrafficGraph.cs:44
readonly List< double > sent
Definition: TrafficGraph.cs:54
readonly List< double > droppedAvg
Definition: TrafficGraph.cs:45
HostIoReadingDatabaseMapper HostIoReadings
Gets the host IO reading mapper.
Definition: DataFace.cs:81
override void Ntp.Analyzer.Graph.TrafficGraph.PreRender ( )
inlineprotectedvirtual

Reimplemented from Ntp.Analyzer.Graph.GraphBase.

Definition at line 251 of file TrafficGraph.cs.

252  {
253  base.PreRender();
254 
255  Surface.YAxis1.NumberFormat = "{0:####0}";
256  }

Member Data Documentation

readonly ITrafficGraphConfiguration Ntp.Analyzer.Graph.TrafficGraph.config
private

Definition at line 43 of file TrafficGraph.cs.

readonly List<double> Ntp.Analyzer.Graph.TrafficGraph.dropped = new List<double>()
private

Definition at line 44 of file TrafficGraph.cs.

readonly List<double> Ntp.Analyzer.Graph.TrafficGraph.droppedAvg = new List<double>()
private

Definition at line 45 of file TrafficGraph.cs.

readonly Host Ntp.Analyzer.Graph.TrafficGraph.host
private

Definition at line 46 of file TrafficGraph.cs.

readonly List<double> Ntp.Analyzer.Graph.TrafficGraph.ignored = new List<double>()
private

Definition at line 47 of file TrafficGraph.cs.

readonly List<double> Ntp.Analyzer.Graph.TrafficGraph.ignoredAvg = new List<double>()
private

Definition at line 48 of file TrafficGraph.cs.

readonly List<double> Ntp.Analyzer.Graph.TrafficGraph.notSent = new List<double>()
private

Definition at line 49 of file TrafficGraph.cs.

readonly List<double> Ntp.Analyzer.Graph.TrafficGraph.notSentAvg = new List<double>()
private

Definition at line 50 of file TrafficGraph.cs.

readonly List<double> Ntp.Analyzer.Graph.TrafficGraph.received = new List<double>()
private

Definition at line 51 of file TrafficGraph.cs.

readonly List<double> Ntp.Analyzer.Graph.TrafficGraph.receivedAvg = new List<double>()
private

Definition at line 52 of file TrafficGraph.cs.

readonly List<double> Ntp.Analyzer.Graph.TrafficGraph.receivedAvgTot = new List<double>()
private

Definition at line 53 of file TrafficGraph.cs.

readonly List<double> Ntp.Analyzer.Graph.TrafficGraph.sent = new List<double>()
private

Definition at line 54 of file TrafficGraph.cs.

readonly List<double> Ntp.Analyzer.Graph.TrafficGraph.sentAvg = new List<double>()
private

Definition at line 55 of file TrafficGraph.cs.

readonly List<DateTime> Ntp.Analyzer.Graph.TrafficGraph.time = new List<DateTime>()
private

Definition at line 56 of file TrafficGraph.cs.

Property Documentation

override string Ntp.Analyzer.Graph.TrafficGraph.YLabel
getprotected

Definition at line 59 of file TrafficGraph.cs.


The documentation for this class was generated from the following file: