S
salimi.NET
Guest
using System;
using InfluxDB.Collector;
using InfluxDB.LineProtocol;
using System.Diagnostics;
using System.ComponentModel;
using System.Threading.Tasks;
using System.Collections.Generic;
namespace <g class="gr_ gr_20 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="20" id="20">influxtest</g>
{
class Program
{
static void Main(string[] args)
{
Collect().Wait();
}
async Task Collect()
{
var process = Process.GetCurrentProcess();
Metrics.Collector = new CollectorConfiguration()
.Tag.With("host", Environment.GetEnvironmentVariable("COMPUTERNAME"))
.Tag.With("os", Environment.GetEnvironmentVariable("OS"))
.Tag.With("process", System.IO.Path.GetFileName(process.MainModule.FileName))
.Batch.AtInterval(TimeSpan.FromSeconds(2))
.WriteTo.InfluxDB("http://192.168.99.100:8086", "data")
.CreateCollector();
while (true)
{
Metrics.Increment("iterations");
Metrics.Write("cpu_time",
new Dictionary<string, object>
{
{ "value", process.TotalProcessorTime.TotalMilliseconds },
{ "user", process.UserProcessorTime.TotalMilliseconds }
});
Metrics.Measure("working_set", process.WorkingSet64);
await Task.Delay(1000);
}
}
}
}
Hello, I am new to c sharp I have an error in the Collect() method, the debugger display: An object reference is required for the non-static field, method, or property. where I made the mistake how I can resolve this error.
thank you in advance.
Continue reading...
using InfluxDB.Collector;
using InfluxDB.LineProtocol;
using System.Diagnostics;
using System.ComponentModel;
using System.Threading.Tasks;
using System.Collections.Generic;
namespace <g class="gr_ gr_20 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="20" id="20">influxtest</g>
{
class Program
{
static void Main(string[] args)
{
Collect().Wait();
}
async Task Collect()
{
var process = Process.GetCurrentProcess();
Metrics.Collector = new CollectorConfiguration()
.Tag.With("host", Environment.GetEnvironmentVariable("COMPUTERNAME"))
.Tag.With("os", Environment.GetEnvironmentVariable("OS"))
.Tag.With("process", System.IO.Path.GetFileName(process.MainModule.FileName))
.Batch.AtInterval(TimeSpan.FromSeconds(2))
.WriteTo.InfluxDB("http://192.168.99.100:8086", "data")
.CreateCollector();
while (true)
{
Metrics.Increment("iterations");
Metrics.Write("cpu_time",
new Dictionary<string, object>
{
{ "value", process.TotalProcessorTime.TotalMilliseconds },
{ "user", process.UserProcessorTime.TotalMilliseconds }
});
Metrics.Measure("working_set", process.WorkingSet64);
await Task.Delay(1000);
}
}
}
}
Hello, I am new to c sharp I have an error in the Collect() method, the debugger display: An object reference is required for the non-static field, method, or property. where I made the mistake how I can resolve this error.
thank you in advance.
Continue reading...