public MetricConfig(TimeSpan interval, GraphiteConfig graphite, InfluxConfig influx, PrometheusConfig prometheus) { Interval = interval; Graphite = graphite; Influx = influx; Prometheus = prometheus; }
public static MetricConfig ParseAppSettings() { if (!int.TryParse(ConfigurationManager.AppSettings["interval"], out int seconds)) { seconds = 5; } var interval = TimeSpan.FromSeconds(seconds); var type = ConfigurationManager.AppSettings["type"] ?? "graphite"; GraphiteConfig gconfig = null; InfluxConfig iconfig = null; switch (type.ToLowerInvariant()) { case "graphite": gconfig = GraphiteConfig.ParseAppSettings(); break; case "influxdb": case "influx": iconfig = InfluxConfig.ParseAppSettings(); break; } return(new MetricConfig(interval, gconfig, iconfig)); }
public static MetricConfig ParseAppSettings(IAppConfig config) { if (!int.TryParse(config["interval"], out int seconds)) { seconds = 5; } var interval = TimeSpan.FromSeconds(seconds); var type = config["type"] ?? "graphite"; GraphiteConfig gconfig = null; InfluxConfig iconfig = null; PrometheusConfig pconfig = null; switch (type.ToLowerInvariant()) { case "graphite": gconfig = GraphiteConfig.ParseAppSettings(config); break; case "influxdb": case "influx": iconfig = InfluxConfig.ParseAppSettings(config); break; case "prometheus": pconfig = PrometheusConfig.ParseAppSettings(config); break; } return(new MetricConfig(interval, gconfig, iconfig, pconfig)); }
public MetricConfig(TimeSpan interval, GraphiteConfig graphite, InfluxConfig influx, PrometheusConfig prometheus, string timescale) { Interval = interval; Graphite = graphite; Influx = influx; Prometheus = prometheus; Timescale = timescale; }
public MetricConfig(TimeSpan interval, INameResolution nameLookup, GraphiteConfig graphite, InfluxConfig influx, PrometheusConfig prometheus, TimescaleConfig timescale) { _nameLookup = nameLookup; Interval = interval; Graphite = graphite; Influx = influx; Prometheus = prometheus; Timescale = timescale; }
public MetricConfig(TimeSpan interval, INameResolution nameLookup, GraphiteConfig graphite, InfluxConfig influx, PrometheusConfig prometheus, TimescaleConfig timescale, Dictionary <String, String> aliases) { _nameLookup = nameLookup; Interval = interval; Graphite = graphite; Influx = influx; Prometheus = prometheus; Timescale = timescale; Aliases = aliases; }
public static MetricConfig ParseAppSettings(IAppConfig config) { if (!int.TryParse(config["interval"], out int seconds)) { seconds = 5; } var interval = TimeSpan.FromSeconds(seconds); INameResolution nameLookup = NameLookup(config["name_lookup"] ?? "netbios"); var type = config["type"] ?? "graphite"; GraphiteConfig gconfig = null; InfluxConfig iconfig = null; PrometheusConfig pconfig = null; TimescaleConfig timescale = null; switch (type.ToLowerInvariant()) { case "graphite": gconfig = GraphiteConfig.ParseAppSettings(config); break; case "influxdb": case "influx": iconfig = InfluxConfig.ParseAppSettings(config); break; case "prometheus": pconfig = PrometheusConfig.ParseAppSettings(config); break; case "timescale": case "timescaledb": timescale = TimescaleConfig.ParseAppSettings(config); break; } // Trim off the LibreHardwareMonitor "/name" suffix so that it is just the // the sensor ID. var aliases = config.GetKeys().Where(x => x.EndsWith("/name")) .ToDictionary( x => x.Remove(x.LastIndexOf("/name", StringComparison.Ordinal)), x => config[x] ); var hidden = config.GetKeys().Where(x => x.EndsWith("/hidden")) .Select(x => x.Remove(x.LastIndexOf("/hidden", StringComparison.Ordinal))); var hiddenSensors = new HashSet <string>(hidden); return(new MetricConfig(interval, nameLookup, gconfig, iconfig, pconfig, timescale, aliases, hiddenSensors)); }
public static MetricConfig ParseAppSettings(IAppConfig config) { if (!int.TryParse(config["interval"], out int seconds)) { seconds = 5; } var interval = TimeSpan.FromSeconds(seconds); var lookup = config["name_lookup"] ?? "netbios"; INameResolution nameLookup; switch (lookup.ToLowerInvariant()) { case "dns": nameLookup = new DnsResolution(); break; default: nameLookup = new NetBiosResolution(); break; } var type = config["type"] ?? "graphite"; GraphiteConfig gconfig = null; InfluxConfig iconfig = null; PrometheusConfig pconfig = null; TimescaleConfig timescale = null; switch (type.ToLowerInvariant()) { case "graphite": gconfig = GraphiteConfig.ParseAppSettings(config); break; case "influxdb": case "influx": iconfig = InfluxConfig.ParseAppSettings(config); break; case "prometheus": pconfig = PrometheusConfig.ParseAppSettings(config); break; case "timescale": case "timescaledb": timescale = TimescaleConfig.ParseAppSettings(config); break; } return(new MetricConfig(interval, nameLookup, gconfig, iconfig, pconfig, timescale)); }
public MetricConfig(TimeSpan interval, INameResolution nameLookup, GraphiteConfig graphite, InfluxConfig influx, PrometheusConfig prometheus, TimescaleConfig timescale, Dictionary <string, string> aliases, List <Regex> hiddenSensors, Influx2Config influx2) { _nameLookup = nameLookup; Interval = interval; Graphite = graphite; Influx = influx; Prometheus = prometheus; Timescale = timescale; Aliases = aliases; HiddenSensors = hiddenSensors; Influx2 = influx2; }
public static MetricConfig ParseAppSettings(IAppConfig config) { if (!int.TryParse(config["interval"], out int seconds)) { seconds = 5; } var interval = TimeSpan.FromSeconds(seconds); INameResolution nameLookup = NameLookup(config["name_lookup"] ?? "netbios"); InstallCertificateVerification(config["certificate_verification"] ?? "True"); var type = config["type"] ?? "graphite"; GraphiteConfig gconfig = null; InfluxConfig iconfig = null; PrometheusConfig pconfig = null; TimescaleConfig timescale = null; Influx2Config influx2 = null; switch (type.ToLowerInvariant()) { case "graphite": gconfig = GraphiteConfig.ParseAppSettings(config); break; case "influxdb": case "influx": iconfig = InfluxConfig.ParseAppSettings(config); break; case "influx2": influx2 = Influx2Config.ParseAppSettings(config); break; case "prometheus": pconfig = PrometheusConfig.ParseAppSettings(config); break; case "timescale": case "timescaledb": timescale = TimescaleConfig.ParseAppSettings(config); break; } // Trim off the LibreHardwareMonitor "/name" suffix so that it is just the // the sensor ID. var aliases = config.GetKeys().Where(x => x.EndsWith("/name")) .ToDictionary( x => x.Remove(x.LastIndexOf("/name", StringComparison.Ordinal)), x => config[x] ); // Do a similar trim with "/hidden" suffix except treat the prefix as a glob to hide // a group of sensors like if one wants to hide all power sensors they can do: // /*/power/*/hidden // Code to detect interpret strings as globs is shamelessly taken from stackoverflow: // https://stackoverflow.com/a/4146349/433785 var hiddenSensors = config.GetKeys().Where(x => x.EndsWith("/hidden")) .Select(x => x.Remove(x.LastIndexOf("/hidden", StringComparison.Ordinal))) .Select(pattern => new Regex( "^" + Regex.Escape(pattern).Replace(@"\*", ".*").Replace(@"\?", ".") + "$", RegexOptions.IgnoreCase | RegexOptions.Singleline )).ToList(); return(new MetricConfig(interval, nameLookup, gconfig, iconfig, pconfig, timescale, aliases, hiddenSensors, influx2)); }
public InfluxWriter(InfluxConfig config, string localHost) { _config = config; _localHost = localHost; }
public MetricConfig(TimeSpan interval, GraphiteConfig graphite, InfluxConfig influx) { Interval = interval; Graphite = graphite; Influx = influx; }