Ejemplo n.º 1
0
 public TaskScheduler()
 {
     this.TaskRunStateGauge           = Metrics.CreateGauge("taskscheduler_task_current_state", "Return the current state of the task.", labelNames: new[] { "taskname", "location" });
     this.TaskLastResultGauge         = Metrics.CreateGauge("taskscheduler_task_result", "Return code from task scheduler.", labelNames: new[] { "taskname", "location" });
     this.TaskLastMissedGauge         = Metrics.CreateGauge("taskscheduler_task_missedruns", "Execution time of the task.", labelNames: new[] { "taskname", "location" });
     this.TaskLastRuntimeGauge        = Metrics.CreateGauge("taskscheduler_task_last_runtime", "Execution time of the task.", labelNames: new[] { "taskname", "location" });
     this.TaskLastSuccessRuntimeGauge = Metrics.CreateGauge("taskscheduler_task_last_success_runtime", "Last successfull execution of the task.", labelNames: new[] { "taskname", "location" });
 }
        public WindowsUpdates()
        {
            this.WindowsUpdateMissingUpdatesTotal = Metrics.CreateGauge("windows_updates_missing_total", "Number of missing Windows patches");
            this.WindowsUpdateMissingUpdatesTotal.Set(0); // maybe this is the default

            this.WindowsUpdateLastScanTime = Metrics.CreateGauge("windows_updates_last_scan_time", "Last search time, in unixtime.");
            this.WindowsUpdateLastScanTime.Set(0);

            this.WindowsUpdateScanDuration = Metrics.CreateSummary("windows_updates_last_scan_duration_milliseconds", "Last scan time, milliseconds.");
        }
Ejemplo n.º 3
0
 public override void Init()
 {
     base.Init();
     if (Config.Current.GetValue <bool>("Metrics:Server:Enabled"))
     {
         Module.Init(this);
         _InfoGauge = prom.Metrics.CreateGauge("app_info", "Application info", "netfx_version", "version");
         _InfoGauge.Labels(AppDomain.CurrentDomain.SetupInformation.TargetFrameworkName, "20.11").Set(1);
     }
 }
Ejemplo n.º 4
0
        private void UpdateMetrics(object state)
        {
            Debug.WriteLine(string.Format("NodeCollector.WindowsBasic::UpdateMetrics(): Reading perfmon counters ({0}).", DateTime.Now.ToString()));

            foreach (CounterEntry entry in this.RegisteredCounts)
            {
                long  rawValue  = entry.PerfCounter.RawValue;
                float nextValue = entry.PerfCounter.NextValue();
                //Debug.WriteLine(String.Format(@"<PerfCounter> {0}\{1}\{2}: {3}", entry.PerfCounter.CategoryName, entry.PerfCounter.CounterName, entry.PerfCounter.InstanceName, nextValue));
                Prometheus.Gauge g = (Prometheus.Gauge)entry.PrometheusCollector;
                g.Labels(entry.PerfCounter.InstanceName).Set(nextValue);
            }
        }
        public GaugeGroupQuery(string name, string description, string query, IEnumerable <Column> labelColumns, Column valueColumn, MetricFactory metricFactory, int?millisecondTimeout)
        {
            Name = name;
            this._description  = description;
            Query              = query;
            MillisecondTimeout = millisecondTimeout;
            this._valueColumn  = valueColumn;
            this._labelColumns = labelColumns.OrderBy(x => x.Order).ToArray();

            var gaugeConfiguration = new Prometheus.GaugeConfiguration
            {
                LabelNames           = this._labelColumns.Select(x => x.Label).ToArray(),
                SuppressInitialValue = true
            };

            _gauge = metricFactory.CreateGauge(name, description, gaugeConfiguration);
        }
Ejemplo n.º 6
0
        public void RegisterMetrics()
        {
            // Load search interval from properties.
            TimeSpan rumpTime       = TimeSpan.FromSeconds(NodeCollector.WindowsBasic.Properties.Settings.Default.SearchRumpTime);
            TimeSpan searchInterval = TimeSpan.FromSeconds(NodeCollector.WindowsBasic.Properties.Settings.Default.SearchInvervalSeconds);

            GVars.MyLog.WriteEntry(string.Format("Initializing WindowsBasic collector v{0} (Search interval is {1}s, Rump time is {2}s).",
                                                 this.GetVersion(), searchInterval.TotalSeconds, rumpTime.TotalSeconds), EventLogEntryType.Information, 1000);

            /*
             * CPU
             */
            string categoryName = "Processor";
            PerformanceCounterCategory perfCategory = new PerformanceCounterCategory(categoryName);

            string[] instanceNames = perfCategory.GetInstanceNames().Where(name => name != "_Total").ToArray();
            foreach (string instanceName in instanceNames)
            {
                System.Diagnostics.PerformanceCounter tmpPerfCounter = new System.Diagnostics.PerformanceCounter();
                tmpPerfCounter.CategoryName = categoryName;
                tmpPerfCounter.CounterName  = "% Processor Time";
                tmpPerfCounter.InstanceName = instanceName;
                Prometheus.Gauge tmpPrometheusCounter = Metrics.CreateGauge("perfmon_processor_processortime_percent", "help text", labelNames: new[] { "name" });
                CounterEntry     entry = new CounterEntry()
                {
                    PerfCounter = tmpPerfCounter, PrometheusCollector = tmpPrometheusCounter
                };
                this.RegisteredCounts.Add(entry);
            }

            this.RegisterPrintSpooler();
            this.RegisterPrintSpooler();

            // Initialize a timer to search all XX minutes for new updates.
            // The process is very time intersive, so please do not lower this value below one hour.
            this.MetricUpdateTimer = new System.Threading.Timer(this.UpdateMetrics,
                                                                this,
                                                                Convert.ToInt32(rumpTime.TotalMilliseconds),
                                                                Convert.ToInt32(searchInterval.TotalMilliseconds)
                                                                );
        }
Ejemplo n.º 7
0
 public Gauge(string name, string help)
 {
     _gauge = Pro.Metrics.CreateGauge(name, help);
 }
 public WindowsServices()
 {
     this.WindowsServiceGauge = Metrics.CreateGauge("windows_service_status", "Current state if Windows services.", labelNames: new[] { "name", "caption", "startmode" });
 }