NTP Analyzer  0.8.2
Analyze the operation of time servers
Keyword.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.Collections.Generic;
24 using System.Linq;
25 
26 namespace Ntp.Analyzer.Config.Table
27 {
28  public sealed class Keyword
29  {
30  private Keyword(string name, Symbol symbol, Type valueType = null)
31  {
32  Name = name;
33  Symbol = symbol;
34  ValueType = valueType;
35  LowerText = name.ToLower();
36  }
37 
38  public static Keyword Undefined = new Keyword("Undefined", Symbol.Undefined);
39  public static Keyword DatabaseProvider = new Keyword("Provider", Symbol.KeywordDatabaseProvider);
40  public static Keyword PageTheme = new Keyword("Template", Symbol.KeywordPageTemplate);
41  public static Keyword TimeStamp = new Keyword("TimeStamp", Symbol.KeywordTimeStamp);
42  public static Keyword Severity = new Keyword("Severity", Symbol.KeywordSeverity);
43  public static Keyword HostType = new Keyword("HostType", Symbol.KeywordHostType);
44  public static Keyword Content = new Keyword("Content", Symbol.KeywordContent, typeof(string));
45  public static Keyword Type = new Keyword("Type", Symbol.KeywordType, typeof(string));
46 
47  public static IEnumerable<Keyword> Keywords = new List<Keyword>
48  {
49  DatabaseProvider,
50  PageTheme,
51  TimeStamp,
52  Severity,
53  HostType,
54  Content,
55  Type,
56  new Keyword("Database", Symbol.KeywordDatabase),
57  new Keyword("Permission", Symbol.KeywordPermission),
58  new Keyword("Listener", Symbol.KeywordListener),
59  new Keyword("Cluster", Symbol.KeywordCluster),
60  new Keyword("Log", Symbol.KeywordLog),
61  new Keyword("Reading", Symbol.KeywordReading),
62  new Keyword("Notify", Symbol.KeywordNotify),
63  new Keyword("Server", Symbol.KeywordServer),
64  new Keyword("HostStats", Symbol.KeywordHostStats),
65  new Keyword("HostIoStats", Symbol.KeywordHostIoStats),
66  new Keyword("PeerStats", Symbol.KeywordPeerStats),
67  new Keyword("DriftStats", Symbol.KeywordDriftStats),
68  new Keyword("Menu", Symbol.KeywordMenu),
69  new Keyword("AboutPage", Symbol.KeywordAboutPage),
70  new Keyword("HostPage", Symbol.KeywordHostPage),
71  new Keyword("HostGraph", Symbol.KeywordHostGraph),
72  new Keyword("PeerGraphs", Symbol.KeywordPeerGraph),
73  new Keyword("TrafficGraph", Symbol.KeywordTrafficGraph),
74  new Keyword("HostGraphPage", Symbol.KeywordHostGraphPage),
75  new Keyword("PeerGraphPage", Symbol.KeywordPeerGraphPage),
76  new Keyword("Images", Symbol.KeywordGraphSet),
77  new Keyword("Destinations", Symbol.KeywordDestinations),
78  new Keyword("Summaries", Symbol.KeywordSummaries),
79  new Keyword("Item", Symbol.KeywordItem),
80  new Keyword("Cluster", Symbol.KeywordClusterNode),
81  new Keyword("Links", Symbol.KeywordWebLinks),
82  new Keyword("Default", Symbol.KeywordDefault),
83  new Keyword("Bootstrap", Symbol.KeywordBootstrap),
84  new Keyword("MySQL", Symbol.KeywordDatabaseProviderMySql),
85  new Keyword("PostgreSQL", Symbol.KeywordDatabaseProviderPostgre),
86  new Keyword("Console", Symbol.KeywordConsole),
87  new Keyword("Syslog", Symbol.KeywordSyslog),
88  new Keyword("Error", Symbol.KeywordError),
89  new Keyword("Warn", Symbol.KeywordWarn),
90  new Keyword("Notice", Symbol.KeywordNotice),
91  new Keyword("Info", Symbol.KeywordInfo),
92  new Keyword("Debug", Symbol.KeywordDebug),
93  new Keyword("Trace", Symbol.KeywordTrace),
94  new Keyword("GraphTime", Symbol.KeywordGraphTime),
95  new Keyword("PageTime", Symbol.KeywordPageTime),
96  new Keyword("UTC", Symbol.KeywordTimeStampUtc),
97  new Keyword("Local", Symbol.KeywordTimeStampLocal),
98  new Keyword("ntpdc", Symbol.KeywordNtpdc),
99  new Keyword("ntpq", Symbol.KeywordNtpq),
100  new Keyword("ntpctl", Symbol.KeywordNtpctl),
101  new Keyword("Spacer", Symbol.KeywordSpacer),
102  new Keyword("Header", Symbol.KeywordHeader),
103  new Keyword("True", Symbol.BooleanTrue),
104  new Keyword("False", Symbol.BooleanFalse),
105  new Keyword("On", Symbol.BooleanTrue),
106  new Keyword("Off", Symbol.BooleanFalse),
107  new Keyword("Unknown", Symbol.KeywordUnknown),
108  new Keyword("Daemon", Symbol.KeywordDaemon),
109  new Keyword("Service", Symbol.KeywordService),
110  new Keyword("Protocol", Symbol.KeywordProtocol),
111  new Keyword("SslMode", Symbol.KeywordSslMode),
112  new Keyword("Required", Symbol.KeywordRequired),
113  new Keyword("Preferred", Symbol.KeywordPreferred),
114  new Keyword("PeerSummaryPage", Symbol.KeywordPeerSummaryPage, typeof(string)),
115  new Keyword("Include", Symbol.KeywordInclude, typeof(string)),
116  new Keyword("Host", Symbol.KeywordHost, typeof(string)),
117  new Keyword("Port", Symbol.KeywordPort, typeof(int)),
118  new Keyword("User", Symbol.KeywordUser, typeof(string)),
119  new Keyword("Pass", Symbol.KeywordPass, typeof(string)),
120  new Keyword("File", Symbol.KeywordFile, typeof(string)),
121  new Keyword("Address", Symbol.KeywordAddress, typeof(string)),
122  new Keyword("IP", Symbol.KeywordIp, typeof(string)),
123  new Keyword("EnableSsl", Symbol.KeywordEnableSsl, typeof(bool)),
124  new Keyword("Name", Symbol.KeywordName, typeof(string)),
125  new Keyword("InitialRun", Symbol.KeywordInitialRun, typeof(bool)),
126  new Keyword("FixedRun", Symbol.KeywordFixedRun, typeof(bool)),
127  new Keyword("Frequency", Symbol.KeywordFrequency, typeof(int)),
128  new Keyword("Create", Symbol.KeywordCreate, typeof(bool)),
129  new Keyword("Upgrade", Symbol.KeywordUpgrade, typeof(bool)),
130  new Keyword("Import", Symbol.KeywordImport, typeof(bool)),
131  new Keyword("ShowTimestamp", Symbol.KeywordShowTimestamp, typeof(bool)),
132  new Keyword("ShowSeverity", Symbol.KeywordShowSeverity, typeof(bool)),
133  new Keyword("TimeFormat", Symbol.KeywordTimeFormat, typeof(string)),
134  new Keyword("HostID", Symbol.KeywordHostId, typeof(int)),
135  new Keyword("HostAddress", Symbol.KeywordHostAddress, typeof(string)),
136  new Keyword("FilePath", Symbol.KeywordFilePath, typeof(string)),
137  new Keyword("WebPath", Symbol.KeywordWebPath, typeof(string)),
138  new Keyword("Recipient", Symbol.KeywordRecipient, typeof(string)),
139  new Keyword("Subject", Symbol.KeywordSubject, typeof(string)),
140  new Keyword("Sender", Symbol.KeywordSender, typeof(string)),
141  new Keyword("Mail", Symbol.KeywordMail, typeof(string)),
142  new Keyword("PageTitle", Symbol.KeywordPageTitle, typeof(string)),
143  new Keyword("PoolMember", Symbol.KeywordPoolMember, typeof(bool)),
144  new Keyword("QueryDirect", Symbol.KeywordQueryDirect, typeof(bool)),
145  new Keyword("ServerID", Symbol.KeywordServerId, typeof(int)),
146  new Keyword("ContentTitle", Symbol.KeywordContentTitle, typeof(string)),
147  new Keyword("Link", Symbol.KeywordLink, typeof(string)),
148  new Keyword("PeerPages", Symbol.KeywordPeerPage, typeof(string)),
149  new Keyword("GraphPage", Symbol.KeywordGraphPage, typeof(string)),
150  new Keyword("Title", Symbol.KeywordTitle, typeof(string)),
151  new Keyword("Width", Symbol.KeywordWidth, typeof(int)),
152  new Keyword("Height", Symbol.KeywordHeight, typeof(int)),
153  new Keyword("Timespan", Symbol.KeywordTimespan, typeof(int)),
154  new Keyword("FilterFactor", Symbol.KeywordFilterFactor, typeof(double)),
155  new Keyword("Jitter", Symbol.KeywordJitter, typeof(double)),
156  new Keyword("Offset", Symbol.KeywordOffset, typeof(double)),
157  new Keyword("GFrequency", Symbol.KeywordGraphFrequency, typeof(double)),
158  new Keyword("Stability", Symbol.KeywordGraphStability, typeof(double)),
159  new Keyword("Balance", Symbol.KeywordGraphBalance, typeof(double)),
160  new Keyword("Delay", Symbol.KeywordGraphDelay, typeof(double)),
161  new Keyword("Received", Symbol.KeywordGraphReceived, typeof(double)),
162  new Keyword("Ignored", Symbol.KeywordGraphIgnored, typeof(double)),
163  new Keyword("Dropped", Symbol.KeywordGraphDropped, typeof(double)),
164  new Keyword("Sent", Symbol.KeywordGraphSent, typeof(double)),
165  new Keyword("NotSent", Symbol.KeywordGraphNotSent, typeof(double)),
166  new Keyword("AvgReceived", Symbol.KeywordGraphAvgReceived, typeof(double)),
167  new Keyword("AvgIgnored", Symbol.KeywordGraphAvgIgnored, typeof(double)),
168  new Keyword("AvgDropped", Symbol.KeywordGraphAvgDropped, typeof(double)),
169  new Keyword("AvgSent", Symbol.KeywordGraphAvgSent, typeof(double)),
170  new Keyword("AvgNotSent", Symbol.KeywordGraphAvgNotSent, typeof(double)),
171  new Keyword("PlotInterval", Symbol.KeywordGraphPlotInterval, typeof(double)),
172  new Keyword("PacketRate", Symbol.KeywordGraphPacketRate, typeof(double)),
173  new Keyword("Graph", Symbol.KeywordGraph, typeof(string)),
174  new Keyword("LinkIndex", Symbol.KeywordLinkIndex, typeof(int)),
175  new Keyword("Prefix", Symbol.KeywordPrefix, typeof(string)),
176  new Keyword("Directory", Symbol.KeywordDirectory, typeof(string)),
177  new Keyword("Caption", Symbol.KeywordCaption, typeof(string)),
178  new Keyword("Page", Symbol.KeywordPage, typeof(string)),
179  new Keyword("Heartbeat", Symbol.KeywordHeartbeat, typeof(int)),
180  new Keyword("Rate", Symbol.KeywordRate, typeof(int)),
181  new Keyword("ExecUser", Symbol.KeywordExecUser, typeof(string)),
182  new Keyword("Group", Symbol.KeywordGroup, typeof(string)),
183  new Keyword("Mode", Symbol.KeywordMode, typeof(int)),
184  new Keyword("Dropdown", Symbol.KeywordDropdown, typeof(string)),
185  new Keyword("ConnectionString", Symbol.KeywordConString, typeof(string)),
186  new Keyword("CertificateFile", Symbol.KeywordCertFile, typeof(string)),
187  new Keyword("CertificatePassword", Symbol.KeywordCertPass, typeof(string)),
188  new Keyword("ConnectionTimeout", Symbol.KeywordConnectionTimeout, typeof(int)),
189  // Deprecated keywords
190  new Keyword("DatabaseName", Symbol.KeywordDatabaseName, typeof(string)),
191  new Keyword("DatabaseUser", Symbol.KeywordDatabaseUser, typeof(string)),
192  new Keyword("DatabasePass", Symbol.KeywordDatabasePass, typeof(string)),
193  new Keyword("SmtpHost", Symbol.KeywordSmtpHost, typeof(string)),
194  new Keyword("SmtpPort", Symbol.KeywordSmtpPort, typeof(int)),
195  new Keyword("SmtpUser", Symbol.KeywordSmtpUser, typeof(string)),
196  new Keyword("SmtpPass", Symbol.KeywordSmtpPass, typeof(string))
197  };
198 
199  public string Name { get; }
200 
201  public Type ValueType { get; }
202 
203  public string LowerText { get; }
204 
205  public Symbol Symbol { get; }
206 
207  public override bool Equals(object obj)
208  {
209  var other = obj as Keyword;
210  if (other == null)
211  return false;
212 
213  return other.LowerText == LowerText;
214  }
215 
216  public static Keyword Find(Symbol symbol)
217  {
218  return Keywords.FirstOrDefault(k => k.Symbol == symbol);
219  }
220 
221  public override int GetHashCode()
222  {
223  return LowerText.GetHashCode();
224  }
225  }
226 }
static Keyword Find(Symbol symbol)
Definition: Keyword.cs:216
Keyword(string name, Symbol symbol, Type valueType=null)
Definition: Keyword.cs:30
override bool Equals(object obj)
Definition: Keyword.cs:207