Documentation
¶
Overview ¶
Package vminfo provides host runtime inspection helpers for the vminfo CLI and for external Go programs that need lightweight system snapshots.
Index ¶
- Constants
- Variables
- func CollectAll(ctx context.Context, opts Options) (StaticInfo, RuntimeStats, error)
- func TerminateProcess(ctx context.Context, pid int32) error
- type AppMetadata
- type DiskIOStats
- type InterfaceIO
- type Options
- type ProcessInfo
- type RuntimeStats
- type Snapshot
- type StaticInfo
- type TempReading
Constants ¶
const ( AppName = "vminfo" DefaultDescription = "Host runtime information toolkit" DefaultRepositoryURL = "https://github.com/cloudapp3/vminfo" DefaultHomepageURL = DefaultRepositoryURL DefaultSchemaVersion = "v1" )
const DefaultSampleInterval = time.Second
DefaultSampleInterval is the fallback sampling interval used by runtime collection helpers when Options.SampleInterval is not set.
Variables ¶
var ( // Version is the application version injected at build time. Version = "dev" // Commit is the source revision injected at build time. Commit = "none" // BuildTime is the build timestamp injected at build time. BuildTime = "unknown" // Channel is the release channel injected at build time. Channel = "dev" Repository = DefaultRepositoryURL Homepage = DefaultHomepageURL License = "MIT" Description = DefaultDescription )
Functions ¶
func CollectAll ¶
func CollectAll(ctx context.Context, opts Options) (StaticInfo, RuntimeStats, error)
CollectAll returns both static host details and sampled runtime metrics. Uses cached static data; reads only dynamic data (mem/swap) fresh each call.
Types ¶
type AppMetadata ¶
type AppMetadata struct {
Name string `json:"name"`
Version string `json:"version"`
Commit string `json:"commit,omitempty"`
BuildTime string `json:"build_time,omitempty"`
Channel string `json:"channel,omitempty"`
Repository string `json:"repository,omitempty"`
Homepage string `json:"homepage,omitempty"`
License string `json:"license,omitempty"`
Description string `json:"description,omitempty"`
SchemaVersion string `json:"schema_version,omitempty"`
}
AppMetadata describes build and repository metadata for the vminfo CLI.
func Metadata ¶
func Metadata() AppMetadata
Metadata returns normalized application metadata for CLI and embedding use.
type DiskIOStats ¶
type DiskIOStats struct {
Name string `json:"name"`
ReadBytes uint64 `json:"read_bytes"`
WriteBytes uint64 `json:"write_bytes"`
ReadSpeed uint64 `json:"read_speed,omitempty"`
WriteSpeed uint64 `json:"write_speed,omitempty"`
ReadCount uint64 `json:"read_count,omitempty"`
WriteCount uint64 `json:"write_count,omitempty"`
IOPS uint64 `json:"iops,omitempty"`
}
DiskIOStats holds per-device disk I/O statistics.
type InterfaceIO ¶
type InterfaceIO struct {
Name string `json:"name"`
RxSpeed uint64 `json:"rx_speed,omitempty"`
TxSpeed uint64 `json:"tx_speed,omitempty"`
IPv4 string `json:"ipv4,omitempty"`
RxBytes uint64 `json:"rx_bytes,omitempty"`
TxBytes uint64 `json:"tx_bytes,omitempty"`
RxErrors uint64 `json:"rx_errors,omitempty"`
TxErrors uint64 `json:"tx_errors,omitempty"`
RxDrops uint64 `json:"rx_drops,omitempty"`
TxDrops uint64 `json:"tx_drops,omitempty"`
}
InterfaceIO holds per-interface network I/O stats.
type ProcessInfo ¶
type ProcessInfo struct {
PID int32 `json:"pid"`
PPID int32 `json:"ppid,omitempty"`
Name string `json:"name,omitempty"`
User string `json:"user,omitempty"`
State string `json:"state,omitempty"`
CPUPercent float64 `json:"cpu_percent,omitempty"`
MemoryPercent float32 `json:"memory_percent,omitempty"`
RSSBytes uint64 `json:"rss_bytes,omitempty"`
Threads int32 `json:"threads,omitempty"`
Nice int32 `json:"nice,omitempty"`
Uptime uint64 `json:"uptime,omitempty"`
}
ProcessInfo describes one local process entry returned by ListProcesses.
func ListProcesses ¶
func ListProcesses(ctx context.Context) ([]ProcessInfo, error)
ListProcesses returns local processes on Linux and an unsupported error on other platforms.
type RuntimeStats ¶
type RuntimeStats struct {
CPU float64 `json:"cpu"`
CPUPerCore []float64 `json:"cpu_per_core,omitempty"`
CPUCount int `json:"cpu_count,omitempty"`
CPUFreqMHz float64 `json:"cpu_freq_mhz,omitempty"`
MemUsed uint64 `json:"mem_used,omitempty"`
SwapUsed uint64 `json:"swap_used,omitempty"`
DiskUsed uint64 `json:"disk_used,omitempty"`
NetIn uint64 `json:"net_in,omitempty"`
NetOut uint64 `json:"net_out,omitempty"`
NetInSpeed uint64 `json:"net_in_speed,omitempty"`
NetOutSpeed uint64 `json:"net_out_speed,omitempty"`
Load1 float64 `json:"load1,omitempty"`
Load5 float64 `json:"load5,omitempty"`
Load15 float64 `json:"load15,omitempty"`
TCPCount uint32 `json:"tcp_count,omitempty"`
UDPCount uint32 `json:"udp_count,omitempty"`
ProcessCount uint32 `json:"process_count,omitempty"`
Uptime uint64 `json:"uptime,omitempty"`
DiskIO []DiskIOStats `json:"disk_io,omitempty"`
Temps []TempReading `json:"temps,omitempty"`
Interfaces []InterfaceIO `json:"interfaces,omitempty"`
}
RuntimeStats contains sampled runtime metrics for the local host.
func CollectStats ¶
func CollectStats(ctx context.Context, opts Options) (RuntimeStats, error)
CollectStats samples runtime metrics using the provided options. Uses cached static data; reads only dynamic data (mem/swap) fresh each call.
type Snapshot ¶
type Snapshot struct {
Static StaticInfo `json:"static"`
Stats RuntimeStats `json:"stats"`
}
Snapshot combines static host metadata with sampled runtime metrics.
type StaticInfo ¶
type StaticInfo struct {
OS string `json:"os"`
Platform string `json:"platform,omitempty"`
OSVersion string `json:"os_version,omitempty"`
Kernel string `json:"kernel,omitempty"`
Arch string `json:"arch,omitempty"`
Hostname string `json:"hostname,omitempty"`
CPUModel string `json:"cpu_model,omitempty"`
CPUCores uint32 `json:"cpu_cores,omitempty"`
MemTotal uint64 `json:"mem_total,omitempty"`
SwapTotal uint64 `json:"swap_total,omitempty"`
DiskTotal uint64 `json:"disk_total,omitempty"`
Virtualization string `json:"virtualization,omitempty"`
}
StaticInfo contains host properties that change rarely across samples.
func CollectStatic ¶
func CollectStatic(ctx context.Context) (StaticInfo, error)
CollectStatic reads one set of static host details.




