Giter VIP home page Giter VIP logo

czgl.systeminfo's Introduction

whuanle's github


ebook or course:

https://istio.whuanle.cn/

Istio basics.

https://k8s.whuanle.cn/

Kubernetes basics.Very detailed tutorial for beginners.

https://maomi.whuanle.cn/

Design a development framework in C#.

https://mmq.whuanle.cn/

RabbitMQ rapid development framework tutorial.

https://kafka.whuanle.cn/

Learn Kafka through C#.

https://threads.whuanle.cn/

Very detailed C# multithreading and asynchronous tutorials.

https://reflect.whuanle.cn/

Very detailed reflection technique tutorial.

https://ex.whuanle.cn/

Very detailed expression tree tutorial.

czgl.systeminfo's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

czgl.systeminfo's Issues

请问maui是否支持

在maui上运行获取当前系统信息,比如获取IP地址. windows,android,mac运行

nuget包中,没有网络流量的获取方法或者相关方法无效

                var networks = NetworkInfo.GetRealNetworkInfos();
                for (int i = 0; i < networks.Length; i++)
                {
                    data.Add($"net_work_{i + 1}_ipv4", (networks[i].AddressIpv4.ToString()));
                    data.Add($"net_work_{i + 1}_ipv6", (networks[i].AddressIpv6.ToString()));
                    data.Add($"net_work_{i + 1}_total_up_kb", (networks[i].Ipv4Statistics.BytesSent / 1024).ToString());
                    data.Add($"net_work_{i + 1}_total_down_kb", (networks[i].Ipv4Statistics.BytesReceived / 1024).ToString());
                    InternetSpeed speed = new InternetSpeed();
                    networks[i].GetInternetSpeed(ref speed,1000);
                    data.Add($"net_work_{i + 1}_down_kb", (speed.Received.OriginSize / 1024).ToString());
                    data.Add($"net_work_{i + 1}_up_kb", (speed.Sent.OriginSize / 1024).ToString());
                }

以上代码,speed.Received.OriginSize , speed.Sent.OriginSize 皆是0,请问要怎么取?

nuget 包版本:1.0.3

使用统一接口

不再使用函数的方式一个个调用,而是使用接口注册,统一扫描。

Make it node_exporter

好棒的东西,给个建议把你这东西做成node exporter 实用性会更强,列出所有dotnet 进程,注入获取gc和线程数据,再加上现在的CPU 内存等,一块export出去,就通用了 :)

最新版本获取linux已用内存不准

  • docker运行
  • debian.11-x64下实际使用2.9G,程序获取使用6.21G
  • debian.11-arm64下实际使用0.5G,程序获取使用1.49G
  • windows 11准确
    -看来linux docker内获取的多了2倍左右。

Get Unix Memory

no unsupport Alpine Linux!

    private MemoryMetrics GetUnixMetrics()
    {
        var output = "";
 
        var info = new ProcessStartInfo("free -m");
        info.FileName = "/bin/bash";
        info.Arguments = "-c \"free -m\"";
        info.RedirectStandardOutput = true;
        
        using(var process = Process.Start(info))
        {                
            output = process.StandardOutput.ReadToEnd();
            Console.WriteLine(output);
        }
 
        var lines = output.Split("\n");
        var memory = lines[1].Split(" ", StringSplitOptions.RemoveEmptyEntries);
    
        var metrics = new MemoryMetrics();
        metrics.Total = double.Parse(memory[1]);
        metrics.Used = double.Parse(memory[2]);
        metrics.Free = double.Parse(memory[3]);
 
        return metrics;            
    }

arm32v7 内存获取不到

linux arm32v7环境下无法获取已用内存和总内存,需要的话我可以提供远程可测试的设备

Input string was not in a correct format 导致进程崩溃

nuget: <PackageReference Include="CZGL.ProcessMetrics" Version="1.0.0" />
runtime: aspnet:5.0-alpine

Error:
Unhandled exception. System.Diagnostics.Tracing.EventSourceException: An error occurred when writing to a listener.
---> System.FormatException: Input string was not in a correct format.
at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, TypeCode type)
at System.Number.ParseDecimal(ReadOnlySpan1 value, NumberStyles styles, NumberFormatInfo info) at CZGL.ProcessMetrics.Counters.EventSourceCreatedListener.GetRelevantMetric(IDictionary2 eventPayload)
at CZGL.ProcessMetrics.Counters.EventSourceCreatedListener.OnEventWritten(EventWrittenEventArgs eventData)
at System.Diagnostics.Tracing.EventSource.DispatchToAllListeners(Int32 eventId, EventWrittenEventArgs eventCallbackArgs)
--- End of inner exception stack trace ---

出现得很频繁,基本启动10分钟就挂了

目测是这里报错了

建议添加全局异常处理, 不让程序崩掉

调用接口/metrics会很大概率出现假死状态

1.问题1:_process.Refresh(); //这里会出现阻塞

2.问题2:
` public static async Task BuildMetric(ProcessMetricsCore processMetricsCore)
{
if (ListenerPayload == null)
{
await Task.CompletedTask;
return;
}

        try
        {
            _lock.EnterWriteLock(); //<span style="color:red;font-weight:bold">**这里会出现锁异常**</span>
            await Task.Factory.StartNew(() =>
            {
                for (int i = 0; i < ListenerPayload.Count; ++i)
                {
                    if (ListenerPayload[i] is IDictionary<string, object> eventPayload)
                    {
                        GetRelevantMetric(eventPayload, processMetricsCore);
                    }
                }
            });
        }
        catch (Exception ex) { }`

空引用异常

rumtime: aspnet:5.0-alpine
nuget: CZGL.ProcessMetrics.ASPNETCore 1.0.0

进程监控空引用异常, 这里的Process为空

.SetValue(processInfo.Process.HandleCount);

[11:06:20 EROR] An unhandled exception has occurred while executing the request.
System.AggregateException: One or more errors occurred. (Object reference not set to an instance of an object.)
---> System.NullReferenceException: Object reference not set to an instance of an object.
at System.Diagnostics.Process.get_HandleCount()
at CZGL.ProcessMetrics.ProcessMetricsCore.b__15_0()
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
at CZGL.ProcessMetrics.ProcessMetricsCore.ProcessThreadsRecord()
at CZGL.ProcessMetrics.ProcessMetricsCore.GetPrometheus()
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at CZGL.ProcessMetrics.Extensions.<>c.<b__0_0>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

这个是偶发现象,不容易复现
网卡监控构造函数懒加载空引用异常

_Statistics = new Lazy<IPInterfaceStatistics>(() => _instance.GetIPStatistics());

System.AggregateException: One or more errors occurred. (Object reference not set to an instance of an object.)
---> System.NullReferenceException: Object reference not set to an instance of an object.
at CZGL.SystemInfo.NetworkInfo.<.ctor>b__3_3()
at System.Lazy1.ViaFactory(LazyThreadSafetyMode mode) at System.Lazy1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1.CreateValue()
at CZGL.ProcessMetrics.ProcessMetricsCore.b__12_0()
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.<>c.<.cctor>b__277_0(Object obj)
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---

新版本规划

系统信息:

  • CPU
  • 内存
  • 网络
  • 磁盘
  • 进程信息

metrics 支持

  • prometheus 支持
  • 自制面板支持

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.