hostmetrics

package
v0.3.11-8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2024 License: Apache-2.0 Imports: 19 Imported by: 1

Documentation

Index

Constants

View Source
const (
	TelegrafServer = "http://127.0.0.1:8087/write"
)

Variables

This section is empty.

Functions

func Init

func Init()

func Start

func Start()

func Stop

func Stop()

Types

type CpuMetric

type CpuMetric struct {
	UsageActive       float64 `json:"usage_active"`
	CpuUsageIdlePcore float64 `json:"cpu_usage_idle_pcore"`
	CpuUsagePcore     float64 `json:"cpu_usage_pcore"`
	CpuTimeUser       float64 `json:"cpu_time_user"`
	CpuTimeSystem     float64 `json:"cpu_time_system"`
	CpuCount          int     `json:"cpu_count"`
	ThreadCount       int32   `json:"thread_count"`
}

func (*CpuMetric) ToMap

func (c *CpuMetric) ToMap() map[string]interface{}

type DiskIOMeta

type DiskIOMeta struct {
	Uptime uint64 `json:"uptime"`
}

type DiskIOMetric

type DiskIOMetric struct {
	Meta DiskIOMeta `json:"-"`

	ReadBytes  uint64 `json:"read_bytes"`
	WriteBytes uint64 `json:"write_bytes"`
	ReadCount  uint64 `json:"read_count"`
	WriteCount uint64 `json:"write_count"`

	// calculated on guest metrics report
	ReadBps   float64 `json:"read_Bps"`
	WriteBps  float64 `json:"write_Bps"`
	ReadBPS   float64 `json:"read_bps"`
	WriteBPS  float64 `json:"write_bps"`
	ReadIOPS  float64 `json:"read_iops"`
	WriteIOPS float64 `json:"write_iops"`
}

func (*DiskIOMetric) ToMap

func (d *DiskIOMetric) ToMap() map[string]interface{}

type GuestMetrics

type GuestMetrics struct {
	VmCpu    *CpuMetric     `json:"vm_cpu"`
	VmMem    *MemMetric     `json:"vm_mem"`
	VmNetio  []*NetIOMetric `json:"vm_netio"`
	VmDiskio *DiskIOMetric  `json:"vm_diskio"`
}

type MemMetric

type MemMetric struct {
	RSS         uint64  `json:"rss"`
	VMS         uint64  `json:"vms"`
	UsedPercent float32 `json:"used_percent"`
}

func (*MemMetric) ToMap

func (m *MemMetric) ToMap() map[string]interface{}

type NetIOMetric

type NetIOMetric struct {
	Meta NetMeta `json:"-"`

	BytesSent   uint64 `json:"bytes_sent"`
	BytesRecv   uint64 `json:"bytes_recv"`
	PacketsSent uint64 `json:"packets_sent"`
	PacketsRecv uint64 `json:"packets_recv"`
	ErrIn       uint64 `json:"err_in"`
	ErrOut      uint64 `json:"err_out"`
	DropIn      uint64 `json:"drop_in"`
	DropOut     uint64 `json:"drop_out"`

	// calculated on guest metrics report
	BPSRecv float64 `json:"bps_recv"`
	BPSSent float64 `json:"bps_sent"`
	PPSRecv float64 `json:"pps_recv"`
	PPSSent float64 `json:"pps_sent"`

	TimeDiff float64 `json:"-"`
}

func (*NetIOMetric) ToMap

func (n *NetIOMetric) ToMap() map[string]interface{}

func (*NetIOMetric) ToTag

func (n *NetIOMetric) ToTag() map[string]string

type NetMeta

type NetMeta struct {
	IpType string `json:"ip_type"`
	Ip     string `json:"ip"`
	Mac    string `json:"mac"`
	Index  int    `json:"index"`
	Ifname string `json:"ifname"`
	NetId  string `json:"net_id"`
	Uptime uint64 `json:"uptime"`
}

type SGuestMonitor

type SGuestMonitor struct {
	Name           string
	Id             string
	Pid            int
	Nics           []*desc.SGuestNetwork
	CpuCnt         int
	Ip             string
	Process        *process.Process
	ScalingGroupId string
	Tenant         string
	TenantId       string
	DomainId       string
	ProjectDomain  string
}

func NewGuestMonitor

func NewGuestMonitor(name, id string, pid int, nics []*desc.SGuestNetwork, cpuCount int,
) (*SGuestMonitor, error)

func (*SGuestMonitor) Cpu

func (m *SGuestMonitor) Cpu() *CpuMetric

func (*SGuestMonitor) Diskio

func (m *SGuestMonitor) Diskio() *DiskIOMetric

func (*SGuestMonitor) GetSriovNicStats

func (m *SGuestMonitor) GetSriovNicStats(pfName string, virtfn int) (*psnet.IOCountersStat, error)

func (*SGuestMonitor) Mem

func (m *SGuestMonitor) Mem() *MemMetric

func (*SGuestMonitor) Netio

func (m *SGuestMonitor) Netio() []*NetIOMetric

func (*SGuestMonitor) SetNicDown

func (m *SGuestMonitor) SetNicDown(index int)

func (*SGuestMonitor) UpdateCpuCount

func (m *SGuestMonitor) UpdateCpuCount(vcpuCount int)

func (*SGuestMonitor) UpdateNicsDesc

func (m *SGuestMonitor) UpdateNicsDesc(nics []*desc.SGuestNetwork)

func (*SGuestMonitor) UpdateVmName

func (m *SGuestMonitor) UpdateVmName(name string)

type SGuestMonitorCollector

type SGuestMonitorCollector struct {
	// contains filtered or unexported fields
}

func NewGuestMonitorCollector

func NewGuestMonitorCollector() *SGuestMonitorCollector

func (*SGuestMonitorCollector) CollectReportData

func (s *SGuestMonitorCollector) CollectReportData() (ret string)

func (*SGuestMonitorCollector) GetGuests

func (s *SGuestMonitorCollector) GetGuests() map[string]*SGuestMonitor

type SHostMetricsCollector

type SHostMetricsCollector struct {
	ReportInterval int // seconds

	LastCollectTime time.Time
	// contains filtered or unexported fields
}

func NewHostMetricsCollector

func NewHostMetricsCollector() *SHostMetricsCollector

func (*SHostMetricsCollector) Start

func (m *SHostMetricsCollector) Start()

func (*SHostMetricsCollector) Stop

func (m *SHostMetricsCollector) Stop()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL