Documentation

Overview

Package cpu scans the current CPU usage of the running system.

It includes function for extracting, running and exposing related data. All the parameters controlling the modules are in Config struct. It includes the driver for the module which monitors CPU usage and takes according to the values in the database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CPU

func CPU(status <-chan bool, wg *sync.WaitGroup)

CPU is the driver function of this module for monitor

func GetConfJSON

func GetConfJSON() []byte

GetConfJSON returns the json byte array of the module's config

func GetStatusJSON

func GetStatusJSON() []byte

GetStatusJSON function returns the json string of the cpuInfo struct

func Init

func Init()

Init is the initialization function of the module

func SaveConfig

func SaveConfig(data []byte, profile string) error

SaveConfig save the config of the module to the database

Types

type Config

type Config struct {
	Profile          string
	CPUWarningLimit  int
	RecheckThreshold int
}

Config holds all the necessary parameters required by the module

func LoadConfig

func LoadConfig() *Config

LoadConfig load the config of the module from the db

func (*Config) CPUUsage

func (conf *Config) CPUUsage(stat *Stat) error

CPUUsage sets the current cpu usage to the passed variable pointer

func (Config) Init

func (conf Config) Init() error

Init method is used to initialiase the global variables

type Info

type Info struct {
	Status Status
	Stats  Stat
}

Info holds the information of CPU's status and stats after the scan

func GetStatus

func GetStatus() Info

GetStatus function is getter function for the cpuInfo to send status of cpu monitor

type Stat

type Stat struct {
	CPUUsage int
}

Stat holds the data about the % usage of cpu

type Status

type Status struct {
	Normal bool
}

Status holds the status of the CPU after the scan