Skip to content

Statsmanager Go-API

import "givc/modules/pkgs/statsmanager"

Copyright 2024 TII (SSRC) and the Ghaf contributors SPDX-License-Identifier: Apache-2.0

The statsmanager package provides functionality to manage and retrieve system statistics.

type StatFields int

const (
SysUserTime StatFields = iota
SysNiceTime
SysSystemTime
SysIdleTime
SysIoWaitTime
SysIrq
SysSoftIrq
SysSteal
SysGuest
SysGuestNice
)

type StatPidFields int

const (
ProcParentPid StatPidFields = iota
ProcProcessGroup
ProcSessionId
ProcTtyNumber
ProcTtyProcGroup
ProcFlags
ProcMinorFaults
ProcChildMinorFaults
ProcMajorFaults
ProcChildMajorFaults
ProcUserTime
ProcSysTime
ProcChildUserTime
ProcChildSysTime
ProcPriority
ProcNice
ProcNumThreads
ProcJiffiesToAlrm
ProcStartTime
ProcVmSize
ProcResidentSetSize
)

type StatsController struct {
jiffies uint64
processes map[uint64]process
totals []uint64
}

func NewController() (*StatsController, error)

func (c *StatsController) GetLoadStats(ctx context.Context) (*stats_api.LoadStats, error)

GetLoadStats retrieves load statistics from the system.

func (c *StatsController) GetMemoryStats(ctx context.Context) (*stats_api.MemoryStats, error)

GetMemoryStats retrieves memory statistics from the system.

func (c *StatsController) GetProcessStats(ctx context.Context) (*stats_api.ProcessStats, error)

GetProcessStats retrieves process statistics from the system.

type StatsServer struct {
Controller *StatsController
stats_api.UnimplementedStatsServiceServer
}

func NewStatsServer() (*StatsServer, error)

NewStatsServer creates a new instance of StatsServer with the provided service whitelist and applications.

func (s *StatsServer) GetStats(ctx context.Context, req *stats_api.StatsRequest) (*stats_api.StatsResponse, error)

GetStats handles incoming requests for system statistics.

func (s *StatsServer) Name() string

func (s *StatsServer) RegisterGrpcService(srv *grpc.Server)

type process struct {
name string
state string
values []uint64
}

Generated by gomarkdoc