I'm trying to get cpu, ram and network usage (like bytes sent per second or total bytes/s) of certain services.
I can get cpu counter like this:
PerformanceCounterCategory processCategory = PerformanceCounterCategory.GetCategories().FirstOrDefault(x => x.CategoryName == "Process");
var counter = processCategory.GetCounters(serviceName).FirstOrDefault(x => x.CounterName == "% Processor Time");
From this counter i can get the cpu usage. I can do the same thing for memory.
How to do the same for the network? If i can't do it in similar way, how should I do it instead?