NTP Analyzer  0.8.2
Analyze the operation of time servers
TrafficGraphConfiguration.cs
Go to the documentation of this file.
1 //
2 // Copyright (c) 2013-2017 Carsten Sonne Larsen <cs@innolan.net>
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining a copy
5 // of this software and associated documentation files (the "Software"), to deal
6 // in the Software without restriction, including without limitation the rights
7 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 // copies of the Software, and to permit persons to whom the Software is
9 // furnished to do so, subject to the following conditions:
10 //
11 // The above copyright notice and this permission notice shall be included in
12 // all copies or substantial portions of the Software.
13 //
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 // THE SOFTWARE.
21 
22 using System;
23 using System.Drawing.Imaging;
26 using Ntp.Analyzer.Config.Table;
27 using Ntp.Analyzer.Interface;
28 using Ntp.Analyzer.Objects;
29 using Ntp.Common.Process;
30 using Ntp.Common.Web;
31 
32 namespace Ntp.Analyzer.Config.Node.Graph
33 {
39  {
41  string name,
42  int? frequency,
43  bool? initialRun,
44  bool? fixedRun,
45  string title,
46  int? width,
47  int? height,
48  int? timespan,
49  DateTimeKind? graphTime,
50  double? received,
51  double? ignored,
52  double? dropped,
53  double? sent,
54  double? notSent,
55  double? receivedAvg,
56  double? ignoredAvg,
57  double? droppedAvg,
58  double? sentAvg,
59  double? notSentAvg,
60  int? plotInterval,
61  int? packetRate,
62  DestinationCollection destinations,
63  WebLinkCollection links)
64  : base(name)
65  {
66  this.frequency = frequency;
67  this.initialRun = initialRun;
68  this.fixedRun = fixedRun;
69  Title = title;
70  this.timespan = timespan;
71  this.height = height;
72  this.width = width;
73  this.graphTime = graphTime;
74  Received = received;
75  Ignored = ignored;
76  Dropped = dropped;
77  Sent = sent;
78  NotSent = notSent;
79  ReceivedAvg = receivedAvg;
80  IgnoredAvg = ignoredAvg;
81  DroppedAvg = droppedAvg;
82  SentAvg = sentAvg;
83  NotSentAvg = notSentAvg;
84  this.plotInterval = plotInterval;
85  this.packetRate = packetRate;
86  Destinations = destinations;
87  ConfigLinks = links;
88  }
89 
90  private readonly bool? fixedRun;
91  private readonly int? frequency;
92  private readonly DateTimeKind? graphTime;
93  private readonly int? height;
94  private readonly bool? initialRun;
95  private readonly int? packetRate;
96  private readonly int? plotInterval;
97  private readonly int? timespan;
98  private readonly int? width;
99 
100  [NtpaIndex(50)]
101  [NtpaSetting(Symbol.KeywordDestinations)]
102  public override DestinationCollection Destinations { get; }
103 
104  [NtpaIndex(51)]
105  [NtpaSetting(Symbol.KeywordWebLinks)]
106  public override WebLinkCollection ConfigLinks { get; }
107 
108  [NtpaIndex(1)]
109  [NtpaSetting(Symbol.KeywordFrequency, 5)]
110  public int Frequency => frequency ?? 5;
111 
112  [NtpaIndex(2)]
113  [NtpaSetting(Symbol.KeywordInitialRun, false)]
114  public bool InitialRun => initialRun ?? false;
115 
116  [NtpaIndex(3)]
117  [NtpaSetting(Symbol.KeywordFixedRun, true)]
118  public bool FixedRun => fixedRun ?? true;
119 
124  [NtpaIndex(10)]
125  [NtpaSetting(Symbol.KeywordTitle, Layout = Layout.Quoted)]
126  public override string Title { get; }
127 
132  [NtpaIndex(11)]
133  [NtpaSetting(Symbol.KeywordTimespan, 60*12)]
134  public override int Timespan => timespan ?? 60*12;
135 
140  [NtpaIndex(20)]
141  [NtpaSetting(Symbol.KeywordWidth, 1024)]
142  public override int Width => width ?? 1024;
143 
148  [NtpaIndex(21)]
149  [NtpaSetting(Symbol.KeywordHeight, 550)]
150  public override int Height => height ?? 550;
151 
156  [NtpaIndex(22)]
157  public override ImageFormat Format => ImageFormat.Png;
158 
159  [NtpaIndex(31)]
160  [NtpaSetting(Symbol.KeywordGraphReceived)]
161  public double? Received { get; }
162 
163  [NtpaIndex(32)]
164  [NtpaSetting(Symbol.KeywordGraphIgnored)]
165  public double? Ignored { get; }
166 
167  [NtpaIndex(33)]
168  [NtpaSetting(Symbol.KeywordGraphDropped)]
169  public double? Dropped { get; }
170 
171  [NtpaIndex(34)]
172  [NtpaSetting(Symbol.KeywordGraphSent)]
173  public double? Sent { get; }
174 
175  [NtpaIndex(35)]
176  [NtpaSetting(Symbol.KeywordGraphNotSent)]
177  public double? NotSent { get; }
178 
179  [NtpaIndex(36)]
180  [NtpaSetting(Symbol.KeywordGraphAvgReceived)]
181  public double? ReceivedAvg { get; }
182 
183  [NtpaIndex(37)]
184  [NtpaSetting(Symbol.KeywordGraphAvgIgnored)]
185  public double? IgnoredAvg { get; }
186 
187  [NtpaIndex(38)]
188  [NtpaSetting(Symbol.KeywordGraphAvgDropped)]
189  public double? DroppedAvg { get; }
190 
191  [NtpaIndex(39)]
192  [NtpaSetting(Symbol.KeywordGraphAvgSent)]
193  public double? SentAvg { get; }
194 
195  [NtpaIndex(40)]
196  [NtpaSetting(Symbol.KeywordGraphAvgNotSent)]
197  public double? NotSentAvg { get; }
198 
199  [NtpaIndex(13)]
200  [NtpaSetting(Symbol.KeywordGraphPlotInterval, 15)]
201  public int PlotInterval => plotInterval ?? 15;
202 
203  [NtpaIndex(14)]
204  [NtpaSetting(Symbol.KeywordGraphPacketRate, 1)]
205  public int PacketRate => packetRate ?? 1;
206 
211  [NtpaIndex(12)]
212  [NtpaSetting(Symbol.KeywordGraphTime, DateTimeKind.Utc)]
213  public override DateTimeKind GraphTime => graphTime ?? DateTimeKind.Utc;
214 
221  public override string GetAltName(GraphSetConfiguration owner, string postfix)
222  {
223  int index = owner.LinkIndex;
224  string name = Links.Destinations[index - 1].Link;
225 
226  // remove any path from name
227  int pos = name.LastIndexOf('/');
228  name = pos != -1 ? name.Remove(0, pos + 1) : name;
229 
230  return name;
231  }
232 
239  public override Uri GetLink(GraphSetConfiguration owner, string postfix)
240  {
241  return WebPath.Append(Links.Destinations[owner.LinkIndex - 1].Link);
242  }
243 
244  public override string GetTitle(NamedObject namedObject)
245  {
246  return Title;
247  }
248  }
249 }
TrafficGraphConfiguration(string name, int?frequency, bool?initialRun, bool?fixedRun, string title, int?width, int?height, int?timespan, DateTimeKind?graphTime, double?received, double?ignored, double?dropped, double?sent, double?notSent, double?receivedAvg, double?ignoredAvg, double?droppedAvg, double?sentAvg, double?notSentAvg, int?plotInterval, int?packetRate, DestinationCollection destinations, WebLinkCollection links)
Traffic graph configuration used when creating Analyzer.Graph.TrafficGraph.
override string GetAltName(GraphSetConfiguration owner, string postfix)
Gets the alternative name when referred to from web pages.
override Uri GetLink(GraphSetConfiguration owner, string postfix)
Gets the link to use when referred to from web pages.