Documentation
¶
Index ¶
- Variables
- type CPUTimer
- type CPUTimes
- type Capabilities
- type CapabilityInfo
- type Environment
- type GoInfo
- type Host
- type HostInfo
- type HostMemoryInfo
- type LoadAverage
- type LoadAverageInfo
- type MemoryInfo
- type OSInfo
- type OpenHandleCounter
- type OpenHandleEnumerator
- type Process
- type ProcessInfo
- type Seccomp
- type SeccompInfo
- type UserInfo
- type VMStat
- type VMStatInfo
Constants ¶
This section is empty.
Variables ¶
var ErrNotImplemented = errors.New("unimplemented")
ErrNotImplemented represents an error for a function that is not implemented on a particular platform.
Functions ¶
This section is empty.
Types ¶
type CPUTimer ¶
type CPUTimer interface { // CPUTime returns a CPUTimes structure for // the host or some process. // // The User and System fields are guaranteed // to be populated for all platforms, and // for both hosts and processes. CPUTime() (CPUTimes, error) }
CPUTimer is the interface that wraps the CPUTime method. CPUTime returns CPU time info
type CPUTimes ¶
type CPUTimes struct { User time.Duration `json:"user"` System time.Duration `json:"system"` Idle time.Duration `json:"idle,omitempty"` IOWait time.Duration `json:"iowait,omitempty"` IRQ time.Duration `json:"irq,omitempty"` Nice time.Duration `json:"nice,omitempty"` SoftIRQ time.Duration `json:"soft_irq,omitempty"` Steal time.Duration `json:"steal,omitempty"` }
CPUTimes contains CPU timing stats for a process
type Capabilities ¶
type Capabilities interface {
Capabilities() (*CapabilityInfo, error)
}
Capabilities is the interface that wraps the Capabilities method. Capabilities returns capabilities for a process
type CapabilityInfo ¶
type CapabilityInfo struct { Inheritable []string `json:"inheritable"` Permitted []string `json:"permitted"` Effective []string `json:"effective"` Bounding []string `json:"bounding"` Ambient []string `json:"ambient"` }
CapabilityInfo contains capability set info.
type Environment ¶
Environment is the interface that wraps the Environment method. Environment returns variables for a process
type GoInfo ¶
type GoInfo struct { OS string `json:"os"` Arch string `json:"arch"` MaxProcs int `json:"max_procs"` Version string `json:"version"` }
GoInfo contains info about the go runtime
type Host ¶
type Host interface { CPUTimer Info() HostInfo Memory() (*HostMemoryInfo, error) }
Host is the interface that wraps methods for returning Host stats
type HostInfo ¶
type HostInfo struct { Architecture string `json:"architecture"` // Hardware architecture (e.g. x86_64, arm, ppc, mips). BootTime time.Time `json:"boot_time"` // Host boot time. Containerized *bool `json:"containerized,omitempty"` // Is the process containerized. Hostname string `json:"name"` // Hostname IPs []string `json:"ip,omitempty"` // List of all IPs. KernelVersion string `json:"kernel_version"` // Kernel version. MACs []string `json:"mac"` // List of MAC addresses. OS *OSInfo `json:"os"` // OS information. Timezone string `json:"timezone"` // System timezone. TimezoneOffsetSec int `json:"timezone_offset_sec"` // Timezone offset (seconds from UTC). UniqueID string `json:"id,omitempty"` // Unique ID of the host (optional). }
HostInfo contains basic host information.
type HostMemoryInfo ¶
type HostMemoryInfo struct { Total uint64 `json:"total_bytes"` // Total physical memory. Used uint64 `json:"used_bytes"` // Total - Free Available uint64 `json:"available_bytes"` // Amount of memory available without swapping. Free uint64 `json:"free_bytes"` // Amount of memory not used by the system. VirtualTotal uint64 `json:"virtual_total_bytes"` // Total virtual memory. VirtualUsed uint64 `json:"virtual_used_bytes"` // VirtualTotal - VirtualFree VirtualFree uint64 `json:"virtual_free_bytes"` // Virtual memory that is not used. Metrics map[string]uint64 `json:"raw,omitempty"` // Other memory related metrics. }
HostMemoryInfo (all values are specified in bytes).
type LoadAverage ¶
type LoadAverage interface {
LoadAverage() LoadAverageInfo
}
LoadAverage is the interface that wraps the LoadAverage method. LoadAverage returns load info on the host
type LoadAverageInfo ¶
type LoadAverageInfo struct { One float64 `json:"one_min"` Five float64 `json:"five_min"` Fifteen float64 `json:"fifteen_min"` }
LoadAverageInfo contains load statistics
type MemoryInfo ¶
type MemoryInfo struct { Resident uint64 `json:"resident_bytes"` Virtual uint64 `json:"virtual_bytes"` Metrics map[string]uint64 `json:"raw,omitempty"` // Other memory related metrics. }
MemoryInfo contains memory stats for a process
type OSInfo ¶
type OSInfo struct { Family string `json:"family"` // OS Family (e.g. redhat, debian, freebsd, windows). Platform string `json:"platform"` // OS platform (e.g. centos, ubuntu, windows). Name string `json:"name"` // OS Name (e.g. Mac OS X, CentOS). Version string `json:"version"` // OS version (e.g. 10.12.6). Major int `json:"major"` // Major release version. Minor int `json:"minor"` // Minor release version. Patch int `json:"patch"` // Patch release version. Build string `json:"build,omitempty"` // Build (e.g. 16G1114). Codename string `json:"codename,omitempty"` // OS codename (e.g. jessie). }
OSInfo contains basic OS information
type OpenHandleCounter ¶
OpenHandleCounter is the interface that wraps the OpenHandleCount method. OpenHandleCount returns the number of open file handles.
type OpenHandleEnumerator ¶
OpenHandleEnumerator is the interface that wraps the OpenHandles method. OpenHandles lists the open file handles.
type Process ¶
type Process interface { CPUTimer Info() (ProcessInfo, error) Memory() (MemoryInfo, error) User() (UserInfo, error) Parent() (Process, error) PID() int }
Process is the main wrapper for gathering information on a process
type ProcessInfo ¶
type ProcessInfo struct { Name string `json:"name"` PID int `json:"pid"` PPID int `json:"ppid"` CWD string `json:"cwd"` Exe string `json:"exe"` Args []string `json:"args"` StartTime time.Time `json:"start_time"` }
ProcessInfo contains basic stats about a process
type Seccomp ¶
type Seccomp interface {
Seccomp() (*SeccompInfo, error)
}
Seccomp is the interface that wraps the Seccomp method. Seccomp returns seccomp info on Linux
type SeccompInfo ¶
type SeccompInfo struct { Mode string `json:"mode"` NoNewPrivs *bool `json:"no_new_privs,omitempty"` // Added in kernel 4.10. }
SeccompInfo contains seccomp info for a process
type UserInfo ¶
type UserInfo struct { // UID is the user ID. // On Linux and Darwin (macOS) this is the real user ID. // On Windows, this is the security identifier (SID) of the // user account of the process access token. UID string `json:"uid"` // On Linux and Darwin (macOS) this is the effective user ID. // On Windows, this is empty. EUID string `json:"euid"` // On Linux and Darwin (macOS) this is the saved user ID. // On Windows, this is empty. SUID string `json:"suid"` // GID is the primary group ID. // On Linux and Darwin (macOS) this is the real group ID. // On Windows, this is the security identifier (SID) of the // primary group of the process access token. GID string `json:"gid"` // On Linux and Darwin (macOS) this is the effective group ID. // On Windows, this is empty. EGID string `json:"egid"` // On Linux and Darwin (macOS) this is the saved group ID. // On Windows, this is empty. SGID string `json:"sgid"` }
UserInfo contains information about the UID and GID values of a process.
type VMStat ¶ added in v1.1.0
type VMStat interface {
VMStat() (*VMStatInfo, error)
}
VMStat is the interface wrapper for platforms that support /proc/vmstat.
type VMStatInfo ¶ added in v1.1.0
type VMStatInfo struct { NrFreePages uint64 `json:"nr_free_pages"` // (since Linux 2.6.31) NrAllocBatch uint64 `json:"nr_alloc_batch"` // (since Linux 3.12) NrInactiveAnon uint64 `json:"nr_inactive_anon"` // (since Linux 2.6.28) NrActiveAnon uint64 `json:"nr_active_anon"` // (since Linux 2.6.28) NrInactiveFile uint64 `json:"nr_inactive_file"` // (since Linux 2.6.28) NrActiveFile uint64 `json:"nr_active_file"` // (since Linux 2.6.28) NrUnevictable uint64 `json:"nr_unevictable"` // (since Linux 2.6.28) NrMlock uint64 `json:"nr_mlock"` // (since Linux 2.6.28) NrAnonPages uint64 `json:"nr_anon_pages"` // (since Linux 2.6.18) NrMapped uint64 `json:"nr_mapped"` // (since Linux 2.6.0) NrFilePages uint64 `json:"nr_file_pages"` // (since Linux 2.6.18) NrDirty uint64 `json:"nr_dirty"` // (since Linux 2.6.0) NrWriteback uint64 `json:"nr_writeback"` // (since Linux 2.6.0) NrSlabReclaimable uint64 `json:"nr_slab_reclaimable"` // (since Linux 2.6.19) NrSlabUnreclaimable uint64 `json:"nr_slab_unreclaimable"` // (since Linux 2.6.19) NrPageTablePages uint64 `json:"nr_page_table_pages"` // (since Linux 2.6.0) NrKernelStack uint64 `json:"nr_kernel_stack"` // (since Linux 2.6.32) Amount of memory allocated to kernel stacks. NrUnstable uint64 `json:"nr_unstable"` // (since Linux 2.6.0) NrBounce uint64 `json:"nr_bounce"` // (since Linux 2.6.12) NrVmscanWrite uint64 `json:"nr_vmscan_write"` // (since Linux 2.6.19) NrVmscanImmediateReclaim uint64 `json:"nr_vmscan_immediate_reclaim"` // (since Linux 3.2) NrWritebackTemp uint64 `json:"nr_writeback_temp"` // (since Linux 2.6.26) NrIsolatedAnon uint64 `json:"nr_isolated_anon"` // (since Linux 2.6.32) NrIsolatedFile uint64 `json:"nr_isolated_file"` // (since Linux 2.6.32) NrShmem uint64 `json:"nr_shmem"` // (since Linux 2.6.32) Pages used by shmem and tmpfs(5). NrDirtied uint64 `json:"nr_dirtied"` // (since Linux 2.6.37) NrWritten uint64 `json:"nr_written"` // (since Linux 2.6.37) NrPagesScanned uint64 `json:"nr_pages_scanned"` // (since Linux 3.17) NumaHit uint64 `json:"numa_hit"` // (since Linux 2.6.18) NumaMiss uint64 `json:"numa_miss"` // (since Linux 2.6.18) NumaForeign uint64 `json:"numa_foreign"` // (since Linux 2.6.18) NumaInterleave uint64 `json:"numa_interleave"` // (since Linux 2.6.18) NumaLocal uint64 `json:"numa_local"` // (since Linux 2.6.18) NumaOther uint64 `json:"numa_other"` // (since Linux 2.6.18) WorkingsetRefault uint64 `json:"workingset_refault"` // (since Linux 3.15) WorkingsetActivate uint64 `json:"workingset_activate"` // (since Linux 3.15) WorkingsetNodereclaim uint64 `json:"workingset_nodereclaim"` // (since Linux 3.15) NrAnonTransparentHugepages uint64 `json:"nr_anon_transparent_hugepages"` // (since Linux 2.6.38) NrFreeCma uint64 `json:"nr_free_cma"` // (since Linux 3.7) Number of free CMA (Contiguous Memory Allocator) pages. NrDirtyThreshold uint64 `json:"nr_dirty_threshold"` // (since Linux 2.6.37) NrDirtyBackgroundThreshold uint64 `json:"nr_dirty_background_threshold"` // (since Linux 2.6.37) Pgpgin uint64 `json:"pgpgin"` // (since Linux 2.6.0) Pgpgout uint64 `json:"pgpgout"` // (since Linux 2.6.0) Pswpin uint64 `json:"pswpin"` // (since Linux 2.6.0) Pswpout uint64 `json:"pswpout"` // (since Linux 2.6.0) PgallocDma uint64 `json:"pgalloc_dma"` // (since Linux 2.6.5) PgallocDma32 uint64 `json:"pgalloc_dma32"` // (since Linux 2.6.16) PgallocNormal uint64 `json:"pgalloc_normal"` // (since Linux 2.6.5) PgallocHigh uint64 `json:"pgalloc_high"` // (since Linux 2.6.5) PgallocMovable uint64 `json:"pgalloc_movable"` // (since Linux 2.6.23) Pgfree uint64 `json:"pgfree"` // (since Linux 2.6.0) Pgactivate uint64 `json:"pgactivate"` // (since Linux 2.6.0) Pgdeactivate uint64 `json:"pgdeactivate"` // (since Linux 2.6.0) Pgfault uint64 `json:"pgfault"` // (since Linux 2.6.0) Pgmajfault uint64 `json:"pgmajfault"` // (since Linux 2.6.0) PgrefillDma uint64 `json:"pgrefill_dma"` // (since Linux 2.6.5) PgrefillDma32 uint64 `json:"pgrefill_dma32"` // (since Linux 2.6.16) PgrefillNormal uint64 `json:"pgrefill_normal"` // (since Linux 2.6.5) PgrefillHigh uint64 `json:"pgrefill_high"` // (since Linux 2.6.5) PgrefillMovable uint64 `json:"pgrefill_movable"` // (since Linux 2.6.23) PgstealKswapdDma uint64 `json:"pgsteal_kswapd_dma"` // (since Linux 3.4) PgstealKswapdDma32 uint64 `json:"pgsteal_kswapd_dma32"` // (since Linux 3.4) PgstealKswapdNormal uint64 `json:"pgsteal_kswapd_normal"` // (since Linux 3.4) PgstealKswapdHigh uint64 `json:"pgsteal_kswapd_high"` // (since Linux 3.4) PgstealKswapdMovable uint64 `json:"pgsteal_kswapd_movable"` // (since Linux 3.4) PgstealDirectDma uint64 `json:"pgsteal_direct_dma"` PgstealDirectDma32 uint64 `json:"pgsteal_direct_dma32"` // (since Linux 3.4) PgstealDirectNormal uint64 `json:"pgsteal_direct_normal"` // (since Linux 3.4) PgstealDirectHigh uint64 `json:"pgsteal_direct_high"` // (since Linux 3.4) PgstealDirectMovable uint64 `json:"pgsteal_direct_movable"` // (since Linux 2.6.23) PgscanKswapdDma uint64 `json:"pgscan_kswapd_dma"` PgscanKswapdDma32 uint64 `json:"pgscan_kswapd_dma32"` // (since Linux 2.6.16) PgscanKswapdNormal uint64 `json:"pgscan_kswapd_normal"` // (since Linux 2.6.5) PgscanKswapdHigh uint64 `json:"pgscan_kswapd_high"` PgscanKswapdMovable uint64 `json:"pgscan_kswapd_movable"` // (since Linux 2.6.23) PgscanDirectDma uint64 `json:"pgscan_direct_dma"` // PgscanDirectDma32 uint64 `json:"pgscan_direct_dma32"` // (since Linux 2.6.16) PgscanDirectNormal uint64 `json:"pgscan_direct_normal"` PgscanDirectHigh uint64 `json:"pgscan_direct_high"` PgscanDirectMovable uint64 `json:"pgscan_direct_movable"` // (since Linux 2.6.23) PgscanDirectThrottle uint64 `json:"pgscan_direct_throttle"` // (since Linux 3.6) ZoneReclaimFailed uint64 `json:"zone_reclaim_failed"` // (since linux 2.6.31) Pginodesteal uint64 `json:"pginodesteal"` // (since linux 2.6.0) SlabsScanned uint64 `json:"slabs_scanned"` // (since linux 2.6.5) KswapdInodesteal uint64 `json:"kswapd_inodesteal"` // (since linux 2.6.0) KswapdLowWmarkHitQuickly uint64 `json:"kswapd_low_wmark_hit_quickly"` // (since 2.6.33) KswapdHighWmarkHitQuickly uint64 `json:"kswapd_high_wmark_hit_quickly"` // (since 2.6.33) Pageoutrun uint64 `json:"pageoutrun"` // (since Linux 2.6.0) Allocstall uint64 `json:"allocstall"` // (since Linux 2.6.0) Pgrotated uint64 `json:"pgrotated"` // (since Linux 2.6.0) DropPagecache uint64 `json:"drop_pagecache"` // (since Linux 3.15) DropSlab uint64 `json:"drop_slab"` // (since Linux 3.15) NumaPteUpdates uint64 `json:"numa_pte_updates"` // (since Linux 3.8) NumaHugePteUpdates uint64 `json:"numa_huge_pte_updates"` // (since Linux 3.13) NumaHintFaults uint64 `json:"numa_hint_faults"` // (since Linux 3.8) NumaHintFaultsLocal uint64 `json:"numa_hint_faults_local"` // (since Linux 3.8) NumaPagesMigrated uint64 `json:"numa_pages_migrated"` // (since Linux 3.8) PgmigrateSuccess uint64 `json:"pgmigrate_success"` // (since Linux 3.8) PgmigrateFail uint64 `json:"pgmigrate_fail"` // (since Linux 3.8) CompactMigrateScanned uint64 `json:"compact_migrate_scanned"` // (since Linux 3.8) CompactFreeScanned uint64 `json:"compact_free_scanned"` // (since Linux 3.8) CompactIsolated uint64 `json:"compact_isolated"` // (since Linux 3.8) CompactStall uint64 `json:"compact_stall"` // (since Linux 2.6.35) See the kernel source file Documentation/admin-guide/mm/transhuge.rst. CompactFail uint64 `json:"compact_fail"` // (since Linux 2.6.35) See the kernel source file Documentation/admin-guide/mm/transhuge.rst. CompactSuccess uint64 `json:"compact_success"` // (since Linux 2.6.35) See the kernel source file Documentation/admin-guide/mm/transhuge.rst. HtlbBuddyAllocSuccess uint64 `json:"htlb_buddy_alloc_success"` // (since Linux 2.6.26) HtlbBuddyAllocFail uint64 `json:"htlb_buddy_alloc_fail"` // (since Linux 2.6.26) UnevictablePgsCulled uint64 `json:"unevictable_pgs_culled"` // (since Linux 2.6.28) UnevictablePgsScanned uint64 `json:"unevictable_pgs_scanned"` // (since Linux 2.6.28) UnevictablePgsRescued uint64 `json:"unevictable_pgs_rescued"` // (since Linux 2.6.28) UnevictablePgsMlocked uint64 `json:"unevictable_pgs_mlocked"` // (since Linux 2.6.28) UnevictablePgsMunlocked uint64 `json:"unevictable_pgs_munlocked"` // (since Linux 2.6.28) UnevictablePgsCleared uint64 `json:"unevictable_pgs_cleared"` // (since Linux 2.6.28) UnevictablePgsStranded uint64 `json:"unevictable_pgs_stranded"` // (since Linux 2.6.28) ThpFaultAlloc uint64 `json:"thp_fault_alloc"` // (since Linux 2.6.39) See the kernel source file Documentation/admin-guide/mm/transhuge.rst. ThpFaultFallback uint64 `json:"thp_fault_fallback"` // (since Linux 2.6.39) See the kernel source file Documentation/admin-guide/mm/transhuge.rst. ThpCollapseAlloc uint64 `json:"thp_collapse_alloc"` // (since Linux 2.6.39) See the kernel source file Documentation/admin-guide/mm/transhuge.rst. ThpCollapseAllocFailed uint64 `json:"thp_collapse_alloc_failed"` // (since Linux 2.6.39) See the kernel source file Documentation/admin-guide/mm/transhuge.rst. ThpSplit uint64 `json:"thp_split"` // (since Linux 2.6.39) See the kernel source file Documentation/admin-guide/mm/transhuge.rst. ThpZeroPageAlloc uint64 `json:"thp_zero_page_alloc"` // (since Linux 3.8) See the kernel source file Documentation/admin-guide/mm/transhuge.rst. ThpZeroPageAllocFailed uint64 `json:"thp_zero_page_alloc_failed"` // (since Linux 3.8) See the kernel source file Documentation/admin-guide/mm/transhuge.rst. BalloonInflate uint64 `json:"balloon_inflate"` // (since Linux 3.18) BalloonDeflate uint64 `json:"balloon_deflate"` // (since Linux 3.18) BalloonMigrate uint64 `json:"balloon_migrate"` // (since Linux 3.18) NrTlbRemoteFlush uint64 `json:"nr_tlb_remote_flush"` // (since Linux 3.12) NrTlbRemoteFlushReceived uint64 `json:"nr_tlb_remote_flush_received"` // (since Linux 3.12) NrTlbLocalFlushAll uint64 `json:"nr_tlb_local_flush_all"` // (since Linux 3.12) NrTlbLocalFlushOne uint64 `json:"nr_tlb_local_flush_one"` // (since Linux 3.12) VmacacheFindCalls uint64 `json:"vmacache_find_calls"` // (since Linux 3.16) VmacacheFindHits uint64 `json:"vmacache_find_hits"` // (since Linux 3.16) VmacacheFullFlushes uint64 `json:"vmacache_full_flushes"` // (since Linux 3.19) // the following fields are not documented in `man 5 proc` as of 4.15 NrZoneInactiveAnon uint64 `json:"nr_zone_inactive_anon"` NrZoneActiveAnon uint64 `json:"nr_zone_active_anon"` NrZoneInactiveFile uint64 `json:"nr_zone_inactive_file"` NrZoneActiveFile uint64 `json:"nr_zone_active_file"` NrZoneUnevictable uint64 `json:"nr_zone_unevictable"` NrZoneWritePending uint64 `json:"nr_zone_write_pending"` NrZspages uint64 `json:"nr_zspages"` NrShmemHugepages uint64 `json:"nr_shmem_hugepages"` NrShmemPmdmapped uint64 `json:"nr_shmem_pmdmapped"` AllocstallDma uint64 `json:"allocstall_dma"` AllocstallDma32 uint64 `json:"allocstall_dma32"` AllocstallNormal uint64 `json:"allocstall_normal"` AllocstallMovable uint64 `json:"allocstall_movable"` PgskipDma uint64 `json:"pgskip_dma"` PgskipDma32 uint64 `json:"pgskip_dma32"` PgskipNormal uint64 `json:"pgskip_normal"` PgskipMovable uint64 `json:"pgskip_movable"` Pglazyfree uint64 `json:"pglazyfree"` Pglazyfreed uint64 `json:"pglazyfreed"` Pgrefill uint64 `json:"pgrefill"` PgstealKswapd uint64 `json:"pgsteal_kswapd"` PgstealDirect uint64 `json:"pgsteal_direct"` PgscanKswapd uint64 `json:"pgscan_kswapd"` PgscanDirect uint64 `json:"pgscan_direct"` OomKill uint64 `json:"oom_kill"` CompactDaemonWake uint64 `json:"compact_daemon_wake"` CompactDaemonMigrateScanned uint64 `json:"compact_daemon_migrate_scanned"` CompactDaemonFreeScanned uint64 `json:"compact_daemon_free_scanned"` ThpFileAlloc uint64 `json:"thp_file_alloc"` ThpFileMapped uint64 `json:"thp_file_mapped"` ThpSplitPage uint64 `json:"thp_split_page"` ThpSplitPageFailed uint64 `json:"thp_split_page_failed"` ThpDeferredSplitPage uint64 `json:"thp_deferred_split_page"` ThpSplitPmd uint64 `json:"thp_split_pmd"` ThpSplitPud uint64 `json:"thp_split_pud"` ThpSwpout uint64 `json:"thp_swpout"` ThpSwpoutFallback uint64 `json:"thp_swpout_fallback"` SwapRa uint64 `json:"swap_ra"` SwapRaHit uint64 `json:"swap_ra_hit"` }
VMStatInfo contains parsed info from /proc/vmstat. This procfs file has expanded much over the years with different kernel versions. If we don't have a field in vmstat, the field in the struct will just be blank. The comments represent kernel versions.