Functions for system status C#

2020-04-11 13:11发布

问题:

I'm looking for general system state functions for Mono. Things I need are:

  • Memory (available, total)
  • Free disk space
  • IP Number
  • External IP
  • Running processes / services / daemons

How do I get those?

Thanks in advance,

Yvan

回答1:

In the order of your list requirements, I have outlined the necessary namespaces for those functions. Since you did not supply the platform...

  • Memory (available/total) Perhaps, System.Environment class?
  • Free Disk Space (Mono.Unix.DriveInfo namespace) System.IO.DriveInfo?
  • IP number (Mono.Unix.UnixEndPoint) System.Net.EndPoint?
  • External IP address - not sure about this, this would be based on the output of ipconfig or ifconfig, or check the routing tables.
  • Running processes/services/daemons (Mono.Unix.UnixProcess) System.Diagnostics.Process class?

Hope this helps, Best regards, Tom.