System metrics and process inspection library.
Dependencies
moon add Milky2018/sysinfolet system = @sysinfo.System::new_all()
println("supported=\{@sysinfo.is_supported_system}")
println("total_memory=\{system.total_memory()}")
println("used_memory=\{system.used_memory()}")
println("cpu_usage=\{system.global_cpu_usage()}")
println("process_count=\{system.processes().size()}")let system = @sysinfo.System::new_all()
system.refresh_cpu_usage()
sleep(220)
system.refresh_cpu_usage()
let usage = system.global_cpu_usage()impl Show for CpuRefreshKindimpl Show for CpuSnapshotimpl Show for DiskIoSnapshotimpl Show for DiskRefreshKindfn Disks::refresh_specifics(self : Disks, remove_not_listed_disks : Bool, refreshes : DiskRefreshKind) -> Unitimpl Show for ExitStatusimpl Show for MacosDiskInfoimpl Show for MemoryRefreshKindimpl Show for MountEntrypub(all) struct NetworkData {
received : UInt64
total_received : UInt64
transmitted : UInt64
total_transmitted : UInt64
packets_received : UInt64
total_packets_received : UInt64
packets_transmitted : UInt64
total_packets_transmitted : UInt64
errors_on_received : UInt64
total_errors_on_received : UInt64
errors_on_transmitted : UInt64
total_errors_on_transmitted : UInt64
mac_address : MacAddr
ip_networks : Array[IpNetwork]
mtu : UInt64
} derive(Eq, Debug)impl Show for NetworkDatapub(all) struct Process {
pid : Pid
parent : Pid?
name : String
cmd : Array[String]
environ : Array[String]
exe : String?
cwd : String?
root : String?
memory : UInt64
virtual_memory : UInt64
status : ProcessStatus
start_time : UInt64
run_time : UInt64
cpu_usage : Double
accumulated_cpu_time : UInt64
disk_usage : DiskUsage
user_id : Uid?
effective_user_id : Uid?
group_id : Gid?
effective_group_id : Gid?
session_id : Pid?
tasks : Array[Pid]?
thread_kind : ThreadKind?
open_files : Int?
open_files_limit : Int?
} derive(Eq, Debug)pub(all) struct ProcessRefreshKind {
cpu : Bool
disk_usage : Bool
memory : Bool
user : UpdateKind
cwd : UpdateKind
root : UpdateKind
environ : UpdateKind
cmd : UpdateKind
exe : UpdateKind
tasks : Bool
} derive(Eq, Debug)impl Show for ProcessRefreshKindfn ProcessRefreshKind::with_environ(self : ProcessRefreshKind, kind : UpdateKind) -> ProcessRefreshKindfn ProcessRefreshKind::with_root(self : ProcessRefreshKind, kind : UpdateKind) -> ProcessRefreshKindfn ProcessRefreshKind::with_user(self : ProcessRefreshKind, kind : UpdateKind) -> ProcessRefreshKindimpl Show for ProcessesToUpdatepub(all) struct RefreshKind {
processes : ProcessRefreshKind?
memory : MemoryRefreshKind?
cpu : CpuRefreshKind?
} derive(Eq, Debug)impl Show for RefreshKindpub(all) struct System {
processes_data : Map[Pid, Process]
cpus_data : Array[Cpu]
total_memory_data : UInt64
free_memory_data : UInt64
available_memory_data : UInt64
used_memory_data : UInt64
total_swap_data : UInt64
free_swap_data : UInt64
used_swap_data : UInt64
cgroup_limits_data : CGroupLimits?
last_cpu_refresh_ms : UInt64
prev_cpu_snapshots : Array[CpuSnapshot]
prev_global_cpu_snapshot : CpuSnapshot?
prev_proc_cpu_total : Map[Pid, UInt64]
prev_proc_system_total : UInt64
}fn System::refresh_processes(self : System, processes_to_update : ProcessesToUpdate, remove_dead_processes : Bool) -> Intfn System::refresh_processes_specifics(self : System, processes_to_update : ProcessesToUpdate, remove_dead_processes : Bool, refresh_kind : ProcessRefreshKind) -> Intimpl Show for ThreadKindimpl Show for UpdateKindSystem metrics and process inspection library.
Dependencies